@orcestr/ui 0.0.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.
- package/README.md +151 -0
- package/README.ru.md +151 -0
- package/assets/orcestr-banner.webp +0 -0
- package/dist/components/Action/ActionConfirmModal.d.ts +8 -0
- package/dist/components/Action/ActionConfirmModal.d.ts.map +1 -0
- package/dist/components/Action/ActionConfirmModal.js +13 -0
- package/dist/components/Action/ActionTypes.d.ts +47 -0
- package/dist/components/Action/ActionTypes.d.ts.map +1 -0
- package/dist/components/Action/ActionTypes.js +49 -0
- package/dist/components/ActionMenu/ActionMenu.d.ts +3 -0
- package/dist/components/ActionMenu/ActionMenu.d.ts.map +1 -0
- package/dist/components/ActionMenu/ActionMenu.js +1 -0
- package/dist/components/Alert/Alert.d.ts +11 -0
- package/dist/components/Alert/Alert.d.ts.map +1 -0
- package/dist/components/Alert/Alert.js +7 -0
- package/dist/components/AppShell/AppShell.d.ts +102 -0
- package/dist/components/AppShell/AppShell.d.ts.map +1 -0
- package/dist/components/AppShell/AppShell.js +96 -0
- package/dist/components/Badge/Badge.d.ts +15 -0
- package/dist/components/Badge/Badge.d.ts.map +1 -0
- package/dist/components/Badge/Badge.js +8 -0
- package/dist/components/Box/Box.d.ts +11 -0
- package/dist/components/Box/Box.d.ts.map +1 -0
- package/dist/components/Box/Box.js +8 -0
- package/dist/components/Button/Button.d.ts +27 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +13 -0
- package/dist/components/Checkbox/Checkbox.d.ts +10 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.js +15 -0
- package/dist/components/Collapse/Collapse.d.ts +11 -0
- package/dist/components/Collapse/Collapse.d.ts.map +1 -0
- package/dist/components/Collapse/Collapse.js +33 -0
- package/dist/components/Combobox/Combobox.d.ts +17 -0
- package/dist/components/Combobox/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox/Combobox.js +32 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +21 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette/CommandPalette.js +168 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +25 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.js +25 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts.map +1 -0
- package/dist/components/ContextMenu/ContextMenu.js +68 -0
- package/dist/components/DataTable/DataTable.d.ts +88 -0
- package/dist/components/DataTable/DataTable.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.js +415 -0
- package/dist/components/DataTable/DataTableStateAdapters.d.ts +41 -0
- package/dist/components/DataTable/DataTableStateAdapters.d.ts.map +1 -0
- package/dist/components/DataTable/DataTableStateAdapters.js +192 -0
- package/dist/components/DatePicker/DatePicker.d.ts +21 -0
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -0
- package/dist/components/DatePicker/DatePicker.js +39 -0
- package/dist/components/DatePicker/DatePickerState.d.ts +30 -0
- package/dist/components/DatePicker/DatePickerState.d.ts.map +1 -0
- package/dist/components/DatePicker/DatePickerState.js +106 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +19 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts.map +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.js +6 -0
- package/dist/components/DateRangePresetPicker/DateRangePresetPicker.d.ts +10 -0
- package/dist/components/DateRangePresetPicker/DateRangePresetPicker.d.ts.map +1 -0
- package/dist/components/DateRangePresetPicker/DateRangePresetPicker.js +26 -0
- package/dist/components/DateRangePresetPicker/DateRangePresetPickerState.d.ts +4 -0
- package/dist/components/DateRangePresetPicker/DateRangePresetPickerState.d.ts.map +1 -0
- package/dist/components/DateRangePresetPicker/DateRangePresetPickerState.js +20 -0
- package/dist/components/Dialog/Dialog.d.ts +2 -0
- package/dist/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.js +1 -0
- package/dist/components/Drawer/Drawer.d.ts +30 -0
- package/dist/components/Drawer/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer/Drawer.js +83 -0
- package/dist/components/EntityPicker/EntityPicker.d.ts +41 -0
- package/dist/components/EntityPicker/EntityPicker.d.ts.map +1 -0
- package/dist/components/EntityPicker/EntityPicker.js +17 -0
- package/dist/components/Field/Field.d.ts +12 -0
- package/dist/components/Field/Field.d.ts.map +1 -0
- package/dist/components/Field/Field.js +8 -0
- package/dist/components/Flex/Flex.d.ts +9 -0
- package/dist/components/Flex/Flex.d.ts.map +1 -0
- package/dist/components/Flex/Flex.js +8 -0
- package/dist/components/Grid/Grid.d.ts +11 -0
- package/dist/components/Grid/Grid.d.ts.map +1 -0
- package/dist/components/Grid/Grid.js +12 -0
- package/dist/components/Highlight/Highlight.d.ts +27 -0
- package/dist/components/Highlight/Highlight.d.ts.map +1 -0
- package/dist/components/Highlight/Highlight.js +26 -0
- package/dist/components/IconButton/IconButton.d.ts +25 -0
- package/dist/components/IconButton/IconButton.d.ts.map +1 -0
- package/dist/components/IconButton/IconButton.js +13 -0
- package/dist/components/IconText/IconText.d.ts +12 -0
- package/dist/components/IconText/IconText.d.ts.map +1 -0
- package/dist/components/IconText/IconText.js +7 -0
- package/dist/components/Listbox/Listbox.d.ts +13 -0
- package/dist/components/Listbox/Listbox.d.ts.map +1 -0
- package/dist/components/Listbox/Listbox.js +74 -0
- package/dist/components/Menu/Menu.d.ts +14 -0
- package/dist/components/Menu/Menu.d.ts.map +1 -0
- package/dist/components/Menu/Menu.js +168 -0
- package/dist/components/Modal/Modal.d.ts +29 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -0
- package/dist/components/Modal/Modal.js +155 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +21 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.js +139 -0
- package/dist/components/NumberField/NumberField.d.ts +4 -0
- package/dist/components/NumberField/NumberField.d.ts.map +1 -0
- package/dist/components/NumberField/NumberField.js +6 -0
- package/dist/components/Overlay/OverlayProvider.d.ts +19 -0
- package/dist/components/Overlay/OverlayProvider.d.ts.map +1 -0
- package/dist/components/Overlay/OverlayProvider.js +73 -0
- package/dist/components/PaginatedCombobox/PaginatedCombobox.d.ts +48 -0
- package/dist/components/PaginatedCombobox/PaginatedCombobox.d.ts.map +1 -0
- package/dist/components/PaginatedCombobox/PaginatedCombobox.js +223 -0
- package/dist/components/PaginatedCombobox/PaginatedComboboxReactQueryAdapter.d.ts +13 -0
- package/dist/components/PaginatedCombobox/PaginatedComboboxReactQueryAdapter.d.ts.map +1 -0
- package/dist/components/PaginatedCombobox/PaginatedComboboxReactQueryAdapter.js +10 -0
- package/dist/components/Pagination/Pagination.d.ts +7 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.js +9 -0
- package/dist/components/Popover/Popover.d.ts +19 -0
- package/dist/components/Popover/Popover.d.ts.map +1 -0
- package/dist/components/Popover/Popover.js +83 -0
- package/dist/components/Portal/Portal.d.ts +6 -0
- package/dist/components/Portal/Portal.d.ts.map +1 -0
- package/dist/components/Portal/Portal.js +23 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +14 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.js +6 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +36 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts.map +1 -0
- package/dist/components/ScrollArea/ScrollArea.js +124 -0
- package/dist/components/Section/Section.d.ts +14 -0
- package/dist/components/Section/Section.d.ts.map +1 -0
- package/dist/components/Section/Section.js +20 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +13 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +6 -0
- package/dist/components/Select/Select.d.ts +27 -0
- package/dist/components/Select/Select.d.ts.map +1 -0
- package/dist/components/Select/Select.js +142 -0
- package/dist/components/Separator/Separator.d.ts +6 -0
- package/dist/components/Separator/Separator.d.ts.map +1 -0
- package/dist/components/Separator/Separator.js +5 -0
- package/dist/components/Skeleton/Skeleton.d.ts +9 -0
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton/Skeleton.js +8 -0
- package/dist/components/Spinner/Spinner.d.ts +7 -0
- package/dist/components/Spinner/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner/Spinner.js +5 -0
- package/dist/components/Stack/Stack.d.ts +9 -0
- package/dist/components/Stack/Stack.d.ts.map +1 -0
- package/dist/components/Stack/Stack.js +7 -0
- package/dist/components/State/State.d.ts +23 -0
- package/dist/components/State/State.d.ts.map +1 -0
- package/dist/components/State/State.js +30 -0
- package/dist/components/State/stateIcon.d.ts +3 -0
- package/dist/components/State/stateIcon.d.ts.map +1 -0
- package/dist/components/State/stateIcon.js +11 -0
- package/dist/components/StepperInput/StepperInput.d.ts +13 -0
- package/dist/components/StepperInput/StepperInput.d.ts.map +1 -0
- package/dist/components/StepperInput/StepperInput.js +22 -0
- package/dist/components/Switch/Switch.d.ts +10 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -0
- package/dist/components/Switch/Switch.js +14 -0
- package/dist/components/Tabs/Tabs.d.ts +18 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.js +104 -0
- package/dist/components/Text/Text.d.ts +13 -0
- package/dist/components/Text/Text.d.ts.map +1 -0
- package/dist/components/Text/Text.js +8 -0
- package/dist/components/TextArea/TextArea.d.ts +15 -0
- package/dist/components/TextArea/TextArea.d.ts.map +1 -0
- package/dist/components/TextArea/TextArea.js +17 -0
- package/dist/components/TextField/TextField.d.ts +25 -0
- package/dist/components/TextField/TextField.d.ts.map +1 -0
- package/dist/components/TextField/TextField.js +31 -0
- package/dist/components/Toast/Toast.d.ts +43 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/Toast.js +205 -0
- package/dist/components/Tooltip/Tooltip.d.ts +10 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.js +24 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +8 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts.map +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +6 -0
- package/dist/components/Workflow/Workflow.d.ts +82 -0
- package/dist/components/Workflow/Workflow.d.ts.map +1 -0
- package/dist/components/Workflow/Workflow.js +73 -0
- package/dist/example/CodePreview.d.ts +25 -0
- package/dist/example/CodePreview.d.ts.map +1 -0
- package/dist/example/CodePreview.js +93 -0
- package/dist/example/ExampleActionsSection.d.ts +10 -0
- package/dist/example/ExampleActionsSection.d.ts.map +1 -0
- package/dist/example/ExampleActionsSection.js +10 -0
- package/dist/example/ExampleBasicsSections.d.ts +8 -0
- package/dist/example/ExampleBasicsSections.d.ts.map +1 -0
- package/dist/example/ExampleBasicsSections.js +43 -0
- package/dist/example/ExampleDataSection.d.ts +7 -0
- package/dist/example/ExampleDataSection.d.ts.map +1 -0
- package/dist/example/ExampleDataSection.js +124 -0
- package/dist/example/ExampleFieldsSection.d.ts +17 -0
- package/dist/example/ExampleFieldsSection.d.ts.map +1 -0
- package/dist/example/ExampleFieldsSection.js +10 -0
- package/dist/example/ExampleFoundationsSection.d.ts +5 -0
- package/dist/example/ExampleFoundationsSection.d.ts.map +1 -0
- package/dist/example/ExampleFoundationsSection.js +25 -0
- package/dist/example/ExampleOverlays.d.ts +30 -0
- package/dist/example/ExampleOverlays.d.ts.map +1 -0
- package/dist/example/ExampleOverlays.js +12 -0
- package/dist/example/ExampleOverlaysSection.d.ts +14 -0
- package/dist/example/ExampleOverlaysSection.d.ts.map +1 -0
- package/dist/example/ExampleOverlaysSection.js +126 -0
- package/dist/example/ExampleSelectionSection.d.ts +30 -0
- package/dist/example/ExampleSelectionSection.d.ts.map +1 -0
- package/dist/example/ExampleSelectionSection.js +66 -0
- package/dist/example/ExampleStateSection.d.ts +8 -0
- package/dist/example/ExampleStateSection.d.ts.map +1 -0
- package/dist/example/ExampleStateSection.js +76 -0
- package/dist/example/ExampleThemePlayground.d.ts +417 -0
- package/dist/example/ExampleThemePlayground.d.ts.map +1 -0
- package/dist/example/ExampleThemePlayground.js +596 -0
- package/dist/example/UiExamplePage.d.ts +2 -0
- package/dist/example/UiExamplePage.d.ts.map +1 -0
- package/dist/example/UiExamplePage.js +315 -0
- package/dist/example/UiExampleSection.d.ts +8 -0
- package/dist/example/UiExampleSection.d.ts.map +1 -0
- package/dist/example/UiExampleSection.js +5 -0
- package/dist/example/codeSamples.d.ts +30 -0
- package/dist/example/codeSamples.d.ts.map +1 -0
- package/dist/example/codeSamples.js +976 -0
- package/dist/example/exampleData.d.ts +33 -0
- package/dist/example/exampleData.d.ts.map +1 -0
- package/dist/example/exampleData.js +217 -0
- package/dist/example/styles.css +1106 -0
- package/dist/hooks/useControllableState.d.ts +6 -0
- package/dist/hooks/useControllableState.d.ts.map +1 -0
- package/dist/hooks/useControllableState.js +16 -0
- package/dist/hooks/useDisclosure.d.ts +12 -0
- package/dist/hooks/useDisclosure.d.ts.map +1 -0
- package/dist/hooks/useDisclosure.js +14 -0
- package/dist/hooks/useEscapeKey.d.ts +2 -0
- package/dist/hooks/useEscapeKey.d.ts.map +1 -0
- package/dist/hooks/useEscapeKey.js +15 -0
- package/dist/hooks/useFloatingLayer.d.ts +19 -0
- package/dist/hooks/useFloatingLayer.d.ts.map +1 -0
- package/dist/hooks/useFloatingLayer.js +26 -0
- package/dist/hooks/useFloatingPosition.d.ts +17 -0
- package/dist/hooks/useFloatingPosition.d.ts.map +1 -0
- package/dist/hooks/useFloatingPosition.js +132 -0
- package/dist/hooks/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -0
- package/dist/hooks/useFocusTrap.js +54 -0
- package/dist/hooks/useListNavigation.d.ts +17 -0
- package/dist/hooks/useListNavigation.d.ts.map +1 -0
- package/dist/hooks/useListNavigation.js +44 -0
- package/dist/hooks/useOutsidePointerDown.d.ts +3 -0
- package/dist/hooks/useOutsidePointerDown.d.ts.map +1 -0
- package/dist/hooks/useOutsidePointerDown.js +20 -0
- package/dist/hooks/usePresence.d.ts +5 -0
- package/dist/hooks/usePresence.d.ts.map +1 -0
- package/dist/hooks/usePresence.js +35 -0
- package/dist/hooks/useTypeahead.d.ts +2 -0
- package/dist/hooks/useTypeahead.d.ts.map +1 -0
- package/dist/hooks/useTypeahead.js +23 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/locale/LocaleProvider.d.ts +89 -0
- package/dist/locale/LocaleProvider.d.ts.map +1 -0
- package/dist/locale/LocaleProvider.js +174 -0
- package/dist/provider/OrcestrUiProvider.d.ts +28 -0
- package/dist/provider/OrcestrUiProvider.d.ts.map +1 -0
- package/dist/provider/OrcestrUiProvider.js +9 -0
- package/dist/react-query.d.ts +2 -0
- package/dist/react-query.d.ts.map +1 -0
- package/dist/react-query.js +1 -0
- package/dist/styles/orcestr-ui.css +4676 -0
- package/dist/theme/ThemeProvider.d.ts +3 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +280 -0
- package/dist/theme/defaultTheme.d.ts +12 -0
- package/dist/theme/defaultTheme.d.ts.map +1 -0
- package/dist/theme/defaultTheme.js +516 -0
- package/dist/theme/systemProps.d.ts +53 -0
- package/dist/theme/systemProps.d.ts.map +1 -0
- package/dist/theme/systemProps.js +240 -0
- package/dist/theme/themeTypes.d.ts +197 -0
- package/dist/theme/themeTypes.d.ts.map +1 -0
- package/dist/theme/themeTypes.js +1 -0
- package/dist/theme/useTheme.d.ts +4 -0
- package/dist/theme/useTheme.d.ts.map +1 -0
- package/dist/theme/useTheme.js +10 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +3 -0
- package/dist/utils/composeRefs.d.ts +3 -0
- package/dist/utils/composeRefs.d.ts.map +1 -0
- package/dist/utils/composeRefs.js +14 -0
- package/dist/utils/mergeProps.d.ts +4 -0
- package/dist/utils/mergeProps.d.ts.map +1 -0
- package/dist/utils/mergeProps.js +26 -0
- package/dist/utils/ownerDocument.d.ts +2 -0
- package/dist/utils/ownerDocument.d.ts.map +1 -0
- package/dist/utils/ownerDocument.js +3 -0
- package/dist/utils/polymorphic.d.ts +6 -0
- package/dist/utils/polymorphic.d.ts.map +1 -0
- package/dist/utils/polymorphic.js +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,155 @@
|
|
|
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';
|
|
5
|
+
import { useFocusTrap } from '../../hooks/useFocusTrap';
|
|
6
|
+
import { usePresence } from '../../hooks/usePresence';
|
|
7
|
+
import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
|
|
8
|
+
import { OrcestrThemeContext } from '../../theme/useTheme';
|
|
9
|
+
import { cn } from '../../utils/cn';
|
|
10
|
+
import { IconButton } from '../IconButton/IconButton';
|
|
11
|
+
import { lockOverlayScroll, useOverlayContext, useOverlayLayerIndex, } from '../Overlay/OverlayProvider';
|
|
12
|
+
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();
|
|
15
|
+
const themeContext = useContext(OrcestrThemeContext);
|
|
16
|
+
const overlayContext = useOverlayContext();
|
|
17
|
+
const layerRef = useRef(null);
|
|
18
|
+
const contentRef = useRef(null);
|
|
19
|
+
const titleId = useId();
|
|
20
|
+
const descriptionId = useId();
|
|
21
|
+
const actualAnimationDuration = animationDuration ?? themeContext?.theme.motion.modalDuration ?? '380ms';
|
|
22
|
+
const actualAnimation = animation ?? themeContext?.theme.motion.modalAnimation ?? 'zoom-blur';
|
|
23
|
+
const actualMaxWidth = maxWidth ?? themeContext?.theme.components.modalMaxWidth ?? 680;
|
|
24
|
+
const actualOverlayColor = overlayColor ?? themeContext?.theme.motion.modalOverlayColor ?? 'transparent';
|
|
25
|
+
const actualOverlayOpacity = overlayOpacity ?? themeContext?.theme.motion.modalOverlayOpacity ?? 0;
|
|
26
|
+
const actualOverlayBlur = overlayBlur ?? themeContext?.theme.motion.modalOverlayBlur ?? 10;
|
|
27
|
+
const actualAnimationMs = durationMs(actualAnimationDuration, 380);
|
|
28
|
+
const actualAnimationEase = themeContext?.theme.motion.ease ?? 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
29
|
+
const { present, state } = usePresence(open, actualAnimationMs);
|
|
30
|
+
const layerIndex = useOverlayLayerIndex(present);
|
|
31
|
+
const zIndex = overlayContext.zIndex.modal + layerIndex * 20;
|
|
32
|
+
const overlayBlurValue = cssLength(actualOverlayBlur) ?? '10px';
|
|
33
|
+
const overlayBackdropFilter = `blur(${overlayBlurValue})`;
|
|
34
|
+
const overlayBackground = modalOverlayBackground(actualOverlayColor, actualOverlayOpacity);
|
|
35
|
+
useFocusTrap(contentRef, open, () => onOpenChange(false));
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!open)
|
|
38
|
+
return;
|
|
39
|
+
return lockOverlayScroll();
|
|
40
|
+
}, [open]);
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
const layer = layerRef.current;
|
|
43
|
+
if (!present || !layer || !layer.animate)
|
|
44
|
+
return;
|
|
45
|
+
if (state !== 'opening' && state !== 'closing')
|
|
46
|
+
return;
|
|
47
|
+
const closedFrame = {
|
|
48
|
+
backgroundColor: 'rgb(0 0 0 / 0)',
|
|
49
|
+
backdropFilter: 'blur(0px)',
|
|
50
|
+
WebkitBackdropFilter: 'blur(0px)',
|
|
51
|
+
};
|
|
52
|
+
const openFrame = {
|
|
53
|
+
backgroundColor: overlayBackground,
|
|
54
|
+
backdropFilter: overlayBackdropFilter,
|
|
55
|
+
WebkitBackdropFilter: overlayBackdropFilter,
|
|
56
|
+
};
|
|
57
|
+
const animation = layer.animate(state === 'opening'
|
|
58
|
+
? [closedFrame, openFrame]
|
|
59
|
+
: [openFrame, closedFrame], {
|
|
60
|
+
duration: actualAnimationMs,
|
|
61
|
+
easing: actualAnimationEase,
|
|
62
|
+
fill: 'forwards',
|
|
63
|
+
});
|
|
64
|
+
return () => {
|
|
65
|
+
animation.cancel();
|
|
66
|
+
};
|
|
67
|
+
}, [
|
|
68
|
+
actualAnimationEase,
|
|
69
|
+
actualAnimationMs,
|
|
70
|
+
overlayBackdropFilter,
|
|
71
|
+
overlayBackground,
|
|
72
|
+
present,
|
|
73
|
+
state,
|
|
74
|
+
]);
|
|
75
|
+
if (!present)
|
|
76
|
+
return null;
|
|
77
|
+
return (_jsx(Portal, { children: _jsx("div", { ref: layerRef, className: cn('oui-modal-layer', overlayClassName, className), style: {
|
|
78
|
+
zIndex,
|
|
79
|
+
'--oui-modal-overlay-background': overlayBackground,
|
|
80
|
+
'--oui-modal-overlay-blur': overlayBlurValue,
|
|
81
|
+
'--oui-modal-animation-duration': cssDuration(actualAnimationDuration),
|
|
82
|
+
'--oui-modal-animation-ease': actualAnimationEase,
|
|
83
|
+
backgroundColor: overlayBackground,
|
|
84
|
+
backdropFilter: overlayBackdropFilter,
|
|
85
|
+
WebkitBackdropFilter: overlayBackdropFilter,
|
|
86
|
+
...overlayStyle,
|
|
87
|
+
}, "data-state": state, "data-testid": testId, onPointerDown: (event) => {
|
|
88
|
+
if (event.target === event.currentTarget) {
|
|
89
|
+
if (closeOnOverlayClick)
|
|
90
|
+
onOpenChange(false);
|
|
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: {
|
|
93
|
+
width: typeof actualMaxWidth === 'number'
|
|
94
|
+
? `min(calc(100vw - 24px), ${actualMaxWidth}px)`
|
|
95
|
+
: `min(calc(100vw - 24px), ${actualMaxWidth})`,
|
|
96
|
+
minHeight: typeof minHeight === 'number'
|
|
97
|
+
? `${minHeight}px`
|
|
98
|
+
: minHeight,
|
|
99
|
+
'--oui-modal-border-color': borderColor,
|
|
100
|
+
'--oui-modal-radius': cssLength(radius),
|
|
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] }) }) }));
|
|
103
|
+
}
|
|
104
|
+
function cssLength(value) {
|
|
105
|
+
if (value === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
return typeof value === 'number' ? `${value}px` : value;
|
|
108
|
+
}
|
|
109
|
+
function cssDuration(value) {
|
|
110
|
+
return typeof value === 'number' ? `${value}ms` : value;
|
|
111
|
+
}
|
|
112
|
+
function durationMs(value, fallbackMs) {
|
|
113
|
+
if (value === undefined)
|
|
114
|
+
return fallbackMs;
|
|
115
|
+
if (typeof value === 'number')
|
|
116
|
+
return Math.max(0, value);
|
|
117
|
+
const normalized = value.trim().toLowerCase();
|
|
118
|
+
const numeric = Number.parseFloat(normalized);
|
|
119
|
+
if (!Number.isFinite(numeric))
|
|
120
|
+
return fallbackMs;
|
|
121
|
+
if (normalized.endsWith('ms'))
|
|
122
|
+
return Math.max(0, numeric);
|
|
123
|
+
if (normalized.endsWith('s'))
|
|
124
|
+
return Math.max(0, numeric * 1000);
|
|
125
|
+
return Math.max(0, numeric);
|
|
126
|
+
}
|
|
127
|
+
function modalOverlayBackground(color, opacity) {
|
|
128
|
+
const normalizedOpacity = Math.max(0, Math.min(1, opacity));
|
|
129
|
+
if (normalizedOpacity === 0 || color.trim().toLowerCase() === 'transparent') {
|
|
130
|
+
return 'rgb(0 0 0 / 0.001)';
|
|
131
|
+
}
|
|
132
|
+
const rgb = hexToRgb(color);
|
|
133
|
+
if (rgb) {
|
|
134
|
+
return `rgb(${rgb.r} ${rgb.g} ${rgb.b} / ${normalizedOpacity})`;
|
|
135
|
+
}
|
|
136
|
+
return `color-mix(in srgb, ${color} ${Math.round(normalizedOpacity * 100)}%, transparent)`;
|
|
137
|
+
}
|
|
138
|
+
function hexToRgb(value) {
|
|
139
|
+
const color = value.trim();
|
|
140
|
+
if (/^#[0-9a-f]{3}$/i.test(color)) {
|
|
141
|
+
return {
|
|
142
|
+
r: Number.parseInt(color[1] + color[1], 16),
|
|
143
|
+
g: Number.parseInt(color[2] + color[2], 16),
|
|
144
|
+
b: Number.parseInt(color[3] + color[3], 16),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (/^#[0-9a-f]{6}$/i.test(color)) {
|
|
148
|
+
return {
|
|
149
|
+
r: Number.parseInt(color.slice(1, 3), 16),
|
|
150
|
+
g: Number.parseInt(color.slice(3, 5), 16),
|
|
151
|
+
b: Number.parseInt(color.slice(5, 7), 16),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { UiSize } from '../../theme/systemProps';
|
|
3
|
+
import type { SelectItem } from '../Select/Select';
|
|
4
|
+
export declare function MultiSelect<V extends string = string>({ items, value, onValueChange, placeholder, clearable, disabled, showChevron, emptyText, clearLabel, selectedFallbackLabel, size, maxHeight, className, renderValue, testId, }: {
|
|
5
|
+
items: ReadonlyArray<SelectItem<V>>;
|
|
6
|
+
value: ReadonlyArray<V>;
|
|
7
|
+
onValueChange: (value: V[]) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
clearable?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
showChevron?: boolean;
|
|
12
|
+
emptyText?: ReactNode;
|
|
13
|
+
clearLabel?: string;
|
|
14
|
+
selectedFallbackLabel?: ReactNode | ((values: ReadonlyArray<V>) => ReactNode);
|
|
15
|
+
size?: UiSize;
|
|
16
|
+
maxHeight?: number;
|
|
17
|
+
className?: string;
|
|
18
|
+
renderValue?: (items: ReadonlyArray<SelectItem<V>>) => ReactNode;
|
|
19
|
+
testId?: string;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=MultiSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../src/components/MultiSelect/MultiSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAMf,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAGpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,EACnD,KAAK,EACL,KAAK,EACL,aAAa,EACb,WAAW,EACX,SAAgB,EAChB,QAAgB,EAChB,WAAkB,EAClB,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,IAAQ,EACR,SAAe,EACf,SAAS,EACT,WAAW,EACX,MAAM,GACT,EAAE;IACC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACxB,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CA2NA"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
4
|
+
import { LuCheck, LuChevronsUpDown, LuX } from 'react-icons/lu';
|
|
5
|
+
import { useListNavigation } from '../../hooks/useListNavigation';
|
|
6
|
+
import { useTypeahead } from '../../hooks/useTypeahead';
|
|
7
|
+
import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
|
|
8
|
+
import { Button } from '../Button/Button';
|
|
9
|
+
import { Popover } from '../Popover/Popover';
|
|
10
|
+
export function MultiSelect({ items, value, onValueChange, placeholder, clearable = true, disabled = false, showChevron = true, emptyText, clearLabel, selectedFallbackLabel, size = 3, maxHeight = 280, className, renderValue, testId, }) {
|
|
11
|
+
const { copy } = useOrcestrUiLocale();
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
const optionsRef = useRef(null);
|
|
14
|
+
const selectedItems = useMemo(() => items.filter((item) => value.includes(item.value)), [items, value]);
|
|
15
|
+
const selectedSet = useMemo(() => new Set(value), [value]);
|
|
16
|
+
const navigationItems = useMemo(() => items.map((item) => ({
|
|
17
|
+
value: item.value,
|
|
18
|
+
disabled: item.disabled,
|
|
19
|
+
searchText: selectItemText(item),
|
|
20
|
+
})), [items]);
|
|
21
|
+
const navigation = useListNavigation(navigationItems, {
|
|
22
|
+
value: value[0] ?? null,
|
|
23
|
+
});
|
|
24
|
+
const highlighted = navigation.highlightedValue;
|
|
25
|
+
const canClear = clearable && selectedItems.length > 0 && !disabled;
|
|
26
|
+
const triggerLabel = selectedItems.length > 0
|
|
27
|
+
? renderValue?.(selectedItems) ?? defaultMultiSelectLabel(selectedItems)
|
|
28
|
+
: value.length > 0
|
|
29
|
+
? typeof selectedFallbackLabel === 'function'
|
|
30
|
+
? selectedFallbackLabel(value)
|
|
31
|
+
: selectedFallbackLabel
|
|
32
|
+
: null;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!open || highlighted === null)
|
|
35
|
+
return;
|
|
36
|
+
const node = optionsRef.current?.querySelector(`[data-oui-multi-select-value="${cssAttr(highlighted)}"]`);
|
|
37
|
+
node?.scrollIntoView({ block: 'nearest' });
|
|
38
|
+
}, [highlighted, open]);
|
|
39
|
+
const toggle = useCallback((nextValue) => {
|
|
40
|
+
if (selectedSet.has(nextValue)) {
|
|
41
|
+
onValueChange(value.filter((itemValue) => itemValue !== nextValue));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
onValueChange([...value, nextValue]);
|
|
45
|
+
}, [onValueChange, selectedSet, value]);
|
|
46
|
+
const close = useCallback(() => {
|
|
47
|
+
setOpen(false);
|
|
48
|
+
navigation.reset();
|
|
49
|
+
}, [navigation]);
|
|
50
|
+
const handleTypeahead = useTypeahead((query) => {
|
|
51
|
+
const match = navigation.enabledItems.find((item) => item.searchText?.toLowerCase().startsWith(query));
|
|
52
|
+
if (match)
|
|
53
|
+
navigation.setHighlightedValue(match.value);
|
|
54
|
+
});
|
|
55
|
+
const handleKeyDown = useCallback((event) => {
|
|
56
|
+
if (!open && ['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(event.key)) {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
setOpen(true);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!open)
|
|
62
|
+
return;
|
|
63
|
+
switch (event.key) {
|
|
64
|
+
case 'ArrowDown':
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
navigation.move(1);
|
|
67
|
+
break;
|
|
68
|
+
case 'ArrowUp':
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
navigation.move(-1);
|
|
71
|
+
break;
|
|
72
|
+
case 'Home':
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
navigation.first();
|
|
75
|
+
break;
|
|
76
|
+
case 'End':
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
navigation.last();
|
|
79
|
+
break;
|
|
80
|
+
case 'Enter':
|
|
81
|
+
case ' ':
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
if (highlighted !== null)
|
|
84
|
+
toggle(highlighted);
|
|
85
|
+
break;
|
|
86
|
+
case 'Escape':
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
close();
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
if (event.key.length === 1 && !event.metaKey && !event.ctrlKey) {
|
|
92
|
+
handleTypeahead(event.key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, [close, handleTypeahead, highlighted, navigation, open, toggle]);
|
|
96
|
+
return (_jsx(Popover, { open: open, onOpenChange: (next) => {
|
|
97
|
+
setOpen(next);
|
|
98
|
+
if (!next)
|
|
99
|
+
navigation.reset();
|
|
100
|
+
}, trigger: _jsx(Button, { type: 'button', v: 'surface', size: size, disabled: disabled, fullWidth: true, pressAnimation: 'none', className: 'oui-combobox-trigger oui-multi-select-trigger', "data-state": open ? 'open' : 'closed', testId: testId, "aria-haspopup": 'listbox', "aria-expanded": open, onKeyDown: handleKeyDown, rightIcon: _jsxs("span", { className: 'oui-combobox-trigger-actions', children: [canClear ? (_jsx("span", { "aria-label": clearLabel ?? copy.common.clearSelectedValues, className: 'oui-combobox-clear', onPointerDown: (event) => {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
event.stopPropagation();
|
|
103
|
+
}, onClick: (event) => {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
event.stopPropagation();
|
|
106
|
+
onValueChange([]);
|
|
107
|
+
navigation.reset();
|
|
108
|
+
}, children: _jsx(LuX, { size: 14 }) })) : null, showChevron ? _jsx(LuChevronsUpDown, { size: 15 }) : null] }), children: _jsx("span", { className: triggerLabel
|
|
109
|
+
? 'oui-combobox-trigger-label'
|
|
110
|
+
: 'oui-combobox-placeholder', children: triggerLabel ?? placeholder ?? copy.common.selectValue }) }), className: className ? `oui-select-content ${className}` : 'oui-select-content', testId: testId ? `${testId}-popover` : undefined, align: 'start', sideOffset: 4, matchTriggerWidth: true, disabled: disabled, children: _jsx("div", { ref: optionsRef, role: 'listbox', "aria-multiselectable": 'true', className: 'oui-combobox-scroll oui-combobox-options', "data-testid": testId ? `${testId}-listbox` : undefined, style: { maxHeight }, tabIndex: -1, onKeyDown: handleKeyDown, children: items.length === 0 ? (_jsx("div", { className: 'oui-combobox-empty', children: emptyText ?? copy.common.noOptions })) : (items.map((item) => {
|
|
111
|
+
const selected = selectedSet.has(item.value);
|
|
112
|
+
const isHighlighted = highlighted === item.value;
|
|
113
|
+
return (_jsxs("button", { type: 'button', role: 'option', "aria-selected": selected, disabled: item.disabled, className: 'oui-combobox-option oui-multi-select-option', "data-oui-multi-select-value": item.value, "data-selected": selected ? 'true' : 'false', "data-highlighted": isHighlighted ? 'true' : 'false', onMouseEnter: () => {
|
|
114
|
+
if (!item.disabled) {
|
|
115
|
+
navigation.setHighlightedValue(item.value);
|
|
116
|
+
}
|
|
117
|
+
}, onClick: () => {
|
|
118
|
+
if (!item.disabled)
|
|
119
|
+
toggle(item.value);
|
|
120
|
+
}, children: [_jsx("span", { className: 'oui-multi-select-check', children: selected ? _jsx(LuCheck, { size: 14 }) : null }), _jsx("span", { className: 'oui-combobox-option-main', children: item.label })] }, item.value));
|
|
121
|
+
})) }) }));
|
|
122
|
+
}
|
|
123
|
+
function defaultMultiSelectLabel(items) {
|
|
124
|
+
if (items.length <= 2) {
|
|
125
|
+
return items.map((item) => selectItemText(item)).join(', ');
|
|
126
|
+
}
|
|
127
|
+
return `${items.length} selected`;
|
|
128
|
+
}
|
|
129
|
+
function selectItemText(item) {
|
|
130
|
+
const label = item.triggerLabel ?? item.label;
|
|
131
|
+
if (typeof label === 'string')
|
|
132
|
+
return label;
|
|
133
|
+
if (typeof label === 'number')
|
|
134
|
+
return String(label);
|
|
135
|
+
return item.searchText ?? String(item.value);
|
|
136
|
+
}
|
|
137
|
+
function cssAttr(value) {
|
|
138
|
+
return value.replace(/"/g, '\\"');
|
|
139
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type TextFieldProps } from '../TextField/TextField';
|
|
2
|
+
export type NumberFieldProps = Omit<TextFieldProps, 'type'>;
|
|
3
|
+
export declare const NumberField: import("react").ForwardRefExoticComponent<NumberFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
4
|
+
//# sourceMappingURL=NumberField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/NumberField/NumberField.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAE5D,eAAO,MAAM,WAAW,+GAYvB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { TextField } from '../TextField/TextField';
|
|
4
|
+
export const NumberField = forwardRef(function NumberField({ testId, ...props }, ref) {
|
|
5
|
+
return (_jsx(TextField, { ref: ref, type: 'number', inputMode: 'decimal', testId: testId, ...props }));
|
|
6
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type OverlayLayerKind = 'dropdown' | 'overlay' | 'modal' | 'toast';
|
|
3
|
+
export type OverlayZIndex = Record<OverlayLayerKind, number>;
|
|
4
|
+
type OverlayContextValue = {
|
|
5
|
+
portalContainer: HTMLElement | null;
|
|
6
|
+
zIndex: OverlayZIndex;
|
|
7
|
+
};
|
|
8
|
+
export type OverlayProviderProps = {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
container?: HTMLElement | null;
|
|
11
|
+
zIndex?: Partial<OverlayZIndex>;
|
|
12
|
+
testId?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function OverlayProvider({ children, container, zIndex, testId, }: OverlayProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function useOverlayContext(): OverlayContextValue;
|
|
16
|
+
export declare function useOverlayLayerIndex(active: boolean): number;
|
|
17
|
+
export declare function lockOverlayScroll(): () => void;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=OverlayProvider.d.ts.map
|
|
@@ -0,0 +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,GAAG,IAAI,CAAC;IACpC,MAAM,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAqBF,wBAAgB,eAAe,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,MAAM,EACN,MAAM,GACT,EAAE,oBAAoB,2CAiCtB;AAED,wBAAgB,iBAAiB,wBAEhC;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,UAsBnD;AAKD,wBAAgB,iBAAiB,eAYhC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
4
|
+
const defaultZIndex = {
|
|
5
|
+
dropdown: 980,
|
|
6
|
+
overlay: 1000,
|
|
7
|
+
modal: 1000,
|
|
8
|
+
toast: 2147483000,
|
|
9
|
+
};
|
|
10
|
+
const OverlayContext = createContext({
|
|
11
|
+
portalContainer: null,
|
|
12
|
+
zIndex: defaultZIndex,
|
|
13
|
+
});
|
|
14
|
+
const layerIds = [];
|
|
15
|
+
const listeners = new Set();
|
|
16
|
+
function emitLayerChange() {
|
|
17
|
+
for (const listener of listeners)
|
|
18
|
+
listener();
|
|
19
|
+
}
|
|
20
|
+
export function OverlayProvider({ children, container, zIndex, testId, }) {
|
|
21
|
+
const fallbackRef = useRef(null);
|
|
22
|
+
const [fallbackContainer, setFallbackContainer] = useState(null);
|
|
23
|
+
const resolvedZIndex = useMemo(() => ({ ...defaultZIndex, ...zIndex }), [zIndex]);
|
|
24
|
+
const value = useMemo(() => ({
|
|
25
|
+
portalContainer: container ?? fallbackContainer,
|
|
26
|
+
zIndex: resolvedZIndex,
|
|
27
|
+
}), [container, fallbackContainer, resolvedZIndex]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setFallbackContainer(fallbackRef.current);
|
|
30
|
+
}, []);
|
|
31
|
+
return (_jsxs(OverlayContext.Provider, { value: value, children: [children, container === undefined ? (_jsx("div", { ref: fallbackRef, className: 'oui-overlay-root', "data-testid": testId })) : null] }));
|
|
32
|
+
}
|
|
33
|
+
export function useOverlayContext() {
|
|
34
|
+
return useContext(OverlayContext);
|
|
35
|
+
}
|
|
36
|
+
export function useOverlayLayerIndex(active) {
|
|
37
|
+
const [id] = useState(() => Symbol('oui-layer'));
|
|
38
|
+
const [index, setIndex] = useState(0);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!active)
|
|
41
|
+
return;
|
|
42
|
+
layerIds.push(id);
|
|
43
|
+
emitLayerChange();
|
|
44
|
+
const update = () => {
|
|
45
|
+
setIndex(Math.max(0, layerIds.indexOf(id)));
|
|
46
|
+
};
|
|
47
|
+
listeners.add(update);
|
|
48
|
+
update();
|
|
49
|
+
return () => {
|
|
50
|
+
const currentIndex = layerIds.indexOf(id);
|
|
51
|
+
if (currentIndex !== -1)
|
|
52
|
+
layerIds.splice(currentIndex, 1);
|
|
53
|
+
listeners.delete(update);
|
|
54
|
+
emitLayerChange();
|
|
55
|
+
};
|
|
56
|
+
}, [active, id]);
|
|
57
|
+
return index;
|
|
58
|
+
}
|
|
59
|
+
let scrollLockCount = 0;
|
|
60
|
+
let previousBodyOverflow = '';
|
|
61
|
+
export function lockOverlayScroll() {
|
|
62
|
+
if (scrollLockCount === 0) {
|
|
63
|
+
previousBodyOverflow = document.body.style.overflow;
|
|
64
|
+
document.body.style.overflow = 'hidden';
|
|
65
|
+
}
|
|
66
|
+
scrollLockCount += 1;
|
|
67
|
+
return () => {
|
|
68
|
+
scrollLockCount = Math.max(0, scrollLockCount - 1);
|
|
69
|
+
if (scrollLockCount === 0) {
|
|
70
|
+
document.body.style.overflow = previousBodyOverflow;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { UiSize } from '../../theme/systemProps';
|
|
3
|
+
export type PaginatedResult<T> = {
|
|
4
|
+
items: T[];
|
|
5
|
+
page: number;
|
|
6
|
+
page_size?: number;
|
|
7
|
+
total?: number;
|
|
8
|
+
has_next: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type PaginatedComboboxSearchAction = {
|
|
11
|
+
label: string | ((search: string) => string);
|
|
12
|
+
onClick: (search: string) => void;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type PaginatedComboboxProps<T> = {
|
|
16
|
+
loadPage: (page: number, search: string) => Promise<PaginatedResult<T>>;
|
|
17
|
+
getItemId: (item: T) => string | number;
|
|
18
|
+
renderOption: (item: T) => ReactNode;
|
|
19
|
+
renderSelectedLabel: (item: T) => ReactNode;
|
|
20
|
+
value: T | null;
|
|
21
|
+
onChange: (item: T | null) => void;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
emptyText?: ReactNode;
|
|
24
|
+
loadingText?: ReactNode;
|
|
25
|
+
errorText?: ReactNode;
|
|
26
|
+
retryLabel?: ReactNode;
|
|
27
|
+
searchPlaceholder?: string;
|
|
28
|
+
clearLabel?: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
clearable?: boolean;
|
|
31
|
+
showChevron?: boolean;
|
|
32
|
+
size?: UiSize;
|
|
33
|
+
maxHeight?: number;
|
|
34
|
+
closeOnSelect?: boolean;
|
|
35
|
+
isItemSelected?: (item: T) => boolean;
|
|
36
|
+
searchAction?: PaginatedComboboxSearchAction;
|
|
37
|
+
optionAction?: {
|
|
38
|
+
label: (item: T) => string;
|
|
39
|
+
icon: ReactNode;
|
|
40
|
+
onClick: (item: T, close?: () => void) => void;
|
|
41
|
+
disabled?: (item: T) => boolean;
|
|
42
|
+
};
|
|
43
|
+
resetKey?: unknown;
|
|
44
|
+
debounceMs?: number;
|
|
45
|
+
testId?: string;
|
|
46
|
+
};
|
|
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
|
+
//# sourceMappingURL=PaginatedCombobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaginatedCombobox.d.ts","sourceRoot":"","sources":["../../../src/components/PaginatedCombobox/PaginatedCombobox.tsx"],"names":[],"mappings":"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"}
|