@ramathibodi/nuxt-commons 0.1.73 → 4.0.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 (260) hide show
  1. package/README.md +81 -55
  2. package/dist/module.json +4 -4
  3. package/dist/module.mjs +5 -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 -22
  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 -73
  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 -68
  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 -38
  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 -99
  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 +128 -0
  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 -27
  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 -12
  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 -33
  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 -55
  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 -153
  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 -166
  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 -47
  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 -53
  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 -28
  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 -17
  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 -50
  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 -17
  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 -36
  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 -17
  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 -70
  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 -34
  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 -182
  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 -73
  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 -64
  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 -52
  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 -28
  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 -150
  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 -131
  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 -84
  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 -73
  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 -174
  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 -22
  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 -240
  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 -43
  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 -253
  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 -118
  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 -24
  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 -170
  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 -127
  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 -87
  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 -139
  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 -69
  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 -194
  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 -28
  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 -21
  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 -67
  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 -97
  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 -32
  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 -20
  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 -30
  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 -12
  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 -26
  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 -27
  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 -47
  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 -26
  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 -34
  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 -37
  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 -37
  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 -53
  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 -32
  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 -133
  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 -175
  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 -35
  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 -38
  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 -83
  205. package/dist/runtime/components/pdf/View.vue.d.ts +52 -0
  206. package/dist/runtime/composables/alert.d.ts +4 -0
  207. package/dist/runtime/composables/api.d.ts +4 -0
  208. package/dist/runtime/composables/api.js +4 -2
  209. package/dist/runtime/composables/assetFile.js +4 -2
  210. package/dist/runtime/composables/dialog.d.ts +1 -1
  211. package/dist/runtime/composables/document/template.js +3 -3
  212. package/dist/runtime/composables/document/templateFormHidden.d.ts +4 -0
  213. package/dist/runtime/composables/document/templateFormTable.js +1 -0
  214. package/dist/runtime/composables/graphql.d.ts +2 -2
  215. package/dist/runtime/composables/graphql.js +5 -5
  216. package/dist/runtime/composables/graphqlModel.d.ts +6 -6
  217. package/dist/runtime/composables/graphqlModelItem.d.ts +4 -4
  218. package/dist/runtime/composables/graphqlModelOperation.d.ts +6 -6
  219. package/dist/runtime/composables/graphqlModelOperation.js +2 -1
  220. package/dist/runtime/composables/graphqlOperation.js +5 -1
  221. package/dist/runtime/composables/hostAgentWs.d.ts +1 -1
  222. package/dist/runtime/composables/localStorageModel.d.ts +4 -0
  223. package/dist/runtime/composables/lookupList.d.ts +4 -0
  224. package/dist/runtime/composables/lookupListMaster.js +3 -3
  225. package/dist/runtime/composables/menu.d.ts +4 -0
  226. package/dist/runtime/composables/menu.js +2 -2
  227. package/dist/runtime/composables/useMrzReader.d.ts +48 -0
  228. package/dist/runtime/composables/useMrzReader.js +423 -0
  229. package/dist/runtime/composables/useTesseract.d.ts +16 -0
  230. package/dist/runtime/composables/useTesseract.js +45 -0
  231. package/dist/runtime/composables/userPermission.d.ts +1 -1
  232. package/dist/runtime/composables/utils/fuzzy.d.ts +2 -1
  233. package/dist/runtime/labs/Calendar.d.vue.ts +35 -0
  234. package/dist/runtime/labs/Calendar.vue +47 -75
  235. package/dist/runtime/labs/Calendar.vue.d.ts +35 -0
  236. package/dist/runtime/labs/form/EditMobile.d.vue.ts +12 -0
  237. package/dist/runtime/labs/form/EditMobile.vue +19 -36
  238. package/dist/runtime/labs/form/EditMobile.vue.d.ts +12 -0
  239. package/dist/runtime/labs/form/TextFieldMask.d.vue.ts +21 -0
  240. package/dist/runtime/labs/form/TextFieldMask.vue +19 -25
  241. package/dist/runtime/labs/form/TextFieldMask.vue.d.ts +21 -0
  242. package/dist/runtime/plugins/dialogManager.js +2 -2
  243. package/dist/runtime/plugins/permission.js +3 -3
  244. package/dist/runtime/types/bridge.d.ts +14 -0
  245. package/dist/runtime/utils/asset.d.ts +2 -0
  246. package/dist/runtime/utils/asset.js +49 -0
  247. package/dist/runtime/utils/datetime.js +1 -1
  248. package/dist/types.d.mts +2 -6
  249. package/package.json +79 -57
  250. package/scripts/ci-release.mjs +125 -0
  251. package/scripts/enrich-vue-docs-from-ai.mjs +197 -0
  252. package/scripts/generate-ai-summary.mjs +321 -0
  253. package/scripts/generate-composables-md.mjs +129 -0
  254. package/scripts/release-version.mjs +68 -0
  255. package/scripts/release.mjs +49 -0
  256. package/templates/public/tesseract/mrz.traineddata.gz +0 -0
  257. package/templates/public/tesseract/ocrb.traineddata.gz +0 -0
  258. package/dist/module.cjs +0 -5
  259. package/dist/module.d.ts +0 -8
  260. package/dist/types.d.ts +0 -7
@@ -1,225 +1,163 @@
1
- <script lang="ts" setup>
2
- import { castArray } from 'lodash-es'
3
- import { ref, shallowRef, watch, computed } from 'vue'
4
- import { VTextField } from 'vuetify/components/VTextField'
5
- import { useAlert } from '../../composables/alert'
6
- import { type Base64File } from '../../composables/assetFile'
7
- import { useAssetFile } from '../../composables/assetFile'
8
-
9
- const alert = useAlert()
10
- const { hydrateAssetFile, base64ToFile, fileToBase64, downloadBase64File } = useAssetFile()
11
-
12
- const fileToBase64WithMaxSize = (file: File) => fileToBase64(file, props.maxSize)
13
-
14
- interface Props extends /* @vue-ignore */ InstanceType<typeof VTextField['$props']> {
15
- accept?: string
16
- multiple?: boolean
17
- maxSize?: number
18
- modelValue?: Base64File | Base64File[] | null
19
- downloadable?: boolean
20
- autoHydrate?: boolean
21
- }
22
-
23
- const props = withDefaults(defineProps<Props>(), {
24
- accept: '*',
25
- multiple: false,
26
- maxSize: 5,
27
- downloadable: false,
28
- autoHydrate: false,
29
- })
30
-
31
- const emit = defineEmits<{
32
- (e: 'update:modelValue', value: Base64File | Base64File[] | null): void
33
- }>()
34
-
35
- /** UI ref */
36
- const fileInput = ref<HTMLInputElement | null>(null)
37
-
38
- /** Internal sources (always arrays) */
39
- const assets = ref<Base64File[]>([]) // items with server id (or ones we keep as “assets”)
40
- const files = shallowRef<File[]>([]) // native File objects picked by the user
41
-
42
- /** Cache to avoid re-reading the same File repeatedly */
43
- const fileCache = new WeakMap<File, Promise<Base64File>>()
44
-
45
- /** Re-entrancy guard to break the emit -> props watcher -> syncFromModel loop */
46
- let internalSync = false
47
-
48
- /** Build a stable dedupe key */
49
- function base64FileKey(x: Base64File): string {
50
- if (x.id != null) return `id:${x.id}`
51
- const name = x.fileName ?? ''
52
- const len = x.base64String?.length ?? 0
53
- return `n:${name}|l:${len}`
1
+ <script setup>
2
+ import { castArray } from "lodash-es";
3
+ import { ref, shallowRef, watch, computed } from "vue";
4
+ import { VTextField } from "vuetify/components/VTextField";
5
+ import { useAlert } from "../../composables/alert";
6
+ import {} from "../../composables/assetFile";
7
+ import { useAssetFile } from "../../composables/assetFile";
8
+ const alert = useAlert();
9
+ const { hydrateAssetFile, base64ToFile, fileToBase64, downloadBase64File } = useAssetFile();
10
+ const fileToBase64WithMaxSize = (file) => fileToBase64(file, props.maxSize);
11
+ const props = defineProps({
12
+ accept: { type: String, required: false, default: "*" },
13
+ multiple: { type: Boolean, required: false, default: false },
14
+ maxSize: { type: Number, required: false, default: 5 },
15
+ modelValue: { type: [Object, Array, null], required: false },
16
+ downloadable: { type: Boolean, required: false, default: false },
17
+ autoHydrate: { type: Boolean, required: false, default: false }
18
+ });
19
+ const emit = defineEmits(["update:modelValue"]);
20
+ const fileInput = ref(null);
21
+ const assets = ref([]);
22
+ const files = shallowRef([]);
23
+ const fileCache = /* @__PURE__ */ new WeakMap();
24
+ let internalSync = false;
25
+ function base64FileKey(x) {
26
+ if (x.id != null) return `id:${x.id}`;
27
+ const name = x.fileName ?? "";
28
+ const len = x.base64String?.length ?? 0;
29
+ return `n:${name}|l:${len}`;
54
30
  }
55
-
56
- /** Dedupe by key (preserves order) */
57
- function uniqByKey(arr: Base64File[]): Base64File[] {
58
- const seen = new Set<string>()
59
- const out: Base64File[] = []
31
+ function uniqByKey(arr) {
32
+ const seen = /* @__PURE__ */ new Set();
33
+ const out = [];
60
34
  for (const it of arr) {
61
- const k = base64FileKey(it)
35
+ const k = base64FileKey(it);
62
36
  if (!seen.has(k)) {
63
- seen.add(k)
64
- out.push(it)
37
+ seen.add(k);
38
+ out.push(it);
65
39
  }
66
40
  }
67
- return out
41
+ return out;
68
42
  }
69
-
70
- /** Shallow equal by key sequence */
71
- function arraysEqualByKey(a: Base64File[], b: Base64File[]): boolean {
72
- if (a === b) return true
73
- if (a.length !== b.length) return false
43
+ function arraysEqualByKey(a, b) {
44
+ if (a === b) return true;
45
+ if (a.length !== b.length) return false;
74
46
  for (let i = 0; i < a.length; i++) {
75
- if (base64FileKey(a[i]) !== base64FileKey(b[i])) return false
47
+ if (base64FileKey(a[i]) !== base64FileKey(b[i])) return false;
76
48
  }
77
- return true
49
+ return true;
78
50
  }
79
-
80
- /** Normalize incoming modelValue into arrays for internal use */
81
51
  async function syncFromModel() {
82
- const mv = props.modelValue
52
+ const mv = props.modelValue;
83
53
  if (!mv) {
84
- assets.value = []
85
- files.value = []
86
- return
54
+ assets.value = [];
55
+ files.value = [];
56
+ return;
87
57
  }
88
-
89
- const asArray = castArray(mv) as Base64File[]
90
-
91
- // Split into “asset with id” vs “inline base64” (no id)
92
- const incomingAssets = asArray.filter(a => a.id != null)
93
- const inlineBase64 = asArray.filter(a => a.id == null && a.base64String)
94
-
95
- // Convert inline base64 to File for consistent UX
96
- const inlineFiles: File[] = []
58
+ const asArray = castArray(mv);
59
+ const incomingAssets = asArray.filter((a) => a.id != null);
60
+ const inlineBase64 = asArray.filter((a) => a.id == null && a.base64String);
61
+ const inlineFiles = [];
97
62
  for (const item of inlineBase64) {
98
- const f = base64ToFile(item.base64String as string, item.fileName)
99
- if (f) inlineFiles.push(f)
63
+ const f = base64ToFile(item.base64String, item.fileName);
64
+ if (f) inlineFiles.push(f);
100
65
  }
101
-
102
- assets.value = incomingAssets
103
- files.value = inlineFiles
104
-
105
- // Optionally hydrate assets that need it
66
+ assets.value = incomingAssets;
67
+ files.value = inlineFiles;
106
68
  if (props.autoHydrate) {
107
- const needsHydration = assets.value.filter(a => a.id != null && !a.base64String)
69
+ const needsHydration = assets.value.filter((a) => a.id != null && !a.base64String);
108
70
  if (needsHydration.length) {
109
- await Promise.allSettled(needsHydration.map(hydrateAssetFile))
71
+ await Promise.allSettled(needsHydration.map(hydrateAssetFile));
110
72
  }
111
73
  }
112
74
  }
113
-
114
- /** Open chooser */
115
75
  function openWindowUpload() {
116
- if (props.multiple || (assets.value.length === 0 && files.value.length === 0)) {
117
- fileInput.value?.click()
76
+ if (props.multiple || assets.value.length === 0 && files.value.length === 0) {
77
+ fileInput.value?.click();
118
78
  }
119
79
  }
120
-
121
- /** Add files from input (single or multiple) */
122
- function addFiles(payload: File | File[]) {
123
- if (Array.isArray(payload)) files.value = [...files.value, ...payload]
124
- else files.value = [...files.value, payload]
80
+ function addFiles(payload) {
81
+ if (Array.isArray(payload)) files.value = [...files.value, ...payload];
82
+ else files.value = [...files.value, payload];
125
83
  }
126
-
127
- /** Remove chips */
128
- function removeFileByIndex(i: number | string) {
129
- const idx = Number(i)
84
+ function removeFileByIndex(i) {
85
+ const idx = Number(i);
130
86
  if (idx >= 0 && idx < files.value.length) {
131
- const copy = files.value.slice()
132
- copy.splice(idx, 1)
133
- files.value = copy
87
+ const copy = files.value.slice();
88
+ copy.splice(idx, 1);
89
+ files.value = copy;
134
90
  }
135
91
  }
136
- function removeAssetByIndex(i: number | string) {
137
- const idx = Number(i)
92
+ function removeAssetByIndex(i) {
93
+ const idx = Number(i);
138
94
  if (idx >= 0 && idx < assets.value.length) {
139
- const copy = assets.value.slice()
140
- copy.splice(idx, 1)
141
- assets.value = copy
95
+ const copy = assets.value.slice();
96
+ copy.splice(idx, 1);
97
+ assets.value = copy;
142
98
  }
143
99
  }
144
-
145
- /** Convert current files → Base64File[] (cached) */
146
- async function filesToBase64Files(list: File[]): Promise<Base64File[]> {
147
- const tasks = list.map(f => {
148
- let p = fileCache.get(f)
100
+ async function filesToBase64Files(list) {
101
+ const tasks = list.map((f) => {
102
+ let p = fileCache.get(f);
149
103
  if (!p) {
150
- p = fileToBase64WithMaxSize(f)
151
- fileCache.set(f, p)
104
+ p = fileToBase64WithMaxSize(f);
105
+ fileCache.set(f, p);
152
106
  }
153
- return p
154
- })
155
- return Promise.all(tasks)
107
+ return p;
108
+ });
109
+ return Promise.all(tasks);
156
110
  }
157
-
158
- /** Combined result (array form) */
159
- const combinedArray = ref<Base64File[]>([])
160
-
161
- /** Dirty flag for <v-text-field> */
162
- const isDirty = computed(() =>
163
- props.multiple ? combinedArray.value.length > 0 : combinedArray.value[0] != null
164
- )
165
-
166
- /** Sync from props.modelValue (guarded) */
111
+ const combinedArray = ref([]);
112
+ const isDirty = computed(
113
+ () => props.multiple ? combinedArray.value.length > 0 : combinedArray.value[0] != null
114
+ );
167
115
  watch(
168
- () => props.modelValue,
169
- () => {
170
- if (internalSync) return
171
- void syncFromModel()
172
- },
173
- { deep: true, immediate: true }
174
- )
175
-
176
- /** Rebuild combined and emit (guarded, deduped, only-on-change) */
116
+ () => props.modelValue,
117
+ () => {
118
+ if (internalSync) return;
119
+ void syncFromModel();
120
+ },
121
+ { deep: true, immediate: true }
122
+ );
177
123
  watch([assets, files], async () => {
178
124
  try {
179
- const base64FromFiles = await filesToBase64Files(files.value)
180
-
181
- const mergedArray = props.multiple
182
- ? [...assets.value, ...base64FromFiles]
183
- : (assets.value[0] ?? base64FromFiles[0] ?? null)
184
- ? [assets.value[0] ?? base64FromFiles[0]]
185
- : []
186
-
187
- const nextCombined = props.multiple ? uniqByKey(mergedArray) : mergedArray
188
-
125
+ const base64FromFiles = await filesToBase64Files(files.value);
126
+ const mergedArray = props.multiple ? [...assets.value, ...base64FromFiles] : assets.value[0] ?? base64FromFiles[0] ?? null ? [assets.value[0] ?? base64FromFiles[0]] : [];
127
+ const nextCombined = props.multiple ? uniqByKey(mergedArray) : mergedArray;
189
128
  if (!arraysEqualByKey(combinedArray.value, nextCombined)) {
190
- combinedArray.value = nextCombined
191
-
192
- internalSync = true
129
+ combinedArray.value = nextCombined;
130
+ internalSync = true;
193
131
  try {
194
132
  if (props.multiple) {
195
- emit('update:modelValue', combinedArray.value)
133
+ emit("update:modelValue", combinedArray.value);
196
134
  } else {
197
- emit('update:modelValue', combinedArray.value[0] ?? null)
135
+ emit("update:modelValue", combinedArray.value[0] ?? null);
198
136
  }
199
137
  } finally {
200
- // let Vue flush the emit before re-enabling the external sync
201
- queueMicrotask(() => { internalSync = false })
138
+ queueMicrotask(() => {
139
+ internalSync = false;
140
+ });
202
141
  }
203
142
  }
204
- } catch (error: any) {
205
- alert?.addAlert({ message: String(error), alertType: 'error' })
206
- files.value = []
207
- const fallback = props.multiple
208
- ? [...assets.value]
209
- : (assets.value[0] ? [assets.value[0]] : [])
210
-
143
+ } catch (error) {
144
+ alert?.addAlert({ message: String(error), alertType: "error" });
145
+ files.value = [];
146
+ const fallback = props.multiple ? [...assets.value] : assets.value[0] ? [assets.value[0]] : [];
211
147
  if (!arraysEqualByKey(combinedArray.value, fallback)) {
212
- combinedArray.value = fallback
213
- internalSync = true
148
+ combinedArray.value = fallback;
149
+ internalSync = true;
214
150
  try {
215
- if (props.multiple) emit('update:modelValue', combinedArray.value)
216
- else emit('update:modelValue', combinedArray.value[0] ?? null)
151
+ if (props.multiple) emit("update:modelValue", combinedArray.value);
152
+ else emit("update:modelValue", combinedArray.value[0] ?? null);
217
153
  } finally {
218
- queueMicrotask(() => { internalSync = false })
154
+ queueMicrotask(() => {
155
+ internalSync = false;
156
+ });
219
157
  }
220
158
  }
221
159
  }
222
- }, { deep: true, immediate: true })
160
+ }, { deep: true, immediate: true });
223
161
  </script>
224
162
 
225
163
  <template>
@@ -281,4 +219,4 @@ watch([assets, files], async () => {
281
219
  style="display: none"
282
220
  @update:model-value="addFiles"
283
221
  />
284
- </template>
222
+ </template>
@@ -0,0 +1,65 @@
1
+ import { VTextField } from 'vuetify/components/VTextField';
2
+ import { type Base64File } from '../../composables/assetFile.js';
3
+ interface Props extends /* @vue-ignore */ InstanceType<typeof VTextField['$props']> {
4
+ accept?: string;
5
+ multiple?: boolean;
6
+ maxSize?: number;
7
+ modelValue?: Base64File | Base64File[] | null;
8
+ downloadable?: boolean;
9
+ autoHydrate?: boolean;
10
+ }
11
+ declare var __VLS_17: {
12
+ item: {
13
+ fileName: string;
14
+ originalFileName?: string | undefined;
15
+ fileType?: string | undefined;
16
+ id?: number | undefined;
17
+ base64String?: string | undefined;
18
+ };
19
+ };
20
+ type __VLS_Slots = {} & {
21
+ download?: (props: typeof __VLS_17) => any;
22
+ };
23
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
24
+ accept: string;
25
+ multiple: boolean;
26
+ maxSize: number;
27
+ downloadable: boolean;
28
+ autoHydrate: boolean;
29
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
30
+ "update:modelValue": (value: Base64File | Base64File[] | null) => any;
31
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
32
+ accept: string;
33
+ multiple: boolean;
34
+ maxSize: number;
35
+ downloadable: boolean;
36
+ autoHydrate: boolean;
37
+ }>>> & Readonly<{
38
+ "onUpdate:modelValue"?: ((value: Base64File | Base64File[] | null) => any) | undefined;
39
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
41
+ declare const _default: typeof __VLS_export;
42
+ export default _default;
43
+ type __VLS_TypePropsToOption<T> = {
44
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
45
+ type: import('vue').PropType<Required<T>[K]>;
46
+ } : {
47
+ type: import('vue').PropType<T[K]>;
48
+ required: true;
49
+ };
50
+ };
51
+ type __VLS_WithDefaults<P, D> = {
52
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
53
+ default: D[K];
54
+ }> : P[K];
55
+ };
56
+ type __VLS_WithSlots<T, S> = T & {
57
+ new (): {
58
+ $slots: S;
59
+ };
60
+ };
61
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
62
+ [K in keyof T]: T[K];
63
+ } : {
64
+ [K in keyof T as K]: T[K];
65
+ }) & {};
@@ -0,0 +1,12 @@
1
+ interface Props {
2
+ itemValue?: any;
3
+ hook?: Function;
4
+ modelValue?: any;
5
+ }
6
+ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ "update:modelValue": (...args: any[]) => void;
8
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
9
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -1,27 +1,22 @@
1
- <script lang="ts" setup>
2
- import { watch } from 'vue'
3
- import { cloneDeep } from 'lodash-es'
4
-
5
- interface Props {
6
- itemValue?: any
7
- hook?: Function
8
- modelValue?: any
9
- }
10
-
11
- const props = defineProps<Props>()
12
- const emit = defineEmits(['update:modelValue'])
13
-
14
- watch(() => props.itemValue, (newValue,oldValue) => {
15
- const resultValue = cloneDeep(newValue)
1
+ <script setup>
2
+ import { watch } from "vue";
3
+ import { cloneDeep } from "lodash-es";
4
+ const props = defineProps({
5
+ itemValue: { type: null, required: false },
6
+ hook: { type: Function, required: false },
7
+ modelValue: { type: null, required: false }
8
+ });
9
+ const emit = defineEmits(["update:modelValue"]);
10
+ watch(() => props.itemValue, (newValue, oldValue) => {
11
+ const resultValue = cloneDeep(newValue);
16
12
  if (props.hook) {
17
- Promise.resolve(props.hook(resultValue, props.modelValue,newValue,oldValue)).then((result) => {
18
- emit('update:modelValue', result)
19
- }).catch(e => void e)
20
- }
21
- else {
22
- emit('update:modelValue', resultValue)
13
+ Promise.resolve(props.hook(resultValue, props.modelValue, newValue, oldValue)).then((result) => {
14
+ emit("update:modelValue", result);
15
+ }).catch((e) => void e);
16
+ } else {
17
+ emit("update:modelValue", resultValue);
23
18
  }
24
- }, { deep: true, immediate: true })
19
+ }, { deep: true, immediate: true });
25
20
  </script>
26
21
 
27
22
  <template>
@@ -0,0 +1,12 @@
1
+ interface Props {
2
+ itemValue?: any;
3
+ hook?: Function;
4
+ modelValue?: any;
5
+ }
6
+ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ "update:modelValue": (...args: any[]) => void;
8
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
9
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;