@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
@@ -1,128 +1,489 @@
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";
5
- import { Portal } from "./Portal.js";
4
+ import { mergeRefs, useIsoLayoutEffect } from "../forms/Button.js";
6
5
  import { Icon } from "../icons/Icon.js";
6
+ import { Portal, useAnchoredStyle } from "./Portal.js";
7
+ const RootCtx = /*#__PURE__*/React.createContext(null);
8
+ const SubCtx = /*#__PURE__*/React.createContext(null);
9
+ const RadioCtx = /*#__PURE__*/React.createContext(null);
10
+ const join = (...values) => values.filter(Boolean).join(' ');
11
+ const compose = (theirs, ours) => event => {
12
+ theirs?.(event);
13
+ if (!event.defaultPrevented) ours?.(event);
14
+ };
15
+ function menuItems(node) {
16
+ return node ? Array.from(node.querySelectorAll('[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]')).filter(item => !item.disabled && item.dataset.disabled !== 'true') : [];
17
+ }
18
+ function focusRelative(node, direction, loop = true) {
19
+ const items = menuItems(node);
20
+ if (!items.length) return;
21
+ const current = items.indexOf(document.activeElement);
22
+ const raw = Math.max(0, current) + direction;
23
+ const index = direction === 'first' ? 0 : direction === 'last' ? items.length - 1 : loop ? (raw + items.length) % items.length : Math.max(0, Math.min(items.length - 1, raw));
24
+ items[index]?.focus();
25
+ }
26
+ function useMenuKeyboard(ref, close, {
27
+ sub = false,
28
+ loop = true
29
+ } = {}) {
30
+ return event => {
31
+ if (event.defaultPrevented) return;
32
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
33
+ event.preventDefault();
34
+ focusRelative(ref.current, event.key === 'ArrowDown' ? 1 : -1, loop);
35
+ } else if (event.key === 'Home' || event.key === 'End') {
36
+ event.preventDefault();
37
+ focusRelative(ref.current, event.key === 'Home' ? 'first' : 'last');
38
+ } else if (event.key === 'Escape' || sub && event.key === 'ArrowLeft') {
39
+ event.preventDefault();
40
+ close?.();
41
+ } else if (event.key.length === 1 && /\S/.test(event.key) && !event.metaKey && !event.ctrlKey && !event.altKey) {
42
+ const items = menuItems(ref.current);
43
+ const start = Math.max(0, items.indexOf(document.activeElement));
44
+ const key = event.key.toLocaleLowerCase();
45
+ for (let offset = 1; offset <= items.length; offset += 1) {
46
+ const item = items[(start + offset) % items.length];
47
+ if ((item.textContent || '').trim().toLocaleLowerCase().startsWith(key)) {
48
+ event.preventDefault();
49
+ item.focus();
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ };
55
+ }
7
56
  export function ContextMenu({
8
- items,
9
- onSelect,
10
- children,
11
- style,
12
- className,
13
- ...rest
57
+ open: controlled,
58
+ defaultOpen = false,
59
+ onOpenChange,
60
+ modal = true,
61
+ children
14
62
  }) {
15
- const [pos, setPos] = React.useState(null);
16
- const panelRef = React.useRef(null);
17
- const focusItem = which => {
18
- const panel = panelRef.current;
19
- const nodes = panel ? Array.from(panel.querySelectorAll('[role="menuitem"]:not(:disabled)')) : [];
20
- if (!nodes.length) return;
21
- const i = nodes.indexOf(document.activeElement);
22
- const next = which === 'first' ? 0 : which === 'last' ? nodes.length - 1 : (i + which + nodes.length) % nodes.length;
23
- nodes[next].focus();
24
- };
25
- // A fixed panel still escapes overflow, but nothing kept it inside the viewport:
26
- // right-clicking near the bottom or right edge pushed items off-screen.
27
- useIsoLayoutEffect(() => {
28
- const panel = panelRef.current;
29
- if (!pos || !panel) return;
30
- const r = panel.getBoundingClientRect();
31
- const vw = document.documentElement.clientWidth,
32
- vh = document.documentElement.clientHeight,
33
- edge = 8;
34
- const x = Math.max(edge, Math.min(pos.x, vw - r.width - edge));
35
- const y = Math.max(edge, Math.min(pos.y, vh - r.height - edge));
36
- if (x !== pos.x || y !== pos.y) setPos({
63
+ const [inner, setInner] = React.useState(defaultOpen);
64
+ const [point, setPoint] = React.useState({
65
+ x: 0,
66
+ y: 0
67
+ });
68
+ const open = controlled !== undefined ? controlled : inner;
69
+ const triggerRef = React.useRef(null);
70
+ const contentRef = React.useRef(null);
71
+ const setOpen = React.useCallback(next => {
72
+ if (controlled === undefined) setInner(next);
73
+ onOpenChange?.(next);
74
+ }, [controlled, onOpenChange]);
75
+ const openAt = React.useCallback((x, y) => {
76
+ setPoint({
37
77
  x,
38
78
  y
39
79
  });
40
- }, [pos]);
41
- const onPanelKey = e => {
42
- if (e.key === 'ArrowDown') {
43
- e.preventDefault();
44
- focusItem(1);
45
- } else if (e.key === 'ArrowUp') {
46
- e.preventDefault();
47
- focusItem(-1);
48
- } else if (e.key === 'Home') {
49
- e.preventDefault();
50
- focusItem('first');
51
- } else if (e.key === 'End') {
52
- e.preventDefault();
53
- focusItem('last');
54
- } else if (e.key.length === 1 && /\S/.test(e.key) && !e.metaKey && !e.ctrlKey && !e.altKey) {
55
- const nodes = panelRef.current ? Array.from(panelRef.current.querySelectorAll('[role="menuitem"]:not(:disabled)')) : [];
56
- const cur = nodes.indexOf(document.activeElement),
57
- ch = e.key.toLowerCase();
58
- for (let k = 1; k <= nodes.length; k++) {
59
- const n = nodes[(cur + k) % nodes.length];
60
- if ((n.textContent || '').trim().toLowerCase().startsWith(ch)) {
61
- e.preventDefault();
62
- n.focus();
63
- break;
64
- }
65
- }
66
- }
80
+ setOpen(true);
81
+ }, [setOpen]);
82
+ const value = React.useMemo(() => ({
83
+ open,
84
+ setOpen,
85
+ openAt,
86
+ point,
87
+ triggerRef,
88
+ contentRef,
89
+ modal
90
+ }), [open, setOpen, openAt, point, modal]);
91
+ return /*#__PURE__*/React.createElement(RootCtx.Provider, {
92
+ value: value
93
+ }, children);
94
+ }
95
+ export const ContextMenuTrigger = /*#__PURE__*/React.forwardRef(function ContextMenuTrigger({
96
+ asChild = false,
97
+ disabled = false,
98
+ children,
99
+ ...rest
100
+ }, forwardedRef) {
101
+ const root = React.useContext(RootCtx);
102
+ const open = event => {
103
+ if (disabled) return;
104
+ event.preventDefault();
105
+ root?.openAt(event.clientX, event.clientY);
67
106
  };
107
+ const keyboard = event => {
108
+ if (disabled || event.key !== 'ContextMenu' && !(event.shiftKey && event.key === 'F10')) return;
109
+ event.preventDefault();
110
+ const rect = root?.triggerRef.current?.getBoundingClientRect();
111
+ root?.openAt(rect?.left ?? 0, rect?.bottom ?? 0);
112
+ };
113
+ const props = {
114
+ ...rest,
115
+ ref: mergeRefs(forwardedRef, root?.triggerRef),
116
+ 'data-slot': 'context-menu-trigger',
117
+ 'data-state': root?.open ? 'open' : 'closed',
118
+ 'data-disabled': disabled ? 'true' : undefined,
119
+ onContextMenu: compose(rest.onContextMenu, open),
120
+ onKeyDown: compose(rest.onKeyDown, keyboard)
121
+ };
122
+ if (asChild && /*#__PURE__*/React.isValidElement(children)) {
123
+ return /*#__PURE__*/React.cloneElement(children, {
124
+ ...props,
125
+ ...children.props,
126
+ ref: mergeRefs(children.ref, props.ref),
127
+ onContextMenu: compose(children.props.onContextMenu, props.onContextMenu),
128
+ onKeyDown: compose(children.props.onKeyDown, props.onKeyDown),
129
+ 'data-slot': props['data-slot'],
130
+ 'data-state': props['data-state'],
131
+ 'data-disabled': props['data-disabled']
132
+ });
133
+ }
134
+ return /*#__PURE__*/React.createElement("span", props, children);
135
+ });
136
+ export function ContextMenuPortal({
137
+ children,
138
+ container
139
+ }) {
140
+ return /*#__PURE__*/React.createElement(Portal, {
141
+ container: container
142
+ }, children);
143
+ }
144
+ export const ContextMenuContent = /*#__PURE__*/React.forwardRef(function ContextMenuContent({
145
+ loop = true,
146
+ className,
147
+ style,
148
+ onKeyDown,
149
+ onCloseAutoFocus,
150
+ children,
151
+ ...rest
152
+ }, forwardedRef) {
153
+ const root = React.useContext(RootCtx);
154
+ const localRef = React.useRef(null);
155
+ const ref = mergeRefs(forwardedRef, localRef, root?.contentRef);
156
+ const close = React.useCallback(() => {
157
+ root?.setOpen(false);
158
+ const event = {
159
+ defaultPrevented: false,
160
+ preventDefault() {
161
+ this.defaultPrevented = true;
162
+ }
163
+ };
164
+ onCloseAutoFocus?.(event);
165
+ if (!event.defaultPrevented) root?.triggerRef.current?.focus?.();
166
+ }, [root, onCloseAutoFocus]);
167
+ const keyboard = useMenuKeyboard(localRef, close, {
168
+ loop
169
+ });
170
+ useIsoLayoutEffect(() => {
171
+ if (!root?.open || !localRef.current) return;
172
+ const panel = localRef.current;
173
+ const rect = panel.getBoundingClientRect();
174
+ const edge = 8;
175
+ const x = Math.max(edge, Math.min(root.point.x, document.documentElement.clientWidth - rect.width - edge));
176
+ const y = Math.max(edge, Math.min(root.point.y, document.documentElement.clientHeight - rect.height - edge));
177
+ panel.style.left = `${Math.round(x)}px`;
178
+ panel.style.top = `${Math.round(y)}px`;
179
+ menuItems(panel)[0]?.focus();
180
+ }, [root?.open, root?.point.x, root?.point.y]);
68
181
  React.useEffect(() => {
69
- if (!pos) return;
70
- const first = panelRef.current && panelRef.current.querySelector('[role="menuitem"]:not(:disabled)');
71
- if (first) first.focus();
72
- const close = () => setPos(null);
73
- const key = e => {
74
- if (e.key === 'Escape') close();
182
+ if (!root?.open) return;
183
+ const away = event => {
184
+ if (!localRef.current?.contains(event.target) && !root.triggerRef.current?.contains(event.target)) close();
75
185
  };
76
- document.addEventListener('mousedown', close);
77
- document.addEventListener('keydown', key);
78
- window.addEventListener('blur', close);
186
+ const blur = () => close();
187
+ document.addEventListener('pointerdown', away);
188
+ window.addEventListener('blur', blur);
79
189
  return () => {
80
- document.removeEventListener('mousedown', close);
81
- document.removeEventListener('keydown', key);
82
- window.removeEventListener('blur', close);
190
+ document.removeEventListener('pointerdown', away);
191
+ window.removeEventListener('blur', blur);
83
192
  };
84
- }, [pos]);
85
- const openAt = e => {
86
- e.preventDefault();
87
- setPos({
88
- x: e.clientX,
89
- y: e.clientY
90
- });
91
- };
92
- return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
93
- className: className,
94
- style: style,
95
- onContextMenu: openAt
96
- }), children, pos ? /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
193
+ }, [root?.open, close]);
194
+ if (!root?.open) return null;
195
+ return /*#__PURE__*/React.createElement(ContextMenuPortal, null, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
196
+ ref: ref,
97
197
  role: "menu",
98
- ref: panelRef,
99
- onKeyDown: onPanelKey,
100
- className: "ef-ctx__panel",
198
+ "data-slot": "context-menu-content",
199
+ "data-state": "open",
200
+ className: join('ef-context-menu__content', className),
101
201
  style: {
102
- left: pos.x,
103
- top: pos.y
202
+ left: root.point.x,
203
+ top: root.point.y,
204
+ ...style
104
205
  },
105
- onMouseDown: e => e.stopPropagation()
106
- }, items.map((it, i) => it === 'separator' ? /*#__PURE__*/React.createElement("div", {
107
- key: 's' + i,
108
- className: "ef-ctx__sep"
109
- }) : /*#__PURE__*/React.createElement("button", {
110
- key: it.id,
206
+ onKeyDown: compose(onKeyDown, keyboard)
207
+ }), children));
208
+ });
209
+ export const ContextMenuGroup = /*#__PURE__*/React.forwardRef(function ContextMenuGroup(props, ref) {
210
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
211
+ ref: ref,
212
+ role: "group",
213
+ "data-slot": "context-menu-group"
214
+ }));
215
+ });
216
+ export const ContextMenuLabel = /*#__PURE__*/React.forwardRef(function ContextMenuLabel({
217
+ inset = false,
218
+ className,
219
+ ...props
220
+ }, ref) {
221
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
222
+ ref: ref,
223
+ "data-slot": "context-menu-label",
224
+ "data-inset": inset ? 'true' : undefined,
225
+ className: join('ef-context-menu__label', className)
226
+ }));
227
+ });
228
+ export const ContextMenuSeparator = /*#__PURE__*/React.forwardRef(function ContextMenuSeparator({
229
+ className,
230
+ ...props
231
+ }, ref) {
232
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
233
+ ref: ref,
234
+ role: "separator",
235
+ "data-slot": "context-menu-separator",
236
+ className: join('ef-context-menu__separator', className)
237
+ }));
238
+ });
239
+ export const ContextMenuShortcut = /*#__PURE__*/React.forwardRef(function ContextMenuShortcut({
240
+ className,
241
+ ...props
242
+ }, ref) {
243
+ return /*#__PURE__*/React.createElement("span", _extends({}, props, {
244
+ ref: ref,
245
+ "data-slot": "context-menu-shortcut",
246
+ className: join('ef-context-menu__shortcut', className)
247
+ }));
248
+ });
249
+ export const ContextMenuItem = /*#__PURE__*/React.forwardRef(function ContextMenuItem({
250
+ inset = false,
251
+ variant = 'default',
252
+ disabled = false,
253
+ onSelect,
254
+ onClick,
255
+ className,
256
+ children,
257
+ ...props
258
+ }, ref) {
259
+ const root = React.useContext(RootCtx);
260
+ const activate = event => {
261
+ onClick?.(event);
262
+ if (!event.defaultPrevented && !disabled) {
263
+ onSelect?.(event);
264
+ if (!event.defaultPrevented) root?.setOpen(false);
265
+ }
266
+ };
267
+ return /*#__PURE__*/React.createElement("button", _extends({}, props, {
268
+ ref: ref,
111
269
  type: "button",
112
270
  role: "menuitem",
113
- disabled: it.disabled,
114
- className: `ef-ctx__item${it.danger ? ' ef-ctx__item--danger' : ''}`,
115
- onClick: () => {
116
- setPos(null);
117
- if (onSelect) onSelect(it.id);
118
- if (it.onClick) it.onClick();
271
+ disabled: disabled,
272
+ "data-slot": "context-menu-item",
273
+ "data-inset": inset ? 'true' : undefined,
274
+ "data-variant": variant,
275
+ "data-disabled": disabled ? 'true' : undefined,
276
+ className: join('ef-context-menu__item', className),
277
+ onClick: activate
278
+ }), children);
279
+ });
280
+ export const ContextMenuCheckboxItem = /*#__PURE__*/React.forwardRef(function ContextMenuCheckboxItem({
281
+ checked: controlled,
282
+ defaultChecked = false,
283
+ onCheckedChange,
284
+ disabled = false,
285
+ onSelect,
286
+ onClick,
287
+ className,
288
+ children,
289
+ ...props
290
+ }, ref) {
291
+ const root = React.useContext(RootCtx);
292
+ const [inner, setInner] = React.useState(defaultChecked);
293
+ const checked = controlled !== undefined ? controlled : inner;
294
+ const activate = event => {
295
+ onClick?.(event);
296
+ if (event.defaultPrevented || disabled) return;
297
+ const next = !checked;
298
+ if (controlled === undefined) setInner(next);
299
+ onCheckedChange?.(next);
300
+ onSelect?.(event);
301
+ if (!event.defaultPrevented) root?.setOpen(false);
302
+ };
303
+ return /*#__PURE__*/React.createElement("button", _extends({}, props, {
304
+ ref: ref,
305
+ type: "button",
306
+ role: "menuitemcheckbox",
307
+ "aria-checked": checked,
308
+ disabled: disabled,
309
+ "data-slot": "context-menu-checkbox-item",
310
+ "data-state": checked ? 'checked' : 'unchecked',
311
+ "data-disabled": disabled ? 'true' : undefined,
312
+ className: join('ef-context-menu__item', className),
313
+ onClick: activate
314
+ }), /*#__PURE__*/React.createElement("span", {
315
+ className: "ef-context-menu__indicator"
316
+ }, checked ? /*#__PURE__*/React.createElement(Icon, {
317
+ name: "check",
318
+ size: 14
319
+ }) : null), children);
320
+ });
321
+ export function ContextMenuRadioGroup({
322
+ value: controlled,
323
+ defaultValue = '',
324
+ onValueChange,
325
+ children,
326
+ ...props
327
+ }) {
328
+ const [inner, setInner] = React.useState(defaultValue);
329
+ const value = controlled !== undefined ? controlled : inner;
330
+ const setValue = next => {
331
+ if (controlled === undefined) setInner(next);
332
+ onValueChange?.(next);
333
+ };
334
+ return /*#__PURE__*/React.createElement(RadioCtx.Provider, {
335
+ value: {
336
+ value,
337
+ setValue
119
338
  }
120
- }, it.icon ? /*#__PURE__*/React.createElement("span", {
121
- className: "ef-ctx__item__icon"
339
+ }, /*#__PURE__*/React.createElement("div", _extends({}, props, {
340
+ role: "group",
341
+ "data-slot": "context-menu-radio-group"
342
+ }), children));
343
+ }
344
+ export const ContextMenuRadioItem = /*#__PURE__*/React.forwardRef(function ContextMenuRadioItem({
345
+ value,
346
+ disabled = false,
347
+ onSelect,
348
+ onClick,
349
+ className,
350
+ children,
351
+ ...props
352
+ }, ref) {
353
+ const root = React.useContext(RootCtx);
354
+ const radio = React.useContext(RadioCtx);
355
+ const checked = radio?.value === value;
356
+ const activate = event => {
357
+ onClick?.(event);
358
+ if (event.defaultPrevented || disabled) return;
359
+ radio?.setValue(value);
360
+ onSelect?.(event);
361
+ if (!event.defaultPrevented) root?.setOpen(false);
362
+ };
363
+ return /*#__PURE__*/React.createElement("button", _extends({}, props, {
364
+ ref: ref,
365
+ type: "button",
366
+ role: "menuitemradio",
367
+ "aria-checked": checked,
368
+ disabled: disabled,
369
+ "data-slot": "context-menu-radio-item",
370
+ "data-state": checked ? 'checked' : 'unchecked',
371
+ "data-disabled": disabled ? 'true' : undefined,
372
+ className: join('ef-context-menu__item', className),
373
+ onClick: activate
374
+ }), /*#__PURE__*/React.createElement("span", {
375
+ className: "ef-context-menu__indicator"
376
+ }, checked ? /*#__PURE__*/React.createElement(Icon, {
377
+ name: "circle",
378
+ size: 8
379
+ }) : null), children);
380
+ });
381
+ export function ContextMenuSub({
382
+ open: controlled,
383
+ defaultOpen = false,
384
+ onOpenChange,
385
+ children
386
+ }) {
387
+ const [inner, setInner] = React.useState(defaultOpen);
388
+ const open = controlled !== undefined ? controlled : inner;
389
+ const triggerRef = React.useRef(null);
390
+ const contentRef = React.useRef(null);
391
+ const setOpen = next => {
392
+ if (controlled === undefined) setInner(next);
393
+ onOpenChange?.(next);
394
+ };
395
+ return /*#__PURE__*/React.createElement(SubCtx.Provider, {
396
+ value: {
397
+ open,
398
+ setOpen,
399
+ triggerRef,
400
+ contentRef
401
+ }
402
+ }, children);
403
+ }
404
+ export const ContextMenuSubTrigger = /*#__PURE__*/React.forwardRef(function ContextMenuSubTrigger({
405
+ inset = false,
406
+ disabled = false,
407
+ className,
408
+ children,
409
+ onKeyDown,
410
+ ...props
411
+ }, forwardedRef) {
412
+ const sub = React.useContext(SubCtx);
413
+ const keyboard = event => {
414
+ if (!disabled && event.key === 'ArrowRight') {
415
+ event.preventDefault();
416
+ sub?.setOpen(true);
417
+ requestAnimationFrame(() => menuItems(sub?.contentRef.current)[0]?.focus());
418
+ }
419
+ };
420
+ return /*#__PURE__*/React.createElement("button", _extends({}, props, {
421
+ ref: mergeRefs(forwardedRef, sub?.triggerRef),
422
+ type: "button",
423
+ role: "menuitem",
424
+ disabled: disabled,
425
+ "data-slot": "context-menu-sub-trigger",
426
+ "data-state": sub?.open ? 'open' : 'closed',
427
+ "data-inset": inset ? 'true' : undefined,
428
+ "data-disabled": disabled ? 'true' : undefined,
429
+ className: join('ef-context-menu__item', className),
430
+ onMouseEnter: () => !disabled && sub?.setOpen(true),
431
+ onKeyDown: compose(onKeyDown, keyboard)
432
+ }), children, /*#__PURE__*/React.createElement("span", {
433
+ className: "ef-context-menu__chevron"
122
434
  }, /*#__PURE__*/React.createElement(Icon, {
123
- name: it.icon,
124
- size: 15
125
- })) : null, it.label, it.kbd ? /*#__PURE__*/React.createElement("span", {
126
- className: "ef-ctx__kbd"
127
- }, it.kbd) : null)))) : null);
128
- }
435
+ name: "chevron-right",
436
+ size: 14
437
+ })));
438
+ });
439
+ export const ContextMenuSubContent = /*#__PURE__*/React.forwardRef(function ContextMenuSubContent({
440
+ sideOffset = 4,
441
+ alignOffset = -4,
442
+ loop = true,
443
+ className,
444
+ style,
445
+ onKeyDown,
446
+ children,
447
+ ...props
448
+ }, forwardedRef) {
449
+ const sub = React.useContext(SubCtx);
450
+ const localRef = React.useRef(null);
451
+ const fallbackTriggerRef = React.useRef(null);
452
+ const fallbackContentRef = React.useRef(null);
453
+ const {
454
+ style: anchored,
455
+ side
456
+ } = useAnchoredStyle(sub?.triggerRef ?? fallbackTriggerRef, sub?.contentRef ?? fallbackContentRef, {
457
+ open: !!sub?.open,
458
+ placement: 'right',
459
+ align: 'start',
460
+ offset: sideOffset,
461
+ crossOffset: alignOffset
462
+ });
463
+ const close = () => {
464
+ sub?.setOpen(false);
465
+ sub?.triggerRef.current?.focus();
466
+ };
467
+ const keyboard = useMenuKeyboard(localRef, close, {
468
+ sub: true,
469
+ loop
470
+ });
471
+ useIsoLayoutEffect(() => {
472
+ if (sub?.open) menuItems(localRef.current)[0]?.focus();
473
+ }, [sub?.open]);
474
+ if (!sub?.open) return null;
475
+ return /*#__PURE__*/React.createElement(ContextMenuPortal, null, /*#__PURE__*/React.createElement("div", _extends({}, props, {
476
+ ref: mergeRefs(forwardedRef, localRef, sub.contentRef),
477
+ role: "menu",
478
+ "data-slot": "context-menu-sub-content",
479
+ "data-state": "open",
480
+ "data-side": side,
481
+ className: join('ef-context-menu__content', className),
482
+ style: {
483
+ ...anchored,
484
+ ...style
485
+ },
486
+ onMouseLeave: () => sub.setOpen(false),
487
+ onKeyDown: compose(onKeyDown, keyboard)
488
+ }), children));
489
+ });
@@ -1,17 +1,32 @@
1
+ import type * as React from 'react';
2
+
3
+ export type DrawerDirection = 'top' | 'right' | 'bottom' | 'left';
1
4
  export interface DrawerProps {
2
- open: boolean;
3
- /** Called on ✕, ESC, or overlay click */
4
- onClose?: () => void;
5
- /** Accessible name of the ✕ button. Pass a translated string in a
6
- * non-English UI. @default 'Close' */
7
- closeLabel?: string;
8
- title: React.ReactNode;
9
- /** Right-aligned action row on sunken strip */
10
- footer?: React.ReactNode;
11
- /** Px @default 400 */
12
- width?: number;
13
- /** @default 'right' */
14
- side?: 'left' | 'right';
5
+ open?: boolean;
6
+ defaultOpen?: boolean;
7
+ onOpenChange?: (open: boolean) => void;
8
+ direction?: DrawerDirection;
9
+ dismissible?: boolean;
10
+ modal?: boolean;
11
+ handleOnly?: boolean;
15
12
  children?: React.ReactNode;
16
13
  }
17
- export declare const Drawer: React.ForwardRefExoticComponent<DrawerProps & React.RefAttributes<HTMLDivElement>>;
14
+ export declare function Drawer(props: DrawerProps): React.JSX.Element;
15
+
16
+ export interface DrawerTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { asChild?: boolean; }
17
+ export declare const DrawerTrigger: React.ForwardRefExoticComponent<DrawerTriggerProps & React.RefAttributes<HTMLButtonElement>>;
18
+ export interface DrawerCloseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { asChild?: boolean; }
19
+ export declare const DrawerClose: React.ForwardRefExoticComponent<DrawerCloseProps & React.RefAttributes<HTMLButtonElement>>;
20
+ export interface DrawerPortalProps { children?: React.ReactNode; container?: HTMLElement; }
21
+ export declare function DrawerPortal(props: DrawerPortalProps): React.JSX.Element | null;
22
+ export declare const DrawerOverlay: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
23
+
24
+ export interface DrawerContentProps extends React.HTMLAttributes<HTMLDivElement> {
25
+ onEscapeKeyDown?: (event: KeyboardEvent) => void;
26
+ overlayProps?: React.HTMLAttributes<HTMLDivElement>;
27
+ }
28
+ export declare const DrawerContent: React.ForwardRefExoticComponent<DrawerContentProps & React.RefAttributes<HTMLDivElement>>;
29
+ export declare const DrawerHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
30
+ export declare const DrawerFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
31
+ export declare const DrawerTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
32
+ export declare const DrawerDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;