ketekny-ui-kit 1.0.8 → 1.0.10

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/ui/kTable.vue +48 -19
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ketekny-ui-kit",
3
3
  "type": "module",
4
- "version": "1.0.8",
4
+ "version": "1.0.10",
5
5
  "description": "A Vue 3 UI component library with Tailwind CSS styling",
6
6
  "main": "index.js",
7
7
  "files": [
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
- <!-- Styled Thead -->
5
- <thead ref="theadRef">
6
- <slot name="head"></slot>
7
- </thead>
8
-
9
- <!-- Styled Tbody -->
10
- <tbody ref="tbodyRef">
11
- <slot name="body"></slot>
12
- </tbody>
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._observer.observe(this.$refs.tbodyRef, {
43
- childList: true,
44
- subtree: true,
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.$refs.theadRef;
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.$refs.tbodyRef;
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,22 +110,34 @@ 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
- @apply px-6 py-4 text-xl font-semibold text-left text-white bg-primary border-b border-primary;
118
+ @apply px-6 py-4 text-lg font-semibold text-left text-white bg-primary border-b border-primary;
98
119
  }
99
120
 
100
121
  .table-custom--plain th {
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
- @apply h-[4rem] px-6 py-4 text-lg text-slate-800;
130
+ @apply h-[3.2rem] px-6 py-4 text-base text-slate-800;
106
131
  }
107
132
 
108
133
  .table-custom--plain td {
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
  }