cynx-lib 1.3.70 → 1.3.72

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,6 +1,6 @@
1
1
  {
2
2
  "name": "cynx-lib",
3
- "version": "1.3.70",
3
+ "version": "1.3.72",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -44,6 +44,7 @@ export default function Select({
44
44
  createLabel,
45
45
  }) {
46
46
  const [open, setOpen] = useState(false);
47
+ const [hovered, setHovered] = useState(false);
47
48
  const [query, setQuery] = useState('');
48
49
  const [pos, setPos] = useState({ top: 0, left: 0, width: 0, openUp: false, maxHeight: 200 });
49
50
  const wrapRef = useRef(null);
@@ -218,6 +219,8 @@ export default function Select({
218
219
  >
219
220
  <div
220
221
  onClick={handleOpen}
222
+ onMouseEnter={() => setHovered(true)}
223
+ onMouseLeave={() => setHovered(false)}
221
224
  style={{
222
225
  width: '100%',
223
226
  boxSizing: 'border-box',
@@ -228,7 +231,7 @@ export default function Select({
228
231
  padding: paddingVal,
229
232
  height: heightVal,
230
233
  background: 'var(--sf,var(--surface, #ffffff))',
231
- border: `1px solid ${open ? 'var(--accent, #f99e2c)' : 'var(--bd2,var(--border, #e2e8f0))'}`,
234
+ border: `1px solid ${open ? 'var(--accent, #12675D)' : 'var(--bd,var(--border, #d7d8e0))'}`,
232
235
  borderRadius: radiusVal,
233
236
  cursor: 'pointer',
234
237
  fontFamily: 'var(--f,var(--sans,inherit))',
@@ -237,7 +240,7 @@ export default function Select({
237
240
  color: 'var(--t,var(--primary-text, #0f172a))',
238
241
  outline: 'none',
239
242
  transition: 'border-color var(--tr,.15s), box-shadow var(--tr,.15s)',
240
- boxShadow: open ? 'var(--infd, rgba(37,99,235,.1))' : 'var(--shadow,0 1px 3px rgba(20,22,41,.1))',
243
+ boxShadow: open ? 'var(--pd, rgba(18,103,93,.12)), var(--shadow,0 1px 3px rgba(20,22,41,.1))' : 'var(--shadow,0 1px 3px rgba(20,22,41,.1))',
241
244
  }}
242
245
  >
243
246
  <div style={{ flex: 1, minWidth: 0, display: 'flex', alignItems: 'center' }}>
@@ -375,7 +378,7 @@ export default function Select({
375
378
  padding: s.height <= 26 ? '2px 5px' : s.height <= 28 ? '3px 6px' : '7px 10px',
376
379
  height: s.searchHeight,
377
380
  background: 'var(--sf2,var(--grey-1, #f5f5f8))',
378
- border: '1.5px solid var(--bd2,var(--border, #e2e8f0))',
381
+ border: '1px solid var(--bd,var(--border, #d7d8e0))',
379
382
  borderRadius: s.height <= 26 ? '3px' : s.height <= 28 ? '4px' : 'var(--rmd,var(--rads, 8px))',
380
383
  fontFamily: 'var(--f,var(--sans, inherit))',
381
384
  fontSize: `${s.searchFont}px`,
@@ -9,6 +9,7 @@ import {
9
9
  useSlots,
10
10
  } from "vue";
11
11
  import { ChevronLeft, ChevronRight, Calendar, Clock } from "lucide-vue-next";
12
+ import TimePicker from "./TimePicker.vue";
12
13
 
13
14
  export interface DatePickerBadge {
14
15
  dot?: boolean;
@@ -1107,28 +1108,37 @@ const posMode = computed(() => {
1107
1108
  gap: 5px;
1108
1109
  font-size: .76rem;
1109
1110
  color: var(--muted, #797b8d);
1110
- fontWeight: 600;
1111
+ font-weight: 600;
1111
1112
  "
1112
1113
  >
1113
1114
  <Clock :size="13" style="opacity: 0.85;" />
1114
1115
  <span>{{ loc.time || 'Time:' }}</span>
1115
1116
  </div>
1116
- <button
1117
- type="button"
1118
- style="
1119
- padding: 4px 10px;
1120
- border-radius: var(--radxs, 6px);
1121
- background: var(--accent, #12675D);
1122
- color: var(--def-btn-text, #ffffff);
1123
- border: none;
1124
- font-size: 11.5px;
1125
- font-weight: 600;
1126
- cursor: pointer;
1127
- "
1128
- @click="open = false; view = 'day';"
1129
- >
1130
- {{ loc.ok || 'OK' }}
1131
- </button>
1117
+ <div style="display: flex; align-items: center; gap: 6px;">
1118
+ <TimePicker
1119
+ :model-value="timeValue || ''"
1120
+ :show-seconds="showSeconds"
1121
+ :placeholder="timePlaceholder || '00:00:00'"
1122
+ size="sm"
1123
+ @update:model-value="(t) => { emit('update:timeValue', t); emit('time-change', t); }"
1124
+ />
1125
+ <button
1126
+ type="button"
1127
+ style="
1128
+ padding: 4px 10px;
1129
+ border-radius: var(--radxs, 6px);
1130
+ background: var(--accent, #12675D);
1131
+ color: var(--def-btn-text, #ffffff);
1132
+ border: none;
1133
+ font-size: 11.5px;
1134
+ font-weight: 600;
1135
+ cursor: pointer;
1136
+ "
1137
+ @click="open = false; view = 'day';"
1138
+ >
1139
+ {{ loc.ok || 'OK' }}
1140
+ </button>
1141
+ </div>
1132
1142
  </div>
1133
1143
  </div>
1134
1144
  </Teleport>
@@ -106,6 +106,7 @@ const emit = defineEmits<{
106
106
 
107
107
  const slots = useSlots();
108
108
  const open = ref(false);
109
+ const hovered = ref(false);
109
110
  const query = ref("");
110
111
  const pos = ref({ top: 0, left: 0, width: 0, openUp: false, maxHeight: 200 });
111
112
  const wrapRef = ref<HTMLElement | null>(null);
@@ -361,7 +362,7 @@ function handleInputKeyDown(e: KeyboardEvent) {
361
362
  padding: `0 ${s.paddingH}px`,
362
363
  height: `${s.height}px`,
363
364
  background: 'var(--sf,var(--surface, #ffffff))',
364
- border: `1px solid ${open ? 'var(--accent, #f99e2c)' : 'var(--bd2,var(--border, #e2e8f0))'}`,
365
+ border: `1px solid ${open ? 'var(--accent, #12675D)' : 'var(--bd,var(--border, #d7d8e0))'}`,
365
366
  borderRadius: radiusVal,
366
367
  cursor: 'pointer',
367
368
  fontFamily: 'var(--f,var(--sans,inherit))',
@@ -371,9 +372,11 @@ function handleInputKeyDown(e: KeyboardEvent) {
371
372
  outline: 'none',
372
373
  transition: 'border-color var(--tr,.15s), box-shadow var(--tr,.15s)',
373
374
  boxShadow: open
374
- ? 'var(--infd, rgba(37,99,235,.1))'
375
+ ? 'var(--pd, rgba(18,103,93,.12)), var(--shadow, 0 1px 3px rgba(20,22,41,.1))'
375
376
  : 'var(--shadow,0 1px 3px rgba(20,22,41,.1))',
376
377
  }"
378
+ @mouseenter="hovered = true"
379
+ @mouseleave="hovered = false"
377
380
  @click="handleOpen"
378
381
  >
379
382
  <slot v-if="slots.prefix" name="prefix" />
@@ -555,7 +558,7 @@ function handleInputKeyDown(e: KeyboardEvent) {
555
558
  padding: s.height <= 26 ? '2px 5px' : s.height <= 28 ? '3px 6px' : '7px 10px',
556
559
  height: `${s.searchHeight}px`,
557
560
  background: 'var(--sf2,var(--grey-1, #f5f5f8))',
558
- border: '1.5px solid var(--bd2,var(--border, #e2e8f0))',
561
+ border: '1px solid var(--bd,var(--border, #d7d8e0))',
559
562
  borderRadius: s.height <= 26 ? '3px' : s.height <= 28 ? '4px' : 'var(--rmd,var(--rads, 8px))',
560
563
  fontFamily: 'var(--f,var(--sans, inherit))',
561
564
  fontSize: `${s.searchFont}px`,
@@ -0,0 +1,395 @@
1
+ <script setup lang="ts">
2
+ import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from "vue";
3
+ import { ChevronDown, Check, X, Clock } from "lucide-vue-next";
4
+
5
+ function pad(n: number | string): string {
6
+ return String(n).padStart(2, "0");
7
+ }
8
+
9
+ function parseTime(val?: string, showSeconds = false) {
10
+ if (!val || typeof val !== "string") {
11
+ return { h: "00", m: "00", s: "00" };
12
+ }
13
+ const clean = val.trim();
14
+ const parts = clean.split(":").map((p) => p.trim());
15
+ const hNum = Math.min(23, Math.max(0, parseInt(parts[0], 10) || 0));
16
+ const mNum = Math.min(59, Math.max(0, parseInt(parts[1], 10) || 0));
17
+ const sNum = Math.min(59, Math.max(0, parseInt(parts[2], 10) || 0));
18
+ return {
19
+ h: pad(hNum),
20
+ m: pad(mNum),
21
+ s: pad(sNum),
22
+ };
23
+ }
24
+
25
+ const props = withDefaults(
26
+ defineProps<{
27
+ modelValue?: string;
28
+ value?: string;
29
+ showSeconds?: boolean;
30
+ disabled?: boolean;
31
+ size?: "xs" | "sm" | "md" | "lg";
32
+ placeholder?: string;
33
+ }>(),
34
+ {
35
+ modelValue: "",
36
+ value: "",
37
+ showSeconds: false,
38
+ disabled: false,
39
+ size: "md",
40
+ placeholder: "",
41
+ }
42
+ );
43
+
44
+ const emit = defineEmits<{
45
+ (e: "update:modelValue", val: string): void;
46
+ (e: "update:value", val: string): void;
47
+ (e: "change", val: string): void;
48
+ }>();
49
+
50
+ const currentVal = computed(() => {
51
+ return props.modelValue !== undefined && props.modelValue !== ""
52
+ ? props.modelValue
53
+ : props.value;
54
+ });
55
+
56
+ const open = ref(false);
57
+ const btnRef = ref<HTMLElement | null>(null);
58
+ const dropRef = ref<HTMLElement | null>(null);
59
+ const pos = ref({ top: 0, left: 0 });
60
+
61
+ const hours = Array.from({ length: 24 }, (_, i) => pad(i));
62
+ const minutes = Array.from({ length: 60 }, (_, i) => pad(i));
63
+ const seconds = Array.from({ length: 60 }, (_, i) => pad(i));
64
+
65
+ const activeTime = ref(parseTime(currentVal.value, props.showSeconds));
66
+
67
+ watch(
68
+ currentVal,
69
+ (newVal) => {
70
+ activeTime.value = parseTime(newVal, props.showSeconds);
71
+ },
72
+ { immediate: true }
73
+ );
74
+
75
+ const displayLabel = computed(() => {
76
+ if (!currentVal.value && props.placeholder) return props.placeholder;
77
+ const t = activeTime.value;
78
+ return props.showSeconds ? `${t.h}:${t.m}:${t.s}` : `${t.h}:${t.m}`;
79
+ });
80
+
81
+ function emitTime() {
82
+ const t = activeTime.value;
83
+ const result = props.showSeconds ? `${t.h}:${t.m}:${t.s}` : `${t.h}:${t.m}`;
84
+ emit("update:modelValue", result);
85
+ emit("update:value", result);
86
+ emit("change", result);
87
+ }
88
+
89
+ function selectHour(h: string) {
90
+ activeTime.value = h;
91
+ emitTime();
92
+ }
93
+
94
+ function selectMinute(m: string) {
95
+ activeTime.value.m = m;
96
+ emitTime();
97
+ }
98
+
99
+ function selectSecond(s: string) {
100
+ activeTime.value.s = s;
101
+ emitTime();
102
+ }
103
+
104
+ function resetTime() {
105
+ activeTime.value = { h: "00", m: "00", s: "00" };
106
+ emitTime();
107
+ }
108
+
109
+ function done() {
110
+ open.value = false;
111
+ }
112
+
113
+ const calcPos = () => {
114
+ if (!btnRef.value) return;
115
+ const r = btnRef.value.getBoundingClientRect();
116
+ const dropW = props.showSeconds ? 220 : 160;
117
+ const dropH = 220;
118
+
119
+ let left = r.left;
120
+ if (left + dropW > window.innerWidth - 12) {
121
+ left = Math.max(12, window.innerWidth - dropW - 12);
122
+ }
123
+ if (left < 12) left = 12;
124
+
125
+ let top = r.bottom + 4;
126
+ if (top + dropH > window.innerHeight - 12 && r.top - dropH - 4 > 12) {
127
+ top = r.top - dropH - 4;
128
+ }
129
+
130
+ pos.value = { top, left };
131
+ };
132
+
133
+ const togglePicker = () => {
134
+ if (props.disabled) return;
135
+ if (!open.value) calcPos();
136
+ open.value = !open.value;
137
+ };
138
+
139
+ const handleWindowClick = (e: MouseEvent) => {
140
+ if (!open.value) return;
141
+ const target = e.target as Node;
142
+ if (btnRef.value?.contains(target)) return;
143
+ if (dropRef.value?.contains(target)) return;
144
+ open.value = false;
145
+ };
146
+
147
+ const handleKeyDown = (e: KeyboardEvent) => {
148
+ if (e.key === "Escape" && open.value) {
149
+ open.value = false;
150
+ }
151
+ };
152
+
153
+ watch(open, (isOpen) => {
154
+ if (isOpen) {
155
+ calcPos();
156
+ window.addEventListener("scroll", calcPos, true);
157
+ window.addEventListener("resize", calcPos);
158
+ document.addEventListener("mousedown", handleWindowClick, true);
159
+ document.addEventListener("keydown", handleKeyDown);
160
+ nextTick(calcPos);
161
+ } else {
162
+ window.removeEventListener("scroll", calcPos, true);
163
+ window.removeEventListener("resize", calcPos);
164
+ document.removeEventListener("mousedown", handleWindowClick, true);
165
+ document.removeEventListener("keydown", handleKeyDown);
166
+ }
167
+ });
168
+
169
+ onBeforeUnmount(() => {
170
+ window.removeEventListener("scroll", calcPos, true);
171
+ window.removeEventListener("resize", calcPos);
172
+ document.removeEventListener("mousedown", handleWindowClick, true);
173
+ document.removeEventListener("keydown", handleKeyDown);
174
+ });
175
+ </script>
176
+
177
+ <template>
178
+ <div style="position: relative; display: inline-flex;">
179
+ <!-- Trigger Button -->
180
+ <button
181
+ ref="btnRef"
182
+ type="button"
183
+ :disabled="disabled"
184
+ style="
185
+ display: inline-flex;
186
+ align-items: center;
187
+ gap: 6px;
188
+ padding: 0 8px;
189
+ height: 28px;
190
+ font-size: 12px;
191
+ font-weight: 600;
192
+ border-radius: var(--radxs, 6px);
193
+ border: 1px solid var(--border, #e2e8f0);
194
+ background: var(--surface, #ffffff);
195
+ color: var(--primary-text, #0f172a);
196
+ cursor: pointer;
197
+ user-select: none;
198
+ transition: border-color .14s;
199
+ "
200
+ :style="{
201
+ borderColor: open ? 'var(--accent, #12675D)' : 'var(--border, #e2e8f0)',
202
+ opacity: disabled ? 0.45 : 1,
203
+ cursor: disabled ? 'not-allowed' : 'pointer',
204
+ }"
205
+ @click="togglePicker"
206
+ >
207
+ <span style="font-variant-numeric: tabular-nums;">
208
+ {{ displayLabel }}
209
+ </span>
210
+ <ChevronDown
211
+ :size="12"
212
+ style="
213
+ color: var(--muted, #797b8d);
214
+ transition: transform .18s;
215
+ "
216
+ :style="{
217
+ transform: open ? 'rotate(180deg)' : 'none',
218
+ }"
219
+ />
220
+ </button>
221
+
222
+ <!-- Dropdown Popup via Teleport -->
223
+ <Teleport to="body">
224
+ <div
225
+ v-if="open"
226
+ ref="dropRef"
227
+ style="
228
+ position: fixed;
229
+ z-index: 999999;
230
+ background: var(--surface, #ffffff);
231
+ border: 1px solid var(--border, #e2e8f0);
232
+ border-radius: 10px;
233
+ box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.15));
234
+ padding: 8px;
235
+ box-sizing: border-box;
236
+ user-select: none;
237
+ font-family: var(--sans, inherit);
238
+ "
239
+ :style="{
240
+ top: `${pos.top}px`,
241
+ left: `${pos.left}px`,
242
+ width: showSeconds ? '220px' : '155px',
243
+ }"
244
+ >
245
+ <!-- Columns Header & Lists -->
246
+ <div
247
+ style="display: grid; gap: 4px;"
248
+ :style="{
249
+ gridTemplateColumns: showSeconds ? '1fr 1fr 1fr' : '1fr 1fr',
250
+ }"
251
+ >
252
+ <!-- Hours Column -->
253
+ <div>
254
+ <div style="font-size: 10.5px; font-weight: 600; color: var(--muted, #797b8d); text-align: center; margin-bottom: 3px;">
255
+ Час
256
+ </div>
257
+ <div class="custom-scrollbar" style="max-height: 140px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 2px;">
258
+ <button
259
+ v-for="h in hours"
260
+ :key="h"
261
+ type="button"
262
+ style="
263
+ padding: 3px 0;
264
+ border-radius: var(--radxs, 4px);
265
+ border: none;
266
+ font-size: 11.5px;
267
+ cursor: pointer;
268
+ text-align: center;
269
+ transition: background .12s, color .12s;
270
+ "
271
+ :style="{
272
+ fontWeight: activeTime.h === h ? 700 : 400,
273
+ background: activeTime.h === h ? 'var(--accent, #12675D)' : 'transparent',
274
+ color: activeTime.h === h ? '#ffffff' : 'var(--primary-text, #0f172a)',
275
+ }"
276
+ @click="selectHour(h)"
277
+ >
278
+ {{ h }}
279
+ </button>
280
+ </div>
281
+ </div>
282
+
283
+ <!-- Minutes Column -->
284
+ <div>
285
+ <div style="font-size: 10.5px; font-weight: 600; color: var(--muted, #797b8d); text-align: center; margin-bottom: 3px;">
286
+ Мин
287
+ </div>
288
+ <div class="custom-scrollbar" style="max-height: 140px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 2px;">
289
+ <button
290
+ v-for="m in minutes"
291
+ :key="m"
292
+ type="button"
293
+ style="
294
+ padding: 3px 0;
295
+ border-radius: var(--radxs, 4px);
296
+ border: none;
297
+ font-size: 11.5px;
298
+ cursor: pointer;
299
+ text-align: center;
300
+ transition: background .12s, color .12s;
301
+ "
302
+ :style="{
303
+ fontWeight: activeTime.m === m ? 700 : 400,
304
+ background: activeTime.m === m ? 'var(--accent, #12675D)' : 'transparent',
305
+ color: activeTime.m === m ? '#ffffff' : 'var(--primary-text, #0f172a)',
306
+ }"
307
+ @click="selectMinute(m)"
308
+ >
309
+ {{ m }}
310
+ </button>
311
+ </div>
312
+ </div>
313
+
314
+ <!-- Seconds Column -->
315
+ <div v-if="showSeconds">
316
+ <div style="font-size: 10.5px; font-weight: 600; color: var(--muted, #797b8d); text-align: center; margin-bottom: 3px;">
317
+ Сек
318
+ </div>
319
+ <div class="custom-scrollbar" style="max-height: 140px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 2px;">
320
+ <button
321
+ v-for="s in seconds"
322
+ :key="s"
323
+ type="button"
324
+ style="
325
+ padding: 3px 0;
326
+ border-radius: var(--radxs, 4px);
327
+ border: none;
328
+ font-size: 11.5px;
329
+ cursor: pointer;
330
+ text-align: center;
331
+ transition: background .12s, color .12s;
332
+ "
333
+ :style="{
334
+ fontWeight: activeTime.s === s ? 700 : 400,
335
+ background: activeTime.s === s ? 'var(--accent, #12675D)' : 'transparent',
336
+ color: activeTime.s === s ? '#ffffff' : 'var(--primary-text, #0f172a)',
337
+ }"
338
+ @click="selectSecond(s)"
339
+ >
340
+ {{ s }}
341
+ </button>
342
+ </div>
343
+ </div>
344
+ </div>
345
+
346
+ <!-- Footer Actions -->
347
+ <div
348
+ style="
349
+ margin-top: 6px;
350
+ padding-top: 5px;
351
+ border-top: 1px solid var(--border-light, #ebebf0);
352
+ display: flex;
353
+ justify-content: space-between;
354
+ align-items: center;
355
+ "
356
+ >
357
+ <button
358
+ type="button"
359
+ style="
360
+ background: none;
361
+ border: none;
362
+ cursor: pointer;
363
+ color: var(--danger, #f64747);
364
+ font-size: 11px;
365
+ font-weight: 500;
366
+ padding: 2px 4px;
367
+ "
368
+ @click="resetTime"
369
+ >
370
+ Сбросить
371
+ </button>
372
+ <button
373
+ type="button"
374
+ style="
375
+ background: var(--accent, #12675D);
376
+ color: #ffffff;
377
+ border: none;
378
+ border-radius: var(--radxs, 4px);
379
+ padding: 3px 8px;
380
+ font-size: 11px;
381
+ font-weight: 600;
382
+ cursor: pointer;
383
+ display: inline-flex;
384
+ align-items: center;
385
+ gap: 3px;
386
+ "
387
+ @click="done"
388
+ >
389
+ <Check :size="12" /> Готово
390
+ </button>
391
+ </div>
392
+ </div>
393
+ </Teleport>
394
+ </div>
395
+ </template>
package/vue/index.js CHANGED
@@ -14,6 +14,7 @@ import Modal from "./components/Modal.vue";
14
14
  import Drawer from "./components/Drawer.vue";
15
15
  import Toggle from "./components/Toggle.vue";
16
16
  import DatePicker from "./components/DatePicker.vue";
17
+ import TimePicker from "./components/TimePicker.vue";
17
18
  import LinearProgress from "./components/LinearProgress.vue";
18
19
  import CircularProgress from "./components/CircularProgress.vue";
19
20
  import StatusTag from "./components/StatusTag.vue";
@@ -37,6 +38,7 @@ export {
37
38
  Drawer,
38
39
  Toggle,
39
40
  DatePicker,
41
+ TimePicker,
40
42
  LinearProgress,
41
43
  CircularProgress,
42
44
  StatusTag,
@@ -66,6 +68,7 @@ export default {
66
68
  Drawer,
67
69
  Toggle,
68
70
  DatePicker,
71
+ TimePicker,
69
72
  LinearProgress,
70
73
  CircularProgress,
71
74
  StatusTag,