@efolusi/meridian 1.20.0 → 1.21.1
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/README.md +1 -1
- package/ai/Bubble.d.ts +16 -0
- package/ai/Bubble.js +71 -0
- package/ai/ChatMessage.js +2 -5
- package/ai/Confirmation.d.ts +0 -7
- package/ai/Confirmation.js +3 -6
- package/ai/GeneratedImage.d.ts +0 -2
- package/ai/GeneratedImage.js +2 -4
- package/ai/Marker.d.ts +26 -0
- package/ai/Marker.js +67 -0
- package/ai/Message.d.ts +13 -0
- package/ai/Message.js +68 -0
- package/ai/MessageScroller.d.ts +21 -0
- package/ai/MessageScroller.js +283 -0
- package/ai/ModelSelector.d.ts +2 -2
- package/ai/ModelSelector.js +1 -2
- package/ai/Player.js +1 -1
- package/ai/PromptSteps.js +4 -2
- package/ai/Sandbox.d.ts +0 -2
- package/ai/Sandbox.js +2 -4
- package/ai/Suggestions.d.ts +0 -2
- package/ai/Suggestions.js +1 -4
- package/ai/WebPreview.d.ts +0 -2
- package/ai/WebPreview.js +2 -4
- package/code/Console.js +1 -1
- package/code/EnvList.d.ts +0 -2
- package/code/EnvList.js +2 -3
- package/components.css +652 -418
- package/data/BarChart.d.ts +0 -2
- package/data/BarChart.js +1 -4
- package/data/Chart.d.ts +14 -0
- package/data/Chart.js +149 -0
- package/data/EmptyState.d.ts +8 -13
- package/data/EmptyState.js +62 -24
- package/data/LineChart.js +7 -4
- package/data/Skeleton.d.ts +2 -11
- package/data/Skeleton.js +8 -38
- package/data/Sparkline.js +4 -1
- package/data/StatusDot.d.ts +0 -4
- package/data/StatusDot.js +3 -6
- package/data/Table.d.ts +11 -4
- package/data/Table.js +39 -7
- package/dates/Calendar.d.ts +10 -27
- package/dates/Calendar.js +250 -184
- package/dates/TimePicker.js +2 -2
- package/display/Accordion.d.ts +47 -15
- package/display/Accordion.js +257 -27
- package/display/AspectRatio.d.ts +4 -6
- package/display/AspectRatio.js +7 -5
- package/display/Avatar.d.ts +17 -14
- package/display/Avatar.js +68 -43
- package/display/Badge.d.ts +9 -8
- package/display/Badge.js +32 -14
- package/display/Card.d.ts +11 -13
- package/display/Card.js +74 -29
- package/display/Carousel.d.ts +23 -15
- package/display/Carousel.js +217 -66
- package/display/Collapsible.d.ts +19 -9
- package/display/Collapsible.js +140 -28
- package/display/Direction.d.ts +10 -0
- package/display/Direction.js +24 -0
- package/display/Item.d.ts +19 -0
- package/display/Item.js +152 -0
- package/display/Kbd.d.ts +5 -7
- package/display/Kbd.js +22 -10
- package/display/Link.js +2 -4
- package/display/Resizable.d.ts +6 -16
- package/display/Resizable.js +141 -58
- package/display/ScrollArea.d.ts +3 -1
- package/display/ScrollArea.js +30 -5
- package/display/Separator.d.ts +9 -0
- package/display/Separator.js +18 -0
- package/display/Timeline.d.ts +24 -0
- package/display/Timeline.js +51 -0
- package/display/Toolbar.js +5 -4
- package/display/TreeList.d.ts +0 -2
- package/display/TreeList.js +2 -5
- package/feedback/Alert.d.ts +13 -13
- package/feedback/Alert.js +40 -36
- package/feedback/AlertDialog.d.ts +30 -0
- package/feedback/AlertDialog.js +249 -0
- package/feedback/Banner.d.ts +1 -3
- package/feedback/Banner.js +1 -5
- package/feedback/ConfirmDialog.d.ts +1 -1
- package/feedback/ConfirmDialog.js +18 -20
- package/feedback/Dialog.d.ts +13 -16
- package/feedback/Dialog.js +204 -62
- package/feedback/Progress.d.ts +8 -9
- package/feedback/Progress.js +42 -24
- package/feedback/Sonner.d.ts +8 -0
- package/feedback/Sonner.js +238 -0
- package/feedback/Spinner.d.ts +2 -9
- package/feedback/Spinner.js +19 -28
- package/feedback/Tooltip.d.ts +9 -10
- package/feedback/Tooltip.js +147 -96
- package/files/Attachment.d.ts +27 -0
- package/files/Attachment.js +111 -0
- package/files/FileDrop.js +3 -1
- package/finance/PaymentCard.js +3 -3
- package/forms/Button.d.ts +6 -5
- package/forms/Button.js +22 -8
- package/forms/ButtonGroup.d.ts +11 -3
- package/forms/ButtonGroup.js +57 -6
- package/forms/Checkbox.d.ts +14 -3
- package/forms/Checkbox.js +84 -16
- package/forms/Combobox.d.ts +24 -16
- package/forms/Combobox.js +466 -135
- package/forms/Field.d.ts +14 -0
- package/forms/Field.js +99 -0
- package/forms/IconButton.d.ts +1 -1
- package/forms/IconButton.js +4 -3
- package/forms/Input.d.ts +8 -8
- package/forms/Input.js +46 -33
- package/forms/InputGroup.d.ts +8 -15
- package/forms/InputGroup.js +74 -35
- package/forms/InputOTP.d.ts +13 -0
- package/forms/InputOTP.js +125 -0
- package/forms/Label.d.ts +2 -6
- package/forms/Label.js +6 -4
- package/forms/NativeSelect.d.ts +16 -0
- package/forms/NativeSelect.js +35 -0
- package/forms/NumberInput.js +2 -2
- package/forms/Radio.d.ts +12 -1
- package/forms/Radio.js +76 -6
- package/forms/Select.d.ts +12 -9
- package/forms/Select.js +254 -42
- package/forms/Slider.d.ts +10 -17
- package/forms/Slider.js +78 -39
- package/forms/Switch.d.ts +8 -2
- package/forms/Switch.js +46 -15
- package/forms/Textarea.d.ts +1 -1
- package/forms/Textarea.js +26 -18
- package/forms/Toggle.d.ts +18 -15
- package/forms/Toggle.js +96 -42
- package/icons/_svg.js +2 -0
- package/index.d.ts +20 -8
- package/index.js +50 -38
- package/navigation/Breadcrumbs.d.ts +18 -11
- package/navigation/Breadcrumbs.js +99 -26
- package/navigation/Menubar.d.ts +52 -10
- package/navigation/Menubar.js +191 -146
- package/navigation/NavigationMenu.d.ts +15 -0
- package/navigation/NavigationMenu.js +296 -0
- package/navigation/Pagination.d.ts +10 -9
- package/navigation/Pagination.js +94 -51
- package/navigation/SideNav.js +4 -3
- package/navigation/Sidebar.d.ts +29 -0
- package/navigation/Sidebar.js +311 -0
- package/navigation/Tabs.d.ts +9 -5
- package/navigation/Tabs.js +132 -44
- package/overlay/Command.d.ts +32 -0
- package/overlay/Command.js +257 -0
- package/overlay/ContextMenu.d.ts +40 -8
- package/overlay/ContextMenu.js +468 -107
- package/overlay/Drawer.d.ts +29 -14
- package/overlay/Drawer.js +178 -80
- package/overlay/DropdownMenu.d.ts +43 -0
- package/overlay/DropdownMenu.js +502 -0
- package/overlay/HoverCard.d.ts +21 -12
- package/overlay/HoverCard.js +129 -61
- package/overlay/Popover.d.ts +11 -13
- package/overlay/Popover.js +138 -65
- package/overlay/Portal.js +21 -7
- package/overlay/Sheet.d.ts +11 -0
- package/overlay/Sheet.js +62 -0
- package/package.json +4 -1
- package/tokens/base.css +1 -1
- package/dates/DatePicker.d.ts +0 -14
- package/dates/DatePicker.js +0 -111
- package/dates/DateRangePicker.d.ts +0 -23
- package/dates/DateRangePicker.js +0 -150
- package/display/ListItem.d.ts +0 -19
- package/display/ListItem.js +0 -50
- package/feedback/Toast.d.ts +0 -78
- package/feedback/Toast.js +0 -192
- package/forms/DigitEntry.d.ts +0 -15
- package/forms/DigitEntry.js +0 -79
- package/forms/FormField.d.ts +0 -82
- package/forms/FormField.js +0 -209
- package/overlay/CommandPalette.d.ts +0 -21
- package/overlay/CommandPalette.js +0 -148
- package/overlay/Menu.d.ts +0 -24
- package/overlay/Menu.js +0 -139
package/dates/Calendar.js
CHANGED
|
@@ -2,204 +2,270 @@
|
|
|
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
4
|
import { IconButton } from "../forms/IconButton.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { NativeSelect, NativeSelectOption } from "../forms/NativeSelect.js";
|
|
6
|
+
import { useDirection } from "../display/Direction.js";
|
|
7
|
+
const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
8
|
+
const startDay = date => new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
9
|
+
const addDays = (date, amount) => new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
|
|
10
|
+
const addMonths = (date, amount) => new Date(date.getFullYear(), date.getMonth() + amount, 1);
|
|
11
|
+
const dayKey = date => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
|
12
|
+
const normalizeLocale = locale => typeof locale === 'string' ? locale : locale?.code;
|
|
13
|
+
const matcherHit = (matcher, date) => {
|
|
14
|
+
if (!matcher) return false;
|
|
15
|
+
if (Array.isArray(matcher)) return matcher.some(item => matcherHit(item, date));
|
|
16
|
+
if (typeof matcher === 'function') return !!matcher(date);
|
|
17
|
+
if (matcher instanceof Date) return sameDay(matcher, date);
|
|
18
|
+
if (matcher.before && date < startDay(matcher.before)) return true;
|
|
19
|
+
if (matcher.after && date > startDay(matcher.after)) return true;
|
|
20
|
+
if (matcher.from && matcher.to && date >= startDay(matcher.from) && date <= startDay(matcher.to)) return true;
|
|
21
|
+
if (matcher.dayOfWeek?.includes(date.getDay())) return true;
|
|
22
|
+
return false;
|
|
18
23
|
};
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
day:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, (_, i) => dShort.format(new Date(2024, 0, 1 + i))),
|
|
42
|
-
dowFull: Array.from({
|
|
43
|
-
length: 7
|
|
44
|
-
}, (_, i) => dLong.format(new Date(2024, 0, 1 + i))),
|
|
45
|
-
dayLabel: d => dayFmt.format(d)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
24
|
+
export const CalendarDayButton = /*#__PURE__*/React.forwardRef(function CalendarDayButton({
|
|
25
|
+
day,
|
|
26
|
+
modifiers = {},
|
|
27
|
+
locale,
|
|
28
|
+
className,
|
|
29
|
+
children,
|
|
30
|
+
...props
|
|
31
|
+
}, ref) {
|
|
32
|
+
const date = day?.date || day;
|
|
33
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
34
|
+
ref: ref,
|
|
35
|
+
type: "button",
|
|
36
|
+
"data-day": date?.toLocaleDateString(normalizeLocale(locale)),
|
|
37
|
+
"data-selected": modifiers.selected || undefined,
|
|
38
|
+
"data-today": modifiers.today || undefined,
|
|
39
|
+
"data-outside": modifiers.outside || undefined,
|
|
40
|
+
"data-range-start": modifiers.range_start || undefined,
|
|
41
|
+
"data-range-middle": modifiers.range_middle || undefined,
|
|
42
|
+
"data-range-end": modifiers.range_end || undefined,
|
|
43
|
+
className: `ef-cal__day${className ? ` ${className}` : ''}`
|
|
44
|
+
}), children ?? date?.getDate());
|
|
45
|
+
});
|
|
48
46
|
export function Calendar({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
mode = 'single',
|
|
48
|
+
selected,
|
|
49
|
+
onSelect,
|
|
50
|
+
month: controlledMonth,
|
|
51
|
+
defaultMonth,
|
|
52
|
+
onMonthChange,
|
|
53
|
+
disabled,
|
|
54
|
+
required = false,
|
|
55
|
+
showOutsideDays = true,
|
|
56
|
+
fixedWeeks = true,
|
|
57
|
+
numberOfMonths = 1,
|
|
58
|
+
captionLayout = 'label',
|
|
59
|
+
startMonth,
|
|
60
|
+
endMonth,
|
|
52
61
|
locale,
|
|
53
|
-
|
|
62
|
+
dir,
|
|
54
63
|
className,
|
|
64
|
+
classNames = {},
|
|
65
|
+
formatters = {},
|
|
66
|
+
components = {},
|
|
67
|
+
buttonVariant,
|
|
68
|
+
style,
|
|
55
69
|
...rest
|
|
56
70
|
}) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} = L;
|
|
66
|
-
// In range mode value is { from, to } of ISO strings (either may be null);
|
|
67
|
-
// without the prop everything below behaves exactly as before.
|
|
68
|
-
const from = range && value ? value.from || null : null;
|
|
69
|
-
const to = range && value ? value.to || null : null;
|
|
70
|
-
const sel = !range && value ? new Date(value + 'T00:00:00') : null;
|
|
71
|
-
const [view, setView] = React.useState(() => {
|
|
72
|
-
const b = sel || (from ? new Date(from + 'T00:00:00') : new Date());
|
|
73
|
-
return [b.getFullYear(), b.getMonth()];
|
|
74
|
-
});
|
|
75
|
-
const [y, m] = view;
|
|
76
|
-
const first = new Date(y, m, 1);
|
|
77
|
-
const offset = (first.getDay() + 6) % 7;
|
|
78
|
-
const start = new Date(y, m, 1 - offset);
|
|
79
|
-
const today = iso(new Date());
|
|
80
|
-
const cells = Array.from({
|
|
81
|
-
length: 42
|
|
82
|
-
}, (_, i) => new Date(start.getFullYear(), start.getMonth(), start.getDate() + i));
|
|
71
|
+
const contextDirection = useDirection();
|
|
72
|
+
const direction = dir || contextDirection;
|
|
73
|
+
const localeCode = normalizeLocale(locale);
|
|
74
|
+
const selectedMonth = mode === 'range' ? selected?.from : mode === 'multiple' ? selected?.[0] : selected;
|
|
75
|
+
const initial = controlledMonth || defaultMonth || selectedMonth || new Date();
|
|
76
|
+
const [innerMonth, setInnerMonth] = React.useState(() => new Date(initial.getFullYear(), initial.getMonth(), 1));
|
|
77
|
+
const visibleMonth = controlledMonth || innerMonth;
|
|
78
|
+
const DayButton = components.DayButton || CalendarDayButton;
|
|
83
79
|
const gridRef = React.useRef(null);
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
const selectedStart = mode === 'range' ? selected?.from : mode === 'multiple' ? selected?.[0] : selected;
|
|
81
|
+
const [focusDate, setFocusDate] = React.useState(() => startDay(selectedStart || new Date()));
|
|
82
|
+
const setMonth = next => {
|
|
83
|
+
const bounded = startMonth && next < new Date(startMonth.getFullYear(), startMonth.getMonth(), 1) ? new Date(startMonth.getFullYear(), startMonth.getMonth(), 1) : endMonth && next > new Date(endMonth.getFullYear(), endMonth.getMonth(), 1) ? new Date(endMonth.getFullYear(), endMonth.getMonth(), 1) : next;
|
|
84
|
+
if (!controlledMonth) setInnerMonth(bounded);
|
|
85
|
+
onMonthChange?.(bounded);
|
|
86
|
+
};
|
|
87
|
+
const pick = date => {
|
|
88
|
+
if (matcherHit(disabled, date)) return;
|
|
89
|
+
setFocusDate(date);
|
|
90
|
+
if (mode === 'range') {
|
|
91
|
+
const from = selected?.from;
|
|
92
|
+
const to = selected?.to;
|
|
93
|
+
if (!from || to) onSelect?.({
|
|
94
|
+
from: date,
|
|
95
|
+
to: undefined
|
|
96
|
+
}, date, {}, null);else if (date < from) onSelect?.({
|
|
97
|
+
from: date,
|
|
98
|
+
to: from
|
|
99
|
+
}, date, {}, null);else onSelect?.({
|
|
100
|
+
from,
|
|
101
|
+
to: date
|
|
102
|
+
}, date, {}, null);
|
|
103
|
+
} else if (mode === 'multiple') {
|
|
104
|
+
const values = selected || [];
|
|
105
|
+
const exists = values.some(item => sameDay(item, date));
|
|
106
|
+
onSelect?.(exists ? required && values.length === 1 ? values : values.filter(item => !sameDay(item, date)) : [...values, date], date, {}, null);
|
|
107
|
+
} else onSelect?.(sameDay(selected, date) && !required ? undefined : date, date, {}, null);
|
|
108
|
+
};
|
|
109
|
+
const isSelected = date => mode === 'range' ? sameDay(date, selected?.from) || sameDay(date, selected?.to) : mode === 'multiple' ? (selected || []).some(item => sameDay(item, date)) : sameDay(date, selected);
|
|
110
|
+
const monthViews = Array.from({
|
|
111
|
+
length: numberOfMonths
|
|
112
|
+
}, (_, index) => addMonths(visibleMonth, index));
|
|
113
|
+
const moveFocus = amount => {
|
|
114
|
+
const next = addDays(focusDate, amount);
|
|
115
|
+
setFocusDate(next);
|
|
116
|
+
if (next.getMonth() !== visibleMonth.getMonth() || next.getFullYear() !== visibleMonth.getFullYear()) setMonth(new Date(next.getFullYear(), next.getMonth(), 1));
|
|
91
117
|
};
|
|
92
118
|
React.useEffect(() => {
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}, [focusTarget, y, m]);
|
|
102
|
-
const onGridKey = e => {
|
|
103
|
-
const map = {
|
|
119
|
+
const target = gridRef.current?.querySelector(`[data-key="${dayKey(focusDate)}"]`);
|
|
120
|
+
if (target && (gridRef.current.contains(document.activeElement) || document.activeElement === document.body)) target.focus();
|
|
121
|
+
}, [focusDate, visibleMonth]);
|
|
122
|
+
const keydown = event => {
|
|
123
|
+
const horizontal = direction === 'rtl' ? {
|
|
124
|
+
ArrowLeft: 1,
|
|
125
|
+
ArrowRight: -1
|
|
126
|
+
} : {
|
|
104
127
|
ArrowLeft: -1,
|
|
105
|
-
ArrowRight: 1
|
|
106
|
-
ArrowUp: -7,
|
|
107
|
-
ArrowDown: 7
|
|
128
|
+
ArrowRight: 1
|
|
108
129
|
};
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
} else if (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const base = new Date(focusTarget + 'T00:00:00');
|
|
124
|
-
const [ty, tm] = e.key === 'PageUp' ? m === 0 ? [y - 1, 11] : [y, m - 1] : m === 11 ? [y + 1, 0] : [y, m + 1];
|
|
125
|
-
const clamped = Math.min(base.getDate(), new Date(ty, tm + 1, 0).getDate());
|
|
126
|
-
setFocusIso(iso(new Date(ty, tm, clamped)));
|
|
127
|
-
setView([ty, tm]);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
// Range selection: first pick opens a range, the second closes it (swapped
|
|
131
|
-
// when it lands earlier — ISO strings compare correctly), a third starts over.
|
|
132
|
-
const pick = id => {
|
|
133
|
-
setFocusIso(id);
|
|
134
|
-
if (!onChange) return;
|
|
135
|
-
if (!range) {
|
|
136
|
-
onChange(id);
|
|
137
|
-
return;
|
|
130
|
+
if (horizontal[event.key]) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
moveFocus(horizontal[event.key]);
|
|
133
|
+
} else if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
moveFocus(event.key === 'ArrowUp' ? -7 : 7);
|
|
136
|
+
} else if (event.key === 'Home' || event.key === 'End') {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
moveFocus((event.key === 'Home' ? 0 : 6) - focusDate.getDay());
|
|
139
|
+
} else if (event.key === 'PageUp' || event.key === 'PageDown') {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
const next = addMonths(focusDate, event.key === 'PageUp' ? -1 : 1);
|
|
142
|
+
setFocusDate(new Date(next.getFullYear(), next.getMonth(), Math.min(focusDate.getDate(), new Date(next.getFullYear(), next.getMonth() + 1, 0).getDate())));
|
|
143
|
+
setMonth(next);
|
|
138
144
|
}
|
|
139
|
-
if (!from || to) onChange({
|
|
140
|
-
from: id,
|
|
141
|
-
to: null
|
|
142
|
-
});else if (id < from) onChange({
|
|
143
|
-
from: id,
|
|
144
|
-
to: from
|
|
145
|
-
});else onChange({
|
|
146
|
-
from,
|
|
147
|
-
to: id
|
|
148
|
-
});
|
|
149
145
|
};
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
const monthLabel = date => formatters.formatCaption?.(date) || new Intl.DateTimeFormat(localeCode, {
|
|
147
|
+
month: 'long',
|
|
148
|
+
year: 'numeric'
|
|
149
|
+
}).format(date);
|
|
150
|
+
const weekday = date => formatters.formatWeekdayName?.(date) || new Intl.DateTimeFormat(localeCode, {
|
|
151
|
+
weekday: 'short'
|
|
152
|
+
}).format(date);
|
|
153
|
+
const years = Array.from({
|
|
154
|
+
length: (endMonth?.getFullYear() || visibleMonth.getFullYear() + 10) - (startMonth?.getFullYear() || visibleMonth.getFullYear() - 100) + 1
|
|
155
|
+
}, (_, i) => (startMonth?.getFullYear() || visibleMonth.getFullYear() - 100) + i);
|
|
153
156
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
154
|
-
|
|
157
|
+
dir: direction,
|
|
158
|
+
"data-slot": "calendar",
|
|
159
|
+
className: `ef-cal${className ? ` ${className}` : ''}`,
|
|
155
160
|
style: style
|
|
156
161
|
}), /*#__PURE__*/React.createElement("div", {
|
|
157
|
-
className:
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
"
|
|
199
|
-
"aria-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
162
|
+
className: `ef-cal__months${classNames.months ? ` ${classNames.months}` : ''}`
|
|
163
|
+
}, monthViews.map((view, viewIndex) => {
|
|
164
|
+
const first = new Date(view.getFullYear(), view.getMonth(), 1);
|
|
165
|
+
const nextDisabled = !!endMonth && view.getTime() >= new Date(endMonth.getFullYear(), endMonth.getMonth(), 1).getTime();
|
|
166
|
+
const start = addDays(first, -first.getDay());
|
|
167
|
+
const count = fixedWeeks ? 42 : Math.ceil((first.getDay() + new Date(view.getFullYear(), view.getMonth() + 1, 0).getDate()) / 7) * 7;
|
|
168
|
+
const cells = Array.from({
|
|
169
|
+
length: count
|
|
170
|
+
}, (_, index) => addDays(start, index));
|
|
171
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
172
|
+
className: "ef-cal__month-wrap",
|
|
173
|
+
key: dayKey(view)
|
|
174
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
175
|
+
className: "ef-cal__head"
|
|
176
|
+
}, viewIndex === 0 ? /*#__PURE__*/React.createElement(IconButton, {
|
|
177
|
+
icon: direction === 'rtl' ? 'chevron-right' : 'chevron-left',
|
|
178
|
+
label: "Previous month",
|
|
179
|
+
size: "sm",
|
|
180
|
+
disabled: !!startMonth && view <= new Date(startMonth.getFullYear(), startMonth.getMonth(), 1),
|
|
181
|
+
onClick: () => setMonth(addMonths(visibleMonth, -1))
|
|
182
|
+
}) : null, captionLayout === 'dropdown' || captionLayout === 'dropdown-months' || captionLayout === 'dropdown-years' ? /*#__PURE__*/React.createElement("div", {
|
|
183
|
+
className: "ef-cal__dropdowns"
|
|
184
|
+
}, captionLayout !== 'dropdown-years' ? /*#__PURE__*/React.createElement(NativeSelect, {
|
|
185
|
+
"aria-label": "Month",
|
|
186
|
+
value: String(view.getMonth()),
|
|
187
|
+
onChange: event => setMonth(new Date(view.getFullYear(), Number(event.target.value), 1))
|
|
188
|
+
}, Array.from({
|
|
189
|
+
length: 12
|
|
190
|
+
}, (_, index) => /*#__PURE__*/React.createElement(NativeSelectOption, {
|
|
191
|
+
key: index,
|
|
192
|
+
value: String(index)
|
|
193
|
+
}, new Intl.DateTimeFormat(localeCode, {
|
|
194
|
+
month: 'short'
|
|
195
|
+
}).format(new Date(2024, index, 1))))) : null, captionLayout !== 'dropdown-months' ? /*#__PURE__*/React.createElement(NativeSelect, {
|
|
196
|
+
"aria-label": "Year",
|
|
197
|
+
value: String(view.getFullYear()),
|
|
198
|
+
onChange: event => setMonth(new Date(Number(event.target.value), view.getMonth(), 1))
|
|
199
|
+
}, years.map(year => /*#__PURE__*/React.createElement(NativeSelectOption, {
|
|
200
|
+
key: year,
|
|
201
|
+
value: String(year)
|
|
202
|
+
}, year))) : null) : /*#__PURE__*/React.createElement("div", {
|
|
203
|
+
className: "ef-cal__caption",
|
|
204
|
+
"aria-live": "polite"
|
|
205
|
+
}, monthLabel(view)), viewIndex === monthViews.length - 1 ? /*#__PURE__*/React.createElement(IconButton, {
|
|
206
|
+
icon: direction === 'rtl' ? 'chevron-left' : 'chevron-right',
|
|
207
|
+
label: "Next month",
|
|
208
|
+
size: "sm",
|
|
209
|
+
disabled: nextDisabled,
|
|
210
|
+
onClick: () => setMonth(addMonths(visibleMonth, 1))
|
|
211
|
+
}) : null), /*#__PURE__*/React.createElement("div", {
|
|
212
|
+
role: "grid",
|
|
213
|
+
ref: viewIndex === 0 ? gridRef : undefined,
|
|
214
|
+
onKeyDown: keydown,
|
|
215
|
+
"aria-label": monthLabel(view),
|
|
216
|
+
className: "ef-cal__grid"
|
|
217
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
218
|
+
role: "row",
|
|
219
|
+
className: "ef-cal__row"
|
|
220
|
+
}, Array.from({
|
|
221
|
+
length: 7
|
|
222
|
+
}, (_, index) => {
|
|
223
|
+
const date = addDays(new Date(2024, 0, 7), index);
|
|
224
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
225
|
+
key: index,
|
|
226
|
+
role: "columnheader",
|
|
227
|
+
className: "ef-cal__dow"
|
|
228
|
+
}, weekday(date));
|
|
229
|
+
})), Array.from({
|
|
230
|
+
length: count / 7
|
|
231
|
+
}, (_, row) => /*#__PURE__*/React.createElement("div", {
|
|
232
|
+
role: "row",
|
|
233
|
+
className: "ef-cal__row",
|
|
234
|
+
key: row
|
|
235
|
+
}, cells.slice(row * 7, row * 7 + 7).map(date => {
|
|
236
|
+
const outside = date.getMonth() !== view.getMonth();
|
|
237
|
+
if (outside && !showOutsideDays) return /*#__PURE__*/React.createElement("span", {
|
|
238
|
+
key: dayKey(date)
|
|
239
|
+
});
|
|
240
|
+
const rangeStart = mode === 'range' && sameDay(date, selected?.from);
|
|
241
|
+
const rangeEnd = mode === 'range' && sameDay(date, selected?.to);
|
|
242
|
+
const rangeMiddle = mode === 'range' && selected?.from && selected?.to && date > selected.from && date < selected.to;
|
|
243
|
+
const modifiers = {
|
|
244
|
+
selected: isSelected(date),
|
|
245
|
+
today: sameDay(date, new Date()),
|
|
246
|
+
outside,
|
|
247
|
+
disabled: matcherHit(disabled, date),
|
|
248
|
+
range_start: rangeStart,
|
|
249
|
+
range_end: rangeEnd,
|
|
250
|
+
range_middle: rangeMiddle
|
|
251
|
+
};
|
|
252
|
+
return /*#__PURE__*/React.createElement(DayButton, {
|
|
253
|
+
key: dayKey(date),
|
|
254
|
+
day: {
|
|
255
|
+
date
|
|
256
|
+
},
|
|
257
|
+
modifiers: modifiers,
|
|
258
|
+
locale: locale,
|
|
259
|
+
role: "gridcell",
|
|
260
|
+
"data-key": dayKey(date),
|
|
261
|
+
tabIndex: sameDay(date, focusDate) ? 0 : -1,
|
|
262
|
+
"aria-label": date.toLocaleDateString(localeCode, {
|
|
263
|
+
dateStyle: 'long'
|
|
264
|
+
}),
|
|
265
|
+
"aria-selected": modifiers.selected || undefined,
|
|
266
|
+
disabled: modifiers.disabled,
|
|
267
|
+
onClick: () => pick(date)
|
|
268
|
+
}, date.getDate());
|
|
269
|
+
})))));
|
|
270
|
+
})));
|
|
205
271
|
}
|
package/dates/TimePicker.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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
4
|
import { Icon } from "../icons/Icon.js";
|
|
5
|
-
import { useFieldProps } from "../forms/
|
|
5
|
+
import { useFieldProps } from "../forms/Field.js";
|
|
6
6
|
import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
|
|
7
7
|
const toMin = t => {
|
|
8
8
|
const p = t.split(':');
|
|
@@ -45,7 +45,7 @@ export function TimePicker({
|
|
|
45
45
|
className,
|
|
46
46
|
...rest
|
|
47
47
|
}) {
|
|
48
|
-
// Picks up id / aria wiring when nested in a
|
|
48
|
+
// Picks up id / aria wiring when nested in a Field; standalone this is a no-op.
|
|
49
49
|
const field = useFieldProps({
|
|
50
50
|
invalid,
|
|
51
51
|
id: rest.id,
|
package/display/Accordion.d.ts
CHANGED
|
@@ -1,15 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface AccordionBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
orientation?: 'horizontal' | 'vertical';
|
|
6
|
+
dir?: 'ltr' | 'rtl';
|
|
7
|
+
loop?: boolean;
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AccordionSingleProps extends AccordionBaseProps {
|
|
12
|
+
type?: 'single';
|
|
13
|
+
value?: string;
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
16
|
+
collapsible?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AccordionMultipleProps extends AccordionBaseProps {
|
|
20
|
+
type: 'multiple';
|
|
21
|
+
value?: string[];
|
|
22
|
+
defaultValue?: string[];
|
|
23
|
+
onValueChange?: (value: string[]) => void;
|
|
24
|
+
collapsible?: never;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type AccordionProps = AccordionSingleProps | AccordionMultipleProps;
|
|
28
|
+
|
|
29
|
+
export interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
30
|
+
value: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
asChild?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface AccordionTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
36
|
+
asChild?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface AccordionContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
forceMount?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare const Accordion: React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<HTMLDivElement>>;
|
|
45
|
+
export declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
46
|
+
export declare const AccordionTrigger: React.ForwardRefExoticComponent<AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
47
|
+
export declare const AccordionContent: React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
|