@sfxcode/formkit-openvue 0.0.0-stage → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +227 -2
  3. package/components.d.ts +1 -0
  4. package/dist/components/FormAutoComplete.vue +100 -0
  5. package/dist/components/FormCascadeSelect.vue +41 -0
  6. package/dist/components/FormCheckbox.vue +49 -0
  7. package/dist/components/FormColorPicker.vue +31 -0
  8. package/dist/components/FormDatePicker.vue +93 -0
  9. package/dist/components/FormInputMask.vue +67 -0
  10. package/dist/components/FormInputNumber.vue +72 -0
  11. package/dist/components/FormInputOtp.vue +40 -0
  12. package/dist/components/FormInputText.vue +63 -0
  13. package/dist/components/FormKitDataDebug.vue +25 -0
  14. package/dist/components/FormKitDataEdit.vue +123 -0
  15. package/dist/components/FormKitDataView.vue +56 -0
  16. package/dist/components/FormKitIcon.vue +23 -0
  17. package/dist/components/FormKitPrefix.vue +9 -0
  18. package/dist/components/FormKitSuffix.vue +9 -0
  19. package/dist/components/FormKnob.vue +48 -0
  20. package/dist/components/FormListbox.vue +482 -0
  21. package/dist/components/FormMultiSelect.vue +68 -0
  22. package/dist/components/FormOutputBoolean.vue +30 -0
  23. package/dist/components/FormOutputDate.vue +40 -0
  24. package/dist/components/FormOutputDuration.vue +24 -0
  25. package/dist/components/FormOutputLink.vue +39 -0
  26. package/dist/components/FormOutputList.vue +105 -0
  27. package/dist/components/FormOutputNumber.vue +47 -0
  28. package/dist/components/FormOutputReference.vue +52 -0
  29. package/dist/components/FormOutputText.vue +52 -0
  30. package/dist/components/FormPassword.vue +47 -0
  31. package/dist/components/FormRadioButton.vue +39 -0
  32. package/dist/components/FormRating.vue +38 -0
  33. package/dist/components/FormSelect.vue +69 -0
  34. package/dist/components/FormSelectButton.vue +42 -0
  35. package/dist/components/FormSlider.vue +40 -0
  36. package/dist/components/FormTextarea.vue +35 -0
  37. package/dist/components/FormToggleButton.vue +40 -0
  38. package/dist/components/FormToggleSwitch.vue +40 -0
  39. package/dist/components/FormTreeSelect.vue +46 -0
  40. package/dist/components/index.d.ts +24 -0
  41. package/dist/components/index.js +167 -0
  42. package/dist/components/index.mjs +48 -0
  43. package/dist/composables/index.d.ts +9 -0
  44. package/dist/composables/index.js +61 -0
  45. package/dist/composables/index.mjs +18 -0
  46. package/dist/composables/useFormInputs.d.ts +3 -0
  47. package/dist/composables/useFormInputs.js +62 -0
  48. package/dist/composables/useFormInputs.mjs +53 -0
  49. package/dist/composables/useFormKitInput.d.ts +11 -0
  50. package/dist/composables/useFormKitInput.js +58 -0
  51. package/dist/composables/useFormKitInput.mjs +45 -0
  52. package/dist/composables/useFormKitRepeater.d.ts +18 -0
  53. package/dist/composables/useFormKitRepeater.js +74 -0
  54. package/dist/composables/useFormKitRepeater.mjs +54 -0
  55. package/dist/composables/useFormKitSchema.d.ts +36 -0
  56. package/dist/composables/useFormKitSchema.js +83 -0
  57. package/dist/composables/useFormKitSchema.mjs +58 -0
  58. package/dist/composables/useFormKitSection.d.ts +7 -0
  59. package/dist/composables/useFormKitSection.js +31 -0
  60. package/dist/composables/useFormKitSection.mjs +19 -0
  61. package/dist/composables/useInputEditor.d.ts +8 -0
  62. package/dist/composables/useInputEditor.js +148 -0
  63. package/dist/composables/useInputEditor.mjs +143 -0
  64. package/dist/composables/useInputEditorSchema.d.ts +163 -0
  65. package/dist/composables/useInputEditorSchema.js +313 -0
  66. package/dist/composables/useInputEditorSchema.mjs +315 -0
  67. package/dist/composables/useOutputDuration.d.ts +4 -0
  68. package/dist/composables/useOutputDuration.js +40 -0
  69. package/dist/composables/useOutputDuration.mjs +35 -0
  70. package/dist/definitions/index.d.ts +35 -0
  71. package/dist/definitions/index.js +44 -0
  72. package/dist/definitions/index.mjs +70 -0
  73. package/dist/definitions/input.d.ts +23 -0
  74. package/dist/definitions/input.js +118 -0
  75. package/dist/definitions/input.mjs +111 -0
  76. package/dist/definitions/output.d.ts +9 -0
  77. package/dist/definitions/output.js +46 -0
  78. package/dist/definitions/output.mjs +136 -0
  79. package/dist/definitions/repeater.d.ts +2 -0
  80. package/dist/definitions/repeater.js +234 -0
  81. package/dist/definitions/repeater.mjs +215 -0
  82. package/dist/index.d.ts +148 -0
  83. package/dist/index.js +62 -0
  84. package/dist/index.mjs +14 -0
  85. package/dist/plugins/autoAnimate.d.ts +9 -0
  86. package/dist/plugins/autoAnimate.js +93 -0
  87. package/dist/plugins/autoAnimate.mjs +87 -0
  88. package/dist/plugins/index.d.ts +5 -0
  89. package/dist/plugins/index.js +67 -0
  90. package/dist/plugins/index.mjs +56 -0
  91. package/dist/sass/formkit-openvue.scss +491 -0
  92. package/dist/style.css +1 -0
  93. package/dist/utils/clonePlain.d.ts +10 -0
  94. package/dist/utils/clonePlain.js +25 -0
  95. package/dist/utils/clonePlain.mjs +24 -0
  96. package/package.json +136 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 sfxcode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
- # Temporary Holding Version
1
+ # FormKit - OpenVue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ OpenVue based [FormKit Inputs](https://sfxcode.github.io/formkit-openvue/guide/inputs.html) for using [FormKit](https://formkit.com/) with the [OpenVue](https://github.com/openvi-foundation/openvue) UI Framework (`openvue`).
4
+
5
+ Main focus of this project is to provide configuration based forms with validation.
6
+
7
+ In addition, you can use the same pattern for **data output** from **schema** using [FormOutputs](https://sfxcode.github.io/formkit-openvue/guide/outputs.html).
8
+
9
+ ## OpenVue Versions
10
+
11
+ Actual OpenVue Version of the main branch is *1.0.0.*
12
+
13
+ This package replaces the former PrimeVue based `@sfxcode/formkit-primevue`. It uses the open source [OpenVue](https://github.com/openvi-foundation/openvue) components (`openvue`, `@openvue/themes`, `@openvue/openicons`) instead of PrimeVue.
14
+
15
+ ## Migration from PrimeVue
16
+
17
+ Migrating from `@sfxcode/formkit-primevue` to `@sfxcode/formkit-openvue`:
18
+
19
+ 1. Replace the package and the UI framework
20
+
21
+ ```bash
22
+ pnpm remove @sfxcode/formkit-primevue primevue @primeuix/themes primeicons
23
+ pnpm add @sfxcode/formkit-openvue openvue @openvue/themes @openvue/openicons
24
+ ```
25
+
26
+ 2. Update the imports (including `/components`, `/composables` and the scss file)
27
+
28
+ ```typescript
29
+ // before
30
+ import { primeInputs, primeOutputs } from '@sfxcode/formkit-primevue'
31
+ // after
32
+ import { formInputs, formOutputs } from '@sfxcode/formkit-openvue'
33
+ ```
34
+
35
+ 3. Rename the input and output types in your schemas: the `prime` prefix is now `form`
36
+
37
+ | PrimeVue | OpenVue |
38
+ |-------------------------------|------------------------------|
39
+ | `type: 'primeInputText'` | `type: 'formInputText'` |
40
+ | `type: 'primeSelect'` | `type: 'formSelect'` |
41
+ | `type: 'primeOutputText'` | `type: 'formOutputText'` |
42
+ | `primeInputs`, `primeOutputs` | `formInputs`, `formOutputs` |
43
+ | `usePrimeInputs()` | `useFormInputs()` |
44
+ | `PrimeInputText` (component) | `FormInputText` (component) |
45
+
46
+ A search and replace of `prime` followed by an uppercase letter (`prime[A-Z]` -> `form`, `Prime[A-Z]` -> `Form`) covers most of it.
47
+
48
+ 4. Replace PrimeVue with OpenVue in your app setup: use the `openvue` components, themes and `@openvue/openicons` (instead of PrimeIcons) and register them as you did with PrimeVue.
49
+
50
+ 5. Update custom CSS: selectors like `[data-type="primeCheckbox"]` become `[data-type="formCheckbox"]`.
51
+
52
+ Also rename the i18n keys `formkit.prime.true` / `formkit.prime.false` to `formkit.form.true` / `formkit.form.false`. If you use `useInputEditor`, its data fields `prime`, `prime_key` and `prime_value` are now `form`, `form_key` and `form_value`. The stylesheet is now `formkit-openvue.scss` (update imports of `dist/sass/formkit-primevue.scss`). Not changed: the `p-formkit` wrapper class.
53
+
54
+ ## Build
55
+
56
+ [![CI](https://github.com/sfxcode/formkit-openvue/actions/workflows/deploy.yml/badge.svg)](https://github.com/sfxcode/formkit-openvue/actions/workflows/deploy.yml)
57
+
58
+ [![Netlify Status](https://api.netlify.com/api/v1/badges/6142cb73-02e0-4b2a-9ca3-25496f59ba9b/deploy-status)](https://app.netlify.com/sites/formkit-openvue/deploys)
59
+
60
+ ## Docs
61
+
62
+ [Docs](https://sfxcode.github.io/formkit-openvue/)
63
+
64
+ [Demo/Playground](https://formkit-openvue.netlify.app/)
65
+
66
+ ## Getting Started
67
+
68
+ Install the latest release of [`@sfxcode/formkit-openvue`](https://www.npmjs.com/package/@sfxcode/formkit-openvue) together with OpenVue:
69
+
70
+ ```bash
71
+ pnpm add @sfxcode/formkit-openvue openvue @openvue/themes @openvue/openicons
72
+ # or: npm install ... / yarn add ...
73
+ ```
74
+
75
+ Set up OpenVue, FormKit and the form inputs in your *main.ts*:
76
+
77
+ ```typescript
78
+ import Aura from '@openvue/themes/aura'
79
+ import { defaultConfig, plugin } from '@formkit/vue'
80
+ import { formInputs, useFormInputs } from '@sfxcode/formkit-openvue'
81
+ import OpenVue from 'openvue/config'
82
+ import { createApp } from 'vue'
83
+ import App from './App.vue'
84
+ import '@openvue/openicons/openicons.css'
85
+ import '@sfxcode/formkit-openvue/dist/style.css'
86
+
87
+ const app = createApp(App)
88
+
89
+ // OpenVue with theme
90
+ app.use(OpenVue, { theme: { preset: Aura } })
91
+
92
+ // register the OpenVue components used by the form inputs
93
+ const { registerInputs } = useFormInputs()
94
+ registerInputs(app)
95
+
96
+ // FormKit with the OpenVue inputs
97
+ app.use(plugin, defaultConfig({ inputs: formInputs }))
98
+
99
+ app.mount('#app')
100
+ ```
101
+
102
+ Use the inputs in a FormKit schema (or as `<FormKit type="formInputText" ... />`):
103
+
104
+ ```vue
105
+ <script setup lang="ts">
106
+ import { ref } from 'vue'
107
+
108
+ const data = ref({ email: '' })
109
+ const schema = [
110
+ { $formkit: 'formInputText', name: 'email', label: 'Email', validation: 'required|email' },
111
+ { $formkit: 'formCheckbox', name: 'newsletter', label: 'Subscribe to the newsletter' },
112
+ ]
113
+ </script>
114
+
115
+ <template>
116
+ <FormKit v-model="data" type="form">
117
+ <FormKitSchema :schema="schema" :data="data" />
118
+ </FormKit>
119
+ </template>
120
+ ```
121
+
122
+ See [Usage](#usage) for outputs, i18n and more configuration.
123
+
124
+ ## Usage
125
+
126
+ ### Configuration
127
+
128
+ Add *formkit.config.ts*
129
+
130
+ ```typescript
131
+ import { defaultConfig, plugin } from '@formkit/vue'
132
+ import { formInputs } from '@sfxcode/formkit-openvue'
133
+
134
+ app.use(plugin, defaultConfig({
135
+ locales: { de, en },
136
+ // Define the active locale
137
+ locale: 'en',
138
+ inputs: formInputs,
139
+ }))
140
+ ```
141
+
142
+ or if using also the output part
143
+
144
+ ```typescript
145
+ import { defaultConfig, plugin } from '@formkit/vue'
146
+ import { formInputs, formOutputs } from '@sfxcode/formkit-openvue'
147
+
148
+ app.use(plugin, defaultConfig({
149
+ locales: { de, en },
150
+ // Define the active locale
151
+ locale: 'en',
152
+ inputs: { ...formInputs, ...formOutputs },
153
+ }))
154
+ ```
155
+
156
+ Important: output elements depends on vue-i18n to style numbers, dates, ...
157
+
158
+ ## Limitations
159
+
160
+ Prefixing of the OpenVue component names is not supported.
161
+
162
+ ### Schema Helper Functions
163
+
164
+ [useFormKitSchema](https://github.com/sfxcode/formkit-openvue/blob/main/src/composables/useFormKitSchema.ts) provide functions to simplify the usage of elements, components, lists, ...
165
+
166
+ [useInputEditorSchema](https://github.com/sfxcode/formkit-openvue/blob/main/src/composables/useInputEditorSchema.ts) provide functions for a component schema generation builder
167
+
168
+ ### Basic Styling
169
+
170
+ Basic styling is provided with the [formkit-openvue.scss](https://github.com/sfxcode/formkit-openvue/blob/main/src/sass/formkit-openvue.scss) file or the corresponding css file in the package.
171
+
172
+ Features:
173
+
174
+ - Width of all text and dropdown elements is set to 100%
175
+ - Error Color by variable (--formkit-error-color)
176
+ - Some margins, font sizes ...
177
+
178
+ You can use it or take it as base for your own styling.
179
+
180
+ ### Extended Styling
181
+
182
+ - Styling outerClas, innerClass .... is provided by FormKit
183
+ - All inputs, outputs are wrapped in a div with a **p-formkit** class
184
+ - Most of the OpenVue Input Components have access to class / styles attributes
185
+ - PT and PTOptions are available (pass-through API of OpenVue components)
186
+ - [Styling](https://formkit-openvue.netlify.app/styling/base) and [PT](https://formkit-openvue.netlify.app/styling/passThrough) demo available
187
+ - [Grid](https://formkit-openvue.netlify.app/styling/grid) Demo of the provided grid styling (col-[1-12])
188
+
189
+ ### Samples
190
+
191
+ Some samples for common tasks are available
192
+
193
+ - [Repeater](https://formkit-openvue.netlify.app/samples/repeater) Use Repeater composable for using repeating values in your schema
194
+ - [Input Editor](https://formkit-openvue.netlify.app/samples/inputEditor) Edit FormKit schema on the based on a provided composable
195
+ - [Form Editor](https://formkit-openvue.netlify.app/samples/formEditor) Basic demo as starter to create Forms visually
196
+
197
+ ## Showcases
198
+
199
+ [Demo Application](https://formkit-openvue.netlify.app/)
200
+
201
+ ## Supported Inputs for OpenVue
202
+
203
+ - AutoComplete
204
+ - CascadeSelect
205
+ - Checkbox
206
+ - ColorPicker
207
+ - DatePicker
208
+ - Editor (HTML Editor - if you register the editor component, make sure to import quill)
209
+ - InputMask
210
+ - InputNumber
211
+ - InputOtp
212
+ - InputText
213
+ - Knob
214
+ - Listbox
215
+ - MultiSelect
216
+ - Password
217
+ - RadioButton
218
+ - Rating
219
+ - Repeater (not an OpenVue component, but provided as helper for repeating groups of inputs)
220
+ - Select
221
+ - SelectButton
222
+ - Slider
223
+ - Textarea
224
+ - ToggleButton
225
+ - ToggleSwitch
226
+ - TreeSelect
227
+
228
+ ![](formkit-primevue.png)
@@ -0,0 +1 @@
1
+ export * from './dist/components'
@@ -0,0 +1,100 @@
1
+ <script setup>
2
+ import { ref } from "vue";
3
+ import { useFormKitInput } from "../composables";
4
+ const props = defineProps({ context: {
5
+ type: Object,
6
+ required: true
7
+ } });
8
+ const { validSlotNames, unstyled, isInvalid, handleInput, handleBlur, modelValue } = useFormKitInput(props.context);
9
+ const suggestions = ref(["", {}]);
10
+ suggestions.value = [];
11
+ const loading = ref(false);
12
+ /**
13
+ * Searches for suggestions based on the input query.
14
+ */
15
+ async function search(event) {
16
+ if (props.context?.options && props.context?.optionLabel) {
17
+ suggestions.value = props.context.options.filter((option) => {
18
+ return option[`${props.context.optionLabel}`].toString().toLowerCase().includes(event.query.toLowerCase());
19
+ });
20
+ } else {
21
+ loading.value = true;
22
+ try {
23
+ suggestions.value = await props.context?.attrs.complete(event.query);
24
+ } catch (error) {
25
+ console.error("Error fetching suggestions:", error);
26
+ suggestions.value = [];
27
+ } finally {
28
+ loading.value = false;
29
+ }
30
+ }
31
+ }
32
+ /**
33
+ * Handles paste event to transform a string separated by any of the provided separators into multiple items.
34
+ */
35
+ function handlePaste(event) {
36
+ if (!props.context?.multiple) return;
37
+ const clipboardData = event.clipboardData;
38
+ if (!clipboardData) return;
39
+ const pastedText = clipboardData.getData("text");
40
+ const separators = Array.isArray(props.context?.separators) && props.context.separators.length > 0 ? props.context.separators : [","];
41
+ const regex = new RegExp(`[${separators.map((s) => s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")).join("")}]`);
42
+ // If separators are provided, split the pasted text by them
43
+ if (pastedText && regex.test(pastedText)) {
44
+ event.preventDefault();
45
+ const items = pastedText.split(regex).map((item) => item.trim()).filter((item) => item.length > 0);
46
+ // Use a local ref, never mutate context._value directly
47
+ if (Array.isArray(modelValue.value)) {
48
+ modelValue.value = [...modelValue.value, ...items];
49
+ } else {
50
+ modelValue.value = items;
51
+ }
52
+ } else if (pastedText) {
53
+ event.preventDefault();
54
+ // If no separators, just set the value directly
55
+ if (Array.isArray(modelValue.value)) {
56
+ modelValue.value = [...modelValue.value, pastedText.trim()];
57
+ } else {
58
+ modelValue.value = [pastedText.trim()];
59
+ }
60
+ }
61
+ }
62
+ </script>
63
+
64
+ <template>
65
+ <div class="p-formkit">
66
+ <AutoComplete
67
+ :id="context.id"
68
+ v-model="modelValue"
69
+ v-bind="context?.attrs"
70
+ :disabled="!!context?.disabled"
71
+ :class="context?.attrs?.class"
72
+ :invalid="isInvalid"
73
+ :tabindex="context?.attrs.tabindex"
74
+ :aria-label="context?.attrs.ariaLabel"
75
+ :aria-labelledby="context?.attrs.ariaLabelledby"
76
+ :size="context?.size ?? undefined"
77
+ :suggestions="suggestions"
78
+ :option-label="context?.optionLabel"
79
+ :dropdown="context?.dropdown ?? false"
80
+ :multiple="context?.multiple ?? false"
81
+ :typeahead="context?.typeahead ?? true"
82
+ :min-length="context?.minLength ?? undefined"
83
+ :placeholder="context?.placeholder ?? undefined"
84
+ :fluid="context?.fluid ?? undefined"
85
+ :pt="context?.pt"
86
+ :pt-options="context?.ptOptions"
87
+ :unstyled="unstyled"
88
+ :loading="loading"
89
+ @keydown.enter.prevent
90
+ @complete="search"
91
+ @change="handleInput"
92
+ @blur="handleBlur"
93
+ @paste="handlePaste"
94
+ >
95
+ <template v-for="slotName in validSlotNames" :key="slotName" #[slotName]="slotProps">
96
+ <component :is="context?.slots[slotName]" v-bind="{ ...context, ...slotProps }" />
97
+ </template>
98
+ </AutoComplete>
99
+ </div>
100
+ </template>
@@ -0,0 +1,41 @@
1
+ <script setup>
2
+ import { useFormKitInput } from "../composables";
3
+ const props = defineProps({ context: {
4
+ type: Object,
5
+ required: true
6
+ } });
7
+ const { validSlotNames, unstyled, isInvalid, handleInput, handleBlur, modelValue } = useFormKitInput(props.context);
8
+ </script>
9
+
10
+ <template>
11
+ <div class="p-formkit">
12
+ <CascadeSelect
13
+ :id="context.id"
14
+ v-model="modelValue"
15
+ v-bind="context?.attrs"
16
+ :disabled="!!context?.disabled"
17
+ :readonly="context?.attrs.readonly ?? false"
18
+ :class="context?.attrs?.class"
19
+ :invalid="isInvalid"
20
+ :tabindex="context?.attrs.tabindex"
21
+ :aria-label="context?.attrs.ariaLabel"
22
+ :aria-labelledby="context?.attrs.ariaLabelledby"
23
+ :size="context?.size ?? undefined"
24
+ :options="context?.options"
25
+ :option-label="context?.optionLabel"
26
+ :option-value="context.optionValue"
27
+ :option-group-label="context.optionGroupLabel"
28
+ :option-group-children="context.optionGroupChildren"
29
+ :placeholder="context.placeholder"
30
+ :pt="context.pt"
31
+ :pt-options="context.ptOptions"
32
+ :unstyled="unstyled"
33
+ @change="handleInput"
34
+ @blur="handleBlur"
35
+ >
36
+ <template v-for="slotName in validSlotNames" :key="slotName" #[slotName]="slotProps">
37
+ <component :is="context?.slots[slotName]" v-bind="{ ...context, ...slotProps }" />
38
+ </template>
39
+ </CascadeSelect>
40
+ </div>
41
+ </template>
@@ -0,0 +1,49 @@
1
+ <script setup>
2
+ import { useFormKitInput, useFormKitSection } from "../composables";
3
+ const props = defineProps({ context: {
4
+ type: Object,
5
+ required: true
6
+ } });
7
+ const { hasPrefix, hasSuffix, generateId } = useFormKitSection(props.context);
8
+ const { validSlotNames, unstyled, isInvalid, handleInput, handleBlur, modelValue } = useFormKitInput(props.context);
9
+ const generatedId = generateId();
10
+ </script>
11
+
12
+ <template>
13
+ <div class="p-formkit">
14
+ <label v-if="hasPrefix" :for="generatedId" class="formkit-prefix">
15
+ {{ context?.prefix }}
16
+ </label>
17
+ <Checkbox
18
+ v-model="modelValue"
19
+ v-bind="context?.attrs"
20
+ :input-id="generatedId"
21
+ :disabled="!!context?.disabled"
22
+ :readonly="context?.attrs.readonly ?? false"
23
+ :input-style="context?.attrs.style"
24
+ :input-class="context?.attrs?.class"
25
+ :invalid="isInvalid"
26
+ :tabindex="context?.attrs.tabindex"
27
+ :aria-label="context?.attrs.ariaLabel"
28
+ :aria-labelledby="context?.attrs.ariaLabelledby"
29
+ :size="context?.size ?? undefined"
30
+ :indeterminate="context.indeterminate ?? undefined"
31
+ :binary="context.binary ?? true"
32
+ :variant="context.variant ?? 'outlined'"
33
+ :true-value="context.trueValue ?? undefined"
34
+ :false-value="context.falseValue ?? undefined"
35
+ :pt="context.pt"
36
+ :pt-options="context.ptOptions"
37
+ :unstyled="unstyled"
38
+ @change="handleInput"
39
+ @blur="handleBlur"
40
+ >
41
+ <template v-for="slotName in validSlotNames" :key="slotName" #[slotName]="slotProps">
42
+ <component :is="context?.slots[slotName]" v-bind="{ ...context, ...slotProps }" />
43
+ </template>
44
+ </Checkbox>
45
+ <label v-if="hasSuffix" :for="generatedId" class="formkit-suffix">
46
+ {{ context?.suffix }}
47
+ </label>
48
+ </div>
49
+ </template>
@@ -0,0 +1,31 @@
1
+ <script setup>
2
+ import { useFormKitInput } from "../composables";
3
+ const props = defineProps({ context: {
4
+ type: Object,
5
+ required: true
6
+ } });
7
+ const { unstyled, handleChange, modelValue } = useFormKitInput(props.context);
8
+ </script>
9
+
10
+ <template>
11
+ <div class="p-formkit">
12
+ <ColorPicker
13
+ v-model="modelValue"
14
+ v-bind="context?.attrs"
15
+ :disabled="!!context?.disabled"
16
+ :readonly="context?.attrs.readonly ?? false"
17
+ :style="context?.attrs.style"
18
+ :panel-class="context?.attrs.class"
19
+ :tabindex="context?.attrs.tabindex"
20
+ :aria-label="context?.attrs.ariaLabel"
21
+ :aria-labelledby="context?.attrs.ariaLabelledby"
22
+ :default-color="context.defaultColor ?? 'ff0000'"
23
+ :inline="context.inline ?? false"
24
+ :format="context.format"
25
+ :pt="context.pt"
26
+ :pt-options="context.ptOptions"
27
+ :unstyled="unstyled"
28
+ @change="handleChange"
29
+ />
30
+ </div>
31
+ </template>
@@ -0,0 +1,93 @@
1
+ <script setup>
2
+ import { useFormKitInput } from "../composables";
3
+ const props = defineProps({ context: {
4
+ type: Object,
5
+ required: true
6
+ } });
7
+ const { validSlotNames, unstyled, isInvalid, handleInput, modelValue } = useFormKitInput(props.context);
8
+ function handleBlur(e) {
9
+ props.context?.handlers.blur(e.originalEvent);
10
+ }
11
+ function handleClearClick() {
12
+ props.context?.node.input(null);
13
+ }
14
+ function handleSelect(e) {
15
+ if (props.context?.selectionMode === "range" || props.context?.selectionMode === "multiple") {
16
+ props.context?.node.input(props.context._value);
17
+ } else {
18
+ props.context?.node.input(e);
19
+ }
20
+ }
21
+ </script>
22
+
23
+ <template>
24
+ <div class="p-formkit">
25
+ <DatePicker
26
+ v-model="modelValue"
27
+ v-bind="context?.attrs"
28
+ :input-id="context.id"
29
+ :disabled="!!context?.disabled"
30
+ :readonly="context?.attrs.readonly ?? false"
31
+ :input-style="context?.attrs.style"
32
+ :input-class="context?.attrs?.class"
33
+ :invalid="isInvalid"
34
+ :tabindex="context?.attrs.tabindex"
35
+ :aria-label="context?.attrs.ariaLabel"
36
+ :aria-labelledby="context?.attrs.ariaLabelledby"
37
+ :size="context?.size ?? undefined"
38
+ :date-format="context?.dateFormat"
39
+ :placeholder="context?.placeholder"
40
+ :selection-mode="context?.selectionMode ?? 'single'"
41
+ :inline="context?.inline ?? false"
42
+ :show-other-months="context?.showOtherMonths ?? true"
43
+ :select-other-months="context?.selectOtherMonths ?? false"
44
+ :icon="context?.icon"
45
+ :show-icon="context.showIcon"
46
+ :previous-icon="context?.previousIcon"
47
+ :next-icon="context?.nextIcon"
48
+ :increment-icon="context?.incrementIcon"
49
+ :decrement-icon="context?.decrementIcon"
50
+ :number-of-months="context?.numberOfMonths ?? 1"
51
+ :responsive-options="context?.responsiveOptions"
52
+ :view="context?.view ?? 'date'"
53
+ :touch-u-i="context?.touchUI ?? false"
54
+ :min-date="context?.minDate"
55
+ :max-date="context?.maxDate"
56
+ :disabled-dates="context?.disabledDates"
57
+ :disabled-days="context?.disabledDays"
58
+ :max-date-count="context?.maxDateCount"
59
+ :show-on-focus="context?.showOnFocus ?? true"
60
+ :auto-z-index="context?.autoZIndex ?? true"
61
+ :base-z-index="context?.baseZIndex ?? 0"
62
+ :show-button-bar="context?.showButtonBar ?? false"
63
+ :show-time="context?.showTime ?? false"
64
+ :time-only="context?.timeOnly ?? false"
65
+ :short-year-cutoff="context?.shortYearCutoff ?? '+10'"
66
+ :hour-format="context?.hourFormat ?? '24'"
67
+ :step-hour="context?.stepHour ?? 1"
68
+ :step-minute="context?.stepMinute ?? 1"
69
+ :step-second="context?.stepSecond ?? 1"
70
+ :show-seconds="context?.showSeconds ?? false"
71
+ :hide-on-date-time-select="context?.hideOnDateTimeSelect ?? false"
72
+ :hide-on-range-selection="context?.hideOnRangeSelection ?? false"
73
+ :time-separator="context?.timeSeparator ?? ':'"
74
+ :show-week="context?.showWeek ?? false"
75
+ :manual-input="context?.manualInput ?? true"
76
+ :append-to="context?.appendTo ?? 'body'"
77
+ :panel-style="context?.panelStyle"
78
+ :panel-class="context?.panelClass"
79
+ :pt="context?.pt"
80
+ :pt-options="context?.ptOptions"
81
+ :unstyled="unstyled"
82
+ :update-model-type="context?.updateModelType ?? 'date'"
83
+ @date-select="handleSelect"
84
+ @blur="handleBlur"
85
+ @clear-click="handleClearClick"
86
+ @value-change="handleInput"
87
+ >
88
+ <template v-for="slotName in validSlotNames" :key="slotName" #[slotName]="slotProps">
89
+ <component :is="context?.slots[slotName]" v-bind="{ ...context, ...slotProps }" />
90
+ </template>
91
+ </DatePicker>
92
+ </div>
93
+ </template>
@@ -0,0 +1,67 @@
1
+ <script setup>
2
+ import IconField from "openvue/iconfield";
3
+ import InputIcon from "openvue/inputicon";
4
+ import { useFormKitInput, useFormKitSection } from "../composables";
5
+ const props = defineProps({ context: {
6
+ type: Object,
7
+ required: true
8
+ } });
9
+ const { unstyled, isInvalid, handleInput, handleBlur, modelValue } = useFormKitInput(props.context);
10
+ const { hasPrefixIcon, hasSuffixIcon } = useFormKitSection(props.context);
11
+ </script>
12
+
13
+ <template>
14
+ <div class="p-formkit">
15
+ <IconField v-if="hasPrefixIcon || hasSuffixIcon">
16
+ <InputIcon v-if="hasPrefixIcon" :class="context?.iconPrefix" />
17
+ <InputMask
18
+ :id="context.id"
19
+ v-model="modelValue"
20
+ v-bind="context?.attrs"
21
+ :disabled="!!context?.disabled"
22
+ :readonly="context?.attrs.readonly ?? false"
23
+ :class="context?.attrs?.class"
24
+ :invalid="isInvalid"
25
+ :tabindex="context?.attrs.tabindex"
26
+ :aria-label="context?.attrs.ariaLabel"
27
+ :aria-labelledby="context?.attrs.ariaLabelledby"
28
+ :size="context?.size ?? undefined"
29
+ :mask="context.mask ?? undefined"
30
+ :slot-char="context.slotChar ?? '_'"
31
+ :auto-clear="context.autoClear ?? true"
32
+ :unmask="context.unmask ?? false"
33
+ :pt="context.pt"
34
+ :variant="context.variant"
35
+ :pt-options="context.ptOptions"
36
+ :unstyled="unstyled"
37
+ @update:model-value="handleInput"
38
+ @blur="handleBlur"
39
+ />
40
+ <InputIcon v-if="hasSuffixIcon" :class="context?.iconSuffix" />
41
+ </IconField>
42
+ <InputMask
43
+ v-if="!hasPrefixIcon && !hasSuffixIcon"
44
+ :id="context.id"
45
+ v-model="modelValue"
46
+ v-bind="context?.attrs"
47
+ :disabled="!!context?.disabled"
48
+ :readonly="context?.attrs.readonly ?? false"
49
+ :class="context?.attrs?.class"
50
+ :invalid="isInvalid"
51
+ :tabindex="context?.attrs.tabindex"
52
+ :aria-label="context?.attrs.ariaLabel"
53
+ :aria-labelledby="context?.attrs.ariaLabelledby"
54
+ :size="context?.size ?? undefined"
55
+ :mask="context.mask ?? undefined"
56
+ :slot-char="context.slotChar ?? '_'"
57
+ :auto-clear="context.autoClear ?? true"
58
+ :unmask="context.unmask ?? false"
59
+ :pt="context.pt"
60
+ :variant="context.variant"
61
+ :pt-options="context.ptOptions"
62
+ :unstyled="unstyled"
63
+ @update:model-value="handleInput"
64
+ @blur="handleBlur"
65
+ />
66
+ </div>
67
+ </template>