@efolusi/meridian 1.19.1 → 1.21.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.
Files changed (183) hide show
  1. package/README.md +1 -1
  2. package/ai/Bubble.d.ts +16 -0
  3. package/ai/Bubble.js +71 -0
  4. package/ai/ChatMessage.js +2 -5
  5. package/ai/Confirmation.d.ts +0 -7
  6. package/ai/Confirmation.js +3 -6
  7. package/ai/GeneratedImage.d.ts +0 -2
  8. package/ai/GeneratedImage.js +2 -4
  9. package/ai/Marker.d.ts +26 -0
  10. package/ai/Marker.js +67 -0
  11. package/ai/Message.d.ts +13 -0
  12. package/ai/Message.js +68 -0
  13. package/ai/MessageScroller.d.ts +21 -0
  14. package/ai/MessageScroller.js +283 -0
  15. package/ai/ModelSelector.d.ts +2 -2
  16. package/ai/ModelSelector.js +1 -2
  17. package/ai/Player.js +1 -1
  18. package/ai/PromptSteps.js +4 -2
  19. package/ai/Sandbox.d.ts +0 -2
  20. package/ai/Sandbox.js +2 -4
  21. package/ai/Suggestions.d.ts +0 -2
  22. package/ai/Suggestions.js +1 -4
  23. package/ai/WebPreview.d.ts +0 -2
  24. package/ai/WebPreview.js +2 -4
  25. package/code/Console.js +1 -1
  26. package/code/EnvList.d.ts +0 -2
  27. package/code/EnvList.js +2 -3
  28. package/components.css +660 -423
  29. package/data/BarChart.d.ts +0 -2
  30. package/data/BarChart.js +1 -4
  31. package/data/Chart.d.ts +14 -0
  32. package/data/Chart.js +149 -0
  33. package/data/EmptyState.d.ts +8 -13
  34. package/data/EmptyState.js +62 -24
  35. package/data/LineChart.js +7 -4
  36. package/data/Skeleton.d.ts +2 -11
  37. package/data/Skeleton.js +8 -38
  38. package/data/Sparkline.js +4 -1
  39. package/data/StatusDot.d.ts +0 -4
  40. package/data/StatusDot.js +3 -6
  41. package/data/Table.d.ts +11 -4
  42. package/data/Table.js +39 -7
  43. package/dates/Calendar.d.ts +10 -27
  44. package/dates/Calendar.js +250 -184
  45. package/dates/TimePicker.js +2 -2
  46. package/display/Accordion.d.ts +47 -15
  47. package/display/Accordion.js +257 -27
  48. package/display/AspectRatio.d.ts +4 -6
  49. package/display/AspectRatio.js +7 -5
  50. package/display/Avatar.d.ts +17 -14
  51. package/display/Avatar.js +68 -43
  52. package/display/Badge.d.ts +9 -8
  53. package/display/Badge.js +32 -14
  54. package/display/Card.d.ts +11 -13
  55. package/display/Card.js +74 -29
  56. package/display/Carousel.d.ts +23 -15
  57. package/display/Carousel.js +217 -66
  58. package/display/Collapsible.d.ts +19 -9
  59. package/display/Collapsible.js +140 -28
  60. package/display/Direction.d.ts +10 -0
  61. package/display/Direction.js +24 -0
  62. package/display/Item.d.ts +19 -0
  63. package/display/Item.js +152 -0
  64. package/display/Kbd.d.ts +5 -7
  65. package/display/Kbd.js +22 -10
  66. package/display/Link.js +2 -4
  67. package/display/Resizable.d.ts +6 -16
  68. package/display/Resizable.js +141 -58
  69. package/display/ScrollArea.d.ts +3 -1
  70. package/display/ScrollArea.js +30 -5
  71. package/display/Separator.d.ts +9 -0
  72. package/display/Separator.js +18 -0
  73. package/display/Timeline.d.ts +24 -0
  74. package/display/Timeline.js +51 -0
  75. package/display/Toolbar.js +5 -4
  76. package/display/TreeList.d.ts +0 -2
  77. package/display/TreeList.js +2 -5
  78. package/feedback/Alert.d.ts +13 -13
  79. package/feedback/Alert.js +40 -36
  80. package/feedback/AlertDialog.d.ts +30 -0
  81. package/feedback/AlertDialog.js +249 -0
  82. package/feedback/Banner.d.ts +1 -3
  83. package/feedback/Banner.js +1 -5
  84. package/feedback/ConfirmDialog.d.ts +1 -1
  85. package/feedback/ConfirmDialog.js +18 -20
  86. package/feedback/Dialog.d.ts +13 -16
  87. package/feedback/Dialog.js +204 -62
  88. package/feedback/Progress.d.ts +8 -9
  89. package/feedback/Progress.js +42 -24
  90. package/feedback/Sonner.d.ts +8 -0
  91. package/feedback/Sonner.js +238 -0
  92. package/feedback/Spinner.d.ts +2 -9
  93. package/feedback/Spinner.js +19 -28
  94. package/feedback/Tooltip.d.ts +9 -10
  95. package/feedback/Tooltip.js +147 -96
  96. package/files/Attachment.d.ts +27 -0
  97. package/files/Attachment.js +111 -0
  98. package/files/FileDrop.js +3 -1
  99. package/finance/PaymentCard.js +3 -3
  100. package/forms/Button.d.ts +6 -5
  101. package/forms/Button.js +42 -8
  102. package/forms/ButtonGroup.d.ts +11 -3
  103. package/forms/ButtonGroup.js +57 -6
  104. package/forms/Checkbox.d.ts +14 -3
  105. package/forms/Checkbox.js +84 -16
  106. package/forms/Combobox.d.ts +24 -16
  107. package/forms/Combobox.js +466 -135
  108. package/forms/Field.d.ts +14 -0
  109. package/forms/Field.js +99 -0
  110. package/forms/IconButton.d.ts +1 -1
  111. package/forms/IconButton.js +4 -3
  112. package/forms/Input.d.ts +8 -8
  113. package/forms/Input.js +46 -33
  114. package/forms/InputGroup.d.ts +8 -15
  115. package/forms/InputGroup.js +74 -35
  116. package/forms/InputOTP.d.ts +13 -0
  117. package/forms/InputOTP.js +125 -0
  118. package/forms/Label.d.ts +2 -6
  119. package/forms/Label.js +6 -4
  120. package/forms/NativeSelect.d.ts +16 -0
  121. package/forms/NativeSelect.js +35 -0
  122. package/forms/NumberInput.js +2 -2
  123. package/forms/Radio.d.ts +12 -1
  124. package/forms/Radio.js +76 -6
  125. package/forms/Select.d.ts +12 -9
  126. package/forms/Select.js +254 -42
  127. package/forms/Slider.d.ts +10 -17
  128. package/forms/Slider.js +78 -39
  129. package/forms/Switch.d.ts +8 -2
  130. package/forms/Switch.js +46 -15
  131. package/forms/Textarea.d.ts +1 -1
  132. package/forms/Textarea.js +26 -18
  133. package/forms/Toggle.d.ts +18 -15
  134. package/forms/Toggle.js +96 -42
  135. package/icons/_svg.js +2 -0
  136. package/index.d.ts +20 -8
  137. package/index.js +50 -38
  138. package/navigation/Breadcrumbs.d.ts +18 -11
  139. package/navigation/Breadcrumbs.js +99 -26
  140. package/navigation/Menubar.d.ts +52 -10
  141. package/navigation/Menubar.js +191 -146
  142. package/navigation/NavigationMenu.d.ts +15 -0
  143. package/navigation/NavigationMenu.js +296 -0
  144. package/navigation/Pagination.d.ts +10 -9
  145. package/navigation/Pagination.js +94 -51
  146. package/navigation/SideNav.js +4 -3
  147. package/navigation/Sidebar.d.ts +29 -0
  148. package/navigation/Sidebar.js +311 -0
  149. package/navigation/Tabs.d.ts +9 -5
  150. package/navigation/Tabs.js +132 -44
  151. package/overlay/Command.d.ts +32 -0
  152. package/overlay/Command.js +257 -0
  153. package/overlay/ContextMenu.d.ts +40 -8
  154. package/overlay/ContextMenu.js +468 -107
  155. package/overlay/Drawer.d.ts +29 -14
  156. package/overlay/Drawer.js +178 -80
  157. package/overlay/DropdownMenu.d.ts +43 -0
  158. package/overlay/DropdownMenu.js +502 -0
  159. package/overlay/HoverCard.d.ts +21 -12
  160. package/overlay/HoverCard.js +129 -61
  161. package/overlay/Popover.d.ts +11 -13
  162. package/overlay/Popover.js +138 -65
  163. package/overlay/Portal.js +21 -7
  164. package/overlay/Sheet.d.ts +11 -0
  165. package/overlay/Sheet.js +62 -0
  166. package/package.json +4 -1
  167. package/tokens/base.css +1 -1
  168. package/dates/DatePicker.d.ts +0 -14
  169. package/dates/DatePicker.js +0 -111
  170. package/dates/DateRangePicker.d.ts +0 -23
  171. package/dates/DateRangePicker.js +0 -150
  172. package/display/ListItem.d.ts +0 -19
  173. package/display/ListItem.js +0 -50
  174. package/feedback/Toast.d.ts +0 -78
  175. package/feedback/Toast.js +0 -192
  176. package/forms/DigitEntry.d.ts +0 -15
  177. package/forms/DigitEntry.js +0 -79
  178. package/forms/FormField.d.ts +0 -82
  179. package/forms/FormField.js +0 -209
  180. package/overlay/CommandPalette.d.ts +0 -21
  181. package/overlay/CommandPalette.js +0 -148
  182. package/overlay/Menu.d.ts +0 -24
  183. 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
- const DOW = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
6
- const DOW_FULL = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
7
- const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
8
- const iso = d => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
9
- // Month, weekday and full-date names for a locale, from Intl. Reference dates:
10
- // 2024-01-01 is a Monday, so index 0..6 is Monday..Sunday — matching the grid,
11
- // which stays Monday-first for every locale (week-start localisation depends on
12
- // Intl.Locale weekInfo, which is not portable, so it is deliberately out of scope).
13
- const EN = {
14
- months: MONTHS,
15
- dow: DOW,
16
- dowFull: DOW_FULL,
17
- dayLabel: d => `${d.getDate()} ${MONTHS[d.getMonth()]} ${d.getFullYear()}`
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 localeNames(locale) {
20
- if (!locale) return EN;
21
- const mLong = new Intl.DateTimeFormat(locale, {
22
- month: 'long'
23
- });
24
- const dShort = new Intl.DateTimeFormat(locale, {
25
- weekday: 'short'
26
- });
27
- const dLong = new Intl.DateTimeFormat(locale, {
28
- weekday: 'long'
29
- });
30
- const dayFmt = new Intl.DateTimeFormat(locale, {
31
- day: 'numeric',
32
- month: 'long',
33
- year: 'numeric'
34
- });
35
- return {
36
- months: Array.from({
37
- length: 12
38
- }, (_, i) => mLong.format(new Date(2024, i, 1))),
39
- dow: Array.from({
40
- length: 7
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
- value,
50
- onChange,
51
- range,
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
- style,
62
+ dir,
54
63
  className,
64
+ classNames = {},
65
+ formatters = {},
66
+ components = {},
67
+ buttonVariant,
68
+ style,
55
69
  ...rest
56
70
  }) {
57
- // Names localise when `locale` is set; without it the English constants are
58
- // used unchanged, so this is additive.
59
- const L = React.useMemo(() => localeNames(locale), [locale]);
60
- const {
61
- months: MONTHS_L,
62
- dow: DOW_L,
63
- dowFull: DOW_FULL_L,
64
- dayLabel
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 [focusIso, setFocusIso] = React.useState(() => sel ? iso(sel) : from || today);
85
- const focusTarget = cells.some(d => iso(d) === focusIso) ? focusIso : iso(first);
86
- const move = days => {
87
- const base = new Date(focusTarget + 'T00:00:00');
88
- const next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + days);
89
- setFocusIso(iso(next));
90
- if (next.getMonth() !== m || next.getFullYear() !== y) setView([next.getFullYear(), next.getMonth()]);
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 g = gridRef.current;
94
- if (!g) return;
95
- // A month change unmounts the focused day and drops focus to <body>;
96
- // reclaiming it from there is restoration, not stealing.
97
- const ae = document.activeElement;
98
- if (!(g.contains(ae) || ae === document.body)) return;
99
- const btn = g.querySelector(`[data-iso="${focusTarget}"]`);
100
- if (btn) btn.focus();
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 (e.key in map) {
110
- e.preventDefault();
111
- move(map[e.key]);
112
- return;
113
- }
114
- const dow = () => (new Date(focusTarget + 'T00:00:00').getDay() + 6) % 7;
115
- if (e.key === 'Home') {
116
- e.preventDefault();
117
- move(-dow());
118
- } else if (e.key === 'End') {
119
- e.preventDefault();
120
- move(6 - dow());
121
- } else if (e.key === 'PageUp' || e.key === 'PageDown') {
122
- e.preventDefault();
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 rows = Array.from({
151
- length: 6
152
- }, (_, r) => cells.slice(r * 7, r * 7 + 7));
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
- className: `ef-cal${className ? ' ' + className : ''}`,
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: "ef-cal__head"
158
- }, /*#__PURE__*/React.createElement(IconButton, {
159
- icon: "chevron-left",
160
- label: "Previous month",
161
- size: "sm",
162
- onClick: () => setView(m === 0 ? [y - 1, 11] : [y, m - 1])
163
- }), /*#__PURE__*/React.createElement("span", {
164
- className: "ef-cal__month",
165
- "aria-live": "polite"
166
- }, MONTHS_L[m], " ", y), /*#__PURE__*/React.createElement(IconButton, {
167
- icon: "chevron-right",
168
- label: "Next month",
169
- size: "sm",
170
- onClick: () => setView(m === 11 ? [y + 1, 0] : [y, m + 1])
171
- })), /*#__PURE__*/React.createElement("div", {
172
- role: "grid",
173
- ref: gridRef,
174
- onKeyDown: onGridKey,
175
- "aria-label": `${MONTHS_L[m]} ${y}`,
176
- className: "ef-cal__grid"
177
- }, /*#__PURE__*/React.createElement("div", {
178
- role: "row",
179
- className: "ef-cal__row"
180
- }, DOW_L.map((d, i) => /*#__PURE__*/React.createElement("span", {
181
- key: i,
182
- role: "columnheader",
183
- "aria-label": DOW_FULL_L[i],
184
- className: "ef-cal__dow"
185
- }, d))), rows.map((row, ri) => /*#__PURE__*/React.createElement("div", {
186
- role: "row",
187
- className: "ef-cal__row",
188
- key: ri
189
- }, row.map(d => {
190
- const id = iso(d);
191
- const isEnd = range && (id === from || id === to);
192
- const inBand = range && from && to && id > from && id < to;
193
- return /*#__PURE__*/React.createElement("button", {
194
- key: id,
195
- role: "gridcell",
196
- "data-iso": id,
197
- tabIndex: id === focusTarget ? 0 : -1,
198
- "aria-selected": range ? from || to ? isEnd : undefined : sel ? id === iso(sel) : undefined,
199
- "aria-current": id === today ? 'date' : undefined,
200
- "aria-label": dayLabel(d),
201
- 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' : ''}`,
202
- onClick: () => pick(id)
203
- }, d.getDate());
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
  }
@@ -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/FormField.js";
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 FormField; standalone this is a no-op.
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,
@@ -1,15 +1,47 @@
1
- export interface AccordionItem {
2
- id: string;
3
- title: React.ReactNode;
4
- content: React.ReactNode;
5
- }
6
- export interface AccordionProps {
7
- items: AccordionItem[];
8
- /** Allow several items open at once @default false */
9
- multiple?: boolean;
10
- /** Ids open initially */
11
- defaultOpen?: string[];
12
- style?: React.CSSProperties;
13
- className?: string;
14
- }
15
- export declare function Accordion(props: AccordionProps): React.JSX.Element;
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>>;