@finema/core 2.31.2 → 2.32.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/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.31.2",
3
+ "version": "2.32.0",
4
4
  "configKey": "core",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import * as lodash from 'lodash-es';
4
4
  import * as theme from '../dist/runtime/theme/index.js';
5
5
 
6
6
  const name = "@finema/core";
7
- const version = "2.31.2";
7
+ const version = "2.32.0";
8
8
 
9
9
  const nuxtAppOptions = {
10
10
  head: {
@@ -5,13 +5,13 @@
5
5
  >
6
6
  <span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
7
7
  จำนวน
8
- <span class="font-bold">{{ pageOptions?.totalCount || 0 }}</span>
8
+ <span class="font-bold">{{ pageOptions?.totalCount || rawData.length || 0 }}</span>
9
9
  รายการ
10
10
  </div>
11
11
  <UTable
12
12
  :loading="status.isLoading"
13
13
  :columns="uTableCompatibleColumns"
14
- :rows="rawData"
14
+ :data="rawData"
15
15
  v-bind="$attrs"
16
16
  >
17
17
  <template #loading-state>
@@ -26,47 +26,44 @@
26
26
  <Empty />
27
27
  </template>
28
28
  <template
29
- v-for="column in columns"
30
- #[`${column.accessorKey}-data`]="{ row }"
29
+ v-for="column in columns.filter((item) => !!item.type)"
30
+ #[`${column.accessorKey}-cell`]="{ row }"
31
31
  :key="column.accessorKey"
32
32
  >
33
33
  <component
34
- :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : column.type ? columnTypeComponents[column.type] : void 0"
35
- v-if="column.type === COLUMN_TYPES.COMPONENT || column.type && columnTypeComponents[column.type]"
36
- :value="transformValue(column, row)"
37
- :column="column"
38
- :row="row"
39
- />
40
- <ColumnText
41
- v-else
34
+ :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
35
+ v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
42
36
  :value="transformValue(column, row)"
43
37
  :column="column"
44
38
  :row="row"
45
39
  />
46
40
  </template>
47
-
48
41
  <template
49
- v-for="(_, slotName) in $slots"
50
- #[slotName]="scope"
42
+ v-for="(_, slotName) of $slots"
43
+ #[slotName]="slotProps"
51
44
  >
52
45
  <slot
53
46
  :name="slotName"
54
- v-bind="scope"
47
+ v-bind="slotProps || {}"
55
48
  />
56
49
  </template>
57
50
  </UTable>
58
51
  <div
59
- v-if="pageOptions"
60
- class="mt-4 flex justify-between px-3"
52
+ v-if="!isHidePagination && pageOptions"
53
+ :class="theme.paginationContainer({})"
61
54
  >
62
- <p class="text-sm text-gray-500">
63
- ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
55
+ <p
56
+ :class="theme.paginationInfo({})"
57
+ >
58
+ {{ pageBetween }} รายการ จากทั้งหมด {{ totalCountWithComma }} รายการ
64
59
  </p>
65
60
  <Pagination
66
- v-if="pageOptions.totalPage > 1 && !isHidePagination"
67
- v-model="page"
68
- :page-count="pageOptions.limit"
61
+ v-if="pageOptions.totalPage > 1"
62
+ v-model:page="page"
63
+ :default-page="pageOptions?.currentPage || 1"
64
+ :items-per-page="pageOptions.limit"
69
65
  :total="pageOptions.totalCount"
66
+ @update:page="onPageChange"
70
67
  />
71
68
  </div>
72
69
  </template>
@@ -77,13 +74,21 @@ import { COLUMN_TYPES } from "#core/components/Table/types";
77
74
  import ColumnNumber from "#core/components/Table/ColumnNumber.vue";
78
75
  import ColumnImage from "#core/components/Table/ColumnImage.vue";
79
76
  import { NumberHelper } from "#core/utils/NumberHelper";
80
- import { ref, watch } from "#imports";
77
+ import { ref, useUiConfig, watch } from "#imports";
81
78
  import ColumnDateTime from "#core/components/Table/ColumnDateTime.vue";
82
79
  import Empty from "#core/components/Empty.vue";
83
80
  import ColumnDate from "#core/components/Table/ColumnDate.vue";
84
81
  import ColumnText from "#core/components/Table/ColumnText.vue";
85
82
  import { useWatchChange } from "#core/composables/useWatch";
86
83
  import UTable from "#ui/components/Table";
84
+ import { tableTheme } from "#core/theme/table";
85
+ const columnTypeComponents = {
86
+ [COLUMN_TYPES.NUMBER]: ColumnNumber,
87
+ [COLUMN_TYPES.IMAGE]: ColumnImage,
88
+ [COLUMN_TYPES.DATE_TIME]: ColumnDateTime,
89
+ [COLUMN_TYPES.DATE]: ColumnDate,
90
+ [COLUMN_TYPES.TEXT]: ColumnText
91
+ };
87
92
  const emits = defineEmits(["pageChange"]);
88
93
  const props = defineProps({
89
94
  status: {
@@ -113,6 +118,7 @@ const props = defineProps({
113
118
  }
114
119
  });
115
120
  const page = ref(props.pageOptions?.currentPage || 1);
121
+ const theme = computed(() => useUiConfig(tableTheme, "table")());
116
122
  const uTableCompatibleColumns = computed(
117
123
  () => props.columns.map((col) => ({
118
124
  ...col,
@@ -120,13 +126,6 @@ const uTableCompatibleColumns = computed(
120
126
  // Use accessorKey for UTable's key property
121
127
  }))
122
128
  );
123
- const columnTypeComponents = {
124
- [COLUMN_TYPES.NUMBER]: ColumnNumber,
125
- [COLUMN_TYPES.IMAGE]: ColumnImage,
126
- [COLUMN_TYPES.DATE_TIME]: ColumnDateTime,
127
- [COLUMN_TYPES.DATE]: ColumnDate,
128
- [COLUMN_TYPES.TEXT]: ColumnText
129
- };
130
129
  useWatchChange(
131
130
  () => props.pageOptions?.currentPage,
132
131
  (value) => {
@@ -143,8 +142,9 @@ const pageBetween = computed(() => {
143
142
  return `${start} - ${end}`;
144
143
  });
145
144
  const transformValue = (column, row) => {
146
- const value = row[column.accessorKey];
147
- return column.transform ? column.transform(value, row, column) : value;
145
+ return column.cell ? column.cell({
146
+ row
147
+ }) : row.getValue(column.accessorKey);
148
148
  };
149
149
  const totalCountWithComma = computed(() => {
150
150
  return !props.pageOptions?.totalCount ? "0" : NumberHelper.withComma(props.pageOptions.totalCount);
@@ -1,8 +1,8 @@
1
1
  import { type PropType } from 'vue';
2
2
  import { type ITableOptions } from '#core/components/Table/types';
3
- declare var __VLS_29: string | number, __VLS_30: any;
3
+ declare var __VLS_25: string | number, __VLS_26: any;
4
4
  type __VLS_Slots = {} & {
5
- [K in NonNullable<typeof __VLS_29>]?: (props: typeof __VLS_30) => any;
5
+ [K in NonNullable<typeof __VLS_25>]?: (props: typeof __VLS_26) => any;
6
6
  };
7
7
  declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
8
  status: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.31.2",
3
+ "version": "2.32.0",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",