@finema/core 2.49.1 → 2.51.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 (39) 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/InputMonth/index.vue +51 -51
  8. package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
  9. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +43 -43
  10. package/dist/runtime/components/Form/InputTags/index.vue +23 -23
  11. package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
  12. package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
  13. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +30 -30
  14. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +50 -50
  15. package/dist/runtime/components/Form/fileState/EmptyState.vue +21 -21
  16. package/dist/runtime/components/Form/fileState/FailedState.vue +33 -33
  17. package/dist/runtime/components/Form/fileState/LoadingState.vue +24 -24
  18. package/dist/runtime/components/Form/fileState/PreviewModal.vue +23 -23
  19. package/dist/runtime/components/Form/index.vue +5 -5
  20. package/dist/runtime/components/Image.vue +28 -28
  21. package/dist/runtime/components/Log/index.vue +17 -17
  22. package/dist/runtime/components/Table/Base.vue +113 -113
  23. package/dist/runtime/components/Table/Base.vue.d.ts +19 -60
  24. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  25. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  26. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  27. package/dist/runtime/components/Table/ColumnText.vue +1 -1
  28. package/dist/runtime/components/Table/Pagination.vue +131 -0
  29. package/dist/runtime/components/Table/Pagination.vue.d.ts +18 -0
  30. package/dist/runtime/components/Table/Simple.vue +7 -9
  31. package/dist/runtime/components/Table/Simple.vue.d.ts +10 -15
  32. package/dist/runtime/components/Table/index.vue +11 -138
  33. package/dist/runtime/components/Table/types.d.ts +3 -0
  34. package/dist/runtime/server/tsconfig.json +3 -3
  35. package/dist/runtime/theme/pagination.d.ts +2 -0
  36. package/dist/runtime/theme/pagination.js +6 -4
  37. package/dist/runtime/theme/table.d.ts +4 -0
  38. package/dist/runtime/theme/table.js +9 -5
  39. package/package.json +3 -3
@@ -12,172 +12,45 @@
12
12
  :placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
13
13
  />
14
14
  </div>
15
- <UTable
15
+ <Base
16
16
  v-bind="$attrs"
17
- :loading="options.status.isLoading"
18
- :data="options.rawData"
19
- :columns="options.columns"
20
- :ui="ui"
17
+ :options="options"
18
+ @page-change="onPageChange"
19
+ @search="emits('search', q)"
21
20
  >
22
- <template #empty>
23
- <slot
24
- v-if="options.status.isLoading"
25
- name="loading"
26
- >
27
- <Loader
28
- :loading="true"
29
- />
30
- </slot>
31
- <slot
32
- v-else-if="options.status.isError"
33
- name="error"
34
- >
35
- <div
36
- class="
37
- text-error-400 flex h-[200px] items-center justify-center text-2xl
38
- "
39
- >
40
- {{ StringHelper.getError(options.status.errorData) }}
41
- </div>
42
- </slot>
43
-
44
- <slot
45
- v-else
46
- name="error"
47
- >
48
- <Empty />
49
- </slot>
50
- </template>
51
- <template
52
- v-for="column in options.columns.filter((item) => !!item.type)"
53
- #[`${column.accessorKey}-cell`]="{ row }"
54
- :key="column.accessorKey"
55
- >
56
- <component
57
- :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
58
- v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
59
- :value="transformValue(column, row)"
60
- :column="column"
61
- :row="row"
62
- />
63
- </template>
64
21
  <template
65
- v-for="(_, slotName) of $slots"
66
- #[slotName]="slotProps"
22
+ v-for="(_, slot) of $slots"
23
+ #[slot]="slotProps"
67
24
  >
68
25
  <slot
69
- :name="slotName"
26
+ :name="slot"
70
27
  v-bind="slotProps || {}"
71
28
  />
72
29
  </template>
73
- </UTable>
74
-
75
- <div
76
- v-if="!options.isHidePagination"
77
- :class="theme.paginationContainer({
78
- class: [ui?.paginationContainer]
79
- })"
80
- >
81
- <p
82
- :class="theme.paginationInfo({
83
- class: [ui?.paginationInfo]
84
- })"
85
- >
86
- {{ pageBetween }} รายการ จากทั้งหมด {{ totalCountWithComma }} รายการ
87
- </p>
88
- <Pagination
89
- v-if="options.pageOptions.totalPage > 1"
90
- v-model:page="page"
91
- :default-page="options.pageOptions?.currentPage || 1"
92
- :items-per-page="options.pageOptions.limit"
93
- :total="options.pageOptions.totalCount"
94
- :to="options.isRouteChange ? to : void 0"
95
- @update:page="onPageChange"
96
- />
97
- </div>
30
+ </Base>
98
31
  </div>
99
32
  </template>
100
33
 
101
34
  <script setup>
102
35
  import { computed } from "vue";
103
- import { COLUMN_TYPES } from "#core/components/Table/types";
104
- import { _debounce, ref, useUiConfig, watch, useWatchChange, useRouter } from "#imports";
105
- import { NumberHelper } from "#core/utils/NumberHelper";
106
- import ColumnDate from "#core/components/Table/ColumnDate.vue";
107
- import ColumnDateTime from "#core/components/Table/ColumnDateTime.vue";
108
- import ColumnImage from "#core/components/Table/ColumnImage.vue";
109
- import ColumnText from "#core/components/Table/ColumnText.vue";
110
- import ColumnNumber from "#core/components/Table/ColumnNumber.vue";
36
+ import { _debounce, ref, useUiConfig, watch } from "#imports";
111
37
  import { tableTheme } from "#core/theme/table";
112
- import UTable from "#ui/components/Table";
38
+ import Base from "#core/components/Table/Base.vue";
113
39
  const emits = defineEmits(["pageChange", "search"]);
114
40
  const props = defineProps({
115
41
  options: { type: Object, required: true },
116
42
  ui: { type: null, required: false }
117
43
  });
118
44
  defineSlots();
119
- const columnTypeComponents = {
120
- [COLUMN_TYPES.NUMBER]: ColumnNumber,
121
- [COLUMN_TYPES.IMAGE]: ColumnImage,
122
- [COLUMN_TYPES.DATE_TIME]: ColumnDateTime,
123
- [COLUMN_TYPES.DATE]: ColumnDate,
124
- [COLUMN_TYPES.TEXT]: ColumnText
125
- };
126
- const page = ref(props.options?.pageOptions?.currentPage || 1);
127
45
  const tableContainer = ref();
128
- const router = useRouter();
129
- const theme = computed(() => useUiConfig(tableTheme, "table")());
130
46
  const q = ref(props.options?.pageOptions.search ?? "");
131
- const to = (page2) => {
132
- const params = props.options?.pageOptions?.request?.params || {};
133
- const cleanParams = Object.fromEntries(
134
- Object.entries(params).filter(
135
- ([key, value]) => value !== null && value !== void 0 && value !== ""
136
- )
137
- );
138
- return {
139
- query: {
140
- ...cleanParams,
141
- page: page2
142
- }
143
- };
144
- };
47
+ const theme = computed(() => useUiConfig(tableTheme, "table")());
145
48
  watch(
146
49
  q,
147
50
  _debounce((value) => {
148
51
  emits("search", value);
149
52
  }, 500)
150
53
  );
151
- useWatchChange(() => props.options?.pageOptions?.currentPage, (value) => {
152
- page.value = value;
153
- });
154
- const pageBetween = computed(() => {
155
- const rawDataLength = props.options.rawData?.length;
156
- const pageOpts = props.options.pageOptions;
157
- if (!rawDataLength || !pageOpts) {
158
- return "0";
159
- }
160
- const currentPage = pageOpts.currentPage || 1;
161
- const limit = pageOpts.limit;
162
- if (limit <= 0) {
163
- return "0";
164
- }
165
- const start = (currentPage - 1) * limit + 1;
166
- const end = start + rawDataLength - 1;
167
- return `${start} - ${end}`;
168
- });
169
- const totalCountWithComma = computed(() => {
170
- const total = props.options.pageOptions?.totalCount;
171
- if (!total || total <= 0) {
172
- return "0";
173
- }
174
- return NumberHelper.withComma(total);
175
- });
176
- const transformValue = (column, row) => {
177
- return column.cell ? column.cell({
178
- row
179
- }) : row.getValue(column.accessorKey);
180
- };
181
54
  const onPageChange = (newPage) => {
182
55
  if (tableContainer.value) {
183
56
  const rect = tableContainer.value.getBoundingClientRect();
@@ -20,6 +20,9 @@ export interface IBaseTableOptions<T extends Record<string, any> = Record<string
20
20
  status: IStatus;
21
21
  columns: TableColumn<T>[];
22
22
  isHidePagination?: boolean;
23
+ isHidePaginationTop?: boolean;
24
+ isHidePaginationBottom?: boolean;
25
+ isHideLimitSelect?: boolean;
23
26
  isHideCaption?: boolean;
24
27
  }
25
28
  export interface ITableOptions<T extends Record<string, any> = Record<string, any>> extends IBaseTableOptions<T> {
@@ -1,3 +1,3 @@
1
- {
2
- "extends": "../../../.nuxt/tsconfig.server.json",
3
- }
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json",
3
+ }
@@ -4,5 +4,7 @@ export declare const paginationTheme: {
4
4
  prev: string;
5
5
  next: string;
6
6
  last: string;
7
+ item: string;
8
+ ellipsis: string;
7
9
  };
8
10
  };
@@ -1,8 +1,10 @@
1
1
  export const paginationTheme = {
2
2
  slots: {
3
- first: "disabled:hidden",
4
- prev: "disabled:hidden",
5
- next: "disabled:hidden",
6
- last: "disabled:hidden"
3
+ first: "hidden",
4
+ prev: "",
5
+ next: "",
6
+ last: "hidden",
7
+ item: "max-sm:!hidden",
8
+ ellipsis: "max-sm:!hidden"
7
9
  }
8
10
  };
@@ -1,12 +1,16 @@
1
1
  export declare const tableTheme: {
2
2
  slots: {
3
3
  root: string;
4
+ rootWrapper: string;
4
5
  searchContainer: string;
5
6
  captionContainer: string;
6
7
  captionBoldText: string;
7
8
  errorMessage: string;
8
9
  paginationContainer: string;
10
+ paginationInfoWrapper: string;
9
11
  paginationInfo: string;
12
+ paginationLimitSelect: string;
13
+ paginationLimitSelectLabel: string;
10
14
  thead: string;
11
15
  th: string;
12
16
  td: string;
@@ -1,15 +1,19 @@
1
1
  export const tableTheme = {
2
2
  slots: {
3
- root: "rounded-t-md rounded-b-md bg-white",
3
+ root: "bg-white",
4
+ rootWrapper: "rounded-t-lg rounded-b-lg border-1 border-[#EAECF0]",
4
5
  searchContainer: "mb-4 flex justify-end",
5
6
  captionContainer: "hidden mb-4 text-gray-500",
6
7
  captionBoldText: "font-bold",
7
8
  errorMessage: "text-error-400 text-2xl h-[200px] flex justify-center items-center",
8
- paginationContainer: "mt-4 flex justify-between px-3 items-center flex-col lg:flex-row gap-4",
9
- paginationInfo: "text-sm text-gray-600",
9
+ paginationContainer: "flex justify-between items-center flex-row md:flex-col lg:flex-row gap-4 px-4 py-3 bg-[#F2F4F7]",
10
+ paginationInfoWrapper: "flex items-center justify-between gap-4",
11
+ paginationInfo: "text-sm font-bold text-gray-600",
12
+ paginationLimitSelect: "max-sm:!hidden min-w-[120px]",
13
+ paginationLimitSelectLabel: "font-bold text-gray-600",
10
14
  thead: "bg-primary",
11
- th: "text-[#222222] bg-white whitespace-nowrap",
12
- td: "text-[#222222]"
15
+ th: "text-[#475467] bg-white whitespace-nowrap font-medium text-xs",
16
+ td: "text-[#475467]"
13
17
  },
14
18
  variants: {
15
19
  pinned: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.49.1",
3
+ "version": "2.51.0",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "scripts": {
30
30
  "prepack": "nuxt-module-build build",
31
- "dev": "nuxi dev playground -o",
31
+ "dev": "bun run dev:prepare && nuxi dev playground -o",
32
32
  "dev:build": "nuxi build playground",
33
33
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
34
34
  "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@eslint/js": "^9.26.0",
75
- "@finema/eslint-config": "^2.0.3",
75
+ "@finema/eslint-config": "^2.0.4",
76
76
  "@nuxt/devtools": "^2.6.0",
77
77
  "@nuxt/eslint-config": "^1.4.1",
78
78
  "@nuxt/module-builder": "^1.0.2",