@ramathibodi/nuxt-commons 0.1.74 → 4.0.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 (243) hide show
  1. package/README.md +9 -2
  2. package/dist/module.json +4 -4
  3. package/dist/module.mjs +4 -4
  4. package/dist/runtime/bridges/authentication.d.ts +21 -0
  5. package/dist/runtime/bridges/authentication.js +20 -0
  6. package/dist/runtime/bridges/graphql.d.ts +17 -0
  7. package/dist/runtime/bridges/graphql.js +45 -0
  8. package/dist/runtime/components/Alert.d.vue.ts +3 -0
  9. package/dist/runtime/components/Alert.vue +17 -26
  10. package/dist/runtime/components/Alert.vue.d.ts +3 -0
  11. package/dist/runtime/components/BarcodeReader.d.vue.ts +9 -0
  12. package/dist/runtime/components/BarcodeReader.vue +56 -81
  13. package/dist/runtime/components/BarcodeReader.vue.d.ts +9 -0
  14. package/dist/runtime/components/ExportCSV.d.vue.ts +55 -0
  15. package/dist/runtime/components/ExportCSV.vue +39 -76
  16. package/dist/runtime/components/ExportCSV.vue.d.ts +55 -0
  17. package/dist/runtime/components/FileBtn.d.vue.ts +53 -0
  18. package/dist/runtime/components/FileBtn.vue +23 -50
  19. package/dist/runtime/components/FileBtn.vue.d.ts +53 -0
  20. package/dist/runtime/components/ImportCSV.d.vue.ts +52 -0
  21. package/dist/runtime/components/ImportCSV.vue +60 -111
  22. package/dist/runtime/components/ImportCSV.vue.d.ts +52 -0
  23. package/dist/runtime/components/MrzReader.d.vue.ts +19 -0
  24. package/dist/runtime/components/MrzReader.vue +69 -109
  25. package/dist/runtime/components/MrzReader.vue.d.ts +19 -0
  26. package/dist/runtime/components/SplitterPanel.d.vue.ts +15 -0
  27. package/dist/runtime/components/SplitterPanel.vue +18 -35
  28. package/dist/runtime/components/SplitterPanel.vue.d.ts +15 -0
  29. package/dist/runtime/components/TabsGroup.d.vue.ts +19 -0
  30. package/dist/runtime/components/TabsGroup.vue +8 -20
  31. package/dist/runtime/components/TabsGroup.vue.d.ts +19 -0
  32. package/dist/runtime/components/TextBarcode.d.vue.ts +12 -0
  33. package/dist/runtime/components/TextBarcode.vue +22 -45
  34. package/dist/runtime/components/TextBarcode.vue.d.ts +12 -0
  35. package/dist/runtime/components/device/IdCardButton.d.vue.ts +57 -0
  36. package/dist/runtime/components/device/IdCardButton.vue +30 -67
  37. package/dist/runtime/components/device/IdCardButton.vue.d.ts +57 -0
  38. package/dist/runtime/components/device/IdCardWebSocket.d.vue.ts +55 -0
  39. package/dist/runtime/components/device/IdCardWebSocket.vue +104 -165
  40. package/dist/runtime/components/device/IdCardWebSocket.vue.d.ts +55 -0
  41. package/dist/runtime/components/device/Scanner.d.vue.ts +66 -0
  42. package/dist/runtime/components/device/Scanner.vue +97 -178
  43. package/dist/runtime/components/device/Scanner.vue.d.ts +66 -0
  44. package/dist/runtime/components/dialog/Confirm.d.vue.ts +37 -0
  45. package/dist/runtime/components/dialog/Confirm.vue +30 -59
  46. package/dist/runtime/components/dialog/Confirm.vue.d.ts +37 -0
  47. package/dist/runtime/components/dialog/Host.d.vue.ts +9 -0
  48. package/dist/runtime/components/dialog/Host.vue +34 -57
  49. package/dist/runtime/components/dialog/Host.vue.d.ts +9 -0
  50. package/dist/runtime/components/dialog/Index.d.vue.ts +24 -0
  51. package/dist/runtime/components/dialog/Index.vue +20 -40
  52. package/dist/runtime/components/dialog/Index.vue.d.ts +24 -0
  53. package/dist/runtime/components/dialog/Loading.d.vue.ts +21 -0
  54. package/dist/runtime/components/dialog/Loading.vue +12 -29
  55. package/dist/runtime/components/dialog/Loading.vue.d.ts +21 -0
  56. package/dist/runtime/components/dialog/default/Confirm.d.vue.ts +40 -0
  57. package/dist/runtime/components/dialog/default/Confirm.vue +29 -62
  58. package/dist/runtime/components/dialog/default/Confirm.vue.d.ts +40 -0
  59. package/dist/runtime/components/dialog/default/Loading.d.vue.ts +23 -0
  60. package/dist/runtime/components/dialog/default/Loading.vue +12 -29
  61. package/dist/runtime/components/dialog/default/Loading.vue.d.ts +23 -0
  62. package/dist/runtime/components/dialog/default/Notify.d.vue.ts +23 -0
  63. package/dist/runtime/components/dialog/default/Notify.vue +19 -48
  64. package/dist/runtime/components/dialog/default/Notify.vue.d.ts +23 -0
  65. package/dist/runtime/components/dialog/default/Printing.d.vue.ts +21 -0
  66. package/dist/runtime/components/dialog/default/Printing.vue +13 -29
  67. package/dist/runtime/components/dialog/default/Printing.vue.d.ts +21 -0
  68. package/dist/runtime/components/dialog/default/VerifyUser.d.vue.ts +29 -0
  69. package/dist/runtime/components/dialog/default/VerifyUser.vue +44 -82
  70. package/dist/runtime/components/dialog/default/VerifyUser.vue.d.ts +29 -0
  71. package/dist/runtime/components/document/Form.d.vue.ts +9 -0
  72. package/dist/runtime/components/document/Form.vue +27 -42
  73. package/dist/runtime/components/document/Form.vue.d.ts +9 -0
  74. package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +24 -0
  75. package/dist/runtime/components/document/TemplateBuilder.vue +154 -194
  76. package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +24 -0
  77. package/dist/runtime/components/form/ActionPad.d.vue.ts +114 -0
  78. package/dist/runtime/components/form/ActionPad.vue +48 -85
  79. package/dist/runtime/components/form/ActionPad.vue.d.ts +114 -0
  80. package/dist/runtime/components/form/Birthdate.d.vue.ts +38 -0
  81. package/dist/runtime/components/form/Birthdate.vue +44 -76
  82. package/dist/runtime/components/form/Birthdate.vue.d.ts +38 -0
  83. package/dist/runtime/components/form/CheckboxGroup.d.vue.ts +41 -0
  84. package/dist/runtime/components/form/CheckboxGroup.vue +34 -64
  85. package/dist/runtime/components/form/CheckboxGroup.vue.d.ts +41 -0
  86. package/dist/runtime/components/form/CodeEditor.d.vue.ts +25 -0
  87. package/dist/runtime/components/form/CodeEditor.vue +18 -36
  88. package/dist/runtime/components/form/CodeEditor.vue.d.ts +25 -0
  89. package/dist/runtime/components/form/Date.d.vue.ts +86 -0
  90. package/dist/runtime/components/form/Date.vue +109 -162
  91. package/dist/runtime/components/form/Date.vue.d.ts +86 -0
  92. package/dist/runtime/components/form/DateTime.d.vue.ts +36 -0
  93. package/dist/runtime/components/form/DateTime.vue +94 -143
  94. package/dist/runtime/components/form/DateTime.vue.d.ts +36 -0
  95. package/dist/runtime/components/form/Dialog.d.vue.ts +69 -0
  96. package/dist/runtime/components/form/Dialog.vue +60 -96
  97. package/dist/runtime/components/form/Dialog.vue.d.ts +69 -0
  98. package/dist/runtime/components/form/EditPad.d.vue.ts +113 -0
  99. package/dist/runtime/components/form/EditPad.vue +49 -85
  100. package/dist/runtime/components/form/EditPad.vue.d.ts +113 -0
  101. package/dist/runtime/components/form/File.d.vue.ts +65 -0
  102. package/dist/runtime/components/form/File.vue +112 -186
  103. package/dist/runtime/components/form/File.vue.d.ts +65 -0
  104. package/dist/runtime/components/form/Hidden.d.vue.ts +12 -0
  105. package/dist/runtime/components/form/Hidden.vue +17 -34
  106. package/dist/runtime/components/form/Hidden.vue.d.ts +12 -0
  107. package/dist/runtime/components/form/Iterator.d.vue.ts +279 -0
  108. package/dist/runtime/components/form/Iterator.vue +162 -252
  109. package/dist/runtime/components/form/Iterator.vue.d.ts +279 -0
  110. package/dist/runtime/components/form/Login.d.vue.ts +32 -0
  111. package/dist/runtime/components/form/Login.vue +23 -55
  112. package/dist/runtime/components/form/Login.vue.d.ts +32 -0
  113. package/dist/runtime/components/form/Pad.d.vue.ts +674 -0
  114. package/dist/runtime/components/form/Pad.vue +166 -265
  115. package/dist/runtime/components/form/Pad.vue.d.ts +674 -0
  116. package/dist/runtime/components/form/SignPad.d.vue.ts +62 -0
  117. package/dist/runtime/components/form/SignPad.vue +80 -126
  118. package/dist/runtime/components/form/SignPad.vue.d.ts +62 -0
  119. package/dist/runtime/components/form/System.d.vue.ts +34 -0
  120. package/dist/runtime/components/form/System.vue +18 -32
  121. package/dist/runtime/components/form/System.vue.d.ts +34 -0
  122. package/dist/runtime/components/form/Table.d.vue.ts +221 -0
  123. package/dist/runtime/components/form/Table.vue +123 -182
  124. package/dist/runtime/components/form/Table.vue.d.ts +221 -0
  125. package/dist/runtime/components/form/TableData.d.vue.ts +102 -0
  126. package/dist/runtime/components/form/TableData.vue +109 -139
  127. package/dist/runtime/components/form/TableData.vue.d.ts +102 -0
  128. package/dist/runtime/components/form/Time.d.vue.ts +49 -0
  129. package/dist/runtime/components/form/Time.vue +64 -99
  130. package/dist/runtime/components/form/Time.vue.d.ts +49 -0
  131. package/dist/runtime/components/form/images/Capture.d.vue.ts +96 -0
  132. package/dist/runtime/components/form/images/Capture.vue +104 -147
  133. package/dist/runtime/components/form/images/Capture.vue.d.ts +96 -0
  134. package/dist/runtime/components/form/images/Edit.d.vue.ts +29 -0
  135. package/dist/runtime/components/form/images/Edit.vue +57 -81
  136. package/dist/runtime/components/form/images/Edit.vue.d.ts +29 -0
  137. package/dist/runtime/components/form/images/Field.d.vue.ts +27 -0
  138. package/dist/runtime/components/form/images/Field.vue +136 -205
  139. package/dist/runtime/components/form/images/Field.vue.d.ts +27 -0
  140. package/dist/runtime/components/form/images/Pad.d.vue.ts +13 -0
  141. package/dist/runtime/components/form/images/Pad.vue +23 -40
  142. package/dist/runtime/components/form/images/Pad.vue.d.ts +13 -0
  143. package/dist/runtime/components/label/Date.d.vue.ts +13 -0
  144. package/dist/runtime/components/label/Date.vue +13 -29
  145. package/dist/runtime/components/label/Date.vue.d.ts +13 -0
  146. package/dist/runtime/components/label/DateAgo.d.vue.ts +20 -0
  147. package/dist/runtime/components/label/DateAgo.vue +43 -75
  148. package/dist/runtime/components/label/DateAgo.vue.d.ts +20 -0
  149. package/dist/runtime/components/label/DateCount.d.vue.ts +22 -0
  150. package/dist/runtime/components/label/DateCount.vue +58 -105
  151. package/dist/runtime/components/label/DateCount.vue.d.ts +22 -0
  152. package/dist/runtime/components/label/Field.d.vue.ts +38 -0
  153. package/dist/runtime/components/label/Field.vue +18 -40
  154. package/dist/runtime/components/label/Field.vue.d.ts +38 -0
  155. package/dist/runtime/components/label/FormatMoney.d.vue.ts +12 -0
  156. package/dist/runtime/components/label/FormatMoney.vue +12 -28
  157. package/dist/runtime/components/label/FormatMoney.vue.d.ts +12 -0
  158. package/dist/runtime/components/label/Mask.d.vue.ts +10 -0
  159. package/dist/runtime/components/label/Mask.vue +21 -38
  160. package/dist/runtime/components/label/Mask.vue.d.ts +10 -0
  161. package/dist/runtime/components/label/Object.d.vue.ts +8 -0
  162. package/dist/runtime/components/label/Object.vue +10 -20
  163. package/dist/runtime/components/label/Object.vue.d.ts +8 -0
  164. package/dist/runtime/components/master/Autocomplete.d.vue.ts +70 -0
  165. package/dist/runtime/components/master/Autocomplete.vue +25 -34
  166. package/dist/runtime/components/master/Autocomplete.vue.d.ts +70 -0
  167. package/dist/runtime/components/master/Combobox.d.vue.ts +70 -0
  168. package/dist/runtime/components/master/Combobox.vue +26 -35
  169. package/dist/runtime/components/master/Combobox.vue.d.ts +70 -0
  170. package/dist/runtime/components/master/RadioGroup.d.vue.ts +51 -0
  171. package/dist/runtime/components/master/RadioGroup.vue +44 -59
  172. package/dist/runtime/components/master/RadioGroup.vue.d.ts +51 -0
  173. package/dist/runtime/components/master/Select.d.vue.ts +68 -0
  174. package/dist/runtime/components/master/Select.vue +25 -34
  175. package/dist/runtime/components/master/Select.vue.d.ts +68 -0
  176. package/dist/runtime/components/master/label.d.vue.ts +24 -0
  177. package/dist/runtime/components/master/label.vue +22 -42
  178. package/dist/runtime/components/master/label.vue.d.ts +24 -0
  179. package/dist/runtime/components/model/Autocomplete.d.vue.ts +82 -0
  180. package/dist/runtime/components/model/Autocomplete.vue +50 -49
  181. package/dist/runtime/components/model/Autocomplete.vue.d.ts +82 -0
  182. package/dist/runtime/components/model/Combobox.d.vue.ts +82 -0
  183. package/dist/runtime/components/model/Combobox.vue +51 -49
  184. package/dist/runtime/components/model/Combobox.vue.d.ts +82 -0
  185. package/dist/runtime/components/model/Pad.d.vue.ts +72 -0
  186. package/dist/runtime/components/model/Pad.vue +50 -65
  187. package/dist/runtime/components/model/Pad.vue.d.ts +72 -0
  188. package/dist/runtime/components/model/Select.d.vue.ts +72 -0
  189. package/dist/runtime/components/model/Select.vue +42 -44
  190. package/dist/runtime/components/model/Select.vue.d.ts +72 -0
  191. package/dist/runtime/components/model/Table.d.vue.ts +272 -0
  192. package/dist/runtime/components/model/Table.vue +121 -145
  193. package/dist/runtime/components/model/Table.vue.d.ts +272 -0
  194. package/dist/runtime/components/model/iterator.d.vue.ts +321 -0
  195. package/dist/runtime/components/model/iterator.vue +148 -183
  196. package/dist/runtime/components/model/iterator.vue.d.ts +321 -0
  197. package/dist/runtime/components/model/label.d.vue.ts +26 -0
  198. package/dist/runtime/components/model/label.vue +25 -43
  199. package/dist/runtime/components/model/label.vue.d.ts +26 -0
  200. package/dist/runtime/components/pdf/Print.d.vue.ts +17 -0
  201. package/dist/runtime/components/pdf/Print.vue +27 -50
  202. package/dist/runtime/components/pdf/Print.vue.d.ts +17 -0
  203. package/dist/runtime/components/pdf/View.d.vue.ts +52 -0
  204. package/dist/runtime/components/pdf/View.vue +58 -95
  205. package/dist/runtime/components/pdf/View.vue.d.ts +52 -0
  206. package/dist/runtime/composables/api.js +4 -2
  207. package/dist/runtime/composables/assetFile.js +4 -2
  208. package/dist/runtime/composables/dialog.d.ts +1 -1
  209. package/dist/runtime/composables/document/template.js +3 -3
  210. package/dist/runtime/composables/document/templateFormTable.js +1 -0
  211. package/dist/runtime/composables/graphql.d.ts +2 -2
  212. package/dist/runtime/composables/graphql.js +5 -5
  213. package/dist/runtime/composables/graphqlModel.d.ts +6 -6
  214. package/dist/runtime/composables/graphqlModelItem.d.ts +4 -4
  215. package/dist/runtime/composables/graphqlModelOperation.d.ts +6 -6
  216. package/dist/runtime/composables/graphqlModelOperation.js +2 -1
  217. package/dist/runtime/composables/graphqlOperation.js +5 -1
  218. package/dist/runtime/composables/hostAgentWs.d.ts +1 -1
  219. package/dist/runtime/composables/lookupListMaster.js +3 -3
  220. package/dist/runtime/composables/menu.js +2 -2
  221. package/dist/runtime/composables/userPermission.d.ts +1 -1
  222. package/dist/runtime/composables/utils/fuzzy.d.ts +2 -1
  223. package/dist/runtime/labs/Calendar.d.vue.ts +35 -0
  224. package/dist/runtime/labs/Calendar.vue +47 -75
  225. package/dist/runtime/labs/Calendar.vue.d.ts +35 -0
  226. package/dist/runtime/labs/form/EditMobile.d.vue.ts +12 -0
  227. package/dist/runtime/labs/form/EditMobile.vue +19 -36
  228. package/dist/runtime/labs/form/EditMobile.vue.d.ts +12 -0
  229. package/dist/runtime/labs/form/TextFieldMask.d.vue.ts +21 -0
  230. package/dist/runtime/labs/form/TextFieldMask.vue +19 -25
  231. package/dist/runtime/labs/form/TextFieldMask.vue.d.ts +21 -0
  232. package/dist/runtime/plugins/dialogManager.js +2 -2
  233. package/dist/runtime/plugins/permission.js +3 -3
  234. package/dist/runtime/types/bridge.d.ts +14 -0
  235. package/dist/runtime/utils/datetime.js +1 -1
  236. package/dist/types.d.mts +2 -6
  237. package/package.json +71 -59
  238. package/scripts/ci-release.mjs +125 -0
  239. package/scripts/release-version.mjs +68 -0
  240. package/scripts/release.mjs +49 -0
  241. package/dist/module.cjs +0 -5
  242. package/dist/module.d.ts +0 -8
  243. package/dist/types.d.ts +0 -7
@@ -1,355 +1,255 @@
1
- <script lang="ts" setup>
2
- /**
3
- * FormPad is a schema-driven form field component that binds model data, renders field UI, and emits normalized updates.
4
- * This doc block is consumed by vue-docgen for generated API documentation.
5
- */
6
- /* eslint-disable @typescript-eslint/no-explicit-any,import/no-self-import */
7
- import {
8
- compile,
9
- computed,
10
- defineComponent,
11
- defineOptions,
12
- inject,
13
- onMounted,
14
- ref,
15
- shallowRef,
16
- watch,
17
- withDefaults
18
- } from 'vue'
19
- import {watchDebounced} from '@vueuse/core'
20
- import {useRules} from '../../composables/utils/validation'
21
- import {useDocumentTemplate} from '../../composables/document/template'
22
- import { isObject, isArray, isString, isPlainObject, isEqual, debounce } from 'lodash-es'
23
- import FormPad from './Pad.vue'
24
-
1
+ <script setup>
2
+ import { compile, computed, defineComponent, inject, onMounted, ref, shallowRef, watch } from "vue";
3
+ import { watchDebounced } from "@vueuse/core";
4
+ import { useRules } from "../../composables/utils/validation";
5
+ import { useDocumentTemplate } from "../../composables/document/template";
6
+ import { isObject, isArray, isString, isPlainObject, isEqual, debounce } from "lodash-es";
7
+ import FormPad from "./Pad.vue";
25
8
  defineOptions({
26
- inheritAttrs: false,
27
- })
28
-
29
- interface Props {
30
- modelValue?: object // Bound value for v-model synchronization with the parent component.
31
- originalData?: object // Original baseline data used for dirty-checking and reset behavior.
32
- template?: any // Template object used to render dynamic form/pad structure.
33
- templateScript?: string // Optional script expression used to post-process template behavior.
34
- disabled?: boolean // disables user interaction for this field
35
- readonly?: boolean // renders as read-only while keeping value visible
36
- isolated?: boolean // boolean flag controlling runtime behavior
37
- decoration?: object // Decoration config used to style or annotate generated fields.
38
- parentTemplates?: string|string[] // Parent template code(s) used for template inheritance/extension.
39
- dirtyClass?: string // CSS class applied when form state differs from original data.
40
- dirtyOnCreate?: boolean // Marks new forms as dirty immediately on first render.
41
- sanitizeDelay?: number // Debounce delay before sanitizing emitted form values.
42
- }
43
-
44
- /**
45
- * Public props accepted by FormPad.
46
- * Document each prop field with intent, defaults, and side effects for clear generated docs.
47
- */
48
- const props = withDefaults(defineProps<Props>(), {
49
- disabled: false,
50
- readonly: false,
51
- isolated: false,
52
- decoration: () => { return {} },
53
- parentTemplates: (): string[] => [],
54
- dirtyClass: "form-data-dirty",
55
- dirtyOnCreate: false,
56
- sanitizeDelay: 2000,
57
- })
58
-
59
- /**
60
- * Custom events emitted by FormPad.
61
- * Parents can listen to these events to react to user actions and internal state changes.
62
- */
63
- const emit = defineEmits(['update:modelValue'])
64
-
65
- const disabled = ref(props.disabled)
66
- const readonly = ref(props.readonly)
67
- const decoration = ref(props.decoration)
68
-
9
+ inheritAttrs: false
10
+ });
11
+ const props = defineProps({
12
+ modelValue: { type: Object, required: false },
13
+ originalData: { type: Object, required: false },
14
+ template: { type: null, required: false },
15
+ templateScript: { type: String, required: false },
16
+ disabled: { type: Boolean, required: false, default: false },
17
+ readonly: { type: Boolean, required: false, default: false },
18
+ isolated: { type: Boolean, required: false, default: false },
19
+ decoration: { type: Object, required: false, default: () => {
20
+ return {};
21
+ } },
22
+ parentTemplates: { type: [String, Array], required: false, default: () => [] },
23
+ dirtyClass: { type: String, required: false, default: "form-data-dirty" },
24
+ dirtyOnCreate: { type: Boolean, required: false, default: false },
25
+ sanitizeDelay: { type: Number, required: false, default: 2e3 }
26
+ });
27
+ const emit = defineEmits(["update:modelValue"]);
28
+ const disabled = ref(props.disabled);
29
+ const readonly = ref(props.readonly);
30
+ const decoration = ref(props.decoration);
69
31
  watch(() => props.disabled, (newValue) => {
70
- disabled.value = newValue
71
- })
72
-
32
+ disabled.value = newValue;
33
+ });
73
34
  watch(() => props.readonly, (newValue) => {
74
- readonly.value = newValue
75
- })
76
-
35
+ readonly.value = newValue;
36
+ });
77
37
  watch(() => props.decoration, (newValue) => {
78
- decoration.value = newValue
79
- }, { deep: true })
80
-
81
- const { rules } = useRules()
82
-
83
- const trimmedTemplate = ref<string>('')
84
-
85
- const vueFunctions = { ref, shallowRef, computed, watch, onMounted }
86
-
38
+ decoration.value = newValue;
39
+ }, { deep: true });
40
+ const { rules } = useRules();
41
+ const trimmedTemplate = ref("");
42
+ const vueFunctions = { ref, shallowRef, computed, watch, onMounted };
87
43
  const templateScriptFunction = computed(() => {
88
- let templateScript = props.templateScript?.trim() || 'return {}'
89
- const pattern = /^\s*[{[].*[}\]]\s*$/
90
- if (pattern.test(templateScript)) templateScript = 'return {}'
91
- return Function('props', 'ctx', ...Object.keys(vueFunctions), templateScript)
92
- })
93
-
94
- const formPad = ref()
95
- const formInjectKey = Symbol.for('vuetify:form')
96
- const formInjected = ref()
97
-
98
- const formData = ref<any>({})
99
-
100
- function isBlankString(v: unknown): v is string {
101
- return isString(v) && v.trim().length === 0
44
+ let templateScript = props.templateScript?.trim() || "return {}";
45
+ const pattern = /^\s*[{[].*[}\]]\s*$/;
46
+ if (pattern.test(templateScript)) templateScript = "return {}";
47
+ return Function("props", "ctx", ...Object.keys(vueFunctions), templateScript);
48
+ });
49
+ const formPad = ref();
50
+ const formInjectKey = /* @__PURE__ */ Symbol.for("vuetify:form");
51
+ const formInjected = ref();
52
+ const formData = ref({});
53
+ function isBlankString(v) {
54
+ return isString(v) && v.trim().length === 0;
102
55
  }
103
-
104
- const sanitizeBlankStrings = debounce(sanitizeBlankStringsRaw, props.sanitizeDelay)
105
-
106
- function sanitizeBlankStringsRaw(val: any, original?: any): void {
56
+ const sanitizeBlankStrings = debounce(sanitizeBlankStringsRaw, props.sanitizeDelay);
57
+ function sanitizeBlankStringsRaw(val, original) {
107
58
  if (!original && props.originalData) {
108
- sanitizeBlankStrings(val, props.originalData)
109
- return
59
+ sanitizeBlankStrings(val, props.originalData);
60
+ return;
110
61
  }
111
-
112
62
  if (isArray(val)) {
113
63
  for (let i = val.length - 1; i >= 0; i--) {
114
- const item = val[i]
64
+ const item = val[i];
115
65
  if (isBlankString(item)) {
116
- val.splice(i, 1)
66
+ val.splice(i, 1);
117
67
  } else if (isPlainObject(item) || isArray(item)) {
118
- sanitizeBlankStrings(item,{})
68
+ sanitizeBlankStrings(item, {});
119
69
  } else {
120
- if (item && typeof item === 'string') val[i] = item.replace(/[ \t]+$/, '')
70
+ if (item && typeof item === "string") val[i] = item.replace(/[ \t]+$/, "");
121
71
  }
122
72
  }
123
- return
73
+ return;
124
74
  }
125
-
126
75
  if (isPlainObject(val)) {
127
76
  for (const key of Object.keys(val)) {
128
- const v = val[key]
77
+ const v = val[key];
129
78
  if (isBlankString(v)) {
130
- if (original && !Object.keys(original).includes(key)) delete val[key]
131
- else val[key] = null
79
+ if (original && !Object.keys(original).includes(key)) delete val[key];
80
+ else val[key] = null;
132
81
  } else if (isPlainObject(v) || isArray(v)) {
133
- let originalChild = (original && (isPlainObject(original[key]) || isArray(original[key]))) ? original[key] : {}
134
- sanitizeBlankStrings(v, originalChild)
82
+ let originalChild = original && (isPlainObject(original[key]) || isArray(original[key])) ? original[key] : {};
83
+ sanitizeBlankStrings(v, originalChild);
135
84
  } else {
136
- if (v && typeof v === 'string') val[key] = v.replace(/[ \t]+$/, '')
85
+ if (v && typeof v === "string") val[key] = v.replace(/[ \t]+$/, "");
137
86
  }
138
87
  }
139
88
  }
140
89
  }
141
-
142
- function autoSanitizedDisplay(item: any, separator: string = ","): string | undefined {
143
- const isEmptyScalar = (v: any) =>
144
- v === null ||
145
- v === undefined ||
146
- (typeof v === "string" && v.trim() === "") ||
147
- (typeof v === "number" && Number.isNaN(v));
148
-
149
- const toStr = (v: any): string | undefined => {
150
- if (isEmptyScalar(v)) return undefined;
90
+ function autoSanitizedDisplay(item, separator = ",") {
91
+ const isEmptyScalar = (v) => v === null || v === void 0 || typeof v === "string" && v.trim() === "" || typeof v === "number" && Number.isNaN(v);
92
+ const toStr = (v) => {
93
+ if (isEmptyScalar(v)) return void 0;
151
94
  if (typeof v === "string") return v.trim();
152
95
  if (typeof v === "number" || typeof v === "boolean" || typeof v === "bigint") return String(v);
153
96
  if (typeof v === "symbol") return v.description ?? String(v);
154
97
  if (typeof v === "function") return v.name ? `[Function ${v.name}]` : "[Function]";
155
- return undefined;
98
+ return void 0;
156
99
  };
157
-
158
- // 1) empty -> undefined
159
- if (isEmptyScalar(item)) return undefined;
160
-
161
- // 2) array -> recurse + join
100
+ if (isEmptyScalar(item)) return void 0;
162
101
  if (Array.isArray(item)) {
163
- const parts = item
164
- .map((x) => autoSanitizedDisplay(x, separator))
165
- .filter((s): s is string => typeof s === "string" && s.trim() !== "");
166
- return parts.length ? parts.join(separator) : undefined;
102
+ const parts = item.map((x) => autoSanitizedDisplay(x, separator)).filter((s) => typeof s === "string" && s.trim() !== "");
103
+ return parts.length ? parts.join(separator) : void 0;
167
104
  }
168
-
169
- // simple scalars
170
105
  const scalar = toStr(item);
171
- if (scalar !== undefined) return scalar;
172
-
173
- // 3) object
106
+ if (scalar !== void 0) return scalar;
174
107
  if (typeof item === "object") {
175
- // 3.1 label
176
108
  if ("label" in item) {
177
- const v = autoSanitizedDisplay((item as any).label, separator) ?? toStr((item as any).label);
178
- if (v !== undefined) return v;
109
+ const v = autoSanitizedDisplay(item.label, separator) ?? toStr(item.label);
110
+ if (v !== void 0) return v;
179
111
  }
180
- // 3.2 value
181
112
  if ("value" in item) {
182
- const v = autoSanitizedDisplay((item as any).value, separator) ?? toStr((item as any).value);
183
- if (v !== undefined) return v;
113
+ const v = autoSanitizedDisplay(item.value, separator) ?? toStr(item.value);
114
+ if (v !== void 0) return v;
184
115
  }
185
-
186
- // 3.3 stringify attributes as key:value (recurse values)
187
- const entries = Object.entries(item as Record<string, any>)
188
- .map(([k, v]) => {
189
- const rendered = autoSanitizedDisplay(v, separator) ?? toStr(v);
190
- if (rendered === undefined || rendered.trim() === "") return undefined;
191
- return `${k}:${rendered}`;
192
- })
193
- .filter((x): x is string => typeof x === "string" && x.trim() !== "");
194
-
195
- return entries.length ? entries.join(separator) : undefined;
116
+ const entries = Object.entries(item).map(([k, v]) => {
117
+ const rendered = autoSanitizedDisplay(v, separator) ?? toStr(v);
118
+ if (rendered === void 0 || rendered.trim() === "") return void 0;
119
+ return `${k}:${rendered}`;
120
+ }).filter((x) => typeof x === "string" && x.trim() !== "");
121
+ return entries.length ? entries.join(separator) : void 0;
196
122
  }
197
-
198
- // fallback
199
123
  try {
200
124
  const s = String(item);
201
- return s.trim() ? s : undefined;
125
+ return s.trim() ? s : void 0;
202
126
  } catch {
203
- return undefined;
127
+ return void 0;
204
128
  }
205
129
  }
206
-
207
130
  watch(formData, (newValue) => {
208
- sanitizeBlankStrings(newValue)
209
- emit('update:modelValue', newValue)
210
- }, { deep: true })
211
-
131
+ sanitizeBlankStrings(newValue);
132
+ emit("update:modelValue", newValue);
133
+ }, { deep: true });
212
134
  watch(() => props.modelValue, (newValue) => {
213
- formData.value = isObject(newValue) ? newValue : {}
214
- }, { deep: true, immediate: true })
215
-
216
- function diffPaths(
217
- a: any,
218
- b: any,
219
- base: string[] = [],
220
- out: string[] = []
221
- ): string[] {
222
- const keys = new Set<string>([
135
+ formData.value = isObject(newValue) ? newValue : {};
136
+ }, { deep: true, immediate: true });
137
+ function diffPaths(a, b, base = [], out = []) {
138
+ const keys = /* @__PURE__ */ new Set([
223
139
  ...Object.keys(a ?? {}),
224
- ...Object.keys(b ?? {}),
225
- ])
226
-
140
+ ...Object.keys(b ?? {})
141
+ ]);
227
142
  for (const k of keys) {
228
- const av = a?.[k]
229
- const bv = b?.[k]
230
- if (!av && !bv) continue // ignore when both are falsy
231
-
232
- const path = [...base, k]
233
-
143
+ const av = a?.[k];
144
+ const bv = b?.[k];
145
+ if (!av && !bv) continue;
146
+ const path = [...base, k];
234
147
  if (isPlainObject(av) && isPlainObject(bv)) {
235
- diffPaths(av, bv, path, out)
236
- continue
148
+ diffPaths(av, bv, path, out);
149
+ continue;
237
150
  }
238
-
239
151
  if (!isEqual(av, bv)) {
240
- out.push(path.join('.'))
152
+ out.push(path.join("."));
241
153
  }
242
154
  }
243
-
244
- return out
155
+ return out;
245
156
  }
246
-
247
- const injectedClass = computed<Record<string, string>>(() => {
248
- const data = (formData.value ?? {}) as Record<string, any>
249
- const result: Record<string, string> = {}
250
-
251
- if (!props.dirtyOnCreate && !props.originalData) return result
252
-
253
- const original = (props.originalData ?? {}) as Record<string, any>
254
- const cls = props.dirtyClass || 'form-data-dirty'
255
-
256
- const paths = diffPaths(data, original)
257
- for (const p of paths) result[p] = cls
258
-
259
- return result
260
- })
261
-
262
- const formComponent = shallowRef()
263
-
157
+ const injectedClass = computed(() => {
158
+ const data = formData.value ?? {};
159
+ const result = {};
160
+ if (!props.dirtyOnCreate && !props.originalData) return result;
161
+ const original = props.originalData ?? {};
162
+ const cls = props.dirtyClass || "form-data-dirty";
163
+ const paths = diffPaths(data, original);
164
+ for (const p of paths) result[p] = cls;
165
+ return result;
166
+ });
167
+ const formComponent = shallowRef();
264
168
  function buildFormComponent() {
265
- if (!trimmedTemplate.value) return
266
- const originalConsoleError = console.warn
267
- console.warn = (error: any) => { throw new Error(error) } // eslint-disable-line
169
+ if (!trimmedTemplate.value) return;
170
+ const originalConsoleError = console.warn;
171
+ console.warn = (error) => {
172
+ throw new Error(error);
173
+ };
268
174
  try {
269
- const componentTemplate = '<form-pad ref="formPadTemplate" v-model="formComponentData" :originalData="originalData" :disabled="disabled" :readonly="readonly" :decoration="decoration" :isolated="isolated"><template v-slot="{ data,isDisabled,isReadonly,rules,formProvided,decoration,injectedClass }">' + trimmedTemplate.value + '</template></form-pad>'
270
- compile(componentTemplate)
175
+ const componentTemplate = '<form-pad ref="formPadTemplate" v-model="formComponentData" :originalData="originalData" :disabled="disabled" :readonly="readonly" :decoration="decoration" :isolated="isolated"><template v-slot="{ data,isDisabled,isReadonly,rules,formProvided,decoration,injectedClass }">' + trimmedTemplate.value + "</template></form-pad>";
176
+ compile(componentTemplate);
271
177
  formComponent.value = defineComponent({
272
178
  components: { FormPad },
273
179
  props: {
274
- modelValue: { type: Object, default: undefined },
275
- originalData: { type: Object, default: undefined },
180
+ modelValue: { type: Object, default: void 0 },
181
+ originalData: { type: Object, default: void 0 },
276
182
  disabled: { type: Boolean, default: false },
277
183
  readonly: { type: Boolean, default: false },
278
- decoration: { type: Object, default: () => { return {} } },
279
- isolated: { type: Boolean, default: false },
184
+ decoration: { type: Object, default: () => {
185
+ return {};
186
+ } },
187
+ isolated: { type: Boolean, default: false }
280
188
  },
281
- emits: ['update:modelValue'],
282
- setup(props, ctx) {
283
- const formComponentData = ref<any>({})
284
- const formPadTemplate = ref<any>({})
189
+ emits: ["update:modelValue"],
190
+ setup(props2, ctx) {
191
+ const formComponentData = ref({});
192
+ const formPadTemplate = ref({});
285
193
  watch(formComponentData, (newValue) => {
286
- sanitizeBlankStrings(newValue)
287
- ctx.emit('update:modelValue', newValue)
288
- }, { deep: true })
289
- watch(() => props.modelValue, (newValue) => {
290
- formComponentData.value = isObject(newValue) ? newValue : {}
291
- }, { deep: true, immediate: true })
292
- const isValid = computed(() => formPadTemplate.value.isValid)
194
+ sanitizeBlankStrings(newValue);
195
+ ctx.emit("update:modelValue", newValue);
196
+ }, { deep: true });
197
+ watch(() => props2.modelValue, (newValue) => {
198
+ formComponentData.value = isObject(newValue) ? newValue : {};
199
+ }, { deep: true, immediate: true });
200
+ const isValid2 = computed(() => formPadTemplate.value.isValid);
293
201
  return {
294
202
  formComponentData,
295
203
  formPadTemplate,
296
204
  reset: () => formPadTemplate.value.reset(),
297
205
  validate: () => formPadTemplate.value.validate(),
298
206
  resetValidate: () => formPadTemplate.value.resetValidate(),
299
- isValid,
300
- ...templateScriptFunction.value(props, ctx, ...Object.values(vueFunctions)),
207
+ isValid: isValid2,
208
+ ...templateScriptFunction.value(props2, ctx, ...Object.values(vueFunctions)),
301
209
  autoSanitizedDisplay
302
- }
210
+ };
303
211
  },
304
- template: componentTemplate,
305
- })
212
+ template: componentTemplate
213
+ });
214
+ } catch (e) {
215
+ formComponent.value = null;
216
+ console.error(e);
306
217
  }
307
- catch (e) {
308
- formComponent.value = null
309
- console.error(e)
310
- }
311
- console.warn = originalConsoleError
218
+ console.warn = originalConsoleError;
312
219
  }
313
-
314
220
  function reset() {
315
- if (!formInjected.value) formPad.value.reset()
316
- else formInjected.value.items.forEach((item: any) => item.reset())
221
+ if (!formInjected.value) formPad.value.reset();
222
+ else formInjected.value.items.forEach((item) => item.reset());
317
223
  }
318
-
319
224
  function validate() {
320
- if (!formInjected.value) formPad.value.validate()
321
- else formInjected.value.items.forEach((item: any) => item.validate())
225
+ if (!formInjected.value) formPad.value.validate();
226
+ else formInjected.value.items.forEach((item) => item.validate());
322
227
  }
323
-
324
228
  function resetValidate() {
325
- if (!formInjected.value) formPad.value.resetValidate()
326
- else formInjected.value.items.forEach((item: any) => item.resetValidate())
229
+ if (!formInjected.value) formPad.value.resetValidate();
230
+ else formInjected.value.items.forEach((item) => item.resetValidate());
327
231
  }
328
-
329
232
  const isValid = computed(() => {
330
- validate()
331
- return formInjected.value ? formInjected.value.isValid || false : formPad.value.isValid || false
332
- })
333
-
233
+ validate();
234
+ return formInjected.value ? formInjected.value.isValid || false : formPad.value.isValid || false;
235
+ });
334
236
  onMounted(() => {
335
- if (!props.isolated) formInjected.value = inject(formInjectKey, false)
336
- buildFormComponent()
337
- })
338
-
237
+ if (!props.isolated) formInjected.value = inject(formInjectKey, false);
238
+ buildFormComponent();
239
+ });
339
240
  watchDebounced(() => props.template, (newValue) => {
340
- trimmedTemplate.value = useDocumentTemplate(newValue,props.parentTemplates).trim() || ''
341
- buildFormComponent()
342
- }, { debounce: 500, maxWait: 5000, deep: true, immediate: true })
343
- watchDebounced(() => props.templateScript, buildFormComponent, { debounce: 500, maxWait: 5000 })
344
-
241
+ trimmedTemplate.value = useDocumentTemplate(newValue, props.parentTemplates).trim() || "";
242
+ buildFormComponent();
243
+ }, { debounce: 500, maxWait: 5e3, deep: true, immediate: true });
244
+ watchDebounced(() => props.templateScript, buildFormComponent, { debounce: 500, maxWait: 5e3 });
345
245
  defineExpose({
346
246
  isValid,
347
247
  disabled,
348
248
  readonly,
349
249
  reset,
350
250
  validate,
351
- resetValidate,
352
- })
251
+ resetValidate
252
+ });
353
253
  </script>
354
254
 
355
255
  <template>
@@ -397,6 +297,7 @@ defineExpose({
397
297
  :class="$attrs.class"
398
298
  />
399
299
  </template>
300
+
400
301
  <style>
401
302
  .form-data-dirty:not(.v-input--error) :not(.v-chip):not(.v-chip *){color:color-mix(in srgb,currentColor 70%,rgb(var(--v-theme-primary)))!important;text-shadow:0 0 .02em currentColor}
402
- </style>
303
+ </style>