@sfxcode/formkit-openvue 0.0.0-stage → 0.8.1

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 (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -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 +179 -0
  81. package/dist/definitions/repeater.mjs +168 -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/index.d.ts +3 -0
  86. package/dist/plugins/index.js +60 -0
  87. package/dist/plugins/index.mjs +55 -0
  88. package/dist/sass/formkit-openvue.scss +460 -0
  89. package/dist/style.css +1 -0
  90. package/package.json +148 -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,170 @@
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 `primeAttributes` prop to `formAttributes` (`prime-attributes` to `form-attributes` in templates). Rename the i18n keys `formkit.prime.true` / `formkit.prime.false` to `formkit.form.true` / `formkit.form.false`. Not changed: the `p-formkit` wrapper class. The stylesheet is now `formkit-openvue.scss` (update imports of `dist/sass/formkit-primevue.scss`).
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
+ ## Usage
67
+
68
+ ### Configuration
69
+
70
+ Add *formkit.config.ts*
71
+
72
+ ```typescript
73
+ import { defaultConfig, plugin } from '@formkit/vue'
74
+ import { formInputs } from '@sfxcode/formkit-openvue'
75
+
76
+ app.use(plugin, defaultConfig({
77
+ locales: { de, en },
78
+ // Define the active locale
79
+ locale: 'en',
80
+ inputs: formInputs,
81
+ }))
82
+ ```
83
+
84
+ or if using also the output part
85
+
86
+ ```typescript
87
+ import { defaultConfig, plugin } from '@formkit/vue'
88
+ import { formInputs, formOutputs } from '@sfxcode/formkit-openvue'
89
+
90
+ app.use(plugin, defaultConfig({
91
+ locales: { de, en },
92
+ // Define the active locale
93
+ locale: 'en',
94
+ inputs: { ...formInputs, ...formOutputs },
95
+ }))
96
+ ```
97
+
98
+ Important: output elements depends on vue-i18n to style numbers, dates, ...
99
+
100
+ ## Limitations
101
+
102
+ Prefixing of the OpenVue component names is not supported.
103
+
104
+ ### Schema Helper Functions
105
+
106
+ [useFormKitSchema](https://github.com/sfxcode/formkit-openvue/blob/main/src/composables/useFormKitSchema.ts) provide functions to simplify the usage of elements, components, lists, ...
107
+
108
+ [useInputEditorSchema](https://github.com/sfxcode/formkit-openvue/blob/main/src/composables/useInputEditorSchema.ts) provide functions for a component schema generation builder
109
+
110
+ ### Basic Styling
111
+
112
+ 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.
113
+
114
+ Features:
115
+
116
+ - Width of all text and dropdown elements is set to 100%
117
+ - Error Color by variable (--formkit-error-color)
118
+ - Some margins, font sizes ...
119
+
120
+ You can use it or take it as base for your own styling.
121
+
122
+ ### Extended Styling
123
+
124
+ - Styling outerClas, innerClass .... is provided by FormKit
125
+ - All inputs, outputs are wrapped in a div with a **p-formkit** class
126
+ - Most of the OpenVue Input Components have access to class / styles attributes
127
+ - PT and PTOptions are available (pass-through API of OpenVue components)
128
+ - [Styling](https://formkit-openvue.netlify.app/styling/base) and [PT](https://formkit-openvue.netlify.app/styling/passThrough) demo available
129
+ - [Grid](https://formkit-openvue.netlify.app/styling/grid) Demo of the provided grid styling (col-[1-12])
130
+
131
+ ### Samples
132
+
133
+ Some samples for common tasks are available
134
+
135
+ - [Repeater](https://formkit-openvue.netlify.app/samples/repeater) Use Repeater composable for using repeating values in your schema
136
+ - [Input Editor](https://formkit-openvue.netlify.app/samples/inputEditor) Edit FormKit schema on the based on a provided composable
137
+ - [Form Editor](https://formkit-openvue.netlify.app/samples/formEditor) Basic demo as starter to create Forms visually
138
+
139
+ ## Showcases
140
+
141
+ [Demo Application](https://formkit-openvue.netlify.app/)
142
+
143
+ ## Supported Inputs for OpenVue
144
+
145
+ - AutoComplete
146
+ - CascadeSelect
147
+ - Checkbox
148
+ - ColorPicker
149
+ - DatePicker
150
+ - Editor (HTML Editor - if you register the editor component, make sure to import quill)
151
+ - InputMask
152
+ - InputNumber
153
+ - InputOtp
154
+ - InputText
155
+ - Knob
156
+ - Listbox
157
+ - MultiSelect
158
+ - Password
159
+ - RadioButton
160
+ - Rating
161
+ - Repeater (not an OpenVue component, but provided as helper for repeating groups of inputs)
162
+ - Select
163
+ - SelectButton
164
+ - Slider
165
+ - Textarea
166
+ - ToggleButton
167
+ - ToggleSwitch
168
+ - TreeSelect
169
+
170
+ ![](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>
@@ -0,0 +1,72 @@
1
+ <script setup>
2
+ import { watch } from "vue";
3
+ import { useFormKitInput } from "../composables";
4
+ const props = defineProps({ context: {
5
+ type: Object,
6
+ required: true
7
+ } });
8
+ const { validSlotNames, unstyled, isInvalid, modelValue } = useFormKitInput(props.context);
9
+ function handleBlur(e) {
10
+ props.context?.handlers.blur(e.originalEvent);
11
+ }
12
+ function handleInput(_) {
13
+ if (typeof _.value === "number" || _.value === null) props.context?.node.input(_.value);
14
+ }
15
+ function roundToDecimals(value, decimals) {
16
+ const factor = 10 ** decimals;
17
+ return Math.round(value * factor) / factor;
18
+ }
19
+ watch(() => props.context._value, (newValue) => {
20
+ // Only update if the value is different
21
+ if (newValue !== props.context.node.value && typeof newValue === "number") {
22
+ if (props.context.maxFractionDigits && props.context.maxFractionDigits > 0) {
23
+ // fix floating-point precision issues
24
+ props.context?.node.input(roundToDecimals(newValue, props.context.maxFractionDigits));
25
+ } else {
26
+ props.context?.node.input(newValue);
27
+ }
28
+ }
29
+ });
30
+ </script>
31
+
32
+ <template>
33
+ <div class="p-formkit">
34
+ <InputNumber
35
+ v-model="modelValue"
36
+ v-bind="context?.attrs"
37
+ :input-id="context.id"
38
+ :disabled="!!context?.disabled"
39
+ :readonly="context?.attrs.readonly ?? false"
40
+ :input-style="context?.attrs.style"
41
+ :input-class="context?.attrs?.class"
42
+ :invalid="isInvalid"
43
+ :tabindex="context?.attrs.tabindex"
44
+ :aria-label="context?.attrs.ariaLabel"
45
+ :aria-labelledby="context?.attrs.ariaLabelledby"
46
+ :size="context?.size ?? undefined"
47
+ :placeholder="context.placeholder"
48
+ :use-grouping="context.useGrouping ?? true"
49
+ :min="context.min ?? undefined"
50
+ :max="context.max ?? undefined"
51
+ :min-fraction-digits="context.minFractionDigits ?? undefined"
52
+ :max-fraction-digits="context.maxFractionDigits ?? undefined"
53
+ :locale="context.locale ?? undefined"
54
+ :mode="context.mode ?? undefined"
55
+ :currency="context.currency ?? undefined"
56
+ :prefix="context.prefix ?? undefined"
57
+ :suffix="context.suffix ?? undefined"
58
+ :show-buttons="context.showButtons ?? undefined"
59
+ :button-layout="context.buttonLayout ?? 'stacked'"
60
+ :step="context.step ?? undefined"
61
+ :pt="context.pt"
62
+ :pt-options="context.ptOptions"
63
+ :unstyled="unstyled"
64
+ @input="handleInput"
65
+ @blur="handleBlur"
66
+ >
67
+ <template v-for="slotName in validSlotNames" :key="slotName" #[slotName]="slotProps">
68
+ <component :is="context?.slots[slotName]" v-bind="{ ...context, ...slotProps }" />
69
+ </template>
70
+ </InputNumber>
71
+ </div>
72
+ </template>