@finema/core 3.21.0 → 3.23.2

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 (126) hide show
  1. package/dist/module.d.mts +2 -0
  2. package/dist/module.json +2 -2
  3. package/dist/module.mjs +16 -2
  4. package/dist/runtime/components/App.vue +1 -1
  5. package/dist/runtime/components/DevToolsWindow/index.vue +1 -1
  6. package/dist/runtime/components/Dialog/index.d.vue.ts +1 -4
  7. package/dist/runtime/components/Dialog/index.vue +9 -10
  8. package/dist/runtime/components/Dialog/index.vue.d.ts +1 -4
  9. package/dist/runtime/components/Empty.d.vue.ts +0 -1
  10. package/dist/runtime/components/Empty.vue +6 -2
  11. package/dist/runtime/components/Empty.vue.d.ts +0 -1
  12. package/dist/runtime/components/FlexDeck/index.vue +86 -81
  13. package/dist/runtime/components/Form/FieldWrapper.vue +14 -14
  14. package/dist/runtime/components/Form/Fields.vue +10 -10
  15. package/dist/runtime/components/Form/InputCheckbox/index.vue +20 -19
  16. package/dist/runtime/components/Form/InputCheckboxGroup/index.vue +2 -1
  17. package/dist/runtime/components/Form/InputComponent/index.vue +2 -1
  18. package/dist/runtime/components/Form/InputCurrency/index.vue +51 -50
  19. package/dist/runtime/components/Form/InputDateTime/date_time_field.types.d.ts +1 -1
  20. package/dist/runtime/components/Form/InputDateTime/index.vue +69 -64
  21. package/dist/runtime/components/Form/InputDateTimeRange/date_range_time_field.types.d.ts +1 -1
  22. package/dist/runtime/components/Form/InputDateTimeRange/index.vue +62 -57
  23. package/dist/runtime/components/Form/InputMonth/index.vue +10 -5
  24. package/dist/runtime/components/Form/InputMonth/types.d.ts +1 -1
  25. package/dist/runtime/components/Form/InputNumber/index.vue +22 -21
  26. package/dist/runtime/components/Form/InputRadio/index.d.vue.ts +1 -1
  27. package/dist/runtime/components/Form/InputRadio/index.vue +2 -1
  28. package/dist/runtime/components/Form/InputRadio/index.vue.d.ts +1 -1
  29. package/dist/runtime/components/Form/InputRating/index.vue +2 -1
  30. package/dist/runtime/components/Form/InputSearch/index.vue +7 -2
  31. package/dist/runtime/components/Form/InputSelect/index.vue +112 -111
  32. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +120 -119
  33. package/dist/runtime/components/Form/InputTags/index.vue +56 -55
  34. package/dist/runtime/components/Form/InputText/index.vue +88 -87
  35. package/dist/runtime/components/Form/InputTextarea/index.vue +20 -19
  36. package/dist/runtime/components/Form/InputTime/index.vue +45 -40
  37. package/dist/runtime/components/Form/InputTime/types.d.ts +1 -1
  38. package/dist/runtime/components/Form/InputToggle/index.vue +19 -18
  39. package/dist/runtime/components/Form/InputUploadDropzone/index.d.vue.ts +1 -4
  40. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +40 -35
  41. package/dist/runtime/components/Form/InputUploadDropzone/index.vue.d.ts +1 -4
  42. package/dist/runtime/components/Form/InputUploadDropzone/types.d.ts +2 -2
  43. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.d.vue.ts +0 -5
  44. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +63 -58
  45. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue.d.ts +0 -5
  46. package/dist/runtime/components/Form/InputUploadDropzoneAuto/types.d.ts +3 -3
  47. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.d.vue.ts +0 -5
  48. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +69 -60
  49. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue.d.ts +0 -5
  50. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/types.d.ts +3 -3
  51. package/dist/runtime/components/Form/InputUploadImageAuto/index.d.vue.ts +1 -6
  52. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +63 -58
  53. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue.d.ts +1 -6
  54. package/dist/runtime/components/Form/InputUploadImageAuto/types.d.ts +3 -3
  55. package/dist/runtime/components/Form/InputWYSIWYG/EditorImageUploadNode.vue +18 -18
  56. package/dist/runtime/components/Form/InputWYSIWYG/EditorLinkPopover.vue +65 -65
  57. package/dist/runtime/components/Form/InputWYSIWYG/README.md +96 -96
  58. package/dist/runtime/components/Form/InputWYSIWYG/index.vue +43 -42
  59. package/dist/runtime/components/Form/fileState/EmptyState.vue +21 -21
  60. package/dist/runtime/components/Form/fileState/FailedState.vue +37 -33
  61. package/dist/runtime/components/Form/fileState/LoadingState.vue +24 -24
  62. package/dist/runtime/components/Form/fileState/MultipleFilesState.d.vue.ts +4 -4
  63. package/dist/runtime/components/Form/fileState/MultipleFilesState.vue +79 -75
  64. package/dist/runtime/components/Form/fileState/MultipleFilesState.vue.d.ts +4 -4
  65. package/dist/runtime/components/Form/fileState/PreviewModal.vue +23 -23
  66. package/dist/runtime/components/Form/fileState/SuccessState.d.vue.ts +2 -2
  67. package/dist/runtime/components/Form/fileState/SuccessState.vue +8 -4
  68. package/dist/runtime/components/Form/fileState/SuccessState.vue.d.ts +2 -2
  69. package/dist/runtime/components/Form/fileState/useFilePicker.d.ts +34 -0
  70. package/dist/runtime/components/Form/fileState/useFilePicker.js +48 -0
  71. package/dist/runtime/components/Form/fileState/useFileState.d.ts +7 -9
  72. package/dist/runtime/components/Form/fileState/useFileState.js +40 -120
  73. package/dist/runtime/components/Form/fileState/useUploadImageState.d.ts +7 -8
  74. package/dist/runtime/components/Form/fileState/useUploadImageState.js +28 -300
  75. package/dist/runtime/components/Form/fileState/useUploadState.d.ts +11 -7
  76. package/dist/runtime/components/Form/fileState/useUploadState.js +58 -131
  77. package/dist/runtime/components/Form/fileState/useUploadStateMultiple.d.ts +12 -18
  78. package/dist/runtime/components/Form/fileState/useUploadStateMultiple.js +89 -222
  79. package/dist/runtime/components/Form/index.vue +5 -5
  80. package/dist/runtime/components/Form/types.d.ts +2 -0
  81. package/dist/runtime/components/Image.vue +28 -28
  82. package/dist/runtime/components/Loader.d.vue.ts +1 -0
  83. package/dist/runtime/components/Loader.vue.d.ts +1 -0
  84. package/dist/runtime/components/Table/Base.d.vue.ts +15 -1
  85. package/dist/runtime/components/Table/Base.vue +118 -118
  86. package/dist/runtime/components/Table/Base.vue.d.ts +15 -1
  87. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  88. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  89. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  90. package/dist/runtime/components/Table/ColumnText.d.vue.ts +2 -3
  91. package/dist/runtime/components/Table/ColumnText.vue +11 -11
  92. package/dist/runtime/components/Table/ColumnText.vue.d.ts +2 -3
  93. package/dist/runtime/components/Table/Pagination.vue +70 -67
  94. package/dist/runtime/components/Table/Simple.vue +19 -19
  95. package/dist/runtime/components/Table/index.d.vue.ts +1 -1
  96. package/dist/runtime/components/Table/index.vue +37 -33
  97. package/dist/runtime/components/Table/index.vue.d.ts +1 -1
  98. package/dist/runtime/composables/loaderList.d.ts +2 -1
  99. package/dist/runtime/composables/loaderList.js +2 -1
  100. package/dist/runtime/composables/loaderObject.d.ts +2 -1
  101. package/dist/runtime/composables/loaderObject.js +2 -1
  102. package/dist/runtime/composables/loaderPage.js +194 -344
  103. package/dist/runtime/composables/useConfig.js +4 -3
  104. package/dist/runtime/composables/useDialog.js +5 -1
  105. package/dist/runtime/composables/useForm.d.ts +1 -1
  106. package/dist/runtime/composables/useForm.js +1 -1
  107. package/dist/runtime/composables/useMessages.d.ts +10 -0
  108. package/dist/runtime/composables/useMessages.js +10 -0
  109. package/dist/runtime/helpers/apiPageHelper.d.ts +0 -1
  110. package/dist/runtime/helpers/uploadCore.d.ts +54 -0
  111. package/dist/runtime/helpers/uploadCore.js +84 -0
  112. package/dist/runtime/i18n/valibot.d.ts +5 -68
  113. package/dist/runtime/i18n/valibot.js +33 -29
  114. package/dist/runtime/locale/en.d.ts +2 -0
  115. package/dist/runtime/locale/en.js +42 -0
  116. package/dist/runtime/locale/index.d.ts +7 -0
  117. package/dist/runtime/locale/index.js +8 -0
  118. package/dist/runtime/locale/th.d.ts +43 -0
  119. package/dist/runtime/locale/th.js +42 -0
  120. package/dist/runtime/server/tsconfig.json +3 -3
  121. package/dist/runtime/theme/dialog.js +1 -1
  122. package/dist/runtime/utils/ParamHelper.js +1 -1
  123. package/dist/runtime/utils/StringHelper.js +1 -4
  124. package/dist/runtime/utils/TimeHelper.js +2 -2
  125. package/dist/runtime/utils/lodash.js +2 -2
  126. package/package.json +20 -12
@@ -20,36 +20,32 @@ export const initPageOptions = (options) => ({
20
20
  });
21
21
  export const usePageLoader = (loaderOptions) => {
22
22
  const config = useCoreConfig();
23
+ const createPageOptions = () => initPageOptions({
24
+ limit: config.limit_per_page,
25
+ primary: config.default_primary_key
26
+ });
23
27
  const fetch = reactive({
24
28
  status: ObjectHelper.createStatus(),
25
29
  statusNextPage: ObjectHelper.createStatus(),
26
30
  items: [],
27
- options: initPageOptions({
28
- limit: config.limit_per_page,
29
- primary: config.default_primary_key
30
- })
31
- });
32
- const find = reactive({
33
- status: ObjectHelper.createStatus(),
34
- item: null,
35
- options: {}
31
+ options: createPageOptions()
36
32
  });
37
- const add = reactive({
38
- status: ObjectHelper.createStatus(),
39
- item: null,
40
- options: {}
41
- });
42
- const update = reactive({
43
- status: ObjectHelper.createStatus(),
44
- item: null,
45
- options: {}
46
- });
47
- const del = reactive({
48
- // Using 'del' as a variable name since 'delete' is a reserved keyword
33
+ const createItemState = () => reactive({
49
34
  status: ObjectHelper.createStatus(),
50
35
  item: null,
51
36
  options: {}
52
37
  });
38
+ const find = createItemState();
39
+ const add = createItemState();
40
+ const update = createItemState();
41
+ const del = createItemState();
42
+ const states = {
43
+ fetch,
44
+ find,
45
+ add,
46
+ update,
47
+ delete: del
48
+ };
53
49
  const requests = {
54
50
  fetch: null,
55
51
  find: null,
@@ -57,100 +53,45 @@ export const usePageLoader = (loaderOptions) => {
57
53
  update: null,
58
54
  delete: null
59
55
  };
60
- const isActiveRequest = (key, currentRequest) => {
61
- return requests[key] === currentRequest;
62
- };
63
- const canUpdateRequest = (key, currentRequest) => {
64
- return isActiveRequest(key, currentRequest) || !currentRequest.signal.aborted;
65
- };
66
- const completeStatus = (status) => ObjectHelper.toCompleteStatus(status);
67
- const cancelFetch = () => {
68
- const currentRequest = requests.fetch;
56
+ const cancel = (key) => {
57
+ const currentRequest = requests[key];
69
58
  if (!currentRequest) return;
70
59
  currentRequest.controller.abort();
71
60
  currentRequest.cleanup();
72
- requests.fetch = null;
73
- fetch.status = completeStatus(fetch.status);
74
- fetch.statusNextPage = completeStatus(fetch.statusNextPage);
75
- };
76
- const cancelFind = () => {
77
- const currentRequest = requests.find;
78
- if (!currentRequest) return;
79
- currentRequest.controller.abort();
80
- currentRequest.cleanup();
81
- requests.find = null;
82
- find.status = completeStatus(find.status);
83
- };
84
- const cancelAdd = () => {
85
- const currentRequest = requests.add;
86
- if (!currentRequest) return;
87
- currentRequest.controller.abort();
88
- currentRequest.cleanup();
89
- requests.add = null;
90
- add.status = completeStatus(add.status);
91
- };
92
- const cancelUpdate = () => {
93
- const currentRequest = requests.update;
94
- if (!currentRequest) return;
95
- currentRequest.controller.abort();
96
- currentRequest.cleanup();
97
- requests.update = null;
98
- update.status = completeStatus(update.status);
99
- };
100
- const cancelDelete = () => {
101
- const currentRequest = requests.delete;
102
- if (!currentRequest) return;
103
- currentRequest.controller.abort();
104
- currentRequest.cleanup();
105
- requests.delete = null;
106
- del.status = completeStatus(del.status);
61
+ requests[key] = null;
62
+ states[key].status = ObjectHelper.toCompleteStatus(states[key].status);
63
+ if (key === "fetch") {
64
+ fetch.statusNextPage = ObjectHelper.toCompleteStatus(fetch.statusNextPage);
65
+ }
107
66
  };
108
67
  const cancelAll = () => {
109
- cancelFetch();
110
- cancelFind();
111
- cancelAdd();
112
- cancelUpdate();
113
- cancelDelete();
114
- };
115
- const cancelRequestByKey = (key) => {
116
- if (key === "fetch") cancelFetch();
117
- if (key === "find") cancelFind();
118
- if (key === "add") cancelAdd();
119
- if (key === "update") cancelUpdate();
120
- if (key === "delete") cancelDelete();
68
+ Object.keys(requests).forEach(cancel);
121
69
  };
122
- const startRequest = (key, externalSignal, autoCancel = true) => {
123
- if (autoCancel) cancelRequestByKey(key);
70
+ const withRequest = async (key, externalSignal, autoCancel, run) => {
71
+ if (autoCancel) cancel(key);
124
72
  const currentRequest = createCancelableRequest(externalSignal);
125
73
  requests[key] = currentRequest;
126
- return currentRequest;
127
- };
128
- const finishRequest = (key, currentRequest) => {
129
- currentRequest.cleanup();
130
- if (!isActiveRequest(key, currentRequest)) return;
131
- requests[key] = null;
74
+ const canUpdate = () => requests[key] === currentRequest || !currentRequest.signal.aborted;
75
+ try {
76
+ await run(currentRequest.signal, (set) => (value) => {
77
+ if (canUpdate()) set(value);
78
+ });
79
+ } finally {
80
+ currentRequest.cleanup();
81
+ if (requests[key] === currentRequest) requests[key] = null;
82
+ }
132
83
  };
133
84
  const clearAll = () => {
134
85
  cancelAll();
135
- find.status = ObjectHelper.createStatus();
136
- del.status = ObjectHelper.createStatus();
137
- add.status = ObjectHelper.createStatus();
138
- update.status = ObjectHelper.createStatus();
139
86
  fetch.status = ObjectHelper.createStatus();
140
87
  fetch.statusNextPage = ObjectHelper.createStatus();
141
- find.item = null;
142
- del.item = null;
143
- update.item = null;
144
- add.item = null;
145
88
  fetch.items = [];
146
- fetch.options = initPageOptions({
147
- limit: config.limit_per_page,
148
- primary: config.default_primary_key
149
- });
150
- find.options = {};
151
- add.options = {};
152
- update.options = {};
153
- del.options = {};
89
+ fetch.options = createPageOptions();
90
+ for (const state of [find, add, update, del]) {
91
+ state.status = ObjectHelper.createStatus();
92
+ state.item = null;
93
+ state.options = {};
94
+ }
154
95
  };
155
96
  const fetchSetLoading = () => {
156
97
  fetch.items = [];
@@ -159,261 +100,170 @@ export const usePageLoader = (loaderOptions) => {
159
100
  const findSetLoading = () => {
160
101
  find.status = ObjectHelper.toLoadingStatus(find.status);
161
102
  };
162
- const fetchPage = async (page = 1, query = "", opts) => {
163
- const currentRequest = startRequest("fetch", opts?.signal);
164
- try {
165
- await apiFetchHelper(
166
- () => ({
167
- status: fetch.status,
168
- items: fetch.items,
169
- options: fetch.options
170
- }),
171
- (data) => {
172
- if (canUpdateRequest("fetch", currentRequest)) fetch.status = data;
173
- },
174
- (data) => {
175
- if (canUpdateRequest("fetch", currentRequest)) fetch.options = data;
176
- },
177
- (data) => {
178
- if (canUpdateRequest("fetch", currentRequest)) fetch.items = data;
179
- },
180
- page,
181
- query,
182
- {
183
- ...loaderOptions,
184
- ...opts,
185
- signal: currentRequest.signal
186
- }
187
- );
188
- } finally {
189
- finishRequest("fetch", currentRequest);
103
+ const runFetch = (page, query, opts, mode = "replace") => withRequest("fetch", opts?.signal, true, (signal, guard) => apiFetchHelper(
104
+ () => ({
105
+ status: fetch.status,
106
+ items: fetch.items,
107
+ options: fetch.options
108
+ }),
109
+ guard((data) => {
110
+ if (mode === "append") fetch.statusNextPage = data;
111
+ else fetch.status = data;
112
+ }),
113
+ guard((data) => {
114
+ fetch.options = data;
115
+ }),
116
+ guard((data) => {
117
+ fetch.items = mode === "append" ? [...fetch.items, ...data] : data;
118
+ }),
119
+ page,
120
+ query,
121
+ {
122
+ ...loaderOptions,
123
+ ...opts,
124
+ signal
190
125
  }
191
- };
192
- const fetchAll = async (query = "", opts = {}) => {
193
- opts.params = {
126
+ ));
127
+ const fetchPage = (page = 1, query = "", opts) => runFetch(page, query, opts);
128
+ const fetchAll = (query = "", opts = {}) => runFetch(1, query, {
129
+ ...opts,
130
+ params: {
194
131
  ...opts.params,
195
132
  limit: 99999
196
- };
197
- const currentRequest = startRequest("fetch", opts.signal);
198
- try {
199
- await apiFetchHelper(
200
- () => ({
201
- status: fetch.status,
202
- items: fetch.items,
203
- options: fetch.options
204
- }),
205
- (data) => {
206
- if (canUpdateRequest("fetch", currentRequest)) fetch.status = data;
207
- },
208
- (data) => {
209
- if (canUpdateRequest("fetch", currentRequest)) fetch.options = data;
210
- },
211
- (data) => {
212
- if (canUpdateRequest("fetch", currentRequest)) fetch.items = data;
213
- },
214
- 1,
215
- query,
216
- {
217
- ...loaderOptions,
218
- ...opts,
219
- signal: currentRequest.signal
220
- }
221
- );
222
- } finally {
223
- finishRequest("fetch", currentRequest);
224
- }
225
- };
226
- const findRun = async (id, opts) => {
227
- const currentRequest = startRequest("find", opts?.signal);
228
- try {
229
- await apiFindHelper(
230
- () => ({
231
- status: find.status,
232
- data: find.item,
233
- options: find.options
234
- }),
235
- (data) => {
236
- if (canUpdateRequest("find", currentRequest)) find.status = data;
237
- },
238
- (data) => {
239
- if (canUpdateRequest("find", currentRequest)) find.options = data;
240
- },
241
- (data) => {
242
- if (canUpdateRequest("find", currentRequest)) find.item = data;
243
- },
244
- id,
245
- {
246
- ...loaderOptions,
247
- ...opts,
248
- signal: currentRequest.signal
249
- }
250
- );
251
- } finally {
252
- finishRequest("find", currentRequest);
253
- }
254
- };
255
- const addRun = async (payload) => {
256
- const currentRequest = startRequest("add", payload.signal, false);
257
- try {
258
- await apiAddHelper(
259
- () => ({
260
- items: fetch.items,
261
- status: add.status,
262
- data: add.item,
263
- options: add.options
264
- }),
265
- (data) => {
266
- if (canUpdateRequest("add", currentRequest)) add.status = data;
267
- },
268
- (data) => {
269
- if (canUpdateRequest("add", currentRequest)) add.options = data;
270
- },
271
- (data) => {
272
- if (canUpdateRequest("add", currentRequest)) add.item = data;
273
- },
274
- (data) => {
275
- if (canUpdateRequest("add", currentRequest)) fetch.items = data;
276
- },
277
- payload.data,
278
- {
279
- ...loaderOptions,
280
- ...payload,
281
- signal: currentRequest.signal
282
- }
283
- );
284
- } finally {
285
- finishRequest("add", currentRequest);
286
- }
287
- };
288
- const updateRun = async (id, payload) => {
289
- const currentRequest = startRequest("update", payload.signal, false);
290
- try {
291
- await updateHelper(
292
- () => ({
293
- items: fetch.items,
294
- status: update.status,
295
- data: update.item,
296
- oldData: find.item,
297
- options: update.options
298
- }),
299
- (data) => {
300
- if (canUpdateRequest("update", currentRequest)) update.status = data;
301
- },
302
- (data) => {
303
- if (canUpdateRequest("update", currentRequest)) update.options = data;
304
- },
305
- (data) => {
306
- if (canUpdateRequest("update", currentRequest)) update.item = data;
307
- },
308
- (data) => {
309
- if (canUpdateRequest("update", currentRequest)) fetch.items = data;
310
- },
311
- (data) => {
312
- if (canUpdateRequest("update", currentRequest)) find.item = data;
313
- },
314
- id,
315
- payload.data,
316
- {
317
- ...loaderOptions,
318
- ...payload,
319
- signal: currentRequest.signal
320
- }
321
- );
322
- } finally {
323
- finishRequest("update", currentRequest);
324
133
  }
325
- };
326
- const fetchSearch = async (query = "", opts) => {
327
- await fetchPage(1, query, opts);
328
- };
329
- const fetchNextPage = async (opts) => {
134
+ });
135
+ const fetchSearch = (query = "", opts) => fetchPage(1, query, opts);
136
+ const lastFetchParams = () => {
330
137
  const {
331
138
  page: _page,
332
139
  ...params
333
140
  } = fetch.options?.request?.params || {};
334
- const currentRequest = startRequest("fetch", opts?.signal);
335
- try {
336
- await apiFetchHelper(
337
- () => ({
338
- status: fetch.status,
339
- items: fetch.items,
340
- options: fetch.options
341
- }),
342
- (data) => {
343
- if (canUpdateRequest("fetch", currentRequest)) fetch.statusNextPage = data;
344
- },
345
- (data) => {
346
- if (canUpdateRequest("fetch", currentRequest)) fetch.options = data;
347
- },
348
- (data) => {
349
- if (canUpdateRequest("fetch", currentRequest)) {
350
- fetch.items = [...fetch.items, ...data];
351
- }
352
- },
353
- fetch.options.currentPage + 1,
354
- fetch.options.search || "",
355
- {
356
- ...loaderOptions,
357
- params,
358
- ...opts,
359
- signal: currentRequest.signal
360
- }
361
- );
362
- } finally {
363
- finishRequest("fetch", currentRequest);
364
- }
141
+ return params;
365
142
  };
366
- const fetchPageChange = async (page, opts) => {
367
- const {
368
- page: _page,
369
- ...params
370
- } = fetch.options?.request?.params || {};
371
- await fetchPage(page, "", {
372
- params,
143
+ const fetchNextPage = (opts) => runFetch(
144
+ fetch.options.currentPage + 1,
145
+ fetch.options.search || "",
146
+ {
147
+ params: lastFetchParams(),
373
148
  ...opts
374
- });
375
- };
376
- const deleteRun = async (id, opts) => {
377
- const currentRequest = startRequest("delete", opts?.signal, false);
378
- try {
379
- await apiDeleteHelper(
380
- () => ({
381
- status: del.status,
382
- data: del.item,
383
- items: fetch.items,
384
- options: del.options
385
- }),
386
- (data) => {
387
- if (canUpdateRequest("delete", currentRequest)) del.status = data;
388
- },
389
- (data) => {
390
- if (canUpdateRequest("delete", currentRequest)) del.options = data;
391
- },
392
- (data) => {
393
- if (canUpdateRequest("delete", currentRequest)) del.item = data;
394
- },
395
- (data) => {
396
- if (canUpdateRequest("delete", currentRequest)) fetch.items = data;
397
- },
398
- id,
399
- {
400
- ...loaderOptions,
401
- ...opts,
402
- signal: currentRequest.signal
403
- }
404
- );
405
- } finally {
406
- finishRequest("delete", currentRequest);
149
+ },
150
+ "append"
151
+ );
152
+ const fetchPageChange = (page, opts) => fetchPage(page, "", {
153
+ params: lastFetchParams(),
154
+ ...opts
155
+ });
156
+ const findRun = (id, opts) => withRequest("find", opts?.signal, true, (signal, guard) => apiFindHelper(
157
+ () => ({
158
+ status: find.status,
159
+ data: find.item,
160
+ options: find.options
161
+ }),
162
+ guard((data) => {
163
+ find.status = data;
164
+ }),
165
+ guard((data) => {
166
+ find.options = data;
167
+ }),
168
+ guard((data) => {
169
+ find.item = data;
170
+ }),
171
+ id,
172
+ {
173
+ ...loaderOptions,
174
+ ...opts,
175
+ signal
407
176
  }
408
- };
177
+ ));
178
+ const addRun = (payload) => withRequest("add", payload.signal, false, (signal, guard) => apiAddHelper(
179
+ () => ({
180
+ items: fetch.items,
181
+ status: add.status,
182
+ data: add.item,
183
+ options: add.options
184
+ }),
185
+ guard((data) => {
186
+ add.status = data;
187
+ }),
188
+ guard((data) => {
189
+ add.options = data;
190
+ }),
191
+ guard((data) => {
192
+ add.item = data;
193
+ }),
194
+ guard((data) => {
195
+ fetch.items = data;
196
+ }),
197
+ payload.data,
198
+ {
199
+ ...loaderOptions,
200
+ ...payload,
201
+ signal
202
+ }
203
+ ));
204
+ const updateRun = (id, payload) => withRequest("update", payload.signal, false, (signal, guard) => updateHelper(
205
+ () => ({
206
+ items: fetch.items,
207
+ status: update.status,
208
+ data: update.item,
209
+ oldData: find.item,
210
+ options: update.options
211
+ }),
212
+ guard((data) => {
213
+ update.status = data;
214
+ }),
215
+ guard((data) => {
216
+ update.options = data;
217
+ }),
218
+ guard((data) => {
219
+ update.item = data;
220
+ }),
221
+ guard((data) => {
222
+ fetch.items = data;
223
+ }),
224
+ guard((data) => {
225
+ find.item = data;
226
+ }),
227
+ id,
228
+ payload.data,
229
+ {
230
+ ...loaderOptions,
231
+ ...payload,
232
+ signal
233
+ }
234
+ ));
235
+ const deleteRun = (id, opts) => withRequest("delete", opts?.signal, false, (signal, guard) => apiDeleteHelper(
236
+ () => ({
237
+ status: del.status,
238
+ data: del.item,
239
+ items: fetch.items,
240
+ options: del.options
241
+ }),
242
+ guard((data) => {
243
+ del.status = data;
244
+ }),
245
+ guard((data) => {
246
+ del.options = data;
247
+ }),
248
+ guard((data) => {
249
+ del.item = data;
250
+ }),
251
+ guard((data) => {
252
+ fetch.items = data;
253
+ }),
254
+ id,
255
+ {
256
+ ...loaderOptions,
257
+ ...opts,
258
+ signal
259
+ }
260
+ ));
409
261
  return {
410
- // State and methods
411
262
  fetch,
412
263
  find,
413
264
  add,
414
265
  update,
415
266
  delete: del,
416
- // Rename del to delete in the return object
417
267
  fetchPage,
418
268
  fetchAll,
419
269
  fetchSearch,
@@ -425,11 +275,11 @@ export const usePageLoader = (loaderOptions) => {
425
275
  addRun,
426
276
  updateRun,
427
277
  deleteRun,
428
- cancelFetch,
429
- cancelFind,
430
- cancelAdd,
431
- cancelUpdate,
432
- cancelDelete,
278
+ cancelFetch: () => cancel("fetch"),
279
+ cancelFind: () => cancel("find"),
280
+ cancelAdd: () => cancel("add"),
281
+ cancelUpdate: () => cancel("update"),
282
+ cancelDelete: () => cancel("delete"),
433
283
  cancelAll,
434
284
  clearAll
435
285
  };
@@ -1,17 +1,18 @@
1
1
  import { tv } from "tailwind-variants";
2
2
  import appConfig from "#build/app.config";
3
+ const uiConfig = () => appConfig.ui;
3
4
  export const useCoreConfig = () => {
4
5
  return appConfig.core;
5
6
  };
6
7
  export const useUiConfig = (config, name) => {
7
8
  return tv({
8
9
  extend: tv(config),
9
- ...appConfig.ui[name] || {}
10
+ ...uiConfig()[name] || {}
10
11
  });
11
12
  };
12
13
  export const useUiIconConfig = (name) => {
13
- return appConfig.ui[name].icons;
14
+ return uiConfig()[name].icons;
14
15
  };
15
16
  export const useUiStaticConfig = (name) => {
16
- return appConfig.ui[name].slots;
17
+ return uiConfig()[name].slots;
17
18
  };
@@ -1,4 +1,5 @@
1
1
  import Dialog from "../components/Dialog/index.vue";
2
+ import { useCoreMessages } from "./useMessages.js";
2
3
  import { useOverlay } from "#imports";
3
4
  export var DialogType = /* @__PURE__ */ ((DialogType2) => {
4
5
  DialogType2["ERROR"] = "error";
@@ -10,6 +11,9 @@ export var DialogType = /* @__PURE__ */ ((DialogType2) => {
10
11
  })(DialogType || {});
11
12
  export const useDialog = () => {
12
13
  const overlay = useOverlay();
14
+ const {
15
+ messages
16
+ } = useCoreMessages();
13
17
  const modalLoading = overlay.create(Dialog);
14
18
  const openDialog = async (payload) => {
15
19
  const modal = overlay.create(Dialog);
@@ -57,7 +61,7 @@ export const useDialog = () => {
57
61
  const loading = async (payload = {}) => {
58
62
  modalLoading.open({
59
63
  ...payload,
60
- title: payload.title || "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14...",
64
+ title: payload.title || messages.value.common.loading,
61
65
  type: "loading" /* LOADING */
62
66
  });
63
67
  };
@@ -7,6 +7,6 @@ interface IFieldContext<TValue> extends FieldContext<TValue> {
7
7
  export declare const useFieldHOC: <TValue = unknown>(newFormProps: IFieldProps, opts?: Partial<FieldOptions<TValue>>) => IFieldContext<TValue>;
8
8
  export declare const createFormFields: (fields: () => IFormField[]) => ComputedRef<IFormField[]>;
9
9
  export declare const moveToError: ({ errors, }: {
10
- errors: any;
10
+ errors: Record<string, unknown>;
11
11
  }) => void;
12
12
  export {};
@@ -4,7 +4,7 @@ import { computed, toRef } from "#imports";
4
4
  export const useFieldHOC = (newFormProps, opts) => {
5
5
  const field = useField(
6
6
  toRef(newFormProps, "name"),
7
- toTypedSchema(newFormProps.rules),
7
+ newFormProps.rules ? toTypedSchema(newFormProps.rules) : void 0,
8
8
  {
9
9
  form: newFormProps.form,
10
10
  ...opts
@@ -0,0 +1,10 @@
1
+ import { type ComputedRef } from 'vue';
2
+ import { formatMessage, type ICoreMessages } from '../locale/index.js';
3
+ export interface IUseCoreMessages {
4
+ messages: ComputedRef<ICoreMessages>;
5
+ format: typeof formatMessage;
6
+ }
7
+ /**
8
+ * Text the kit renders by itself, in `core.locale`, with `core.messages` overrides from app.config applied.
9
+ */
10
+ export declare const useCoreMessages: () => IUseCoreMessages;
@@ -0,0 +1,10 @@
1
+ import { computed } from "vue";
2
+ import { formatMessage, resolveMessages } from "../locale/index.js";
3
+ import { useCoreConfig } from "./useConfig.js";
4
+ export const useCoreMessages = () => {
5
+ const config = useCoreConfig();
6
+ return {
7
+ messages: computed(() => resolveMessages(config.locale, config.messages)),
8
+ format: formatMessage
9
+ };
10
+ };