cynx-ui 1.2.16 → 1.2.18

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.
@@ -1,156 +1,156 @@
1
- import { useRef, useEffect } from 'react';
2
-
3
- const STYLES = `
4
- @keyframes cx-tabSlide {
5
- from { opacity: 0; transform: scaleX(.8); }
6
- to { opacity: 1; transform: scaleX(1); }
7
- }
8
- `;
9
-
10
- let _id = 'cynx-tabbar-styles';
11
- function ensureStyles() {
12
- if (typeof document === 'undefined') return;
13
- if (document.getElementById(_id)) return;
14
- const tag = document.createElement('style');
15
- tag.id = _id;
16
- tag.textContent = STYLES;
17
- document.head.appendChild(tag);
18
- }
19
-
20
- if (typeof document !== 'undefined') ensureStyles();
21
-
22
- export default function TabBar({ tabs, active, onChange, capitalize = false, padding, variant = 'underline' }) {
23
- const barRef = useRef(null);
24
- const indRef = useRef(null);
25
- const initDone = useRef(false);
26
-
27
- // Underline indicator positioning
28
- useEffect(() => {
29
- if (variant !== 'underline') return;
30
- const bar = barRef.current;
31
- const ind = indRef.current;
32
- if (!bar || !ind) return;
33
-
34
- const activeBtn = bar.querySelector(`[data-tabid="${active}"]`);
35
- if (!activeBtn) return;
36
-
37
- const barRect = bar.getBoundingClientRect();
38
- const btnRect = activeBtn.getBoundingClientRect();
39
- const x = btnRect.left - barRect.left;
40
- const w = btnRect.width;
41
-
42
- if (!initDone.current) {
43
- ind.style.transition = 'none';
44
- ind.style.width = w + 'px';
45
- ind.style.transform = `translateX(${x}px)`;
46
- requestAnimationFrame(() => { ind.style.transition = ''; });
47
- initDone.current = true;
48
- } else {
49
- ind.style.width = w + 'px';
50
- ind.style.transform = `translateX(${x}px)`;
51
- }
52
- }, [active, tabs, variant]);
53
-
54
- if (variant === 'pill') {
55
- return (
56
- <div style={{
57
- display: 'inline-flex', gap: 3,
58
- background: 'var(--grey-1, #f5f5f8)',
59
- borderRadius: 'var(--radxs, 6px)',
60
- padding: '3px',
61
- border: '1px solid var(--border-light, #ebebf0)',
62
- }}>
63
- {tabs.map(t => {
64
- const isActive = active === t.id;
65
- return (
66
- <button
67
- key={t.id}
68
- data-tabid={t.id}
69
- onClick={() => onChange(t.id)}
70
- style={{
71
- display: 'flex', alignItems: 'center', gap: 5,
72
- padding: padding || '5px 12px',
73
- border: 'none',
74
- borderRadius: 'var(--radxs, 6px)',
75
- background: isActive ? '#fff' : 'transparent',
76
- boxShadow: isActive ? '0 1px 2px rgba(0,0,0,.06)' : 'none',
77
- fontSize: '.75rem', fontWeight: isActive ? 600 : 500,
78
- color: isActive ? 'var(--primary-text, #0f111c)' : 'var(--muted, #9b9daa)',
79
- cursor: 'pointer',
80
- transition: 'all .18s ease',
81
- fontFamily: 'inherit',
82
- whiteSpace: 'nowrap',
83
- textTransform: capitalize ? 'capitalize' : 'none',
84
- }}
85
- >
86
- {t.icon}{t.label}
87
- {t.count != null && t.count > 0 && (
88
- <span style={{
89
- background: isActive ? 'var(--accent-bg)' : 'var(--grey-2, #d7d8e0)',
90
- color: isActive ? 'var(--accent)' : 'var(--muted)',
91
- borderRadius: 10,
92
- padding: '1px 6px',
93
- fontSize: '.68rem',
94
- fontWeight: 600,
95
- }}>{t.count}</span>
96
- )}
97
- </button>
98
- );
99
- })}
100
- </div>
101
- );
102
- }
103
-
104
- // Default: underline variant
105
- const defaultPadding = padding || '10px 16px';
106
-
107
- return (
108
- <div ref={barRef} style={{ display:'flex', position:'relative' }}>
109
- <div ref={indRef} style={{
110
- position:'absolute', bottom:'-1px', left:0,
111
- height:2, width:0,
112
- background:'var(--accent)',
113
- borderRadius:'2px 2px 0 0',
114
- transition:'transform .22s cubic-bezier(.4,0,.2,1), width .22s cubic-bezier(.4,0,.2,1)',
115
- pointerEvents:'none', zIndex:2,
116
- }} />
117
-
118
- {tabs.map(t => {
119
- const isActive = active === t.id;
120
- return (
121
- <button
122
- key={t.id}
123
- data-tabid={t.id}
124
- onClick={() => onChange(t.id)}
125
- style={{
126
- display:'flex', alignItems:'center', gap:6,
127
- padding: defaultPadding,
128
- border:'none', background:'none',
129
- fontSize:'.82rem', fontWeight:500,
130
- color: isActive ? 'var(--accent)' : 'var(--muted)',
131
- cursor:'pointer',
132
- transition:'color .18s',
133
- marginBottom:'-1px',
134
- position:'relative', zIndex:1,
135
- fontFamily:'inherit',
136
- whiteSpace:'nowrap',
137
- textTransform: capitalize ? 'capitalize' : 'none',
138
- }}
139
- >
140
- {t.icon}{t.label}
141
- {t.count != null && t.count > 0 && (
142
- <span style={{
143
- background: isActive ? 'var(--accent-bg)' : 'var(--grey-1)',
144
- color: isActive ? 'var(--accent)' : 'var(--muted)',
145
- borderRadius: 10,
146
- padding: '1px 6px',
147
- fontSize: '.68rem',
148
- transition: 'background .18s, color .18s',
149
- }}>{t.count}</span>
150
- )}
151
- </button>
152
- );
153
- })}
154
- </div>
155
- );
156
- }
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ const STYLES = `
4
+ @keyframes cx-tabSlide {
5
+ from { opacity: 0; transform: scaleX(.8); }
6
+ to { opacity: 1; transform: scaleX(1); }
7
+ }
8
+ `;
9
+
10
+ let _id = 'cynx-tabbar-styles';
11
+ function ensureStyles() {
12
+ if (typeof document === 'undefined') return;
13
+ if (document.getElementById(_id)) return;
14
+ const tag = document.createElement('style');
15
+ tag.id = _id;
16
+ tag.textContent = STYLES;
17
+ document.head.appendChild(tag);
18
+ }
19
+
20
+ if (typeof document !== 'undefined') ensureStyles();
21
+
22
+ export default function TabBar({ tabs, active, onChange, capitalize = false, padding, variant = 'underline' }) {
23
+ const barRef = useRef(null);
24
+ const indRef = useRef(null);
25
+ const initDone = useRef(false);
26
+
27
+ // Underline indicator positioning
28
+ useEffect(() => {
29
+ if (variant !== 'underline') return;
30
+ const bar = barRef.current;
31
+ const ind = indRef.current;
32
+ if (!bar || !ind) return;
33
+
34
+ const activeBtn = bar.querySelector(`[data-tabid="${active}"]`);
35
+ if (!activeBtn) return;
36
+
37
+ const barRect = bar.getBoundingClientRect();
38
+ const btnRect = activeBtn.getBoundingClientRect();
39
+ const x = btnRect.left - barRect.left;
40
+ const w = btnRect.width;
41
+
42
+ if (!initDone.current) {
43
+ ind.style.transition = 'none';
44
+ ind.style.width = w + 'px';
45
+ ind.style.transform = `translateX(${x}px)`;
46
+ requestAnimationFrame(() => { ind.style.transition = ''; });
47
+ initDone.current = true;
48
+ } else {
49
+ ind.style.width = w + 'px';
50
+ ind.style.transform = `translateX(${x}px)`;
51
+ }
52
+ }, [active, tabs, variant]);
53
+
54
+ if (variant === 'pill') {
55
+ return (
56
+ <div style={{
57
+ display: 'inline-flex', gap: 3,
58
+ background: 'var(--grey-1, #f5f5f8)',
59
+ borderRadius: 'var(--radxs, 6px)',
60
+ padding: '3px',
61
+ border: '1px solid var(--border-light, #ebebf0)',
62
+ }}>
63
+ {tabs.map(t => {
64
+ const isActive = active === t.id;
65
+ return (
66
+ <button
67
+ key={t.id}
68
+ data-tabid={t.id}
69
+ onClick={() => onChange(t.id)}
70
+ style={{
71
+ display: 'flex', alignItems: 'center', gap: 5,
72
+ padding: padding || '5px 12px',
73
+ border: 'none',
74
+ borderRadius: 'var(--radxs, 6px)',
75
+ background: isActive ? '#fff' : 'transparent',
76
+ boxShadow: isActive ? '0 1px 2px rgba(0,0,0,.06)' : 'none',
77
+ fontSize: '.75rem', fontWeight: isActive ? 600 : 500,
78
+ color: isActive ? 'var(--primary-text, #0f111c)' : 'var(--muted, #9b9daa)',
79
+ cursor: 'pointer',
80
+ transition: 'all .18s ease',
81
+ fontFamily: 'inherit',
82
+ whiteSpace: 'nowrap',
83
+ textTransform: capitalize ? 'capitalize' : 'none',
84
+ }}
85
+ >
86
+ {t.icon}{t.label}
87
+ {t.count != null && t.count > 0 && (
88
+ <span style={{
89
+ background: isActive ? 'var(--accent-bg)' : 'var(--grey-2, #d7d8e0)',
90
+ color: isActive ? 'var(--accent)' : 'var(--muted)',
91
+ borderRadius: 10,
92
+ padding: '1px 6px',
93
+ fontSize: '.68rem',
94
+ fontWeight: 600,
95
+ }}>{t.count}</span>
96
+ )}
97
+ </button>
98
+ );
99
+ })}
100
+ </div>
101
+ );
102
+ }
103
+
104
+ // Default: underline variant
105
+ const defaultPadding = padding || '10px 16px';
106
+
107
+ return (
108
+ <div ref={barRef} style={{ display:'flex', position:'relative' }}>
109
+ <div ref={indRef} style={{
110
+ position:'absolute', bottom:'-1px', left:0,
111
+ height:2, width:0,
112
+ background:'var(--accent)',
113
+ borderRadius:'2px 2px 0 0',
114
+ transition:'transform .22s cubic-bezier(.4,0,.2,1), width .22s cubic-bezier(.4,0,.2,1)',
115
+ pointerEvents:'none', zIndex:2,
116
+ }} />
117
+
118
+ {tabs.map(t => {
119
+ const isActive = active === t.id;
120
+ return (
121
+ <button
122
+ key={t.id}
123
+ data-tabid={t.id}
124
+ onClick={() => onChange(t.id)}
125
+ style={{
126
+ display:'flex', alignItems:'center', gap:6,
127
+ padding: defaultPadding,
128
+ border:'none', background:'none',
129
+ fontSize:'.82rem', fontWeight:500,
130
+ color: isActive ? 'var(--accent)' : 'var(--muted)',
131
+ cursor:'pointer',
132
+ transition:'color .18s',
133
+ marginBottom:'-1px',
134
+ position:'relative', zIndex:1,
135
+ fontFamily:'inherit',
136
+ whiteSpace:'nowrap',
137
+ textTransform: capitalize ? 'capitalize' : 'none',
138
+ }}
139
+ >
140
+ {t.icon}{t.label}
141
+ {t.count != null && t.count > 0 && (
142
+ <span style={{
143
+ background: isActive ? 'var(--accent-bg)' : 'var(--grey-1)',
144
+ color: isActive ? 'var(--accent)' : 'var(--muted)',
145
+ borderRadius: 10,
146
+ padding: '1px 6px',
147
+ fontSize: '.68rem',
148
+ transition: 'background .18s, color .18s',
149
+ }}>{t.count}</span>
150
+ )}
151
+ </button>
152
+ );
153
+ })}
154
+ </div>
155
+ );
156
+ }
@@ -1,16 +1,16 @@
1
- export function Tabs({ tabs, value, onChange, style }) {
2
- return (
3
- <div className="xtabs" style={style}>
4
- {tabs.map(t => {
5
- const label = typeof t === 'string' ? t : t.label;
6
- const key = typeof t === 'string' ? t : t.value;
7
- const active = key === value;
8
- return (
9
- <button key={key} className={`xtab${active ? ' active' : ''}`} onClick={() => onChange(key)}>
10
- {label}
11
- </button>
12
- );
13
- })}
14
- </div>
15
- );
16
- }
1
+ export function Tabs({ tabs, value, onChange, style }) {
2
+ return (
3
+ <div className="xtabs" style={style}>
4
+ {tabs.map(t => {
5
+ const label = typeof t === 'string' ? t : t.label;
6
+ const key = typeof t === 'string' ? t : t.value;
7
+ const active = key === value;
8
+ return (
9
+ <button key={key} className={`xtab${active ? ' active' : ''}`} onClick={() => onChange(key)}>
10
+ {label}
11
+ </button>
12
+ );
13
+ })}
14
+ </div>
15
+ );
16
+ }
@@ -1,88 +1,88 @@
1
- import { useState, useEffect, useCallback } from 'react';
2
- import { createPortal } from 'react-dom';
3
-
4
- const STYLES = `
5
- #toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 99999; }
6
- .toast {
7
- background: var(--surface, #fff); border: 1px solid var(--border, #d7d8e0);
8
- border-radius: var(--rads, 8px); padding: 10px 14px;
9
- font-size: .78rem; display: flex; align-items: center; gap: 8px;
10
- box-shadow: 0px 40px 100px 0px rgba(0,0,0,.15); max-width: 300px;
11
- color: var(--primary-text, #0f111c); font-weight: 500;
12
- animation: cx-toastSlide .18s ease;
13
- cursor: pointer;
14
- }
15
- .toast.ok { border-left: 3px solid var(--success, #27ae60); }
16
- .toast.err { border-left: 3px solid var(--danger, #f64747); }
17
- @keyframes cx-toastSlide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
18
- `;
19
-
20
- let _id = 'cynx-toast-styles';
21
- function ensureStyles() {
22
- if (typeof document === 'undefined') return;
23
- if (document.getElementById(_id)) return;
24
- const tag = document.createElement('style');
25
- tag.id = _id;
26
- tag.textContent = STYLES;
27
- document.head.appendChild(tag);
28
- }
29
-
30
- // Auto-inject on module load
31
- if (typeof document !== 'undefined') ensureStyles();
32
-
33
- // ── Module-level state ────────────────────────────────────────────────────────
34
- let _toasts = [];
35
- let _listeners = new Set();
36
-
37
- function notify() {
38
- const snapshot = [..._toasts];
39
- _listeners.forEach(fn => fn(snapshot));
40
- }
41
-
42
- // Global toast — call from anywhere, no hook needed
43
- export function toast(msg, type = 'ok') {
44
- ensureStyles();
45
- const id = Date.now() + Math.random();
46
- _toasts = [..._toasts, { id, msg, type }];
47
- notify();
48
- setTimeout(() => {
49
- _toasts = _toasts.filter(t => t.id !== id);
50
- notify();
51
- }, 3500);
52
- }
53
-
54
- // ── Hook — for components that want reactive state ────────────────────────────
55
- export function useToast() {
56
- const [toasts, setToasts] = useState(_toasts);
57
-
58
- useEffect(() => {
59
- _listeners.add(setToasts);
60
- return () => _listeners.delete(setToasts);
61
- }, []);
62
-
63
- const remove = useCallback(id => {
64
- _toasts = _toasts.filter(t => t.id !== id);
65
- notify();
66
- }, []);
67
-
68
- return { toasts, toast, remove };
69
- }
70
-
71
- // ── Render component ──────────────────────────────────────────────────────────
72
- export function Toast({ toasts, remove }) {
73
- ensureStyles();
74
- return createPortal(
75
- <div id="toast-root">
76
- {toasts.map(t => (
77
- <div key={t.id} className={`toast ${t.type}`} onClick={() => remove(t.id)}>
78
- {t.type === 'ok'
79
- ? <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--success)" strokeWidth="2.5" strokeLinecap="round"><polyline points="20 6 9 17 4 12"/></svg>
80
- : <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--danger)" strokeWidth="2.5" strokeLinecap="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
81
- }
82
- {t.msg}
83
- </div>
84
- ))}
85
- </div>,
86
- document.body
87
- );
88
- }
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+
4
+ const STYLES = `
5
+ #toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 99999; }
6
+ .toast {
7
+ background: var(--surface, #fff); border: 1px solid var(--border, #d7d8e0);
8
+ border-radius: var(--rads, 8px); padding: 10px 14px;
9
+ font-size: .78rem; display: flex; align-items: center; gap: 8px;
10
+ box-shadow: 0px 40px 100px 0px rgba(0,0,0,.15); max-width: 300px;
11
+ color: var(--primary-text, #0f111c); font-weight: 500;
12
+ animation: cx-toastSlide .18s ease;
13
+ cursor: pointer;
14
+ }
15
+ .toast.ok { border-left: 3px solid var(--success, #27ae60); }
16
+ .toast.err { border-left: 3px solid var(--danger, #f64747); }
17
+ @keyframes cx-toastSlide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
18
+ `;
19
+
20
+ let _id = 'cynx-toast-styles';
21
+ function ensureStyles() {
22
+ if (typeof document === 'undefined') return;
23
+ if (document.getElementById(_id)) return;
24
+ const tag = document.createElement('style');
25
+ tag.id = _id;
26
+ tag.textContent = STYLES;
27
+ document.head.appendChild(tag);
28
+ }
29
+
30
+ // Auto-inject on module load
31
+ if (typeof document !== 'undefined') ensureStyles();
32
+
33
+ // ── Module-level state ────────────────────────────────────────────────────────
34
+ let _toasts = [];
35
+ let _listeners = new Set();
36
+
37
+ function notify() {
38
+ const snapshot = [..._toasts];
39
+ _listeners.forEach(fn => fn(snapshot));
40
+ }
41
+
42
+ // Global toast — call from anywhere, no hook needed
43
+ export function toast(msg, type = 'ok') {
44
+ ensureStyles();
45
+ const id = Date.now() + Math.random();
46
+ _toasts = [..._toasts, { id, msg, type }];
47
+ notify();
48
+ setTimeout(() => {
49
+ _toasts = _toasts.filter(t => t.id !== id);
50
+ notify();
51
+ }, 3500);
52
+ }
53
+
54
+ // ── Hook — for components that want reactive state ────────────────────────────
55
+ export function useToast() {
56
+ const [toasts, setToasts] = useState(_toasts);
57
+
58
+ useEffect(() => {
59
+ _listeners.add(setToasts);
60
+ return () => _listeners.delete(setToasts);
61
+ }, []);
62
+
63
+ const remove = useCallback(id => {
64
+ _toasts = _toasts.filter(t => t.id !== id);
65
+ notify();
66
+ }, []);
67
+
68
+ return { toasts, toast, remove };
69
+ }
70
+
71
+ // ── Render component ──────────────────────────────────────────────────────────
72
+ export function Toast({ toasts, remove }) {
73
+ ensureStyles();
74
+ return createPortal(
75
+ <div id="toast-root">
76
+ {toasts.map(t => (
77
+ <div key={t.id} className={`toast ${t.type}`} onClick={() => remove(t.id)}>
78
+ {t.type === 'ok'
79
+ ? <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--success)" strokeWidth="2.5" strokeLinecap="round"><polyline points="20 6 9 17 4 12"/></svg>
80
+ : <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="var(--danger)" strokeWidth="2.5" strokeLinecap="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
81
+ }
82
+ {t.msg}
83
+ </div>
84
+ ))}
85
+ </div>,
86
+ document.body
87
+ );
88
+ }
@@ -1,67 +1,67 @@
1
- const SIZES = {
2
- sm: { w: 28, h: 16, r: 8, dot: 12, off: 2, on: 14 },
3
- md: { w: 34, h: 18, r: 9, dot: 14, off: 2, on: 18 },
4
- lg: { w: 44, h: 24, r: 12, dot: 18, off: 3, on: 23 },
5
- };
6
-
7
- const COLORS = {
8
- primary: '#f99e2c',
9
- success: '#27ae60',
10
- warning: '#f59e0b',
11
- danger: '#f64747',
12
- };
13
-
14
- const OFF_COLOR = '#d7d8e0';
15
-
16
- export default function Toggle({
17
- checked = false,
18
- onChange,
19
- disabled = false,
20
- size = 'md',
21
- color = 'primary',
22
- label = null,
23
- labelStyle = {},
24
- onClick = null,
25
- className = '',
26
- style = {},
27
- }) {
28
- const s = SIZES[size] || SIZES.md;
29
- const trackBg = checked ? (COLORS[color] || COLORS.primary) : OFF_COLOR;
30
-
31
- return (
32
- <label
33
- className={className}
34
- style={{
35
- display:'inline-flex', alignItems:'center', gap:8,
36
- cursor: disabled ? 'not-allowed' : 'pointer',
37
- userSelect:'none', opacity: disabled ? .4 : 1,
38
- ...style,
39
- }}
40
- onClick={onClick}
41
- >
42
- <input type="checkbox" checked={checked} disabled={disabled}
43
- onChange={e => onChange?.(e.target.checked)}
44
- style={{ position:'absolute', opacity:0, width:0, height:0 }} />
45
- <span style={{
46
- position:'relative', width: s.w, height: s.h, borderRadius: s.r,
47
- background: trackBg, flexShrink: 0,
48
- transition: 'background .25s ease',
49
- boxShadow: '0 1px 3px rgba(20,22,41,.1)',
50
- }}>
51
- <span style={{
52
- position:'absolute', top:'50%',
53
- transform: checked
54
- ? 'translateY(-50%) scale(1)'
55
- : 'translateY(-50%) scale(1)',
56
- left: checked ? s.on : s.off,
57
- width: s.dot, height: s.dot,
58
- background: '#fff', borderRadius: '50%',
59
- boxShadow: '0 1px 3px rgba(0,0,0,.25)',
60
- transition: 'left .3s cubic-bezier(.34,1.56,.64,1), transform .2s ease',
61
- willChange: 'left',
62
- }} />
63
- </span>
64
- {label && <span style={labelStyle}>{label}</span>}
65
- </label>
66
- );
67
- }
1
+ const SIZES = {
2
+ sm: { w: 28, h: 16, r: 8, dot: 12, off: 2, on: 14 },
3
+ md: { w: 34, h: 18, r: 9, dot: 14, off: 2, on: 18 },
4
+ lg: { w: 44, h: 24, r: 12, dot: 18, off: 3, on: 23 },
5
+ };
6
+
7
+ const COLORS = {
8
+ primary: '#f99e2c',
9
+ success: '#27ae60',
10
+ warning: '#f59e0b',
11
+ danger: '#f64747',
12
+ };
13
+
14
+ const OFF_COLOR = '#d7d8e0';
15
+
16
+ export default function Toggle({
17
+ checked = false,
18
+ onChange,
19
+ disabled = false,
20
+ size = 'md',
21
+ color = 'primary',
22
+ label = null,
23
+ labelStyle = {},
24
+ onClick = null,
25
+ className = '',
26
+ style = {},
27
+ }) {
28
+ const s = SIZES[size] || SIZES.md;
29
+ const trackBg = checked ? (COLORS[color] || COLORS.primary) : OFF_COLOR;
30
+
31
+ return (
32
+ <label
33
+ className={className}
34
+ style={{
35
+ display:'inline-flex', alignItems:'center', gap:8,
36
+ cursor: disabled ? 'not-allowed' : 'pointer',
37
+ userSelect:'none', opacity: disabled ? .4 : 1,
38
+ ...style,
39
+ }}
40
+ onClick={onClick}
41
+ >
42
+ <input type="checkbox" checked={checked} disabled={disabled}
43
+ onChange={e => onChange?.(e.target.checked)}
44
+ style={{ position:'absolute', opacity:0, width:0, height:0 }} />
45
+ <span style={{
46
+ position:'relative', width: s.w, height: s.h, borderRadius: s.r,
47
+ background: trackBg, flexShrink: 0,
48
+ transition: 'background .25s ease',
49
+ boxShadow: '0 1px 3px rgba(20,22,41,.1)',
50
+ }}>
51
+ <span style={{
52
+ position:'absolute', top:'50%',
53
+ transform: checked
54
+ ? 'translateY(-50%) scale(1)'
55
+ : 'translateY(-50%) scale(1)',
56
+ left: checked ? s.on : s.off,
57
+ width: s.dot, height: s.dot,
58
+ background: '#fff', borderRadius: '50%',
59
+ boxShadow: '0 1px 3px rgba(0,0,0,.25)',
60
+ transition: 'left .3s cubic-bezier(.34,1.56,.64,1), transform .2s ease',
61
+ willChange: 'left',
62
+ }} />
63
+ </span>
64
+ {label && <span style={labelStyle}>{label}</span>}
65
+ </label>
66
+ );
67
+ }