@finema/core 3.17.2 → 3.19.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.
Files changed (88) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +1 -1
  3. package/dist/runtime/components/FlexDeck/index.vue +79 -79
  4. package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
  5. package/dist/runtime/components/Form/Fields.vue +13 -13
  6. package/dist/runtime/components/Form/InputCheckbox/index.d.vue.ts +5 -1
  7. package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
  8. package/dist/runtime/components/Form/InputCheckbox/index.vue.d.ts +5 -1
  9. package/dist/runtime/components/Form/InputCheckboxGroup/index.d.vue.ts +5 -1
  10. package/dist/runtime/components/Form/InputCheckboxGroup/index.vue +21 -21
  11. package/dist/runtime/components/Form/InputCheckboxGroup/index.vue.d.ts +5 -1
  12. package/dist/runtime/components/Form/InputCurrency/index.d.vue.ts +5 -1
  13. package/dist/runtime/components/Form/InputCurrency/index.vue +49 -49
  14. package/dist/runtime/components/Form/InputCurrency/index.vue.d.ts +5 -1
  15. package/dist/runtime/components/Form/InputDateTime/index.d.vue.ts +5 -1
  16. package/dist/runtime/components/Form/InputDateTime/index.vue +63 -63
  17. package/dist/runtime/components/Form/InputDateTime/index.vue.d.ts +5 -1
  18. package/dist/runtime/components/Form/InputDateTimeRange/index.d.vue.ts +5 -1
  19. package/dist/runtime/components/Form/InputDateTimeRange/index.vue +56 -56
  20. package/dist/runtime/components/Form/InputDateTimeRange/index.vue.d.ts +5 -1
  21. package/dist/runtime/components/Form/InputMonth/index.d.vue.ts +5 -1
  22. package/dist/runtime/components/Form/InputMonth/index.vue.d.ts +5 -1
  23. package/dist/runtime/components/Form/InputNumber/index.d.vue.ts +5 -1
  24. package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
  25. package/dist/runtime/components/Form/InputNumber/index.vue.d.ts +5 -1
  26. package/dist/runtime/components/Form/InputSearch/index.d.vue.ts +9 -1
  27. package/dist/runtime/components/Form/InputSearch/index.vue.d.ts +9 -1
  28. package/dist/runtime/components/Form/InputSelect/index.d.vue.ts +7 -1
  29. package/dist/runtime/components/Form/InputSelect/index.vue +110 -110
  30. package/dist/runtime/components/Form/InputSelect/index.vue.d.ts +7 -1
  31. package/dist/runtime/components/Form/InputSelectMultiple/index.d.vue.ts +7 -1
  32. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +118 -118
  33. package/dist/runtime/components/Form/InputSelectMultiple/index.vue.d.ts +7 -1
  34. package/dist/runtime/components/Form/InputTags/index.d.vue.ts +11 -1
  35. package/dist/runtime/components/Form/InputTags/index.vue +54 -54
  36. package/dist/runtime/components/Form/InputTags/index.vue.d.ts +11 -1
  37. package/dist/runtime/components/Form/InputText/index.d.vue.ts +7 -1
  38. package/dist/runtime/components/Form/InputText/index.vue +85 -85
  39. package/dist/runtime/components/Form/InputText/index.vue.d.ts +7 -1
  40. package/dist/runtime/components/Form/InputTextarea/index.d.vue.ts +5 -1
  41. package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
  42. package/dist/runtime/components/Form/InputTextarea/index.vue.d.ts +5 -1
  43. package/dist/runtime/components/Form/InputTime/index.d.vue.ts +5 -1
  44. package/dist/runtime/components/Form/InputTime/index.vue +38 -38
  45. package/dist/runtime/components/Form/InputTime/index.vue.d.ts +5 -1
  46. package/dist/runtime/components/Form/InputToggle/index.d.vue.ts +5 -1
  47. package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
  48. package/dist/runtime/components/Form/InputToggle/index.vue.d.ts +5 -1
  49. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +30 -30
  50. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +50 -50
  51. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +50 -50
  52. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +50 -50
  53. package/dist/runtime/components/Form/InputWYSIWYG/EditorImageUploadNode.vue +18 -18
  54. package/dist/runtime/components/Form/InputWYSIWYG/EditorLinkPopover.vue +65 -65
  55. package/dist/runtime/components/Form/InputWYSIWYG/README.md +96 -96
  56. package/dist/runtime/components/Form/InputWYSIWYG/index.vue +41 -41
  57. package/dist/runtime/components/Form/fileState/EmptyState.vue +21 -21
  58. package/dist/runtime/components/Form/fileState/FailedState.vue +33 -33
  59. package/dist/runtime/components/Form/fileState/LoadingState.vue +24 -24
  60. package/dist/runtime/components/Form/fileState/MultipleFilesState.vue +75 -75
  61. package/dist/runtime/components/Form/fileState/PreviewModal.vue +23 -23
  62. package/dist/runtime/components/Form/index.vue +5 -5
  63. package/dist/runtime/components/Image.vue +28 -28
  64. package/dist/runtime/components/Log/index.vue +17 -17
  65. package/dist/runtime/components/Table/Base.d.vue.ts +8 -2
  66. package/dist/runtime/components/Table/Base.vue +117 -117
  67. package/dist/runtime/components/Table/Base.vue.d.ts +8 -2
  68. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  69. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  70. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  71. package/dist/runtime/components/Table/ColumnText.vue +10 -10
  72. package/dist/runtime/components/Table/Pagination.vue +62 -62
  73. package/dist/runtime/components/Table/Simple.vue +19 -19
  74. package/dist/runtime/components/Table/index.vue +33 -33
  75. package/dist/runtime/composables/loaderList.js +38 -15
  76. package/dist/runtime/composables/loaderObject.js +49 -20
  77. package/dist/runtime/composables/loaderPage.js +300 -168
  78. package/dist/runtime/helpers/apiBaseHelper.d.ts +5 -2
  79. package/dist/runtime/helpers/apiBaseHelper.js +53 -3
  80. package/dist/runtime/helpers/apiCancelHelper.d.ts +6 -0
  81. package/dist/runtime/helpers/apiCancelHelper.js +22 -0
  82. package/dist/runtime/helpers/apiListHelper.js +6 -3
  83. package/dist/runtime/helpers/apiObjectHelper.d.ts +3 -1
  84. package/dist/runtime/helpers/apiObjectHelper.js +6 -3
  85. package/dist/runtime/helpers/apiPageHelper.d.ts +9 -3
  86. package/dist/runtime/helpers/apiPageHelper.js +29 -16
  87. package/dist/runtime/server/tsconfig.json +3 -3
  88. package/package.json +2 -2
@@ -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>
@@ -1,5 +1,6 @@
1
1
  import { reactive, computed } from "vue";
2
2
  import { ObjectHelper } from "../utils/ObjectHelper.js";
3
+ import { createCancelableRequest } from "../helpers/apiCancelHelper.js";
3
4
  import {
4
5
  apiListHelper
5
6
  } from "../helpers/apiListHelper.js";
@@ -9,28 +10,49 @@ export const useListLoader = (loaderOptions) => {
9
10
  status: ObjectHelper.createStatus(),
10
11
  options: {}
11
12
  });
13
+ let request = null;
14
+ const isActiveRequest = (currentRequest) => request === currentRequest;
15
+ const cancel = () => {
16
+ if (!request) return;
17
+ request.controller.abort();
18
+ request.cleanup();
19
+ request = null;
20
+ result.status = ObjectHelper.toCompleteStatus(result.status);
21
+ };
12
22
  const clear = () => {
23
+ cancel();
13
24
  result.status = ObjectHelper.createStatus();
14
25
  result.items = [];
15
26
  result.options = {};
16
27
  };
17
28
  const run = async (payload) => {
18
- await apiListHelper(
19
- () => result,
20
- (_data) => {
21
- result.status = _data;
22
- },
23
- (_data) => {
24
- result.options = _data;
25
- },
26
- (_data) => {
27
- result.items = _data;
28
- },
29
- {
30
- ...loaderOptions,
31
- ...payload
29
+ cancel();
30
+ const currentRequest = createCancelableRequest(payload?.signal);
31
+ request = currentRequest;
32
+ try {
33
+ await apiListHelper(
34
+ () => result,
35
+ (_data) => {
36
+ if (isActiveRequest(currentRequest)) result.status = _data;
37
+ },
38
+ (_data) => {
39
+ if (isActiveRequest(currentRequest)) result.options = _data;
40
+ },
41
+ (_data) => {
42
+ if (isActiveRequest(currentRequest)) result.items = _data;
43
+ },
44
+ {
45
+ ...loaderOptions,
46
+ ...payload,
47
+ signal: currentRequest.signal
48
+ }
49
+ );
50
+ } finally {
51
+ if (isActiveRequest(currentRequest)) {
52
+ currentRequest.cleanup();
53
+ request = null;
32
54
  }
33
- );
55
+ }
34
56
  };
35
57
  const setLoading = () => {
36
58
  result.items = [];
@@ -44,6 +66,7 @@ export const useListLoader = (loaderOptions) => {
44
66
  status: computed(() => result.status),
45
67
  options: computed(() => result.options),
46
68
  run,
69
+ cancel,
47
70
  clear,
48
71
  setItems,
49
72
  setLoading
@@ -1,5 +1,6 @@
1
1
  import { computed, reactive } from "vue";
2
2
  import { ObjectHelper } from "../utils/ObjectHelper.js";
3
+ import { createCancelableRequest } from "../helpers/apiCancelHelper.js";
3
4
  import {
4
5
  apiObjectHelper
5
6
  } from "../helpers/apiObjectHelper.js";
@@ -9,32 +10,59 @@ export const useObjectLoader = (loaderOptions) => {
9
10
  status: ObjectHelper.createStatus(),
10
11
  options: {}
11
12
  });
13
+ let request = null;
14
+ const isActiveRequest = (currentRequest) => request === currentRequest;
15
+ const canUpdateState = (currentRequest) => {
16
+ return isActiveRequest(currentRequest) || !currentRequest.signal.aborted;
17
+ };
18
+ const cancel = () => {
19
+ if (!request) return;
20
+ request.controller.abort();
21
+ request.cleanup();
22
+ request = null;
23
+ state.status = ObjectHelper.toCompleteStatus(state.status);
24
+ };
12
25
  const clear = () => {
26
+ cancel();
13
27
  state.status = ObjectHelper.createStatus();
14
28
  state.data = null;
15
29
  };
16
30
  const run = async (payload = {}) => {
17
- await apiObjectHelper(
18
- () => ({
19
- data: state.data,
20
- status: state.status,
21
- options: state.options
22
- }),
23
- (_status) => {
24
- state.status = _status;
25
- },
26
- (_options) => {
27
- state.options = _options;
28
- },
29
- (_data) => {
30
- state.data = _data ?? null;
31
- },
32
- payload.data,
33
- {
34
- ...loaderOptions,
35
- ...payload
31
+ const method = String(payload.method ?? loaderOptions.method).toUpperCase();
32
+ if (method === "GET") cancel();
33
+ const currentRequest = createCancelableRequest(payload.signal);
34
+ request = currentRequest;
35
+ try {
36
+ await apiObjectHelper(
37
+ () => ({
38
+ data: state.data,
39
+ status: state.status,
40
+ options: state.options
41
+ }),
42
+ (_status) => {
43
+ if (canUpdateState(currentRequest)) state.status = _status;
44
+ },
45
+ (_options) => {
46
+ if (canUpdateState(currentRequest)) state.options = _options;
47
+ },
48
+ (_data) => {
49
+ if (canUpdateState(currentRequest)) {
50
+ state.data = _data ?? null;
51
+ }
52
+ },
53
+ payload.data,
54
+ {
55
+ ...loaderOptions,
56
+ ...payload,
57
+ signal: currentRequest.signal
58
+ }
59
+ );
60
+ } finally {
61
+ currentRequest.cleanup();
62
+ if (isActiveRequest(currentRequest)) {
63
+ request = null;
36
64
  }
37
- );
65
+ }
38
66
  };
39
67
  const setLoading = () => {
40
68
  state.status = ObjectHelper.toLoadingStatus(state.status);
@@ -47,6 +75,7 @@ export const useObjectLoader = (loaderOptions) => {
47
75
  status: computed(() => state.status),
48
76
  options: computed(() => state.options),
49
77
  run,
78
+ cancel,
50
79
  clear,
51
80
  setLoading,
52
81
  setData