ketekny-ui-kit 1.0.7 → 1.0.9
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/package.json +1 -1
- package/src/ui/kTable.vue +46 -17
- package/src/ui/kToolbar.vue +6 -1
package/package.json
CHANGED
package/src/ui/kTable.vue
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="tableWrapper" :class="['w-full', { 'k-table-mobile': isMobileLayout }]">
|
|
3
|
-
<table :class="['table-custom', `table-custom--${variant}`]">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
<table ref="tableRef" :class="['table-custom', `table-custom--${variant}`]">
|
|
4
|
+
<template v-if="hasNamedSlots">
|
|
5
|
+
<thead ref="theadRef">
|
|
6
|
+
<slot name="head"></slot>
|
|
7
|
+
</thead>
|
|
8
|
+
<tbody ref="tbodyRef">
|
|
9
|
+
<slot name="body"></slot>
|
|
10
|
+
</tbody>
|
|
11
|
+
</template>
|
|
12
|
+
<template v-else>
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</template>
|
|
13
15
|
</table>
|
|
14
16
|
</div>
|
|
15
17
|
</template>
|
|
@@ -21,7 +23,7 @@ export default {
|
|
|
21
23
|
variant: {
|
|
22
24
|
type: String,
|
|
23
25
|
default: "card",
|
|
24
|
-
validator: (value) => ["card", "plain"].includes(value),
|
|
26
|
+
validator: (value) => ["card", "plain", "flat"].includes(value),
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
data() {
|
|
@@ -29,6 +31,11 @@ export default {
|
|
|
29
31
|
isMobileLayout: false,
|
|
30
32
|
};
|
|
31
33
|
},
|
|
34
|
+
computed: {
|
|
35
|
+
hasNamedSlots() {
|
|
36
|
+
return !!(this.$slots.head || this.$slots.body);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
32
39
|
mounted() {
|
|
33
40
|
this.$nextTick(() => {
|
|
34
41
|
this.updateLayoutMode();
|
|
@@ -39,10 +46,13 @@ export default {
|
|
|
39
46
|
this.$nextTick(() => this.applyMobileLayout());
|
|
40
47
|
});
|
|
41
48
|
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const tbody = this.getTbodyRef();
|
|
50
|
+
if (tbody) {
|
|
51
|
+
this._observer.observe(tbody, {
|
|
52
|
+
childList: true,
|
|
53
|
+
subtree: true,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
46
56
|
|
|
47
57
|
this._resizeObserver = new ResizeObserver(() => {
|
|
48
58
|
this.updateLayoutMode();
|
|
@@ -61,12 +71,13 @@ export default {
|
|
|
61
71
|
this.isMobileLayout = wrapper.clientWidth < 640;
|
|
62
72
|
},
|
|
63
73
|
applyMobileLayout() {
|
|
64
|
-
const thead = this
|
|
74
|
+
const thead = this.getTheadRef();
|
|
65
75
|
if (!thead) return;
|
|
66
76
|
|
|
67
77
|
const headers = Array.from(thead.querySelectorAll("th")).map((th) => th.textContent.trim());
|
|
68
78
|
|
|
69
|
-
const tbody = this
|
|
79
|
+
const tbody = this.getTbodyRef();
|
|
80
|
+
if (!tbody) return;
|
|
70
81
|
const rows = tbody.querySelectorAll("tr");
|
|
71
82
|
|
|
72
83
|
rows.forEach((row) => {
|
|
@@ -76,6 +87,12 @@ export default {
|
|
|
76
87
|
});
|
|
77
88
|
});
|
|
78
89
|
},
|
|
90
|
+
getTheadRef() {
|
|
91
|
+
return this.$refs.theadRef || this.$refs.tableRef?.querySelector("thead");
|
|
92
|
+
},
|
|
93
|
+
getTbodyRef() {
|
|
94
|
+
return this.$refs.tbodyRef || this.$refs.tableRef?.querySelector("tbody");
|
|
95
|
+
},
|
|
79
96
|
},
|
|
80
97
|
};
|
|
81
98
|
</script>
|
|
@@ -93,6 +110,10 @@ export default {
|
|
|
93
110
|
@apply bg-transparent border-0 rounded-none shadow-none;
|
|
94
111
|
}
|
|
95
112
|
|
|
113
|
+
.table-custom--flat {
|
|
114
|
+
@apply bg-white border border-slate-200 rounded-xl shadow-none;
|
|
115
|
+
}
|
|
116
|
+
|
|
96
117
|
.table-custom--card th {
|
|
97
118
|
@apply px-6 py-4 text-xl font-semibold text-left text-white bg-primary border-b border-primary;
|
|
98
119
|
}
|
|
@@ -101,6 +122,10 @@ export default {
|
|
|
101
122
|
@apply px-4 py-2 text-sm font-semibold tracking-wide text-left text-slate-700 uppercase bg-transparent border-b border-slate-300;
|
|
102
123
|
}
|
|
103
124
|
|
|
125
|
+
.table-custom--flat th {
|
|
126
|
+
@apply px-4 py-2 text-sm font-semibold tracking-wide text-left uppercase text-slate-600 bg-slate-100 border-b border-slate-200 align-middle;
|
|
127
|
+
}
|
|
128
|
+
|
|
104
129
|
.table-custom--card td {
|
|
105
130
|
@apply h-[4rem] px-6 py-4 text-lg text-slate-800;
|
|
106
131
|
}
|
|
@@ -109,6 +134,10 @@ export default {
|
|
|
109
134
|
@apply h-[3.2rem] px-2 py-2 text-base text-slate-800;
|
|
110
135
|
}
|
|
111
136
|
|
|
137
|
+
.table-custom--flat td {
|
|
138
|
+
@apply h-[3.2rem] px-4 py-2 text-base text-slate-900 align-middle;
|
|
139
|
+
}
|
|
140
|
+
|
|
112
141
|
.table-custom tr {
|
|
113
142
|
@apply transition duration-200 ease-in-out hover:bg-slate-50;
|
|
114
143
|
}
|
package/src/ui/kToolbar.vue
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
:aria-label="ariaLabel"
|
|
6
6
|
:aria-disabled="disabled.toString()"
|
|
7
7
|
:class="[
|
|
8
|
-
'k-toolbar relative
|
|
8
|
+
'k-toolbar relative w-full',
|
|
9
|
+
dense ? 'p-0 md:p-0' : 'px-3 md:px-4 py-2.5',
|
|
9
10
|
variant === 'plain' ? 'bg-transparent border-0 rounded-none shadow-none px-0 md:px-0' : 'border border-slate-200 rounded-lg bg-white shadow-sm',
|
|
10
11
|
disabled ? 'pointer-events-none opacity-60' : '',
|
|
11
12
|
]">
|
|
@@ -119,6 +120,10 @@ const props = defineProps({
|
|
|
119
120
|
type: Boolean,
|
|
120
121
|
default: false,
|
|
121
122
|
},
|
|
123
|
+
dense: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: false,
|
|
126
|
+
},
|
|
122
127
|
variant: {
|
|
123
128
|
type: String,
|
|
124
129
|
default: "card",
|