ketekny-ui-kit 1.0.22 → 1.0.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ketekny-ui-kit",
3
3
  "type": "module",
4
- "version": "1.0.22",
4
+ "version": "1.0.24",
5
5
  "description": "A Vue 3 UI component library with Tailwind CSS styling",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -57,7 +57,7 @@
57
57
  <SelectViewport
58
58
  ref="viewportRef"
59
59
  class="select-viewport p-1 overflow-y-scroll"
60
- :style="{ maxHeight: dropdownHeight }"
60
+ :style="{ maxHeight: resolvedDropdownHeight }"
61
61
  @keydown="handleViewportKeydown"
62
62
  >
63
63
  <SelectItem
@@ -138,9 +138,44 @@ const defaultStyle = "w-full px-3 py-2 border rounded-lg transition shadow-sm fo
138
138
  const errorStyle = "border-red-500 focus:ring focus:ring-red-300";
139
139
  const disabledStyle = "!bg-gray-100 !text-gray-400 !cursor-not-allowed";
140
140
 
141
+ function normalizeDropdownHeight(value) {
142
+ const raw = String(value ?? "").trim();
143
+ if (!raw) return "min(400px, 40vh)";
144
+
145
+ // Accept Tailwind arbitrary values like max-h-[400px] / min-h-[20rem].
146
+ const arbitraryMatch = raw.match(/^(?:max-h|min-h)-\[(.+)\]$/);
147
+ if (arbitraryMatch) return arbitraryMatch[1].trim();
148
+
149
+ // Accept Tailwind scale values like max-h-80 -> 20rem.
150
+ const scaleMatch = raw.match(/^(?:max-h|min-h)-(\d+(?:\.\d+)?)$/);
151
+ if (scaleMatch) {
152
+ const scale = Number(scaleMatch[1]);
153
+ if (Number.isFinite(scale)) return `${scale * 0.25}rem`;
154
+ }
155
+
156
+ // Accept common Tailwind keywords.
157
+ const keywordMap = {
158
+ "max-h-full": "100%",
159
+ "min-h-full": "100%",
160
+ "max-h-screen": "100vh",
161
+ "min-h-screen": "100vh",
162
+ "max-h-fit": "fit-content",
163
+ "min-h-fit": "fit-content",
164
+ "max-h-min": "min-content",
165
+ "min-h-min": "min-content",
166
+ "max-h-max": "max-content",
167
+ "min-h-max": "max-content",
168
+ };
169
+ if (keywordMap[raw]) return keywordMap[raw];
170
+
171
+ // Already valid CSS values (e.g. 20rem, 400px, min(400px, 40vh)).
172
+ return raw;
173
+ }
174
+
141
175
  const computedId = computed(() => (props.id != null && props.id !== "" ? props.id : generatedId));
142
176
  const hasError = computed(() => props.error != null && props.error !== false);
143
177
  const isSelectionSet = computed(() => props.modelValue !== null && props.modelValue !== undefined && props.modelValue !== "");
178
+ const resolvedDropdownHeight = computed(() => normalizeDropdownHeight(props.dropdownHeight));
144
179
 
145
180
  const internalValue = computed({
146
181
  get() {
@@ -1,7 +1,14 @@
1
1
  <template>
2
2
  <div :class="labelStyle === 'inline' ? 'flex items-center' : ''">
3
3
  <!-- Block-style label -->
4
- <div v-if="showLabel && labelStyle !== 'inline'" :class="['block mb-1 text-sm font-bold', disabled ? 'text-slate-500' : 'text-primary/90']" for="toggle">
4
+ <div
5
+ v-if="showLabel && labelStyle !== 'inline'"
6
+ :class="[
7
+ 'block mb-1 text-sm font-bold',
8
+ disabled ? 'text-slate-500' : 'text-primary/90',
9
+ ]"
10
+ for="toggle"
11
+ >
5
12
  {{ label }}
6
13
  </div>
7
14
 
@@ -13,27 +20,38 @@
13
20
  :aria-disabled="disabled.toString()"
14
21
  :disabled="disabled"
15
22
  :class="[
16
- 'w-16 h-8 flex items-center rounded-full p-1 transition duration-300 border',
23
+ 'k-toggle-track',
17
24
  disabled
18
- ? 'bg-slate-200 border-slate-300 cursor-not-allowed'
25
+ ? 'k-toggle-track--disabled cursor-not-allowed'
19
26
  : modelValue
20
- ? 'bg-primary border-primary shadow-sm shadow-primary/30'
21
- : 'bg-gray-400 border-gray-400',
22
- ]">
27
+ ? 'k-toggle-track--on'
28
+ : 'k-toggle-track--off',
29
+ ]"
30
+ >
23
31
  <div
24
32
  :class="[
25
- 'w-6 h-6 rounded-full shadow-md transform transition duration-300',
26
- disabled ? 'bg-slate-100' : modelValue ? 'bg-white ring-2 ring-primary/20' : 'bg-white',
27
- modelValue ? 'translate-x-8' : 'translate-x-0',
28
- ]"></div>
33
+ 'k-toggle-thumb',
34
+ disabled
35
+ ? 'k-toggle-thumb--disabled'
36
+ : modelValue
37
+ ? 'k-toggle-thumb--on'
38
+ : 'k-toggle-thumb--off',
39
+ ]"
40
+ ></div>
29
41
  </button>
30
42
 
31
43
  <!-- Inline-style label -->
32
44
  <div
33
45
  v-if="showLabel && labelStyle === 'inline'"
34
- :class="['ml-2 text-sm font-bold', disabled ? 'text-slate-500 cursor-not-allowed' : 'text-primary/90 cursor-pointer']"
46
+ :class="[
47
+ 'ml-2 text-sm font-bold',
48
+ disabled
49
+ ? 'text-slate-500 cursor-not-allowed'
50
+ : 'text-primary/90 cursor-pointer',
51
+ ]"
35
52
  :for="computedId"
36
- @click="toggle">
53
+ @click="toggle"
54
+ >
37
55
  {{ label }}
38
56
  </div>
39
57
  </div>
@@ -66,5 +84,93 @@ export default {
66
84
  </script>
67
85
 
68
86
  <style scoped>
69
- /* Additional styles if needed */
87
+ .k-toggle-track {
88
+ width: 4rem;
89
+ height: 2rem;
90
+ display: flex;
91
+ align-items: center;
92
+ padding: 0.25rem;
93
+ border-radius: 9999px;
94
+ border: 1px solid transparent;
95
+ transition:
96
+ background-color 0.2s ease,
97
+ box-shadow 0.2s ease,
98
+ border-color 0.2s ease;
99
+ }
100
+
101
+ .k-toggle-track:focus-visible {
102
+ outline: none;
103
+ box-shadow: 0 0 0 2px rgb(37 99 235 / 0.35);
104
+ }
105
+
106
+ .k-toggle-track--on {
107
+ background: #1d4ed8;
108
+ border-color: #1d4ed8;
109
+ box-shadow: 0 2px 8px rgb(2 6 23 / 0.25);
110
+ }
111
+
112
+ .k-toggle-track--off {
113
+ background: #64748b;
114
+ border-color: #64748b;
115
+ }
116
+
117
+ .k-toggle-track--disabled {
118
+ background: #cbd5e1;
119
+ border-color: #cbd5e1;
120
+ }
121
+
122
+ .k-toggle-thumb {
123
+ width: 1.5rem;
124
+ height: 1.5rem;
125
+ border-radius: 9999px;
126
+ transition:
127
+ transform 0.22s ease,
128
+ background-color 0.2s ease,
129
+ border-color 0.2s ease;
130
+ }
131
+
132
+ .k-toggle-thumb--on {
133
+ transform: translateX(2rem);
134
+ background: #f8fafc;
135
+ border: 1px solid rgb(203 213 225 / 0.7);
136
+ }
137
+
138
+ .k-toggle-thumb--off {
139
+ transform: translateX(0);
140
+ background: #f8fafc;
141
+ border: 1px solid rgb(203 213 225 / 0.7);
142
+ }
143
+
144
+ .k-toggle-thumb--disabled {
145
+ transform: translateX(0);
146
+ background: #e2e8f0;
147
+ border: 1px solid #cbd5e1;
148
+ }
149
+
150
+ :global(html.dark) .k-toggle-track--on {
151
+ background: #1d4ed8;
152
+ border-color: #1d4ed8;
153
+ box-shadow: 0 2px 8px rgb(2 6 23 / 0.45);
154
+ }
155
+
156
+ :global(html.dark) .k-toggle-track--off {
157
+ background: #475569;
158
+ border-color: #475569;
159
+ }
160
+
161
+ :global(html.dark) .k-toggle-track--disabled {
162
+ background: #334155;
163
+ border-color: #334155;
164
+ }
165
+
166
+ :global(html.dark) .k-toggle-thumb--on,
167
+ :global(html.dark) .k-toggle-thumb--off {
168
+ background: #f8fafc;
169
+ border-color: #cbd5e1;
170
+ }
171
+
172
+ :global(html.dark) .k-toggle-thumb--disabled {
173
+ background: #94a3b8;
174
+ border-color: #64748b;
175
+ }
70
176
  </style>
@@ -1,5 +1,6 @@
1
1
  /** @type {import('tailwindcss').Config} */
2
2
  export default {
3
+ darkMode: "class",
3
4
  content: [
4
5
  "./index.html",
5
6
  "./src/**/*.{vue,js,ts,jsx,tsx}",