@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.
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 +652 -418
  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 +22 -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
@@ -1,111 +0,0 @@
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
- // The trigger's date label; locale defaults to en-US so the display is unchanged
9
- // unless a locale is passed.
10
- const fmt = (v, locale) => {
11
- if (!v) return null;
12
- const d = new Date(v + 'T00:00:00');
13
- return d.toLocaleDateString(locale || 'en-US', {
14
- month: 'short',
15
- day: 'numeric',
16
- year: 'numeric'
17
- });
18
- };
19
- export function DatePicker({
20
- label,
21
- value,
22
- defaultValue,
23
- onChange,
24
- placeholder = 'Pick a date',
25
- locale,
26
- style,
27
- className,
28
- ...rest
29
- }) {
30
- // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
31
- const field = useFieldProps({
32
- id: rest.id,
33
- 'aria-describedby': rest['aria-describedby']
34
- });
35
- const [inner, setInner] = React.useState(defaultValue || '');
36
- const v = value != null ? value : inner;
37
- const [open, setOpen] = React.useState(false);
38
- const ref = React.useRef(null);
39
- const btnRef = React.useRef(null);
40
- const panelRef = React.useRef(null);
41
- const {
42
- style: anchored
43
- } = useAnchoredStyle(ref, panelRef, {
44
- open,
45
- placement: 'bottom',
46
- align: 'start'
47
- });
48
- React.useEffect(() => {
49
- if (!open) return;
50
- // the calendar is portaled out of `ref`, so look for it in the panel
51
- const day = panelRef.current && panelRef.current.querySelector('[role="gridcell"][tabindex="0"]');
52
- if (day) day.focus();
53
- const away = e => {
54
- const inTrigger = ref.current && ref.current.contains(e.target);
55
- const inPanel = panelRef.current && panelRef.current.contains(e.target);
56
- if (!inTrigger && !inPanel) setOpen(false);
57
- };
58
- const key = e => {
59
- if (e.key === 'Escape') {
60
- setOpen(false);
61
- if (btnRef.current) btnRef.current.focus();
62
- }
63
- };
64
- document.addEventListener('mousedown', away);
65
- document.addEventListener('keydown', key);
66
- return () => {
67
- document.removeEventListener('mousedown', away);
68
- document.removeEventListener('keydown', key);
69
- };
70
- }, [open]);
71
- return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
72
- ref: ref,
73
- className: `ef-datepicker${className ? ' ' + className : ''}`,
74
- style: style
75
- }), label ? /*#__PURE__*/React.createElement("span", {
76
- className: "ef-datepicker__label"
77
- }, label) : null, /*#__PURE__*/React.createElement("button", _extends({}, field.controlProps, {
78
- type: "button",
79
- ref: btnRef,
80
- "aria-haspopup": "dialog",
81
- "aria-expanded": open,
82
- className: `ef-datepicker__btn${v ? '' : ' ef-datepicker__btn--empty'}`,
83
- onClick: () => setOpen(o => !o)
84
- }), /*#__PURE__*/React.createElement(Icon, {
85
- name: "calendar",
86
- size: 15,
87
- style: {
88
- color: 'var(--text-muted)'
89
- }
90
- }), fmt(v, locale) || placeholder, /*#__PURE__*/React.createElement(Icon, {
91
- name: "chevron-down",
92
- size: 14,
93
- style: {
94
- color: 'var(--text-muted)',
95
- marginLeft: 'auto'
96
- }
97
- })), open && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
98
- ref: panelRef,
99
- className: "ef-datepicker__pop",
100
- style: anchored
101
- }, /*#__PURE__*/React.createElement(Calendar, {
102
- value: v || undefined,
103
- locale: locale,
104
- onChange: d => {
105
- if (value == null) setInner(d);
106
- if (onChange) onChange(d);
107
- setOpen(false);
108
- if (btnRef.current) btnRef.current.focus();
109
- }
110
- }))));
111
- }
@@ -1,23 +0,0 @@
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
- /** BCP 47 locale for the trigger's date labels and the calendar's names via Intl (e.g. 'id', 'en'); omit for en-US. */
19
- locale?: string;
20
- style?: React.CSSProperties;
21
- className?: string;
22
- }
23
- export declare function DateRangePicker(props: DateRangePickerProps): React.JSX.Element;
@@ -1,150 +0,0 @@
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, locale) => {
9
- if (!v) return null;
10
- const d = new Date(v + 'T00:00:00');
11
- return d.toLocaleDateString(locale || '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
- locale,
31
- style,
32
- className,
33
- ...rest
34
- }) {
35
- // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
36
- const field = useFieldProps({
37
- id: rest.id,
38
- 'aria-describedby': rest['aria-describedby']
39
- });
40
- const [inner, setInner] = React.useState(EMPTY);
41
- const v = value != null ? value : inner;
42
- const from = v && v.from ? v.from : null;
43
- const to = v && v.to ? v.to : null;
44
- const [open, setOpen] = React.useState(false);
45
- const rootRef = React.useRef(null);
46
- const wrapRef = React.useRef(null);
47
- const btnRef = React.useRef(null);
48
- const panelRef = React.useRef(null);
49
- const {
50
- style: anchored
51
- } = useAnchoredStyle(wrapRef, panelRef, {
52
- open,
53
- placement: 'bottom',
54
- align: 'start'
55
- });
56
- React.useEffect(() => {
57
- if (!open) return;
58
- // the calendar is portaled out of `rootRef`, so look for it in the panel
59
- const day = panelRef.current && panelRef.current.querySelector('[role="gridcell"][tabindex="0"]');
60
- if (day) day.focus();
61
- const away = e => {
62
- const inTrigger = rootRef.current && rootRef.current.contains(e.target);
63
- const inPanel = panelRef.current && panelRef.current.contains(e.target);
64
- if (!inTrigger && !inPanel) setOpen(false);
65
- };
66
- const key = e => {
67
- if (e.key === 'Escape') {
68
- setOpen(false);
69
- if (btnRef.current) btnRef.current.focus();
70
- }
71
- };
72
- document.addEventListener('mousedown', away);
73
- document.addEventListener('keydown', key);
74
- return () => {
75
- document.removeEventListener('mousedown', away);
76
- document.removeEventListener('keydown', key);
77
- };
78
- }, [open]);
79
- const commit = r => {
80
- if (value == null) setInner(r);
81
- if (onChange) onChange(r);
82
- };
83
- // The Calendar itself has no bounds, so a pick outside [min, max] is dropped
84
- // here: any change whose ends stray out of the window never commits.
85
- const inBounds = d => !d || (!min || d >= min) && (!max || d <= max);
86
- const handlePick = r => {
87
- if (!inBounds(r.from) || !inBounds(r.to)) return;
88
- commit(r);
89
- if (r.from && r.to) {
90
- setOpen(false);
91
- if (btnRef.current) btnRef.current.focus();
92
- }
93
- };
94
- const clear = () => {
95
- commit(EMPTY);
96
- if (btnRef.current) btnRef.current.focus();
97
- };
98
- const text = from || to ? `${fmt(from, locale) || '…'} — ${fmt(to, locale) || '…'}` : null;
99
- return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
100
- ref: rootRef,
101
- className: `ef-daterange${className ? ' ' + className : ''}`,
102
- style: style
103
- }), label ? /*#__PURE__*/React.createElement("span", {
104
- className: "ef-daterange__label"
105
- }, label) : null, /*#__PURE__*/React.createElement("span", {
106
- ref: wrapRef,
107
- className: "ef-daterange__wrap"
108
- }, /*#__PURE__*/React.createElement("button", _extends({}, field.controlProps, {
109
- type: "button",
110
- ref: btnRef,
111
- disabled: disabled,
112
- "aria-haspopup": "dialog",
113
- "aria-expanded": open,
114
- className: `ef-daterange__btn${text ? '' : ' ef-daterange__btn--empty'}`,
115
- onClick: () => setOpen(o => !o)
116
- }), /*#__PURE__*/React.createElement(Icon, {
117
- name: "calendar",
118
- size: 15,
119
- style: {
120
- color: 'var(--text-muted)'
121
- }
122
- }), text || placeholder), text && !disabled ? /*#__PURE__*/React.createElement("button", {
123
- type: "button",
124
- className: "ef-daterange__clear",
125
- "aria-label": "Clear date range",
126
- onClick: clear
127
- }, /*#__PURE__*/React.createElement(Icon, {
128
- name: "x",
129
- size: 13
130
- })) : /*#__PURE__*/React.createElement("span", {
131
- className: "ef-daterange__chevron"
132
- }, /*#__PURE__*/React.createElement(Icon, {
133
- name: "chevron-down",
134
- size: 14
135
- }))), hint ? /*#__PURE__*/React.createElement("span", {
136
- className: "ef-daterange__hint"
137
- }, hint) : null, open && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
138
- ref: panelRef,
139
- className: "ef-daterange__pop",
140
- style: anchored
141
- }, /*#__PURE__*/React.createElement(Calendar, {
142
- range: true,
143
- value: {
144
- from,
145
- to
146
- },
147
- locale: locale,
148
- onChange: handlePick
149
- }))));
150
- }
@@ -1,19 +0,0 @@
1
- export interface ListItemProps {
2
- /** Lucide icon in a 32px sunken square */
3
- icon?: string;
4
- /** Custom leading node (Avatar, FileTypeIcon…) — overrides icon */
5
- media?: React.ReactNode;
6
- title: React.ReactNode;
7
- description?: React.ReactNode;
8
- /** Right-aligned slot (Badge, time, Switch…) */
9
- trailing?: React.ReactNode;
10
- /** Trailing chevron */
11
- chevron?: boolean;
12
- /** Renders as button */
13
- onClick?: (e: React.MouseEvent) => void;
14
- /** Renders as anchor */
15
- href?: string;
16
- style?: React.CSSProperties;
17
- className?: string;
18
- }
19
- export declare function ListItem(props: ListItemProps): React.JSX.Element;
@@ -1,50 +0,0 @@
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
- export function ListItem({
6
- icon,
7
- media,
8
- title,
9
- description,
10
- trailing,
11
- chevron,
12
- onClick,
13
- href,
14
- style,
15
- className,
16
- ...rest
17
- }) {
18
- const Tag = href ? 'a' : onClick ? 'button' : 'div';
19
- return /*#__PURE__*/React.createElement(Tag, _extends({}, rest, {
20
- href: href,
21
- onClick: onClick,
22
- className: `ef-listitem${className ? ' ' + className : ''}`,
23
- style: style
24
- }), media ? media : icon ? /*#__PURE__*/React.createElement("span", {
25
- className: "ef-listitem__media"
26
- }, /*#__PURE__*/React.createElement(Icon, {
27
- name: icon,
28
- size: 16
29
- })) : null, /*#__PURE__*/React.createElement("span", {
30
- style: {
31
- minWidth: 0,
32
- flex: 1
33
- }
34
- }, /*#__PURE__*/React.createElement("span", {
35
- className: "ef-listitem__title",
36
- style: {
37
- display: 'block'
38
- }
39
- }, title), description ? /*#__PURE__*/React.createElement("span", {
40
- className: "ef-listitem__desc",
41
- style: {
42
- display: 'block'
43
- }
44
- }, description) : null), /*#__PURE__*/React.createElement("span", {
45
- className: "ef-listitem__trailing"
46
- }, trailing, chevron ? /*#__PURE__*/React.createElement(Icon, {
47
- name: "chevron-right",
48
- size: 15
49
- }) : null));
50
- }
@@ -1,78 +0,0 @@
1
- export interface ToastProps {
2
- /** @default 'info' */
3
- tone?: 'info' | 'success' | 'warning' | 'danger';
4
- title: React.ReactNode;
5
- description?: React.ReactNode;
6
- /** Action slot, a node rendered as-is (prevents auto-dismiss per WCAG 2.2.1). */
7
- action?: React.ReactNode;
8
- /** @deprecated pass a node to `action` instead */
9
- actionLabel?: string;
10
- /** @deprecated pass a node to `action` instead */
11
- onAction?: () => void;
12
- /** Shows a dismiss ✕ */
13
- onClose?: () => void;
14
- /**
15
- * Live-region role. Inside a `Toaster` the stack owns the live region and each
16
- * toast renders with `null`, so a queue announces once rather than as N
17
- * competing regions. @default 'status'
18
- */
19
- role?: 'status' | 'alert' | null;
20
- style?: React.CSSProperties;
21
- className?: string;
22
- }
23
- export declare function Toast(props: ToastProps): React.JSX.Element;
24
-
25
- export interface ToastStackProps {
26
- /** Toasts, stacked fixed bottom-right */
27
- children?: React.ReactNode;
28
- style?: React.CSSProperties;
29
- className?: string;
30
- }
31
- export declare function ToastStack(props: ToastStackProps): React.JSX.Element;
32
-
33
- export interface ToastOptions {
34
- title: React.ReactNode;
35
- description?: React.ReactNode;
36
- /** @default 'info' */
37
- tone?: 'info' | 'success' | 'warning' | 'danger';
38
- /** Action slot, a node rendered as-is (prevents auto-dismiss per WCAG 2.2.1). */
39
- action?: React.ReactNode;
40
- /** @deprecated pass a node to `action` instead */
41
- actionLabel?: string;
42
- /** @deprecated pass a node to `action` instead */
43
- onAction?: () => void;
44
- /**
45
- * ms before auto-dismiss; 0 never dismisses.
46
- * @default the Toaster's `duration`, or 0 when `action`/`actionLabel` is set — a
47
- * control must not vanish on a timer the user cannot adjust (WCAG 2.2.1).
48
- */
49
- duration?: number;
50
- }
51
- export interface ToastApi {
52
- /** Queue a toast; returns its id. */
53
- notify: (options: ToastOptions) => string;
54
- dismiss: (id: string) => void;
55
- dismissAll: () => void;
56
- }
57
- export interface ToasterProps {
58
- /** ms before a toast auto-dismisses; 0 never. @default 5000 */
59
- duration?: number;
60
- /** aria-label of the live region. @default 'Notifications' */
61
- label?: string;
62
- /** Your app. Toaster renders a Fragment, never a wrapper element. */
63
- children?: React.ReactNode;
64
- style?: React.CSSProperties;
65
- className?: string;
66
- }
67
- /**
68
- * Owns the toast queue: ids, timers, the live region and the portal. Timers
69
- * pause while the stack is hovered or focused.
70
- *
71
- * The hook is published as a static — `Toaster.useToast()` — because only
72
- * capitalised exports reach the global namespace.
73
- */
74
- export declare function Toaster(props: ToasterProps): React.JSX.Element;
75
- export declare namespace Toaster {
76
- /** Must be called inside a `<Toaster>`; throws otherwise. */
77
- function useToast(): ToastApi;
78
- }
package/feedback/Toast.js DELETED
@@ -1,192 +0,0 @@
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 { IconButton } from "../forms/IconButton.js";
6
- import { Portal } from "../overlay/Portal.js";
7
- const ICONS = {
8
- success: 'circle-check',
9
- danger: 'circle-alert',
10
- warning: 'triangle-alert',
11
- info: 'info'
12
- };
13
- export function Toast({
14
- tone = 'info',
15
- title,
16
- description,
17
- action,
18
- actionLabel,
19
- onAction,
20
- onClose,
21
- role = 'status',
22
- style,
23
- className,
24
- ...rest
25
- }) {
26
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
27
- className: `ef-toast ef-toast--${tone}${className ? ' ' + className : ''}`,
28
- role: role || undefined,
29
- style: style
30
- }), /*#__PURE__*/React.createElement("span", {
31
- className: "ef-toast__icon"
32
- }, /*#__PURE__*/React.createElement(Icon, {
33
- name: ICONS[tone] || 'info',
34
- size: 18
35
- })), /*#__PURE__*/React.createElement("div", {
36
- style: {
37
- flex: 1
38
- }
39
- }, /*#__PURE__*/React.createElement("div", {
40
- className: "ef-toast__title"
41
- }, title), description ? /*#__PURE__*/React.createElement("div", {
42
- className: "ef-toast__desc"
43
- }, description) : null, action ? action : actionLabel ? /*#__PURE__*/React.createElement("button", {
44
- className: "ef-toast__action",
45
- onClick: onAction
46
- }, actionLabel) : null), onClose ? /*#__PURE__*/React.createElement(IconButton, {
47
- icon: "x",
48
- label: "Dismiss",
49
- size: "sm",
50
- onClick: onClose
51
- }) : null);
52
- }
53
- export function ToastStack({
54
- children,
55
- style,
56
- className,
57
- ...rest
58
- }) {
59
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
60
- className: `ef-toast-stack${className ? ' ' + className : ''}`,
61
- style: style
62
- }), children);
63
- }
64
- const ToastCtx = /*#__PURE__*/React.createContext(null);
65
-
66
- /**
67
- * The toast queue API: notify, dismiss, dismissAll.
68
- *
69
- * Lowercase, so the compiler files it under unexposedExports and it never
70
- * reaches the global namespace directly. Consumers get it as `Toaster.useToast`
71
- * (assigned at the bottom of this file), which is the one sanctioned way to
72
- * publish a hook when only capitalised exports are exposed.
73
- *
74
- * Throws outside a <Toaster> rather than degrading to a no-op: a notification
75
- * that silently never appears is the harder bug to find.
76
- */
77
- export function useToast() {
78
- const ctx = React.useContext(ToastCtx);
79
- if (!ctx) throw new Error('useToast must be called inside a <Toaster>');
80
- return ctx;
81
- }
82
-
83
- /**
84
- * Owns the toast queue: ids, timers, the live region, and the portal.
85
- *
86
- * Renders a Fragment around your app plus one portaled stack, so it can sit at
87
- * the root without introducing a wrapper element.
88
- */
89
- export function Toaster({
90
- duration = 5000,
91
- label = 'Notifications',
92
- children,
93
- ...rest
94
- }) {
95
- const uid = React.useId();
96
- const seq = React.useRef(0);
97
- const [toasts, setToasts] = React.useState([]);
98
- const timers = React.useRef(new Map());
99
- const dismiss = React.useCallback(id => {
100
- const rec = timers.current.get(id);
101
- if (rec && rec.handle) clearTimeout(rec.handle);
102
- timers.current.delete(id);
103
- setToasts(list => list.filter(x => x.id !== id));
104
- }, []);
105
- const arm = React.useCallback((id, ms) => {
106
- const rec = {
107
- remaining: ms,
108
- startedAt: Date.now(),
109
- handle: null
110
- };
111
- rec.handle = setTimeout(() => dismiss(id), ms);
112
- timers.current.set(id, rec);
113
- }, [dismiss]);
114
- const notify = React.useCallback(options => {
115
- const id = uid + seq.current++;
116
- const {
117
- duration: own,
118
- ...props
119
- } = options || {};
120
- // A toast carrying an action must not time out: WCAG 2.2.1 does not allow a
121
- // control to disappear on a timer the user cannot adjust.
122
- const ms = own != null ? own : props.action || props.actionLabel ? 0 : duration;
123
- setToasts(list => [...list, {
124
- id,
125
- props
126
- }]);
127
- if (ms > 0) arm(id, ms);
128
- return id;
129
- }, [uid, duration, arm]);
130
- const dismissAll = React.useCallback(() => {
131
- timers.current.forEach(rec => {
132
- if (rec.handle) clearTimeout(rec.handle);
133
- });
134
- timers.current.clear();
135
- setToasts([]);
136
- }, []);
137
- React.useEffect(() => () => {
138
- timers.current.forEach(rec => {
139
- if (rec.handle) clearTimeout(rec.handle);
140
- });
141
- timers.current.clear();
142
- }, []);
143
-
144
- // Hovering or focusing the stack holds every pending timer, so a slow reader
145
- // or a keyboard user can actually reach the action inside a toast.
146
- const pause = () => {
147
- timers.current.forEach(rec => {
148
- if (!rec.handle) return;
149
- clearTimeout(rec.handle);
150
- rec.remaining = Math.max(0, rec.remaining - (Date.now() - rec.startedAt));
151
- rec.handle = null;
152
- });
153
- };
154
- const resume = () => {
155
- // A toast whose time ran out while paused must go on unpause, not become
156
- // permanent. Collect them first: dismiss() mutates the map being iterated.
157
- const expired = [];
158
- timers.current.forEach((rec, id) => {
159
- if (rec.handle) return;
160
- if (rec.remaining <= 0) {
161
- expired.push(id);
162
- return;
163
- }
164
- rec.startedAt = Date.now();
165
- rec.handle = setTimeout(() => dismiss(id), rec.remaining);
166
- });
167
- expired.forEach(dismiss);
168
- };
169
- const api = React.useMemo(() => ({
170
- notify,
171
- dismiss,
172
- dismissAll
173
- }), [notify, dismiss, dismissAll]);
174
- return /*#__PURE__*/React.createElement(ToastCtx.Provider, {
175
- value: api
176
- }, children, /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(ToastStack, _extends({}, rest, {
177
- "aria-label": label,
178
- role: "log",
179
- "aria-live": "polite",
180
- "aria-relevant": "additions",
181
- onMouseEnter: pause,
182
- onMouseLeave: resume,
183
- onFocusCapture: pause,
184
- onBlurCapture: resume
185
- }), toasts.map(t => /*#__PURE__*/React.createElement(Toast, _extends({
186
- key: t.id
187
- }, t.props, {
188
- role: null,
189
- onClose: () => dismiss(t.id)
190
- }))))));
191
- }
192
- Toaster.useToast = useToast;
@@ -1,15 +0,0 @@
1
- export interface DigitEntryProps {
2
- /** Number of cells @default 6 */
3
- length?: number;
4
- /** Controlled value (digits only) */
5
- value?: string;
6
- onChange?: (value: string) => void;
7
- /** Fires when all cells are filled */
8
- onComplete?: (value: string) => void;
9
- label?: string;
10
- invalid?: boolean;
11
- disabled?: boolean;
12
- style?: React.CSSProperties;
13
- className?: string;
14
- }
15
- export declare function DigitEntry(props: DigitEntryProps): React.JSX.Element;