pukaad-ui-lib 1.209.0 → 1.210.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 +1 -1
- package/dist/runtime/components/data-table.d.vue.ts +24 -13
- package/dist/runtime/components/data-table.vue +69 -1
- package/dist/runtime/components/data-table.vue.d.ts +24 -13
- package/dist/runtime/components/input/input-file.d.vue.ts +1 -1
- package/dist/runtime/components/input/input-file.vue.d.ts +1 -1
- package/dist/runtime/components/ui/table/TableRow.vue +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -9,46 +9,54 @@ export interface DataTableProps {
|
|
|
9
9
|
disabledPagination?: boolean;
|
|
10
10
|
totalPage?: number;
|
|
11
11
|
loading?: boolean;
|
|
12
|
+
selectable?: boolean;
|
|
13
|
+
selectKey?: string;
|
|
12
14
|
}
|
|
13
15
|
type __VLS_Props = DataTableProps;
|
|
14
16
|
type __VLS_ModelProps = {
|
|
15
17
|
"page"?: number;
|
|
18
|
+
"selected"?: Record<string, any>[];
|
|
16
19
|
};
|
|
17
20
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
18
|
-
declare var
|
|
21
|
+
declare var __VLS_1: {
|
|
22
|
+
selected: Record<string, any>[];
|
|
23
|
+
}, __VLS_15: {
|
|
19
24
|
item: TableHeader[];
|
|
20
|
-
},
|
|
25
|
+
}, __VLS_43: `header-${string}`, __VLS_44: {
|
|
21
26
|
header: TableHeader;
|
|
22
27
|
onSort: () => void;
|
|
23
28
|
isSorted: boolean;
|
|
24
29
|
sortDesc: boolean;
|
|
25
|
-
},
|
|
30
|
+
}, __VLS_51: {
|
|
26
31
|
items: Record<string, any>[];
|
|
27
32
|
header: TableHeader[];
|
|
28
|
-
},
|
|
33
|
+
}, __VLS_99: {
|
|
29
34
|
item: Record<string, any>;
|
|
30
35
|
header: TableHeader[];
|
|
31
36
|
index: number;
|
|
32
|
-
},
|
|
37
|
+
}, __VLS_108: `item-${string}`, __VLS_109: {
|
|
33
38
|
item: Record<string, any>;
|
|
34
|
-
},
|
|
39
|
+
}, __VLS_111: {}, __VLS_119: {};
|
|
35
40
|
type __VLS_Slots = {} & {
|
|
36
|
-
[K in NonNullable<typeof
|
|
41
|
+
[K in NonNullable<typeof __VLS_43>]?: (props: typeof __VLS_44) => any;
|
|
37
42
|
} & {
|
|
38
|
-
[K in NonNullable<typeof
|
|
43
|
+
[K in NonNullable<typeof __VLS_108>]?: (props: typeof __VLS_109) => any;
|
|
39
44
|
} & {
|
|
40
|
-
|
|
45
|
+
'selection-actions'?: (props: typeof __VLS_1) => any;
|
|
41
46
|
} & {
|
|
42
|
-
|
|
47
|
+
header?: (props: typeof __VLS_15) => any;
|
|
43
48
|
} & {
|
|
44
|
-
|
|
49
|
+
body?: (props: typeof __VLS_51) => any;
|
|
45
50
|
} & {
|
|
46
|
-
|
|
51
|
+
item?: (props: typeof __VLS_99) => any;
|
|
47
52
|
} & {
|
|
48
|
-
|
|
53
|
+
empty?: (props: typeof __VLS_111) => any;
|
|
54
|
+
} & {
|
|
55
|
+
'empty-content'?: (props: typeof __VLS_119) => any;
|
|
49
56
|
};
|
|
50
57
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
51
58
|
"update:page": (value: number) => any;
|
|
59
|
+
"update:selected": (value: Record<string, any>[]) => any;
|
|
52
60
|
} & {
|
|
53
61
|
"select-page": (value: number) => any;
|
|
54
62
|
"change-page": (value: number) => any;
|
|
@@ -60,6 +68,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
60
68
|
"onClick-row"?: ((item: Record<string, any>, index: number) => any) | undefined;
|
|
61
69
|
"onChange-item-per-page"?: ((value: number) => any) | undefined;
|
|
62
70
|
"onUpdate:page"?: ((value: number) => any) | undefined;
|
|
71
|
+
"onUpdate:selected"?: ((value: Record<string, any>[]) => any) | undefined;
|
|
63
72
|
}>, {
|
|
64
73
|
loading: boolean;
|
|
65
74
|
items: Record<string, any>[];
|
|
@@ -70,6 +79,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
70
79
|
cellAlignment: TableHeaderAlignment;
|
|
71
80
|
disabledHeader: boolean;
|
|
72
81
|
disabledSort: boolean;
|
|
82
|
+
selectable: boolean;
|
|
83
|
+
selectKey: string;
|
|
73
84
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
74
85
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
75
86
|
declare const _default: typeof __VLS_export;
|
|
@@ -20,11 +20,47 @@ const props = defineProps({
|
|
|
20
20
|
disabledSort: { type: Boolean, required: false, default: false },
|
|
21
21
|
disabledPagination: { type: Boolean, required: false, default: false },
|
|
22
22
|
totalPage: { type: Number, required: false, default: 1 },
|
|
23
|
-
loading: { type: Boolean, required: false, default: false }
|
|
23
|
+
loading: { type: Boolean, required: false, default: false },
|
|
24
|
+
selectable: { type: Boolean, required: false, default: false },
|
|
25
|
+
selectKey: { type: String, required: false, default: "id" }
|
|
24
26
|
});
|
|
25
27
|
const page = defineModel("page", { type: Number, ...{
|
|
26
28
|
default: 1
|
|
27
29
|
} });
|
|
30
|
+
const selected = defineModel("selected", { type: Array, ...{
|
|
31
|
+
default: () => []
|
|
32
|
+
} });
|
|
33
|
+
const isAllSelected = computed(() => {
|
|
34
|
+
if (sortedItems.value.length === 0) return false;
|
|
35
|
+
return sortedItems.value.every((item) => isSelected(item));
|
|
36
|
+
});
|
|
37
|
+
const isIndeterminate = computed(() => {
|
|
38
|
+
return selected.value.length > 0 && !isAllSelected.value;
|
|
39
|
+
});
|
|
40
|
+
const isSelected = (item) => {
|
|
41
|
+
const key = props.selectKey;
|
|
42
|
+
return selected.value.some((s) => s[key] === item[key]);
|
|
43
|
+
};
|
|
44
|
+
const toggleAll = () => {
|
|
45
|
+
if (isAllSelected.value) {
|
|
46
|
+
const pageKeys = sortedItems.value.map((i) => i[props.selectKey]);
|
|
47
|
+
selected.value = selected.value.filter(
|
|
48
|
+
(s) => !pageKeys.includes(s[props.selectKey])
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
const toAdd = sortedItems.value.filter((item) => !isSelected(item));
|
|
52
|
+
selected.value = [...selected.value, ...toAdd];
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const toggleRow = (item) => {
|
|
56
|
+
if (isSelected(item)) {
|
|
57
|
+
selected.value = selected.value.filter(
|
|
58
|
+
(s) => s[props.selectKey] !== item[props.selectKey]
|
|
59
|
+
);
|
|
60
|
+
} else {
|
|
61
|
+
selected.value = [...selected.value, item];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
28
64
|
const sortkey = ref("");
|
|
29
65
|
const sortDesc = ref(false);
|
|
30
66
|
const itemPerPage = ref(10);
|
|
@@ -78,6 +114,17 @@ const getJustifyClass = (alignment = "start") => {
|
|
|
78
114
|
|
|
79
115
|
<template>
|
|
80
116
|
<div class="bg-white rounded-lg h-full flex flex-col">
|
|
117
|
+
<!-- Selection Action Bar -->
|
|
118
|
+
<div
|
|
119
|
+
v-if="props.selectable && selected.length > 0"
|
|
120
|
+
class="flex items-center gap-3 px-4 py-2 bg-primary rounded-t-lg"
|
|
121
|
+
>
|
|
122
|
+
<span class="font-body-medium text-white">
|
|
123
|
+
เลือก {{ selected.length }} รายการ
|
|
124
|
+
</span>
|
|
125
|
+
<slot name="selection-actions" :selected="selected" />
|
|
126
|
+
</div>
|
|
127
|
+
|
|
81
128
|
<!-- Table Container -->
|
|
82
129
|
<div class="flex-1 overflow-auto">
|
|
83
130
|
<ShadTable>
|
|
@@ -85,6 +132,16 @@ const getJustifyClass = (alignment = "start") => {
|
|
|
85
132
|
<ShadTableHeader v-if="!props.disabledHeader">
|
|
86
133
|
<slot name="header" :item="props.itemHeader">
|
|
87
134
|
<ShadTableRow>
|
|
135
|
+
<!-- Checkbox select-all -->
|
|
136
|
+
<ShadTableHead v-if="props.selectable" class="w-12">
|
|
137
|
+
<div class="flex items-center justify-center">
|
|
138
|
+
<InputCheckbox
|
|
139
|
+
:model-value="isIndeterminate ? 'indeterminate' : isAllSelected"
|
|
140
|
+
@update:model-value="() => toggleAll()"
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
</ShadTableHead>
|
|
144
|
+
|
|
88
145
|
<ShadTableHead
|
|
89
146
|
v-for="(header, i) in itemHeaders"
|
|
90
147
|
:key="i"
|
|
@@ -151,8 +208,19 @@ const getJustifyClass = (alignment = "start") => {
|
|
|
151
208
|
v-for="(item, i_body) in sortedItems"
|
|
152
209
|
:key="i_body"
|
|
153
210
|
class="cursor-pointer"
|
|
211
|
+
:data-state="props.selectable && isSelected(item) ? 'selected' : void 0"
|
|
154
212
|
@click="emit('click-row', item, i_body)"
|
|
155
213
|
>
|
|
214
|
+
<!-- Checkbox per row -->
|
|
215
|
+
<ShadTableCell v-if="props.selectable" @click.stop>
|
|
216
|
+
<div class="flex items-center justify-center">
|
|
217
|
+
<InputCheckbox
|
|
218
|
+
:model-value="isSelected(item)"
|
|
219
|
+
@update:model-value="() => toggleRow(item)"
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
</ShadTableCell>
|
|
223
|
+
|
|
156
224
|
<slot
|
|
157
225
|
name="item"
|
|
158
226
|
:item="item"
|
|
@@ -9,46 +9,54 @@ export interface DataTableProps {
|
|
|
9
9
|
disabledPagination?: boolean;
|
|
10
10
|
totalPage?: number;
|
|
11
11
|
loading?: boolean;
|
|
12
|
+
selectable?: boolean;
|
|
13
|
+
selectKey?: string;
|
|
12
14
|
}
|
|
13
15
|
type __VLS_Props = DataTableProps;
|
|
14
16
|
type __VLS_ModelProps = {
|
|
15
17
|
"page"?: number;
|
|
18
|
+
"selected"?: Record<string, any>[];
|
|
16
19
|
};
|
|
17
20
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
18
|
-
declare var
|
|
21
|
+
declare var __VLS_1: {
|
|
22
|
+
selected: Record<string, any>[];
|
|
23
|
+
}, __VLS_15: {
|
|
19
24
|
item: TableHeader[];
|
|
20
|
-
},
|
|
25
|
+
}, __VLS_43: `header-${string}`, __VLS_44: {
|
|
21
26
|
header: TableHeader;
|
|
22
27
|
onSort: () => void;
|
|
23
28
|
isSorted: boolean;
|
|
24
29
|
sortDesc: boolean;
|
|
25
|
-
},
|
|
30
|
+
}, __VLS_51: {
|
|
26
31
|
items: Record<string, any>[];
|
|
27
32
|
header: TableHeader[];
|
|
28
|
-
},
|
|
33
|
+
}, __VLS_99: {
|
|
29
34
|
item: Record<string, any>;
|
|
30
35
|
header: TableHeader[];
|
|
31
36
|
index: number;
|
|
32
|
-
},
|
|
37
|
+
}, __VLS_108: `item-${string}`, __VLS_109: {
|
|
33
38
|
item: Record<string, any>;
|
|
34
|
-
},
|
|
39
|
+
}, __VLS_111: {}, __VLS_119: {};
|
|
35
40
|
type __VLS_Slots = {} & {
|
|
36
|
-
[K in NonNullable<typeof
|
|
41
|
+
[K in NonNullable<typeof __VLS_43>]?: (props: typeof __VLS_44) => any;
|
|
37
42
|
} & {
|
|
38
|
-
[K in NonNullable<typeof
|
|
43
|
+
[K in NonNullable<typeof __VLS_108>]?: (props: typeof __VLS_109) => any;
|
|
39
44
|
} & {
|
|
40
|
-
|
|
45
|
+
'selection-actions'?: (props: typeof __VLS_1) => any;
|
|
41
46
|
} & {
|
|
42
|
-
|
|
47
|
+
header?: (props: typeof __VLS_15) => any;
|
|
43
48
|
} & {
|
|
44
|
-
|
|
49
|
+
body?: (props: typeof __VLS_51) => any;
|
|
45
50
|
} & {
|
|
46
|
-
|
|
51
|
+
item?: (props: typeof __VLS_99) => any;
|
|
47
52
|
} & {
|
|
48
|
-
|
|
53
|
+
empty?: (props: typeof __VLS_111) => any;
|
|
54
|
+
} & {
|
|
55
|
+
'empty-content'?: (props: typeof __VLS_119) => any;
|
|
49
56
|
};
|
|
50
57
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
51
58
|
"update:page": (value: number) => any;
|
|
59
|
+
"update:selected": (value: Record<string, any>[]) => any;
|
|
52
60
|
} & {
|
|
53
61
|
"select-page": (value: number) => any;
|
|
54
62
|
"change-page": (value: number) => any;
|
|
@@ -60,6 +68,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
60
68
|
"onClick-row"?: ((item: Record<string, any>, index: number) => any) | undefined;
|
|
61
69
|
"onChange-item-per-page"?: ((value: number) => any) | undefined;
|
|
62
70
|
"onUpdate:page"?: ((value: number) => any) | undefined;
|
|
71
|
+
"onUpdate:selected"?: ((value: Record<string, any>[]) => any) | undefined;
|
|
63
72
|
}>, {
|
|
64
73
|
loading: boolean;
|
|
65
74
|
items: Record<string, any>[];
|
|
@@ -70,6 +79,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
70
79
|
cellAlignment: TableHeaderAlignment;
|
|
71
80
|
disabledHeader: boolean;
|
|
72
81
|
disabledSort: boolean;
|
|
82
|
+
selectable: boolean;
|
|
83
|
+
selectKey: string;
|
|
73
84
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
74
85
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
75
86
|
declare const _default: typeof __VLS_export;
|
|
@@ -35,8 +35,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
35
35
|
fullHeight: boolean;
|
|
36
36
|
name: string;
|
|
37
37
|
limit: number;
|
|
38
|
-
disabledErrorMessage: boolean;
|
|
39
38
|
accept: string;
|
|
39
|
+
disabledErrorMessage: boolean;
|
|
40
40
|
labelIcon: string;
|
|
41
41
|
disabledDrop: boolean;
|
|
42
42
|
column: boolean;
|
|
@@ -35,8 +35,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
35
35
|
fullHeight: boolean;
|
|
36
36
|
name: string;
|
|
37
37
|
limit: number;
|
|
38
|
-
disabledErrorMessage: boolean;
|
|
39
38
|
accept: string;
|
|
39
|
+
disabledErrorMessage: boolean;
|
|
40
40
|
labelIcon: string;
|
|
41
41
|
disabledDrop: boolean;
|
|
42
42
|
column: boolean;
|
|
@@ -8,7 +8,7 @@ const props = defineProps({
|
|
|
8
8
|
<template>
|
|
9
9
|
<tr
|
|
10
10
|
data-slot="table-row"
|
|
11
|
-
:class="cn('hover:bg-muted/50 data-[state=selected]:bg-
|
|
11
|
+
:class="cn('hover:bg-muted/50 data-[state=selected]:bg-info border-b transition-colors', props.class)"
|
|
12
12
|
>
|
|
13
13
|
<slot />
|
|
14
14
|
</tr>
|