@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.
- package/README.md +1 -1
- package/ai/Bubble.d.ts +16 -0
- package/ai/Bubble.js +71 -0
- package/ai/ChatMessage.js +2 -5
- package/ai/Confirmation.d.ts +0 -7
- package/ai/Confirmation.js +3 -6
- package/ai/GeneratedImage.d.ts +0 -2
- package/ai/GeneratedImage.js +2 -4
- package/ai/Marker.d.ts +26 -0
- package/ai/Marker.js +67 -0
- package/ai/Message.d.ts +13 -0
- package/ai/Message.js +68 -0
- package/ai/MessageScroller.d.ts +21 -0
- package/ai/MessageScroller.js +283 -0
- package/ai/ModelSelector.d.ts +2 -2
- package/ai/ModelSelector.js +1 -2
- package/ai/Player.js +1 -1
- package/ai/PromptSteps.js +4 -2
- package/ai/Sandbox.d.ts +0 -2
- package/ai/Sandbox.js +2 -4
- package/ai/Suggestions.d.ts +0 -2
- package/ai/Suggestions.js +1 -4
- package/ai/WebPreview.d.ts +0 -2
- package/ai/WebPreview.js +2 -4
- package/code/Console.js +1 -1
- package/code/EnvList.d.ts +0 -2
- package/code/EnvList.js +2 -3
- package/components.css +660 -423
- package/data/BarChart.d.ts +0 -2
- package/data/BarChart.js +1 -4
- package/data/Chart.d.ts +14 -0
- package/data/Chart.js +149 -0
- package/data/EmptyState.d.ts +8 -13
- package/data/EmptyState.js +62 -24
- package/data/LineChart.js +7 -4
- package/data/Skeleton.d.ts +2 -11
- package/data/Skeleton.js +8 -38
- package/data/Sparkline.js +4 -1
- package/data/StatusDot.d.ts +0 -4
- package/data/StatusDot.js +3 -6
- package/data/Table.d.ts +11 -4
- package/data/Table.js +39 -7
- package/dates/Calendar.d.ts +10 -27
- package/dates/Calendar.js +250 -184
- package/dates/TimePicker.js +2 -2
- package/display/Accordion.d.ts +47 -15
- package/display/Accordion.js +257 -27
- package/display/AspectRatio.d.ts +4 -6
- package/display/AspectRatio.js +7 -5
- package/display/Avatar.d.ts +17 -14
- package/display/Avatar.js +68 -43
- package/display/Badge.d.ts +9 -8
- package/display/Badge.js +32 -14
- package/display/Card.d.ts +11 -13
- package/display/Card.js +74 -29
- package/display/Carousel.d.ts +23 -15
- package/display/Carousel.js +217 -66
- package/display/Collapsible.d.ts +19 -9
- package/display/Collapsible.js +140 -28
- package/display/Direction.d.ts +10 -0
- package/display/Direction.js +24 -0
- package/display/Item.d.ts +19 -0
- package/display/Item.js +152 -0
- package/display/Kbd.d.ts +5 -7
- package/display/Kbd.js +22 -10
- package/display/Link.js +2 -4
- package/display/Resizable.d.ts +6 -16
- package/display/Resizable.js +141 -58
- package/display/ScrollArea.d.ts +3 -1
- package/display/ScrollArea.js +30 -5
- package/display/Separator.d.ts +9 -0
- package/display/Separator.js +18 -0
- package/display/Timeline.d.ts +24 -0
- package/display/Timeline.js +51 -0
- package/display/Toolbar.js +5 -4
- package/display/TreeList.d.ts +0 -2
- package/display/TreeList.js +2 -5
- package/feedback/Alert.d.ts +13 -13
- package/feedback/Alert.js +40 -36
- package/feedback/AlertDialog.d.ts +30 -0
- package/feedback/AlertDialog.js +249 -0
- package/feedback/Banner.d.ts +1 -3
- package/feedback/Banner.js +1 -5
- package/feedback/ConfirmDialog.d.ts +1 -1
- package/feedback/ConfirmDialog.js +18 -20
- package/feedback/Dialog.d.ts +13 -16
- package/feedback/Dialog.js +204 -62
- package/feedback/Progress.d.ts +8 -9
- package/feedback/Progress.js +42 -24
- package/feedback/Sonner.d.ts +8 -0
- package/feedback/Sonner.js +238 -0
- package/feedback/Spinner.d.ts +2 -9
- package/feedback/Spinner.js +19 -28
- package/feedback/Tooltip.d.ts +9 -10
- package/feedback/Tooltip.js +147 -96
- package/files/Attachment.d.ts +27 -0
- package/files/Attachment.js +111 -0
- package/files/FileDrop.js +3 -1
- package/finance/PaymentCard.js +3 -3
- package/forms/Button.d.ts +6 -5
- package/forms/Button.js +42 -8
- package/forms/ButtonGroup.d.ts +11 -3
- package/forms/ButtonGroup.js +57 -6
- package/forms/Checkbox.d.ts +14 -3
- package/forms/Checkbox.js +84 -16
- package/forms/Combobox.d.ts +24 -16
- package/forms/Combobox.js +466 -135
- package/forms/Field.d.ts +14 -0
- package/forms/Field.js +99 -0
- package/forms/IconButton.d.ts +1 -1
- package/forms/IconButton.js +4 -3
- package/forms/Input.d.ts +8 -8
- package/forms/Input.js +46 -33
- package/forms/InputGroup.d.ts +8 -15
- package/forms/InputGroup.js +74 -35
- package/forms/InputOTP.d.ts +13 -0
- package/forms/InputOTP.js +125 -0
- package/forms/Label.d.ts +2 -6
- package/forms/Label.js +6 -4
- package/forms/NativeSelect.d.ts +16 -0
- package/forms/NativeSelect.js +35 -0
- package/forms/NumberInput.js +2 -2
- package/forms/Radio.d.ts +12 -1
- package/forms/Radio.js +76 -6
- package/forms/Select.d.ts +12 -9
- package/forms/Select.js +254 -42
- package/forms/Slider.d.ts +10 -17
- package/forms/Slider.js +78 -39
- package/forms/Switch.d.ts +8 -2
- package/forms/Switch.js +46 -15
- package/forms/Textarea.d.ts +1 -1
- package/forms/Textarea.js +26 -18
- package/forms/Toggle.d.ts +18 -15
- package/forms/Toggle.js +96 -42
- package/icons/_svg.js +2 -0
- package/index.d.ts +20 -8
- package/index.js +50 -38
- package/navigation/Breadcrumbs.d.ts +18 -11
- package/navigation/Breadcrumbs.js +99 -26
- package/navigation/Menubar.d.ts +52 -10
- package/navigation/Menubar.js +191 -146
- package/navigation/NavigationMenu.d.ts +15 -0
- package/navigation/NavigationMenu.js +296 -0
- package/navigation/Pagination.d.ts +10 -9
- package/navigation/Pagination.js +94 -51
- package/navigation/SideNav.js +4 -3
- package/navigation/Sidebar.d.ts +29 -0
- package/navigation/Sidebar.js +311 -0
- package/navigation/Tabs.d.ts +9 -5
- package/navigation/Tabs.js +132 -44
- package/overlay/Command.d.ts +32 -0
- package/overlay/Command.js +257 -0
- package/overlay/ContextMenu.d.ts +40 -8
- package/overlay/ContextMenu.js +468 -107
- package/overlay/Drawer.d.ts +29 -14
- package/overlay/Drawer.js +178 -80
- package/overlay/DropdownMenu.d.ts +43 -0
- package/overlay/DropdownMenu.js +502 -0
- package/overlay/HoverCard.d.ts +21 -12
- package/overlay/HoverCard.js +129 -61
- package/overlay/Popover.d.ts +11 -13
- package/overlay/Popover.js +138 -65
- package/overlay/Portal.js +21 -7
- package/overlay/Sheet.d.ts +11 -0
- package/overlay/Sheet.js +62 -0
- package/package.json +4 -1
- package/tokens/base.css +1 -1
- package/dates/DatePicker.d.ts +0 -14
- package/dates/DatePicker.js +0 -111
- package/dates/DateRangePicker.d.ts +0 -23
- package/dates/DateRangePicker.js +0 -150
- package/display/ListItem.d.ts +0 -19
- package/display/ListItem.js +0 -50
- package/feedback/Toast.d.ts +0 -78
- package/feedback/Toast.js +0 -192
- package/forms/DigitEntry.d.ts +0 -15
- package/forms/DigitEntry.js +0 -79
- package/forms/FormField.d.ts +0 -82
- package/forms/FormField.js +0 -209
- package/overlay/CommandPalette.d.ts +0 -21
- package/overlay/CommandPalette.js +0 -148
- package/overlay/Menu.d.ts +0 -24
- package/overlay/Menu.js +0 -139
|
@@ -0,0 +1,283 @@
|
|
|
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 { mergeRefs } from "../forms/Button.js";
|
|
5
|
+
import { Icon } from "../icons/Icon.js";
|
|
6
|
+
const MessageScrollerContext = /*#__PURE__*/React.createContext(null);
|
|
7
|
+
const join = (...values) => values.filter(Boolean).join(' ');
|
|
8
|
+
const EDGE_EPSILON = 2;
|
|
9
|
+
function readRows(viewport) {
|
|
10
|
+
return viewport ? Array.from(viewport.querySelectorAll('[data-slot="message-scroller-item"]')) : [];
|
|
11
|
+
}
|
|
12
|
+
export function MessageScrollerProvider({
|
|
13
|
+
autoScroll = false,
|
|
14
|
+
defaultScrollPosition = 'last-anchor',
|
|
15
|
+
preserveScrollOnPrepend = true,
|
|
16
|
+
scrollPreviousItemPeek = 64,
|
|
17
|
+
children
|
|
18
|
+
}) {
|
|
19
|
+
const viewportRef = React.useRef(null);
|
|
20
|
+
const initializedRef = React.useRef(false);
|
|
21
|
+
const followingRef = React.useRef(autoScroll);
|
|
22
|
+
const automaticRef = React.useRef(false);
|
|
23
|
+
const previousRef = React.useRef({
|
|
24
|
+
firstId: null,
|
|
25
|
+
lastId: null,
|
|
26
|
+
height: 0,
|
|
27
|
+
anchorId: null
|
|
28
|
+
});
|
|
29
|
+
const [scrollable, setScrollable] = React.useState({
|
|
30
|
+
start: false,
|
|
31
|
+
end: false
|
|
32
|
+
});
|
|
33
|
+
const [visibility, setVisibility] = React.useState({
|
|
34
|
+
currentAnchorId: null,
|
|
35
|
+
visibleMessageIds: []
|
|
36
|
+
});
|
|
37
|
+
const [autoscrolling, setAutoscrolling] = React.useState(false);
|
|
38
|
+
const readState = React.useCallback(() => {
|
|
39
|
+
const viewport = viewportRef.current;
|
|
40
|
+
if (!viewport) return {
|
|
41
|
+
start: false,
|
|
42
|
+
end: false
|
|
43
|
+
};
|
|
44
|
+
const next = {
|
|
45
|
+
start: viewport.scrollTop > EDGE_EPSILON,
|
|
46
|
+
end: viewport.scrollTop + viewport.clientHeight < viewport.scrollHeight - EDGE_EPSILON
|
|
47
|
+
};
|
|
48
|
+
setScrollable(current => current.start === next.start && current.end === next.end ? current : next);
|
|
49
|
+
const box = viewport.getBoundingClientRect();
|
|
50
|
+
const rows = readRows(viewport);
|
|
51
|
+
const visibleMessageIds = rows.filter(row => {
|
|
52
|
+
const rect = row.getBoundingClientRect();
|
|
53
|
+
return rect.bottom > box.top && rect.top < box.bottom;
|
|
54
|
+
}).map(row => row.dataset.messageId).filter(Boolean);
|
|
55
|
+
const currentAnchor = rows.filter(row => row.dataset.scrollAnchor === 'true' && row.getBoundingClientRect().top <= box.top + scrollPreviousItemPeek + 1).at(-1) || rows.find(row => row.dataset.scrollAnchor === 'true' && row.getBoundingClientRect().bottom > box.top);
|
|
56
|
+
const currentAnchorId = currentAnchor?.dataset.messageId || null;
|
|
57
|
+
setVisibility(current => current.currentAnchorId === currentAnchorId && current.visibleMessageIds.join('\0') === visibleMessageIds.join('\0') ? current : {
|
|
58
|
+
currentAnchorId,
|
|
59
|
+
visibleMessageIds
|
|
60
|
+
});
|
|
61
|
+
return next;
|
|
62
|
+
}, [scrollPreviousItemPeek]);
|
|
63
|
+
const move = React.useCallback((top, behavior = 'smooth', follow = false) => {
|
|
64
|
+
const viewport = viewportRef.current;
|
|
65
|
+
if (!viewport) return;
|
|
66
|
+
automaticRef.current = true;
|
|
67
|
+
followingRef.current = follow;
|
|
68
|
+
setAutoscrolling(true);
|
|
69
|
+
viewport.scrollTo({
|
|
70
|
+
top,
|
|
71
|
+
behavior
|
|
72
|
+
});
|
|
73
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
74
|
+
automaticRef.current = false;
|
|
75
|
+
setAutoscrolling(false);
|
|
76
|
+
readState();
|
|
77
|
+
}));
|
|
78
|
+
}, [readState]);
|
|
79
|
+
const scrollToStart = React.useCallback(options => move(0, options?.behavior, false), [move]);
|
|
80
|
+
const scrollToEnd = React.useCallback(options => {
|
|
81
|
+
const viewport = viewportRef.current;
|
|
82
|
+
if (viewport) move(viewport.scrollHeight, options?.behavior, true);
|
|
83
|
+
}, [move]);
|
|
84
|
+
const scrollToMessage = React.useCallback((messageId, options) => {
|
|
85
|
+
const viewport = viewportRef.current;
|
|
86
|
+
const row = readRows(viewport).find(item => item.dataset.messageId === String(messageId));
|
|
87
|
+
if (!viewport || !row) return false;
|
|
88
|
+
move(Math.max(0, row.offsetTop - (options?.offset ?? scrollPreviousItemPeek)), options?.behavior, false);
|
|
89
|
+
return true;
|
|
90
|
+
}, [move, scrollPreviousItemPeek]);
|
|
91
|
+
const setViewport = React.useCallback(node => {
|
|
92
|
+
viewportRef.current = node;
|
|
93
|
+
}, []);
|
|
94
|
+
const handleScroll = React.useCallback(event => {
|
|
95
|
+
const next = readState();
|
|
96
|
+
if (!automaticRef.current) followingRef.current = autoScroll && !next.end;
|
|
97
|
+
return event;
|
|
98
|
+
}, [autoScroll, readState]);
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
const viewport = viewportRef.current;
|
|
101
|
+
if (!viewport) return;
|
|
102
|
+
const reconcile = () => {
|
|
103
|
+
const rows = readRows(viewport);
|
|
104
|
+
const firstId = rows[0]?.dataset.messageId || null;
|
|
105
|
+
const lastId = rows.at(-1)?.dataset.messageId || null;
|
|
106
|
+
const lastAnchor = rows.filter(row => row.dataset.scrollAnchor === 'true').at(-1);
|
|
107
|
+
const lastAnchorId = lastAnchor?.dataset.messageId || null;
|
|
108
|
+
const previous = previousRef.current;
|
|
109
|
+
if (!initializedRef.current) {
|
|
110
|
+
initializedRef.current = true;
|
|
111
|
+
if (defaultScrollPosition === 'end') viewport.scrollTop = viewport.scrollHeight;else if (defaultScrollPosition === 'last-anchor') {
|
|
112
|
+
const anchoredTurnFits = lastAnchor && viewport.scrollHeight - lastAnchor.offsetTop <= viewport.clientHeight;
|
|
113
|
+
viewport.scrollTop = lastAnchor && !anchoredTurnFits ? Math.max(0, lastAnchor.offsetTop - scrollPreviousItemPeek) : viewport.scrollHeight;
|
|
114
|
+
}
|
|
115
|
+
} else if (preserveScrollOnPrepend && previous.firstId && firstId !== previous.firstId && previous.lastId === lastId) {
|
|
116
|
+
viewport.scrollTop += viewport.scrollHeight - previous.height;
|
|
117
|
+
} else if (lastAnchorId && lastAnchorId !== previous.anchorId && lastId !== previous.lastId) {
|
|
118
|
+
viewport.scrollTop = Math.max(0, lastAnchor.offsetTop - scrollPreviousItemPeek);
|
|
119
|
+
} else if (autoScroll && followingRef.current && viewport.scrollHeight !== previous.height) {
|
|
120
|
+
viewport.scrollTop = viewport.scrollHeight;
|
|
121
|
+
}
|
|
122
|
+
previousRef.current = {
|
|
123
|
+
firstId,
|
|
124
|
+
lastId,
|
|
125
|
+
height: viewport.scrollHeight,
|
|
126
|
+
anchorId: lastAnchorId
|
|
127
|
+
};
|
|
128
|
+
readState();
|
|
129
|
+
};
|
|
130
|
+
reconcile();
|
|
131
|
+
const mutation = new MutationObserver(reconcile);
|
|
132
|
+
mutation.observe(viewport, {
|
|
133
|
+
childList: true,
|
|
134
|
+
subtree: true,
|
|
135
|
+
characterData: true
|
|
136
|
+
});
|
|
137
|
+
const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(reconcile);
|
|
138
|
+
resize?.observe(viewport);
|
|
139
|
+
const content = viewport.querySelector('[data-slot="message-scroller-content"]');
|
|
140
|
+
if (content) resize?.observe(content);
|
|
141
|
+
return () => {
|
|
142
|
+
mutation.disconnect();
|
|
143
|
+
resize?.disconnect();
|
|
144
|
+
};
|
|
145
|
+
}, [autoScroll, defaultScrollPosition, preserveScrollOnPrepend, readState, scrollPreviousItemPeek]);
|
|
146
|
+
const value = React.useMemo(() => ({
|
|
147
|
+
viewportRef,
|
|
148
|
+
setViewport,
|
|
149
|
+
handleScroll,
|
|
150
|
+
scrollable,
|
|
151
|
+
visibility,
|
|
152
|
+
autoscrolling,
|
|
153
|
+
scrollToStart,
|
|
154
|
+
scrollToEnd,
|
|
155
|
+
scrollToMessage
|
|
156
|
+
}), [setViewport, handleScroll, scrollable, visibility, autoscrolling, scrollToStart, scrollToEnd, scrollToMessage]);
|
|
157
|
+
return /*#__PURE__*/React.createElement(MessageScrollerContext.Provider, {
|
|
158
|
+
value: value
|
|
159
|
+
}, children);
|
|
160
|
+
}
|
|
161
|
+
function useScrollerContext(name) {
|
|
162
|
+
const context = React.useContext(MessageScrollerContext);
|
|
163
|
+
if (!context) throw new Error(`${name} must be used inside a <MessageScrollerProvider>`);
|
|
164
|
+
return context;
|
|
165
|
+
}
|
|
166
|
+
export function useMessageScroller() {
|
|
167
|
+
const {
|
|
168
|
+
scrollToStart,
|
|
169
|
+
scrollToEnd,
|
|
170
|
+
scrollToMessage
|
|
171
|
+
} = useScrollerContext('useMessageScroller');
|
|
172
|
+
return {
|
|
173
|
+
scrollToStart,
|
|
174
|
+
scrollToEnd,
|
|
175
|
+
scrollToMessage
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export function useMessageScrollerVisibility() {
|
|
179
|
+
return useScrollerContext('useMessageScrollerVisibility').visibility;
|
|
180
|
+
}
|
|
181
|
+
export function useMessageScrollerScrollable() {
|
|
182
|
+
return useScrollerContext('useMessageScrollerScrollable').scrollable;
|
|
183
|
+
}
|
|
184
|
+
export const MessageScroller = /*#__PURE__*/React.forwardRef(function MessageScroller({
|
|
185
|
+
className,
|
|
186
|
+
...props
|
|
187
|
+
}, ref) {
|
|
188
|
+
const context = useScrollerContext('MessageScroller');
|
|
189
|
+
const directions = [context.scrollable.start && 'start', context.scrollable.end && 'end'].filter(Boolean).join(' ') || 'none';
|
|
190
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
191
|
+
ref: ref,
|
|
192
|
+
"data-slot": "message-scroller",
|
|
193
|
+
"data-scrollable": directions,
|
|
194
|
+
"data-autoscrolling": context.autoscrolling ? 'true' : 'false',
|
|
195
|
+
className: join('ef-message-scroller', className)
|
|
196
|
+
}));
|
|
197
|
+
});
|
|
198
|
+
export const MessageScrollerViewport = /*#__PURE__*/React.forwardRef(function MessageScrollerViewport({
|
|
199
|
+
className,
|
|
200
|
+
onScroll,
|
|
201
|
+
role = 'region',
|
|
202
|
+
'aria-label': ariaLabel = 'Messages',
|
|
203
|
+
tabIndex = 0,
|
|
204
|
+
...props
|
|
205
|
+
}, ref) {
|
|
206
|
+
const context = useScrollerContext('MessageScrollerViewport');
|
|
207
|
+
const handle = event => {
|
|
208
|
+
context.handleScroll(event);
|
|
209
|
+
onScroll?.(event);
|
|
210
|
+
};
|
|
211
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
212
|
+
ref: mergeRefs(ref, context.setViewport),
|
|
213
|
+
role: role,
|
|
214
|
+
"aria-label": ariaLabel,
|
|
215
|
+
tabIndex: tabIndex,
|
|
216
|
+
"data-slot": "message-scroller-viewport",
|
|
217
|
+
"data-scrollable": [context.scrollable.start && 'start', context.scrollable.end && 'end'].filter(Boolean).join(' ') || 'none',
|
|
218
|
+
"data-autoscrolling": context.autoscrolling ? 'true' : 'false',
|
|
219
|
+
className: join('ef-message-scroller__viewport', className),
|
|
220
|
+
onScroll: handle
|
|
221
|
+
}));
|
|
222
|
+
});
|
|
223
|
+
export const MessageScrollerContent = /*#__PURE__*/React.forwardRef(function MessageScrollerContent({
|
|
224
|
+
className,
|
|
225
|
+
role = 'log',
|
|
226
|
+
'aria-live': ariaLive = 'polite',
|
|
227
|
+
'aria-relevant': ariaRelevant = 'additions',
|
|
228
|
+
...props
|
|
229
|
+
}, ref) {
|
|
230
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
231
|
+
ref: ref,
|
|
232
|
+
role: role,
|
|
233
|
+
"aria-live": ariaLive,
|
|
234
|
+
"aria-relevant": ariaRelevant,
|
|
235
|
+
"data-slot": "message-scroller-content",
|
|
236
|
+
className: join('ef-message-scroller__content', className)
|
|
237
|
+
}));
|
|
238
|
+
});
|
|
239
|
+
export const MessageScrollerItem = /*#__PURE__*/React.forwardRef(function MessageScrollerItem({
|
|
240
|
+
messageId,
|
|
241
|
+
scrollAnchor = false,
|
|
242
|
+
className,
|
|
243
|
+
...props
|
|
244
|
+
}, ref) {
|
|
245
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
246
|
+
ref: ref,
|
|
247
|
+
"data-slot": "message-scroller-item",
|
|
248
|
+
"data-message-id": messageId == null ? undefined : String(messageId),
|
|
249
|
+
"data-scroll-anchor": scrollAnchor ? 'true' : undefined,
|
|
250
|
+
className: join('ef-message-scroller__item', className)
|
|
251
|
+
}));
|
|
252
|
+
});
|
|
253
|
+
export const MessageScrollerButton = /*#__PURE__*/React.forwardRef(function MessageScrollerButton({
|
|
254
|
+
direction = 'end',
|
|
255
|
+
className,
|
|
256
|
+
children,
|
|
257
|
+
onClick,
|
|
258
|
+
...props
|
|
259
|
+
}, ref) {
|
|
260
|
+
const context = useScrollerContext('MessageScrollerButton');
|
|
261
|
+
const active = context.scrollable[direction];
|
|
262
|
+
const click = event => {
|
|
263
|
+
onClick?.(event);
|
|
264
|
+
if (!event.defaultPrevented) direction === 'end' ? context.scrollToEnd() : context.scrollToStart();
|
|
265
|
+
};
|
|
266
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
267
|
+
ref: ref,
|
|
268
|
+
type: "button",
|
|
269
|
+
"aria-label": props['aria-label'] || (direction === 'end' ? 'Scroll to end' : 'Scroll to start'),
|
|
270
|
+
tabIndex: active ? props.tabIndex : -1,
|
|
271
|
+
inert: active ? undefined : '',
|
|
272
|
+
"data-slot": "message-scroller-button",
|
|
273
|
+
"data-active": active ? 'true' : 'false',
|
|
274
|
+
"data-direction": direction,
|
|
275
|
+
className: join('ef-message-scroller__button', className),
|
|
276
|
+
onClick: click
|
|
277
|
+
}), children || /*#__PURE__*/React.createElement("span", {
|
|
278
|
+
className: "ef-message-scroller__button-icon"
|
|
279
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
280
|
+
name: "chevron-down",
|
|
281
|
+
size: 16
|
|
282
|
+
})));
|
|
283
|
+
});
|
package/ai/ModelSelector.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export interface ModelSelectorProps {
|
|
|
13
13
|
/** Selected model id */
|
|
14
14
|
value?: string;
|
|
15
15
|
onChange?: (id: string) => void;
|
|
16
|
-
/** Panel direction @default 'top'.
|
|
17
|
-
side?: 'top' | 'bottom'
|
|
16
|
+
/** Panel direction @default 'top'. */
|
|
17
|
+
side?: 'top' | 'bottom';
|
|
18
18
|
style?: React.CSSProperties;
|
|
19
19
|
className?: string;
|
|
20
20
|
}
|
package/ai/ModelSelector.js
CHANGED
|
@@ -12,8 +12,7 @@ export function ModelSelector({
|
|
|
12
12
|
className,
|
|
13
13
|
...rest
|
|
14
14
|
}) {
|
|
15
|
-
|
|
16
|
-
const dir = side === 'down' || side === 'bottom' ? 'bottom' : 'top';
|
|
15
|
+
const dir = side === 'bottom' ? 'bottom' : 'top';
|
|
17
16
|
const [open, setOpen] = React.useState(false);
|
|
18
17
|
const ref = React.useRef(null);
|
|
19
18
|
const panelRef = React.useRef(null);
|
package/ai/Player.js
CHANGED
|
@@ -188,7 +188,7 @@ export const Player = /*#__PURE__*/React.forwardRef(function Player({
|
|
|
188
188
|
type: "button",
|
|
189
189
|
className: "ef-player__btn",
|
|
190
190
|
style: {
|
|
191
|
-
|
|
191
|
+
marginInlineStart: 'auto'
|
|
192
192
|
},
|
|
193
193
|
"aria-label": muted ? 'Unmute' : 'Mute',
|
|
194
194
|
"aria-pressed": muted,
|
package/ai/PromptSteps.js
CHANGED
|
@@ -2,6 +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 { useDirection } from "../display/Direction.js";
|
|
5
6
|
export function PromptSteps({
|
|
6
7
|
steps = [],
|
|
7
8
|
defaultValues = {},
|
|
@@ -12,6 +13,7 @@ export function PromptSteps({
|
|
|
12
13
|
className,
|
|
13
14
|
...rest
|
|
14
15
|
}) {
|
|
16
|
+
const direction = useDirection();
|
|
15
17
|
const [idx, setIdx] = React.useState(0);
|
|
16
18
|
const [hi, setHi] = React.useState(0);
|
|
17
19
|
const [other, setOther] = React.useState('');
|
|
@@ -76,7 +78,7 @@ export function PromptSteps({
|
|
|
76
78
|
e.preventDefault();
|
|
77
79
|
reset();
|
|
78
80
|
if (onDismiss) onDismiss();
|
|
79
|
-
} else if (e.key === 'ArrowLeft' && !inOther || e.key === 'Tab' && e.shiftKey) {
|
|
81
|
+
} else if (e.key === (direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft') && !inOther || e.key === 'Tab' && e.shiftKey) {
|
|
80
82
|
e.preventDefault();
|
|
81
83
|
back();
|
|
82
84
|
} else if (!inOther && /^[1-9]$/.test(e.key)) {
|
|
@@ -142,7 +144,7 @@ export function PromptSteps({
|
|
|
142
144
|
className: "ef-promptsteps__back",
|
|
143
145
|
onClick: back
|
|
144
146
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
145
|
-
name:
|
|
147
|
+
name: direction === 'rtl' ? 'chevron-right' : 'chevron-left',
|
|
146
148
|
size: 12
|
|
147
149
|
}), "Back") : null, /*#__PURE__*/React.createElement("span", null, idx + 1, " of ", steps.length), /*#__PURE__*/React.createElement("span", {
|
|
148
150
|
className: "ef-promptsteps__kbd"
|
package/ai/Sandbox.d.ts
CHANGED
|
@@ -10,8 +10,6 @@ export interface SandboxProps {
|
|
|
10
10
|
/** 'running' | 'success' | 'error' */
|
|
11
11
|
/** @default 'success' */
|
|
12
12
|
status?: 'running' | 'success' | 'error';
|
|
13
|
-
/** @deprecated use `status` */
|
|
14
|
-
state?: 'running' | 'success' | 'error';
|
|
15
13
|
/** Right-side meta, e.g. duration */
|
|
16
14
|
meta?: React.ReactNode;
|
|
17
15
|
tabs: SandboxTab[];
|
package/ai/Sandbox.js
CHANGED
|
@@ -9,8 +9,7 @@ const STATES = {
|
|
|
9
9
|
};
|
|
10
10
|
export function Sandbox({
|
|
11
11
|
title,
|
|
12
|
-
status,
|
|
13
|
-
state,
|
|
12
|
+
status = 'success',
|
|
14
13
|
meta,
|
|
15
14
|
tabs = [],
|
|
16
15
|
defaultOpen,
|
|
@@ -19,8 +18,7 @@ export function Sandbox({
|
|
|
19
18
|
className,
|
|
20
19
|
...rest
|
|
21
20
|
}) {
|
|
22
|
-
const s = status
|
|
23
|
-
|
|
21
|
+
const s = status;
|
|
24
22
|
const [open, setOpen] = React.useState(defaultOpen !== undefined ? !!defaultOpen : s === 'error');
|
|
25
23
|
const [tab, setTab] = React.useState(defaultTab || tabs[0] && tabs[0].id);
|
|
26
24
|
const active = tabs.find(t => t.id === tab) || tabs[0];
|
package/ai/Suggestions.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ export interface SuggestionsProps {
|
|
|
4
4
|
items: Array<string | SuggestionItem>;
|
|
5
5
|
/** Fires with the picked label */
|
|
6
6
|
onSelect?: (label: string, index: number) => void;
|
|
7
|
-
/** @deprecated Use `onSelect`. Alias kept for one major; `onSelect` wins when both are passed. */
|
|
8
|
-
onPick?: (label: string, index: number) => void;
|
|
9
7
|
style?: React.CSSProperties;
|
|
10
8
|
className?: string;
|
|
11
9
|
}
|
package/ai/Suggestions.js
CHANGED
|
@@ -5,13 +5,10 @@ import { Icon } from "../icons/Icon.js";
|
|
|
5
5
|
export function Suggestions({
|
|
6
6
|
items = [],
|
|
7
7
|
onSelect,
|
|
8
|
-
onPick,
|
|
9
8
|
style,
|
|
10
9
|
className,
|
|
11
10
|
...rest
|
|
12
11
|
}) {
|
|
13
|
-
// onPick is the deprecated alias; onSelect (command-pick convention) wins when both are passed.
|
|
14
|
-
const fire = onSelect ?? onPick;
|
|
15
12
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
16
13
|
className: `ef-suggestions${className ? ' ' + className : ''}`,
|
|
17
14
|
style: style
|
|
@@ -22,7 +19,7 @@ export function Suggestions({
|
|
|
22
19
|
key: i,
|
|
23
20
|
type: "button",
|
|
24
21
|
className: "ef-suggestion",
|
|
25
|
-
onClick: () =>
|
|
22
|
+
onClick: () => onSelect?.(label, i)
|
|
26
23
|
}, icon ? /*#__PURE__*/React.createElement("span", {
|
|
27
24
|
className: "ef-suggestion__icon"
|
|
28
25
|
}, /*#__PURE__*/React.createElement(Icon, {
|
package/ai/WebPreview.d.ts
CHANGED
|
@@ -12,8 +12,6 @@ export interface WebPreviewProps {
|
|
|
12
12
|
logs?: WebPreviewLog[];
|
|
13
13
|
/** Console starts open */
|
|
14
14
|
defaultOpen?: boolean;
|
|
15
|
-
/** @deprecated Use `defaultOpen`. Alias kept for one major; `defaultOpen` wins when both are passed. */
|
|
16
|
-
defaultConsoleOpen?: boolean;
|
|
17
15
|
/** Rendered instead of an iframe (mock content) */
|
|
18
16
|
children?: React.ReactNode;
|
|
19
17
|
onUrlChange?: (url: string) => void;
|
package/ai/WebPreview.js
CHANGED
|
@@ -19,8 +19,7 @@ export function WebPreview({
|
|
|
19
19
|
url: urlProp = '',
|
|
20
20
|
height = 340,
|
|
21
21
|
logs = [],
|
|
22
|
-
defaultOpen,
|
|
23
|
-
defaultConsoleOpen,
|
|
22
|
+
defaultOpen = false,
|
|
24
23
|
children,
|
|
25
24
|
onUrlChange,
|
|
26
25
|
style,
|
|
@@ -31,8 +30,7 @@ export function WebPreview({
|
|
|
31
30
|
const [draft, setDraft] = React.useState(urlProp);
|
|
32
31
|
const [key, setKey] = React.useState(0);
|
|
33
32
|
const [vp, setVp] = React.useState('desktop');
|
|
34
|
-
|
|
35
|
-
const [cons, setCons] = React.useState(!!(defaultOpen ?? defaultConsoleOpen));
|
|
33
|
+
const [cons, setCons] = React.useState(!!defaultOpen);
|
|
36
34
|
// Controlled-capable url: a changed url prop is adopted into state, so a parent
|
|
37
35
|
// can drive navigation (address bar + iframe follow it) between user edits.
|
|
38
36
|
React.useEffect(() => {
|
package/code/Console.js
CHANGED
|
@@ -74,7 +74,7 @@ export function Console({
|
|
|
74
74
|
size: 13
|
|
75
75
|
}), title, /*#__PURE__*/React.createElement("span", {
|
|
76
76
|
style: {
|
|
77
|
-
|
|
77
|
+
marginInlineStart: 'auto',
|
|
78
78
|
color: 'var(--text-muted)'
|
|
79
79
|
}
|
|
80
80
|
}, entries.length, " entries")), /*#__PURE__*/React.createElement("div", {
|
package/code/EnvList.d.ts
CHANGED
package/code/EnvList.js
CHANGED
|
@@ -33,13 +33,12 @@ function Row({
|
|
|
33
33
|
export function EnvList({
|
|
34
34
|
title = 'Environment',
|
|
35
35
|
vars = [],
|
|
36
|
-
defaultOpen,
|
|
37
|
-
defaultVisible,
|
|
36
|
+
defaultOpen = false,
|
|
38
37
|
style,
|
|
39
38
|
className,
|
|
40
39
|
...rest
|
|
41
40
|
}) {
|
|
42
|
-
const [visible, setVisible] = React.useState(!!
|
|
41
|
+
const [visible, setVisible] = React.useState(!!defaultOpen);
|
|
43
42
|
const hasSecrets = vars.some(v => v.secret);
|
|
44
43
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
45
44
|
className: `ef-env${className ? ' ' + className : ''}`,
|