@efolusi/meridian 1.6.0 → 1.8.0
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/ai/Conversation.js +2 -1
- package/ai/Player.js +18 -1
- package/ai/SelectionQuote.js +2 -1
- package/ai/Transcript.js +2 -1
- package/ai/UsageMeter.js +2 -2
- package/code/Console.js +4 -1
- package/code/Terminal.js +2 -0
- package/components.css +69 -2
- package/dates/Calendar.d.ts +18 -2
- package/dates/Calendar.js +44 -15
- package/dates/DateRangePicker.d.ts +21 -0
- package/dates/DateRangePicker.js +148 -0
- package/dates/TimePicker.d.ts +25 -0
- package/dates/TimePicker.js +205 -0
- package/display/AspectRatio.js +1 -1
- package/display/Avatar.js +12 -3
- package/display/Carousel.js +2 -1
- package/display/Tag.js +30 -7
- package/feedback/Progress.js +4 -1
- package/feedback/Tooltip.js +2 -1
- package/forms/Button.js +15 -0
- package/forms/FormField.d.ts +43 -0
- package/forms/FormField.js +92 -1
- package/forms/NumberInput.d.ts +39 -0
- package/forms/NumberInput.js +177 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/navigation/Menubar.js +4 -1
- package/navigation/Tabs.js +2 -2
- package/overlay/ContextMenu.js +2 -1
- package/overlay/HoverCard.js +11 -0
- package/overlay/Portal.js +3 -2
- package/package.json +3 -1
- package/tailwind.preset.cjs +125 -0
- package/tokens.json +622 -0
package/ai/Conversation.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { prefersReducedMotion } from "../forms/Button.js";
|
|
4
5
|
import { Icon } from "../icons/Icon.js";
|
|
5
6
|
export const Conversation = /*#__PURE__*/React.forwardRef(function Conversation({
|
|
6
7
|
height = 420,
|
|
@@ -27,7 +28,7 @@ export const Conversation = /*#__PURE__*/React.forwardRef(function Conversation(
|
|
|
27
28
|
const v = viewport.current;
|
|
28
29
|
if (v) v.scrollTo({
|
|
29
30
|
top: v.scrollHeight,
|
|
30
|
-
behavior: behavior || 'smooth'
|
|
31
|
+
behavior: prefersReducedMotion() ? 'auto' : behavior || 'smooth'
|
|
31
32
|
});
|
|
32
33
|
};
|
|
33
34
|
React.useEffect(() => {
|
package/ai/Player.js
CHANGED
|
@@ -128,10 +128,27 @@ export const Player = /*#__PURE__*/React.forwardRef(function Player({
|
|
|
128
128
|
className: "ef-player__wave",
|
|
129
129
|
role: "slider",
|
|
130
130
|
"aria-label": "Seek",
|
|
131
|
+
tabIndex: 0,
|
|
131
132
|
"aria-valuemin": 0,
|
|
132
133
|
"aria-valuemax": Math.round(dur),
|
|
133
134
|
"aria-valuenow": Math.round(t),
|
|
134
|
-
|
|
135
|
+
"aria-valuetext": `${formatTime(t, dur)} of ${formatTime(dur)}`,
|
|
136
|
+
onPointerDown: onPointerDown,
|
|
137
|
+
onKeyDown: e => {
|
|
138
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowUp') {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
jumpTo(t + 5);
|
|
141
|
+
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
jumpTo(t - 5);
|
|
144
|
+
} else if (e.key === 'Home') {
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
jumpTo(0);
|
|
147
|
+
} else if (e.key === 'End') {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
jumpTo(dur);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
135
152
|
}, bars.map((p, i) => /*#__PURE__*/React.createElement("span", {
|
|
136
153
|
key: i,
|
|
137
154
|
className: `ef-player__bar${!dur && playing ? ' ef-player__bar--loading' : (i + 0.5) / bars.length <= ratio ? ' ef-player__bar--played' : ''}`,
|
package/ai/SelectionQuote.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { useIsoLayoutEffect } from "../forms/Button.js";
|
|
4
5
|
import { Icon } from "../icons/Icon.js";
|
|
5
6
|
export function SelectionQuote({
|
|
6
7
|
children,
|
|
@@ -63,7 +64,7 @@ export function SelectionQuote({
|
|
|
63
64
|
document.removeEventListener('keydown', key);
|
|
64
65
|
};
|
|
65
66
|
}, []);
|
|
66
|
-
|
|
67
|
+
useIsoLayoutEffect(() => {
|
|
67
68
|
if (!sel || !barRef.current || !contRef.current) return;
|
|
68
69
|
const bar = barRef.current.getBoundingClientRect();
|
|
69
70
|
const cont = contRef.current.getBoundingClientRect();
|
package/ai/Transcript.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { prefersReducedMotion } from "../forms/Button.js";
|
|
4
5
|
import { formatTime } from "./Player.js";
|
|
5
6
|
export function Transcript({
|
|
6
7
|
title = 'Transcript',
|
|
@@ -32,7 +33,7 @@ export function Transcript({
|
|
|
32
33
|
const target = row.offsetTop - v.clientHeight / 2 + row.offsetHeight / 2;
|
|
33
34
|
v.scrollTo({
|
|
34
35
|
top: Math.max(0, target),
|
|
35
|
-
behavior: 'smooth'
|
|
36
|
+
behavior: prefersReducedMotion() ? 'auto' : 'smooth'
|
|
36
37
|
});
|
|
37
38
|
}, [active, auto]);
|
|
38
39
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
package/ai/UsageMeter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { cssPct } from "../forms/Button.js";
|
|
4
|
+
import { cssPct, prefersReducedMotion } from "../forms/Button.js";
|
|
5
5
|
export function UsageMeter({
|
|
6
6
|
used = 0,
|
|
7
7
|
limit = 100,
|
|
@@ -18,7 +18,7 @@ export function UsageMeter({
|
|
|
18
18
|
}) {
|
|
19
19
|
const [shown, setShown] = React.useState(animated ? 0 : used);
|
|
20
20
|
React.useEffect(() => {
|
|
21
|
-
if (!animated) {
|
|
21
|
+
if (!animated || prefersReducedMotion()) {
|
|
22
22
|
setShown(used);
|
|
23
23
|
return;
|
|
24
24
|
}
|
package/code/Console.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { prefersReducedMotion } from "../forms/Button.js";
|
|
4
5
|
import { Icon } from "../icons/Icon.js";
|
|
5
6
|
const GLYPH = {
|
|
6
7
|
info: 'info',
|
|
@@ -79,6 +80,8 @@ export function Console({
|
|
|
79
80
|
}, entries.length, " entries")), /*#__PURE__*/React.createElement("div", {
|
|
80
81
|
ref: viewport,
|
|
81
82
|
className: "ef-console__scroll",
|
|
83
|
+
role: "log",
|
|
84
|
+
"aria-live": "polite",
|
|
82
85
|
style: {
|
|
83
86
|
height
|
|
84
87
|
},
|
|
@@ -93,7 +96,7 @@ export function Console({
|
|
|
93
96
|
const v = viewport.current;
|
|
94
97
|
if (v) v.scrollTo({
|
|
95
98
|
top: v.scrollHeight,
|
|
96
|
-
behavior: 'smooth'
|
|
99
|
+
behavior: prefersReducedMotion() ? 'auto' : 'smooth'
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
102
|
}, /*#__PURE__*/React.createElement(Icon, {
|
package/code/Terminal.js
CHANGED
package/components.css
CHANGED
|
@@ -161,7 +161,8 @@
|
|
|
161
161
|
.ef-player__top{display:flex;align-items:center;gap:10px}
|
|
162
162
|
.ef-player__title{flex:1;min-width:0;font-size:13.5px;font-weight:var(--weight-semibold);color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
163
163
|
.ef-player__meta{font-size:12px;color:var(--text-muted)}
|
|
164
|
-
.ef-player__wave{position:relative;display:flex;align-items:center;justify-content:space-between;height:44px;cursor:pointer;touch-action:none}
|
|
164
|
+
.ef-player__wave{position:relative;display:flex;align-items:center;justify-content:space-between;height:44px;cursor:pointer;touch-action:none;border-radius:var(--radius-sm)}
|
|
165
|
+
.ef-player__wave:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
165
166
|
.ef-player__bar{flex:none;width:2.5px;border-radius:var(--radius-full);background:var(--sand-300,#D9D2C3);transition:background .2s var(--ease-out)}
|
|
166
167
|
.ef-player__bar--played{background:var(--accent)}
|
|
167
168
|
.ef-player__bar--loading{animation:ef-player-load 1.2s ease-in-out infinite}
|
|
@@ -611,6 +612,8 @@ a.ef-sourcecard:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
|
611
612
|
.ef-cal__day--today{border-color:var(--sand-400)}
|
|
612
613
|
.ef-cal__day--sel{background:var(--accent);color:var(--accent-contrast);font-weight:var(--weight-semibold)}
|
|
613
614
|
.ef-cal__day--sel:hover{background:var(--sand-900)}
|
|
615
|
+
.ef-cal__day--band{background:var(--brand-100);color:var(--brand-950);border-radius:0}
|
|
616
|
+
.ef-cal__day--band:hover{background:var(--brand-200)}
|
|
614
617
|
/* components/dates/DatePicker.jsx */
|
|
615
618
|
.ef-datepicker{position:relative;display:inline-flex;flex-direction:column;gap:6px}
|
|
616
619
|
.ef-datepicker__label{font-size:var(--text-sm);font-weight:var(--weight-semibold);color:var(--text-primary)}
|
|
@@ -620,6 +623,41 @@ a.ef-sourcecard:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
|
620
623
|
.ef-datepicker__btn--empty{color:var(--text-muted)}
|
|
621
624
|
.ef-datepicker__pop{position:absolute;top:calc(100% + 6px);left:0;background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-md);padding:12px;z-index:var(--z-dropdown);animation:ef-dp-in var(--dur-fast) var(--ease-out)}
|
|
622
625
|
@keyframes ef-dp-in{from{opacity:0;transform:translateY(-3px)}}
|
|
626
|
+
/* components/dates/DateRangePicker.jsx */
|
|
627
|
+
.ef-daterange{position:relative;display:inline-flex;flex-direction:column;gap:6px}
|
|
628
|
+
.ef-daterange__label{font-size:var(--text-sm);font-weight:var(--weight-semibold);color:var(--text-primary)}
|
|
629
|
+
.ef-daterange__hint{font-size:var(--text-xs);color:var(--text-muted)}
|
|
630
|
+
.ef-daterange__wrap{position:relative;display:inline-flex}
|
|
631
|
+
.ef-daterange__btn{flex:1;min-width:0;display:inline-flex;align-items:center;gap:8px;height:var(--control-h-md);padding:0 32px 0 12px;border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--surface-card);font-family:var(--font-sans);font-size:var(--text-md);color:var(--text-primary);cursor:pointer;white-space:nowrap;transition:border-color var(--dur-fast) var(--ease-out)}
|
|
632
|
+
.ef-daterange__btn:hover:not(:disabled){border-color:var(--sand-400)}
|
|
633
|
+
.ef-daterange__btn:focus-visible{outline:none;border-color:var(--accent);box-shadow:var(--focus-ring)}
|
|
634
|
+
.ef-daterange__btn:disabled{background:var(--surface-sunken);color:var(--text-muted);cursor:not-allowed}
|
|
635
|
+
.ef-daterange__btn--empty{color:var(--text-muted)}
|
|
636
|
+
.ef-daterange__chevron{position:absolute;right:10px;top:50%;transform:translateY(-50%);display:inline-flex;color:var(--text-muted);pointer-events:none}
|
|
637
|
+
.ef-daterange__clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border:none;border-radius:var(--radius-sm);background:none;color:var(--text-muted);cursor:pointer}
|
|
638
|
+
.ef-daterange__clear:hover{background:var(--surface-sunken);color:var(--text-primary)}
|
|
639
|
+
.ef-daterange__clear:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
640
|
+
.ef-daterange__pop{background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-md);padding:12px;z-index:var(--z-dropdown);animation:ef-drp-in var(--dur-fast) var(--ease-out)}
|
|
641
|
+
@keyframes ef-drp-in{from{opacity:0;transform:translateY(-3px)}}
|
|
642
|
+
/* components/dates/TimePicker.jsx */
|
|
643
|
+
.ef-field{display:flex;flex-direction:column;gap:6px}
|
|
644
|
+
.ef-field__label{font-size:var(--text-sm);font-weight:var(--weight-semibold);color:var(--text-primary)}
|
|
645
|
+
.ef-field__hint{font-size:var(--text-xs);color:var(--text-muted)}
|
|
646
|
+
.ef-timepicker{position:relative;display:flex;align-items:center}
|
|
647
|
+
.ef-timepicker__input{width:100%;height:var(--control-h-md);padding:0 34px 0 12px;border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--surface-card);font-family:var(--font-sans);font-size:var(--text-md);color:var(--text-primary);transition:border-color var(--dur-fast) var(--ease-out),box-shadow var(--dur-fast) var(--ease-out)}
|
|
648
|
+
.ef-timepicker__input::placeholder{color:var(--text-muted)}
|
|
649
|
+
.ef-timepicker__input:hover:not(:disabled){border-color:var(--sand-400)}
|
|
650
|
+
.ef-timepicker__input:focus{outline:none;border-color:var(--accent);box-shadow:var(--focus-ring)}
|
|
651
|
+
.ef-timepicker__input:disabled{background:var(--surface-sunken);color:var(--text-muted);cursor:not-allowed}
|
|
652
|
+
.ef-timepicker--invalid .ef-timepicker__input{border-color:var(--danger-600)}
|
|
653
|
+
.ef-timepicker--invalid .ef-timepicker__input:focus{box-shadow:var(--focus-ring-danger)}
|
|
654
|
+
.ef-timepicker__icon{position:absolute;right:11px;color:var(--text-muted);display:inline-flex;pointer-events:none}
|
|
655
|
+
.ef-timepicker__panel{max-height:240px;overflow-y:auto;background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-md);padding:4px;z-index:var(--z-dropdown);animation:ef-tp-in var(--dur-fast) var(--ease-out)}
|
|
656
|
+
@keyframes ef-tp-in{from{opacity:0;transform:translateY(-3px)}}
|
|
657
|
+
.ef-timepicker__opt{display:flex;align-items:center;gap:9px;width:100%;padding:7px 10px;border:none;border-radius:var(--radius-sm);background:none;cursor:pointer;text-align:left;font-family:var(--font-sans);font-size:var(--text-sm);color:var(--text-primary)}
|
|
658
|
+
.ef-timepicker__opt--hi{background:var(--surface-sunken)}
|
|
659
|
+
.ef-timepicker__opt__check{margin-left:auto;color:var(--accent);display:inline-flex}
|
|
660
|
+
.ef-timepicker__empty{padding:14px 10px;font-size:var(--text-sm);color:var(--text-muted);text-align:center}
|
|
623
661
|
/* components/display/Accordion.jsx */
|
|
624
662
|
.ef-acc{display:flex;flex-direction:column}
|
|
625
663
|
.ef-acc__item{border-bottom:1px solid var(--border-default)}
|
|
@@ -729,9 +767,12 @@ button.ef-listitem:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
|
729
767
|
.ef-scrollarea::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:var(--radius-full);border:2px solid transparent;background-clip:content-box}
|
|
730
768
|
.ef-scrollarea::-webkit-scrollbar-thumb:hover{background:var(--text-muted);border:2px solid transparent;background-clip:content-box}
|
|
731
769
|
/* components/display/Tag.jsx */
|
|
732
|
-
.ef-tag{display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 10px;border-radius:var(--radius-sm);background:transparent;border:1px solid var(--border-strong);color:var(--text-secondary);font-size:var(--text-sm);font-weight:var(--weight-medium);white-space:nowrap;transition:background var(--dur-fast) var(--ease-out),border-color var(--dur-fast) var(--ease-out)}
|
|
770
|
+
.ef-tag{display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 10px;border-radius:var(--radius-sm);background:transparent;border:1px solid var(--border-strong);color:var(--text-secondary);font-family:var(--font-sans);font-size:var(--text-sm);font-weight:var(--weight-medium);white-space:nowrap;transition:background var(--dur-fast) var(--ease-out),border-color var(--dur-fast) var(--ease-out)}
|
|
733
771
|
.ef-tag--interactive{cursor:pointer}
|
|
734
772
|
.ef-tag--interactive:hover{background:var(--surface-sunken);border-color:var(--sand-400)}
|
|
773
|
+
.ef-tag--interactive:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
774
|
+
.ef-tag__body{display:inline-flex;align-items:center;gap:6px;border:none;background:transparent;padding:0;margin:0;font:inherit;color:inherit;cursor:pointer;border-radius:var(--radius-sm)}
|
|
775
|
+
.ef-tag__body:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
735
776
|
.ef-tag__x{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin:-3px -9px -3px -5px;border:none;border-radius:var(--radius-sm);background:transparent;color:var(--text-muted);cursor:pointer;padding:0;transition:background var(--dur-fast) var(--ease-out),color var(--dur-fast) var(--ease-out)}
|
|
736
777
|
.ef-tag__x:hover{background:var(--sand-200);color:var(--text-primary)}
|
|
737
778
|
.ef-tag__x:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
@@ -998,6 +1039,32 @@ button.ef-listitem:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
|
998
1039
|
.ef-label{display:inline-flex;align-items:baseline;gap:5px;font-family:var(--font-sans);font-size:var(--text-sm);font-weight:600;color:var(--text-primary)}
|
|
999
1040
|
.ef-label__req{color:var(--danger-600);font-weight:600}
|
|
1000
1041
|
.ef-label__hint{font-weight:400;color:var(--text-muted);font-size:12.5px}
|
|
1042
|
+
/* components/forms/NumberInput.jsx */
|
|
1043
|
+
.ef-field{display:flex;flex-direction:column;gap:6px}
|
|
1044
|
+
.ef-field__label{font-size:var(--text-sm);font-weight:var(--weight-semibold);color:var(--text-primary)}
|
|
1045
|
+
.ef-field__hint{font-size:var(--text-xs);color:var(--text-muted)}
|
|
1046
|
+
.ef-field__error{font-size:var(--text-xs);color:var(--danger-600);display:flex;align-items:center;gap:4px}
|
|
1047
|
+
.ef-number{display:flex;align-items:stretch;overflow:hidden;border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--surface-card);transition:border-color var(--dur-fast) var(--ease-out),box-shadow var(--dur-fast) var(--ease-out)}
|
|
1048
|
+
.ef-number:hover:not(.ef-number--disabled){border-color:var(--sand-400)}
|
|
1049
|
+
.ef-number:focus-within{border-color:var(--accent);box-shadow:var(--focus-ring)}
|
|
1050
|
+
.ef-number.ef-number--invalid{border-color:var(--danger-600)}
|
|
1051
|
+
.ef-number.ef-number--invalid:focus-within{box-shadow:var(--focus-ring-danger)}
|
|
1052
|
+
.ef-number--disabled{background:var(--surface-sunken)}
|
|
1053
|
+
.ef-number__el{flex:1;min-width:0;border:none;background:transparent;color:var(--text-primary);font-family:var(--font-sans);font-variant-numeric:tabular-nums}
|
|
1054
|
+
.ef-number__el:focus{outline:none}
|
|
1055
|
+
.ef-number__el::placeholder{color:var(--text-muted)}
|
|
1056
|
+
.ef-number__el:disabled{color:var(--text-muted);cursor:not-allowed}
|
|
1057
|
+
.ef-number--sm .ef-number__el{height:calc(var(--control-h-sm) - 2px);padding:0 10px;font-size:var(--text-sm)}
|
|
1058
|
+
.ef-number--md .ef-number__el{height:calc(var(--control-h-md) - 2px);padding:0 12px;font-size:var(--text-md)}
|
|
1059
|
+
.ef-number--lg .ef-number__el{height:calc(var(--control-h-lg) - 2px);padding:0 14px;font-size:var(--text-lg)}
|
|
1060
|
+
.ef-number__steps{display:flex;flex-direction:column;flex:none;align-self:stretch;border-left:1px solid var(--border-default)}
|
|
1061
|
+
.ef-number__step{flex:1 1 0;display:flex;align-items:center;justify-content:center;width:24px;padding:0;border:none;background:transparent;color:var(--text-muted);cursor:pointer;transition:background var(--dur-fast) var(--ease-out),color var(--dur-fast) var(--ease-out)}
|
|
1062
|
+
.ef-number__step:hover:not(:disabled){background:var(--surface-sunken);color:var(--text-primary)}
|
|
1063
|
+
.ef-number__step:disabled{opacity:.45;cursor:not-allowed}
|
|
1064
|
+
.ef-number__step:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
1065
|
+
.ef-number__step+.ef-number__step{border-top:1px solid var(--border-default)}
|
|
1066
|
+
.ef-number--sm .ef-number__step{width:22px}
|
|
1067
|
+
.ef-number--lg .ef-number__step{width:28px}
|
|
1001
1068
|
/* components/forms/Radio.jsx */
|
|
1002
1069
|
.ef-radio{display:inline-flex;align-items:flex-start;gap:10px;cursor:pointer;user-select:none}
|
|
1003
1070
|
.ef-radio--disabled{opacity:.45;cursor:not-allowed}
|
package/dates/Calendar.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface DateRange {
|
|
2
|
+
/** Range start as YYYY-MM-DD, or null while unset */
|
|
3
|
+
from: string | null;
|
|
4
|
+
/** Range end as YYYY-MM-DD, or null while unset */
|
|
5
|
+
to: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface CalendarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
8
|
+
/** Single-date mode (the default) */
|
|
9
|
+
range?: false;
|
|
2
10
|
/** Selected date as YYYY-MM-DD */
|
|
3
11
|
value?: string;
|
|
4
12
|
onChange?: (date: string) => void;
|
|
5
13
|
style?: React.CSSProperties;
|
|
6
14
|
className?: string;
|
|
7
15
|
}
|
|
8
|
-
export
|
|
16
|
+
export interface CalendarRangeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
17
|
+
/** Range mode: value/onChange carry a {from,to} pair; first pick sets from, second sets to (swapped when earlier), third starts over */
|
|
18
|
+
range: true;
|
|
19
|
+
value?: DateRange;
|
|
20
|
+
onChange?: (range: DateRange) => void;
|
|
21
|
+
style?: React.CSSProperties;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function Calendar(props: CalendarProps | CalendarRangeProps): React.JSX.Element;
|
package/dates/Calendar.js
CHANGED
|
@@ -9,13 +9,18 @@ const iso = d => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0
|
|
|
9
9
|
export function Calendar({
|
|
10
10
|
value,
|
|
11
11
|
onChange,
|
|
12
|
+
range,
|
|
12
13
|
style,
|
|
13
14
|
className,
|
|
14
15
|
...rest
|
|
15
16
|
}) {
|
|
16
|
-
|
|
17
|
+
// In range mode value is { from, to } of ISO strings (either may be null);
|
|
18
|
+
// without the prop everything below behaves exactly as before.
|
|
19
|
+
const from = range && value ? value.from || null : null;
|
|
20
|
+
const to = range && value ? value.to || null : null;
|
|
21
|
+
const sel = !range && value ? new Date(value + 'T00:00:00') : null;
|
|
17
22
|
const [view, setView] = React.useState(() => {
|
|
18
|
-
const b = sel || new Date();
|
|
23
|
+
const b = sel || (from ? new Date(from + 'T00:00:00') : new Date());
|
|
19
24
|
return [b.getFullYear(), b.getMonth()];
|
|
20
25
|
});
|
|
21
26
|
const [y, m] = view;
|
|
@@ -27,7 +32,7 @@ export function Calendar({
|
|
|
27
32
|
length: 42
|
|
28
33
|
}, (_, i) => new Date(start.getFullYear(), start.getMonth(), start.getDate() + i));
|
|
29
34
|
const gridRef = React.useRef(null);
|
|
30
|
-
const [focusIso, setFocusIso] = React.useState(() => sel ? iso(sel) : today);
|
|
35
|
+
const [focusIso, setFocusIso] = React.useState(() => sel ? iso(sel) : from || today);
|
|
31
36
|
const focusTarget = cells.some(d => iso(d) === focusIso) ? focusIso : iso(first);
|
|
32
37
|
const move = days => {
|
|
33
38
|
const base = new Date(focusTarget + 'T00:00:00');
|
|
@@ -37,7 +42,11 @@ export function Calendar({
|
|
|
37
42
|
};
|
|
38
43
|
React.useEffect(() => {
|
|
39
44
|
const g = gridRef.current;
|
|
40
|
-
if (!g
|
|
45
|
+
if (!g) return;
|
|
46
|
+
// A month change unmounts the focused day and drops focus to <body>;
|
|
47
|
+
// reclaiming it from there is restoration, not stealing.
|
|
48
|
+
const ae = document.activeElement;
|
|
49
|
+
if (!(g.contains(ae) || ae === document.body)) return;
|
|
41
50
|
const btn = g.querySelector(`[data-iso="${focusTarget}"]`);
|
|
42
51
|
if (btn) btn.focus();
|
|
43
52
|
}, [focusTarget, y, m]);
|
|
@@ -60,13 +69,34 @@ export function Calendar({
|
|
|
60
69
|
} else if (e.key === 'End') {
|
|
61
70
|
e.preventDefault();
|
|
62
71
|
move(6 - dow());
|
|
63
|
-
} else if (e.key === 'PageUp') {
|
|
72
|
+
} else if (e.key === 'PageUp' || e.key === 'PageDown') {
|
|
64
73
|
e.preventDefault();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
const base = new Date(focusTarget + 'T00:00:00');
|
|
75
|
+
const [ty, tm] = e.key === 'PageUp' ? m === 0 ? [y - 1, 11] : [y, m - 1] : m === 11 ? [y + 1, 0] : [y, m + 1];
|
|
76
|
+
const clamped = Math.min(base.getDate(), new Date(ty, tm + 1, 0).getDate());
|
|
77
|
+
setFocusIso(iso(new Date(ty, tm, clamped)));
|
|
78
|
+
setView([ty, tm]);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// Range selection: first pick opens a range, the second closes it (swapped
|
|
82
|
+
// when it lands earlier — ISO strings compare correctly), a third starts over.
|
|
83
|
+
const pick = id => {
|
|
84
|
+
setFocusIso(id);
|
|
85
|
+
if (!onChange) return;
|
|
86
|
+
if (!range) {
|
|
87
|
+
onChange(id);
|
|
88
|
+
return;
|
|
69
89
|
}
|
|
90
|
+
if (!from || to) onChange({
|
|
91
|
+
from: id,
|
|
92
|
+
to: null
|
|
93
|
+
});else if (id < from) onChange({
|
|
94
|
+
from: id,
|
|
95
|
+
to: from
|
|
96
|
+
});else onChange({
|
|
97
|
+
from,
|
|
98
|
+
to: id
|
|
99
|
+
});
|
|
70
100
|
};
|
|
71
101
|
const rows = Array.from({
|
|
72
102
|
length: 6
|
|
@@ -109,19 +139,18 @@ export function Calendar({
|
|
|
109
139
|
key: ri
|
|
110
140
|
}, row.map(d => {
|
|
111
141
|
const id = iso(d);
|
|
142
|
+
const isEnd = range && (id === from || id === to);
|
|
143
|
+
const inBand = range && from && to && id > from && id < to;
|
|
112
144
|
return /*#__PURE__*/React.createElement("button", {
|
|
113
145
|
key: id,
|
|
114
146
|
role: "gridcell",
|
|
115
147
|
"data-iso": id,
|
|
116
148
|
tabIndex: id === focusTarget ? 0 : -1,
|
|
117
|
-
"aria-selected": sel ? id === iso(sel) : undefined,
|
|
149
|
+
"aria-selected": range ? from || to ? isEnd : undefined : sel ? id === iso(sel) : undefined,
|
|
118
150
|
"aria-current": id === today ? 'date' : undefined,
|
|
119
151
|
"aria-label": `${d.getDate()} ${MONTHS[d.getMonth()]} ${d.getFullYear()}`,
|
|
120
|
-
className: `ef-cal__day${d.getMonth() !== m ? ' ef-cal__day--out' : ''}${id === today ? ' ef-cal__day--today' : ''}${sel && id === iso(sel) ? ' ef-cal__day--sel' : ''}`,
|
|
121
|
-
onClick: () =>
|
|
122
|
-
setFocusIso(id);
|
|
123
|
-
if (onChange) onChange(id);
|
|
124
|
-
}
|
|
152
|
+
className: `ef-cal__day${d.getMonth() !== m ? ' ef-cal__day--out' : ''}${id === today ? ' ef-cal__day--today' : ''}${(range ? isEnd : sel && id === iso(sel)) ? ' ef-cal__day--sel' : ''}${inBand ? ' ef-cal__day--band' : ''}`,
|
|
153
|
+
onClick: () => pick(id)
|
|
125
154
|
}, d.getDate());
|
|
126
155
|
})))));
|
|
127
156
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DateRange } from './Calendar.js';
|
|
2
|
+
|
|
3
|
+
export interface DateRangePickerProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onChange'> {
|
|
4
|
+
/** Field label rendered above the trigger */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Muted helper line rendered below */
|
|
7
|
+
hint?: string;
|
|
8
|
+
/** Controlled {from,to} of YYYY-MM-DD strings; either may be null */
|
|
9
|
+
value?: DateRange;
|
|
10
|
+
onChange?: (range: DateRange) => void;
|
|
11
|
+
/** Earliest pickable day as YYYY-MM-DD; earlier picks are ignored */
|
|
12
|
+
min?: string;
|
|
13
|
+
/** Latest pickable day as YYYY-MM-DD; later picks are ignored */
|
|
14
|
+
max?: string;
|
|
15
|
+
/** @default 'Pick a date range' */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function DateRangePicker(props: DateRangePickerProps): React.JSX.Element;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Icon } from "../icons/Icon.js";
|
|
5
|
+
import { Calendar } from "./Calendar.js";
|
|
6
|
+
import { useFieldProps } from "../forms/FormField.js";
|
|
7
|
+
import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
|
|
8
|
+
const fmt = v => {
|
|
9
|
+
if (!v) return null;
|
|
10
|
+
const d = new Date(v + 'T00:00:00');
|
|
11
|
+
return d.toLocaleDateString('en-US', {
|
|
12
|
+
month: 'short',
|
|
13
|
+
day: 'numeric',
|
|
14
|
+
year: 'numeric'
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const EMPTY = {
|
|
18
|
+
from: null,
|
|
19
|
+
to: null
|
|
20
|
+
};
|
|
21
|
+
export function DateRangePicker({
|
|
22
|
+
label,
|
|
23
|
+
hint,
|
|
24
|
+
value,
|
|
25
|
+
onChange,
|
|
26
|
+
min,
|
|
27
|
+
max,
|
|
28
|
+
placeholder = 'Pick a date range',
|
|
29
|
+
disabled,
|
|
30
|
+
style,
|
|
31
|
+
className,
|
|
32
|
+
...rest
|
|
33
|
+
}) {
|
|
34
|
+
// Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
|
|
35
|
+
const field = useFieldProps({
|
|
36
|
+
id: rest.id,
|
|
37
|
+
'aria-describedby': rest['aria-describedby']
|
|
38
|
+
});
|
|
39
|
+
const [inner, setInner] = React.useState(EMPTY);
|
|
40
|
+
const v = value != null ? value : inner;
|
|
41
|
+
const from = v && v.from ? v.from : null;
|
|
42
|
+
const to = v && v.to ? v.to : null;
|
|
43
|
+
const [open, setOpen] = React.useState(false);
|
|
44
|
+
const rootRef = React.useRef(null);
|
|
45
|
+
const wrapRef = React.useRef(null);
|
|
46
|
+
const btnRef = React.useRef(null);
|
|
47
|
+
const panelRef = React.useRef(null);
|
|
48
|
+
const {
|
|
49
|
+
style: anchored
|
|
50
|
+
} = useAnchoredStyle(wrapRef, panelRef, {
|
|
51
|
+
open,
|
|
52
|
+
placement: 'bottom',
|
|
53
|
+
align: 'start'
|
|
54
|
+
});
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (!open) return;
|
|
57
|
+
// the calendar is portaled out of `rootRef`, so look for it in the panel
|
|
58
|
+
const day = panelRef.current && panelRef.current.querySelector('[role="gridcell"][tabindex="0"]');
|
|
59
|
+
if (day) day.focus();
|
|
60
|
+
const away = e => {
|
|
61
|
+
const inTrigger = rootRef.current && rootRef.current.contains(e.target);
|
|
62
|
+
const inPanel = panelRef.current && panelRef.current.contains(e.target);
|
|
63
|
+
if (!inTrigger && !inPanel) setOpen(false);
|
|
64
|
+
};
|
|
65
|
+
const key = e => {
|
|
66
|
+
if (e.key === 'Escape') {
|
|
67
|
+
setOpen(false);
|
|
68
|
+
if (btnRef.current) btnRef.current.focus();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
document.addEventListener('mousedown', away);
|
|
72
|
+
document.addEventListener('keydown', key);
|
|
73
|
+
return () => {
|
|
74
|
+
document.removeEventListener('mousedown', away);
|
|
75
|
+
document.removeEventListener('keydown', key);
|
|
76
|
+
};
|
|
77
|
+
}, [open]);
|
|
78
|
+
const commit = r => {
|
|
79
|
+
if (value == null) setInner(r);
|
|
80
|
+
if (onChange) onChange(r);
|
|
81
|
+
};
|
|
82
|
+
// The Calendar itself has no bounds, so a pick outside [min, max] is dropped
|
|
83
|
+
// here: any change whose ends stray out of the window never commits.
|
|
84
|
+
const inBounds = d => !d || (!min || d >= min) && (!max || d <= max);
|
|
85
|
+
const handlePick = r => {
|
|
86
|
+
if (!inBounds(r.from) || !inBounds(r.to)) return;
|
|
87
|
+
commit(r);
|
|
88
|
+
if (r.from && r.to) {
|
|
89
|
+
setOpen(false);
|
|
90
|
+
if (btnRef.current) btnRef.current.focus();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const clear = () => {
|
|
94
|
+
commit(EMPTY);
|
|
95
|
+
if (btnRef.current) btnRef.current.focus();
|
|
96
|
+
};
|
|
97
|
+
const text = from || to ? `${fmt(from) || '…'} — ${fmt(to) || '…'}` : null;
|
|
98
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
|
|
99
|
+
ref: rootRef,
|
|
100
|
+
className: `ef-daterange${className ? ' ' + className : ''}`,
|
|
101
|
+
style: style
|
|
102
|
+
}), label ? /*#__PURE__*/React.createElement("span", {
|
|
103
|
+
className: "ef-daterange__label"
|
|
104
|
+
}, label) : null, /*#__PURE__*/React.createElement("span", {
|
|
105
|
+
ref: wrapRef,
|
|
106
|
+
className: "ef-daterange__wrap"
|
|
107
|
+
}, /*#__PURE__*/React.createElement("button", _extends({}, field.controlProps, {
|
|
108
|
+
type: "button",
|
|
109
|
+
ref: btnRef,
|
|
110
|
+
disabled: disabled,
|
|
111
|
+
"aria-haspopup": "dialog",
|
|
112
|
+
"aria-expanded": open,
|
|
113
|
+
className: `ef-daterange__btn${text ? '' : ' ef-daterange__btn--empty'}`,
|
|
114
|
+
onClick: () => setOpen(o => !o)
|
|
115
|
+
}), /*#__PURE__*/React.createElement(Icon, {
|
|
116
|
+
name: "calendar",
|
|
117
|
+
size: 15,
|
|
118
|
+
style: {
|
|
119
|
+
color: 'var(--text-muted)'
|
|
120
|
+
}
|
|
121
|
+
}), text || placeholder), text && !disabled ? /*#__PURE__*/React.createElement("button", {
|
|
122
|
+
type: "button",
|
|
123
|
+
className: "ef-daterange__clear",
|
|
124
|
+
"aria-label": "Clear date range",
|
|
125
|
+
onClick: clear
|
|
126
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
127
|
+
name: "x",
|
|
128
|
+
size: 13
|
|
129
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
130
|
+
className: "ef-daterange__chevron"
|
|
131
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
132
|
+
name: "chevron-down",
|
|
133
|
+
size: 14
|
|
134
|
+
}))), hint ? /*#__PURE__*/React.createElement("span", {
|
|
135
|
+
className: "ef-daterange__hint"
|
|
136
|
+
}, hint) : null, open && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
|
|
137
|
+
ref: panelRef,
|
|
138
|
+
className: "ef-daterange__pop",
|
|
139
|
+
style: anchored
|
|
140
|
+
}, /*#__PURE__*/React.createElement(Calendar, {
|
|
141
|
+
range: true,
|
|
142
|
+
value: {
|
|
143
|
+
from,
|
|
144
|
+
to
|
|
145
|
+
},
|
|
146
|
+
onChange: handlePick
|
|
147
|
+
}))));
|
|
148
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface TimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
2
|
+
/** Field label rendered above the input */
|
|
3
|
+
label?: string;
|
|
4
|
+
/** Muted helper line rendered below */
|
|
5
|
+
hint?: string;
|
|
6
|
+
/** Controlled time as 24h 'HH:MM', or null when empty (always 24h, whatever `format24` shows) */
|
|
7
|
+
value?: string | null;
|
|
8
|
+
onChange?: (time: string | null) => void;
|
|
9
|
+
/** Minutes between listed slots @default 30 */
|
|
10
|
+
stepMinutes?: number;
|
|
11
|
+
/** First listed slot as 'HH:MM' @default '00:00' */
|
|
12
|
+
minTime?: string;
|
|
13
|
+
/** Slots stop at this 'HH:MM' @default '23:59' */
|
|
14
|
+
maxTime?: string;
|
|
15
|
+
/** 24h labels; false renders 12h with AM/PM (value stays 24h) @default true */
|
|
16
|
+
format24?: boolean;
|
|
17
|
+
/** @default 'Pick a time' */
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Danger border + aria-invalid */
|
|
21
|
+
invalid?: boolean;
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function TimePicker(props: TimePickerProps): React.JSX.Element;
|