diff --git a/formkit.config.ts b/formkit.config.ts index 5694671..2d2b570 100644 --- a/formkit.config.ts +++ b/formkit.config.ts @@ -1,6 +1,6 @@ import { form } from '@/__fk-inputs__/inputs/form'; -import { PInputPassword } from '@/__fk-inputs__/inputs/input-password'; -import { PInputText } from '@/__fk-inputs__/inputs/input-text'; +import { PInputPassword } from '@/__fk-inputs__/inputs/p-input-password'; +import { PInputText } from '@/__fk-inputs__/inputs/p-input-text'; import { createAutoAnimatePlugin, createAutoHeightTextareaPlugin } from '@formkit/addons'; import { autoAnimatePlugin } from '@formkit/auto-animate/vue'; import type { FormKitOptions, FormKitPlugin } from '@formkit/core'; @@ -13,6 +13,7 @@ import { /* defaultConfig, */ bindings, plugin /* defaultConfig */ } from '@form import type { App } from 'vue'; import { addAsteriskPlugin } from './formkit.config.plugin.addAsteriskPlugin'; import { debugPlugin } from './formkit.config.plugin.debug'; +import { PSelect } from '@/__fk-inputs__/inputs/p-select'; const plugins: FormKitPlugin[] = [ // createProPlugin(apiKey, { toggle }), @@ -26,6 +27,7 @@ const plugins: FormKitPlugin[] = [ form, PInputText, PInputPassword, + PSelect, }), // createLibraryPlugin( // { diff --git a/src/App.vue b/src/App.vue index 1ae1d90..48efca0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,12 +1,35 @@ diff --git a/src/__fk-inputs__/inputs/input-password.ts b/src/__fk-inputs__/inputs/p-input-password.ts similarity index 96% rename from src/__fk-inputs__/inputs/input-password.ts rename to src/__fk-inputs__/inputs/p-input-password.ts index 1ca5bb6..1b73b4e 100644 --- a/src/__fk-inputs__/inputs/input-password.ts +++ b/src/__fk-inputs__/inputs/p-input-password.ts @@ -12,11 +12,9 @@ const input = createSection('input', () => ({ props: { invalid: '$state.invalid', disabled: '$disabled', - // name: '$node.name', - // inputProps: {} + modelValue: '$_value', onInput: '$handlers.DOMInput', onBlur: '$handlers.blur', - modelValue: '$_value', inputId: '$id', fluid: true, }, diff --git a/src/__fk-inputs__/inputs/input-text.ts b/src/__fk-inputs__/inputs/p-input-text.ts similarity index 100% rename from src/__fk-inputs__/inputs/input-text.ts rename to src/__fk-inputs__/inputs/p-input-text.ts index 62c656e..7b9e696 100644 --- a/src/__fk-inputs__/inputs/input-text.ts +++ b/src/__fk-inputs__/inputs/p-input-text.ts @@ -14,9 +14,9 @@ const input = createSection('input', () => ({ type: '$type', disabled: '$disabled', name: '$node.name', + modelValue: '$_value', onInput: '$handlers.DOMInput', onBlur: '$handlers.blur', - modelValue: '$_value', id: '$id', fluid: true, }, diff --git a/src/__fk-inputs__/inputs/p-select.ts b/src/__fk-inputs__/inputs/p-select.ts new file mode 100644 index 0000000..eda5f1d --- /dev/null +++ b/src/__fk-inputs__/inputs/p-select.ts @@ -0,0 +1,45 @@ +import type { FormKitTypeDefinition } from '@formkit/core'; +import type { FormKitInputs } from '@formkit/inputs'; +import { createSection, label, outer } from '@formkit/inputs'; +import SchemaComponent from 'primevue/select'; +import { markRaw } from 'vue'; +import { floatLabel } from '../sections/floatLabel'; +import { messages } from '../sections/messages'; + +const input = createSection('input', () => ({ + $cmp: markRaw(SchemaComponent) as never, + bind: '$attrs', + props: { + invalid: '$state.invalid', + disabled: '$disabled', + modelValue: '$_value', + // onValueChange: '$handlers.DOMInput', + onBlur: '$handlers.blur', + id: '$id', + fluid: true, + options: '$options', + }, +})); + +export const PSelect: FormKitTypeDefinition = { + type: 'input', + schema: outer( + floatLabel( + input(), // + label('$label'), + ), + messages(), + ), + props: ['options'], + // schemaMemoKey: 'nnvujvlf2xr', // Math.random().toString(36).substring(2, 15) +}; + +declare module '@formkit/inputs' { + // https://formkit.com/essentials/custom-inputs#typescript-support + interface FormKitInputProps> { + PSelect: { + type: 'PSelect'; + options: Array; + }; + } +} diff --git a/src/all-custom/all-custom.vue b/src/all-custom/all-custom.vue index 548edae..2c9af68 100644 --- a/src/all-custom/all-custom.vue +++ b/src/all-custom/all-custom.vue @@ -1,6 +1,6 @@