@sfxcode/formkit-primevue 3.2.10 → 3.3.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 (164) hide show
  1. package/README.md +13 -138
  2. package/dist/PrimeTreeSelect-Dksx7tL-.js +1881 -0
  3. package/dist/components/index.d.ts +2 -24
  4. package/dist/components/index.js +4 -167
  5. package/dist/components-HJnJ39cU.js +255 -0
  6. package/dist/composables/index.d.ts +2 -9
  7. package/dist/composables/index.js +2 -61
  8. package/dist/composables-CZ6f1QYe.js +820 -0
  9. package/dist/definitions/index.d.ts +37 -32
  10. package/dist/definitions/index.js +4 -42
  11. package/dist/definitions-BHwWaom7.js +1196 -0
  12. package/dist/index-Ch3MtT1C.d.ts +266 -0
  13. package/dist/index-EJ8M51RO.d.ts +917 -0
  14. package/dist/index.d.ts +146 -143
  15. package/dist/index.js +5 -62
  16. package/dist/plugins/index.d.ts +7 -3
  17. package/dist/plugins/index.js +45 -57
  18. package/dist/sass/formkit-primevue.scss +99 -101
  19. package/package.json +32 -117
  20. package/LICENSE +0 -21
  21. package/components.d.ts +0 -1
  22. package/dist/components/FormKitDataDebug.d.vue.ts +0 -24
  23. package/dist/components/FormKitDataDebug.vue +0 -23
  24. package/dist/components/FormKitDataDebug.vue.d.ts +0 -24
  25. package/dist/components/FormKitDataEdit.d.vue.ts +0 -180
  26. package/dist/components/FormKitDataEdit.vue +0 -126
  27. package/dist/components/FormKitDataEdit.vue.d.ts +0 -180
  28. package/dist/components/FormKitDataView.d.vue.ts +0 -73
  29. package/dist/components/FormKitDataView.vue +0 -58
  30. package/dist/components/FormKitDataView.vue.d.ts +0 -73
  31. package/dist/components/FormKitIcon.d.vue.ts +0 -39
  32. package/dist/components/FormKitIcon.vue +0 -25
  33. package/dist/components/FormKitIcon.vue.d.ts +0 -39
  34. package/dist/components/FormKitPrefix.d.vue.ts +0 -7
  35. package/dist/components/FormKitPrefix.vue +0 -11
  36. package/dist/components/FormKitPrefix.vue.d.ts +0 -7
  37. package/dist/components/FormKitSuffix.d.vue.ts +0 -7
  38. package/dist/components/FormKitSuffix.vue +0 -11
  39. package/dist/components/FormKitSuffix.vue.d.ts +0 -7
  40. package/dist/components/PrimeAutoComplete.d.vue.ts +0 -31
  41. package/dist/components/PrimeAutoComplete.vue +0 -162
  42. package/dist/components/PrimeAutoComplete.vue.d.ts +0 -31
  43. package/dist/components/PrimeCascadeSelect.d.vue.ts +0 -28
  44. package/dist/components/PrimeCascadeSelect.vue +0 -62
  45. package/dist/components/PrimeCascadeSelect.vue.d.ts +0 -28
  46. package/dist/components/PrimeCheckbox.d.vue.ts +0 -27
  47. package/dist/components/PrimeCheckbox.vue +0 -71
  48. package/dist/components/PrimeCheckbox.vue.d.ts +0 -27
  49. package/dist/components/PrimeColorPicker.d.vue.ts +0 -24
  50. package/dist/components/PrimeColorPicker.vue +0 -48
  51. package/dist/components/PrimeColorPicker.vue.d.ts +0 -24
  52. package/dist/components/PrimeDatePicker.d.vue.ts +0 -63
  53. package/dist/components/PrimeDatePicker.vue +0 -153
  54. package/dist/components/PrimeDatePicker.vue.d.ts +0 -63
  55. package/dist/components/PrimeInputMask.d.vue.ts +0 -28
  56. package/dist/components/PrimeInputMask.vue +0 -88
  57. package/dist/components/PrimeInputMask.vue.d.ts +0 -28
  58. package/dist/components/PrimeInputNumber.d.vue.ts +0 -36
  59. package/dist/components/PrimeInputNumber.vue +0 -110
  60. package/dist/components/PrimeInputNumber.vue.d.ts +0 -36
  61. package/dist/components/PrimeInputOtp.d.vue.ts +0 -26
  62. package/dist/components/PrimeInputOtp.vue +0 -59
  63. package/dist/components/PrimeInputOtp.vue.d.ts +0 -26
  64. package/dist/components/PrimeInputText.d.vue.ts +0 -24
  65. package/dist/components/PrimeInputText.vue +0 -80
  66. package/dist/components/PrimeInputText.vue.d.ts +0 -24
  67. package/dist/components/PrimeKnob.d.vue.ts +0 -31
  68. package/dist/components/PrimeKnob.vue +0 -75
  69. package/dist/components/PrimeKnob.vue.d.ts +0 -31
  70. package/dist/components/PrimeListbox.d.vue.ts +0 -42
  71. package/dist/components/PrimeListbox.vue +0 -86
  72. package/dist/components/PrimeListbox.vue.d.ts +0 -42
  73. package/dist/components/PrimeMultiSelect.d.vue.ts +0 -53
  74. package/dist/components/PrimeMultiSelect.vue +0 -115
  75. package/dist/components/PrimeMultiSelect.vue.d.ts +0 -53
  76. package/dist/components/PrimeOutputBoolean.d.vue.ts +0 -16
  77. package/dist/components/PrimeOutputBoolean.vue +0 -41
  78. package/dist/components/PrimeOutputBoolean.vue.d.ts +0 -16
  79. package/dist/components/PrimeOutputDate.d.vue.ts +0 -16
  80. package/dist/components/PrimeOutputDate.vue +0 -51
  81. package/dist/components/PrimeOutputDate.vue.d.ts +0 -16
  82. package/dist/components/PrimeOutputDuration.d.vue.ts +0 -16
  83. package/dist/components/PrimeOutputDuration.vue +0 -32
  84. package/dist/components/PrimeOutputDuration.vue.d.ts +0 -16
  85. package/dist/components/PrimeOutputLink.d.vue.ts +0 -16
  86. package/dist/components/PrimeOutputLink.vue +0 -50
  87. package/dist/components/PrimeOutputLink.vue.d.ts +0 -16
  88. package/dist/components/PrimeOutputList.d.vue.ts +0 -19
  89. package/dist/components/PrimeOutputList.vue +0 -71
  90. package/dist/components/PrimeOutputList.vue.d.ts +0 -19
  91. package/dist/components/PrimeOutputNumber.d.vue.ts +0 -16
  92. package/dist/components/PrimeOutputNumber.vue +0 -59
  93. package/dist/components/PrimeOutputNumber.vue.d.ts +0 -16
  94. package/dist/components/PrimeOutputReference.d.vue.ts +0 -16
  95. package/dist/components/PrimeOutputReference.vue +0 -62
  96. package/dist/components/PrimeOutputReference.vue.d.ts +0 -16
  97. package/dist/components/PrimeOutputText.d.vue.ts +0 -22
  98. package/dist/components/PrimeOutputText.vue +0 -72
  99. package/dist/components/PrimeOutputText.vue.d.ts +0 -22
  100. package/dist/components/PrimePassword.d.vue.ts +0 -33
  101. package/dist/components/PrimePassword.vue +0 -73
  102. package/dist/components/PrimePassword.vue.d.ts +0 -33
  103. package/dist/components/PrimeRadioButton.d.vue.ts +0 -28
  104. package/dist/components/PrimeRadioButton.vue +0 -53
  105. package/dist/components/PrimeRadioButton.vue.d.ts +0 -28
  106. package/dist/components/PrimeRating.d.vue.ts +0 -24
  107. package/dist/components/PrimeRating.vue +0 -55
  108. package/dist/components/PrimeRating.vue.d.ts +0 -24
  109. package/dist/components/PrimeSelect.d.vue.ts +0 -50
  110. package/dist/components/PrimeSelect.vue +0 -113
  111. package/dist/components/PrimeSelect.vue.d.ts +0 -50
  112. package/dist/components/PrimeSelectButton.d.vue.ts +0 -28
  113. package/dist/components/PrimeSelectButton.vue +0 -64
  114. package/dist/components/PrimeSelectButton.vue.d.ts +0 -28
  115. package/dist/components/PrimeSlider.d.vue.ts +0 -26
  116. package/dist/components/PrimeSlider.vue +0 -60
  117. package/dist/components/PrimeSlider.vue.d.ts +0 -26
  118. package/dist/components/PrimeTextarea.d.vue.ts +0 -25
  119. package/dist/components/PrimeTextarea.vue +0 -53
  120. package/dist/components/PrimeTextarea.vue.d.ts +0 -25
  121. package/dist/components/PrimeToggleButton.d.vue.ts +0 -26
  122. package/dist/components/PrimeToggleButton.vue +0 -60
  123. package/dist/components/PrimeToggleButton.vue.d.ts +0 -26
  124. package/dist/components/PrimeToggleSwitch.d.vue.ts +0 -23
  125. package/dist/components/PrimeToggleSwitch.vue +0 -57
  126. package/dist/components/PrimeToggleSwitch.vue.d.ts +0 -23
  127. package/dist/components/PrimeTreeSelect.d.vue.ts +0 -32
  128. package/dist/components/PrimeTreeSelect.vue +0 -71
  129. package/dist/components/PrimeTreeSelect.vue.d.ts +0 -32
  130. package/dist/components/index.mjs +0 -48
  131. package/dist/composables/index.mjs +0 -18
  132. package/dist/composables/useFormKitInput.d.ts +0 -10
  133. package/dist/composables/useFormKitInput.js +0 -51
  134. package/dist/composables/useFormKitInput.mjs +0 -39
  135. package/dist/composables/useFormKitRepeater.d.ts +0 -15
  136. package/dist/composables/useFormKitRepeater.js +0 -74
  137. package/dist/composables/useFormKitRepeater.mjs +0 -54
  138. package/dist/composables/useFormKitSchema.d.ts +0 -36
  139. package/dist/composables/useFormKitSchema.js +0 -83
  140. package/dist/composables/useFormKitSchema.mjs +0 -58
  141. package/dist/composables/useFormKitSection.d.ts +0 -7
  142. package/dist/composables/useFormKitSection.js +0 -31
  143. package/dist/composables/useFormKitSection.mjs +0 -19
  144. package/dist/composables/useInputEditor.d.ts +0 -8
  145. package/dist/composables/useInputEditor.js +0 -148
  146. package/dist/composables/useInputEditor.mjs +0 -143
  147. package/dist/composables/useInputEditorSchema.d.ts +0 -163
  148. package/dist/composables/useInputEditorSchema.js +0 -313
  149. package/dist/composables/useInputEditorSchema.mjs +0 -315
  150. package/dist/composables/useOutputDuration.d.ts +0 -4
  151. package/dist/composables/useOutputDuration.js +0 -40
  152. package/dist/composables/useOutputDuration.mjs +0 -35
  153. package/dist/composables/usePrimeInputs.d.ts +0 -3
  154. package/dist/composables/usePrimeInputs.js +0 -62
  155. package/dist/composables/usePrimeInputs.mjs +0 -53
  156. package/dist/definitions/index.mjs +0 -68
  157. package/dist/definitions/input.d.ts +0 -47
  158. package/dist/definitions/input.js +0 -142
  159. package/dist/definitions/input.mjs +0 -135
  160. package/dist/definitions/output.d.ts +0 -9
  161. package/dist/definitions/output.js +0 -46
  162. package/dist/definitions/output.mjs +0 -39
  163. package/dist/index.mjs +0 -14
  164. package/dist/plugins/index.mjs +0 -55
@@ -1,83 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useFormKitSchema = useFormKitSchema;
7
- function useFormKitSchema() {
8
- const addComponent = (component = "Button", props = {}, render = true, formKitAttrs = {}) => {
9
- return {
10
- $cmp: component,
11
- if: render.toString(),
12
- props,
13
- ...formKitAttrs
14
- };
15
- };
16
- const addElement = (element = "div", children = [], attrs = {}, render = true, formKitAttrs = {}) => {
17
- return {
18
- $el: element,
19
- if: render.toString(),
20
- attrs,
21
- children,
22
- ...formKitAttrs
23
- };
24
- };
25
- const addGroup = (name, children = [], render = true, formKitAttrs = {}) => {
26
- return {
27
- $formkit: "group",
28
- if: render.toString(),
29
- name,
30
- children,
31
- ...formKitAttrs
32
- };
33
- };
34
- const addList = (name, children = [], dynamic = true, render = true, formKitAttrs = {}) => {
35
- return {
36
- $formkit: "list",
37
- if: render.toString(),
38
- name,
39
- dynamic,
40
- children,
41
- ...formKitAttrs
42
- };
43
- };
44
- const addListGroup = (children = [], render = true, formKitAttrs = {}) => {
45
- return {
46
- $formkit: "group",
47
- if: render.toString(),
48
- for: ["item", "index", "$items"],
49
- // 👈 $items is in the slot’s scope
50
- key: "$item",
51
- index: "$index",
52
- children,
53
- ...formKitAttrs
54
- };
55
- };
56
- const addElementsInOuterDiv = (children = [], innerClass = "", outerClass = "", label = "", help = "", render = true) => {
57
- const inner = addElement("div", children, {
58
- class: `formkit-inner ${innerClass}`,
59
- style: "position: relative;"
60
- });
61
- const labelDiv = addElement("label", [label], {
62
- class: "formkit-label"
63
- });
64
- const wrapperDiv = addElement("div", [labelDiv, inner], {
65
- class: "formkit-wrapper"
66
- });
67
- const helpDiv = addElement("div", [help], {
68
- class: "formkit-help"
69
- });
70
- return addElement("div", [wrapperDiv, helpDiv], {
71
- class: `formkit-outer ${outerClass}`,
72
- style: "position: relative;"
73
- }, render);
74
- };
75
- return {
76
- addComponent,
77
- addElement,
78
- addGroup,
79
- addList,
80
- addListGroup,
81
- addElementsInOuterDiv
82
- };
83
- }
@@ -1,58 +0,0 @@
1
- export function useFormKitSchema() {
2
- const addComponent = (component = "Button", props = {}, render = true, formKitAttrs = {}) => {
3
- return {
4
- $cmp: component,
5
- if: render.toString(),
6
- props,
7
- ...formKitAttrs
8
- };
9
- };
10
- const addElement = (element = "div", children = [], attrs = {}, render = true, formKitAttrs = {}) => {
11
- return {
12
- $el: element,
13
- if: render.toString(),
14
- attrs,
15
- children,
16
- ...formKitAttrs
17
- };
18
- };
19
- const addGroup = (name, children = [], render = true, formKitAttrs = {}) => {
20
- return {
21
- $formkit: "group",
22
- if: render.toString(),
23
- name,
24
- children,
25
- ...formKitAttrs
26
- };
27
- };
28
- const addList = (name, children = [], dynamic = true, render = true, formKitAttrs = {}) => {
29
- return {
30
- $formkit: "list",
31
- if: render.toString(),
32
- name,
33
- dynamic,
34
- children,
35
- ...formKitAttrs
36
- };
37
- };
38
- const addListGroup = (children = [], render = true, formKitAttrs = {}) => {
39
- return {
40
- $formkit: "group",
41
- if: render.toString(),
42
- for: ["item", "index", "$items"],
43
- // 👈 $items is in the slot’s scope
44
- key: "$item",
45
- index: "$index",
46
- children,
47
- ...formKitAttrs
48
- };
49
- };
50
- const addElementsInOuterDiv = (children = [], innerClass = "", outerClass = "", label = "", help = "", render = true) => {
51
- const inner = addElement("div", children, { class: `formkit-inner ${innerClass}`, style: "position: relative;" });
52
- const labelDiv = addElement("label", [label], { class: "formkit-label" });
53
- const wrapperDiv = addElement("div", [labelDiv, inner], { class: "formkit-wrapper" });
54
- const helpDiv = addElement("div", [help], { class: "formkit-help" });
55
- return addElement("div", [wrapperDiv, helpDiv], { class: `formkit-outer ${outerClass}`, style: "position: relative;" }, render);
56
- };
57
- return { addComponent, addElement, addGroup, addList, addListGroup, addElementsInOuterDiv };
58
- }
@@ -1,7 +0,0 @@
1
- export declare function useFormKitSection(context: any): {
2
- generateId: () => string;
3
- hasPrefix: import("vue").ComputedRef<boolean>;
4
- hasPrefixIcon: import("vue").ComputedRef<boolean>;
5
- hasSuffix: import("vue").ComputedRef<boolean>;
6
- hasSuffixIcon: import("vue").ComputedRef<boolean>;
7
- };
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useFormKitSection = useFormKitSection;
7
- var _vue = require("vue");
8
- function useFormKitSection(context) {
9
- const hasPrefix = (0, _vue.computed)(() => {
10
- return Boolean(context?.prefix?.length > 0);
11
- });
12
- const hasPrefixIcon = (0, _vue.computed)(() => {
13
- return Boolean(context?.iconPrefix?.length > 0);
14
- });
15
- const hasSuffixIcon = (0, _vue.computed)(() => {
16
- return Boolean(context?.iconSuffix?.length > 0);
17
- });
18
- const hasSuffix = (0, _vue.computed)(() => {
19
- return Boolean(context?.suffix?.length > 0);
20
- });
21
- function generateId() {
22
- return typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2);
23
- }
24
- return {
25
- generateId,
26
- hasPrefix,
27
- hasPrefixIcon,
28
- hasSuffix,
29
- hasSuffixIcon
30
- };
31
- }
@@ -1,19 +0,0 @@
1
- import { computed } from "vue";
2
- export function useFormKitSection(context) {
3
- const hasPrefix = computed(() => {
4
- return Boolean(context?.prefix?.length > 0);
5
- });
6
- const hasPrefixIcon = computed(() => {
7
- return Boolean(context?.iconPrefix?.length > 0);
8
- });
9
- const hasSuffixIcon = computed(() => {
10
- return Boolean(context?.iconSuffix?.length > 0);
11
- });
12
- const hasSuffix = computed(() => {
13
- return Boolean(context?.suffix?.length > 0);
14
- });
15
- function generateId() {
16
- return typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2);
17
- }
18
- return { generateId, hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon };
19
- }
@@ -1,8 +0,0 @@
1
- export declare function useInputEditor(): {
2
- primeInputNames: string[];
3
- primeOutputNames: string[];
4
- editorDataToSchema: (data: any) => any;
5
- editorDataToJson: (data: any) => string;
6
- editorDataToCode: (data: any) => string;
7
- schemaToEditorData: (schema: any) => any;
8
- };
@@ -1,148 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useInputEditor = useInputEditor;
7
- function useInputEditor() {
8
- const primeInputWithOptionNames = ["CascadeSelect", "Listbox", "MultiSelect", "RadioButton", "Select", "SelectButton", "TreeSelect"];
9
- const primeInputNames = [...primeInputWithOptionNames, "AutoComplete", "Checkbox", "ColorPicker", "DatePicker", "Editor", "InputMask", "InputNumber", "InputOtp", "InputText", "Knob", "Password", "Rating", "Slider", "Textarea", "ToggleButton", "ToggleSwitch"].sort();
10
- const primeOutputNames = ["OutputBoolean", "OutputDate", "OutputDuration", "OutputLink", "OutputList", "OutputNumber", "OutputReference", "OutputText"];
11
- function editorDataToSchema(data) {
12
- if (!data) return {};
13
- const formkitInput = data?._dollar_formkit;
14
- let tempData = {};
15
- if (data.prime && Array.isArray(data.prime) && data.prime.length > 0) {
16
- const mapped = data.prime.filter(entry => entry && typeof entry === "object" && "prime_key" in entry && "prime_value" in entry).map(entry => {
17
- const key = entry.prime_key || "";
18
- let value = entry.prime_value;
19
- if (formkitInput === "primeInputOtp" && key === "length" && value !== void 0) {
20
- value = Number(value);
21
- }
22
- return [key, value];
23
- });
24
- tempData = Object.assign({}, ...mapped.map(([key, val]) => ({
25
- [key]: val
26
- })));
27
- }
28
- const readonlyValue = data.readonly === true ? true : void 0;
29
- const disabledValue = data.disabled === true ? true : void 0;
30
- const preserveValue = data.preserve === true ? true : void 0;
31
- const defaultObject = {
32
- readonly: readonlyValue,
33
- disabled: disabledValue,
34
- preserve: preserveValue
35
- };
36
- let outerClass = "";
37
- if (data.outerClass) outerClass = `${outerClass} ${data.outerClass}`.trim();
38
- let wrapperClass = "";
39
- if (data.wrapperClass) wrapperClass = `${wrapperClass} ${data.wrapperClass}`.trim();
40
- let innerClass = "";
41
- if (data.innerClass) innerClass = `${innerClass} ${data.innerClass}`.trim();
42
- const undefinedObject = {
43
- prime: void 0,
44
- schemaResultFormKey: void 0,
45
- _dollar_formkit: void 0,
46
- slots: void 0,
47
- selectButton: void 0
48
- };
49
- const useOptions = formkitInput ? primeInputWithOptionNames.map(s => `prime${s}`).includes(formkitInput) : false;
50
- let result = {};
51
- if (useOptions) {
52
- result = {
53
- ...data,
54
- $formkit: formkitInput,
55
- ...tempData,
56
- ...undefinedObject,
57
- ...defaultObject,
58
- outerClass,
59
- wrapperClass,
60
- innerClass,
61
- optionLabel: "label",
62
- optionValue: "value"
63
- };
64
- } else {
65
- result = {
66
- ...data,
67
- $formkit: formkitInput,
68
- ...tempData,
69
- ...undefinedObject,
70
- ...defaultObject,
71
- outerClass,
72
- wrapperClass,
73
- innerClass,
74
- options: void 0
75
- };
76
- }
77
- for (const key in result) {
78
- const value = result[key];
79
- if (value !== null && value !== void 0 && typeof value === "string") {
80
- if (value.trim().length === 0) {
81
- result[key] = void 0;
82
- }
83
- }
84
- }
85
- return result;
86
- }
87
- function dataToSchema(data) {
88
- if (!data) return {};
89
- const schema = editorDataToSchema(data);
90
- if (schema?.options && Array.isArray(schema.options)) {
91
- const options = schema.options.map(o => o ? JSON.parse(JSON.stringify(o)) : {});
92
- return {
93
- ...schema,
94
- options
95
- };
96
- } else {
97
- return schema;
98
- }
99
- }
100
- function editorDataToJson(data) {
101
- if (!data) return "{}";
102
- return JSON.stringify(dataToSchema(data));
103
- }
104
- function objectToString(data) {
105
- if (!data) return "{}";
106
- return `{${Object.entries(data).map(([key, value]) => {
107
- if (key === "options" && Array.isArray(value) && value.length > 0) {
108
- let result = "[";
109
- value.forEach(o => {
110
- if (o && typeof o === "object") {
111
- result = `${result + objectToString(o)}, `;
112
- }
113
- });
114
- return `${key}: ${result.substring(0, result.length - 2)}]`;
115
- } else if (key === "primeInputOtp") {
116
- return `${key}: ${value}`;
117
- } else {
118
- return `${key}: '${value}'`;
119
- }
120
- }).join()}}`;
121
- }
122
- function editorDataToObject(data) {
123
- if (!data) return "{}";
124
- try {
125
- const jsonData = editorDataToJson(data);
126
- return objectToString(JSON.parse(jsonData));
127
- } catch (error) {
128
- console.error("Error in editorDataToObject:", error);
129
- return "{}";
130
- }
131
- }
132
- function schemaToEditorData(schema) {
133
- if (!schema) return {};
134
- const formkitInput = schema?.$formkit;
135
- return {
136
- ...schema,
137
- _dollar_formkit: formkitInput
138
- };
139
- }
140
- return {
141
- primeInputNames,
142
- primeOutputNames,
143
- editorDataToSchema,
144
- editorDataToJson,
145
- editorDataToCode: editorDataToObject,
146
- schemaToEditorData
147
- };
148
- }
@@ -1,143 +0,0 @@
1
- export function useInputEditor() {
2
- const primeInputWithOptionNames = ["CascadeSelect", "Listbox", "MultiSelect", "RadioButton", "Select", "SelectButton", "TreeSelect"];
3
- const primeInputNames = [...primeInputWithOptionNames, "AutoComplete", "Checkbox", "ColorPicker", "DatePicker", "Editor", "InputMask", "InputNumber", "InputOtp", "InputText", "Knob", "Password", "Rating", "Slider", "Textarea", "ToggleButton", "ToggleSwitch"].sort();
4
- const primeOutputNames = ["OutputBoolean", "OutputDate", "OutputDuration", "OutputLink", "OutputList", "OutputNumber", "OutputReference", "OutputText"];
5
- function editorDataToSchema(data) {
6
- if (!data)
7
- return {};
8
- const formkitInput = data?._dollar_formkit;
9
- let tempData = {};
10
- if (data.prime && Array.isArray(data.prime) && data.prime.length > 0) {
11
- const mapped = data.prime.filter((entry) => entry && typeof entry === "object" && "prime_key" in entry && "prime_value" in entry).map((entry) => {
12
- const key = entry.prime_key || "";
13
- let value = entry.prime_value;
14
- if (formkitInput === "primeInputOtp" && key === "length" && value !== void 0) {
15
- value = Number(value);
16
- }
17
- return [key, value];
18
- });
19
- tempData = Object.assign({}, ...mapped.map(([key, val]) => ({ [key]: val })));
20
- }
21
- const readonlyValue = data.readonly === true ? true : void 0;
22
- const disabledValue = data.disabled === true ? true : void 0;
23
- const preserveValue = data.preserve === true ? true : void 0;
24
- const defaultObject = {
25
- readonly: readonlyValue,
26
- disabled: disabledValue,
27
- preserve: preserveValue
28
- };
29
- let outerClass = "";
30
- if (data.outerClass)
31
- outerClass = `${outerClass} ${data.outerClass}`.trim();
32
- let wrapperClass = "";
33
- if (data.wrapperClass)
34
- wrapperClass = `${wrapperClass} ${data.wrapperClass}`.trim();
35
- let innerClass = "";
36
- if (data.innerClass)
37
- innerClass = `${innerClass} ${data.innerClass}`.trim();
38
- const undefinedObject = {
39
- prime: void 0,
40
- schemaResultFormKey: void 0,
41
- _dollar_formkit: void 0,
42
- slots: void 0,
43
- selectButton: void 0
44
- };
45
- const useOptions = formkitInput ? primeInputWithOptionNames.map((s) => `prime${s}`).includes(formkitInput) : false;
46
- let result = {};
47
- if (useOptions) {
48
- result = {
49
- ...data,
50
- $formkit: formkitInput,
51
- ...tempData,
52
- ...undefinedObject,
53
- ...defaultObject,
54
- outerClass,
55
- wrapperClass,
56
- innerClass,
57
- optionLabel: "label",
58
- optionValue: "value"
59
- };
60
- } else {
61
- result = {
62
- ...data,
63
- $formkit: formkitInput,
64
- ...tempData,
65
- ...undefinedObject,
66
- ...defaultObject,
67
- outerClass,
68
- wrapperClass,
69
- innerClass,
70
- options: void 0
71
- };
72
- }
73
- for (const key in result) {
74
- const value = result[key];
75
- if (value !== null && value !== void 0 && typeof value === "string") {
76
- if (value.trim().length === 0) {
77
- result[key] = void 0;
78
- }
79
- }
80
- }
81
- return result;
82
- }
83
- function dataToSchema(data) {
84
- if (!data)
85
- return {};
86
- const schema = editorDataToSchema(data);
87
- if (schema?.options && Array.isArray(schema.options)) {
88
- const options = schema.options.map((o) => o ? JSON.parse(JSON.stringify(o)) : {});
89
- return { ...schema, options };
90
- } else {
91
- return schema;
92
- }
93
- }
94
- function editorDataToJson(data) {
95
- if (!data)
96
- return "{}";
97
- return JSON.stringify(dataToSchema(data));
98
- }
99
- function objectToString(data) {
100
- if (!data)
101
- return "{}";
102
- return `{${Object.entries(data).map(([key, value]) => {
103
- if (key === "options" && Array.isArray(value) && value.length > 0) {
104
- let result = "[";
105
- value.forEach((o) => {
106
- if (o && typeof o === "object") {
107
- result = `${result + objectToString(o)}, `;
108
- }
109
- });
110
- return `${key}: ${result.substring(0, result.length - 2)}]`;
111
- } else if (key === "primeInputOtp") {
112
- return `${key}: ${value}`;
113
- } else {
114
- return `${key}: '${value}'`;
115
- }
116
- }).join()}}`;
117
- }
118
- function editorDataToObject(data) {
119
- if (!data)
120
- return "{}";
121
- try {
122
- const jsonData = editorDataToJson(data);
123
- return objectToString(JSON.parse(jsonData));
124
- } catch (error) {
125
- console.error("Error in editorDataToObject:", error);
126
- return "{}";
127
- }
128
- }
129
- function schemaToEditorData(schema) {
130
- if (!schema)
131
- return {};
132
- const formkitInput = schema?.$formkit;
133
- return { ...schema, _dollar_formkit: formkitInput };
134
- }
135
- return {
136
- primeInputNames,
137
- primeOutputNames,
138
- editorDataToSchema,
139
- editorDataToJson,
140
- editorDataToCode: editorDataToObject,
141
- schemaToEditorData
142
- };
143
- }
@@ -1,163 +0,0 @@
1
- export declare function useInputEditorSchema(): {
2
- editorSchema: (inputOptions?: any[]) => ({
3
- $formkit: string;
4
- if: string;
5
- name: string;
6
- dynamic: boolean;
7
- children: object[];
8
- } | {
9
- $formkit: string;
10
- id: string;
11
- name: string;
12
- label: string;
13
- value: string;
14
- optionLabel: string;
15
- optionValue: string;
16
- options: any[];
17
- filter: boolean;
18
- key: string;
19
- outerClass: string;
20
- preserve: boolean;
21
- validation?: undefined;
22
- validationVisibility?: undefined;
23
- allowEmpty?: undefined;
24
- if?: undefined;
25
- suffix?: undefined;
26
- } | {
27
- $formkit: string;
28
- name: string;
29
- label: string;
30
- validation: string;
31
- validationVisibility: string;
32
- key: string;
33
- outerClass: string;
34
- preserve: boolean;
35
- id?: undefined;
36
- value?: undefined;
37
- optionLabel?: undefined;
38
- optionValue?: undefined;
39
- options?: undefined;
40
- filter?: undefined;
41
- allowEmpty?: undefined;
42
- if?: undefined;
43
- suffix?: undefined;
44
- } | {
45
- $formkit: string;
46
- id: string;
47
- name: string;
48
- options: {
49
- label: string;
50
- value: string;
51
- }[];
52
- optionLabel: string;
53
- optionValue: string;
54
- value: string;
55
- allowEmpty: boolean;
56
- key: string;
57
- preserve: boolean;
58
- label?: undefined;
59
- filter?: undefined;
60
- outerClass?: undefined;
61
- validation?: undefined;
62
- validationVisibility?: undefined;
63
- if?: undefined;
64
- suffix?: undefined;
65
- } | {
66
- $formkit: string;
67
- if: string;
68
- name: string;
69
- label: string;
70
- key: string;
71
- preserve: boolean;
72
- id?: undefined;
73
- value?: undefined;
74
- optionLabel?: undefined;
75
- optionValue?: undefined;
76
- options?: undefined;
77
- filter?: undefined;
78
- outerClass?: undefined;
79
- validation?: undefined;
80
- validationVisibility?: undefined;
81
- allowEmpty?: undefined;
82
- suffix?: undefined;
83
- } | {
84
- $formkit: string;
85
- if: string;
86
- name: string;
87
- label: string;
88
- key: string;
89
- outerClass: string;
90
- preserve: boolean;
91
- id?: undefined;
92
- value?: undefined;
93
- optionLabel?: undefined;
94
- optionValue?: undefined;
95
- options?: undefined;
96
- filter?: undefined;
97
- validation?: undefined;
98
- validationVisibility?: undefined;
99
- allowEmpty?: undefined;
100
- suffix?: undefined;
101
- } | {
102
- $formkit: string;
103
- if: string;
104
- name: string;
105
- label: string;
106
- key: string;
107
- value: boolean;
108
- suffix: string;
109
- outerClass: string;
110
- preserve: boolean;
111
- id?: undefined;
112
- optionLabel?: undefined;
113
- optionValue?: undefined;
114
- options?: undefined;
115
- filter?: undefined;
116
- validation?: undefined;
117
- validationVisibility?: undefined;
118
- allowEmpty?: undefined;
119
- } | {
120
- $formkit: string;
121
- if: string;
122
- name: string;
123
- label: string;
124
- key: string;
125
- value: boolean;
126
- outerClass: string;
127
- preserve: boolean;
128
- id?: undefined;
129
- optionLabel?: undefined;
130
- optionValue?: undefined;
131
- options?: undefined;
132
- filter?: undefined;
133
- validation?: undefined;
134
- validationVisibility?: undefined;
135
- allowEmpty?: undefined;
136
- suffix?: undefined;
137
- } | {
138
- $formkit: string;
139
- if: string;
140
- name: string;
141
- label: string;
142
- optionLabel: string;
143
- optionValue: string;
144
- options: {
145
- label: string;
146
- value: string;
147
- }[];
148
- key: string;
149
- outerClass: string;
150
- preserve: boolean;
151
- id?: undefined;
152
- value?: undefined;
153
- filter?: undefined;
154
- validation?: undefined;
155
- validationVisibility?: undefined;
156
- allowEmpty?: undefined;
157
- suffix?: undefined;
158
- })[];
159
- primeInputOptions: (list: string[]) => {
160
- label: string;
161
- value: string;
162
- }[];
163
- };