pukaad-ui-lib 1.209.0 → 1.210.1

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,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.209.0",
4
+ "version": "1.210.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17" fill="none">
2
+ <g clip-path="url(#clip0_6644_10663)">
3
+ <path d="M14.1667 3.98438C14.1667 5.79727 11.6285 9.02793 10.5139 10.3594C10.2465 10.6781 9.75 10.6781 9.48611 10.3594C8.37153 9.02793 5.83333 5.79727 5.83333 3.98438C5.83333 1.78301 7.69792 0 10 0C12.3021 0 14.1667 1.78301 14.1667 3.98438ZM14.4444 6.65391C14.566 6.42481 14.6771 6.1957 14.7778 5.96992C14.7951 5.93008 14.8125 5.88691 14.8299 5.84707L18.8576 4.30645C19.4062 4.09727 20 4.48242 20 5.04688V14.0383C20 14.3637 19.7917 14.6559 19.4757 14.7787L14.4444 16.7012V6.65391ZM4.77778 4.59199C4.86111 5.06016 5.02778 5.53164 5.22222 5.96992C5.32292 6.1957 5.43403 6.42481 5.55556 6.65391V15.0012L1.14236 16.6912C0.59375 16.9004 0 16.5152 0 15.9508V6.95938C0 6.63399 0.208333 6.3418 0.524306 6.21895L4.78125 4.59199H4.77778ZM11.3819 11.0234C11.8646 10.4457 12.6215 9.50606 13.3333 8.4668V16.7443L6.66667 14.9215V8.4668C7.37847 9.50606 8.13542 10.4457 8.61806 11.0234C9.32986 11.8734 10.6701 11.8734 11.3819 11.0234ZM10 5.04688C10.3684 5.04688 10.7216 4.90695 10.9821 4.65788C11.2426 4.4088 11.3889 4.07099 11.3889 3.71875C11.3889 3.36651 11.2426 3.0287 10.9821 2.77962C10.7216 2.53055 10.3684 2.39063 10 2.39063C9.63164 2.39063 9.27837 2.53055 9.01791 2.77962C8.75744 3.0287 8.61111 3.36651 8.61111 3.71875C8.61111 4.07099 8.75744 4.4088 9.01791 4.65788C9.27837 4.90695 9.63164 5.04688 10 5.04688Z" fill="#1976B8"/>
4
+ </g>
5
+ <defs>
6
+ <clipPath id="clip0_6644_10663">
7
+ <rect width="20" height="17" fill="white"/>
8
+ </clipPath>
9
+ </defs>
10
+ </svg>
@@ -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 __VLS_13: {
21
+ declare var __VLS_1: {
22
+ selected: Record<string, any>[];
23
+ }, __VLS_15: {
19
24
  item: TableHeader[];
20
- }, __VLS_28: `header-${string}`, __VLS_29: {
25
+ }, __VLS_43: `header-${string}`, __VLS_44: {
21
26
  header: TableHeader;
22
27
  onSort: () => void;
23
28
  isSorted: boolean;
24
29
  sortDesc: boolean;
25
- }, __VLS_36: {
30
+ }, __VLS_51: {
26
31
  items: Record<string, any>[];
27
32
  header: TableHeader[];
28
- }, __VLS_69: {
33
+ }, __VLS_99: {
29
34
  item: Record<string, any>;
30
35
  header: TableHeader[];
31
36
  index: number;
32
- }, __VLS_78: `item-${string}`, __VLS_79: {
37
+ }, __VLS_108: `item-${string}`, __VLS_109: {
33
38
  item: Record<string, any>;
34
- }, __VLS_81: {}, __VLS_89: {};
39
+ }, __VLS_111: {}, __VLS_119: {};
35
40
  type __VLS_Slots = {} & {
36
- [K in NonNullable<typeof __VLS_28>]?: (props: typeof __VLS_29) => any;
41
+ [K in NonNullable<typeof __VLS_43>]?: (props: typeof __VLS_44) => any;
37
42
  } & {
38
- [K in NonNullable<typeof __VLS_78>]?: (props: typeof __VLS_79) => any;
43
+ [K in NonNullable<typeof __VLS_108>]?: (props: typeof __VLS_109) => any;
39
44
  } & {
40
- header?: (props: typeof __VLS_13) => any;
45
+ 'selection-actions'?: (props: typeof __VLS_1) => any;
41
46
  } & {
42
- body?: (props: typeof __VLS_36) => any;
47
+ header?: (props: typeof __VLS_15) => any;
43
48
  } & {
44
- item?: (props: typeof __VLS_69) => any;
49
+ body?: (props: typeof __VLS_51) => any;
45
50
  } & {
46
- empty?: (props: typeof __VLS_81) => any;
51
+ item?: (props: typeof __VLS_99) => any;
47
52
  } & {
48
- 'empty-content'?: (props: typeof __VLS_89) => any;
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 __VLS_13: {
21
+ declare var __VLS_1: {
22
+ selected: Record<string, any>[];
23
+ }, __VLS_15: {
19
24
  item: TableHeader[];
20
- }, __VLS_28: `header-${string}`, __VLS_29: {
25
+ }, __VLS_43: `header-${string}`, __VLS_44: {
21
26
  header: TableHeader;
22
27
  onSort: () => void;
23
28
  isSorted: boolean;
24
29
  sortDesc: boolean;
25
- }, __VLS_36: {
30
+ }, __VLS_51: {
26
31
  items: Record<string, any>[];
27
32
  header: TableHeader[];
28
- }, __VLS_69: {
33
+ }, __VLS_99: {
29
34
  item: Record<string, any>;
30
35
  header: TableHeader[];
31
36
  index: number;
32
- }, __VLS_78: `item-${string}`, __VLS_79: {
37
+ }, __VLS_108: `item-${string}`, __VLS_109: {
33
38
  item: Record<string, any>;
34
- }, __VLS_81: {}, __VLS_89: {};
39
+ }, __VLS_111: {}, __VLS_119: {};
35
40
  type __VLS_Slots = {} & {
36
- [K in NonNullable<typeof __VLS_28>]?: (props: typeof __VLS_29) => any;
41
+ [K in NonNullable<typeof __VLS_43>]?: (props: typeof __VLS_44) => any;
37
42
  } & {
38
- [K in NonNullable<typeof __VLS_78>]?: (props: typeof __VLS_79) => any;
43
+ [K in NonNullable<typeof __VLS_108>]?: (props: typeof __VLS_109) => any;
39
44
  } & {
40
- header?: (props: typeof __VLS_13) => any;
45
+ 'selection-actions'?: (props: typeof __VLS_1) => any;
41
46
  } & {
42
- body?: (props: typeof __VLS_36) => any;
47
+ header?: (props: typeof __VLS_15) => any;
43
48
  } & {
44
- item?: (props: typeof __VLS_69) => any;
49
+ body?: (props: typeof __VLS_51) => any;
45
50
  } & {
46
- empty?: (props: typeof __VLS_81) => any;
51
+ item?: (props: typeof __VLS_99) => any;
47
52
  } & {
48
- 'empty-content'?: (props: typeof __VLS_89) => any;
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;
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
64
64
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
65
65
  src: string;
66
66
  center: boolean;
67
+ background: boolean;
68
+ modal: boolean;
67
69
  responsive: boolean;
68
70
  restore: boolean;
69
71
  checkCrossOrigin: boolean;
70
72
  checkOrientation: boolean;
71
73
  crossorigin: "" | "anonymous" | "use-credentials";
72
- modal: boolean;
73
74
  guides: boolean;
74
75
  highlight: boolean;
75
- background: boolean;
76
76
  autoCrop: boolean;
77
77
  movable: boolean;
78
78
  rotatable: boolean;
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
64
64
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
65
65
  src: string;
66
66
  center: boolean;
67
+ background: boolean;
68
+ modal: boolean;
67
69
  responsive: boolean;
68
70
  restore: boolean;
69
71
  checkCrossOrigin: boolean;
70
72
  checkOrientation: boolean;
71
73
  crossorigin: "" | "anonymous" | "use-credentials";
72
- modal: boolean;
73
74
  guides: boolean;
74
75
  highlight: boolean;
75
- background: boolean;
76
76
  autoCrop: boolean;
77
77
  movable: boolean;
78
78
  rotatable: boolean;
@@ -25,8 +25,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
25
25
  "onUpdate:modelValue"?: ((value: SelectedTag[]) => any) | undefined;
26
26
  }>, {
27
27
  name: string;
28
- state: "user" | "admin";
29
28
  placeholder: string;
29
+ state: "user" | "admin";
30
30
  limit: number;
31
31
  ignore: string[];
32
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -25,8 +25,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
25
25
  "onUpdate:modelValue"?: ((value: SelectedTag[]) => any) | undefined;
26
26
  }>, {
27
27
  name: string;
28
- state: "user" | "admin";
29
28
  placeholder: string;
29
+ state: "user" | "admin";
30
30
  limit: number;
31
31
  ignore: string[];
32
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -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-muted border-b transition-colors', props.class)"
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.209.0",
3
+ "version": "1.210.1",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",