@finema/core 2.36.1 → 2.38.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 (38) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +1 -1
  3. package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
  4. package/dist/runtime/components/Form/Fields.vue +13 -13
  5. package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
  6. package/dist/runtime/components/Form/InputComponent/index.vue +1 -1
  7. package/dist/runtime/components/Form/InputDateTime/index.vue +52 -52
  8. package/dist/runtime/components/Form/InputDateTimeRange/index.vue +55 -55
  9. package/dist/runtime/components/Form/InputMonth/index.vue +50 -50
  10. package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
  11. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +43 -43
  12. package/dist/runtime/components/Form/InputTags/index.vue +23 -23
  13. package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
  14. package/dist/runtime/components/Form/InputTime/index.vue +38 -38
  15. package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
  16. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +30 -30
  17. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +51 -50
  18. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue.d.ts +1 -0
  19. package/dist/runtime/components/Form/InputUploadDropzoneAuto/types.d.ts +1 -0
  20. package/dist/runtime/components/Form/fileState/EmptyState.vue +21 -21
  21. package/dist/runtime/components/Form/fileState/FailedState.vue +33 -33
  22. package/dist/runtime/components/Form/fileState/LoadingState.vue +24 -24
  23. package/dist/runtime/components/Form/fileState/PreviewModal.vue +23 -23
  24. package/dist/runtime/components/Form/fileState/useUploadState.js +2 -1
  25. package/dist/runtime/components/Form/index.vue +5 -5
  26. package/dist/runtime/components/Form/types.d.ts +1 -0
  27. package/dist/runtime/components/Image.vue +28 -28
  28. package/dist/runtime/components/Log/index.vue +17 -17
  29. package/dist/runtime/components/Table/Base.vue +67 -67
  30. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  31. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  32. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  33. package/dist/runtime/components/Table/ColumnText.vue +1 -1
  34. package/dist/runtime/components/Table/Simple.vue +20 -20
  35. package/dist/runtime/composables/loaderPage.js +32 -0
  36. package/dist/runtime/helpers/apiPageHelper.d.ts +2 -0
  37. package/dist/runtime/server/tsconfig.json +3 -3
  38. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
- <template>
2
- <form class="form">
3
- <slot />
4
- </form>
5
- </template>
1
+ <template>
2
+ <form class="form">
3
+ <slot />
4
+ </form>
5
+ </template>
@@ -79,4 +79,5 @@ export interface IFileValue {
79
79
  path?: string;
80
80
  name?: string;
81
81
  size?: number;
82
+ id?: string;
82
83
  }
@@ -1,32 +1,32 @@
1
1
  <template>
2
- <UseImage v-bind="$props">
3
- <template #loading>
4
- <slot name="loading">
5
- <div
6
- class="flex h-full w-full items-center justify-center"
7
- >
8
- <Loader
9
- :loading="true"
10
- />
11
- </div>
12
- </slot>
13
- </template>
14
-
15
- <template #error>
16
- <slot name="error">
17
- <div
18
- class="flex h-full w-full items-center justify-center"
19
- >
20
- <p class="text-error-400">
21
- <Icon
22
- name="i-heroicons:exclamation-circle-solid"
23
- class="text-error-400 size-8"
24
- />
25
- </p>
26
- </div>
27
- </slot>
28
- </template>
29
- </UseImage>
2
+ <UseImage v-bind="$props">
3
+ <template #loading>
4
+ <slot name="loading">
5
+ <div
6
+ class="flex h-full w-full items-center justify-center"
7
+ >
8
+ <Loader
9
+ :loading="true"
10
+ />
11
+ </div>
12
+ </slot>
13
+ </template>
14
+
15
+ <template #error>
16
+ <slot name="error">
17
+ <div
18
+ class="flex h-full w-full items-center justify-center"
19
+ >
20
+ <p class="text-error-400">
21
+ <Icon
22
+ name="i-heroicons:exclamation-circle-solid"
23
+ class="text-error-400 size-8"
24
+ />
25
+ </p>
26
+ </div>
27
+ </slot>
28
+ </template>
29
+ </UseImage>
30
30
  </template>
31
31
 
32
32
  <script setup>
@@ -1,21 +1,21 @@
1
1
  <template>
2
- <DevOnly>
3
- <TeleportSafe
4
- to="#dev-logs"
5
- >
6
- <LogItem
7
- v-if="typeof data !== 'undefined'"
8
- :data="data"
9
- :title="title"
10
- />
11
- <LogItem
12
- v-for="(item, index) in dataItems"
13
- :key="index"
14
- :data="item"
15
- :title="`${title} #${index + 1}`"
16
- />
17
- </TeleportSafe>
18
- </DevOnly>
2
+ <DevOnly>
3
+ <TeleportSafe
4
+ to="#dev-logs"
5
+ >
6
+ <LogItem
7
+ v-if="typeof data !== 'undefined'"
8
+ :data="data"
9
+ :title="title"
10
+ />
11
+ <LogItem
12
+ v-for="(item, index) in dataItems"
13
+ :key="index"
14
+ :data="item"
15
+ :title="`${title} #${index + 1}`"
16
+ />
17
+ </TeleportSafe>
18
+ </DevOnly>
19
19
  </template>
20
20
 
21
21
  <script setup>
@@ -1,71 +1,71 @@
1
1
  <template>
2
- <div
3
- v-if="!isHideCaption"
4
- class="mb-4 text-gray-500"
5
- >
6
- <span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
7
- จำนวน
8
- <span class="font-bold">{{ pageOptions?.totalCount || rawData.length || 0 }}</span>
9
- รายการ
10
- </div>
11
- <UTable
12
- :loading="status.isLoading"
13
- :columns="uTableCompatibleColumns"
14
- :data="rawData"
15
- v-bind="$attrs"
16
- >
17
- <template #loading-state>
18
- <div class="flex h-60 items-center justify-center">
19
- <Icon
20
- name="i-svg-spinners:180-ring-with-bg"
21
- class="text-primary size-8"
22
- />
23
- </div>
24
- </template>
25
- <template #empty-state>
26
- <Empty />
27
- </template>
28
- <template
29
- v-for="column in columns.filter((item) => !!item.type)"
30
- #[`${column.accessorKey}-cell`]="{ row }"
31
- :key="column.accessorKey"
32
- >
33
- <component
34
- :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
35
- v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
36
- :value="transformValue(column, row)"
37
- :column="column"
38
- :row="row"
39
- />
40
- </template>
41
- <template
42
- v-for="(_, slotName) of $slots"
43
- #[slotName]="slotProps"
44
- >
45
- <slot
46
- :name="slotName"
47
- v-bind="slotProps || {}"
48
- />
49
- </template>
50
- </UTable>
51
- <div
52
- v-if="!isHidePagination && pageOptions"
53
- :class="theme.paginationContainer({})"
54
- >
55
- <p
56
- :class="theme.paginationInfo({})"
57
- >
58
- {{ pageBetween }} รายการ จากทั้งหมด {{ totalCountWithComma }} รายการ
59
- </p>
60
- <Pagination
61
- v-if="pageOptions.totalPage > 1"
62
- v-model:page="page"
63
- :default-page="pageOptions?.currentPage || 1"
64
- :items-per-page="pageOptions.limit"
65
- :total="pageOptions.totalCount"
66
- @update:page="onPageChange"
67
- />
68
- </div>
2
+ <div
3
+ v-if="!isHideCaption"
4
+ class="mb-4 text-gray-500"
5
+ >
6
+ <span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
7
+ จำนวน
8
+ <span class="font-bold">{{ pageOptions?.totalCount || rawData.length || 0 }}</span>
9
+ รายการ
10
+ </div>
11
+ <UTable
12
+ :loading="status.isLoading"
13
+ :columns="uTableCompatibleColumns"
14
+ :data="rawData"
15
+ v-bind="$attrs"
16
+ >
17
+ <template #loading-state>
18
+ <div class="flex h-60 items-center justify-center">
19
+ <Icon
20
+ name="i-svg-spinners:180-ring-with-bg"
21
+ class="text-primary size-8"
22
+ />
23
+ </div>
24
+ </template>
25
+ <template #empty-state>
26
+ <Empty />
27
+ </template>
28
+ <template
29
+ v-for="column in columns.filter((item) => !!item.type)"
30
+ #[`${column.accessorKey}-cell`]="{ row }"
31
+ :key="column.accessorKey"
32
+ >
33
+ <component
34
+ :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
35
+ v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
36
+ :value="transformValue(column, row)"
37
+ :column="column"
38
+ :row="row"
39
+ />
40
+ </template>
41
+ <template
42
+ v-for="(_, slotName) of $slots"
43
+ #[slotName]="slotProps"
44
+ >
45
+ <slot
46
+ :name="slotName"
47
+ v-bind="slotProps || {}"
48
+ />
49
+ </template>
50
+ </UTable>
51
+ <div
52
+ v-if="!isHidePagination && pageOptions"
53
+ :class="theme.paginationContainer({})"
54
+ >
55
+ <p
56
+ :class="theme.paginationInfo({})"
57
+ >
58
+ {{ pageBetween }} รายการ จากทั้งหมด {{ totalCountWithComma }} รายการ
59
+ </p>
60
+ <Pagination
61
+ v-if="pageOptions.totalPage > 1"
62
+ v-model:page="page"
63
+ :default-page="pageOptions?.currentPage || 1"
64
+ :items-per-page="pageOptions.limit"
65
+ :total="pageOptions.totalCount"
66
+ @update:page="onPageChange"
67
+ />
68
+ </div>
69
69
  </template>
70
70
 
71
71
  <script setup>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- {{ getValue || "-" }}
2
+ {{ getValue || "-" }}
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- {{ getValue || "-" }}
2
+ {{ getValue || "-" }}
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <Image
3
- class="h-12 rounded"
4
- :src="getValue"
5
- />
2
+ <Image
3
+ class="h-12 rounded"
4
+ :src="getValue"
5
+ />
6
6
  </template>
7
7
 
8
8
  <script setup>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- {{ getValue }}
2
+ {{ getValue }}
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,24 +1,24 @@
1
1
  <template>
2
- <Base
3
- v-bind="$attrs"
4
- :columns="options.columns"
5
- :raw-data="itemsByPage"
6
- :status="options.status"
7
- :page-options="pageOptions"
8
- :is-hide-pagination="options.isHidePagination"
9
- :is-hide-caption="options.isHideCaption"
10
- @page-change="onPageChange"
11
- >
12
- <template
13
- v-for="(_, slot) of $slots"
14
- #[slot]="slotProps"
15
- >
16
- <slot
17
- :name="slot"
18
- v-bind="slotProps || {}"
19
- />
20
- </template>
21
- </Base>
2
+ <Base
3
+ v-bind="$attrs"
4
+ :columns="options.columns"
5
+ :raw-data="itemsByPage"
6
+ :status="options.status"
7
+ :page-options="pageOptions"
8
+ :is-hide-pagination="options.isHidePagination"
9
+ :is-hide-caption="options.isHideCaption"
10
+ @page-change="onPageChange"
11
+ >
12
+ <template
13
+ v-for="(_, slot) of $slots"
14
+ #[slot]="slotProps"
15
+ >
16
+ <slot
17
+ :name="slot"
18
+ v-bind="slotProps || {}"
19
+ />
20
+ </template>
21
+ </Base>
22
22
  </template>
23
23
 
24
24
  <script setup>
@@ -21,6 +21,7 @@ export const usePageLoader = (loaderOptions) => {
21
21
  const config = useCoreConfig();
22
22
  const fetch = reactive({
23
23
  status: ObjectHelper.createStatus(),
24
+ statusNextPage: ObjectHelper.createStatus(),
24
25
  items: [],
25
26
  options: initPageOptions({
26
27
  limit: config.limit_per_page,
@@ -54,6 +55,7 @@ export const usePageLoader = (loaderOptions) => {
54
55
  add.status = ObjectHelper.createStatus();
55
56
  update.status = ObjectHelper.createStatus();
56
57
  fetch.status = ObjectHelper.createStatus();
58
+ fetch.statusNextPage = ObjectHelper.createStatus();
57
59
  find.item = null;
58
60
  del.item = null;
59
61
  update.item = null;
@@ -184,6 +186,35 @@ export const usePageLoader = (loaderOptions) => {
184
186
  const fetchSearch = async (query = "", opts) => {
185
187
  await fetchPage(1, query, opts);
186
188
  };
189
+ const fetchNextPage = async (opts) => {
190
+ const {
191
+ page: _page,
192
+ ...params
193
+ } = fetch.options?.request?.params || {};
194
+ await apiFetchHelper(
195
+ () => ({
196
+ status: fetch.status,
197
+ items: fetch.items,
198
+ options: fetch.options
199
+ }),
200
+ (data) => {
201
+ fetch.statusNextPage = data;
202
+ },
203
+ (data) => {
204
+ fetch.options = data;
205
+ },
206
+ (data) => {
207
+ fetch.items = [...fetch.items, ...data];
208
+ },
209
+ fetch.options.currentPage + 1,
210
+ fetch.options.search || "",
211
+ {
212
+ ...loaderOptions,
213
+ params,
214
+ ...opts
215
+ }
216
+ );
217
+ };
187
218
  const fetchPageChange = async (page, opts) => {
188
219
  const {
189
220
  page: _page,
@@ -232,6 +263,7 @@ export const usePageLoader = (loaderOptions) => {
232
263
  fetchPage,
233
264
  fetchSearch,
234
265
  fetchPageChange,
266
+ fetchNextPage,
235
267
  fetchSetLoading,
236
268
  findSetLoading,
237
269
  findRun,
@@ -46,6 +46,7 @@ export interface IPageLoaderOptions<T> {
46
46
  export interface IUsePageLoader<T> {
47
47
  fetch: {
48
48
  status: IStatus;
49
+ statusNextPage: IStatus;
49
50
  items: T[];
50
51
  options: IPageOptions;
51
52
  };
@@ -72,6 +73,7 @@ export interface IUsePageLoader<T> {
72
73
  };
73
74
  fetchPage: (page?: number, query?: string, opts?: IPageFetchLoaderOptions) => Promise<void>;
74
75
  fetchPageChange: (page: number, opts?: IPageFetchLoaderOptions) => Promise<void>;
76
+ fetchNextPage: (opts?: IPageFetchLoaderOptions) => Promise<void>;
75
77
  fetchSearch: (query: string, opts?: IPageFetchLoaderOptions) => Promise<void>;
76
78
  fetchSetLoading: () => void;
77
79
  findSetLoading: () => void;
@@ -1,3 +1,3 @@
1
- {
2
- "extends": "../../../.nuxt/tsconfig.server.json",
3
- }
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json",
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.36.1",
3
+ "version": "2.38.0",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",
@@ -93,4 +93,4 @@
93
93
  "lint-staged": {
94
94
  "*": "eslint --fix --quiet"
95
95
  }
96
- }
96
+ }