@ramathibodi/nuxt-commons 4.0.27 → 4.0.29

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 (118) hide show
  1. package/dist/module.json +2 -2
  2. package/dist/runtime/components/Calendar.d.vue.ts +12 -10
  3. package/dist/runtime/components/Calendar.vue.d.ts +12 -10
  4. package/dist/runtime/components/ExportCSV.d.vue.ts +3 -3
  5. package/dist/runtime/components/ExportCSV.vue.d.ts +3 -3
  6. package/dist/runtime/components/FileBtn.d.vue.ts +3 -3
  7. package/dist/runtime/components/FileBtn.vue.d.ts +3 -3
  8. package/dist/runtime/components/ImportCSV.d.vue.ts +3 -3
  9. package/dist/runtime/components/ImportCSV.vue.d.ts +3 -3
  10. package/dist/runtime/components/SplitterPanel.d.vue.ts +7 -5
  11. package/dist/runtime/components/SplitterPanel.vue.d.ts +7 -5
  12. package/dist/runtime/components/TabsGroup.d.vue.ts +7 -5
  13. package/dist/runtime/components/TabsGroup.vue.d.ts +7 -5
  14. package/dist/runtime/components/device/IdCardButton.d.vue.ts +3 -3
  15. package/dist/runtime/components/device/IdCardButton.vue.d.ts +3 -3
  16. package/dist/runtime/components/device/Scanner.d.vue.ts +31 -29
  17. package/dist/runtime/components/device/Scanner.vue.d.ts +31 -29
  18. package/dist/runtime/components/dialog/Confirm.d.vue.ts +7 -5
  19. package/dist/runtime/components/dialog/Confirm.vue.d.ts +7 -5
  20. package/dist/runtime/components/dialog/ImportProgress.d.vue.ts +5 -3
  21. package/dist/runtime/components/dialog/ImportProgress.vue.d.ts +5 -3
  22. package/dist/runtime/components/dialog/Index.d.vue.ts +5 -3
  23. package/dist/runtime/components/dialog/Index.vue.d.ts +5 -3
  24. package/dist/runtime/components/dialog/Loading.d.vue.ts +5 -3
  25. package/dist/runtime/components/dialog/Loading.vue.d.ts +5 -3
  26. package/dist/runtime/components/dialog/default/Confirm.d.vue.ts +7 -5
  27. package/dist/runtime/components/dialog/default/Confirm.vue.d.ts +7 -5
  28. package/dist/runtime/components/dialog/default/Loading.d.vue.ts +7 -5
  29. package/dist/runtime/components/dialog/default/Loading.vue.d.ts +7 -5
  30. package/dist/runtime/components/dialog/default/Printing.d.vue.ts +5 -3
  31. package/dist/runtime/components/dialog/default/Printing.vue.d.ts +5 -3
  32. package/dist/runtime/components/document/TemplateBuilderLiveView.d.vue.ts +71 -69
  33. package/dist/runtime/components/document/TemplateBuilderLiveView.vue.d.ts +71 -69
  34. package/dist/runtime/components/document/TemplateInputAttributesHelper.d.vue.ts +14 -0
  35. package/dist/runtime/components/document/TemplateInputAttributesHelper.vue +154 -0
  36. package/dist/runtime/components/document/TemplateInputAttributesHelper.vue.d.ts +14 -0
  37. package/dist/runtime/components/document/TemplateItemForm.vue +46 -1
  38. package/dist/runtime/components/document/TemplatePalette.d.vue.ts +8 -6
  39. package/dist/runtime/components/document/TemplatePalette.vue +16 -0
  40. package/dist/runtime/components/document/TemplatePalette.vue.d.ts +8 -6
  41. package/dist/runtime/components/form/ActionPad.d.vue.ts +34 -32
  42. package/dist/runtime/components/form/ActionPad.vue.d.ts +34 -32
  43. package/dist/runtime/components/form/Date.d.vue.ts +20 -18
  44. package/dist/runtime/components/form/Date.vue.d.ts +20 -18
  45. package/dist/runtime/components/form/Dialog.d.vue.ts +24 -22
  46. package/dist/runtime/components/form/Dialog.vue.d.ts +24 -22
  47. package/dist/runtime/components/form/EditPad.d.vue.ts +34 -32
  48. package/dist/runtime/components/form/EditPad.vue.d.ts +34 -32
  49. package/dist/runtime/components/form/File.d.vue.ts +12 -10
  50. package/dist/runtime/components/form/File.vue.d.ts +12 -10
  51. package/dist/runtime/components/form/Iterator.d.vue.ts +121 -134
  52. package/dist/runtime/components/form/Iterator.vue.d.ts +121 -134
  53. package/dist/runtime/components/form/Login.d.vue.ts +5 -3
  54. package/dist/runtime/components/form/Login.vue.d.ts +5 -3
  55. package/dist/runtime/components/form/Pad.d.vue.ts +652 -650
  56. package/dist/runtime/components/form/Pad.vue +3 -0
  57. package/dist/runtime/components/form/Pad.vue.d.ts +652 -650
  58. package/dist/runtime/components/form/Table.d.vue.ts +69 -82
  59. package/dist/runtime/components/form/Table.vue.d.ts +69 -82
  60. package/dist/runtime/components/form/TableData.d.vue.ts +18 -24
  61. package/dist/runtime/components/form/TableData.vue.d.ts +18 -24
  62. package/dist/runtime/components/form/images/Capture.d.vue.ts +15 -13
  63. package/dist/runtime/components/form/images/Capture.vue.d.ts +15 -13
  64. package/dist/runtime/components/label/Field.d.vue.ts +16 -14
  65. package/dist/runtime/components/label/Field.vue.d.ts +16 -14
  66. package/dist/runtime/components/label/FormatMoney.d.vue.ts +1 -1
  67. package/dist/runtime/components/label/FormatMoney.vue.d.ts +1 -1
  68. package/dist/runtime/components/master/Autocomplete.d.vue.ts +3 -5
  69. package/dist/runtime/components/master/Autocomplete.vue.d.ts +3 -5
  70. package/dist/runtime/components/master/Combobox.d.vue.ts +3 -5
  71. package/dist/runtime/components/master/Combobox.vue.d.ts +3 -5
  72. package/dist/runtime/components/master/RadioGroup.d.vue.ts +3 -3
  73. package/dist/runtime/components/master/RadioGroup.vue.d.ts +3 -3
  74. package/dist/runtime/components/master/Select.d.vue.ts +3 -5
  75. package/dist/runtime/components/master/Select.vue.d.ts +3 -5
  76. package/dist/runtime/components/master/label.d.vue.ts +7 -3
  77. package/dist/runtime/components/master/label.vue +33 -15
  78. package/dist/runtime/components/master/label.vue.d.ts +7 -3
  79. package/dist/runtime/components/model/Autocomplete.d.vue.ts +3 -3
  80. package/dist/runtime/components/model/Autocomplete.vue.d.ts +3 -3
  81. package/dist/runtime/components/model/Combobox.d.vue.ts +3 -3
  82. package/dist/runtime/components/model/Combobox.vue.d.ts +3 -3
  83. package/dist/runtime/components/model/Pad.d.vue.ts +17 -15
  84. package/dist/runtime/components/model/Pad.vue.d.ts +17 -15
  85. package/dist/runtime/components/model/Select.d.vue.ts +3 -3
  86. package/dist/runtime/components/model/Select.vue.d.ts +3 -3
  87. package/dist/runtime/components/model/Table.d.vue.ts +102 -166
  88. package/dist/runtime/components/model/Table.vue.d.ts +102 -166
  89. package/dist/runtime/components/model/iterator.d.vue.ts +188 -240
  90. package/dist/runtime/components/model/iterator.vue.d.ts +188 -240
  91. package/dist/runtime/components/model/label.d.vue.ts +11 -5
  92. package/dist/runtime/components/model/label.vue +54 -4
  93. package/dist/runtime/components/model/label.vue.d.ts +11 -5
  94. package/dist/runtime/composables/batchLookup.d.ts +39 -0
  95. package/dist/runtime/composables/batchLookup.js +144 -0
  96. package/dist/runtime/composables/document/inputAttributeCatalog.generated.json +95 -0
  97. package/dist/runtime/composables/document/inputAttributes.d.ts +46 -0
  98. package/dist/runtime/composables/document/inputAttributes.js +196 -0
  99. package/dist/runtime/composables/document/template.js +4 -0
  100. package/dist/runtime/composables/document/templateInputTypes.d.ts +36 -0
  101. package/dist/runtime/composables/document/templateInputTypes.js +86 -17
  102. package/dist/runtime/composables/document/templateMasterLabel.d.ts +32 -0
  103. package/dist/runtime/composables/document/templateMasterLabel.js +30 -0
  104. package/dist/runtime/composables/document/validateTemplate.js +11 -1
  105. package/dist/runtime/composables/masterItemBatch.d.ts +7 -0
  106. package/dist/runtime/composables/masterItemBatch.js +12 -0
  107. package/dist/runtime/composables/modelBatch.d.ts +61 -0
  108. package/dist/runtime/composables/modelBatch.js +192 -0
  109. package/dist/runtime/labs/form/EditMobile.d.vue.ts +1 -1
  110. package/dist/runtime/labs/form/EditMobile.vue.d.ts +1 -1
  111. package/dist/runtime/labs/form/TextFieldMask.d.vue.ts +3 -3
  112. package/dist/runtime/labs/form/TextFieldMask.vue.d.ts +3 -3
  113. package/dist/runtime/plugins/clientConfig.d.ts +1 -1
  114. package/dist/runtime/plugins/default.d.ts +1 -1
  115. package/dist/runtime/plugins/dialogManager.d.ts +1 -1
  116. package/dist/runtime/plugins/permission.d.ts +1 -1
  117. package/package.json +2 -2
  118. package/scripts/build-input-attribute-catalog.mjs +133 -0
@@ -7,13 +7,19 @@ interface Props {
7
7
  notFoundText?: string;
8
8
  placeholder?: string;
9
9
  api?: boolean;
10
+ batchOperation?: string;
11
+ batchKey?: string;
12
+ batchVariable?: string;
13
+ batchMatch?: string;
10
14
  }
11
- declare var __VLS_1: {
12
- data: Record<string, any>;
13
- };
14
- type __VLS_Slots = {} & {
15
- default?: (props: typeof __VLS_1) => any;
15
+ declare const __VLS_template: () => {
16
+ __VLS_Slots: {
17
+ default?: (props: {
18
+ data: Record<string, any>;
19
+ }) => any;
20
+ };
16
21
  };
22
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
17
23
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
18
24
  cache: number | boolean;
19
25
  api: boolean;
@@ -0,0 +1,39 @@
1
+ export type BatchLookupStatus = 'pending' | 'loaded' | 'notFound' | 'error';
2
+ export interface BatchLookupEntry<V> {
3
+ status: BatchLookupStatus;
4
+ value: V | null;
5
+ /** Fetch attempts made for this key in the current round. */
6
+ attempts: number;
7
+ error?: unknown;
8
+ }
9
+ export interface BatchLookupOptions<V> {
10
+ /**
11
+ * Fetch the given keys of one group. Return a Map of key → value; keys absent from the Map
12
+ * (or mapped to `null` / `undefined`) are treated as not found. Reject to signal a failure.
13
+ */
14
+ fetch: (group: string, keys: string[]) => Promise<Map<string, V | null | undefined>>;
15
+ /** Max keys per fetch call. A function lets the size depend on the group (default 100). */
16
+ maxBatchSize?: number | ((group: string) => number);
17
+ /** Total tries per key, including the first one (default 3). */
18
+ maxAttempts?: number;
19
+ /** Delay in ms before retry number `attempt` (1-based count of failed tries). Default min(5000 × attempt, 30000). */
20
+ retryDelay?: (attempt: number) => number;
21
+ /** Return false to fail a key immediately instead of retrying (default: always retry). */
22
+ isRetryable?: (error: unknown) => boolean;
23
+ /** Called once when a key ends in `error`. */
24
+ onError?: (group: string, keys: string[], error: unknown) => void;
25
+ }
26
+ export interface BatchLookup<V> {
27
+ /** Reactive read of a key's entry; `undefined` when never requested (or cleared). */
28
+ get: (group: string, key: string) => BatchLookupEntry<V> | undefined;
29
+ /**
30
+ * Queue a key unless it is loaded, not found, or already in flight. An `error` key is retried.
31
+ * Resolves with the entry once it settles (`loaded`, `notFound` or `error`); never rejects.
32
+ */
33
+ request: (group: string, key: string) => Promise<BatchLookupEntry<V>>;
34
+ /** Store a value obtained elsewhere (e.g. a persistent cache) as `loaded`. */
35
+ prime: (group: string, key: string, value: V) => void;
36
+ /** Drop every entry, or only the entries of one group. */
37
+ clear: (group?: string) => void;
38
+ }
39
+ export declare function createBatchLookup<V>(options: BatchLookupOptions<V>): BatchLookup<V>;
@@ -0,0 +1,144 @@
1
+ import { shallowReactive } from "vue";
2
+ const SEPARATOR = "\0";
3
+ function deferred() {
4
+ let resolve;
5
+ const promise = new Promise((r) => {
6
+ resolve = r;
7
+ });
8
+ return { promise, resolve };
9
+ }
10
+ export function createBatchLookup(options) {
11
+ const maxAttempts = Math.max(1, options.maxAttempts ?? 3);
12
+ const retryDelay = options.retryDelay ?? ((attempt) => Math.min(5e3 * attempt, 3e4));
13
+ const isRetryable = options.isRetryable ?? (() => true);
14
+ const entries = shallowReactive(/* @__PURE__ */ new Map());
15
+ const generations = /* @__PURE__ */ new Map();
16
+ const waiters = /* @__PURE__ */ new Map();
17
+ const queue = /* @__PURE__ */ new Map();
18
+ const timers = /* @__PURE__ */ new Set();
19
+ let flushScheduled = false;
20
+ const id = (group, key) => group + SEPARATOR + key;
21
+ function batchSize(group) {
22
+ const size = typeof options.maxBatchSize === "function" ? options.maxBatchSize(group) : options.maxBatchSize;
23
+ return Math.max(1, Math.floor(size || 100));
24
+ }
25
+ function settle(entryId, entry) {
26
+ entries.set(entryId, entry);
27
+ const waiter = waiters.get(entryId);
28
+ if (waiter) {
29
+ waiters.delete(entryId);
30
+ waiter.resolve(entry);
31
+ }
32
+ }
33
+ function enqueue(group, key) {
34
+ let keys = queue.get(group);
35
+ if (!keys) queue.set(group, keys = /* @__PURE__ */ new Set());
36
+ keys.add(key);
37
+ if (!flushScheduled) {
38
+ flushScheduled = true;
39
+ queueMicrotask(flush);
40
+ }
41
+ }
42
+ function flush() {
43
+ flushScheduled = false;
44
+ const groups = Array.from(queue.entries());
45
+ queue.clear();
46
+ for (const [group, keySet] of groups) {
47
+ const keys = Array.from(keySet);
48
+ const size = batchSize(group);
49
+ for (let i = 0; i < keys.length; i += size) runChunk(group, keys.slice(i, i + size));
50
+ }
51
+ }
52
+ function runChunk(group, keys) {
53
+ const sent = keys.map((key) => ({ key, entryId: id(group, key), generation: generations.get(id(group, key)) }));
54
+ let fetching;
55
+ try {
56
+ fetching = Promise.resolve(options.fetch(group, keys));
57
+ } catch (error) {
58
+ fetching = Promise.reject(error);
59
+ }
60
+ fetching.then((result) => {
61
+ for (const { key, entryId, generation } of sent) {
62
+ if (generations.get(entryId) !== generation) continue;
63
+ const value = result?.get(key);
64
+ settle(entryId, value === null || value === void 0 ? { status: "notFound", value: null, attempts: (entries.get(entryId)?.attempts ?? 0) + 1 } : { status: "loaded", value, attempts: (entries.get(entryId)?.attempts ?? 0) + 1 });
65
+ }
66
+ }, (error) => {
67
+ const retryGroups = /* @__PURE__ */ new Map();
68
+ const failed = [];
69
+ for (const { key, entryId, generation } of sent) {
70
+ if (generations.get(entryId) !== generation) continue;
71
+ const attempts = (entries.get(entryId)?.attempts ?? 0) + 1;
72
+ if (attempts < maxAttempts && isRetryable(error)) {
73
+ entries.set(entryId, { status: "pending", value: null, attempts, error });
74
+ let retryKeys = retryGroups.get(attempts);
75
+ if (!retryKeys) retryGroups.set(attempts, retryKeys = []);
76
+ retryKeys.push(key);
77
+ } else {
78
+ failed.push(key);
79
+ settle(entryId, { status: "error", value: null, attempts, error });
80
+ }
81
+ }
82
+ if (failed.length) options.onError?.(group, failed, error);
83
+ for (const [attempt, retryKeys] of retryGroups) scheduleRetry(group, retryKeys, attempt);
84
+ });
85
+ }
86
+ function scheduleRetry(group, keys, attempt) {
87
+ const generationsAtFailure = keys.map((key) => generations.get(id(group, key)));
88
+ const timer = setTimeout(() => {
89
+ timers.delete(timer);
90
+ keys.forEach((key, index) => {
91
+ const entryId = id(group, key);
92
+ if (generations.get(entryId) === generationsAtFailure[index] && entries.get(entryId)?.status === "pending") enqueue(group, key);
93
+ });
94
+ }, Math.max(0, retryDelay(attempt)));
95
+ timers.add(timer);
96
+ }
97
+ function request(group, key) {
98
+ const entryId = id(group, key);
99
+ const existing = entries.get(entryId);
100
+ if (existing && existing.status !== "error") {
101
+ if (existing.status !== "pending") return Promise.resolve(existing);
102
+ const waiter2 = waiters.get(entryId);
103
+ if (waiter2) return waiter2.promise;
104
+ }
105
+ generations.set(entryId, (generations.get(entryId) ?? 0) + 1);
106
+ entries.set(entryId, { status: "pending", value: null, attempts: 0 });
107
+ const waiter = deferred();
108
+ waiters.set(entryId, waiter);
109
+ enqueue(group, key);
110
+ return waiter.promise;
111
+ }
112
+ function prime(group, key, value) {
113
+ const entryId = id(group, key);
114
+ generations.set(entryId, (generations.get(entryId) ?? 0) + 1);
115
+ settle(entryId, { status: "loaded", value, attempts: 0 });
116
+ }
117
+ function clear(group) {
118
+ const prefix = group === void 0 ? void 0 : group + SEPARATOR;
119
+ const matches = (entryId) => prefix === void 0 || entryId.startsWith(prefix);
120
+ for (const entryId of Array.from(entries.keys())) {
121
+ if (!matches(entryId)) continue;
122
+ generations.set(entryId, (generations.get(entryId) ?? 0) + 1);
123
+ entries.delete(entryId);
124
+ const waiter = waiters.get(entryId);
125
+ if (waiter) {
126
+ waiters.delete(entryId);
127
+ waiter.resolve({ status: "error", value: null, attempts: 0, error: new Error("Batch lookup entry cleared") });
128
+ }
129
+ }
130
+ if (group === void 0) {
131
+ queue.clear();
132
+ timers.forEach((timer) => clearTimeout(timer));
133
+ timers.clear();
134
+ } else {
135
+ queue.delete(group);
136
+ }
137
+ }
138
+ return {
139
+ get: (group, key) => entries.get(id(group, key)),
140
+ request,
141
+ prime,
142
+ clear
143
+ };
144
+ }