cynx-lib 1.3.72 → 1.3.73

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.72",
3
+ "version": "1.3.73",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -0,0 +1,602 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { Eye, EyeOff } from 'lucide-react';
3
+
4
+ function useIsDarkMode() {
5
+ const [isDark, setIsDark] = useState(false);
6
+
7
+ useEffect(() => {
8
+ const checkDark = () => {
9
+ if (typeof document === 'undefined') return false;
10
+ const root = document.documentElement;
11
+ const theme = root.getAttribute('data-theme') || document.body.getAttribute('data-theme');
12
+ if (theme === 'dark') return true;
13
+ if (theme === 'light' || theme === 'amber') return false;
14
+ const textColor = window.getComputedStyle(document.body).color;
15
+ const m = textColor.match(/\d+/g);
16
+ if (m && m.length >= 3) {
17
+ const b = (Number(m[0]) * 299 + Number(m[1]) * 587 + Number(m[2]) * 114) / 1000;
18
+ return b > 128;
19
+ }
20
+ return false;
21
+ };
22
+
23
+ setIsDark(checkDark());
24
+
25
+ const observer = new MutationObserver(() => {
26
+ setIsDark(checkDark());
27
+ });
28
+
29
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme', 'class'] });
30
+ return () => observer.disconnect();
31
+ }, []);
32
+
33
+ return isDark;
34
+ }
35
+
36
+ // Telegram-style Shared Singleton Tiling Engine
37
+ class SpoilerEngine {
38
+ constructor() {
39
+ this.subscribers = new Map();
40
+ this.tileCanvas = null;
41
+ this.tileCtx = null;
42
+ this.tileSize = 200;
43
+ this.particles = [];
44
+ this.animId = null;
45
+ this.speedMultiplier = 1.8;
46
+ }
47
+
48
+ initTile() {
49
+ if (this.tileCanvas) return;
50
+ if (typeof document === 'undefined') return;
51
+
52
+ this.tileCanvas = document.createElement('canvas');
53
+ this.tileCanvas.width = this.tileSize;
54
+ this.tileCanvas.height = this.tileSize;
55
+ this.tileCtx = this.tileCanvas.getContext('2d');
56
+
57
+ // 220 dense sparkling micro-particles inside a 200x200 seamless tile
58
+ const count = 220;
59
+ this.particles = [];
60
+ for (let i = 0; i < count; i++) {
61
+ const isMicro = Math.random() < 0.7;
62
+ this.particles.push({
63
+ x: Math.random() * this.tileSize,
64
+ y: Math.random() * this.tileSize,
65
+ size: isMicro ? (Math.random() * 0.4 + 0.6) : (Math.random() * 0.5 + 1.0),
66
+ phase: Math.random() * Math.PI * 2,
67
+ speed: Math.random() * 0.05 + 0.02,
68
+ baseAlpha: Math.random() * 0.55 + 0.35,
69
+ });
70
+ }
71
+ }
72
+
73
+ updateSpeed() {
74
+ if (this.subscribers.size === 0) return;
75
+ let maxSpeed = 1.8;
76
+ for (const s of this.subscribers.values()) {
77
+ if (typeof s === 'number' && s > 0) {
78
+ maxSpeed = Math.max(maxSpeed, s);
79
+ }
80
+ }
81
+ this.speedMultiplier = maxSpeed;
82
+ }
83
+
84
+ subscribe(callback, speed = 1.8) {
85
+ this.subscribers.set(callback, speed);
86
+ this.updateSpeed();
87
+ if (this.subscribers.size === 1) {
88
+ this.start();
89
+ }
90
+ }
91
+
92
+ unsubscribe(callback) {
93
+ this.subscribers.delete(callback);
94
+ this.updateSpeed();
95
+ if (this.subscribers.size === 0) {
96
+ this.stop();
97
+ }
98
+ }
99
+
100
+ start() {
101
+ this.initTile();
102
+ if (this.animId) return;
103
+
104
+ const loop = () => {
105
+ this.renderTile();
106
+ for (const cb of this.subscribers.keys()) {
107
+ cb(this.tileCanvas);
108
+ }
109
+ this.animId = requestAnimationFrame(loop);
110
+ };
111
+ this.animId = requestAnimationFrame(loop);
112
+ }
113
+
114
+ stop() {
115
+ if (this.animId) {
116
+ cancelAnimationFrame(this.animId);
117
+ this.animId = null;
118
+ }
119
+ }
120
+
121
+ renderTile() {
122
+ const ctx = this.tileCtx;
123
+ if (!ctx) return;
124
+ ctx.clearRect(0, 0, this.tileSize, this.tileSize);
125
+
126
+ const mult = this.speedMultiplier;
127
+ // Fast batch drawing of sparkling white particles with speed multiplier
128
+ for (let i = 0; i < this.particles.length; i++) {
129
+ const p = this.particles[i];
130
+ p.phase += p.speed * mult;
131
+
132
+ p.x += Math.sin(p.phase) * (0.05 * mult);
133
+ p.y += Math.cos(p.phase) * (0.05 * mult);
134
+ if (p.x < 0) p.x = this.tileSize;
135
+ if (p.x > this.tileSize) p.x = 0;
136
+ if (p.y < 0) p.y = this.tileSize;
137
+ if (p.y > this.tileSize) p.y = 0;
138
+
139
+ const shimmer = Math.sin(p.phase) * 0.35;
140
+ const alpha = Math.max(0.12, Math.min(1, p.baseAlpha + shimmer));
141
+
142
+ ctx.beginPath();
143
+ ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
144
+ ctx.fillStyle = `rgba(255, 255, 255, ${alpha})`;
145
+ ctx.fill();
146
+ }
147
+ }
148
+ }
149
+
150
+ const spoilerEngine = new SpoilerEngine();
151
+
152
+ function SpoilerCanvas({
153
+ active,
154
+ isBursting,
155
+ burstOrigin,
156
+ onBurstComplete,
157
+ isDark,
158
+ shimmerSpeed,
159
+ }) {
160
+ const canvasRef = useRef(null);
161
+ const sizeRef = useRef({ width: 0, height: 0, dpr: 1 });
162
+ const animBurstRef = useRef(null);
163
+
164
+ // Resize handling with devicePixelRatio for crisp Retina rendering
165
+ useEffect(() => {
166
+ const canvas = canvasRef.current;
167
+ if (!canvas) return;
168
+ const parent = canvas.parentElement;
169
+ if (!parent) return;
170
+
171
+ const ro = new ResizeObserver((entries) => {
172
+ for (const entry of entries) {
173
+ const rect = entry.contentRect;
174
+ if (rect.width > 0 && rect.height > 0) {
175
+ const dpr = window.devicePixelRatio || 1;
176
+ canvas.width = Math.floor(rect.width * dpr);
177
+ canvas.height = Math.floor(rect.height * dpr);
178
+ canvas.style.width = `${rect.width}px`;
179
+ canvas.style.height = `${rect.height}px`;
180
+ sizeRef.current = { width: rect.width, height: rect.height, dpr };
181
+ }
182
+ }
183
+ });
184
+
185
+ ro.observe(parent);
186
+ return () => ro.disconnect();
187
+ }, []);
188
+
189
+ // Shared Tiling Loop (Hardware accelerated repeat - 0.01ms draw call)
190
+ useEffect(() => {
191
+ if (!active || isBursting) return;
192
+
193
+ const draw = (tileCanvas) => {
194
+ const canvas = canvasRef.current;
195
+ if (!canvas) return;
196
+ const ctx = canvas.getContext('2d');
197
+ if (!ctx) return;
198
+ const { width, height, dpr } = sizeRef.current;
199
+ if (!width || !height) return;
200
+
201
+ ctx.save();
202
+ ctx.scale(dpr, dpr);
203
+ ctx.clearRect(0, 0, width, height);
204
+
205
+ // Frosted veil: slate-silver in light mode, obsidian in dark mode
206
+ ctx.fillStyle = isDark
207
+ ? 'rgba(12, 16, 22, 0.78)'
208
+ : 'rgba(92, 100, 114, 0.46)';
209
+ ctx.fillRect(0, 0, width, height);
210
+
211
+ // Instant hardware texture fill from single shared tile
212
+ const pattern = ctx.createPattern(tileCanvas, 'repeat');
213
+ if (pattern) {
214
+ ctx.fillStyle = pattern;
215
+ ctx.fillRect(0, 0, width, height);
216
+ }
217
+ ctx.restore();
218
+ };
219
+
220
+ spoilerEngine.subscribe(draw, shimmerSpeed);
221
+ return () => spoilerEngine.unsubscribe(draw);
222
+ }, [active, isBursting, isDark, shimmerSpeed]);
223
+
224
+ // Burst Dispersal on Click (lasts only ~300ms, then shuts down)
225
+ useEffect(() => {
226
+ if (!isBursting) return;
227
+ const canvas = canvasRef.current;
228
+ if (!canvas) return;
229
+ const ctx = canvas.getContext('2d');
230
+ if (!ctx) return;
231
+ const { width, height, dpr } = sizeRef.current;
232
+
233
+ const startTime = performance.now();
234
+ const duration = 280;
235
+ const originX = burstOrigin?.x ?? (width / 2);
236
+ const originY = burstOrigin?.y ?? (height / 2);
237
+
238
+ const burstParticles = [];
239
+ for (let i = 0; i < 70; i++) {
240
+ const angle = Math.random() * Math.PI * 2;
241
+ const speed = Math.random() * 8 + 3;
242
+ burstParticles.push({
243
+ x: originX + (Math.random() - 0.5) * 30,
244
+ y: originY + (Math.random() - 0.5) * 30,
245
+ vx: Math.cos(angle) * speed,
246
+ vy: Math.sin(angle) * speed,
247
+ size: Math.random() * 1.2 + 0.8,
248
+ alpha: 1,
249
+ });
250
+ }
251
+
252
+ const animateBurst = (now) => {
253
+ const progress = Math.min(1, (now - startTime) / duration);
254
+ const fade = 1 - progress;
255
+
256
+ ctx.save();
257
+ ctx.scale(dpr, dpr);
258
+ ctx.clearRect(0, 0, width, height);
259
+
260
+ // Fading veil
261
+ ctx.fillStyle = isDark
262
+ ? `rgba(12, 16, 22, ${0.78 * fade})`
263
+ : `rgba(92, 100, 114, ${0.46 * fade})`;
264
+ ctx.fillRect(0, 0, width, height);
265
+
266
+ // Outward radiating sparkles
267
+ for (const p of burstParticles) {
268
+ p.x += p.vx;
269
+ p.y += p.vy;
270
+ p.vx *= 0.94;
271
+ p.vy *= 0.94;
272
+ p.alpha = Math.max(0, p.alpha * 0.93);
273
+
274
+ ctx.beginPath();
275
+ ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
276
+ ctx.fillStyle = `rgba(255, 255, 255, ${p.alpha * fade})`;
277
+ ctx.fill();
278
+ }
279
+ ctx.restore();
280
+
281
+ if (progress < 1) {
282
+ animBurstRef.current = requestAnimationFrame(animateBurst);
283
+ } else {
284
+ if (onBurstComplete) onBurstComplete();
285
+ }
286
+ };
287
+
288
+ animBurstRef.current = requestAnimationFrame(animateBurst);
289
+ return () => {
290
+ if (animBurstRef.current) cancelAnimationFrame(animBurstRef.current);
291
+ };
292
+ }, [isBursting, burstOrigin, isDark]);
293
+
294
+ return (
295
+ <canvas
296
+ ref={canvasRef}
297
+ style={{
298
+ position: 'absolute',
299
+ inset: 0,
300
+ width: '100%',
301
+ height: '100%',
302
+ pointerEvents: 'none',
303
+ borderRadius: 'inherit',
304
+ zIndex: 2,
305
+ transition: 'opacity 0.25s ease',
306
+ }}
307
+ />
308
+ );
309
+ }
310
+
311
+ function getPlacementStyles(position) {
312
+ switch (position) {
313
+ case 'top':
314
+ return { alignItems: 'center', justifyContent: 'flex-start', paddingTop: 24 };
315
+ case 'top-left':
316
+ return { alignItems: 'flex-start', justifyContent: 'flex-start', padding: 20 };
317
+ case 'top-right':
318
+ return { alignItems: 'flex-end', justifyContent: 'flex-start', padding: 20 };
319
+ case 'bottom':
320
+ return { alignItems: 'center', justifyContent: 'flex-end', paddingBottom: 24 };
321
+ case 'bottom-left':
322
+ return { alignItems: 'flex-start', justifyContent: 'flex-end', padding: 20 };
323
+ case 'bottom-right':
324
+ return { alignItems: 'flex-end', justifyContent: 'flex-end', padding: 20 };
325
+ case 'center':
326
+ default:
327
+ return { alignItems: 'center', justifyContent: 'center' };
328
+ }
329
+ }
330
+
331
+ export default function PrivacyBlur({
332
+ active = false,
333
+ blur = 6,
334
+ spoiler = false,
335
+ shimmerSpeed,
336
+ showBadge = true,
337
+ showCountdown = false,
338
+ position = 'center',
339
+ icon,
340
+ badgeIcon,
341
+ countdownIcon,
342
+ text,
343
+ subtext,
344
+ revealable = false,
345
+ interactive,
346
+ revealDuration,
347
+ revealText = 'Показать',
348
+ hideText = 'Скрыть',
349
+ onReveal,
350
+ onHide,
351
+ style,
352
+ contentStyle,
353
+ className,
354
+ children,
355
+ }) {
356
+ const isDark = useIsDarkMode();
357
+ const isRevealable = Boolean(revealable || interactive);
358
+ const [tempRevealed, setTempRevealed] = useState(false);
359
+ const [timeLeft, setTimeLeft] = useState(0);
360
+ const [isBursting, setIsBursting] = useState(false);
361
+ const [burstOrigin, setBurstOrigin] = useState(null);
362
+
363
+ const containerRef = useRef(null);
364
+ const timerRef = useRef(null);
365
+
366
+ const clearTimer = () => {
367
+ if (timerRef.current) {
368
+ clearInterval(timerRef.current);
369
+ timerRef.current = null;
370
+ }
371
+ };
372
+
373
+ useEffect(() => {
374
+ if (!active) {
375
+ clearTimer();
376
+ setTempRevealed(false);
377
+ setIsBursting(false);
378
+ setTimeLeft(0);
379
+ }
380
+ }, [active]);
381
+
382
+ useEffect(() => {
383
+ return () => clearTimer();
384
+ }, []);
385
+
386
+ const finishReveal = () => {
387
+ const hasDuration = revealDuration !== undefined && revealDuration !== null && revealDuration !== false;
388
+ if (hasDuration) {
389
+ const duration = typeof revealDuration === 'number' && revealDuration > 0 ? revealDuration : 5;
390
+ clearTimer();
391
+ setTempRevealed(true);
392
+ setTimeLeft(duration);
393
+
394
+ timerRef.current = setInterval(() => {
395
+ setTimeLeft((prev) => {
396
+ if (prev <= 1) {
397
+ clearTimer();
398
+ setTempRevealed(false);
399
+ if (onHide) onHide();
400
+ return 0;
401
+ }
402
+ return prev - 1;
403
+ });
404
+ }, 1000);
405
+ } else {
406
+ if (onReveal) onReveal();
407
+ }
408
+ };
409
+
410
+ const handleReveal = (e) => {
411
+ if (e) e.stopPropagation();
412
+ if (!isRevealable || isBursting) return;
413
+
414
+ if (spoiler) {
415
+ let origin = null;
416
+ if (e && typeof e.clientX === 'number' && typeof e.clientY === 'number' && containerRef.current) {
417
+ const rect = containerRef.current.getBoundingClientRect();
418
+ origin = {
419
+ x: Math.max(0, Math.min(rect.width, e.clientX - rect.left)),
420
+ y: Math.max(0, Math.min(rect.height, e.clientY - rect.top)),
421
+ };
422
+ }
423
+ setBurstOrigin(origin);
424
+ setIsBursting(true);
425
+ } else {
426
+ finishReveal();
427
+ }
428
+ };
429
+
430
+ const handleBurstComplete = () => {
431
+ setIsBursting(false);
432
+ finishReveal();
433
+ };
434
+
435
+ const handleHideNow = (e) => {
436
+ if (e) e.stopPropagation();
437
+ clearTimer();
438
+ setTempRevealed(false);
439
+ setIsBursting(false);
440
+ setTimeLeft(0);
441
+ if (onHide) onHide();
442
+ };
443
+
444
+ const effectiveBadgeIcon = badgeIcon || icon;
445
+ const blurValue = typeof blur === 'number' ? `${blur}px` : blur;
446
+ const isBlurred = active && !tempRevealed;
447
+ const hasOverlay = showBadge && Boolean(text || effectiveBadgeIcon || isRevealable);
448
+ const placementStyles = getPlacementStyles(position);
449
+
450
+ return (
451
+ <div
452
+ ref={containerRef}
453
+ className={className}
454
+ onClick={isBlurred && isRevealable ? handleReveal : undefined}
455
+ style={{
456
+ position: 'relative',
457
+ width: '100%',
458
+ height: '100%',
459
+ minHeight: '100%',
460
+ display: 'flex',
461
+ flexDirection: 'column',
462
+ flex: 1,
463
+ overflow: 'hidden',
464
+ cursor: isBlurred && isRevealable ? 'pointer' : 'default',
465
+ ...style,
466
+ }}
467
+ >
468
+ <div
469
+ style={{
470
+ width: '100%',
471
+ height: '100%',
472
+ display: 'flex',
473
+ flexDirection: 'column',
474
+ flex: 1,
475
+ filter: isBlurred && !isBursting ? `blur(${blurValue})` : 'none',
476
+ userSelect: isBlurred ? 'none' : 'auto',
477
+ pointerEvents: isBlurred ? 'none' : 'auto',
478
+ transition: 'filter 0.3s ease, opacity 0.25s ease',
479
+ opacity: isBlurred ? (isBursting ? 0.9 : 0.6) : 1,
480
+ ...contentStyle,
481
+ }}
482
+ >
483
+ {children}
484
+ </div>
485
+
486
+ {spoiler && isBlurred && (
487
+ <SpoilerCanvas
488
+ active={isBlurred}
489
+ isBursting={isBursting}
490
+ burstOrigin={burstOrigin}
491
+ onBurstComplete={handleBurstComplete}
492
+ isDark={isDark}
493
+ shimmerSpeed={shimmerSpeed}
494
+ />
495
+ )}
496
+
497
+ {isBlurred && hasOverlay && (
498
+ <div
499
+ style={{
500
+ position: 'absolute',
501
+ inset: 0,
502
+ width: '100%',
503
+ height: '100%',
504
+ display: 'flex',
505
+ flexDirection: 'column',
506
+ gap: 6,
507
+ padding: 12,
508
+ boxSizing: 'border-box',
509
+ zIndex: 3,
510
+ pointerEvents: isRevealable ? 'auto' : 'none',
511
+ opacity: isBursting ? 0 : 1,
512
+ transition: 'opacity 0.2s ease',
513
+ ...placementStyles,
514
+ }}
515
+ >
516
+ <div
517
+ onClick={isRevealable ? handleReveal : undefined}
518
+ style={{
519
+ display: 'inline-flex',
520
+ alignItems: 'center',
521
+ gap: 8,
522
+ padding: '6px 14px',
523
+ borderRadius: 'var(--rads)',
524
+ background: 'var(--surface)',
525
+ border: '1px solid var(--border-light)',
526
+ boxShadow: 'var(--shadow)',
527
+ color: 'var(--primary-text)',
528
+ fontSize: '.76rem',
529
+ fontWeight: 600,
530
+ cursor: isRevealable ? 'pointer' : 'default',
531
+ backdropFilter: 'blur(8px)',
532
+ WebkitBackdropFilter: 'blur(8px)',
533
+ transition: 'all 0.2s ease',
534
+ maxWidth: '90%',
535
+ userSelect: 'none',
536
+ }}
537
+ >
538
+ <span style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, alignSelf: 'center' }}>
539
+ {effectiveBadgeIcon || <EyeOff size={14} style={{ color: 'var(--muted)' }} />}
540
+ </span>
541
+ {text && <span style={{ whiteSpace: 'normal', wordBreak: 'break-word', lineHeight: 1.35 }}>{text}</span>}
542
+ {isRevealable && (
543
+ <span style={{ fontSize: '.7rem', color: 'var(--accent)', textDecoration: 'underline', marginLeft: 4, flexShrink: 0, whiteSpace: 'nowrap', alignSelf: 'center' }}>
544
+ {revealText}
545
+ </span>
546
+ )}
547
+ </div>
548
+ {subtext && (
549
+ <span style={{ fontSize: '.68rem', color: 'var(--muted)', textAlign: 'center' }}>
550
+ {subtext}
551
+ </span>
552
+ )}
553
+ </div>
554
+ )}
555
+
556
+ {active && tempRevealed && showCountdown && (
557
+ <div
558
+ style={{
559
+ position: 'absolute',
560
+ top: 8,
561
+ right: 8,
562
+ display: 'inline-flex',
563
+ alignItems: 'center',
564
+ gap: 6,
565
+ padding: '3px 8px',
566
+ borderRadius: 'var(--rads)',
567
+ background: 'var(--surface)',
568
+ border: '1px solid var(--border-light)',
569
+ boxShadow: 'var(--shadow)',
570
+ fontSize: '.7rem',
571
+ fontWeight: 600,
572
+ color: 'var(--muted)',
573
+ zIndex: 4,
574
+ userSelect: 'none',
575
+ backdropFilter: 'blur(8px)',
576
+ WebkitBackdropFilter: 'blur(8px)',
577
+ }}
578
+ >
579
+ <span style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
580
+ {countdownIcon || <Eye size={12} style={{ color: 'var(--accent)' }} />}
581
+ </span>
582
+ <span style={{ whiteSpace: 'nowrap' }}>Скроется через {timeLeft}с</span>
583
+ <span
584
+ onClick={handleHideNow}
585
+ style={{
586
+ color: 'var(--accent)',
587
+ textDecoration: 'underline',
588
+ marginLeft: 4,
589
+ cursor: 'pointer',
590
+ flexShrink: 0,
591
+ whiteSpace: 'nowrap',
592
+ }}
593
+ >
594
+ {hideText}
595
+ </span>
596
+ </div>
597
+ )}
598
+ </div>
599
+ );
600
+ }
601
+
602
+ export { PrivacyBlur };
package/ui/index.cjs CHANGED
@@ -54,6 +54,7 @@ __export(index_exports, {
54
54
  Modal: () => Modal,
55
55
  PageShell: () => PageShell,
56
56
  Pagination: () => Pagination,
57
+ PrivacyBlur: () => PrivacyBlur,
57
58
  PulseDot: () => PulseDot,
58
59
  Select: () => Select,
59
60
  Sidebar: () => Sidebar,
@@ -131,6 +132,7 @@ var import_InfoBadge = __toESM(require("./components/InfoBadge.jsx"), 1);
131
132
  var import_Layout = __toESM(require("./components/Layout.jsx"), 1);
132
133
  var import_Sidebar = __toESM(require("./components/Sidebar.jsx"), 1);
133
134
  var import_LoginPage = __toESM(require("./components/LoginPage.jsx"), 1);
135
+ var import_PrivacyBlur = __toESM(require("./components/PrivacyBlur.jsx"), 1);
134
136
  const Layout = import_Layout.default;
135
137
  const Sidebar = import_Sidebar.default;
136
138
  const LoginPage = import_LoginPage.default;
@@ -192,3 +194,4 @@ const TableCardFooter = import_Card.TableCardFooter;
192
194
  const CardHdr = import_Card.CardHdr;
193
195
  const StatCard = import_Card.StatCard;
194
196
  const StatCardSkeleton = import_Card.StatCardSkeleton;
197
+ const PrivacyBlur = import_PrivacyBlur.default;
package/ui/index.js CHANGED
@@ -41,6 +41,7 @@ import { default as _InfoBadge } from './components/InfoBadge.jsx';
41
41
  import { default as _Layout } from './components/Layout.jsx';
42
42
  import { default as _Sidebar } from './components/Sidebar.jsx';
43
43
  import { default as _LoginPage } from './components/LoginPage.jsx';
44
+ import { default as _PrivacyBlur } from './components/PrivacyBlur.jsx';
44
45
 
45
46
  export const Layout = _Layout;
46
47
  export const Sidebar = _Sidebar;
@@ -103,3 +104,4 @@ export const TableCardFooter = _TableCardFooter;
103
104
  export const CardHdr = _CardHdr;
104
105
  export const StatCard = _StatCard;
105
106
  export const StatCardSkeleton = _StatCardSkeleton;
107
+ export const PrivacyBlur = _PrivacyBlur;
@@ -44,14 +44,18 @@ const toggle = () => {
44
44
  :style="{
45
45
  opacity: disabled ? 0.45 : 1,
46
46
  cursor: disabled ? 'not-allowed' : 'pointer',
47
+ verticalAlign: 'middle',
48
+ boxSizing: 'border-box',
47
49
  }"
48
50
  @click.prevent="toggle"
49
51
  >
50
52
  <span
51
- class="relative flex-shrink-0 transition-all duration-150 flex items-center justify-center"
53
+ class="relative flex-shrink-0 transition-all duration-150 flex items-center justify-center overflow-hidden"
52
54
  :style="{
53
55
  width: `${dims.w}px`,
54
56
  height: `${dims.h}px`,
57
+ boxSizing: 'border-box',
58
+ verticalAlign: 'middle',
55
59
  border: `1.5px solid ${isChecked || indeterminate ? 'var(--accent, #12675D)' : 'var(--border, #e2e8f0)'}`,
56
60
  borderRadius: size === 'sm' ? '3px' : '4px',
57
61
  background: isChecked || indeterminate ? 'var(--accent, #12675D)' : 'var(--input-bg, #ffffff)',
@@ -64,6 +68,7 @@ const toggle = () => {
64
68
  :height="dims.icon"
65
69
  viewBox="0 0 10 10"
66
70
  fill="none"
71
+ style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: block; pointer-events: none;"
67
72
  >
68
73
  <line x1="2" y1="5" x2="8" y2="5" stroke="white" stroke-width="1.6" stroke-linecap="round" />
69
74
  </svg>
@@ -75,6 +80,7 @@ const toggle = () => {
75
80
  :height="dims.icon"
76
81
  viewBox="0 0 10 10"
77
82
  fill="none"
83
+ style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: block; pointer-events: none;"
78
84
  >
79
85
  <polyline
80
86
  points="1.5,5 4,7.5 8.5,2.5"
@@ -88,8 +94,8 @@ const toggle = () => {
88
94
 
89
95
  <span
90
96
  v-if="label || $slots.default"
91
- :style="{ fontSize: size === 'sm' ? '.72rem' : '.78rem' }"
92
- class="text-slate-800 font-semibold"
97
+ :style="{ fontSize: size === 'sm' ? '.72rem' : '.78rem', lineHeight: '1.2' }"
98
+ class="text-[var(--primary-text,#0f172a)] font-semibold select-none"
93
99
  >
94
100
  <slot>{{ label }}</slot>
95
101
  </span>
@@ -278,9 +278,11 @@ const calcPos = () => {
278
278
 
279
279
  const handleWindowClick = (e: MouseEvent) => {
280
280
  if (!open.value) return;
281
- const target = e.target as Node;
281
+ const target = e.target as HTMLElement | null;
282
+ if (!target) return;
282
283
  if (wrapRef.value?.contains(target)) return;
283
284
  if (dropRef.value?.contains(target)) return;
285
+ if (target.closest?.(".cynx-timepicker-drop")) return;
284
286
  open.value = false;
285
287
  view.value = "day";
286
288
  };
@@ -5,8 +5,8 @@ const STATUS_COLORS: Record<string, string> = {
5
5
  DR: "var(--drive, #28C76F)",
6
6
  SB: "var(--break, #FFB200)",
7
7
  ON: "var(--shift, #0F60FF)",
8
- OFF: "#8B909A",
9
- PC: "#8B909A",
8
+ OFF: "var(--muted, #8B909A)",
9
+ PC: "var(--muted, #8B909A)",
10
10
  YM: "var(--shift, #0F60FF)",
11
11
  };
12
12
 
@@ -17,27 +17,33 @@ const props = withDefaults(
17
17
  width?: number | string;
18
18
  height?: number | string;
19
19
  radius?: number | string;
20
+ plain?: boolean;
20
21
  }>(),
21
22
  {
22
23
  status: "",
23
24
  width: 36,
24
25
  height: 20,
25
26
  radius: 6,
27
+ plain: false,
26
28
  }
27
29
  );
28
30
 
31
+ const normalizedKey = computed(() =>
32
+ (props.status || "").replace(/\s+/g, "_").toUpperCase().trim()
33
+ );
34
+
29
35
  const isPrimaryStatus = computed(() => {
30
36
  if (props.color) return true;
31
- const key = (props.status || "").toUpperCase().trim();
32
- return Boolean(STATUS_COLORS[key]);
37
+ return Boolean(STATUS_COLORS[normalizedKey.value]);
33
38
  });
34
39
 
35
- const bg = computed(() => {
40
+ const statusColor = computed(() => {
36
41
  if (props.color) return props.color;
37
- const key = (props.status || "").toUpperCase().trim();
38
- return STATUS_COLORS[key] || "transparent";
42
+ return STATUS_COLORS[normalizedKey.value] || "var(--muted, #8B909A)";
39
43
  });
40
44
 
45
+ const isShortStatus = computed(() => (props.status || "").trim().length <= 3);
46
+
41
47
  const boxWidth = computed(() =>
42
48
  typeof props.width === "number" ? `${props.width}px` : props.width
43
49
  );
@@ -51,20 +57,31 @@ const borderRadius = computed(() =>
51
57
 
52
58
  <template>
53
59
  <span
54
- v-if="status && isPrimaryStatus"
60
+ v-if="status && plain"
61
+ class="inline-flex items-center text-[11.5px] font-bold select-none whitespace-nowrap tracking-wide"
62
+ :style="{
63
+ color: statusColor,
64
+ }"
65
+ >
66
+ {{ status }}
67
+ </span>
68
+ <span
69
+ v-else-if="status && isPrimaryStatus"
55
70
  class="inline-flex items-center justify-center text-[11px] font-bold text-white tracking-wide select-none shadow-sm flex-shrink-0"
56
71
  :style="{
57
- width: boxWidth,
72
+ width: isShortStatus ? boxWidth : 'auto',
73
+ minWidth: boxWidth,
74
+ padding: isShortStatus ? '0' : '0 6px',
58
75
  height: boxHeight,
59
76
  borderRadius: borderRadius,
60
- backgroundColor: bg,
77
+ backgroundColor: statusColor,
61
78
  }"
62
79
  >
63
80
  {{ status }}
64
81
  </span>
65
82
  <span
66
83
  v-else-if="status"
67
- class="text-[12px] font-semibold text-[var(--primary-text,inherit)] select-none truncate"
84
+ class="text-[12px] font-semibold text-[var(--muted,#8B909A)] select-none truncate"
68
85
  >
69
86
  {{ status }}
70
87
  </span>
@@ -87,7 +87,7 @@ function emitTime() {
87
87
  }
88
88
 
89
89
  function selectHour(h: string) {
90
- activeTime.value = h;
90
+ activeTime.value.h = h;
91
91
  emitTime();
92
92
  }
93
93
 
@@ -125,7 +125,10 @@ const calcPos = () => {
125
125
  let top = r.bottom + 4;
126
126
  if (top + dropH > window.innerHeight - 12 && r.top - dropH - 4 > 12) {
127
127
  top = r.top - dropH - 4;
128
+ } else if (top + dropH > window.innerHeight - 12) {
129
+ top = Math.max(12, window.innerHeight - dropH - 12);
128
130
  }
131
+ if (top < 12) top = 12;
129
132
 
130
133
  pos.value = { top, left };
131
134
  };
@@ -224,6 +227,7 @@ onBeforeUnmount(() => {
224
227
  <div
225
228
  v-if="open"
226
229
  ref="dropRef"
230
+ class="cynx-timepicker-drop"
227
231
  style="
228
232
  position: fixed;
229
233
  z-index: 999999;