cynx-ui 1.3.8 → 1.3.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.
- package/components/DatePicker.jsx +2 -20
- package/components/Divider.jsx +96 -0
- package/index.js +2 -0
- package/package.json +1 -1
|
@@ -42,32 +42,15 @@ function isSameDay(a, b) {
|
|
|
42
42
|
}
|
|
43
43
|
function isToday(y, m, d) { const t = new Date(); return t.getFullYear()===y && t.getMonth()===m && t.getDate()===d; }
|
|
44
44
|
|
|
45
|
-
export function DatePicker({ value, onChange, label, placeholder = 'Select date', badges = {}, minDate, maxDate, disabled, showStepper = true, stepperPosition, style }) {
|
|
45
|
+
export function DatePicker({ value, onChange, label, placeholder = 'Select date', badges = {}, minDate, maxDate, disabled, showStepper = true, stepperPosition = 'around', style }) {
|
|
46
46
|
const [open, setOpen] = useState(false);
|
|
47
47
|
const [view, setView] = useState('day'); // 'day' | 'month' | 'year'
|
|
48
48
|
const [cursor, setCursor] = useState(() => toDate(value) || new Date());
|
|
49
49
|
const [pos, setPos] = useState({ top: 0, left: 0, width: 0 });
|
|
50
|
-
const [localStepperPos, setLocalStepperPos] = useState(() => {
|
|
51
|
-
return typeof window !== 'undefined' ? (localStorage.getItem('datepicker_stepper_position') || 'around') : 'around';
|
|
52
|
-
});
|
|
53
50
|
const ref = useRef(null);
|
|
54
51
|
const btnRef = useRef(null);
|
|
55
52
|
const dropRef = useRef(null);
|
|
56
53
|
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
function syncPos() {
|
|
59
|
-
if (typeof window !== 'undefined') {
|
|
60
|
-
setLocalStepperPos(localStorage.getItem('datepicker_stepper_position') || 'around');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
window.addEventListener('storage', syncPos);
|
|
64
|
-
window.addEventListener('datepicker-pos-changed', syncPos);
|
|
65
|
-
return () => {
|
|
66
|
-
window.removeEventListener('storage', syncPos);
|
|
67
|
-
window.removeEventListener('datepicker-pos-changed', syncPos);
|
|
68
|
-
};
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
54
|
const changeDay = (delta) => {
|
|
72
55
|
if (disabled) return;
|
|
73
56
|
const current = toDate(value) || new Date();
|
|
@@ -385,8 +368,7 @@ export function DatePicker({ value, onChange, label, placeholder = 'Select date'
|
|
|
385
368
|
</button>
|
|
386
369
|
);
|
|
387
370
|
|
|
388
|
-
const
|
|
389
|
-
const actualPos = stepperPosition || savedPos || 'around';
|
|
371
|
+
const actualPos = stepperPosition || 'around';
|
|
390
372
|
const showStepperEffective = showStepper && actualPos !== 'off';
|
|
391
373
|
const posMode = actualPos === 'left' || actualPos === 'start' ? 'left'
|
|
392
374
|
: actualPos === 'right' || actualPos === 'end' ? 'right'
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const SIZE_CONFIG = {
|
|
4
|
+
xs: { hMargin: '8px 0', vMargin: '0 4px', vHeight: '14px', fontSize: '.7rem', padding: '0 8px' },
|
|
5
|
+
sm: { hMargin: '12px 0', vMargin: '0 8px', vHeight: '18px', fontSize: '.75rem', padding: '0 10px' },
|
|
6
|
+
md: { hMargin: '16px 0', vMargin: '0 12px', vHeight: '24px', fontSize: '.82rem', padding: '0 12px' },
|
|
7
|
+
lg: { hMargin: '24px 0', vMargin: '0 16px', vHeight: '32px', fontSize: '.9rem', padding: '0 16px' },
|
|
8
|
+
xl: { hMargin: '32px 0', vMargin: '0 24px', vHeight: '48px', fontSize: '1rem', padding: '0 20px' },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default function Divider({
|
|
12
|
+
children,
|
|
13
|
+
label,
|
|
14
|
+
orientation = 'horizontal',
|
|
15
|
+
align = 'center',
|
|
16
|
+
size = 'md',
|
|
17
|
+
color = 'var(--border-light, #ebebf0)',
|
|
18
|
+
thickness = 1,
|
|
19
|
+
variant = 'solid',
|
|
20
|
+
style = {},
|
|
21
|
+
className = '',
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
const content = children || label;
|
|
25
|
+
const cfg = SIZE_CONFIG[size] || SIZE_CONFIG.md;
|
|
26
|
+
const thickStr = typeof thickness === 'number' ? `${thickness}px` : thickness;
|
|
27
|
+
const lineStyle = `${thickStr} ${variant} ${color}`;
|
|
28
|
+
|
|
29
|
+
if (orientation === 'vertical') {
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
className={`cynx-divider cynx-divider-vertical ${className}`}
|
|
33
|
+
style={{
|
|
34
|
+
display: 'inline-block',
|
|
35
|
+
width: 0,
|
|
36
|
+
height: style.height || cfg.vHeight,
|
|
37
|
+
margin: style.margin || cfg.vMargin,
|
|
38
|
+
borderLeft: lineStyle,
|
|
39
|
+
verticalAlign: 'middle',
|
|
40
|
+
alignSelf: 'center',
|
|
41
|
+
flexShrink: 0,
|
|
42
|
+
...style,
|
|
43
|
+
}}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Horizontal Divider
|
|
50
|
+
if (content) {
|
|
51
|
+
const leftFlex = align === 'left' ? '0 0 16px' : '1';
|
|
52
|
+
const rightFlex = align === 'right' ? '0 0 16px' : '1';
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div
|
|
56
|
+
className={`cynx-divider cynx-divider-horizontal ${className}`}
|
|
57
|
+
style={{
|
|
58
|
+
display: 'flex',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
width: '100%',
|
|
61
|
+
margin: style.margin || cfg.hMargin,
|
|
62
|
+
...style,
|
|
63
|
+
}}
|
|
64
|
+
{...props}
|
|
65
|
+
>
|
|
66
|
+
<div style={{ flex: leftFlex, borderBottom: lineStyle }} />
|
|
67
|
+
<span
|
|
68
|
+
style={{
|
|
69
|
+
padding: cfg.padding,
|
|
70
|
+
fontSize: cfg.fontSize,
|
|
71
|
+
color: 'var(--muted, #9b9daa)',
|
|
72
|
+
fontWeight: 500,
|
|
73
|
+
whiteSpace: 'nowrap',
|
|
74
|
+
lineHeight: 1,
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{content}
|
|
78
|
+
</span>
|
|
79
|
+
<div style={{ flex: rightFlex, borderBottom: lineStyle }} />
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
className={`cynx-divider cynx-divider-horizontal ${className}`}
|
|
87
|
+
style={{
|
|
88
|
+
width: '100%',
|
|
89
|
+
margin: style.margin || cfg.hMargin,
|
|
90
|
+
borderBottom: lineStyle,
|
|
91
|
+
...style,
|
|
92
|
+
}}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
}
|
package/index.js
CHANGED
|
@@ -38,9 +38,11 @@ import { XTable as _XTable, XThead as _XThead, XTbody as _XTbody, XTr as _XTr, X
|
|
|
38
38
|
import { PageShell as _PageShell, TableCard as _TableCard, TableCardFilters as _TableCardFilters, TableCardBody as _TableCardBody, TableCardFooter as _TableCardFooter, CardHdr as _CardHdr, StatCard as _StatCard, StatCardSkeleton as _StatCardSkeleton } from './components/Card.jsx';
|
|
39
39
|
|
|
40
40
|
import { default as _FilePicker } from './components/FilePicker.jsx';
|
|
41
|
+
import { default as _Divider } from './components/Divider.jsx';
|
|
41
42
|
|
|
42
43
|
export const Button = _Button;
|
|
43
44
|
export const FilePicker = _FilePicker;
|
|
45
|
+
export const Divider = _Divider;
|
|
44
46
|
export const Input = _Input;
|
|
45
47
|
export const Toggle = _Toggle;
|
|
46
48
|
export const Spinner = _Spinner || _SpinnerNamed;
|