@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,23 +1,18 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useContext, useEffect, useId, useLayoutEffect, useRef, } from 'react';
4
- import { LuX } from 'react-icons/lu';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useEffect, useLayoutEffect, useRef, } from 'react';
5
4
  import { useFocusTrap } from '../../hooks/useFocusTrap';
6
5
  import { usePresence } from '../../hooks/usePresence';
7
- import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
8
6
  import { OrcestrThemeContext } from '../../theme/useTheme';
9
7
  import { cn } from '../../utils/cn';
10
- import { IconButton } from '../IconButton/IconButton';
11
- import { lockOverlayScroll, useOverlayContext, useOverlayLayerIndex, } from '../Overlay/OverlayProvider';
8
+ import { lockOverlayScroll, overlayLayerZIndex, useOverlayContext, useOverlayLayerIndex, } from '../Overlay/OverlayProvider';
12
9
  import { Portal } from '../Portal/Portal';
13
- export function Modal({ open, onOpenChange, title, description, children, footer, maxWidth, minHeight, overlayColor, overlayOpacity, overlayBlur, borderColor, radius, shadow, animationDuration, animation, overlayClassName, overlayStyle, className, contentClassName, bodyClassName, closeOnOverlayClick = true, testId, }) {
14
- const { copy } = useOrcestrUiLocale();
10
+ const ModalContext = createContext(null);
11
+ function ModalRoot({ open, onOpenChange, children, maxWidth, minHeight, overlayColor, overlayOpacity, overlayBlur, borderColor, radius, shadow, animationDuration, animation, overlayClassName, overlayStyle, className, contentClassName, contentStyle, onKeyDown, onOpenAutoFocus, closeOnOverlayClick = true, ariaLabel, ariaLabelledBy, ariaDescribedBy, testId, }) {
15
12
  const themeContext = useContext(OrcestrThemeContext);
16
13
  const overlayContext = useOverlayContext();
17
14
  const layerRef = useRef(null);
18
15
  const contentRef = useRef(null);
19
- const titleId = useId();
20
- const descriptionId = useId();
21
16
  const actualAnimationDuration = animationDuration ?? themeContext?.theme.motion.modalDuration ?? '380ms';
22
17
  const actualAnimation = animation ?? themeContext?.theme.motion.modalAnimation ?? 'zoom-blur';
23
18
  const actualMaxWidth = maxWidth ?? themeContext?.theme.components.modalMaxWidth ?? 680;
@@ -28,7 +23,7 @@ export function Modal({ open, onOpenChange, title, description, children, footer
28
23
  const actualAnimationEase = themeContext?.theme.motion.ease ?? 'cubic-bezier(0.22, 1, 0.36, 1)';
29
24
  const { present, state } = usePresence(open, actualAnimationMs);
30
25
  const layerIndex = useOverlayLayerIndex(present);
31
- const zIndex = overlayContext.zIndex.modal + layerIndex * 20;
26
+ const zIndex = overlayLayerZIndex(overlayContext.zIndex, 'modal', layerIndex);
32
27
  const overlayBlurValue = cssLength(actualOverlayBlur) ?? '10px';
33
28
  const overlayBackdropFilter = `blur(${overlayBlurValue})`;
34
29
  const overlayBackground = modalOverlayBackground(actualOverlayColor, actualOverlayOpacity);
@@ -38,6 +33,11 @@ export function Modal({ open, onOpenChange, title, description, children, footer
38
33
  return;
39
34
  return lockOverlayScroll();
40
35
  }, [open]);
36
+ useEffect(() => {
37
+ if (!open || !onOpenAutoFocus)
38
+ return;
39
+ onOpenAutoFocus({ preventDefault: () => undefined });
40
+ }, [onOpenAutoFocus, open]);
41
41
  useLayoutEffect(() => {
42
42
  const layer = layerRef.current;
43
43
  if (!present || !layer || !layer.animate)
@@ -89,7 +89,7 @@ export function Modal({ open, onOpenChange, title, description, children, footer
89
89
  if (closeOnOverlayClick)
90
90
  onOpenChange(false);
91
91
  }
92
- }, children: _jsxs("div", { ref: contentRef, role: 'dialog', "aria-modal": 'true', "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined, className: cn('oui-modal-content', contentClassName), "data-state": state, "data-animation": actualAnimation, "data-testid": testId ? `${testId}-content` : undefined, style: {
92
+ }, children: _jsx("div", { ref: contentRef, role: 'dialog', "aria-modal": 'true', "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className: cn('oui-modal-content', contentClassName), "data-state": state, "data-animation": actualAnimation, "data-testid": testId ? `${testId}-content` : undefined, style: {
93
93
  width: typeof actualMaxWidth === 'number'
94
94
  ? `min(calc(100vw - 24px), ${actualMaxWidth}px)`
95
95
  : `min(calc(100vw - 24px), ${actualMaxWidth})`,
@@ -99,7 +99,8 @@ export function Modal({ open, onOpenChange, title, description, children, footer
99
99
  '--oui-modal-border-color': borderColor,
100
100
  '--oui-modal-radius': cssLength(radius),
101
101
  '--oui-modal-shadow': shadow,
102
- }, children: [_jsxs("div", { className: 'oui-modal-header', children: [_jsxs("div", { className: 'oui-modal-title-wrap', children: [title ? (_jsx("h2", { id: titleId, className: 'oui-modal-title', children: title })) : null, description ? (_jsx("p", { id: descriptionId, className: 'oui-modal-description', children: description })) : null] }), _jsx(IconButton, { v: 'ghost', icon: _jsx(LuX, { size: 18 }), "aria-label": copy.common.close, onClick: () => onOpenChange(false) })] }), _jsx("div", { className: cn('oui-modal-body', bodyClassName), children: children }), footer ? _jsx("div", { className: 'oui-modal-footer', children: footer }) : null] }) }) }));
102
+ ...contentStyle,
103
+ }, onKeyDown: onKeyDown, children: _jsx(ModalContext.Provider, { value: { onOpenChange }, children: children }) }) }) }));
103
104
  }
104
105
  function cssLength(value) {
105
106
  if (value === undefined)
@@ -153,3 +154,26 @@ function hexToRgb(value) {
153
154
  }
154
155
  return null;
155
156
  }
157
+ function ModalHeader({ children, className, style }) {
158
+ return (_jsx("div", { className: cn('oui-modal-header', className), style: style, children: children }));
159
+ }
160
+ function ModalBody({ children, className, style }) {
161
+ return (_jsx("div", { className: cn('oui-modal-body', className), style: style, children: children }));
162
+ }
163
+ function ModalFooter({ children, className, style }) {
164
+ return (_jsx("div", { className: cn('oui-modal-footer', className), style: style, children: children }));
165
+ }
166
+ function ModalClose({ onClick, ...props }) {
167
+ const context = useContext(ModalContext);
168
+ return (_jsx("button", { type: 'button', ...props, onClick: (event) => {
169
+ onClick?.(event);
170
+ if (!event.defaultPrevented)
171
+ context?.onOpenChange(false);
172
+ } }));
173
+ }
174
+ export const Modal = Object.assign(ModalRoot, {
175
+ Header: ModalHeader,
176
+ Body: ModalBody,
177
+ Footer: ModalFooter,
178
+ Close: ModalClose,
179
+ });
@@ -14,6 +14,7 @@ export type OverlayProviderProps = {
14
14
  export declare function OverlayProvider({ children, container, zIndex, testId, }: OverlayProviderProps): import("react/jsx-runtime").JSX.Element;
15
15
  export declare function useOverlayContext(): OverlayContextValue;
16
16
  export declare function useOverlayLayerIndex(active: boolean): number;
17
+ export declare function overlayLayerZIndex(zIndex: OverlayZIndex, kind: OverlayLayerKind, layerIndex: number): number;
17
18
  export declare function lockOverlayScroll(): () => void;
18
19
  export {};
19
20
  //# sourceMappingURL=OverlayProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OverlayProvider.d.ts","sourceRoot":"","sources":["../../../src/components/Overlay/OverlayProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1E,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAE7D,KAAK,mBAAmB,GAAG;IACvB,eAAe,EAAE,WAAW,G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ED,wBAAgB,iBAAiB,wBAEhC;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,UA4BnD;AAED,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,MAAM,UAQrB;AAKD,wBAAgB,iBAAiB,eAYhC"}
@@ -7,6 +7,8 @@ const defaultZIndex = {
7
7
  modal: 1000,
8
8
  toast: 2147483000,
9
9
  };
10
+ const OVERLAY_LAYER_STEP = 20;
11
+ const DROPDOWN_LAYER_OFFSET = 10;
10
12
  const OverlayContext = createContext({
11
13
  portalContainer: null,
12
14
  zIndex: defaultZIndex,
@@ -36,6 +38,12 @@ export function useOverlayContext() {
36
38
  export function useOverlayLayerIndex(active) {
37
39
  const [id] = useState(() => Symbol('oui-layer'));
38
40
  const [index, setIndex] = useState(0);
41
+ const currentIndex = layerIds.indexOf(id);
42
+ const optimisticIndex = active
43
+ ? currentIndex === -1
44
+ ? layerIds.length
45
+ : currentIndex
46
+ : index;
39
47
  useEffect(() => {
40
48
  if (!active)
41
49
  return;
@@ -54,7 +62,16 @@ export function useOverlayLayerIndex(active) {
54
62
  emitLayerChange();
55
63
  };
56
64
  }, [active, id]);
57
- return index;
65
+ return optimisticIndex;
66
+ }
67
+ export function overlayLayerZIndex(zIndex, kind, layerIndex) {
68
+ if (kind === 'toast')
69
+ return zIndex.toast;
70
+ if (kind === 'dropdown') {
71
+ const base = Math.max(zIndex.dropdown, zIndex.modal, zIndex.overlay);
72
+ return base + layerIndex * OVERLAY_LAYER_STEP + DROPDOWN_LAYER_OFFSET;
73
+ }
74
+ return zIndex[kind] + layerIndex * OVERLAY_LAYER_STEP;
58
75
  }
59
76
  let scrollLockCount = 0;
60
77
  let previousBodyOverflow = '';
@@ -29,6 +29,7 @@ export type PaginatedComboboxProps<T> = {
29
29
  disabled?: boolean;
30
30
  clearable?: boolean;
31
31
  showChevron?: boolean;
32
+ trigger?: ReactNode;
32
33
  size?: UiSize;
33
34
  maxHeight?: number;
34
35
  closeOnSelect?: boolean;
@@ -44,5 +45,5 @@ export type PaginatedComboboxProps<T> = {
44
45
  debounceMs?: number;
45
46
  testId?: string;
46
47
  };
47
- export declare function PaginatedCombobox<T>({ loadPage, getItemId, renderOption, renderSelectedLabel, value, onChange, placeholder, emptyText, loadingText, errorText, retryLabel, searchPlaceholder, clearLabel, disabled, clearable, showChevron, size, maxHeight, closeOnSelect, isItemSelected, searchAction, optionAction, resetKey, debounceMs, testId, }: PaginatedComboboxProps<T>): import("react/jsx-runtime").JSX.Element;
48
+ export declare function PaginatedCombobox<T>({ loadPage, getItemId, renderOption, renderSelectedLabel, value, onChange, placeholder, emptyText, loadingText, errorText, retryLabel, searchPlaceholder, clearLabel, disabled, clearable, showChevron, trigger, size, maxHeight, closeOnSelect, isItemSelected, searchAction, optionAction, resetKey, debounceMs, testId, }: PaginatedComboboxProps<T>): import("react/jsx-runtime").JSX.Element;
48
49
  //# sourceMappingURL=PaginatedCombobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaginatedCombobox.d.ts","sourceRoot":"","sources":["../../../src/components/PaginatedCombobox/PaginatedCombobox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAQpD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IACxC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,MAAM,EAA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E,SAAS,CAAC;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;QAC/C,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;KACnC,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,EACjC,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,QAAgB,EAChB,SAAiB,EACjB,WAAkB,EAClB,IAAQ,EACR,SAAe,EACf,aAAoB,EACpB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,UAAgC,EAChC,MAAM,GACT,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CAmX3B"}
1
+ {"version":3,"file":"PaginatedCombobox.d.ts","sourceRoot":"","sources":["../../../src/components/PaginatedCombobox/PaginatedCombobox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAQpD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IACxC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KA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AAY,CAAC,EAAE;QACX,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;QAC3B,IAAI,EAAE,SAAS,CAAC;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;QAC/C,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;KACnC,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,EACjC,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,QAAgB,EAChB,SAAiB,EACjB,WAAkB,EAClB,OAAO,EACP,IAAQ,EACR,SAAe,EACf,aAAoB,EACpB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,UAAgC,EAChC,MAAM,GACT,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CAqX3B"}
@@ -11,7 +11,7 @@ import { Spinner } from '../Spinner/Spinner';
11
11
  import { TextField } from '../TextField/TextField';
12
12
  import { Tooltip } from '../Tooltip/Tooltip';
13
13
  const DEFAULT_DEBOUNCE_MS = 200;
14
- export function PaginatedCombobox({ loadPage, getItemId, renderOption, renderSelectedLabel, value, onChange, placeholder, emptyText, loadingText, errorText, retryLabel, searchPlaceholder, clearLabel, disabled = false, clearable = false, showChevron = true, size = 3, maxHeight = 280, closeOnSelect = true, isItemSelected, searchAction, optionAction, resetKey, debounceMs = DEFAULT_DEBOUNCE_MS, testId, }) {
14
+ export function PaginatedCombobox({ loadPage, getItemId, renderOption, renderSelectedLabel, value, onChange, placeholder, emptyText, loadingText, errorText, retryLabel, searchPlaceholder, clearLabel, disabled = false, clearable = false, showChevron = true, trigger, size = 3, maxHeight = 280, closeOnSelect = true, isItemSelected, searchAction, optionAction, resetKey, debounceMs = DEFAULT_DEBOUNCE_MS, testId, }) {
15
15
  const { copy } = useOrcestrUiLocale();
16
16
  const actualPlaceholder = placeholder ?? copy.common.selectValue;
17
17
  const actualEmptyText = emptyText ?? copy.common.noOptions;
@@ -191,14 +191,14 @@ export function PaginatedCombobox({ loadPage, getItemId, renderOption, renderSel
191
191
  if (!next) {
192
192
  navigation.reset();
193
193
  }
194
- }, trigger: _jsx(Button, { type: 'button', v: 'surface', size: size, disabled: disabled, fullWidth: true, pressAnimation: 'none', className: 'oui-combobox-trigger', "data-testid": testId, "data-state": open ? 'open' : 'closed', onKeyDown: handleKeyDown, rightIcon: _jsxs("span", { className: 'oui-combobox-trigger-actions', children: [canClear ? (_jsx("span", { "aria-label": clearLabel ?? copy.common.clear, className: 'oui-combobox-clear', onPointerDown: (event) => {
194
+ }, trigger: trigger ?? (_jsx(Button, { type: 'button', v: 'surface', size: size, disabled: disabled, fullWidth: true, pressAnimation: 'none', className: 'oui-combobox-trigger', "data-testid": testId, "data-state": open ? 'open' : 'closed', onKeyDown: handleKeyDown, rightIcon: _jsxs("span", { className: 'oui-combobox-trigger-actions', children: [canClear ? (_jsx("span", { "aria-label": clearLabel ?? copy.common.clear, className: 'oui-combobox-clear', onPointerDown: (event) => {
195
195
  event.preventDefault();
196
196
  event.stopPropagation();
197
197
  }, onClick: (event) => {
198
198
  event.preventDefault();
199
199
  event.stopPropagation();
200
200
  clear();
201
- }, children: _jsx(LuX, { size: 14 }) })) : null, showChevron ? _jsx(LuChevronsUpDown, { size: 15 }) : null] }), children: _jsx("span", { className: triggerLabel ? 'oui-combobox-trigger-label' : 'oui-combobox-placeholder', children: triggerLabel ?? actualPlaceholder }) }), className: 'oui-combobox-content', align: 'start', sideOffset: 4, matchTriggerWidth: true, disabled: disabled, children: [_jsxs("div", { className: 'oui-combobox-search-wrap', children: [_jsx(TextField, { autoFocus: true, size: 2, placeholder: actualSearchPlaceholder, value: searchInput, onChange: (event) => setSearchInput(event.target.value), onKeyDown: handleKeyDown }), searchAction ? (_jsx(Tooltip, { content: actualSearchActionLabel, children: _jsx(IconButton, { size: 2, v: 'soft', icon: _jsx(LuPlus, { size: 14 }), className: 'oui-combobox-search-action', "aria-label": actualSearchActionLabel, disabled: searchAction.disabled, onClick: () => {
201
+ }, children: _jsx(LuX, { size: 14 }) })) : null, showChevron ? _jsx(LuChevronsUpDown, { size: 15 }) : null] }), children: _jsx("span", { className: triggerLabel ? 'oui-combobox-trigger-label' : 'oui-combobox-placeholder', children: triggerLabel ?? actualPlaceholder }) })), className: 'oui-combobox-content', align: 'start', sideOffset: 4, matchTriggerWidth: true, disabled: disabled, children: [_jsxs("div", { className: 'oui-combobox-search-wrap', children: [_jsx(TextField, { autoFocus: true, size: 2, placeholder: actualSearchPlaceholder, value: searchInput, onChange: (event) => setSearchInput(event.target.value), onKeyDown: handleKeyDown }), searchAction ? (_jsx(Tooltip, { content: actualSearchActionLabel, children: _jsx(IconButton, { size: 2, v: 'soft', icon: _jsx(LuPlus, { size: 14 }), className: 'oui-combobox-search-action', "aria-label": actualSearchActionLabel, disabled: searchAction.disabled, onClick: () => {
202
202
  setOpen(false);
203
203
  searchAction.onClick(searchInput);
204
204
  } }) })) : null] }), _jsx("div", { ref: scrollRef, className: 'oui-combobox-scroll', style: { maxHeight }, tabIndex: -1, onKeyDown: handleKeyDown, children: isInitialLoading ? (_jsxs("div", { className: 'oui-combobox-state', children: [_jsx(Spinner, {}), _jsx("span", { className: 'oui-visually-hidden', children: actualLoadingText })] })) : error ? (_jsxs("div", { className: 'oui-combobox-state', children: [_jsx("span", { children: actualErrorText }), _jsx(Button, { size: 1, v: 'surface', onClick: () => void fetchPage(1, debouncedSearch), children: actualRetryLabel })] })) : items.length === 0 ? (_jsx("div", { className: 'oui-combobox-empty', children: actualEmptyText })) : (_jsxs("div", { className: 'oui-combobox-options', children: [items.map((item) => {
@@ -1,6 +1,7 @@
1
- import { type ReactNode } from 'react';
1
+ import { type CSSProperties, type HTMLAttributes, type ReactNode, type Ref } from 'react';
2
2
  import { type FloatingAlign, type FloatingSide } from '../../hooks/useFloatingPosition';
3
- export type PopoverProps = {
3
+ import { type SystemProps } from '../../theme/systemProps';
4
+ export type PopoverProps = SystemProps & Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
4
5
  trigger: ReactNode;
5
6
  children: ReactNode;
6
7
  open?: boolean;
@@ -13,7 +14,40 @@ export type PopoverProps = {
13
14
  matchTriggerWidth?: boolean;
14
15
  disabled?: boolean;
15
16
  className?: string;
17
+ contentStyle?: CSSProperties;
18
+ contentRef?: Ref<HTMLDivElement>;
19
+ onOpenAutoFocus?: (event: {
20
+ preventDefault: () => void;
21
+ }) => void;
22
+ onInteractOutside?: (event: Event) => void;
16
23
  testId?: string;
17
24
  };
18
- export declare function Popover({ trigger, children, open, defaultOpen, onOpenChange, side, align, sideOffset, collisionPadding, matchTriggerWidth, disabled, className, testId, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function Popover({ trigger, children, open, defaultOpen, onOpenChange, side, align, sideOffset, collisionPadding, matchTriggerWidth, disabled, className, contentStyle, contentRef: externalContentRef, style: contentStyleProp, onOpenAutoFocus, onInteractOutside, testId, ...props }: PopoverProps): import("react/jsx-runtime").JSX.Element;
26
+ type PopoverRootProps = Pick<PopoverProps, 'open' | 'defaultOpen' | 'onOpenChange'> & {
27
+ children: ReactNode;
28
+ };
29
+ type PopoverTriggerProps = {
30
+ children: ReactNode;
31
+ };
32
+ declare function PopoverRoot({ children, ...props }: PopoverRootProps): import("react/jsx-runtime").JSX.Element | null;
33
+ declare function PopoverTrigger(_props: PopoverTriggerProps): null;
34
+ export declare namespace Popover {
35
+ const Root: typeof PopoverRoot;
36
+ const Trigger: typeof PopoverTrigger;
37
+ const Content: import("react").ForwardRefExoticComponent<SystemProps & Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
38
+ children: ReactNode;
39
+ width?: number | string;
40
+ size?: number | string;
41
+ align?: FloatingAlign;
42
+ side?: FloatingSide;
43
+ sideOffset?: number;
44
+ matchTriggerWidth?: boolean;
45
+ className?: string;
46
+ onOpenAutoFocus?: (event: {
47
+ preventDefault: () => void;
48
+ }) => void;
49
+ onInteractOutside?: (event: Event) => void;
50
+ } & import("react").RefAttributes<HTMLDivElement>>;
51
+ }
52
+ export {};
19
53
  //# sourceMappingURL=Popover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAEA,OAAO,EASH,KAAK,SAAS,EAEjB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAC,KAAK,aAAa,EAAE,KAAK,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAkBtF,MAAM,MAAM,YAAY,GAAG;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACpB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAe,EACf,KAAe,EACf,UAAc,EACd,gB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IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACpB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAe,EACf,KAAe,EACf,UAAc,EACd,gBAAoB,EACpB,iBAAyB,EACzB,QAAgB,EAChB,SAAS,EACT,YAAY,EACZ,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,gBAAgB,EACvB,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,GAAG,KAAK,EACX,EAAE,YAAY,2CA2Hd;AAED,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,CAAC,GAAG;IAClF,QAAQ,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACvB,QAAQ,EAAE,SAAS,CAAC;CACvB,CAAC;AAgBF,iBAAS,WAAW,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAC,EAAE,gBAAgB,kDAuB1D;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,mBAAmB,QAElD;AA2BD,yBAAiB,OAAO,CAAC;IACd,MAAM,IAAI,oBAAc,CAAC;IACzB,MAAM,OAAO,uBAAiB,CAAC;IAC/B,MAAM,OAAO;kBArEV,SAAS;gBACX,MAAM,GAAG,MAAM;eAChB,MAAM,GAAG,MAAM;gBACd,aAAa;eACd,YAAY;qBACN,MAAM;4BACC,OAAO;oBACf,MAAM;0BACA,CAAC,KAAK,EAAE;YAAC,cAAc,EAAE,MAAM,IAAI,CAAA;SAAC,KAAK,IAAI;4BAC3C,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;sDA4DL,CAAC;CACzC"}
@@ -1,16 +1,19 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { cloneElement, isValidElement, useCallback, useEffect, useRef, } from 'react';
3
+ import { cloneElement, Children, forwardRef, isValidElement, useCallback, useContext, useEffect, useRef, } from 'react';
4
4
  import { useDisclosure } from '../../hooks/useDisclosure';
5
5
  import {} from '../../hooks/useFloatingPosition';
6
6
  import { useFloatingLayer } from '../../hooks/useFloatingLayer';
7
7
  import { useOutsidePointerDown } from '../../hooks/useOutsidePointerDown';
8
+ import { splitSystemProps } from '../../theme/systemProps';
9
+ import { OrcestrThemeContext } from '../../theme/useTheme';
8
10
  import { composeRefs } from '../../utils/composeRefs';
9
11
  import { cn } from '../../utils/cn';
10
- import { useOverlayContext, useOverlayLayerIndex } from '../Overlay/OverlayProvider';
12
+ import { overlayLayerZIndex, useOverlayContext, useOverlayLayerIndex, } from '../Overlay/OverlayProvider';
11
13
  import { Portal } from '../Portal/Portal';
12
- export function Popover({ trigger, children, open, defaultOpen, onOpenChange, side = 'bottom', align = 'start', sideOffset = 8, collisionPadding = 8, matchTriggerWidth = false, disabled = false, className, testId, }) {
14
+ export function Popover({ trigger, children, open, defaultOpen, onOpenChange, side = 'bottom', align = 'start', sideOffset = 8, collisionPadding = 8, matchTriggerWidth = false, disabled = false, className, contentStyle, contentRef: externalContentRef, style: contentStyleProp, onOpenAutoFocus, onInteractOutside, testId, ...props }) {
13
15
  const overlay = useOverlayContext();
16
+ const themeContext = useContext(OrcestrThemeContext);
14
17
  const disclosure = useDisclosure({ open, defaultOpen, onOpenChange });
15
18
  const { open: isOpen, close: closeDisclosure, toggle } = disclosure;
16
19
  const previousFocusRef = useRef(null);
@@ -22,12 +25,19 @@ export function Popover({ trigger, children, open, defaultOpen, onOpenChange, si
22
25
  collisionPadding,
23
26
  matchTriggerWidth,
24
27
  });
25
- const close = useCallback(() => closeDisclosure(), [closeDisclosure]);
26
28
  const layerIndex = useOverlayLayerIndex(present);
27
- useOutsidePointerDown([triggerRef, contentRef], isOpen, close);
29
+ const { systemStyle, restProps } = splitSystemProps(props);
30
+ const handleOutsidePointerDown = useCallback((event) => {
31
+ onInteractOutside?.(event);
32
+ if (event.defaultPrevented)
33
+ return;
34
+ closeDisclosure();
35
+ }, [closeDisclosure, onInteractOutside]);
36
+ useOutsidePointerDown([triggerRef, contentRef], isOpen, handleOutsidePointerDown);
28
37
  useEffect(() => {
29
38
  if (!isOpen)
30
39
  return;
40
+ onOpenAutoFocus?.({ preventDefault: () => undefined });
31
41
  previousFocusRef.current =
32
42
  document.activeElement instanceof HTMLElement ? document.activeElement : null;
33
43
  const onKeyDown = (event) => {
@@ -41,7 +51,7 @@ export function Popover({ trigger, children, open, defaultOpen, onOpenChange, si
41
51
  document.removeEventListener('keydown', onKeyDown, true);
42
52
  previousFocusRef.current?.focus?.();
43
53
  };
44
- }, [closeDisclosure, isOpen]);
54
+ }, [closeDisclosure, isOpen, onOpenAutoFocus]);
45
55
  const handleTriggerClick = useCallback((event) => {
46
56
  if (event.defaultPrevented || disabled)
47
57
  return;
@@ -63,11 +73,48 @@ export function Popover({ trigger, children, open, defaultOpen, onOpenChange, si
63
73
  toggle();
64
74
  }
65
75
  }, children: trigger }));
66
- return (_jsxs(_Fragment, { children: [triggerNode, present ? (_jsx(Portal, { children: _jsx("div", { ref: contentRef, className: cn('oui-popover-content', className), "data-state": state, "data-layer": 'dropdown', "data-testid": testId ? `${testId}-content` : undefined, style: {
76
+ return (_jsxs(_Fragment, { children: [triggerNode, present ? (_jsx(Portal, { children: _jsx("div", { ref: composeRefs(contentRef, externalContentRef), className: cn('oui-popover-content', className), "data-state": state, "data-layer": 'dropdown', "data-oui-theme": themeContext?.mode, "data-oui-surface": themeContext?.surface, "data-testid": testId ? `${testId}-content` : undefined, style: {
77
+ ...themeContext?.cssVariables,
67
78
  ...style,
68
- zIndex: overlay.zIndex.dropdown + layerIndex * 10,
69
- }, children: children }) })) : null] }));
79
+ ...systemStyle,
80
+ ...contentStyle,
81
+ ...contentStyleProp,
82
+ zIndex: overlayLayerZIndex(overlay.zIndex, 'dropdown', layerIndex),
83
+ }, ...restProps, children: children }) })) : null] }));
84
+ }
85
+ function PopoverRoot({ children, ...props }) {
86
+ const trigger = findPopoverChild(children, PopoverTrigger);
87
+ const content = findPopoverChild(children, PopoverContent);
88
+ if (!trigger || !content)
89
+ return null;
90
+ const { children: contentChildren, width, size: _size, ref: contentRef, ...contentProps } = content.props;
91
+ return (_jsx(Popover, { ...props, ...contentProps, w: width, contentRef: contentRef, trigger: trigger.props.children, children: contentChildren }));
92
+ }
93
+ function PopoverTrigger(_props) {
94
+ return null;
95
+ }
96
+ const PopoverContent = forwardRef(function PopoverContent(_props, _ref) {
97
+ return null;
98
+ });
99
+ function findPopoverChild(children, type) {
100
+ let found = null;
101
+ Children.forEach(children, (child) => {
102
+ if (!found && isValidElement(child) && child.type === type) {
103
+ found = child;
104
+ }
105
+ });
106
+ return found;
70
107
  }
108
+ Object.assign(Popover, {
109
+ Root: PopoverRoot,
110
+ Trigger: PopoverTrigger,
111
+ Content: PopoverContent,
112
+ });
113
+ (function (Popover) {
114
+ Popover.Root = PopoverRoot;
115
+ Popover.Trigger = PopoverTrigger;
116
+ Popover.Content = PopoverContent;
117
+ })(Popover || (Popover = {}));
71
118
  function clonePopoverTrigger(trigger, { ref, open, disabled, testId, onClick, }) {
72
119
  return cloneElement(trigger, {
73
120
  ref: composeRefs(trigger.props.ref, ref),
@@ -10,6 +10,8 @@ export type ScrollHighlightConfig = {
10
10
  maxOpacity?: number;
11
11
  };
12
12
  export type ScrollAreaProps = ComponentPropsWithoutRef<'div'> & SystemProps & {
13
+ scrollbars?: 'vertical' | 'horizontal' | 'both';
14
+ type?: 'auto' | 'always' | 'scroll' | 'hover';
13
15
  highlights?: boolean;
14
16
  highlightH?: number | string;
15
17
  highlightColor?: string;
@@ -22,6 +24,8 @@ export type ScrollAreaProps = ComponentPropsWithoutRef<'div'> & SystemProps & {
22
24
  testId?: string;
23
25
  };
24
26
  export declare const ScrollArea: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & SystemProps & {
27
+ scrollbars?: "vertical" | "horizontal" | "both";
28
+ type?: "auto" | "always" | "scroll" | "hover";
25
29
  highlights?: boolean;
26
30
  highlightH?: number | string;
27
31
  highlightColor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollArea.d.ts","sourceRoot":"","sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQH,KAAK,wBAAwB,EAChC,MAAM,OAAO,CAAC;AAGf,OAAO,EAAmB,KAAK,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAG3E,MAAM,MAAM,qBAAqB,GAAG;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,wBAAwB,CAAC,KAAK,CAAC,GACzD,WAAW,GAAG;IACV,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,UAAU;iBAZF,OAAO;iBACP,MAAM,GAAG,MAAM;qBACX,MAAM;uBACJ,OAAO;qBACT,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AAEN,eAAO,MAAM,UAAU;iBAdF,UAAU,GAAG,YAAY,GAAG,MAAM;WACxC,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO;iBAChC,OAAO;iBACP,MAAM,GAAG,MAAM;qBACX,MAAM;uBACJ,OAAO;qBACT,MAAM;4BACC,MAAM;0BACR,MAAM;mBACb,qBAAqB;sBAClB,qBAAqB;aAC9B,MAAM;kDAuNtB,CAAC"}
@@ -4,13 +4,14 @@ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRe
4
4
  import { cn } from '../../utils/cn';
5
5
  import { splitSystemProps } from '../../theme/systemProps';
6
6
  import { BottomHighlight, TopHighlight } from '../Highlight/Highlight';
7
- export const ScrollArea = forwardRef(function ScrollArea({ className, style, children, highlights = false, highlightH = 32, highlightColor, highlightVisible = true, highlightStart = 0, highlightFadeDistance = 100, highlightMaxOpacity = 1, highlightTop, highlightBottom, testId, ...props }, ref) {
7
+ export const ScrollArea = forwardRef(function ScrollArea({ className, style, children, highlights = false, highlightH = 32, highlightColor, highlightVisible = true, highlightStart = 0, highlightFadeDistance = 100, highlightMaxOpacity = 1, highlightTop, highlightBottom, scrollbars = 'both', type = 'auto', testId, ...props }, ref) {
8
8
  const { systemStyle, restProps } = splitSystemProps(props);
9
9
  const { onScroll, ...outerProps } = restProps;
10
10
  const showHighlights = highlights && highlightVisible;
11
11
  const scrollRef = useRef(null);
12
12
  const frameRef = useRef(null);
13
13
  const [opacity, setOpacity] = useState({ top: 0, bottom: 0 });
14
+ const [overflow, setOverflow] = useState({ x: false, y: false });
14
15
  const topConfig = useMemo(() => normalizeHighlightConfig({
15
16
  h: highlightH,
16
17
  color: highlightColor,
@@ -46,8 +47,24 @@ export const ScrollArea = forwardRef(function ScrollArea({ className, style, chi
46
47
  useImperativeHandle(ref, () => scrollRef.current, []);
47
48
  const updateOpacity = useCallback(() => {
48
49
  const node = scrollRef.current;
49
- if (!node || !showHighlights) {
50
- setOpacity({ top: 0, bottom: 0 });
50
+ if (!node) {
51
+ setOpacity((current) => current.top === 0 && current.bottom === 0
52
+ ? current
53
+ : { top: 0, bottom: 0 });
54
+ setOverflow((current) => !current.x && !current.y ? current : { x: false, y: false });
55
+ return;
56
+ }
57
+ const nextOverflow = {
58
+ x: node.scrollWidth > node.clientWidth + 1,
59
+ y: node.scrollHeight > node.clientHeight + 1,
60
+ };
61
+ setOverflow((current) => current.x === nextOverflow.x && current.y === nextOverflow.y
62
+ ? current
63
+ : nextOverflow);
64
+ if (!showHighlights) {
65
+ setOpacity((current) => current.top === 0 && current.bottom === 0
66
+ ? current
67
+ : { top: 0, bottom: 0 });
51
68
  return;
52
69
  }
53
70
  const maxScroll = Math.max(0, node.scrollHeight - node.clientHeight);
@@ -79,6 +96,9 @@ export const ScrollArea = forwardRef(function ScrollArea({ className, style, chi
79
96
  const observer = typeof ResizeObserver === 'undefined'
80
97
  ? null
81
98
  : new ResizeObserver(scheduleUpdate);
99
+ const mutationObserver = typeof MutationObserver === 'undefined'
100
+ ? null
101
+ : new MutationObserver(scheduleUpdate);
82
102
  observer?.observe(node);
83
103
  Array.from(node.children).forEach((child) => {
84
104
  if (child instanceof HTMLElement &&
@@ -86,9 +106,15 @@ export const ScrollArea = forwardRef(function ScrollArea({ className, style, chi
86
106
  observer?.observe(child);
87
107
  }
88
108
  });
109
+ mutationObserver?.observe(node, {
110
+ attributes: true,
111
+ childList: true,
112
+ subtree: true,
113
+ });
89
114
  window.addEventListener('resize', scheduleUpdate);
90
115
  return () => {
91
116
  observer?.disconnect();
117
+ mutationObserver?.disconnect();
92
118
  window.removeEventListener('resize', scheduleUpdate);
93
119
  if (frameRef.current !== null) {
94
120
  window.cancelAnimationFrame(frameRef.current);
@@ -96,7 +122,7 @@ export const ScrollArea = forwardRef(function ScrollArea({ className, style, chi
96
122
  }
97
123
  };
98
124
  }, [scheduleUpdate]);
99
- return (_jsxs("div", { className: cn('oui-scroll-area', className), "data-testid": testId, style: { ...systemStyle, ...style }, ...outerProps, children: [_jsx("div", { ref: scrollRef, className: 'oui-scroll-area-viewport', "data-testid": testId ? `${testId}-viewport` : undefined, onScroll: (event) => {
125
+ return (_jsxs("div", { className: cn('oui-scroll-area', className), "data-scrollbars": scrollbars, "data-type": type, "data-overflow-x": overflow.x ? 'true' : undefined, "data-overflow-y": overflow.y ? 'true' : undefined, "data-testid": testId, style: { ...systemStyle, ...style }, ...outerProps, children: [_jsx("div", { ref: scrollRef, className: 'oui-scroll-area-viewport', "data-testid": testId ? `${testId}-viewport` : undefined, onScroll: (event) => {
100
126
  onScroll?.(event);
101
127
  scheduleUpdate();
102
128
  }, children: children }), showHighlights ? (_jsxs("div", { className: 'oui-scroll-area-highlight-overlay', "aria-hidden": 'true', children: [topConfig.visible ? (_jsx(TopHighlight, { h: topConfig.h, color: topConfig.color, style: { opacity: opacity.top } })) : null, bottomConfig.visible ? (_jsx(BottomHighlight, { h: bottomConfig.h, color: bottomConfig.color, style: { opacity: opacity.bottom } })) : null] })) : null] }));
@@ -5,6 +5,8 @@ export type SectionProps = FlexProps & {
5
5
  testId?: string;
6
6
  };
7
7
  export declare const Section: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("../..").SystemProps & {
8
+ as?: import("react").ElementType;
9
+ asChild?: boolean;
8
10
  testId?: string;
9
11
  } & {
10
12
  sectionColor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Section.d.ts","sourceRoot":"","sources":["../../../src/components/Section/Section.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAaF,eAAO,MAAM,OAAO;;;mBAhBD,MAAM;qBACJ,MAAM,GAAG,MAAM;aACvB,MAAM;kDAuCjB,CAAC"}
1
+ {"version":3,"file":"Section.d.ts","sourceRoot":"","sources":["../../../src/components/Section/Section.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAaF,eAAO,MAAM,OAAO;;;;;mBAhBD,MAAM;qBACJ,MAAM,GAAG,MAAM;aACvB,MAAM;kDAuCjB,CAAC"}
@@ -1,13 +1,36 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { UiSize } from '../../theme/systemProps';
1
3
  export type SegmentedControlItem = {
2
4
  value: string;
3
5
  label: string;
4
6
  disabled?: boolean;
5
7
  };
6
- export declare function SegmentedControl({ value, onValueChange, items, className, testId, }: {
8
+ export declare function SegmentedControl({ value, onValueChange, items, size, className, testId, }: {
7
9
  value: string;
8
10
  onValueChange: (value: string) => void;
9
11
  items: ReadonlyArray<SegmentedControlItem>;
12
+ size?: UiSize;
10
13
  className?: string;
11
14
  testId?: string;
12
15
  }): import("react/jsx-runtime").JSX.Element;
16
+ type SegmentedRootProps = {
17
+ value: string;
18
+ onValueChange: (value: string) => void;
19
+ children: ReactNode;
20
+ size?: UiSize;
21
+ className?: string;
22
+ testId?: string;
23
+ };
24
+ type SegmentedItemProps = {
25
+ value: string;
26
+ disabled?: boolean;
27
+ children: ReactNode;
28
+ };
29
+ declare function SegmentedRoot({ value, onValueChange, children, size, className, testId, }: SegmentedRootProps): import("react/jsx-runtime").JSX.Element;
30
+ declare function SegmentedItem(_props: SegmentedItemProps): null;
31
+ export declare namespace SegmentedControl {
32
+ const Root: typeof SegmentedRoot;
33
+ const Item: typeof SegmentedItem;
34
+ }
35
+ export {};
13
36
  //# sourceMappingURL=SegmentedControl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,oBAAoB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC7B,KAAK,EACL,aAAa,EACb,KAAK,EACL,SAAS,EACT,MAAM,GACT,EAAE;IACC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CAkBA"}
1
+ {"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAE/D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAGpD,MAAM,MAAM,oBAAoB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC7B,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EACT,MAAM,GACT,EAAE;IACC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CAkBA;AAED,KAAK,kBAAkB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,iBAAS,aAAa,CAAC,EACnB,KAAK,EACL,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,MAAM,GACT,EAAE,kBAAkB,2CAsBpB;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,kBAAkB,QAEhD;AAOD,yBAAiB,gBAAgB,CAAC;IACvB,MAAM,IAAI,sBAAgB,CAAC;IAC3B,MAAM,IAAI,sBAAgB,CAAC;CACrC"}
@@ -1,6 +1,32 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Children, isValidElement } from 'react';
3
4
  import { cn } from '../../utils/cn';
4
- export function SegmentedControl({ value, onValueChange, items, className, testId, }) {
5
- return (_jsx("div", { className: cn('oui-segmented', className), "data-testid": testId, children: items.map((item) => (_jsx("button", { type: 'button', className: 'oui-segmented-item', "data-active": value === item.value ? 'true' : undefined, "data-testid": testId ? `${testId}-${item.value}` : undefined, disabled: item.disabled, onClick: () => onValueChange(item.value), children: item.label }, item.value))) }));
5
+ export function SegmentedControl({ value, onValueChange, items, size, className, testId, }) {
6
+ return (_jsx("div", { className: cn('oui-segmented', className), "data-size": size, "data-testid": testId, children: items.map((item) => (_jsx("button", { type: 'button', className: 'oui-segmented-item', "data-active": value === item.value ? 'true' : undefined, "data-testid": testId ? `${testId}-${item.value}` : undefined, disabled: item.disabled, onClick: () => onValueChange(item.value), children: item.label }, item.value))) }));
6
7
  }
8
+ function SegmentedRoot({ value, onValueChange, children, size, className, testId, }) {
9
+ const items = [];
10
+ Children.forEach(children, (child) => {
11
+ if (!isValidElement(child) || child.type !== SegmentedItem)
12
+ return;
13
+ const props = child.props;
14
+ items.push({
15
+ value: props.value,
16
+ label: String(props.children ?? ''),
17
+ disabled: props.disabled,
18
+ });
19
+ });
20
+ return (_jsx(SegmentedControl, { value: value, onValueChange: onValueChange, items: items, size: size, className: className, testId: testId }));
21
+ }
22
+ function SegmentedItem(_props) {
23
+ return null;
24
+ }
25
+ Object.assign(SegmentedControl, {
26
+ Root: SegmentedRoot,
27
+ Item: SegmentedItem,
28
+ });
29
+ (function (SegmentedControl) {
30
+ SegmentedControl.Root = SegmentedRoot;
31
+ SegmentedControl.Item = SegmentedItem;
32
+ })(SegmentedControl || (SegmentedControl = {}));