@finema/core 3.23.2 → 3.25.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.json +1 -1
- package/dist/module.mjs +3 -14
- package/dist/runtime/components/DevToolsWindow/index.vue +24 -26
- package/dist/runtime/components/Dialog/index.vue +11 -10
- package/dist/runtime/components/Empty.d.vue.ts +1 -1
- package/dist/runtime/components/Empty.vue +16 -12
- package/dist/runtime/components/Empty.vue.d.ts +1 -1
- package/dist/runtime/components/FlexDeck/index.vue +85 -92
- package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
- package/dist/runtime/components/Form/Fields.d.vue.ts +1 -1
- package/dist/runtime/components/Form/Fields.vue +17 -11
- package/dist/runtime/components/Form/Fields.vue.d.ts +1 -1
- package/dist/runtime/components/Form/InputCheckbox/index.vue +19 -23
- package/dist/runtime/components/Form/InputCheckboxGroup/index.vue +1 -5
- package/dist/runtime/components/Form/InputCurrency/index.vue +56 -57
- package/dist/runtime/components/Form/InputDateTime/date_time_field.types.d.ts +2 -0
- package/dist/runtime/components/Form/InputDateTime/index.vue +70 -80
- package/dist/runtime/components/Form/InputDateTimeRange/index.vue +78 -75
- package/dist/runtime/components/Form/InputMonth/index.vue +7 -10
- package/dist/runtime/components/Form/InputNumber/index.vue +21 -25
- package/dist/runtime/components/Form/InputRadio/index.d.vue.ts +1 -1
- package/dist/runtime/components/Form/InputRadio/index.vue +1 -5
- package/dist/runtime/components/Form/InputRadio/index.vue.d.ts +1 -1
- package/dist/runtime/components/Form/InputRating/index.vue +1 -5
- package/dist/runtime/components/Form/InputSearch/index.vue +2 -8
- package/dist/runtime/components/Form/InputSelect/index.vue +112 -122
- package/dist/runtime/components/Form/InputSelectMultiple/index.vue +121 -133
- package/dist/runtime/components/Form/InputTags/index.vue +55 -59
- package/dist/runtime/components/Form/InputText/index.vue +122 -133
- package/dist/runtime/components/Form/InputTextarea/index.vue +19 -23
- package/dist/runtime/components/Form/InputTime/index.d.vue.ts +1 -0
- package/dist/runtime/components/Form/InputTime/index.vue +66 -63
- package/dist/runtime/components/Form/InputTime/index.vue.d.ts +1 -0
- package/dist/runtime/components/Form/InputTime/types.d.ts +2 -0
- package/dist/runtime/components/Form/InputToggle/index.vue +18 -21
- package/dist/runtime/components/Form/InputUploadDropzone/index.vue +46 -49
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +57 -63
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +57 -64
- package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +57 -63
- 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 +21 -19
- package/dist/runtime/components/Form/InputWYSIWYG/EditorLinkPopover.vue +85 -87
- package/dist/runtime/components/Form/InputWYSIWYG/README.md +96 -96
- package/dist/runtime/components/Form/InputWYSIWYG/index.vue +178 -157
- package/dist/runtime/components/Form/fileState/EmptyState.vue +21 -21
- package/dist/runtime/components/Form/fileState/FailedState.vue +34 -36
- package/dist/runtime/components/Form/fileState/LoadingState.vue +24 -24
- package/dist/runtime/components/Form/fileState/MultipleFilesState.vue +74 -78
- package/dist/runtime/components/Form/fileState/PreviewModal.vue +23 -23
- package/dist/runtime/components/Form/fileState/SuccessState.vue +3 -12
- package/dist/runtime/components/Form/fileState/useFileState.js +2 -10
- package/dist/runtime/components/Form/fileState/useUploadImageState.js +1 -3
- package/dist/runtime/components/Form/fileState/useUploadState.js +8 -19
- package/dist/runtime/components/Form/fileState/useUploadStateMultiple.js +25 -30
- package/dist/runtime/components/Form/index.vue +5 -5
- package/dist/runtime/components/Image.vue +22 -28
- package/dist/runtime/components/Loader.d.vue.ts +1 -1
- package/dist/runtime/components/Loader.vue +10 -7
- package/dist/runtime/components/Loader.vue.d.ts +1 -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.vue +117 -137
- package/dist/runtime/components/Table/ColumnDate.vue +1 -1
- package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
- package/dist/runtime/components/Table/ColumnImage.vue +4 -4
- package/dist/runtime/components/Table/ColumnText.vue +10 -10
- package/dist/runtime/components/Table/Pagination.vue +71 -77
- package/dist/runtime/components/Table/Simple.vue +19 -19
- package/dist/runtime/components/Table/index.vue +36 -42
- package/dist/runtime/composables/loaderList.js +1 -3
- package/dist/runtime/composables/loaderPage.js +156 -133
- package/dist/runtime/composables/useConfig.js +1 -1
- package/dist/runtime/composables/useDialog.js +1 -3
- package/dist/runtime/composables/useForm.d.ts +1 -1
- package/dist/runtime/composables/useForm.js +1 -3
- 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.js +19 -38
- package/dist/runtime/helpers/componentHelper.js +2 -6
- package/dist/runtime/helpers/uploadCore.js +1 -4
- package/dist/runtime/locale/index.js +1 -4
- package/dist/runtime/server/tsconfig.json +3 -3
- package/dist/runtime/styles/main.css +1 -1
- package/package.json +39 -26
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="tableContainer">
|
|
3
|
-
<div
|
|
4
|
-
v-if="options.isEnabledSearch"
|
|
2
|
+
<div ref="tableContainer">
|
|
3
|
+
<div
|
|
4
|
+
v-if="options.isEnabledSearch"
|
|
5
5
|
:class="
|
|
6
6
|
theme.searchContainer({
|
|
7
7
|
class: [ui?.searchContainer]
|
|
8
8
|
})
|
|
9
|
-
"
|
|
10
|
-
>
|
|
11
|
-
<Input
|
|
12
|
-
v-model="q"
|
|
13
|
-
icon="i-heroicons-magnifying-glass"
|
|
14
|
-
:placeholder="options.searchPlaceholder || messages.common.search"
|
|
15
|
-
/>
|
|
16
|
-
</div>
|
|
17
|
-
<Base
|
|
18
|
-
v-bind="$attrs"
|
|
19
|
-
:options="options"
|
|
20
|
-
:ui="computedUi"
|
|
21
|
-
:column-pinning="computedColumnPinning"
|
|
22
|
-
:to="to"
|
|
23
|
-
:target="target"
|
|
24
|
-
:preserve-query="preserveQuery"
|
|
25
|
-
@page-change="onPageChange"
|
|
26
|
-
@search="emits('search', q)"
|
|
27
|
-
>
|
|
28
|
-
<template
|
|
29
|
-
v-for="(_, slot) of $slots"
|
|
30
|
-
#[slot]="slotProps"
|
|
31
|
-
>
|
|
32
|
-
<slot
|
|
33
|
-
:name="slot"
|
|
34
|
-
v-bind="slotProps || {}"
|
|
35
|
-
/>
|
|
36
|
-
</template>
|
|
37
|
-
</Base>
|
|
38
|
-
</div>
|
|
9
|
+
"
|
|
10
|
+
>
|
|
11
|
+
<Input
|
|
12
|
+
v-model="q"
|
|
13
|
+
icon="i-heroicons-magnifying-glass"
|
|
14
|
+
:placeholder="options.searchPlaceholder || messages.common.search"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
<Base
|
|
18
|
+
v-bind="$attrs"
|
|
19
|
+
:options="options"
|
|
20
|
+
:ui="computedUi"
|
|
21
|
+
:column-pinning="computedColumnPinning"
|
|
22
|
+
:to="to"
|
|
23
|
+
:target="target"
|
|
24
|
+
:preserve-query="preserveQuery"
|
|
25
|
+
@page-change="onPageChange"
|
|
26
|
+
@search="emits('search', q)"
|
|
27
|
+
>
|
|
28
|
+
<template
|
|
29
|
+
v-for="(_, slot) of $slots"
|
|
30
|
+
#[slot]="slotProps"
|
|
31
|
+
>
|
|
32
|
+
<slot
|
|
33
|
+
:name="slot"
|
|
34
|
+
v-bind="slotProps || {}"
|
|
35
|
+
/>
|
|
36
|
+
</template>
|
|
37
|
+
</Base>
|
|
38
|
+
</div>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
41
|
<script setup>
|
|
@@ -72,13 +72,9 @@ const computedUi = computed(() => {
|
|
|
72
72
|
});
|
|
73
73
|
const computedColumnPinning = computed(() => {
|
|
74
74
|
if (props.isPinAction) {
|
|
75
|
-
const hasActionsColumn = props.options.columns.some(
|
|
76
|
-
(col) => col.accessorKey === "actions"
|
|
77
|
-
);
|
|
75
|
+
const hasActionsColumn = props.options.columns.some((col) => col.accessorKey === "actions");
|
|
78
76
|
if (hasActionsColumn) {
|
|
79
|
-
const rightPinned = props.columnPinning.right.filter(
|
|
80
|
-
(col) => col !== "actions"
|
|
81
|
-
);
|
|
77
|
+
const rightPinned = props.columnPinning.right.filter((col) => col !== "actions");
|
|
82
78
|
return {
|
|
83
79
|
left: props.columnPinning.left,
|
|
84
80
|
right: [...rightPinned, "actions"]
|
|
@@ -104,7 +100,5 @@ const onPageChange = (newPage) => {
|
|
|
104
100
|
}
|
|
105
101
|
emits("pageChange", newPage);
|
|
106
102
|
};
|
|
107
|
-
const {
|
|
108
|
-
messages
|
|
109
|
-
} = useCoreMessages();
|
|
103
|
+
const { messages } = useCoreMessages();
|
|
110
104
|
</script>
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { reactive, computed } from "vue";
|
|
2
2
|
import { ObjectHelper } from "../utils/ObjectHelper.js";
|
|
3
3
|
import { createCancelableRequest } from "../helpers/apiCancelHelper.js";
|
|
4
|
-
import {
|
|
5
|
-
apiListHelper
|
|
6
|
-
} from "../helpers/apiListHelper.js";
|
|
4
|
+
import { apiListHelper } from "../helpers/apiListHelper.js";
|
|
7
5
|
const useListLoader = (loaderOptions) => {
|
|
8
6
|
const result = reactive({
|
|
9
7
|
items: [],
|
|
@@ -65,6 +65,7 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
const cancelAll = () => {
|
|
68
|
+
;
|
|
68
69
|
Object.keys(requests).forEach(cancel);
|
|
69
70
|
};
|
|
70
71
|
const withRequest = async (key, externalSignal, autoCancel, run) => {
|
|
@@ -100,30 +101,35 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
100
101
|
const findSetLoading = () => {
|
|
101
102
|
find.status = ObjectHelper.toLoadingStatus(find.status);
|
|
102
103
|
};
|
|
103
|
-
const runFetch = (page, query, opts, mode = "replace") => withRequest(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
);
|
|
127
133
|
const fetchPage = (page = 1, query = "", opts) => runFetch(page, query, opts);
|
|
128
134
|
const fetchAll = (query = "", opts = {}) => runFetch(1, query, {
|
|
129
135
|
...opts,
|
|
@@ -134,10 +140,7 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
134
140
|
});
|
|
135
141
|
const fetchSearch = (query = "", opts) => fetchPage(1, query, opts);
|
|
136
142
|
const lastFetchParams = () => {
|
|
137
|
-
const {
|
|
138
|
-
page: _page,
|
|
139
|
-
...params
|
|
140
|
-
} = fetch.options?.request?.params || {};
|
|
143
|
+
const { page: _page, ...params } = fetch.options?.request?.params || {};
|
|
141
144
|
return params;
|
|
142
145
|
};
|
|
143
146
|
const fetchNextPage = (opts) => runFetch(
|
|
@@ -153,111 +156,131 @@ export const usePageLoader = (loaderOptions) => {
|
|
|
153
156
|
params: lastFetchParams(),
|
|
154
157
|
...opts
|
|
155
158
|
});
|
|
156
|
-
const findRun = (id, opts) => withRequest(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
guard
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
data
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
+
);
|
|
261
284
|
return {
|
|
262
285
|
fetch,
|
|
263
286
|
find,
|
|
@@ -11,9 +11,7 @@ export var DialogType = /* @__PURE__ */ ((DialogType2) => {
|
|
|
11
11
|
})(DialogType || {});
|
|
12
12
|
export const useDialog = () => {
|
|
13
13
|
const overlay = useOverlay();
|
|
14
|
-
const {
|
|
15
|
-
messages
|
|
16
|
-
} = useCoreMessages();
|
|
14
|
+
const { messages } = useCoreMessages();
|
|
17
15
|
const modalLoading = overlay.create(Dialog);
|
|
18
16
|
const openDialog = async (payload) => {
|
|
19
17
|
const modal = overlay.create(Dialog);
|
|
@@ -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
|
|
9
|
+
export declare const moveToError: ({ errors }: {
|
|
10
10
|
errors: Record<string, unknown>;
|
|
11
11
|
}) => void;
|
|
12
12
|
export {};
|
|
@@ -21,9 +21,7 @@ export const useFieldHOC = (newFormProps, opts) => {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
export const createFormFields = (fields) => computed(fields);
|
|
24
|
-
export const moveToError = ({
|
|
25
|
-
errors
|
|
26
|
-
}) => {
|
|
24
|
+
export const moveToError = ({ errors }) => {
|
|
27
25
|
const firstErrorFieldName = Object.keys(errors)[0];
|
|
28
26
|
const el = document.querySelector(`[name="${firstErrorFieldName}"]`);
|
|
29
27
|
if (el) {
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { get } from "@vueuse/core";
|
|
2
2
|
import { computed, ObjectHelper } from "#imports";
|
|
3
3
|
export const useTable = (options) => computed(() => {
|
|
4
|
-
const {
|
|
5
|
-
repo,
|
|
6
|
-
columns,
|
|
7
|
-
transformItems,
|
|
8
|
-
options: nestedOptions,
|
|
9
|
-
...inlineOptions
|
|
10
|
-
} = options;
|
|
4
|
+
const { repo, columns, transformItems, options: nestedOptions, ...inlineOptions } = options;
|
|
11
5
|
return createTableOptions(
|
|
12
6
|
repo,
|
|
13
7
|
columns(),
|
|
@@ -19,13 +13,7 @@ export const useTable = (options) => computed(() => {
|
|
|
19
13
|
);
|
|
20
14
|
});
|
|
21
15
|
export const useTableSimple = (options) => computed(() => {
|
|
22
|
-
const {
|
|
23
|
-
items,
|
|
24
|
-
status,
|
|
25
|
-
columns,
|
|
26
|
-
options: nestedOptions,
|
|
27
|
-
...inlineOptions
|
|
28
|
-
} = options;
|
|
16
|
+
const { items, status, columns, options: nestedOptions, ...inlineOptions } = options;
|
|
29
17
|
return {
|
|
30
18
|
items: items(),
|
|
31
19
|
columns: columns(),
|
|
@@ -52,11 +52,7 @@ export const createErrorOptions = (error, request) => ({
|
|
|
52
52
|
request
|
|
53
53
|
});
|
|
54
54
|
export const toSerializableLoaderOptions = (opts) => {
|
|
55
|
-
const {
|
|
56
|
-
request,
|
|
57
|
-
signal: _signal,
|
|
58
|
-
...rest
|
|
59
|
-
} = opts;
|
|
55
|
+
const { request, signal: _signal, ...rest } = opts;
|
|
60
56
|
const serializableOptions = JSON.parse(JSON.stringify(rest));
|
|
61
57
|
if (request) {
|
|
62
58
|
serializableOptions.request = toSerializableRequestOptions(request);
|
|
@@ -89,12 +85,7 @@ const wait = (ms, signal) => new Promise((resolve, reject) => {
|
|
|
89
85
|
});
|
|
90
86
|
});
|
|
91
87
|
export const handleApiRequest = async (requestContext, mockData, callbacks) => {
|
|
92
|
-
const {
|
|
93
|
-
url,
|
|
94
|
-
method,
|
|
95
|
-
data,
|
|
96
|
-
options
|
|
97
|
-
} = requestContext;
|
|
88
|
+
const { url, method, data, options } = requestContext;
|
|
98
89
|
try {
|
|
99
90
|
if (mockData) {
|
|
100
91
|
await wait(300, options.signal);
|
|
@@ -111,19 +102,10 @@ export const handleApiRequest = async (requestContext, mockData, callbacks) => {
|
|
|
111
102
|
}
|
|
112
103
|
};
|
|
113
104
|
export const updateLoaderState = {
|
|
114
|
-
setLoading: (status) => ObjectHelper.toLoadingStatus(
|
|
115
|
-
|
|
116
|
-
),
|
|
117
|
-
|
|
118
|
-
status
|
|
119
|
-
),
|
|
120
|
-
setError: (status, error) => ObjectHelper.toErrorStatus(
|
|
121
|
-
status,
|
|
122
|
-
error
|
|
123
|
-
),
|
|
124
|
-
setComplete: (status) => ObjectHelper.toCompleteStatus(
|
|
125
|
-
status
|
|
126
|
-
),
|
|
105
|
+
setLoading: (status) => ObjectHelper.toLoadingStatus(status),
|
|
106
|
+
setSuccess: (status) => ObjectHelper.toSuccessStatus(status),
|
|
107
|
+
setError: (status, error) => ObjectHelper.toErrorStatus(status, error),
|
|
108
|
+
setComplete: (status) => ObjectHelper.toCompleteStatus(status),
|
|
127
109
|
setOptions: (options, updates) => ({
|
|
128
110
|
...options,
|
|
129
111
|
...updates,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bindParamsToUrl } from "./apiBaseHelper.js";
|
|
2
1
|
import {
|
|
2
|
+
bindParamsToUrl,
|
|
3
3
|
checkExpiration,
|
|
4
4
|
createErrorOptions,
|
|
5
5
|
createSuccessOptions,
|
|
@@ -14,10 +14,7 @@ export const apiListHelper = async (state, onUpdateStatus, onUpdateOptions, onUp
|
|
|
14
14
|
}
|
|
15
15
|
onUpdateStatus(updateLoaderState.setLoading(state().status));
|
|
16
16
|
onUpdateOptions({});
|
|
17
|
-
const {
|
|
18
|
-
requestOptions,
|
|
19
|
-
stateRequestOptions
|
|
20
|
-
} = prepareLoaderRequestOptions(
|
|
17
|
+
const { requestOptions, stateRequestOptions } = prepareLoaderRequestOptions(
|
|
21
18
|
{},
|
|
22
19
|
opts.getRequestOptions?.(opts),
|
|
23
20
|
opts.params,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bindParamsToUrl } from "./apiBaseHelper.js";
|
|
2
1
|
import {
|
|
2
|
+
bindParamsToUrl,
|
|
3
3
|
checkExpiration,
|
|
4
4
|
createErrorOptions,
|
|
5
5
|
createSuccessOptions,
|
|
@@ -14,10 +14,7 @@ export const apiObjectHelper = async (state, onUpdateStatus, onUpdateOptions, on
|
|
|
14
14
|
}
|
|
15
15
|
onUpdateStatus(updateLoaderState.setLoading(state().status));
|
|
16
16
|
onUpdateOptions({});
|
|
17
|
-
const {
|
|
18
|
-
requestOptions,
|
|
19
|
-
stateRequestOptions
|
|
20
|
-
} = prepareLoaderRequestOptions(
|
|
17
|
+
const { requestOptions, stateRequestOptions } = prepareLoaderRequestOptions(
|
|
21
18
|
{},
|
|
22
19
|
opts.getRequestOptions?.(payload, opts),
|
|
23
20
|
opts.params,
|