@orcestr/ui 0.0.3 → 0.1.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 (184) hide show
  1. package/dist/components/Alert/Alert.d.ts +5 -4
  2. package/dist/components/Alert/Alert.d.ts.map +1 -1
  3. package/dist/components/Alert/Alert.js +5 -2
  4. package/dist/components/AppShell/AppShell.d.ts +13 -0
  5. package/dist/components/AppShell/AppShell.d.ts.map +1 -1
  6. package/dist/components/AppShell/AppShell.js +14 -9
  7. package/dist/components/AppSidebar/AppSidebar.d.ts +36 -0
  8. package/dist/components/AppSidebar/AppSidebar.d.ts.map +1 -0
  9. package/dist/components/AppSidebar/AppSidebar.js +117 -0
  10. package/dist/components/Badge/Badge.d.ts +8 -6
  11. package/dist/components/Badge/Badge.d.ts.map +1 -1
  12. package/dist/components/Badge/Badge.js +4 -4
  13. package/dist/components/BadgeSelectMenu/BadgeSelectMenu.d.ts +22 -0
  14. package/dist/components/BadgeSelectMenu/BadgeSelectMenu.d.ts.map +1 -0
  15. package/dist/components/BadgeSelectMenu/BadgeSelectMenu.js +50 -0
  16. package/dist/components/Box/Box.d.ts +2 -0
  17. package/dist/components/Box/Box.d.ts.map +1 -1
  18. package/dist/components/Box/Box.js +15 -2
  19. package/dist/components/Button/Button.d.ts +7 -3
  20. package/dist/components/Button/Button.d.ts.map +1 -1
  21. package/dist/components/Button/Button.js +23 -3
  22. package/dist/components/Card/Card.d.ts +26 -0
  23. package/dist/components/Card/Card.d.ts.map +1 -0
  24. package/dist/components/Card/Card.js +25 -0
  25. package/dist/components/Checkbox/Checkbox.d.ts +6 -2
  26. package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
  27. package/dist/components/Checkbox/Checkbox.js +13 -4
  28. package/dist/components/Collapse/Collapse.d.ts.map +1 -1
  29. package/dist/components/Collapse/Collapse.js +5 -25
  30. package/dist/components/CommandPalette/CommandPalette.d.ts.map +1 -1
  31. package/dist/components/CommandPalette/CommandPalette.js +10 -9
  32. package/dist/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
  33. package/dist/components/ConfirmDialog/ConfirmDialog.js +5 -2
  34. package/dist/components/ContextMenu/ContextMenu.d.ts.map +1 -1
  35. package/dist/components/ContextMenu/ContextMenu.js +2 -2
  36. package/dist/components/CopyButton/CopyButton.d.ts +24 -0
  37. package/dist/components/CopyButton/CopyButton.d.ts.map +1 -0
  38. package/dist/components/CopyButton/CopyButton.js +81 -0
  39. package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
  40. package/dist/components/DatePicker/DatePicker.js +9 -1
  41. package/dist/components/Dialog/Dialog.d.ts +69 -1
  42. package/dist/components/Dialog/Dialog.d.ts.map +1 -1
  43. package/dist/components/Dialog/Dialog.js +48 -1
  44. package/dist/components/Drawer/Drawer.d.ts +2 -1
  45. package/dist/components/Drawer/Drawer.d.ts.map +1 -1
  46. package/dist/components/Drawer/Drawer.js +4 -4
  47. package/dist/components/EntityPicker/EntityPicker.d.ts +2 -1
  48. package/dist/components/EntityPicker/EntityPicker.d.ts.map +1 -1
  49. package/dist/components/EntityPicker/EntityPicker.js +2 -2
  50. package/dist/components/Flex/Flex.d.ts +5 -1
  51. package/dist/components/Flex/Flex.d.ts.map +1 -1
  52. package/dist/components/Flex/Flex.js +16 -3
  53. package/dist/components/Grid/Grid.d.ts +9 -2
  54. package/dist/components/Grid/Grid.d.ts.map +1 -1
  55. package/dist/components/Grid/Grid.js +22 -1
  56. package/dist/components/IconButton/IconButton.d.ts +19 -7
  57. package/dist/components/IconButton/IconButton.d.ts.map +1 -1
  58. package/dist/components/IconButton/IconButton.js +40 -5
  59. package/dist/components/IconTextButton/IconTextButton.d.ts +20 -0
  60. package/dist/components/IconTextButton/IconTextButton.d.ts.map +1 -0
  61. package/dist/components/IconTextButton/IconTextButton.js +24 -0
  62. package/dist/components/InlineEdit/InlineEdit.d.ts +63 -0
  63. package/dist/components/InlineEdit/InlineEdit.d.ts.map +1 -0
  64. package/dist/components/InlineEdit/InlineEdit.js +98 -0
  65. package/dist/components/LinkButton/LinkButton.d.ts +25 -0
  66. package/dist/components/LinkButton/LinkButton.d.ts.map +1 -0
  67. package/dist/components/LinkButton/LinkButton.js +12 -0
  68. package/dist/components/Modal/Modal.d.ts +29 -6
  69. package/dist/components/Modal/Modal.d.ts.map +1 -1
  70. package/dist/components/Modal/Modal.js +37 -13
  71. package/dist/components/Overlay/OverlayProvider.d.ts +1 -0
  72. package/dist/components/Overlay/OverlayProvider.d.ts.map +1 -1
  73. package/dist/components/Overlay/OverlayProvider.js +18 -1
  74. package/dist/components/PaginatedCombobox/PaginatedCombobox.d.ts +2 -1
  75. package/dist/components/PaginatedCombobox/PaginatedCombobox.d.ts.map +1 -1
  76. package/dist/components/PaginatedCombobox/PaginatedCombobox.js +3 -3
  77. package/dist/components/Popover/Popover.d.ts +37 -3
  78. package/dist/components/Popover/Popover.d.ts.map +1 -1
  79. package/dist/components/Popover/Popover.js +56 -9
  80. package/dist/components/ScrollArea/ScrollArea.d.ts +4 -0
  81. package/dist/components/ScrollArea/ScrollArea.d.ts.map +1 -1
  82. package/dist/components/ScrollArea/ScrollArea.js +30 -4
  83. package/dist/components/Section/Section.d.ts +2 -0
  84. package/dist/components/Section/Section.d.ts.map +1 -1
  85. package/dist/components/SegmentedControl/SegmentedControl.d.ts +24 -1
  86. package/dist/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  87. package/dist/components/SegmentedControl/SegmentedControl.js +28 -2
  88. package/dist/components/Select/Select.d.ts +36 -4
  89. package/dist/components/Select/Select.d.ts.map +1 -1
  90. package/dist/components/Select/Select.js +70 -3
  91. package/dist/components/Separator/Separator.d.ts +3 -1
  92. package/dist/components/Separator/Separator.d.ts.map +1 -1
  93. package/dist/components/Separator/Separator.js +4 -2
  94. package/dist/components/SpecialModal/SpecialModal.d.ts +43 -0
  95. package/dist/components/SpecialModal/SpecialModal.d.ts.map +1 -0
  96. package/dist/components/SpecialModal/SpecialModal.js +34 -0
  97. package/dist/components/Spinner/Spinner.d.ts +3 -1
  98. package/dist/components/Spinner/Spinner.d.ts.map +1 -1
  99. package/dist/components/Spinner/Spinner.js +2 -2
  100. package/dist/components/State/State.d.ts +8 -1
  101. package/dist/components/State/State.d.ts.map +1 -1
  102. package/dist/components/State/State.js +2 -2
  103. package/dist/components/Switch/Switch.d.ts +2 -0
  104. package/dist/components/Switch/Switch.d.ts.map +1 -1
  105. package/dist/components/Switch/Switch.js +2 -1
  106. package/dist/components/Table/Table.d.ts +64 -0
  107. package/dist/components/Table/Table.d.ts.map +1 -0
  108. package/dist/components/Table/Table.js +38 -0
  109. package/dist/components/Tabs/Tabs.d.ts +33 -2
  110. package/dist/components/Tabs/Tabs.d.ts.map +1 -1
  111. package/dist/components/Tabs/Tabs.js +201 -5
  112. package/dist/components/Text/Text.d.ts +13 -3
  113. package/dist/components/Text/Text.d.ts.map +1 -1
  114. package/dist/components/Text/Text.js +16 -3
  115. package/dist/components/TextArea/TextArea.d.ts.map +1 -1
  116. package/dist/components/TextArea/TextArea.js +1 -1
  117. package/dist/components/TextField/TextField.d.ts.map +1 -1
  118. package/dist/components/TextField/TextField.js +1 -1
  119. package/dist/components/Toast/Toast.d.ts +1 -4
  120. package/dist/components/Toast/Toast.d.ts.map +1 -1
  121. package/dist/components/Toast/Toast.js +72 -37
  122. package/dist/components/Tooltip/Tooltip.d.ts +11 -3
  123. package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
  124. package/dist/components/Tooltip/Tooltip.js +58 -9
  125. package/dist/example/CodePreview.d.ts +2 -1
  126. package/dist/example/CodePreview.d.ts.map +1 -1
  127. package/dist/example/CodePreview.js +16 -51
  128. package/dist/example/ExampleActionsSection.d.ts.map +1 -1
  129. package/dist/example/ExampleActionsSection.js +3 -3
  130. package/dist/example/ExampleApplicationSection.d.ts +7 -0
  131. package/dist/example/ExampleApplicationSection.d.ts.map +1 -0
  132. package/dist/example/ExampleApplicationSection.js +88 -0
  133. package/dist/example/ExampleBasicsSections.d.ts +1 -1
  134. package/dist/example/ExampleBasicsSections.d.ts.map +1 -1
  135. package/dist/example/ExampleBasicsSections.js +15 -13
  136. package/dist/example/ExampleDataSection.d.ts.map +1 -1
  137. package/dist/example/ExampleDataSection.js +31 -30
  138. package/dist/example/ExampleFieldsSection.d.ts.map +1 -1
  139. package/dist/example/ExampleFieldsSection.js +51 -3
  140. package/dist/example/ExampleFoundationsSection.js +1 -1
  141. package/dist/example/ExampleOverlays.d.ts.map +1 -1
  142. package/dist/example/ExampleOverlays.js +7 -2
  143. package/dist/example/ExampleOverlaysSection.d.ts.map +1 -1
  144. package/dist/example/ExampleOverlaysSection.js +20 -30
  145. package/dist/example/ExampleSelectionSection.d.ts +3 -1
  146. package/dist/example/ExampleSelectionSection.d.ts.map +1 -1
  147. package/dist/example/ExampleSelectionSection.js +10 -3
  148. package/dist/example/ExampleStateSection.d.ts +3 -0
  149. package/dist/example/ExampleStateSection.d.ts.map +1 -1
  150. package/dist/example/ExampleStateSection.js +65 -9
  151. package/dist/example/ExampleThemePlayground.d.ts +84 -54
  152. package/dist/example/ExampleThemePlayground.d.ts.map +1 -1
  153. package/dist/example/ExampleThemePlayground.js +129 -63
  154. package/dist/example/UiExamplePage.d.ts.map +1 -1
  155. package/dist/example/UiExamplePage.js +39 -19
  156. package/dist/example/codeSamples.d.ts +8 -1
  157. package/dist/example/codeSamples.d.ts.map +1 -1
  158. package/dist/example/codeSamples.js +590 -119
  159. package/dist/example/exampleData.d.ts.map +1 -1
  160. package/dist/example/exampleData.js +18 -10
  161. package/dist/example/styles.css +277 -146
  162. package/dist/hooks/useFloatingPosition.js +1 -1
  163. package/dist/hooks/usePresence.d.ts.map +1 -1
  164. package/dist/hooks/usePresence.js +9 -7
  165. package/dist/index.d.ts +9 -1
  166. package/dist/index.d.ts.map +1 -1
  167. package/dist/index.js +9 -1
  168. package/dist/styles/orcestr-ui.css +3002 -872
  169. package/dist/theme/ThemeProvider.d.ts.map +1 -1
  170. package/dist/theme/ThemeProvider.js +109 -53
  171. package/dist/theme/defaultTheme.d.ts.map +1 -1
  172. package/dist/theme/defaultTheme.js +356 -223
  173. package/dist/theme/systemProps.d.ts +48 -28
  174. package/dist/theme/systemProps.d.ts.map +1 -1
  175. package/dist/theme/systemProps.js +103 -1
  176. package/dist/theme/themeTypes.d.ts +44 -35
  177. package/dist/theme/themeTypes.d.ts.map +1 -1
  178. package/dist/utils/slot.d.ts +11 -0
  179. package/dist/utils/slot.d.ts.map +1 -0
  180. package/dist/utils/slot.js +18 -0
  181. package/package.json +4 -1
  182. package/dist/components/Workflow/Workflow.d.ts +0 -82
  183. package/dist/components/Workflow/Workflow.d.ts.map +0 -1
  184. package/dist/components/Workflow/Workflow.js +0 -73
@@ -1,9 +1,22 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useCallback, useLayoutEffect, useRef, useState, } from 'react';
3
+ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
4
+ import { LuChevronLeft, LuChevronRight } from 'react-icons/lu';
4
5
  import { cn } from '../../utils/cn';
5
6
  import { Collapse } from '../Collapse/Collapse';
6
- export function Tabs({ items, value, onValueChange, className, listClassName, contentClassName, testId, }) {
7
+ import { IconButton } from '../IconButton/IconButton';
8
+ function stableTabRect(current, next) {
9
+ if (!current || !next)
10
+ return next;
11
+ if (current.left === next.left &&
12
+ current.top === next.top &&
13
+ current.width === next.width &&
14
+ current.height === next.height) {
15
+ return current;
16
+ }
17
+ return next;
18
+ }
19
+ function ItemTabs({ items, value, onValueChange, className, listClassName, contentClassName, testId, }) {
7
20
  const active = items.find((item) => item.value === value) ?? items[0];
8
21
  const listRef = useRef(null);
9
22
  const triggerRefs = useRef(new Map());
@@ -28,9 +41,10 @@ export function Tabs({ items, value, onValueChange, className, listClassName, co
28
41
  height: trigger.offsetHeight,
29
42
  };
30
43
  };
31
- setActiveRect(readRect(active?.value));
32
- setHoverRect((current) => readRect(hoveredValue) ?? current);
33
- setHoverVisible(Boolean(hoveredValue && readRect(hoveredValue)));
44
+ setActiveRect((current) => stableTabRect(current, readRect(active?.value)));
45
+ const nextHoverRect = readRect(hoveredValue);
46
+ setHoverRect((current) => (nextHoverRect ? stableTabRect(current, nextHoverRect) : current));
47
+ setHoverVisible(Boolean(hoveredValue && nextHoverRect && hoveredValue !== active?.value));
34
48
  }, [active?.value, hoveredValue]);
35
49
  const moveFocus = (currentValue, direction) => {
36
50
  const currentIndex = items.findIndex((item) => item.value === currentValue);
@@ -94,6 +108,174 @@ export function Tabs({ items, value, onValueChange, className, listClassName, co
94
108
  return (_jsx(Collapse, { open: open, children: _jsx("div", { role: 'tabpanel', className: 'oui-tabs-panel', "data-active": open ? 'true' : undefined, "data-testid": testId ? `${testId}-${item.value}-panel` : undefined, children: item.content }) }, item.value));
95
109
  }) })] }));
96
110
  }
111
+ const TabsCtx = createContext(null);
112
+ function useTabsCtx() {
113
+ const ctx = useContext(TabsCtx);
114
+ if (!ctx)
115
+ throw new Error('Tabs.* must be used inside <Tabs.Root>.');
116
+ return ctx;
117
+ }
118
+ function Root({ value, defaultValue, onValueChange, children, className, ...props }) {
119
+ const [uncontrolled, setUncontrolled] = useState(defaultValue);
120
+ const isControlled = value !== undefined;
121
+ const currentValue = isControlled ? value : uncontrolled;
122
+ const [hoveredValue, setHoveredValue] = useState(null);
123
+ const triggersRef = useRef(new Map());
124
+ const [, setTriggersVersion] = useState(0);
125
+ const registerTrigger = useCallback((nextValue, element) => {
126
+ const triggers = triggersRef.current;
127
+ if (element) {
128
+ if (triggers.get(nextValue) === element)
129
+ return;
130
+ triggers.set(nextValue, element);
131
+ }
132
+ else {
133
+ if (!triggers.has(nextValue))
134
+ return;
135
+ triggers.delete(nextValue);
136
+ }
137
+ setTriggersVersion((current) => current + 1);
138
+ }, []);
139
+ const handleChange = useCallback((nextValue) => {
140
+ if (!isControlled)
141
+ setUncontrolled(nextValue);
142
+ onValueChange?.(nextValue);
143
+ }, [isControlled, onValueChange]);
144
+ const ctxValue = useMemo(() => ({
145
+ activeValue: currentValue,
146
+ hoveredValue,
147
+ setHoveredValue,
148
+ setActiveValue: handleChange,
149
+ registerTrigger,
150
+ }), [currentValue, handleChange, hoveredValue, registerTrigger]);
151
+ return (_jsx(TabsCtx.Provider, { value: ctxValue, children: _jsx("div", { className: cn('oui-tabs-compound', className), "data-tabs-root": true, "data-value": currentValue, ...props, children: children }) }));
152
+ }
153
+ function List({ children, indicatorPaddingY = 4, className, style, ...props }) {
154
+ const ctx = useTabsCtx();
155
+ const listRef = useRef(null);
156
+ const [hoverRect, setHoverRect] = useState(null);
157
+ const [hoverVisible, setHoverVisible] = useState(false);
158
+ const [activeRect, setActiveRect] = useState(null);
159
+ const [canScrollLeft, setCanScrollLeft] = useState(false);
160
+ const [canScrollRight, setCanScrollRight] = useState(false);
161
+ const measure = useCallback(() => {
162
+ const list = listRef.current;
163
+ if (!list)
164
+ return;
165
+ const triggers = list.querySelectorAll('[data-tabs-trigger]');
166
+ let hover = null;
167
+ let active = null;
168
+ triggers.forEach((element) => {
169
+ const nextValue = element.dataset.tabsTrigger;
170
+ if (!nextValue)
171
+ return;
172
+ const rect = {
173
+ left: element.offsetLeft,
174
+ top: element.offsetTop,
175
+ width: element.offsetWidth,
176
+ height: element.offsetHeight,
177
+ };
178
+ if (nextValue === ctx.hoveredValue)
179
+ hover = rect;
180
+ if (nextValue === ctx.activeValue)
181
+ active = rect;
182
+ });
183
+ setHoverRect((current) => (hover ? stableTabRect(current, hover) : current));
184
+ setHoverVisible(Boolean(hover && ctx.hoveredValue !== ctx.activeValue));
185
+ setActiveRect((current) => stableTabRect(current, active));
186
+ setCanScrollLeft(list.scrollLeft > 1);
187
+ setCanScrollRight(list.scrollLeft + list.clientWidth < list.scrollWidth - 1);
188
+ }, [ctx.activeValue, ctx.hoveredValue]);
189
+ useLayoutEffect(() => {
190
+ measure();
191
+ }, [measure]);
192
+ useEffect(() => {
193
+ const list = listRef.current;
194
+ if (!list)
195
+ return;
196
+ const observer = new ResizeObserver(() => measure());
197
+ observer.observe(list);
198
+ list.querySelectorAll('[data-tabs-trigger]').forEach((element) => observer.observe(element));
199
+ list.addEventListener('scroll', measure, { passive: true });
200
+ return () => {
201
+ observer.disconnect();
202
+ list.removeEventListener('scroll', measure);
203
+ };
204
+ }, [children, measure]);
205
+ const scrollList = (direction) => {
206
+ const list = listRef.current;
207
+ if (!list)
208
+ return;
209
+ list.scrollBy({
210
+ left: direction * Math.max(Math.round(list.clientWidth * 0.6), 160),
211
+ behavior: 'smooth',
212
+ });
213
+ };
214
+ const handleWheel = useCallback((event) => {
215
+ if (event.defaultPrevented)
216
+ return;
217
+ const list = listRef.current;
218
+ if (!list || list.scrollWidth <= list.clientWidth + 1)
219
+ return;
220
+ const rawDelta = Math.abs(event.deltaY) >= Math.abs(event.deltaX)
221
+ ? event.deltaY
222
+ : event.deltaX;
223
+ if (rawDelta === 0)
224
+ return;
225
+ const delta = event.deltaMode === 1
226
+ ? rawDelta * 32
227
+ : event.deltaMode === 2
228
+ ? rawDelta * list.clientWidth
229
+ : rawDelta;
230
+ const maxScrollLeft = list.scrollWidth - list.clientWidth;
231
+ const canScroll = delta < 0 ? list.scrollLeft > 1 : list.scrollLeft < maxScrollLeft - 1;
232
+ if (!canScroll)
233
+ return;
234
+ event.preventDefault();
235
+ list.scrollBy({ left: delta, behavior: 'smooth' });
236
+ }, []);
237
+ useEffect(() => {
238
+ const list = listRef.current;
239
+ if (!list)
240
+ return;
241
+ list.addEventListener('wheel', handleWheel, { passive: false });
242
+ return () => list.removeEventListener('wheel', handleWheel);
243
+ }, [handleWheel]);
244
+ const hasOverflowControls = canScrollLeft || canScrollRight;
245
+ return (_jsxs("div", { className: 'oui-tabs-compound-shell', children: [canScrollLeft ? (_jsx("span", { "aria-hidden": true, className: 'oui-tabs-edge oui-tabs-edge-left' })) : null, canScrollRight ? (_jsx("span", { "aria-hidden": true, className: 'oui-tabs-edge oui-tabs-edge-right' })) : null, canScrollLeft ? (_jsx(IconButton, { type: 'button', v: 'soft', tone: 'neutral', round: true, size: 1, onClick: () => scrollList(-1), "aria-label": 'Scroll tabs left', className: 'oui-tabs-scroll-button oui-tabs-scroll-button-left', children: _jsx(LuChevronLeft, { size: 16 }) })) : null, canScrollRight ? (_jsx(IconButton, { type: 'button', v: 'soft', tone: 'neutral', round: true, size: 1, onClick: () => scrollList(1), "aria-label": 'Scroll tabs right', className: 'oui-tabs-scroll-button oui-tabs-scroll-button-right', children: _jsx(LuChevronRight, { size: 16 }) })) : null, _jsxs("div", { ref: listRef, role: 'tablist', onMouseLeave: () => ctx.setHoveredValue(null), className: cn('oui-tabs-list-scroll', className), "data-overflow": hasOverflowControls ? 'true' : undefined, style: style, ...props, children: [activeRect ? (_jsx("span", { "aria-hidden": true, className: 'oui-tabs-compound-active-indicator', style: compoundIndicatorStyle(activeRect, indicatorPaddingY) })) : null, hoverRect ? (_jsx("span", { "aria-hidden": true, className: 'oui-tabs-compound-hover-indicator', "data-visible": hoverVisible ? 'true' : undefined, style: compoundIndicatorStyle(hoverRect, indicatorPaddingY) })) : null, children] })] }));
246
+ }
247
+ function Trigger({ value, children, icon, size = '2', className, onMouseEnter, onClick, ...props }) {
248
+ const ctx = useTabsCtx();
249
+ const ref = useRef(null);
250
+ const isActive = ctx.activeValue === value;
251
+ useEffect(() => {
252
+ ctx.registerTrigger(value, ref.current);
253
+ return () => ctx.registerTrigger(value, null);
254
+ }, [ctx, value]);
255
+ return (_jsxs("button", { ref: ref, type: 'button', role: 'tab', "aria-selected": isActive, className: cn('oui-tabs-trigger', className), "data-active": isActive ? 'true' : undefined, "data-size": size, "data-tabs-trigger": value, onMouseEnter: (event) => {
256
+ ctx.setHoveredValue(value);
257
+ onMouseEnter?.(event);
258
+ }, onClick: (event) => {
259
+ onClick?.(event);
260
+ if (event.defaultPrevented)
261
+ return;
262
+ ctx.setHoveredValue(value);
263
+ ctx.setActiveValue(value);
264
+ }, ...props, children: [icon ? (_jsx("span", { className: 'oui-tabs-trigger-icon', "aria-hidden": true, children: icon })) : null, children] }));
265
+ }
266
+ function Content({ value, children, className, mountOnActive = false, ...props }) {
267
+ const ctx = useTabsCtx();
268
+ const open = ctx.activeValue === value;
269
+ const [mounted, setMounted] = useState(open);
270
+ useEffect(() => {
271
+ if (!open || mounted)
272
+ return;
273
+ const frameId = window.requestAnimationFrame(() => setMounted(true));
274
+ return () => window.cancelAnimationFrame(frameId);
275
+ }, [mounted, open]);
276
+ const shouldRenderChildren = !mountOnActive || mounted || open;
277
+ return (_jsx("div", { role: 'tabpanel', className: cn('oui-tabs-compound-panel', className), "data-tabs-content": value, hidden: !open, ...props, children: _jsx(Collapse, { open: open, children: _jsx("div", { className: 'oui-tabs-compound-panel-inner', children: shouldRenderChildren ? children : null }) }) }));
278
+ }
97
279
  function indicatorStyle(rect) {
98
280
  return {
99
281
  left: rect.left,
@@ -102,3 +284,17 @@ function indicatorStyle(rect) {
102
284
  height: Math.max(0, rect.height - 8),
103
285
  };
104
286
  }
287
+ function compoundIndicatorStyle(rect, paddingY) {
288
+ return {
289
+ left: rect.left,
290
+ top: rect.top + paddingY,
291
+ width: rect.width,
292
+ height: Math.max(0, rect.height - paddingY * 2),
293
+ };
294
+ }
295
+ export const Tabs = Object.assign(ItemTabs, {
296
+ Root,
297
+ List,
298
+ Trigger,
299
+ Content,
300
+ });
@@ -1,13 +1,23 @@
1
1
  import { type ComponentPropsWithoutRef, type ElementType } from 'react';
2
- import { type SystemProps, type Tone } from '../../theme/systemProps';
2
+ import { type SystemProps, type ToneInput } from '../../theme/systemProps';
3
3
  export type TextProps = ComponentPropsWithoutRef<'span'> & SystemProps & {
4
4
  as?: ElementType;
5
- tone?: Tone | 'muted';
5
+ tone?: ToneInput;
6
+ asChild?: boolean;
7
+ href?: string;
8
+ target?: string;
9
+ rel?: string;
10
+ trim?: string;
6
11
  testId?: string;
7
12
  };
8
13
  export declare const Text: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & SystemProps & {
9
14
  as?: ElementType;
10
- tone?: Tone | "muted";
15
+ tone?: ToneInput;
16
+ asChild?: boolean;
17
+ href?: string;
18
+ target?: string;
19
+ rel?: string;
20
+ trim?: string;
11
21
  testId?: string;
12
22
  } & import("react").RefAttributes<HTMLElement>>;
13
23
  //# sourceMappingURL=Text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EACnB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAEtF,MAAM,MAAM,SAAS,GAAG,wBAAwB,CAAC,MAAM,CAAC,GACpD,WAAW,GAAG;IACV,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,IAAI;SALJ,WAAW;WACT,IAAI,GAAG,OAAO;aACZ,MAAM;+CAiBrB,CAAC"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAEnB,MAAM,OAAO,CAAC;AAGf,OAAO,EAGH,KAAK,WAAW,EAChB,KAAK,SAAS,EACjB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,MAAM,SAAS,GAAG,wBAAwB,CAAC,MAAM,CAAC,GACpD,WAAW,GAAG;IACV,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,IAAI;SAVJ,WAAW;WACT,SAAS;cACN,OAAO;WACV,MAAM;aACJ,MAAM;UACT,MAAM;WACL,MAAM;aACJ,MAAM;+CA2CrB,CAAC"}
@@ -1,8 +1,21 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, } from 'react';
3
3
  import { cn } from '../../utils/cn';
4
- import { splitSystemProps } from '../../theme/systemProps';
5
- export const Text = forwardRef(function Text({ as: Component = 'span', className, style, tone, testId, ...props }, ref) {
4
+ import { normalizeTone, splitSystemProps, } from '../../theme/systemProps';
5
+ import { renderSlot } from '../../utils/slot';
6
+ export const Text = forwardRef(function Text({ as: Component = 'span', className, style, tone, asChild = false, testId, children, ...props }, ref) {
6
7
  const { systemStyle, restProps } = splitSystemProps(props);
7
- return (_jsx(Component, { ref: ref, className: cn('oui-text', tone && `oui-text-${tone}`, className), "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps }));
8
+ const commonProps = {
9
+ className: cn('oui-text', tone && `oui-text-${tone === 'muted' ? 'muted' : normalizeTone(tone)}`, className),
10
+ 'data-testid': testId,
11
+ style: { ...systemStyle, ...style },
12
+ ...restProps,
13
+ };
14
+ if (asChild) {
15
+ return renderSlot(children, {
16
+ ...commonProps,
17
+ ref: ref,
18
+ });
19
+ }
20
+ return (_jsx(Component, { ref: ref, ...commonProps, children: children }));
8
21
  });
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIH,KAAK,sBAAsB,EAC9B,MAAM,OAAO,CAAC;AAIf,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,MAAM,EACd,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,aAAa,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,GACnE,WAAW,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,QAAQ;WANN,MAAM;cACH,OAAO;iBACJ,OAAO;aACX,MAAM;uDAwCtB,CAAC"}
1
+ {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIH,KAAK,sBAAsB,EAC9B,MAAM,OAAO,CAAC;AAIf,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,MAAM,EACd,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,aAAa,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,GACnE,WAAW,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,QAAQ;WANN,MAAM;cACH,OAAO;iBACJ,OAAO;aACX,MAAM;uDA0CtB,CAAC"}
@@ -4,7 +4,7 @@ import { forwardRef, useLayoutEffect, useRef, } from 'react';
4
4
  import { cn } from '../../utils/cn';
5
5
  import { composeRefs } from '../../utils/composeRefs';
6
6
  import { splitSystemProps, } from '../../theme/systemProps';
7
- export const TextArea = forwardRef(function TextArea({ className, style, size = 2, invalid = false, autoResize = false, value, testId, ...props }, ref) {
7
+ export const TextArea = forwardRef(function TextArea({ className, style, size = 2, invalid = false, autoResize = false, value, testId, children: _children, dangerouslySetInnerHTML: _dangerouslySetInnerHTML, ...props }, ref) {
8
8
  const localRef = useRef(null);
9
9
  const { systemStyle, restProps } = splitSystemProps(props);
10
10
  useLayoutEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,EAMH,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAMf,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,MAAM,EACd,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,cAAc,GAAG,IAAI,CAC7B,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,CACT,GACG,WAAW,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,SAAS;WAXP,MAAM;cACH,OAAO;gBACL,OAAO;eACR,SAAS;gBACR,SAAS;gBACT,OAAO;cACT,MAAM,IAAI;iBACP,MAAM;aACV,MAAM;oDA4FtB,CAAC"}
1
+ {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,EAMH,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAMf,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,MAAM,EACd,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,cAAc,GAAG,IAAI,CAC7B,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,CACT,GACG,WAAW,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,SAAS;WAXP,MAAM;cACH,OAAO;gBACL,OAAO;eACR,SAAS;gBACR,SAAS;gBACT,OAAO;cACT,MAAM,IAAI;iBACP,MAAM;aACV,MAAM;oDA8FtB,CAAC"}
@@ -6,7 +6,7 @@ import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
6
6
  import { cn } from '../../utils/cn';
7
7
  import { composeRefs } from '../../utils/composeRefs';
8
8
  import { splitSystemProps, } from '../../theme/systemProps';
9
- export const TextField = forwardRef(function TextField({ className, style, size = 3, invalid = false, fullWidth = true, leftSlot, rightSlot, clearable = false, onClear, clearLabel, testId, value, defaultValue, onChange, disabled, id, ...props }, ref) {
9
+ export const TextField = forwardRef(function TextField({ className, style, size = 3, invalid = false, fullWidth = true, leftSlot, rightSlot, clearable = false, onClear, clearLabel, testId, value, defaultValue, onChange, disabled, id, children: _children, dangerouslySetInnerHTML: _dangerouslySetInnerHTML, ...props }, ref) {
10
10
  const { copy } = useOrcestrUiLocale();
11
11
  const generatedId = useId();
12
12
  const inputId = id ?? generatedId;
@@ -10,11 +10,8 @@ export type ToastOptions = {
10
10
  title: ReactNode;
11
11
  message?: ReactNode;
12
12
  tone?: ToastTone;
13
+ icon?: ReactNode | false;
13
14
  position?: ToastPosition;
14
- background?: string;
15
- blur?: number | string | false;
16
- borderColor?: string;
17
- shadow?: string;
18
15
  progressColor?: string;
19
16
  action?: ToastAction;
20
17
  duration?: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,EASH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AASf,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAClE,MAAM,MAAM,aAAa,GACnB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,aAAa,GACb,eAAe,GACf,cAAc,CAAC;AAErB,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,YAAY,CAAC;AAU/C,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM,CAAC;IACtD,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACrC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACpC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAmCF,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,eAAwC,EACxC,UAA+B,EAC/B,MAAM,GACT,EAAE;IACC,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CAoJA;AAED,wBAAgB,QAAQ,sBAMvB"}
1
+ {"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,EASH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AASf,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAClE,MAAM,MAAM,aAAa,GACnB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,aAAa,GACb,eAAe,GACf,cAAc,CAAC;AAErB,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,YAAY,CAAC;AAe/C,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,MAAM,CAAC;IACtD,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACrC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;IACpC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAmCF,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,eAAwC,EACxC,UAA+B,EAC/B,MAAM,GACT,EAAE;IACC,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CA8LA;AAED,wBAAgB,QAAQ,sBAMvB"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
4
- import { LuX } from 'react-icons/lu';
4
+ import { LuCircleAlert, LuCircleCheck, LuCircleX, LuInfo, LuX } from 'react-icons/lu';
5
5
  import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
6
6
  import { Button } from '../Button/Button';
7
7
  import { IconButton } from '../IconButton/IconButton';
@@ -41,6 +41,7 @@ export function ToastProvider({ children, defaultPosition = DEFAULT_TOAST_POSITI
41
41
  const nextId = useRef(1);
42
42
  const timeoutIds = useRef(new Map());
43
43
  const removalIds = useRef(new Map());
44
+ const timers = useRef(new Map());
44
45
  const setToastItems = useCallback((update) => {
45
46
  setItems((current) => {
46
47
  const next = update(current);
@@ -54,6 +55,14 @@ export function ToastProvider({ children, defaultPosition = DEFAULT_TOAST_POSITI
54
55
  window.clearTimeout(timeoutId);
55
56
  timeoutIds.current.delete(id);
56
57
  }
58
+ timers.current.delete(id);
59
+ }, []);
60
+ const stopTimer = useCallback((id) => {
61
+ const timeoutId = timeoutIds.current.get(id);
62
+ if (timeoutId !== undefined) {
63
+ window.clearTimeout(timeoutId);
64
+ timeoutIds.current.delete(id);
65
+ }
57
66
  }, []);
58
67
  const clearRemovalTimer = useCallback((id) => {
59
68
  const timeoutId = removalIds.current.get(id);
@@ -63,9 +72,10 @@ export function ToastProvider({ children, defaultPosition = DEFAULT_TOAST_POSITI
63
72
  }
64
73
  }, []);
65
74
  const removeToast = useCallback((id) => {
75
+ clearTimer(id);
66
76
  clearRemovalTimer(id);
67
77
  setToastItems((current) => current.filter((item) => item.id !== id));
68
- }, [clearRemovalTimer, setToastItems]);
78
+ }, [clearRemovalTimer, clearTimer, setToastItems]);
69
79
  const dismiss = useCallback((id) => {
70
80
  clearTimer(id);
71
81
  setToastItems((current) => current.map((item) => item.id === id ? { ...item, state: 'closing' } : item));
@@ -78,20 +88,48 @@ export function ToastProvider({ children, defaultPosition = DEFAULT_TOAST_POSITI
78
88
  const clear = useCallback(() => {
79
89
  timeoutIds.current.forEach((timeoutId) => window.clearTimeout(timeoutId));
80
90
  timeoutIds.current.clear();
91
+ timers.current.clear();
81
92
  removalIds.current.forEach((timeoutId) => window.clearTimeout(timeoutId));
82
93
  removalIds.current.clear();
83
94
  setToastItems(() => []);
84
95
  }, [setToastItems]);
85
- const scheduleDismiss = useCallback((item) => {
86
- clearTimer(item.id);
87
- if (item.duration === null)
96
+ const scheduleDismiss = useCallback((item, remainingMs) => {
97
+ stopTimer(item.id);
98
+ if (item.duration === null) {
99
+ timers.current.delete(item.id);
88
100
  return;
89
- const duration = item.duration ?? DEFAULT_TOAST_DURATION;
90
- if (duration <= 0)
101
+ }
102
+ const duration = remainingMs ?? item.duration ?? DEFAULT_TOAST_DURATION;
103
+ if (duration <= 0) {
104
+ dismiss(item.id);
91
105
  return;
106
+ }
107
+ timers.current.set(item.id, {
108
+ startedAt: Date.now(),
109
+ remaining: duration,
110
+ });
92
111
  const timeoutId = window.setTimeout(() => dismiss(item.id), duration);
93
112
  timeoutIds.current.set(item.id, timeoutId);
94
- }, [clearTimer, dismiss]);
113
+ }, [dismiss, stopTimer]);
114
+ const pauseDismiss = useCallback((id) => {
115
+ const timer = timers.current.get(id);
116
+ if (!timer || !timeoutIds.current.has(id))
117
+ return;
118
+ stopTimer(id);
119
+ timers.current.set(id, {
120
+ startedAt: timer.startedAt,
121
+ remaining: Math.max(0, timer.remaining - (Date.now() - timer.startedAt)),
122
+ });
123
+ }, [stopTimer]);
124
+ const resumeDismiss = useCallback((id) => {
125
+ if (timeoutIds.current.has(id))
126
+ return;
127
+ const item = itemsRef.current.find((currentItem) => currentItem.id === id);
128
+ const timer = timers.current.get(id);
129
+ if (!item || !timer || item.state === 'closing')
130
+ return;
131
+ scheduleDismiss(item, timer.remaining);
132
+ }, [scheduleDismiss]);
95
133
  const push = useCallback((input, tone) => {
96
134
  const normalized = normalizeToast(input, tone, defaultPosition);
97
135
  const existingItem = normalized.dedupeKey
@@ -134,7 +172,7 @@ export function ToastProvider({ children, defaultPosition = DEFAULT_TOAST_POSITI
134
172
  const positionItems = items.filter((item) => item.position === position);
135
173
  if (positionItems.length === 0)
136
174
  return null;
137
- return (_jsx("div", { className: 'oui-toast-viewport', "data-position": position, "data-testid": testId ? `${testId}-${position}` : undefined, "aria-live": 'polite', "aria-relevant": 'additions text', style: { zIndex: overlay.zIndex.toast }, children: positionItems.map((item) => (_jsx(ToastCard, { item: item, onDismiss: dismiss, onExited: removeToast, testId: testId ? `${testId}-${item.id}` : undefined }, item.id))) }, position));
175
+ return (_jsx("div", { className: 'oui-toast-stack', "data-position": position, "data-testid": testId ? `${testId}-${position}` : undefined, "aria-live": 'polite', "aria-relevant": 'additions text', style: { zIndex: overlay.zIndex.toast }, children: positionItems.map((item) => (_jsx(ToastCard, { item: item, onDismiss: dismiss, onPause: pauseDismiss, onResume: resumeDismiss, onExited: removeToast, testId: testId ? `${testId}-${item.id}` : undefined }, item.id))) }, position));
138
176
  }) })] }));
139
177
  }
140
178
  export function useToast() {
@@ -144,48 +182,45 @@ export function useToast() {
144
182
  }
145
183
  return context;
146
184
  }
147
- function ToastCard({ item, onDismiss, onExited, testId, }) {
185
+ function ToastCard({ item, onDismiss, onPause, onResume, onExited, testId, }) {
148
186
  const { copy } = useOrcestrUiLocale();
149
187
  const duration = toastDuration(item);
150
188
  const hasProgress = item.duration !== null && duration > 0;
151
- const effectiveBlur = item.blur !== undefined ? cssLength(item.blur) : 'var(--oui-toast-blur, 14px)';
189
+ const icon = item.icon === false ? null : item.icon ?? toastIcon(item.tone);
152
190
  const style = {
153
- ...(item.background ? { '--oui-toast-bg': item.background } : null),
154
- '--oui-toast-effective-blur': effectiveBlur,
155
- ...(item.borderColor ? { '--oui-toast-custom-border-color': item.borderColor } : null),
156
- ...(item.shadow ? { '--oui-toast-shadow': item.shadow } : null),
157
191
  ...(item.progressColor ? { '--oui-toast-progress-color': item.progressColor } : null),
158
192
  };
159
- const blurStyle = {
160
- backdropFilter: `blur(${effectiveBlur})`,
161
- WebkitBackdropFilter: `blur(${effectiveBlur})`,
162
- };
163
- return (_jsxs("div", { className: 'oui-toast-frame', "data-position": item.position, "data-state": item.state, style: style, onAnimationEnd: (event) => {
193
+ return (_jsx("div", { className: 'oui-toast-viewport oui-toast-frame', "data-position": item.position, "data-state": item.state, style: style, onAnimationEnd: (event) => {
164
194
  if (event.animationName === 'ouiToastOut') {
165
195
  onExited(item.id);
166
196
  }
167
- }, children: [_jsx("span", { className: 'oui-toast-backdrop', "aria-hidden": 'true', style: blurStyle }), _jsxs("div", { className: 'oui-toast', "data-tone": item.tone, "data-state": item.state, "data-position": item.position, "data-clickable": item.dismissible === false ? undefined : 'true', "data-testid": testId, role: item.tone === 'danger' ? 'alert' : 'status', style: blurStyle, onClick: () => {
168
- if (item.dismissible !== false)
197
+ }, children: _jsxs("div", { className: 'oui-toast', "data-tone": item.tone, "data-state": item.state, "data-position": item.position, "data-clickable": item.dismissible === false ? undefined : 'true', "data-testid": testId, role: item.tone === 'danger' ? 'alert' : 'status', onMouseEnter: () => onPause(item.id), onMouseLeave: () => onResume(item.id), onClick: () => {
198
+ if (item.dismissible !== false)
199
+ onDismiss(item.id);
200
+ }, children: [_jsxs("div", { className: 'oui-toast-content', children: [icon ? (_jsx("span", { className: 'oui-toast-icon', "data-tone": item.tone, children: icon })) : null, _jsxs("div", { className: 'oui-toast-main', children: [_jsx("div", { className: 'oui-toast-title', children: item.title }), item.message ? (_jsx("div", { className: 'oui-toast-message', children: item.message })) : null, item.action ? (_jsx(Button, { className: 'oui-toast-action', size: 1, v: 'surface', tone: item.tone, onClick: (event) => {
201
+ event.stopPropagation();
202
+ item.action?.onClick();
203
+ if (item.action?.closeOnClick !== false) {
204
+ onDismiss(item.id);
205
+ }
206
+ }, children: item.action.label })) : null] })] }), item.closeButton ? (_jsx(IconButton, { className: 'oui-toast-close', size: 1, v: 'ghost', icon: _jsx(LuX, { size: 14 }), "aria-label": copy.common.dismissNotification, onClick: (event) => {
207
+ event.stopPropagation();
169
208
  onDismiss(item.id);
170
- }, children: [_jsxs("div", { className: 'oui-toast-main', children: [_jsx("div", { className: 'oui-toast-title', children: item.title }), item.message ? (_jsx("div", { className: 'oui-toast-message', children: item.message })) : null, item.action ? (_jsx(Button, { className: 'oui-toast-action', size: 1, v: 'surface', tone: item.tone, onClick: (event) => {
171
- event.stopPropagation();
172
- item.action?.onClick();
173
- if (item.action?.closeOnClick !== false) {
174
- onDismiss(item.id);
175
- }
176
- }, children: item.action.label })) : null] }), item.closeButton ? (_jsx(IconButton, { className: 'oui-toast-close', size: 1, v: 'ghost', icon: _jsx(LuX, { size: 14 }), "aria-label": copy.common.dismissNotification, onClick: (event) => {
177
- event.stopPropagation();
178
- onDismiss(item.id);
179
- } })) : null, hasProgress ? (_jsx("span", { className: 'oui-toast-progress', style: { '--oui-toast-duration': `${duration}ms` } }, item.createdAt)) : null] })] }));
180
- }
181
- function cssLength(value) {
182
- if (value === false)
183
- return '0px';
184
- return typeof value === 'number' ? `${value}px` : value;
209
+ } })) : null, hasProgress ? (_jsx("span", { className: 'oui-toast-progress', style: { '--oui-toast-duration': `${duration}ms` } }, item.createdAt)) : null] }) }));
185
210
  }
186
211
  function toastDuration(item) {
187
212
  return item.duration ?? DEFAULT_TOAST_DURATION;
188
213
  }
214
+ function toastIcon(tone) {
215
+ const size = 26;
216
+ if (tone === 'success')
217
+ return _jsx(LuCircleCheck, { size: size });
218
+ if (tone === 'warning')
219
+ return _jsx(LuCircleAlert, { size: size });
220
+ if (tone === 'danger')
221
+ return _jsx(LuCircleX, { size: size });
222
+ return _jsx(LuInfo, { size: size });
223
+ }
189
224
  function limitToastItems(items, maxVisible) {
190
225
  if (maxVisible <= 0)
191
226
  return items;
@@ -1,10 +1,18 @@
1
1
  import { type ReactNode } from 'react';
2
- import { type FloatingSide } from '../../hooks/useFloatingPosition';
3
- export declare function Tooltip({ content, children, side, className, testId, }: {
2
+ import { type FloatingAlign, type FloatingSide } from '../../hooks/useFloatingPosition';
3
+ export type TooltipProps = {
4
4
  content: ReactNode;
5
5
  children: ReactNode;
6
6
  side?: FloatingSide;
7
+ align?: FloatingAlign;
8
+ sideOffset?: number;
9
+ avoidCollisions?: boolean;
10
+ collisionPadding?: number;
11
+ open?: boolean;
12
+ defaultOpen?: boolean;
13
+ onOpenChange?: (open: boolean) => void;
7
14
  className?: string;
8
15
  testId?: string;
9
- }): import("react/jsx-runtime").JSX.Element;
16
+ };
17
+ export declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & import("react").RefAttributes<HTMLElement>>;
10
18
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAC,KAAK,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAMlE,wBAAgB,OAAO,CAAC,EACpB,OAAO,EACP,QAAQ,EACR,IAAY,EACZ,SAAS,EACT,MAAM,GACT,EAAE;IACC,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CAmDA"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQH,KAAK,SAAS,EAEjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAC,KAAK,aAAa,EAAE,KAAK,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAqBtF,MAAM,MAAM,YAAY,GAAG;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,OAAO,sGA0FlB,CAAC"}