@finema/core 3.19.0 → 3.20.1
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/dist/module.json +1 -1
- package/dist/module.mjs +43 -60
- package/dist/runtime/components/App.d.vue.ts +2 -2
- package/dist/runtime/components/App.vue.d.ts +2 -2
- package/dist/runtime/components/Empty.d.vue.ts +1 -1
- package/dist/runtime/components/Empty.vue.d.ts +1 -1
- package/dist/runtime/components/FlexDeck/index.vue +79 -79
- package/dist/runtime/components/Form/FieldWrapper.d.vue.ts +2 -2
- package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
- package/dist/runtime/components/Form/FieldWrapper.vue.d.ts +2 -2
- package/dist/runtime/components/Form/Fields.vue +13 -13
- package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
- package/dist/runtime/components/Form/InputCheckboxGroup/index.vue +21 -21
- package/dist/runtime/components/Form/InputCurrency/index.vue +49 -49
- package/dist/runtime/components/Form/InputDateTime/index.vue +63 -63
- package/dist/runtime/components/Form/InputDateTimeRange/index.vue +56 -56
- package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
- package/dist/runtime/components/Form/InputSelect/index.vue +110 -110
- package/dist/runtime/components/Form/InputSelectMultiple/index.vue +118 -118
- package/dist/runtime/components/Form/InputTags/index.d.vue.ts +2 -2
- package/dist/runtime/components/Form/InputTags/index.vue +54 -54
- package/dist/runtime/components/Form/InputTags/index.vue.d.ts +2 -2
- package/dist/runtime/components/Form/InputText/index.vue +86 -86
- package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
- package/dist/runtime/components/Form/InputTime/index.vue +38 -38
- package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
- package/dist/runtime/components/Form/InputUploadDropzone/index.vue +30 -30
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +50 -50
- package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +50 -50
- package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +50 -50
- package/dist/runtime/components/Form/InputWYSIWYG/EditorImageUploadNode.vue +18 -18
- package/dist/runtime/components/Form/InputWYSIWYG/EditorLinkPopover.vue +65 -65
- package/dist/runtime/components/Form/InputWYSIWYG/README.md +96 -96
- package/dist/runtime/components/Form/InputWYSIWYG/index.vue +41 -41
- package/dist/runtime/components/Form/fileState/EmptyState.vue +21 -21
- package/dist/runtime/components/Form/fileState/FailedState.vue +33 -33
- package/dist/runtime/components/Form/fileState/LoadingState.vue +24 -24
- package/dist/runtime/components/Form/fileState/MultipleFilesState.vue +75 -75
- package/dist/runtime/components/Form/fileState/PreviewModal.vue +23 -23
- package/dist/runtime/components/Form/index.vue +5 -5
- package/dist/runtime/components/Image.vue +28 -28
- package/dist/runtime/components/Log/index.vue +17 -17
- package/dist/runtime/components/Table/Base.d.vue.ts +4 -4
- package/dist/runtime/components/Table/Base.vue +117 -117
- package/dist/runtime/components/Table/Base.vue.d.ts +4 -4
- 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 +62 -62
- package/dist/runtime/components/Table/Simple.vue +19 -19
- package/dist/runtime/components/Table/index.vue +33 -33
- package/dist/runtime/components/TeleportSafe.d.vue.ts +2 -2
- package/dist/runtime/components/TeleportSafe.vue.d.ts +2 -2
- package/dist/runtime/helpers/apiBaseHelper.d.ts +10 -2
- package/dist/runtime/helpers/apiBaseHelper.js +28 -7
- package/dist/runtime/helpers/apiListHelper.js +9 -13
- package/dist/runtime/helpers/apiObjectHelper.js +9 -13
- package/dist/runtime/helpers/apiPageHelper.js +43 -62
- package/dist/runtime/server/tsconfig.json +3 -3
- package/package.json +10 -10
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<NuxtLink
|
|
3
|
-
v-if="column.meta?.link"
|
|
4
|
-
v-bind="column.meta.link"
|
|
5
|
-
>
|
|
6
|
-
{{ getValue }}
|
|
7
|
-
</NuxtLink>
|
|
8
|
-
|
|
9
|
-
<span v-else>
|
|
10
|
-
{{ getValue }}
|
|
11
|
-
</span>
|
|
2
|
+
<NuxtLink
|
|
3
|
+
v-if="column.meta?.link"
|
|
4
|
+
v-bind="column.meta.link"
|
|
5
|
+
>
|
|
6
|
+
{{ getValue }}
|
|
7
|
+
</NuxtLink>
|
|
8
|
+
|
|
9
|
+
<span v-else>
|
|
10
|
+
{{ getValue }}
|
|
11
|
+
</span>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script setup>
|
|
@@ -1,90 +1,90 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
3
|
:class="
|
|
4
4
|
theme.paginationContainer({
|
|
5
5
|
class: [ui?.paginationContainer]
|
|
6
6
|
})
|
|
7
|
-
"
|
|
8
|
-
>
|
|
9
|
-
<div
|
|
7
|
+
"
|
|
8
|
+
>
|
|
9
|
+
<div
|
|
10
10
|
:class="
|
|
11
11
|
theme.paginationInfoWrapper({
|
|
12
12
|
class: [ui?.paginationInfoWrapper]
|
|
13
13
|
})
|
|
14
|
-
"
|
|
15
|
-
>
|
|
16
|
-
<USelect
|
|
17
|
-
v-if="options.pageOptions && !options.isHideLimitSelect"
|
|
18
|
-
size="lg"
|
|
19
|
-
trailing="รายการ"
|
|
14
|
+
"
|
|
15
|
+
>
|
|
16
|
+
<USelect
|
|
17
|
+
v-if="options.pageOptions && !options.isHideLimitSelect"
|
|
18
|
+
size="lg"
|
|
19
|
+
trailing="รายการ"
|
|
20
20
|
:class="
|
|
21
21
|
theme.paginationLimitSelect({
|
|
22
22
|
class: [ui?.paginationLimitSelect, 'cursor-pointer']
|
|
23
23
|
})
|
|
24
|
-
"
|
|
25
|
-
:items="pageLimitItems"
|
|
26
|
-
:model-value="pageLimit"
|
|
27
|
-
@update:modelValue="emits('pageLimitChange', $event)"
|
|
28
|
-
>
|
|
29
|
-
<template #default="{ modelValue }">
|
|
30
|
-
<p
|
|
24
|
+
"
|
|
25
|
+
:items="pageLimitItems"
|
|
26
|
+
:model-value="pageLimit"
|
|
27
|
+
@update:modelValue="emits('pageLimitChange', $event)"
|
|
28
|
+
>
|
|
29
|
+
<template #default="{ modelValue }">
|
|
30
|
+
<p
|
|
31
31
|
:class="
|
|
32
32
|
theme.paginationLimitSelectLabel({
|
|
33
33
|
class: [ui?.paginationLimitSelectLabel]
|
|
34
34
|
})
|
|
35
|
-
"
|
|
36
|
-
>
|
|
37
|
-
{{ modelValue }}
|
|
38
|
-
{{ appConfig.core?.locale === "th" ? "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23" : "items" }}
|
|
39
|
-
</p>
|
|
40
|
-
</template>
|
|
41
|
-
</USelect>
|
|
42
|
-
<p
|
|
35
|
+
"
|
|
36
|
+
>
|
|
37
|
+
{{ modelValue }}
|
|
38
|
+
{{ appConfig.core?.locale === "th" ? "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23" : "items" }}
|
|
39
|
+
</p>
|
|
40
|
+
</template>
|
|
41
|
+
</USelect>
|
|
42
|
+
<p
|
|
43
43
|
:class="
|
|
44
44
|
theme.paginationInfo({
|
|
45
45
|
class: [ui?.paginationInfo, '']
|
|
46
46
|
})
|
|
47
|
-
"
|
|
48
|
-
>
|
|
49
|
-
<span v-if="options.pageOptions">{{ pageBetween }}
|
|
50
|
-
{{ appConfig.core?.locale === "th" ? "\u0E08\u0E32\u0E01\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14" : "of total" }}
|
|
51
|
-
{{ totalCountWithComma }}</span>
|
|
52
|
-
<span v-else>{{ appConfig.core?.locale === "th" ? "\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14" : "Total" }}
|
|
53
|
-
{{ options.rawData.length }}
|
|
54
|
-
{{ appConfig.core?.locale === "th" ? "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23" : "items" }}</span>
|
|
55
|
-
</p>
|
|
56
|
-
</div>
|
|
57
|
-
<UPagination
|
|
58
|
-
v-if="options.pageOptions && options.pageOptions.totalPage > 1"
|
|
59
|
-
:page="page"
|
|
60
|
-
:default-page="options.pageOptions?.currentPage || 1"
|
|
61
|
-
:items-per-page="options.pageOptions.limit"
|
|
62
|
-
:total="options.pageOptions.totalCount"
|
|
63
|
-
:to="options.isRouteChange ? to : void 0"
|
|
64
|
-
show-edges
|
|
65
|
-
variant="outline"
|
|
66
|
-
color="neutral"
|
|
67
|
-
active-color="neutral"
|
|
68
|
-
active-variant="subtle"
|
|
69
|
-
@update:page="emits('pageChange', $event)"
|
|
70
|
-
>
|
|
71
|
-
<template #item="{ item, page }">
|
|
72
|
-
<Button
|
|
73
|
-
:variant="page === item.value ? 'subtle' : 'outline'"
|
|
74
|
-
:color="page === item.value ? 'neutral' : 'neutral'"
|
|
75
|
-
:label="String(NumberHelper.withComma(item.value))"
|
|
76
|
-
:ui="{ label: themePagination.label }"
|
|
77
|
-
square
|
|
78
|
-
:to="options.isRouteChange ? to?.(item.value) : void 0"
|
|
47
|
+
"
|
|
48
|
+
>
|
|
49
|
+
<span v-if="options.pageOptions">{{ pageBetween }}
|
|
50
|
+
{{ appConfig.core?.locale === "th" ? "\u0E08\u0E32\u0E01\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14" : "of total" }}
|
|
51
|
+
{{ totalCountWithComma }}</span>
|
|
52
|
+
<span v-else>{{ appConfig.core?.locale === "th" ? "\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14" : "Total" }}
|
|
53
|
+
{{ options.rawData.length }}
|
|
54
|
+
{{ appConfig.core?.locale === "th" ? "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23" : "items" }}</span>
|
|
55
|
+
</p>
|
|
56
|
+
</div>
|
|
57
|
+
<UPagination
|
|
58
|
+
v-if="options.pageOptions && options.pageOptions.totalPage > 1"
|
|
59
|
+
:page="page"
|
|
60
|
+
:default-page="options.pageOptions?.currentPage || 1"
|
|
61
|
+
:items-per-page="options.pageOptions.limit"
|
|
62
|
+
:total="options.pageOptions.totalCount"
|
|
63
|
+
:to="options.isRouteChange ? to : void 0"
|
|
64
|
+
show-edges
|
|
65
|
+
variant="outline"
|
|
66
|
+
color="neutral"
|
|
67
|
+
active-color="neutral"
|
|
68
|
+
active-variant="subtle"
|
|
69
|
+
@update:page="emits('pageChange', $event)"
|
|
70
|
+
>
|
|
71
|
+
<template #item="{ item, page }">
|
|
72
|
+
<Button
|
|
73
|
+
:variant="page === item.value ? 'subtle' : 'outline'"
|
|
74
|
+
:color="page === item.value ? 'neutral' : 'neutral'"
|
|
75
|
+
:label="String(NumberHelper.withComma(item.value))"
|
|
76
|
+
:ui="{ label: themePagination.label }"
|
|
77
|
+
square
|
|
78
|
+
:to="options.isRouteChange ? to?.(item.value) : void 0"
|
|
79
79
|
:class="
|
|
80
80
|
theme.buttonPagination({
|
|
81
81
|
class: [ui?.buttonPagination]
|
|
82
82
|
})
|
|
83
|
-
"
|
|
84
|
-
/>
|
|
85
|
-
</template>
|
|
86
|
-
</UPagination>
|
|
87
|
-
</div>
|
|
83
|
+
"
|
|
84
|
+
/>
|
|
85
|
+
</template>
|
|
86
|
+
</UPagination>
|
|
87
|
+
</div>
|
|
88
88
|
</template>
|
|
89
89
|
|
|
90
90
|
<script setup>
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Base
|
|
3
|
-
v-bind="$attrs"
|
|
2
|
+
<Base
|
|
3
|
+
v-bind="$attrs"
|
|
4
4
|
:options="{
|
|
5
5
|
...options,
|
|
6
6
|
pageOptions,
|
|
7
7
|
isHideLimitSelect: true,
|
|
8
8
|
rawData: itemsByPage
|
|
9
|
-
}"
|
|
10
|
-
:ui="computedUi"
|
|
11
|
-
:to="to"
|
|
12
|
-
:target="target"
|
|
13
|
-
:preserve-query="preserveQuery"
|
|
14
|
-
@page-change="onPageChange"
|
|
15
|
-
>
|
|
16
|
-
<template
|
|
17
|
-
v-for="(_, slot) of $slots"
|
|
18
|
-
#[slot]="slotProps"
|
|
19
|
-
>
|
|
20
|
-
<slot
|
|
21
|
-
:name="slot"
|
|
22
|
-
v-bind="slotProps || {}"
|
|
23
|
-
/>
|
|
24
|
-
</template>
|
|
25
|
-
</Base>
|
|
9
|
+
}"
|
|
10
|
+
:ui="computedUi"
|
|
11
|
+
:to="to"
|
|
12
|
+
:target="target"
|
|
13
|
+
:preserve-query="preserveQuery"
|
|
14
|
+
@page-change="onPageChange"
|
|
15
|
+
>
|
|
16
|
+
<template
|
|
17
|
+
v-for="(_, slot) of $slots"
|
|
18
|
+
#[slot]="slotProps"
|
|
19
|
+
>
|
|
20
|
+
<slot
|
|
21
|
+
:name="slot"
|
|
22
|
+
v-bind="slotProps || {}"
|
|
23
|
+
/>
|
|
24
|
+
</template>
|
|
25
|
+
</Base>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
28
|
<script setup>
|
|
@@ -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 || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
|
|
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 || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
|
|
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>
|
|
@@ -2,9 +2,9 @@ type __VLS_Props = {
|
|
|
2
2
|
to: string;
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare var
|
|
5
|
+
declare var __VLS_7: {};
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
7
|
-
default?: (props: typeof
|
|
7
|
+
default?: (props: typeof __VLS_7) => any;
|
|
8
8
|
};
|
|
9
9
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
10
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -2,9 +2,9 @@ type __VLS_Props = {
|
|
|
2
2
|
to: string;
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare var
|
|
5
|
+
declare var __VLS_7: {};
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
7
|
-
default?: (props: typeof
|
|
7
|
+
default?: (props: typeof __VLS_7) => any;
|
|
8
8
|
};
|
|
9
9
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
10
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -13,11 +13,18 @@ export interface IRequestContext {
|
|
|
13
13
|
data?: any;
|
|
14
14
|
options: AxiosRequestConfig;
|
|
15
15
|
}
|
|
16
|
+
type StateRequestOptions = Partial<AxiosRequestConfig>;
|
|
16
17
|
export declare const checkExpiration: (timestamp: number | undefined, expire?: number) => boolean;
|
|
17
18
|
export declare const bindParamsToUrl: (urlTemplate: string, urlParams?: Record<string, any>) => string;
|
|
18
19
|
export declare const prepareRequestOptions: (baseOptions?: AxiosRequestConfig, requestOptions?: AxiosRequestConfig, params?: Record<string, any>, signal?: AbortSignal) => AxiosRequestConfig;
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const toSerializableRequestOptions: (options: AxiosRequestConfig) => StateRequestOptions;
|
|
21
|
+
export declare const prepareLoaderRequestOptions: (baseOptions?: AxiosRequestConfig, requestOptions?: AxiosRequestConfig, params?: Record<string, any>, signal?: AbortSignal) => {
|
|
22
|
+
requestOptions: AxiosRequestConfig<any>;
|
|
23
|
+
stateRequestOptions: Partial<AxiosRequestConfig<any>>;
|
|
24
|
+
};
|
|
25
|
+
export declare const createSuccessOptions: (status: number | undefined, request: StateRequestOptions) => IAPIOptions;
|
|
26
|
+
export declare const createErrorOptions: (error: any, request: StateRequestOptions) => IAPIOptions;
|
|
27
|
+
export declare const toSerializableLoaderOptions: <T extends Record<string, any>>(opts: T) => Partial<T>;
|
|
21
28
|
export declare const handleApiRequest: <T>(requestContext: IRequestContext, mockData: T | T[] | null, callbacks: {
|
|
22
29
|
onSuccess: (data: T, status?: number) => void;
|
|
23
30
|
onError: (error: any) => void;
|
|
@@ -30,3 +37,4 @@ export declare const updateLoaderState: {
|
|
|
30
37
|
setComplete: (status: IStatus) => IStatus;
|
|
31
38
|
setOptions: (options: IAPIOptions, updates: Partial<IAPIOptions>) => IAPIOptions;
|
|
32
39
|
};
|
|
40
|
+
export {};
|
|
@@ -22,13 +22,6 @@ export const prepareRequestOptions = (baseOptions, requestOptions, params, signa
|
|
|
22
22
|
});
|
|
23
23
|
return options;
|
|
24
24
|
};
|
|
25
|
-
export const omitLoaderSignal = (opts) => {
|
|
26
|
-
const {
|
|
27
|
-
signal: _signal,
|
|
28
|
-
...rest
|
|
29
|
-
} = opts;
|
|
30
|
-
return rest;
|
|
31
|
-
};
|
|
32
25
|
export const toSerializableRequestOptions = (options) => {
|
|
33
26
|
const {
|
|
34
27
|
adapter: _adapter,
|
|
@@ -42,6 +35,34 @@ export const toSerializableRequestOptions = (options) => {
|
|
|
42
35
|
} = options;
|
|
43
36
|
return JSON.parse(JSON.stringify(serializableOptions));
|
|
44
37
|
};
|
|
38
|
+
export const prepareLoaderRequestOptions = (baseOptions, requestOptions, params, signal) => {
|
|
39
|
+
const options = prepareRequestOptions(baseOptions, requestOptions, params, signal);
|
|
40
|
+
return {
|
|
41
|
+
requestOptions: options,
|
|
42
|
+
stateRequestOptions: toSerializableRequestOptions(options)
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export const createSuccessOptions = (status, request) => ({
|
|
46
|
+
_timestamp: Date.now(),
|
|
47
|
+
_status: status,
|
|
48
|
+
request
|
|
49
|
+
});
|
|
50
|
+
export const createErrorOptions = (error, request) => ({
|
|
51
|
+
_status: error.response?.status,
|
|
52
|
+
request
|
|
53
|
+
});
|
|
54
|
+
export const toSerializableLoaderOptions = (opts) => {
|
|
55
|
+
const {
|
|
56
|
+
request,
|
|
57
|
+
signal: _signal,
|
|
58
|
+
...rest
|
|
59
|
+
} = opts;
|
|
60
|
+
const serializableOptions = JSON.parse(JSON.stringify(rest));
|
|
61
|
+
if (request) {
|
|
62
|
+
serializableOptions.request = toSerializableRequestOptions(request);
|
|
63
|
+
}
|
|
64
|
+
return serializableOptions;
|
|
65
|
+
};
|
|
45
66
|
const createAbortError = () => ({
|
|
46
67
|
code: "ERR_CANCELED",
|
|
47
68
|
name: "AbortError",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { bindParamsToUrl } from "./apiBaseHelper.js";
|
|
2
2
|
import {
|
|
3
3
|
checkExpiration,
|
|
4
|
-
|
|
4
|
+
createErrorOptions,
|
|
5
|
+
createSuccessOptions,
|
|
5
6
|
handleApiRequest,
|
|
6
|
-
|
|
7
|
+
prepareLoaderRequestOptions,
|
|
7
8
|
updateLoaderState
|
|
8
9
|
} from "./apiBaseHelper.js";
|
|
9
10
|
export const apiListHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateItems, opts) => {
|
|
@@ -13,13 +14,15 @@ export const apiListHelper = async (state, onUpdateStatus, onUpdateOptions, onUp
|
|
|
13
14
|
}
|
|
14
15
|
onUpdateStatus(updateLoaderState.setLoading(state().status));
|
|
15
16
|
onUpdateOptions({});
|
|
16
|
-
const
|
|
17
|
+
const {
|
|
18
|
+
requestOptions,
|
|
19
|
+
stateRequestOptions
|
|
20
|
+
} = prepareLoaderRequestOptions(
|
|
17
21
|
{},
|
|
18
22
|
opts.getRequestOptions?.(opts),
|
|
19
23
|
opts.params,
|
|
20
24
|
opts.signal
|
|
21
25
|
);
|
|
22
|
-
const serializableRequestOptions = toSerializableRequestOptions(requestOptions);
|
|
23
26
|
const url = bindParamsToUrl(opts.getURL ? opts.getURL(opts) : opts.url, opts.urlBind || {});
|
|
24
27
|
await handleApiRequest(
|
|
25
28
|
{
|
|
@@ -32,18 +35,11 @@ export const apiListHelper = async (state, onUpdateStatus, onUpdateOptions, onUp
|
|
|
32
35
|
onSuccess: (items, status) => {
|
|
33
36
|
onUpdateItems(items);
|
|
34
37
|
onUpdateStatus(updateLoaderState.setSuccess(state().status));
|
|
35
|
-
onUpdateOptions(
|
|
36
|
-
_timestamp: Date.now(),
|
|
37
|
-
_status: status,
|
|
38
|
-
request: serializableRequestOptions
|
|
39
|
-
});
|
|
38
|
+
onUpdateOptions(createSuccessOptions(status, stateRequestOptions));
|
|
40
39
|
},
|
|
41
40
|
onError: (error) => {
|
|
42
41
|
onUpdateStatus(updateLoaderState.setError(state().status, error));
|
|
43
|
-
onUpdateOptions(
|
|
44
|
-
_status: error.response?.status,
|
|
45
|
-
request: serializableRequestOptions
|
|
46
|
-
});
|
|
42
|
+
onUpdateOptions(createErrorOptions(error, stateRequestOptions));
|
|
47
43
|
},
|
|
48
44
|
onComplete: () => {
|
|
49
45
|
onUpdateStatus(updateLoaderState.setComplete(state().status));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { bindParamsToUrl } from "./apiBaseHelper.js";
|
|
2
2
|
import {
|
|
3
3
|
checkExpiration,
|
|
4
|
+
createErrorOptions,
|
|
5
|
+
createSuccessOptions,
|
|
4
6
|
handleApiRequest,
|
|
5
|
-
|
|
6
|
-
toSerializableRequestOptions,
|
|
7
|
+
prepareLoaderRequestOptions,
|
|
7
8
|
updateLoaderState
|
|
8
9
|
} from "./apiBaseHelper.js";
|
|
9
10
|
export const apiObjectHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateData, payload, opts) => {
|
|
@@ -13,13 +14,15 @@ export const apiObjectHelper = async (state, onUpdateStatus, onUpdateOptions, on
|
|
|
13
14
|
}
|
|
14
15
|
onUpdateStatus(updateLoaderState.setLoading(state().status));
|
|
15
16
|
onUpdateOptions({});
|
|
16
|
-
const
|
|
17
|
+
const {
|
|
18
|
+
requestOptions,
|
|
19
|
+
stateRequestOptions
|
|
20
|
+
} = prepareLoaderRequestOptions(
|
|
17
21
|
{},
|
|
18
22
|
opts.getRequestOptions?.(payload, opts),
|
|
19
23
|
opts.params,
|
|
20
24
|
opts.signal
|
|
21
25
|
);
|
|
22
|
-
const serializableRequestOptions = toSerializableRequestOptions(requestOptions);
|
|
23
26
|
const url = bindParamsToUrl(opts.getURL ? opts.getURL(payload, opts) : opts.url, opts.urlBind || {});
|
|
24
27
|
await handleApiRequest(
|
|
25
28
|
{
|
|
@@ -33,18 +36,11 @@ export const apiObjectHelper = async (state, onUpdateStatus, onUpdateOptions, on
|
|
|
33
36
|
onSuccess: (item, status) => {
|
|
34
37
|
onUpdateData(item);
|
|
35
38
|
onUpdateStatus(updateLoaderState.setSuccess(state().status));
|
|
36
|
-
onUpdateOptions(
|
|
37
|
-
request: serializableRequestOptions,
|
|
38
|
-
_timestamp: Date.now(),
|
|
39
|
-
_status: status
|
|
40
|
-
});
|
|
39
|
+
onUpdateOptions(createSuccessOptions(status, stateRequestOptions));
|
|
41
40
|
},
|
|
42
41
|
onError: (error) => {
|
|
43
42
|
onUpdateStatus(updateLoaderState.setError(state().status, error));
|
|
44
|
-
onUpdateOptions(
|
|
45
|
-
request: serializableRequestOptions,
|
|
46
|
-
_status: error.response?.status
|
|
47
|
-
});
|
|
43
|
+
onUpdateOptions(createErrorOptions(error, stateRequestOptions));
|
|
48
44
|
},
|
|
49
45
|
onComplete: () => {
|
|
50
46
|
onUpdateStatus(updateLoaderState.setComplete(state().status));
|