@finema/core 1.4.217 → 1.4.218

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 (67) hide show
  1. package/README.md +60 -60
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1 -1
  4. package/dist/runtime/components/Alert.vue +48 -48
  5. package/dist/runtime/components/Avatar.vue +27 -27
  6. package/dist/runtime/components/Badge.vue +11 -11
  7. package/dist/runtime/components/Breadcrumb.vue +44 -44
  8. package/dist/runtime/components/Button/Group.vue +37 -37
  9. package/dist/runtime/components/Button/index.vue +75 -75
  10. package/dist/runtime/components/Card.vue +38 -38
  11. package/dist/runtime/components/Core.vue +45 -45
  12. package/dist/runtime/components/Dialog/index.vue +108 -108
  13. package/dist/runtime/components/Dropdown/index.vue +70 -70
  14. package/dist/runtime/components/Empty.vue +18 -18
  15. package/dist/runtime/components/FlexDeck/Base.vue +159 -159
  16. package/dist/runtime/components/FlexDeck/index.vue +68 -68
  17. package/dist/runtime/components/Form/FieldWrapper.vue +23 -23
  18. package/dist/runtime/components/Form/Fields.vue +230 -230
  19. package/dist/runtime/components/Form/InputCheckbox/index.vue +28 -28
  20. package/dist/runtime/components/Form/InputDateTime/index.vue +68 -68
  21. package/dist/runtime/components/Form/InputDateTimeRange/index.vue +91 -91
  22. package/dist/runtime/components/Form/InputNumber/index.vue +27 -27
  23. package/dist/runtime/components/Form/InputRadio/index.vue +27 -27
  24. package/dist/runtime/components/Form/InputSelect/index.vue +55 -55
  25. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +54 -54
  26. package/dist/runtime/components/Form/InputStatic/index.vue +16 -16
  27. package/dist/runtime/components/Form/InputTags/index.vue +141 -141
  28. package/dist/runtime/components/Form/InputText/index.vue +68 -68
  29. package/dist/runtime/components/Form/InputTextarea/index.vue +25 -25
  30. package/dist/runtime/components/Form/InputToggle/index.vue +27 -27
  31. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +206 -206
  32. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +362 -350
  33. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/ItemUpload.vue +241 -241
  34. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/ItemView.vue +110 -102
  35. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +171 -171
  36. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/ItemUpload.vue +161 -161
  37. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/ItemView.vue +64 -64
  38. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/index.vue +178 -178
  39. package/dist/runtime/components/Form/InputUploadFileClassic/index.vue +95 -95
  40. package/dist/runtime/components/Form/InputUploadFileClassicAuto/index.vue +151 -151
  41. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +219 -219
  42. package/dist/runtime/components/Form/InputWYSIWYG/UploadImageForm.vue +55 -55
  43. package/dist/runtime/components/Form/InputWYSIWYG/index.vue +228 -228
  44. package/dist/runtime/components/Form/index.vue +6 -6
  45. package/dist/runtime/components/Icon.vue +23 -23
  46. package/dist/runtime/components/Image.vue +36 -36
  47. package/dist/runtime/components/Loader.vue +27 -27
  48. package/dist/runtime/components/Log.vue +22 -22
  49. package/dist/runtime/components/LogItem.vue +41 -41
  50. package/dist/runtime/components/Modal/index.vue +146 -146
  51. package/dist/runtime/components/OTPInput.vue +127 -127
  52. package/dist/runtime/components/QRCode.vue +22 -22
  53. package/dist/runtime/components/SimplePagination.vue +96 -96
  54. package/dist/runtime/components/Slideover/index.vue +110 -110
  55. package/dist/runtime/components/Table/Base.vue +161 -161
  56. package/dist/runtime/components/Table/ColumnDate.vue +16 -16
  57. package/dist/runtime/components/Table/ColumnDateTime.vue +18 -18
  58. package/dist/runtime/components/Table/ColumnImage.vue +15 -15
  59. package/dist/runtime/components/Table/ColumnNumber.vue +14 -14
  60. package/dist/runtime/components/Table/ColumnText.vue +29 -29
  61. package/dist/runtime/components/Table/Simple.vue +70 -70
  62. package/dist/runtime/components/Table/index.vue +65 -65
  63. package/dist/runtime/components/Tabs/index.vue +64 -64
  64. package/dist/runtime/components/TeleportSafe.vue +40 -40
  65. package/dist/runtime/helpers/componentHelper.d.ts +1 -0
  66. package/dist/runtime/helpers/componentHelper.mjs +5 -0
  67. package/package.json +100 -100
@@ -1,161 +1,161 @@
1
- <template>
2
- <div v-if="!isHideCaption || !isHideBottomPagination" class="mb-4 text-gray-500">
3
- <span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
4
- จำนวน
5
- <span class="font-bold">{{ pageOptions?.totalCount || 0 }}</span>
6
- รายการ
7
- </div>
8
- <UTable :loading="status.isLoading" :columns="columns" :rows="rawData" v-bind="$attrs">
9
- <template #loading-state>
10
- <div class="flex h-60 items-center justify-center">
11
- <Icon name="i-svg-spinners:180-ring-with-bg" class="text-primary size-8" />
12
- </div>
13
- </template>
14
- <template #empty-state>
15
- <Empty />
16
- </template>
17
- <template v-for="column in columns" #[`${column.key}-data`]="{ row }" :key="column.key">
18
- <ColumnNumber
19
- v-if="column.type === COLUMN_TYPES.NUMBER"
20
- :value="transformValue(column, row)"
21
- :column="column"
22
- :class="column.class"
23
- :row="row"
24
- />
25
- <ColumnImage
26
- v-else-if="column.type === COLUMN_TYPES.IMAGE"
27
- :value="transformValue(column, row)"
28
- :column="column"
29
- :class="column.class"
30
- :row="row"
31
- />
32
- <ColumnDateTime
33
- v-else-if="column.type === COLUMN_TYPES.DATE_TIME"
34
- :value="transformValue(column, row)"
35
- :column="column"
36
- :class="column.class"
37
- :row="row"
38
- />
39
- <ColumnDate
40
- v-else-if="column.type === COLUMN_TYPES.DATE"
41
- :value="transformValue(column, row)"
42
- :column="column"
43
- :class="column.class"
44
- :row="row"
45
- />
46
- <component
47
- :is="column.component"
48
- v-else-if="column.type === COLUMN_TYPES.COMPONENT"
49
- :value="transformValue(column, row)"
50
- :column="column"
51
- :class="column.class"
52
- :row="row"
53
- />
54
- <ColumnText v-else :value="transformValue(column, row)" :column="column" :row="row" />
55
- </template>
56
-
57
- <template v-for="(_, slot) of $slots" #[slot]="scope">
58
- <slot :name="slot" v-bind="scope" />
59
- </template>
60
- </UTable>
61
- <div v-if="pageOptions" class="mt-4 flex justify-between px-3">
62
- <p class="text-sm text-gray-500">
63
- ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
64
- </p>
65
- <UPagination
66
- v-if="pageOptions.totalPage > 1 && !isSimplePagination && !isHideBottomPagination"
67
- v-model="page"
68
- :page-count="pageOptions.limit"
69
- :total="pageOptions.totalCount"
70
- />
71
- <SimplePagination
72
- v-if="pageOptions.totalPage > 1 && isSimplePagination"
73
- v-model="page"
74
- :page-count="pageOptions.limit"
75
- :total="pageOptions.totalCount"
76
- />
77
- </div>
78
- </template>
79
-
80
- <script lang="ts" setup>
81
- import { COLUMN_TYPES, type IColumn, type ITableOptions } from '#core/components/Table/types'
82
- import ColumnNumber from '#core/components/Table/ColumnNumber.vue'
83
- import ColumnImage from '#core/components/Table/ColumnImage.vue'
84
- import { computed, type PropType } from 'vue'
85
- import { StringHelper } from '#core/utils/StringHelper'
86
- import { ref, watch } from '#imports'
87
- import ColumnDateTime from '#core/components/Table/ColumnDateTime.vue'
88
- import Empty from '#core/components/Empty.vue'
89
- import ColumnDate from '#core/components/Table/ColumnDate.vue'
90
- import ColumnText from '#core/components/Table/ColumnText.vue'
91
- import { useWatchChange } from '#core/composables/useWatch'
92
-
93
- const emits = defineEmits(['pageChange'])
94
-
95
- const props = defineProps({
96
- status: {
97
- type: Object as PropType<ITableOptions['status']>,
98
- required: true,
99
- },
100
- pageOptions: {
101
- type: Object as PropType<ITableOptions['pageOptions']>,
102
- required: false,
103
- },
104
- columns: {
105
- type: Array as PropType<ITableOptions['columns']>,
106
- required: true,
107
- },
108
- rawData: {
109
- type: Array as PropType<ITableOptions['rawData']>,
110
- required: true,
111
- },
112
- isSimplePagination: {
113
- type: Boolean as PropType<ITableOptions['isSimplePagination']>,
114
- default: false,
115
- },
116
- isHideBottomPagination: {
117
- type: Boolean as PropType<ITableOptions['isHideBottomPagination']>,
118
- default: false,
119
- },
120
- isHideCaption: {
121
- type: Boolean as PropType<ITableOptions['isHideCaption']>,
122
- default: false,
123
- },
124
- })
125
-
126
- const page = ref(props.pageOptions?.currentPage || 1)
127
-
128
- useWatchChange(
129
- () => props.pageOptions?.currentPage,
130
- (value: number) => {
131
- page.value = value
132
- }
133
- )
134
-
135
- const pageBetween = computed((): string => {
136
- const length = props.rawData?.length
137
-
138
- if (length === 0) {
139
- return '0'
140
- }
141
-
142
- const start = (props.pageOptions!.currentPage - 1) * props.pageOptions!.limit + 1
143
- const end = start + length - 1
144
-
145
- return `${start} - ${end}`
146
- })
147
-
148
- const transformValue = (column: IColumn, row: any) => {
149
- return column.transform ? column.transform(row[column.key], row, column) : row[column.key]
150
- }
151
-
152
- const totalCountWithComma = computed((): string => {
153
- return !props.pageOptions!.totalCount
154
- ? '0'
155
- : StringHelper.withComma(props.pageOptions!.totalCount)
156
- })
157
-
158
- watch(page, () => {
159
- emits('pageChange', page.value)
160
- })
161
- </script>
1
+ <template>
2
+ <div v-if="!isHideCaption || !isHideBottomPagination" class="mb-4 text-gray-500">
3
+ <span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
4
+ จำนวน
5
+ <span class="font-bold">{{ pageOptions?.totalCount || 0 }}</span>
6
+ รายการ
7
+ </div>
8
+ <UTable :loading="status.isLoading" :columns="columns" :rows="rawData" v-bind="$attrs">
9
+ <template #loading-state>
10
+ <div class="flex h-60 items-center justify-center">
11
+ <Icon name="i-svg-spinners:180-ring-with-bg" class="text-primary size-8" />
12
+ </div>
13
+ </template>
14
+ <template #empty-state>
15
+ <Empty />
16
+ </template>
17
+ <template v-for="column in columns" #[`${column.key}-data`]="{ row }" :key="column.key">
18
+ <ColumnNumber
19
+ v-if="column.type === COLUMN_TYPES.NUMBER"
20
+ :value="transformValue(column, row)"
21
+ :column="column"
22
+ :class="column.class"
23
+ :row="row"
24
+ />
25
+ <ColumnImage
26
+ v-else-if="column.type === COLUMN_TYPES.IMAGE"
27
+ :value="transformValue(column, row)"
28
+ :column="column"
29
+ :class="column.class"
30
+ :row="row"
31
+ />
32
+ <ColumnDateTime
33
+ v-else-if="column.type === COLUMN_TYPES.DATE_TIME"
34
+ :value="transformValue(column, row)"
35
+ :column="column"
36
+ :class="column.class"
37
+ :row="row"
38
+ />
39
+ <ColumnDate
40
+ v-else-if="column.type === COLUMN_TYPES.DATE"
41
+ :value="transformValue(column, row)"
42
+ :column="column"
43
+ :class="column.class"
44
+ :row="row"
45
+ />
46
+ <component
47
+ :is="column.component"
48
+ v-else-if="column.type === COLUMN_TYPES.COMPONENT"
49
+ :value="transformValue(column, row)"
50
+ :column="column"
51
+ :class="column.class"
52
+ :row="row"
53
+ />
54
+ <ColumnText v-else :value="transformValue(column, row)" :column="column" :row="row" />
55
+ </template>
56
+
57
+ <template v-for="(_, slot) of $slots" #[slot]="scope">
58
+ <slot :name="slot" v-bind="scope" />
59
+ </template>
60
+ </UTable>
61
+ <div v-if="pageOptions" class="mt-4 flex justify-between px-3">
62
+ <p class="text-sm text-gray-500">
63
+ ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
64
+ </p>
65
+ <UPagination
66
+ v-if="pageOptions.totalPage > 1 && !isSimplePagination && !isHideBottomPagination"
67
+ v-model="page"
68
+ :page-count="pageOptions.limit"
69
+ :total="pageOptions.totalCount"
70
+ />
71
+ <SimplePagination
72
+ v-if="pageOptions.totalPage > 1 && isSimplePagination"
73
+ v-model="page"
74
+ :page-count="pageOptions.limit"
75
+ :total="pageOptions.totalCount"
76
+ />
77
+ </div>
78
+ </template>
79
+
80
+ <script lang="ts" setup>
81
+ import { COLUMN_TYPES, type IColumn, type ITableOptions } from '#core/components/Table/types'
82
+ import ColumnNumber from '#core/components/Table/ColumnNumber.vue'
83
+ import ColumnImage from '#core/components/Table/ColumnImage.vue'
84
+ import { computed, type PropType } from 'vue'
85
+ import { StringHelper } from '#core/utils/StringHelper'
86
+ import { ref, watch } from '#imports'
87
+ import ColumnDateTime from '#core/components/Table/ColumnDateTime.vue'
88
+ import Empty from '#core/components/Empty.vue'
89
+ import ColumnDate from '#core/components/Table/ColumnDate.vue'
90
+ import ColumnText from '#core/components/Table/ColumnText.vue'
91
+ import { useWatchChange } from '#core/composables/useWatch'
92
+
93
+ const emits = defineEmits(['pageChange'])
94
+
95
+ const props = defineProps({
96
+ status: {
97
+ type: Object as PropType<ITableOptions['status']>,
98
+ required: true,
99
+ },
100
+ pageOptions: {
101
+ type: Object as PropType<ITableOptions['pageOptions']>,
102
+ required: false,
103
+ },
104
+ columns: {
105
+ type: Array as PropType<ITableOptions['columns']>,
106
+ required: true,
107
+ },
108
+ rawData: {
109
+ type: Array as PropType<ITableOptions['rawData']>,
110
+ required: true,
111
+ },
112
+ isSimplePagination: {
113
+ type: Boolean as PropType<ITableOptions['isSimplePagination']>,
114
+ default: false,
115
+ },
116
+ isHideBottomPagination: {
117
+ type: Boolean as PropType<ITableOptions['isHideBottomPagination']>,
118
+ default: false,
119
+ },
120
+ isHideCaption: {
121
+ type: Boolean as PropType<ITableOptions['isHideCaption']>,
122
+ default: false,
123
+ },
124
+ })
125
+
126
+ const page = ref(props.pageOptions?.currentPage || 1)
127
+
128
+ useWatchChange(
129
+ () => props.pageOptions?.currentPage,
130
+ (value: number) => {
131
+ page.value = value
132
+ }
133
+ )
134
+
135
+ const pageBetween = computed((): string => {
136
+ const length = props.rawData?.length
137
+
138
+ if (length === 0) {
139
+ return '0'
140
+ }
141
+
142
+ const start = (props.pageOptions!.currentPage - 1) * props.pageOptions!.limit + 1
143
+ const end = start + length - 1
144
+
145
+ return `${start} - ${end}`
146
+ })
147
+
148
+ const transformValue = (column: IColumn, row: any) => {
149
+ return column.transform ? column.transform(row[column.key], row, column) : row[column.key]
150
+ }
151
+
152
+ const totalCountWithComma = computed((): string => {
153
+ return !props.pageOptions!.totalCount
154
+ ? '0'
155
+ : StringHelper.withComma(props.pageOptions!.totalCount)
156
+ })
157
+
158
+ watch(page, () => {
159
+ emits('pageChange', page.value)
160
+ })
161
+ </script>
@@ -1,16 +1,16 @@
1
- <template>
2
- {{ getValue || '-' }}
3
- </template>
4
- <script lang="ts" setup>
5
- import { computed } from 'vue'
6
- import { type IColumn } from '#core/components/Table/types'
7
- import { TimeHelper } from '#core/utils/TimeHelper'
8
-
9
- const props = defineProps<{
10
- value: any
11
- row: any
12
- column: IColumn
13
- }>()
14
-
15
- const getValue = computed<string>(() => TimeHelper.displayDate(props.value))
16
- </script>
1
+ <template>
2
+ {{ getValue || '-' }}
3
+ </template>
4
+ <script lang="ts" setup>
5
+ import { computed } from 'vue'
6
+ import { type IColumn } from '#core/components/Table/types'
7
+ import { TimeHelper } from '#core/utils/TimeHelper'
8
+
9
+ const props = defineProps<{
10
+ value: any
11
+ row: any
12
+ column: IColumn
13
+ }>()
14
+
15
+ const getValue = computed<string>(() => TimeHelper.displayDate(props.value))
16
+ </script>
@@ -1,18 +1,18 @@
1
- <template>
2
- {{ getValue || '-' }}
3
- </template>
4
- <script lang="ts" setup>
5
- import { computed } from 'vue'
6
- import { type IColumn } from '#core/components/Table/types'
7
- import { TimeHelper } from '#core/utils/TimeHelper'
8
-
9
- const props = defineProps<{
10
- value: any
11
- row: any
12
- column: IColumn
13
- }>()
14
-
15
- const getValue = computed(() => {
16
- return TimeHelper.displayDateTime(props.value)
17
- })
18
- </script>
1
+ <template>
2
+ {{ getValue || '-' }}
3
+ </template>
4
+ <script lang="ts" setup>
5
+ import { computed } from 'vue'
6
+ import { type IColumn } from '#core/components/Table/types'
7
+ import { TimeHelper } from '#core/utils/TimeHelper'
8
+
9
+ const props = defineProps<{
10
+ value: any
11
+ row: any
12
+ column: IColumn
13
+ }>()
14
+
15
+ const getValue = computed(() => {
16
+ return TimeHelper.displayDateTime(props.value)
17
+ })
18
+ </script>
@@ -1,15 +1,15 @@
1
- <template>
2
- <Image class="h-12" :src="getValue" />
3
- </template>
4
- <script lang="ts" setup>
5
- import { computed } from 'vue'
6
- import { type IColumn } from '#core/components/Table/types'
7
-
8
- const props = defineProps<{
9
- value: any
10
- row: any
11
- column: IColumn
12
- }>()
13
-
14
- const getValue = computed(() => props.value)
15
- </script>
1
+ <template>
2
+ <Image class="h-12" :src="getValue" />
3
+ </template>
4
+ <script lang="ts" setup>
5
+ import { computed } from 'vue'
6
+ import { type IColumn } from '#core/components/Table/types'
7
+
8
+ const props = defineProps<{
9
+ value: any
10
+ row: any
11
+ column: IColumn
12
+ }>()
13
+
14
+ const getValue = computed(() => props.value)
15
+ </script>
@@ -1,14 +1,14 @@
1
- <template>{{ getValue }}</template>
2
- <script lang="ts" setup>
3
- import { StringHelper } from '../../utils/StringHelper'
4
- import { computed } from 'vue'
5
- import { type IColumn } from '#core/components/Table/types'
6
-
7
- const props = defineProps<{
8
- value: any
9
- row: any
10
- column: IColumn
11
- }>()
12
-
13
- const getValue = computed(() => StringHelper.withComma(props.value))
14
- </script>
1
+ <template>{{ getValue }}</template>
2
+ <script lang="ts" setup>
3
+ import { StringHelper } from '../../utils/StringHelper'
4
+ import { computed } from 'vue'
5
+ import { type IColumn } from '#core/components/Table/types'
6
+
7
+ const props = defineProps<{
8
+ value: any
9
+ row: any
10
+ column: IColumn
11
+ }>()
12
+
13
+ const getValue = computed(() => StringHelper.withComma(props.value))
14
+ </script>
@@ -1,29 +1,29 @@
1
- <template>{{ getValue }}</template>
2
- <script lang="ts" setup>
3
- import { computed } from 'vue'
4
- import { type IColumn } from '#core/components/Table/types'
5
- import { StringHelper } from '#imports'
6
-
7
- const props = defineProps<{
8
- value: any
9
- row: any
10
- column: IColumn<{
11
- max?: number
12
- }>
13
- }>()
14
-
15
- const getValue = computed<string>(() => {
16
- const value = props.value
17
- const max = props.column.props?.max
18
-
19
- if (max) {
20
- return StringHelper.truncate(value, max)
21
- }
22
-
23
- if (typeof value === 'string') {
24
- return value || '-'
25
- }
26
-
27
- return value ?? '-'
28
- })
29
- </script>
1
+ <template>{{ getValue }}</template>
2
+ <script lang="ts" setup>
3
+ import { computed } from 'vue'
4
+ import { type IColumn } from '#core/components/Table/types'
5
+ import { StringHelper } from '#imports'
6
+
7
+ const props = defineProps<{
8
+ value: any
9
+ row: any
10
+ column: IColumn<{
11
+ max?: number
12
+ }>
13
+ }>()
14
+
15
+ const getValue = computed<string>(() => {
16
+ const value = props.value
17
+ const max = props.column.props?.max
18
+
19
+ if (max) {
20
+ return StringHelper.truncate(value, max)
21
+ }
22
+
23
+ if (typeof value === 'string') {
24
+ return value || '-'
25
+ }
26
+
27
+ return value ?? '-'
28
+ })
29
+ </script>
@@ -1,70 +1,70 @@
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-simple-pagination="isShowSimplePagination"
9
- :is-hide-bottom-pagination="options.isHideBottomPagination"
10
- :is-hide-caption="options.isHideCaption"
11
- @page-change="onPageChange"
12
- >
13
- <template v-for="(_, slot) of $slots" #[slot]="slotProps">
14
- <slot :name="slot" v-bind="slotProps || {}" />
15
- </template>
16
- </Base>
17
- </template>
18
- <script lang="ts" setup>
19
- import { computed, type PropType, ref } from 'vue'
20
- import { type ISimpleTableOptions } from '#core/components/Table/types'
21
- import Base from '#core/components/Table/Base.vue'
22
- import { initPageOptions } from '#core/composables/loaderPage'
23
- import { useCoreConfig } from '#core/composables/useConfig'
24
-
25
- defineSlots<{
26
- 'empty-state': () => any
27
- 'loading-state': () => any
28
- }>()
29
-
30
- const props = defineProps({
31
- options: { type: Object as PropType<ISimpleTableOptions>, required: true },
32
- })
33
-
34
- const currentPage = ref(1)
35
- const coreConfig = useCoreConfig()
36
- const isShowSimplePagination = computed(
37
- (): boolean => props.options.isSimplePagination ?? coreConfig.is_simple_pagination
38
- )
39
-
40
- const pageOptions = computed(() => {
41
- if (!props.options?.limit) {
42
- return undefined
43
- }
44
-
45
- return {
46
- ...initPageOptions({
47
- limit: props.options.limit,
48
- primary: props.options.primary,
49
- }),
50
- totalCount: props.options.rawData.length,
51
- totalPage: Math.ceil(props.options.rawData.length / props.options.limit),
52
- currentPage: currentPage.value,
53
- }
54
- })
55
-
56
- const onPageChange = (page: number) => {
57
- currentPage.value = page
58
- }
59
-
60
- const itemsByPage = computed(() => {
61
- if (!pageOptions.value) {
62
- return props.options?.rawData
63
- }
64
-
65
- const start = (pageOptions.value.currentPage - 1) * pageOptions.value.limit
66
- const end = start + pageOptions.value.limit
67
-
68
- return props.options?.rawData.slice(start, end)
69
- })
70
- </script>
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-simple-pagination="isShowSimplePagination"
9
+ :is-hide-bottom-pagination="options.isHideBottomPagination"
10
+ :is-hide-caption="options.isHideCaption"
11
+ @page-change="onPageChange"
12
+ >
13
+ <template v-for="(_, slot) of $slots" #[slot]="slotProps">
14
+ <slot :name="slot" v-bind="slotProps || {}" />
15
+ </template>
16
+ </Base>
17
+ </template>
18
+ <script lang="ts" setup>
19
+ import { computed, type PropType, ref } from 'vue'
20
+ import { type ISimpleTableOptions } from '#core/components/Table/types'
21
+ import Base from '#core/components/Table/Base.vue'
22
+ import { initPageOptions } from '#core/composables/loaderPage'
23
+ import { useCoreConfig } from '#core/composables/useConfig'
24
+
25
+ defineSlots<{
26
+ 'empty-state': () => any
27
+ 'loading-state': () => any
28
+ }>()
29
+
30
+ const props = defineProps({
31
+ options: { type: Object as PropType<ISimpleTableOptions>, required: true },
32
+ })
33
+
34
+ const currentPage = ref(1)
35
+ const coreConfig = useCoreConfig()
36
+ const isShowSimplePagination = computed(
37
+ (): boolean => props.options.isSimplePagination ?? coreConfig.is_simple_pagination
38
+ )
39
+
40
+ const pageOptions = computed(() => {
41
+ if (!props.options?.limit) {
42
+ return undefined
43
+ }
44
+
45
+ return {
46
+ ...initPageOptions({
47
+ limit: props.options.limit,
48
+ primary: props.options.primary,
49
+ }),
50
+ totalCount: props.options.rawData.length,
51
+ totalPage: Math.ceil(props.options.rawData.length / props.options.limit),
52
+ currentPage: currentPage.value,
53
+ }
54
+ })
55
+
56
+ const onPageChange = (page: number) => {
57
+ currentPage.value = page
58
+ }
59
+
60
+ const itemsByPage = computed(() => {
61
+ if (!pageOptions.value) {
62
+ return props.options?.rawData
63
+ }
64
+
65
+ const start = (pageOptions.value.currentPage - 1) * pageOptions.value.limit
66
+ const end = start + pageOptions.value.limit
67
+
68
+ return props.options?.rawData.slice(start, end)
69
+ })
70
+ </script>