@finema/core 3.22.0 → 3.24.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.
- package/README.md +22 -2
- package/dist/module.d.mts +2 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +18 -15
- package/dist/runtime/components/App.vue +1 -1
- package/dist/runtime/components/DevToolsWindow/index.vue +24 -26
- package/dist/runtime/components/Dialog/index.d.vue.ts +1 -4
- package/dist/runtime/components/Dialog/index.vue +17 -17
- package/dist/runtime/components/Dialog/index.vue.d.ts +1 -4
- package/dist/runtime/components/Empty.d.vue.ts +1 -2
- package/dist/runtime/components/Empty.vue +19 -11
- package/dist/runtime/components/Empty.vue.d.ts +1 -2
- package/dist/runtime/components/FlexDeck/index.vue +21 -23
- package/dist/runtime/components/Form/FieldWrapper.vue +1 -1
- package/dist/runtime/components/Form/Fields.d.vue.ts +1 -1
- package/dist/runtime/components/Form/Fields.vue +26 -20
- package/dist/runtime/components/Form/Fields.vue.d.ts +1 -1
- package/dist/runtime/components/Form/InputCheckbox/index.vue +3 -6
- package/dist/runtime/components/Form/InputCheckboxGroup/index.vue +3 -6
- package/dist/runtime/components/Form/InputComponent/index.vue +2 -1
- package/dist/runtime/components/Form/InputCurrency/index.vue +11 -11
- package/dist/runtime/components/Form/InputDateTime/date_time_field.types.d.ts +3 -1
- package/dist/runtime/components/Form/InputDateTime/index.vue +12 -17
- package/dist/runtime/components/Form/InputDateTimeRange/date_range_time_field.types.d.ts +1 -1
- package/dist/runtime/components/Form/InputDateTimeRange/index.vue +28 -20
- package/dist/runtime/components/Form/InputMonth/index.vue +14 -12
- package/dist/runtime/components/Form/InputMonth/types.d.ts +1 -1
- package/dist/runtime/components/Form/InputNumber/index.vue +3 -6
- package/dist/runtime/components/Form/InputRadio/index.vue +3 -6
- package/dist/runtime/components/Form/InputRating/index.vue +3 -6
- package/dist/runtime/components/Form/InputSearch/index.vue +6 -7
- package/dist/runtime/components/Form/InputSelect/index.vue +6 -15
- package/dist/runtime/components/Form/InputSelectMultiple/index.vue +7 -18
- package/dist/runtime/components/Form/InputTags/index.vue +3 -6
- package/dist/runtime/components/Form/InputText/index.vue +41 -51
- package/dist/runtime/components/Form/InputTextarea/index.vue +3 -6
- package/dist/runtime/components/Form/InputTime/index.vue +32 -27
- package/dist/runtime/components/Form/InputTime/types.d.ts +1 -1
- package/dist/runtime/components/Form/InputToggle/index.vue +3 -5
- package/dist/runtime/components/Form/InputUploadDropzone/index.d.vue.ts +1 -4
- package/dist/runtime/components/Form/InputUploadDropzone/index.vue +25 -23
- package/dist/runtime/components/Form/InputUploadDropzone/index.vue.d.ts +1 -4
- package/dist/runtime/components/Form/InputUploadDropzone/types.d.ts +2 -2
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.d.vue.ts +0 -5
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +22 -23
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue.d.ts +0 -5
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/types.d.ts +3 -3
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.d.vue.ts +0 -5
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +26 -24
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue.d.ts +0 -5
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/types.d.ts +3 -3
- package/dist/runtime/components/Form/InputUploadImageAuto/index.d.vue.ts +1 -6
- package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +22 -23
- package/dist/runtime/components/Form/InputUploadImageAuto/index.vue.d.ts +1 -6
- package/dist/runtime/components/Form/InputUploadImageAuto/types.d.ts +3 -3
- package/dist/runtime/components/Form/InputWYSIWYG/EditorImagePasteExtension.js +7 -6
- package/dist/runtime/components/Form/InputWYSIWYG/EditorImageUploadExtension.js +13 -12
- package/dist/runtime/components/Form/InputWYSIWYG/EditorImageUploadNode.vue +3 -1
- package/dist/runtime/components/Form/InputWYSIWYG/EditorLinkPopover.vue +20 -22
- package/dist/runtime/components/Form/InputWYSIWYG/index.vue +140 -118
- package/dist/runtime/components/Form/fileState/EmptyState.vue +1 -1
- package/dist/runtime/components/Form/fileState/FailedState.vue +4 -2
- package/dist/runtime/components/Form/fileState/MultipleFilesState.d.vue.ts +4 -4
- package/dist/runtime/components/Form/fileState/MultipleFilesState.vue +5 -5
- package/dist/runtime/components/Form/fileState/MultipleFilesState.vue.d.ts +4 -4
- package/dist/runtime/components/Form/fileState/SuccessState.d.vue.ts +2 -2
- package/dist/runtime/components/Form/fileState/SuccessState.vue +8 -13
- package/dist/runtime/components/Form/fileState/SuccessState.vue.d.ts +2 -2
- package/dist/runtime/components/Form/fileState/useFilePicker.d.ts +34 -0
- package/dist/runtime/components/Form/fileState/useFilePicker.js +48 -0
- package/dist/runtime/components/Form/fileState/useFileState.d.ts +7 -9
- package/dist/runtime/components/Form/fileState/useFileState.js +32 -120
- package/dist/runtime/components/Form/fileState/useUploadImageState.d.ts +7 -8
- package/dist/runtime/components/Form/fileState/useUploadImageState.js +27 -301
- package/dist/runtime/components/Form/fileState/useUploadState.d.ts +11 -7
- package/dist/runtime/components/Form/fileState/useUploadState.js +52 -136
- package/dist/runtime/components/Form/fileState/useUploadStateMultiple.d.ts +12 -18
- package/dist/runtime/components/Form/fileState/useUploadStateMultiple.js +88 -226
- package/dist/runtime/components/Form/types.d.ts +2 -0
- package/dist/runtime/components/Image.vue +4 -10
- package/dist/runtime/components/Loader.d.vue.ts +2 -1
- package/dist/runtime/components/Loader.vue +10 -7
- package/dist/runtime/components/Loader.vue.d.ts +2 -1
- package/dist/runtime/components/Log/LogItem.vue +1 -3
- package/dist/runtime/components/Log/index.vue +1 -3
- package/dist/runtime/components/Table/Base.d.vue.ts +15 -1
- package/dist/runtime/components/Table/Base.vue +9 -29
- package/dist/runtime/components/Table/Base.vue.d.ts +15 -1
- package/dist/runtime/components/Table/ColumnText.d.vue.ts +2 -3
- package/dist/runtime/components/Table/ColumnText.vue +1 -1
- package/dist/runtime/components/Table/ColumnText.vue.d.ts +2 -3
- package/dist/runtime/components/Table/Pagination.vue +19 -22
- package/dist/runtime/components/Table/index.d.vue.ts +1 -1
- package/dist/runtime/components/Table/index.vue +5 -7
- package/dist/runtime/components/Table/index.vue.d.ts +1 -1
- package/dist/runtime/composables/loaderList.d.ts +2 -1
- package/dist/runtime/composables/loaderList.js +3 -4
- package/dist/runtime/composables/loaderObject.d.ts +2 -1
- package/dist/runtime/composables/loaderObject.js +2 -1
- package/dist/runtime/composables/loaderPage.js +223 -350
- package/dist/runtime/composables/useConfig.js +4 -3
- package/dist/runtime/composables/useDialog.js +3 -1
- package/dist/runtime/composables/useForm.d.ts +2 -2
- package/dist/runtime/composables/useForm.js +2 -4
- package/dist/runtime/composables/useMessages.d.ts +10 -0
- package/dist/runtime/composables/useMessages.js +10 -0
- package/dist/runtime/composables/useTable.js +2 -14
- package/dist/runtime/helpers/apiBaseHelper.js +6 -24
- package/dist/runtime/helpers/apiListHelper.js +2 -5
- package/dist/runtime/helpers/apiObjectHelper.js +2 -5
- package/dist/runtime/helpers/apiPageHelper.d.ts +0 -1
- package/dist/runtime/helpers/apiPageHelper.js +19 -38
- package/dist/runtime/helpers/componentHelper.js +2 -6
- package/dist/runtime/helpers/uploadCore.d.ts +54 -0
- package/dist/runtime/helpers/uploadCore.js +81 -0
- package/dist/runtime/i18n/valibot.d.ts +5 -68
- package/dist/runtime/i18n/valibot.js +33 -29
- package/dist/runtime/locale/en.d.ts +2 -0
- package/dist/runtime/locale/en.js +42 -0
- package/dist/runtime/locale/index.d.ts +7 -0
- package/dist/runtime/locale/index.js +5 -0
- package/dist/runtime/locale/th.d.ts +43 -0
- package/dist/runtime/locale/th.js +42 -0
- package/dist/runtime/server/tsconfig.json +1 -1
- package/dist/runtime/styles/main.css +1 -1
- package/dist/runtime/utils/ParamHelper.js +1 -1
- package/dist/runtime/utils/StringHelper.js +1 -4
- package/dist/runtime/utils/TimeHelper.js +2 -2
- package/dist/runtime/utils/lodash.js +2 -2
- package/package.json +57 -36
|
@@ -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:
|
|
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
|
|
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,46 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
57
53
|
update: null,
|
|
58
54
|
delete: null
|
|
59
55
|
};
|
|
60
|
-
const
|
|
61
|
-
|
|
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;
|
|
69
|
-
if (!currentRequest) return;
|
|
70
|
-
currentRequest.controller.abort();
|
|
71
|
-
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;
|
|
56
|
+
const cancel = (key) => {
|
|
57
|
+
const currentRequest = requests[key];
|
|
78
58
|
if (!currentRequest) return;
|
|
79
59
|
currentRequest.controller.abort();
|
|
80
60
|
currentRequest.cleanup();
|
|
81
|
-
requests
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
cancelAdd();
|
|
112
|
-
cancelUpdate();
|
|
113
|
-
cancelDelete();
|
|
68
|
+
;
|
|
69
|
+
Object.keys(requests).forEach(cancel);
|
|
114
70
|
};
|
|
115
|
-
const
|
|
116
|
-
if (
|
|
117
|
-
if (key === "find") cancelFind();
|
|
118
|
-
if (key === "add") cancelAdd();
|
|
119
|
-
if (key === "update") cancelUpdate();
|
|
120
|
-
if (key === "delete") cancelDelete();
|
|
121
|
-
};
|
|
122
|
-
const startRequest = (key, externalSignal, autoCancel = true) => {
|
|
123
|
-
if (autoCancel) cancelRequestByKey(key);
|
|
71
|
+
const withRequest = async (key, externalSignal, autoCancel, run) => {
|
|
72
|
+
if (autoCancel) cancel(key);
|
|
124
73
|
const currentRequest = createCancelableRequest(externalSignal);
|
|
125
74
|
requests[key] = currentRequest;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
75
|
+
const canUpdate = () => requests[key] === currentRequest || !currentRequest.signal.aborted;
|
|
76
|
+
try {
|
|
77
|
+
await run(currentRequest.signal, (set) => (value) => {
|
|
78
|
+
if (canUpdate()) set(value);
|
|
79
|
+
});
|
|
80
|
+
} finally {
|
|
81
|
+
currentRequest.cleanup();
|
|
82
|
+
if (requests[key] === currentRequest) requests[key] = null;
|
|
83
|
+
}
|
|
132
84
|
};
|
|
133
85
|
const clearAll = () => {
|
|
134
86
|
cancelAll();
|
|
135
|
-
find.status = ObjectHelper.createStatus();
|
|
136
|
-
del.status = ObjectHelper.createStatus();
|
|
137
|
-
add.status = ObjectHelper.createStatus();
|
|
138
|
-
update.status = ObjectHelper.createStatus();
|
|
139
87
|
fetch.status = ObjectHelper.createStatus();
|
|
140
88
|
fetch.statusNextPage = ObjectHelper.createStatus();
|
|
141
|
-
find.item = null;
|
|
142
|
-
del.item = null;
|
|
143
|
-
update.item = null;
|
|
144
|
-
add.item = null;
|
|
145
89
|
fetch.items = [];
|
|
146
|
-
fetch.options =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
update.options = {};
|
|
153
|
-
del.options = {};
|
|
90
|
+
fetch.options = createPageOptions();
|
|
91
|
+
for (const state of [find, add, update, del]) {
|
|
92
|
+
state.status = ObjectHelper.createStatus();
|
|
93
|
+
state.item = null;
|
|
94
|
+
state.options = {};
|
|
95
|
+
}
|
|
154
96
|
};
|
|
155
97
|
const fetchSetLoading = () => {
|
|
156
98
|
fetch.items = [];
|
|
@@ -159,261 +101,192 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
159
101
|
const findSetLoading = () => {
|
|
160
102
|
find.status = ObjectHelper.toLoadingStatus(find.status);
|
|
161
103
|
};
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const fetchAll =
|
|
193
|
-
opts
|
|
104
|
+
const runFetch = (page, query, opts, mode = "replace") => withRequest(
|
|
105
|
+
"fetch",
|
|
106
|
+
opts?.signal,
|
|
107
|
+
true,
|
|
108
|
+
(signal, guard) => apiFetchHelper(
|
|
109
|
+
() => ({
|
|
110
|
+
status: fetch.status,
|
|
111
|
+
items: fetch.items,
|
|
112
|
+
options: fetch.options
|
|
113
|
+
}),
|
|
114
|
+
guard((data) => {
|
|
115
|
+
if (mode === "append") fetch.statusNextPage = data;
|
|
116
|
+
else fetch.status = data;
|
|
117
|
+
}),
|
|
118
|
+
guard((data) => {
|
|
119
|
+
fetch.options = data;
|
|
120
|
+
}),
|
|
121
|
+
guard((data) => {
|
|
122
|
+
fetch.items = mode === "append" ? [...fetch.items, ...data] : data;
|
|
123
|
+
}),
|
|
124
|
+
page,
|
|
125
|
+
query,
|
|
126
|
+
{
|
|
127
|
+
...loaderOptions,
|
|
128
|
+
...opts,
|
|
129
|
+
signal
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
const fetchPage = (page = 1, query = "", opts) => runFetch(page, query, opts);
|
|
134
|
+
const fetchAll = (query = "", opts = {}) => runFetch(1, query, {
|
|
135
|
+
...opts,
|
|
136
|
+
params: {
|
|
194
137
|
...opts.params,
|
|
195
138
|
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
|
-
}
|
|
325
|
-
};
|
|
326
|
-
const fetchSearch = async (query = "", opts) => {
|
|
327
|
-
await fetchPage(1, query, opts);
|
|
328
|
-
};
|
|
329
|
-
const fetchNextPage = async (opts) => {
|
|
330
|
-
const {
|
|
331
|
-
page: _page,
|
|
332
|
-
...params
|
|
333
|
-
} = 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
139
|
}
|
|
140
|
+
});
|
|
141
|
+
const fetchSearch = (query = "", opts) => fetchPage(1, query, opts);
|
|
142
|
+
const lastFetchParams = () => {
|
|
143
|
+
const { page: _page, ...params } = fetch.options?.request?.params || {};
|
|
144
|
+
return params;
|
|
365
145
|
};
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
await fetchPage(page, "", {
|
|
372
|
-
params,
|
|
146
|
+
const fetchNextPage = (opts) => runFetch(
|
|
147
|
+
fetch.options.currentPage + 1,
|
|
148
|
+
fetch.options.search || "",
|
|
149
|
+
{
|
|
150
|
+
params: lastFetchParams(),
|
|
373
151
|
...opts
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
152
|
+
},
|
|
153
|
+
"append"
|
|
154
|
+
);
|
|
155
|
+
const fetchPageChange = (page, opts) => fetchPage(page, "", {
|
|
156
|
+
params: lastFetchParams(),
|
|
157
|
+
...opts
|
|
158
|
+
});
|
|
159
|
+
const findRun = (id, opts) => withRequest(
|
|
160
|
+
"find",
|
|
161
|
+
opts?.signal,
|
|
162
|
+
true,
|
|
163
|
+
(signal, guard) => apiFindHelper(
|
|
164
|
+
() => ({
|
|
165
|
+
status: find.status,
|
|
166
|
+
data: find.item,
|
|
167
|
+
options: find.options
|
|
168
|
+
}),
|
|
169
|
+
guard((data) => {
|
|
170
|
+
find.status = data;
|
|
171
|
+
}),
|
|
172
|
+
guard((data) => {
|
|
173
|
+
find.options = data;
|
|
174
|
+
}),
|
|
175
|
+
guard((data) => {
|
|
176
|
+
find.item = data;
|
|
177
|
+
}),
|
|
178
|
+
id,
|
|
179
|
+
{
|
|
180
|
+
...loaderOptions,
|
|
181
|
+
...opts,
|
|
182
|
+
signal
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
);
|
|
186
|
+
const addRun = (payload) => withRequest(
|
|
187
|
+
"add",
|
|
188
|
+
payload.signal,
|
|
189
|
+
false,
|
|
190
|
+
(signal, guard) => apiAddHelper(
|
|
191
|
+
() => ({
|
|
192
|
+
items: fetch.items,
|
|
193
|
+
status: add.status,
|
|
194
|
+
data: add.item,
|
|
195
|
+
options: add.options
|
|
196
|
+
}),
|
|
197
|
+
guard((data) => {
|
|
198
|
+
add.status = data;
|
|
199
|
+
}),
|
|
200
|
+
guard((data) => {
|
|
201
|
+
add.options = data;
|
|
202
|
+
}),
|
|
203
|
+
guard((data) => {
|
|
204
|
+
add.item = data;
|
|
205
|
+
}),
|
|
206
|
+
guard((data) => {
|
|
207
|
+
fetch.items = data;
|
|
208
|
+
}),
|
|
209
|
+
payload.data,
|
|
210
|
+
{
|
|
211
|
+
...loaderOptions,
|
|
212
|
+
...payload,
|
|
213
|
+
signal
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
);
|
|
217
|
+
const updateRun = (id, payload) => withRequest(
|
|
218
|
+
"update",
|
|
219
|
+
payload.signal,
|
|
220
|
+
false,
|
|
221
|
+
(signal, guard) => updateHelper(
|
|
222
|
+
() => ({
|
|
223
|
+
items: fetch.items,
|
|
224
|
+
status: update.status,
|
|
225
|
+
data: update.item,
|
|
226
|
+
oldData: find.item,
|
|
227
|
+
options: update.options
|
|
228
|
+
}),
|
|
229
|
+
guard((data) => {
|
|
230
|
+
update.status = data;
|
|
231
|
+
}),
|
|
232
|
+
guard((data) => {
|
|
233
|
+
update.options = data;
|
|
234
|
+
}),
|
|
235
|
+
guard((data) => {
|
|
236
|
+
update.item = data;
|
|
237
|
+
}),
|
|
238
|
+
guard((data) => {
|
|
239
|
+
fetch.items = data;
|
|
240
|
+
}),
|
|
241
|
+
guard((data) => {
|
|
242
|
+
find.item = data;
|
|
243
|
+
}),
|
|
244
|
+
id,
|
|
245
|
+
payload.data,
|
|
246
|
+
{
|
|
247
|
+
...loaderOptions,
|
|
248
|
+
...payload,
|
|
249
|
+
signal
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
);
|
|
253
|
+
const deleteRun = (id, opts) => withRequest(
|
|
254
|
+
"delete",
|
|
255
|
+
opts?.signal,
|
|
256
|
+
false,
|
|
257
|
+
(signal, guard) => apiDeleteHelper(
|
|
258
|
+
() => ({
|
|
259
|
+
status: del.status,
|
|
260
|
+
data: del.item,
|
|
261
|
+
items: fetch.items,
|
|
262
|
+
options: del.options
|
|
263
|
+
}),
|
|
264
|
+
guard((data) => {
|
|
265
|
+
del.status = data;
|
|
266
|
+
}),
|
|
267
|
+
guard((data) => {
|
|
268
|
+
del.options = data;
|
|
269
|
+
}),
|
|
270
|
+
guard((data) => {
|
|
271
|
+
del.item = data;
|
|
272
|
+
}),
|
|
273
|
+
guard((data) => {
|
|
274
|
+
fetch.items = data;
|
|
275
|
+
}),
|
|
276
|
+
id,
|
|
277
|
+
{
|
|
278
|
+
...loaderOptions,
|
|
279
|
+
...opts,
|
|
280
|
+
signal
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
);
|
|
409
284
|
return {
|
|
410
|
-
// State and methods
|
|
411
285
|
fetch,
|
|
412
286
|
find,
|
|
413
287
|
add,
|
|
414
288
|
update,
|
|
415
289
|
delete: del,
|
|
416
|
-
// Rename del to delete in the return object
|
|
417
290
|
fetchPage,
|
|
418
291
|
fetchAll,
|
|
419
292
|
fetchSearch,
|
|
@@ -425,11 +298,11 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
425
298
|
addRun,
|
|
426
299
|
updateRun,
|
|
427
300
|
deleteRun,
|
|
428
|
-
cancelFetch,
|
|
429
|
-
cancelFind,
|
|
430
|
-
cancelAdd,
|
|
431
|
-
cancelUpdate,
|
|
432
|
-
cancelDelete,
|
|
301
|
+
cancelFetch: () => cancel("fetch"),
|
|
302
|
+
cancelFind: () => cancel("find"),
|
|
303
|
+
cancelAdd: () => cancel("add"),
|
|
304
|
+
cancelUpdate: () => cancel("update"),
|
|
305
|
+
cancelDelete: () => cancel("delete"),
|
|
433
306
|
cancelAll,
|
|
434
307
|
clearAll
|
|
435
308
|
};
|
|
@@ -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
|
-
...
|
|
10
|
+
...uiConfig()[name]
|
|
10
11
|
});
|
|
11
12
|
};
|
|
12
13
|
export const useUiIconConfig = (name) => {
|
|
13
|
-
return
|
|
14
|
+
return uiConfig()[name].icons;
|
|
14
15
|
};
|
|
15
16
|
export const useUiStaticConfig = (name) => {
|
|
16
|
-
return
|
|
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,7 @@ export var DialogType = /* @__PURE__ */ ((DialogType2) => {
|
|
|
10
11
|
})(DialogType || {});
|
|
11
12
|
export const useDialog = () => {
|
|
12
13
|
const overlay = useOverlay();
|
|
14
|
+
const { messages } = useCoreMessages();
|
|
13
15
|
const modalLoading = overlay.create(Dialog);
|
|
14
16
|
const openDialog = async (payload) => {
|
|
15
17
|
const modal = overlay.create(Dialog);
|
|
@@ -57,7 +59,7 @@ export const useDialog = () => {
|
|
|
57
59
|
const loading = async (payload = {}) => {
|
|
58
60
|
modalLoading.open({
|
|
59
61
|
...payload,
|
|
60
|
-
title: payload.title ||
|
|
62
|
+
title: payload.title || messages.value.common.loading,
|
|
61
63
|
type: "loading" /* LOADING */
|
|
62
64
|
});
|
|
63
65
|
};
|
|
@@ -6,7 +6,7 @@ interface IFieldContext<TValue> extends FieldContext<TValue> {
|
|
|
6
6
|
}
|
|
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
|
-
export declare const moveToError: ({ errors
|
|
10
|
-
errors:
|
|
9
|
+
export declare const moveToError: ({ errors }: {
|
|
10
|
+
errors: Record<string, unknown>;
|
|
11
11
|
}) => void;
|
|
12
12
|
export {};
|