@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
@@ -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>
@@ -0,0 +1,40 @@
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, handleBlur, handleInput, modelValue } = useFormKitInput(props.context);
8
+ </script>
9
+
10
+ <template>
11
+ <div class="p-formkit">
12
+ <InputOtp
13
+ :id="context.id"
14
+ v-model="modelValue"
15
+ v-bind="context?.attrs"
16
+ :disabled="!!context?.disabled"
17
+ :readonly="context?.attrs.readonly ?? false"
18
+ :style="context?.attrs.style"
19
+ :class="context?.attrs?.class"
20
+ :invalid="isInvalid"
21
+ :tabindex="context?.attrs.tabindex"
22
+ :aria-label="context?.attrs.ariaLabel"
23
+ :aria-labelledby="context?.attrs.ariaLabelledby"
24
+ :size="context?.size ?? undefined"
25
+ :length="context.length"
26
+ :variant="context.variant"
27
+ :mask="context.mask"
28
+ :integer-only="context.integerOnly"
29
+ :pt="context.pt"
30
+ :pt-options="context.ptOptions"
31
+ :unstyled="unstyled"
32
+ @change="handleInput"
33
+ @blur="handleBlur"
34
+ >
35
+ <template v-for="slotName in validSlotNames" :key="slotName" #[slotName]="slotProps">
36
+ <component :is="context?.slots[slotName]" v-bind="{ ...context, ...slotProps }" />
37
+ </template>
38
+ </InputOtp>
39
+ </div>
40
+ </template>
@@ -0,0 +1,63 @@
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
+ <InputText
18
+ :id="context.id"
19
+ v-model="modelValue"
20
+ v-bind="context?.attrs"
21
+ :type="context?.attrs?.inputType ?? 'text'"
22
+ :disabled="!!context?.disabled"
23
+ :readonly="context?.attrs.readonly ?? false"
24
+ :style="context?.attrs?.style"
25
+ :class="context?.attrs?.class"
26
+ :invalid="isInvalid"
27
+ :tabindex="context?.attrs.tabindex"
28
+ :aria-label="context?.attrs.ariaLabel"
29
+ :aria-labelledby="context?.attrs.ariaLabelledby"
30
+ :size="context?.size ?? undefined"
31
+ :placeholder="context.placeholder"
32
+ :pt="context.pt"
33
+ :pt-options="context.ptOptions"
34
+ :unstyled="unstyled"
35
+ @input="handleInput"
36
+ @blur="handleBlur"
37
+ />
38
+ <InputIcon v-if="hasSuffixIcon" :class="context?.iconSuffix" />
39
+ </IconField>
40
+ <InputText
41
+ v-if="!hasPrefixIcon && !hasSuffixIcon"
42
+ :id="context.id"
43
+ v-model="modelValue"
44
+ v-bind="context?.attrs"
45
+ :type="context?.inputType ?? 'text'"
46
+ :disabled="!!context?.disabled"
47
+ :readonly="context?.attrs.readonly ?? false"
48
+ :style="context?.attrs.style"
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
+ :placeholder="context.placeholder"
56
+ :pt="context.pt"
57
+ :pt-options="context.ptOptions"
58
+ :unstyled="unstyled"
59
+ @input="handleInput"
60
+ @blur="handleBlur"
61
+ />
62
+ </div>
63
+ </template>
@@ -0,0 +1,25 @@
1
+ <script setup>
2
+ defineProps({
3
+ data: {
4
+ type: [
5
+ Object,
6
+ Array,
7
+ String,
8
+ Number,
9
+ Boolean
10
+ ],
11
+ default: null
12
+ },
13
+ header: {
14
+ type: String,
15
+ default: "Debug"
16
+ }
17
+ });
18
+ </script>
19
+
20
+ <template>
21
+ <Fieldset class="p-formkit-data-debug" :legend="header" :toggleable="true" :collapsed="true">
22
+ <pre v-if="data">{{ data }}</pre>
23
+ <span v-else>No Data available</span>
24
+ </Fieldset>
25
+ </template>
@@ -0,0 +1,123 @@
1
+ <script setup>
2
+ import { reset } from "@formkit/core";
3
+ import { FormKit, FormKitMessages, FormKitSchema } from "@formkit/vue";
4
+ import { ref, watch } from "vue";
5
+ import FormKitDataDebug from "./FormKitDataDebug.vue";
6
+ const props = defineProps({
7
+ id: {
8
+ type: String,
9
+ default: "formkit_form"
10
+ },
11
+ data: {
12
+ type: Object,
13
+ default: null
14
+ },
15
+ schema: {
16
+ type: Object,
17
+ default: null
18
+ },
19
+ formClass: {
20
+ type: String,
21
+ default: ""
22
+ },
23
+ actionsClass: {
24
+ type: String,
25
+ default: ""
26
+ },
27
+ submitSeverity: {
28
+ type: String,
29
+ default: ""
30
+ },
31
+ submitClass: {
32
+ type: String,
33
+ default: ""
34
+ },
35
+ submitLabel: {
36
+ type: String,
37
+ default: "Save"
38
+ },
39
+ submitIcon: {
40
+ type: String,
41
+ default: ""
42
+ },
43
+ showReset: {
44
+ type: Boolean,
45
+ default: false
46
+ },
47
+ resetSeverity: {
48
+ type: String,
49
+ default: "danger"
50
+ },
51
+ resetLabel: {
52
+ type: String,
53
+ default: "Reset"
54
+ },
55
+ resetClass: {
56
+ type: String,
57
+ default: ""
58
+ },
59
+ resetIcon: {
60
+ type: String,
61
+ default: ""
62
+ },
63
+ debugData: {
64
+ type: Boolean,
65
+ default: false
66
+ },
67
+ debugSchema: {
68
+ type: Boolean,
69
+ default: false
70
+ }
71
+ });
72
+ const emit = defineEmits(["dataSaved", "onReset"]);
73
+ const formData = defineModel({ type: null });
74
+ if (props.data) {
75
+ formData.value = props.data;
76
+ }
77
+ const formSchema = ref(props.schema);
78
+ // Watch for changes to props and update internal refs
79
+ watch(() => props.schema, (newSchema) => {
80
+ formSchema.value = newSchema;
81
+ }, { deep: true });
82
+ watch(() => props.data, (newData) => {
83
+ if (newData && newData !== formData.value) {
84
+ formData.value = newData;
85
+ }
86
+ }, { deep: true });
87
+ function handleSave() {
88
+ emit("dataSaved", formData.value);
89
+ }
90
+ function handleReset() {
91
+ reset(props.id);
92
+ emit("onReset");
93
+ }
94
+ </script>
95
+
96
+ <template>
97
+ <FormKit
98
+ :id="id"
99
+ v-model="formData"
100
+ :actions-class="actionsClass"
101
+ :form-class="`p-formkit-data-edit ${formClass}`"
102
+ type="form"
103
+ @submit="handleSave"
104
+ >
105
+ <template #default>
106
+ <FormKitSchema v-if="formSchema" :schema="formSchema" :data="formData" />
107
+ <slot />
108
+ <FormKitDataDebug v-if="debugData" :data="formData" header="Debug Mode - Data" />
109
+ <FormKitDataDebug v-if="debugSchema" :data="formSchema" header="Debug Mode - Schema" />
110
+ </template>
111
+ <template #messages>
112
+ <slot name="messages">
113
+ <FormKitMessages class="p-formkit-data-edit-messages" />
114
+ </slot>
115
+ </template>
116
+ <template #submit>
117
+ <slot name="submit">
118
+ <Button :icon="submitIcon" type="submit" :label="submitLabel" :class="submitClass" :severity="submitSeverity" @submit="handleSave" />
119
+ <Button v-if="showReset" type="reset" :icon="resetIcon" :label="resetLabel" :class="resetClass" :severity="resetSeverity" @click="handleReset" />
120
+ </slot>
121
+ </template>
122
+ </FormKit>
123
+ </template>
@@ -0,0 +1,56 @@
1
+ <script setup>
2
+ import { FormKit, FormKitSchema } from "@formkit/vue";
3
+ import { ref, watch } from "vue";
4
+ import FormKitDataDebug from "./FormKitDataDebug.vue";
5
+ const props = defineProps({
6
+ data: {
7
+ type: Object,
8
+ default: null
9
+ },
10
+ schema: {
11
+ type: Object,
12
+ default: null
13
+ },
14
+ formClass: {
15
+ type: String,
16
+ default: ""
17
+ },
18
+ debugData: {
19
+ type: Boolean,
20
+ default: false
21
+ },
22
+ debugSchema: {
23
+ type: Boolean,
24
+ default: false
25
+ }
26
+ });
27
+ const formSchema = ref(props.schema);
28
+ const formData = defineModel({ type: null });
29
+ // Watch for changes to props and update internal refs
30
+ watch(() => props.schema, (newSchema) => {
31
+ formSchema.value = newSchema;
32
+ }, { deep: true });
33
+ watch(() => props.data, (newData) => {
34
+ if (newData && newData !== formData.value) {
35
+ formData.value = newData;
36
+ }
37
+ }, { deep: true });
38
+ if (props.data) {
39
+ formData.value = props.data;
40
+ }
41
+ </script>
42
+
43
+ <template>
44
+ <FormKit
45
+ v-model="formData"
46
+ :actions="false"
47
+ :form-class="`p-formkit-data-view ${formClass}`"
48
+ class="p-formkit-data-view"
49
+ type="form"
50
+ >
51
+ <FormKitSchema v-if="schema" :schema="formSchema" :data="formData" />
52
+ <slot />
53
+ <FormKitDataDebug v-if="debugData" :data="formData" header="Debug Mode - Data" />
54
+ <FormKitDataDebug v-if="debugSchema" :data="formSchema" header="Debug Mode - Schema" />
55
+ </FormKit>
56
+ </template>
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ defineProps({
3
+ iconClass: {
4
+ type: String,
5
+ default: ""
6
+ },
7
+ onClick: {
8
+ type: Function,
9
+ default: undefined
10
+ },
11
+ position: {
12
+ type: String,
13
+ required: true,
14
+ validator: (val) => ["prefix", "suffix"].includes(val)
15
+ },
16
+ tooltip: { type: String }
17
+ });
18
+ </script>
19
+
20
+ <template>
21
+ <i v-if="tooltip && tooltip?.length > 0" v-tooltip.bottom="tooltip" :class="[`formkit-${position}-icon`, iconClass]" @click="onClick" />
22
+ <i v-else :class="[`formkit-${position}-icon`, iconClass]" @click="onClick" />
23
+ </template>
@@ -0,0 +1,9 @@
1
+ <script setup>
2
+ defineProps({ prefix: String });
3
+ </script>
4
+
5
+ <template>
6
+ <span class="formkit-prefix">
7
+ {{ prefix }}
8
+ </span>
9
+ </template>
@@ -0,0 +1,9 @@
1
+ <script setup>
2
+ defineProps({ suffix: String });
3
+ </script>
4
+
5
+ <template>
6
+ <span class="formkit-suffix">
7
+ {{ suffix }}
8
+ </span>
9
+ </template>
@@ -0,0 +1,48 @@
1
+ <script setup>
2
+ import { useFormKitInput } from "../composables";
3
+ const props = defineProps({ context: {
4
+ type: Object,
5
+ required: true
6
+ } });
7
+ const { unstyled, isInvalid, modelValue } = useFormKitInput(props.context);
8
+ function handleInput(e) {
9
+ props.context?.node.input(e);
10
+ props.context?.handlers.blur(e);
11
+ }
12
+ function updateValue(n) {
13
+ props.context?.node.input(n);
14
+ }
15
+ </script>
16
+
17
+ <template>
18
+ <div class="p-formkit">
19
+ <Knob
20
+ :id="context.id"
21
+ v-model="modelValue"
22
+ v-bind="context?.attrs"
23
+ :disabled="!!context?.disabled"
24
+ :readonly="context?.attrs.readonly ?? false"
25
+ :style="context?.attrs.style"
26
+ :class="context?.attrs?.class"
27
+ :invalid="isInvalid"
28
+ :tabindex="context?.attrs.tabindex"
29
+ :aria-label="context?.attrs.ariaLabel"
30
+ :aria-labelledby="context?.attrs.ariaLabelledby"
31
+ :min="context.min ?? 0"
32
+ :max="context.max ?? 100"
33
+ :step="context.step ?? undefined"
34
+ :size="context.size ?? 100"
35
+ :stroke-width="context.strokeWidth ?? 14"
36
+ :show-value="context.showValue ?? true"
37
+ :value-color="context.valueColor ?? undefined"
38
+ :range-color="context.rangeColor ?? undefined"
39
+ :text-color="context.textColor ?? undefined"
40
+ :value-template="context.valueTemplate ?? undefined"
41
+ :pt="context.pt"
42
+ :pt-options="context.ptOptions"
43
+ :unstyled="unstyled"
44
+ @change="handleInput"
45
+ @update:model-value="updateValue"
46
+ />
47
+ </div>
48
+ </template>