@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,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useEffect, useState, } from 'react';
|
|
4
|
+
import { LuMenu, LuX } from 'react-icons/lu';
|
|
5
|
+
import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
|
|
6
|
+
import { splitSystemProps } from '../../theme/systemProps';
|
|
7
|
+
import { cn } from '../../utils/cn';
|
|
8
|
+
import { Badge } from '../Badge/Badge';
|
|
9
|
+
import { Drawer } from '../Drawer/Drawer';
|
|
10
|
+
import { IconButton } from '../IconButton/IconButton';
|
|
11
|
+
import { ScrollArea } from '../ScrollArea/ScrollArea';
|
|
12
|
+
import { Separator } from '../Separator/Separator';
|
|
13
|
+
import { Text } from '../Text/Text';
|
|
14
|
+
export const AppShell = forwardRef(function AppShell({ className, style, sidebar, header, sidebarOpen = false, onSidebarOpenChange, sidebarWidth = 260, maxWidth = 1440, contentInset = 28, children, testId, ...props }, ref) {
|
|
15
|
+
const [drawerMode, setDrawerMode] = useState(false);
|
|
16
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
17
|
+
const shellStyle = {
|
|
18
|
+
'--oui-app-shell-sidebar-width': shellSizeValue(sidebarWidth),
|
|
19
|
+
'--oui-app-shell-max-width': shellSizeValue(maxWidth),
|
|
20
|
+
'--oui-app-shell-inset': shellSizeValue(contentInset),
|
|
21
|
+
...systemStyle,
|
|
22
|
+
...style,
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const media = window.matchMedia('(max-width: 860px)');
|
|
26
|
+
const update = () => setDrawerMode(media.matches);
|
|
27
|
+
update();
|
|
28
|
+
media.addEventListener('change', update);
|
|
29
|
+
return () => media.removeEventListener('change', update);
|
|
30
|
+
}, []);
|
|
31
|
+
return (_jsxs("div", { ref: ref, className: cn('oui-app-shell', className), "data-sidebar-open": sidebarOpen ? 'true' : 'false', "data-testid": testId, style: shellStyle, ...restProps, children: [header, _jsxs("div", { className: 'oui-app-shell-frame', children: [!drawerMode ? (_jsx("div", { className: 'oui-app-shell-sidebar-desktop', children: sidebar })) : null, drawerMode ? (_jsx(Drawer, { open: sidebarOpen, onOpenChange: (nextOpen) => onSidebarOpenChange?.(nextOpen), side: 'left', size: sidebarWidth, showCloseButton: false, panelClassName: 'oui-app-shell-sidebar-drawer-panel', bodyClassName: 'oui-app-shell-sidebar-drawer-body', testId: testId ? `${testId}-sidebar-drawer` : undefined, children: sidebar })) : null, _jsx("main", { className: 'oui-app-shell-main', children: children })] })] }));
|
|
32
|
+
});
|
|
33
|
+
export const AppShellHeader = forwardRef(function AppShellHeader({ className, style, title, actions, sidebarOpen = false, onSidebarOpenChange, navigationLabel, visibility = 'always', children, testId, ...props }, ref) {
|
|
34
|
+
const { copy } = useOrcestrUiLocale();
|
|
35
|
+
const actualNavigationLabel = navigationLabel ??
|
|
36
|
+
(sidebarOpen ? copy.common.closeNavigation : copy.common.openNavigation);
|
|
37
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
38
|
+
return (_jsxs("header", { ref: ref, className: cn('oui-app-shell-header', className), "data-visibility": visibility, "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps, children: [onSidebarOpenChange ? (_jsx(IconButton, { v: 'pad', icon: sidebarOpen ? _jsx(LuX, { size: 19 }) : _jsx(LuMenu, { size: 19 }), "aria-label": actualNavigationLabel, "aria-expanded": sidebarOpen, onClick: () => onSidebarOpenChange(!sidebarOpen) })) : null, title ? _jsx("div", { className: 'oui-app-shell-header-title', children: title }) : null, children, actions ? _jsx("div", { className: 'oui-app-shell-header-actions', children: actions }) : null] }));
|
|
39
|
+
});
|
|
40
|
+
export const AppShellSidebar = forwardRef(function AppShellSidebar({ className, style, title, description, footer, onClose, closeLabel, children, testId, ...props }, ref) {
|
|
41
|
+
const { copy } = useOrcestrUiLocale();
|
|
42
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
43
|
+
return (_jsxs("aside", { ref: ref, className: cn('oui-app-shell-sidebar', className), "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps, children: [title || description || onClose ? (_jsxs("div", { className: 'oui-app-shell-sidebar-head', children: [_jsxs("div", { className: 'oui-app-shell-sidebar-head-main', children: [title ? (_jsx("div", { className: 'oui-app-shell-sidebar-title', children: title })) : null, description ? (_jsx(Text, { className: 'oui-app-shell-sidebar-description', color: 'var(--oui-muted)', fs: '13px', lh: 1.45, children: description })) : null] }), onClose ? (_jsx(IconButton, { className: 'oui-app-shell-sidebar-close', v: 'ghost', icon: _jsx(LuX, { size: 18 }), "aria-label": closeLabel ?? copy.common.closeNavigation, onClick: onClose })) : null] })) : null, (title || description) && children ? (_jsx(Separator, { className: 'oui-app-shell-sidebar-separator' })) : null, _jsx(ScrollArea, { className: 'oui-app-shell-sidebar-scroll', highlights: true, highlightH: 52, highlightColor: 'var(--oui-app-shell-sidebar-highlight-bg)', highlightTop: {
|
|
44
|
+
start: 50,
|
|
45
|
+
fadeDistance: 200,
|
|
46
|
+
maxOpacity: 0.92,
|
|
47
|
+
}, highlightBottom: {
|
|
48
|
+
start: 16,
|
|
49
|
+
fadeDistance: 140,
|
|
50
|
+
maxOpacity: 0.92,
|
|
51
|
+
}, children: _jsx("div", { className: 'oui-app-shell-sidebar-body', children: children }) }), footer ? _jsx("div", { className: 'oui-app-shell-sidebar-footer', children: footer }) : null] }));
|
|
52
|
+
});
|
|
53
|
+
export const AppShellContent = forwardRef(function AppShellContent({ className, style, scroll = true, children, testId, ...props }, ref) {
|
|
54
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
55
|
+
const content = (_jsx("div", { ref: ref, className: cn('oui-app-shell-content', className), "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps, children: children }));
|
|
56
|
+
if (!scroll)
|
|
57
|
+
return content;
|
|
58
|
+
return (_jsx(ScrollArea, { className: 'oui-app-shell-content-scroll', highlights: true, highlightH: 52, highlightColor: 'var(--oui-bg)', highlightTop: {
|
|
59
|
+
start: 50,
|
|
60
|
+
fadeDistance: 200,
|
|
61
|
+
maxOpacity: 0.94,
|
|
62
|
+
}, highlightBottom: {
|
|
63
|
+
start: 16,
|
|
64
|
+
fadeDistance: 140,
|
|
65
|
+
maxOpacity: 0.94,
|
|
66
|
+
}, children: content }));
|
|
67
|
+
});
|
|
68
|
+
export const AppShellNav = forwardRef(function AppShellNav({ className, style, items, onNavigate, label, testId, ...props }, ref) {
|
|
69
|
+
const { copy } = useOrcestrUiLocale();
|
|
70
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
71
|
+
return (_jsx("nav", { ref: ref, className: cn('oui-app-shell-nav', className), "aria-label": label ?? copy.common.primaryNavigation, "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps, children: items.map((item) => (_jsx(AppShellNavButton, { item: item, onNavigate: onNavigate, testId: testId ? `${testId}-${item.key}` : undefined }, item.key))) }));
|
|
72
|
+
});
|
|
73
|
+
export const PageTitleBlock = forwardRef(function PageTitleBlock({ className, style, title, caption, action, badge, testId, ...props }, ref) {
|
|
74
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
75
|
+
return (_jsxs("div", { ref: ref, className: cn('oui-page-title-block', className), "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps, children: [_jsxs("div", { className: 'oui-page-title-main', children: [_jsxs("div", { className: 'oui-page-title-row', children: [_jsx("h1", { className: 'oui-page-title', children: title }), badge ? _jsx(Badge, { tone: 'brand', children: badge }) : null] }), caption ? _jsx("p", { className: 'oui-page-title-caption', children: caption }) : null] }), action ? _jsx("div", { className: 'oui-page-title-actions', children: action }) : null] }));
|
|
76
|
+
});
|
|
77
|
+
function AppShellNavButton({ item, onNavigate, testId, }) {
|
|
78
|
+
const content = (_jsxs(_Fragment, { children: [item.icon ? _jsx("span", { className: 'oui-app-shell-nav-icon', children: item.icon }) : null, _jsxs("span", { className: 'oui-app-shell-nav-text', children: [_jsx("span", { className: 'oui-app-shell-nav-label', children: item.label }), item.caption ? (_jsx("span", { className: 'oui-app-shell-nav-caption', children: item.caption })) : null] }), item.badge ? _jsx("span", { className: 'oui-app-shell-nav-badge', children: item.badge }) : null] }));
|
|
79
|
+
const commonProps = {
|
|
80
|
+
className: 'oui-app-shell-nav-item',
|
|
81
|
+
'data-active': item.active ? 'true' : undefined,
|
|
82
|
+
'data-testid': testId,
|
|
83
|
+
'aria-current': item.active ? 'page' : undefined,
|
|
84
|
+
onClick: () => {
|
|
85
|
+
item.onSelect?.();
|
|
86
|
+
onNavigate?.(item);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
if (item.href && !item.disabled) {
|
|
90
|
+
return (_jsx("a", { href: item.href, ...commonProps, children: content }));
|
|
91
|
+
}
|
|
92
|
+
return (_jsx("button", { type: 'button', disabled: item.disabled, ...commonProps, children: content }));
|
|
93
|
+
}
|
|
94
|
+
function shellSizeValue(value) {
|
|
95
|
+
return typeof value === 'number' ? `${value}px` : value;
|
|
96
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { type SystemProps, type Tone, type UiSize } from '../../theme/systemProps';
|
|
3
|
+
export type BadgeProps = ComponentPropsWithoutRef<'span'> & SystemProps & {
|
|
4
|
+
tone?: Tone;
|
|
5
|
+
size?: UiSize;
|
|
6
|
+
v?: 'soft' | 'solid' | 'outline';
|
|
7
|
+
testId?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const Badge: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & SystemProps & {
|
|
10
|
+
tone?: Tone;
|
|
11
|
+
size?: UiSize;
|
|
12
|
+
v?: "soft" | "solid" | "outline";
|
|
13
|
+
testId?: string;
|
|
14
|
+
} & import("react").RefAttributes<HTMLSpanElement>>;
|
|
15
|
+
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,wBAAwB,EAAC,MAAM,OAAO,CAAC;AAGhE,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,MAAM,EACd,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG,wBAAwB,CAAC,MAAM,CAAC,GACrD,WAAW,GAAG;IACV,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,KAAK;WANH,IAAI;WACJ,MAAM;QACT,MAAM,GAAG,OAAO,GAAG,SAAS;aACvB,MAAM;mDA4BrB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { cn } from '../../utils/cn';
|
|
4
|
+
import { splitSystemProps, } from '../../theme/systemProps';
|
|
5
|
+
export const Badge = forwardRef(function Badge({ className, style, tone = 'neutral', size = 2, v = 'soft', testId, ...props }, ref) {
|
|
6
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
7
|
+
return (_jsx("span", { ref: ref, className: cn('oui-badge', className), "data-tone": tone, "data-size": size, "data-variant": v, "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps }));
|
|
8
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType } from 'react';
|
|
2
|
+
import { type SystemProps } from '../../theme/systemProps';
|
|
3
|
+
export type BoxProps = ComponentPropsWithoutRef<'div'> & SystemProps & {
|
|
4
|
+
as?: ElementType;
|
|
5
|
+
testId?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const Box: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & SystemProps & {
|
|
8
|
+
as?: ElementType;
|
|
9
|
+
testId?: string;
|
|
10
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
11
|
+
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EACnB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAmB,KAAK,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAClD,WAAW,GAAG;IACV,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,GAAG;SAJH,WAAW;aACP,MAAM;+CAiBrB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, } from 'react';
|
|
3
|
+
import { cn } from '../../utils/cn';
|
|
4
|
+
import { splitSystemProps } from '../../theme/systemProps';
|
|
5
|
+
export const Box = forwardRef(function Box({ as: Component = 'div', className, style, testId, ...props }, ref) {
|
|
6
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
7
|
+
return (_jsx(Component, { ref: ref, className: cn('oui-box', className), "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps }));
|
|
8
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type SystemProps, type Tone, type UiSize } from '../../theme/systemProps';
|
|
3
|
+
import type { ButtonPressAnimation } from '../../theme/themeTypes';
|
|
4
|
+
export type ButtonVariant = 'solid' | 'soft' | 'surface' | 'pad' | 'ghost' | 'outline';
|
|
5
|
+
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & SystemProps & {
|
|
6
|
+
size?: UiSize;
|
|
7
|
+
v?: ButtonVariant;
|
|
8
|
+
tone?: Tone;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
leftIcon?: ReactNode;
|
|
12
|
+
rightIcon?: ReactNode;
|
|
13
|
+
pressAnimation?: ButtonPressAnimation;
|
|
14
|
+
testId?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & SystemProps & {
|
|
17
|
+
size?: UiSize;
|
|
18
|
+
v?: ButtonVariant;
|
|
19
|
+
tone?: Tone;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
fullWidth?: boolean;
|
|
22
|
+
leftIcon?: ReactNode;
|
|
23
|
+
rightIcon?: ReactNode;
|
|
24
|
+
pressAnimation?: ButtonPressAnimation;
|
|
25
|
+
testId?: string;
|
|
26
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAGf,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,MAAM,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAGjE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AAEvF,MAAM,MAAM,WAAW,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAC7D,WAAW,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,aAAa,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,MAAM;WAXJ,MAAM;QACT,aAAa;WACV,IAAI;cACD,OAAO;gBACL,OAAO;eACR,SAAS;gBACR,SAAS;qBACJ,oBAAoB;aAC5B,MAAM;qDAgDrB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useContext, } from 'react';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { splitSystemProps, } from '../../theme/systemProps';
|
|
6
|
+
import { OrcestrThemeContext } from '../../theme/useTheme';
|
|
7
|
+
import { Spinner } from '../Spinner/Spinner';
|
|
8
|
+
export const Button = forwardRef(function Button({ className, style, size = 3, v = 'solid', tone = 'neutral', loading = false, fullWidth = false, leftIcon, rightIcon, pressAnimation, testId, children, disabled, type = 'button', ...props }, ref) {
|
|
9
|
+
const themeContext = useContext(OrcestrThemeContext);
|
|
10
|
+
const actualPressAnimation = pressAnimation ?? themeContext?.theme.motion.pressAnimation ?? 'soft';
|
|
11
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
12
|
+
return (_jsxs("button", { ref: ref, type: type, className: cn('oui-button', fullWidth && 'oui-button-full', className), "data-size": size, "data-variant": v, "data-tone": tone, "data-press-animation": actualPressAnimation, "data-loading": loading ? 'true' : undefined, "data-testid": testId, "aria-busy": loading ? 'true' : undefined, disabled: disabled || loading, style: { ...systemStyle, ...style }, ...restProps, children: [loading ? _jsx(Spinner, { size: 1 }) : leftIcon, _jsx("span", { className: 'oui-button-label', children: children }), rightIcon] }));
|
|
13
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> & {
|
|
3
|
+
label?: ReactNode;
|
|
4
|
+
testId?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "type"> & {
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
testId?: string;
|
|
9
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
10
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIH,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAKf,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,GAAG;IAC9E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,QAAQ;YAJT,SAAS;aACR,MAAM;oDA+ClB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useState, } from 'react';
|
|
4
|
+
import { LuCheck } from 'react-icons/lu';
|
|
5
|
+
import { cn } from '../../utils/cn';
|
|
6
|
+
export const Checkbox = forwardRef(function Checkbox({ className, label, children, checked, defaultChecked, disabled, onChange, testId, ...props }, ref) {
|
|
7
|
+
const [internalChecked, setInternalChecked] = useState(Boolean(defaultChecked));
|
|
8
|
+
const actualChecked = checked ?? internalChecked;
|
|
9
|
+
const handleChange = (event) => {
|
|
10
|
+
if (checked === undefined)
|
|
11
|
+
setInternalChecked(event.target.checked);
|
|
12
|
+
onChange?.(event);
|
|
13
|
+
};
|
|
14
|
+
return (_jsxs("label", { className: cn('oui-checkbox', className), "data-checked": actualChecked ? 'true' : undefined, "data-disabled": disabled ? 'true' : undefined, "data-testid": testId, children: [_jsx("input", { ref: ref, type: 'checkbox', checked: actualChecked, disabled: disabled, onChange: handleChange, ...props }), _jsx("span", { className: 'oui-checkbox-box', children: _jsx(LuCheck, { size: 13 }) }), label || children ? _jsx("span", { children: label ?? children }) : null] }));
|
|
15
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export type CollapseProps = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
animate?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
testId?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function Collapse({ open, children, animate, className, style, testId, }: CollapseProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=Collapse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collapse.d.ts","sourceRoot":"","sources":["../../../src/components/Collapse/Collapse.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKH,KAAK,aAAa,EAClB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,aAAa,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EACrB,IAAI,EACJ,QAAQ,EACR,OAAc,EACd,SAAS,EACT,KAAK,EACL,MAAM,GACT,EAAE,aAAa,2CAyCf"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useLayoutEffect, useRef, useState, } from 'react';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
export function Collapse({ open, children, animate = true, className, style, testId, }) {
|
|
6
|
+
const contentRef = useRef(null);
|
|
7
|
+
const [contentHeight, setContentHeight] = useState(null);
|
|
8
|
+
const measure = useCallback(() => {
|
|
9
|
+
const element = contentRef.current;
|
|
10
|
+
if (!element)
|
|
11
|
+
return;
|
|
12
|
+
const nextHeight = element.scrollHeight;
|
|
13
|
+
setContentHeight((current) => (current === nextHeight ? current : nextHeight));
|
|
14
|
+
}, []);
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
measure();
|
|
17
|
+
}, [children, measure, open]);
|
|
18
|
+
useLayoutEffect(() => {
|
|
19
|
+
const element = contentRef.current;
|
|
20
|
+
if (!element || typeof ResizeObserver === 'undefined')
|
|
21
|
+
return;
|
|
22
|
+
const observer = new ResizeObserver(() => measure());
|
|
23
|
+
observer.observe(element);
|
|
24
|
+
return () => observer.disconnect();
|
|
25
|
+
}, [measure]);
|
|
26
|
+
return (_jsx("div", { className: cn('oui-collapse', className), "data-state": open ? 'open' : 'closed', "data-testid": testId, style: {
|
|
27
|
+
height: open ? (contentHeight ?? undefined) : 0,
|
|
28
|
+
transition: animate
|
|
29
|
+
? 'height 220ms cubic-bezier(0.22, 1, 0.36, 1)'
|
|
30
|
+
: 'none',
|
|
31
|
+
...style,
|
|
32
|
+
}, children: _jsx("div", { ref: contentRef, className: 'oui-collapse-content', children: children }) }));
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ListboxItem } from '../Listbox/Listbox';
|
|
3
|
+
export declare function Combobox({ items, value, onValueChange, placeholder, selectedFallbackLabel, searchPlaceholder, emptyText, clearLabel, disabled, clearable, showChevron, testId, }: {
|
|
4
|
+
items: ReadonlyArray<ListboxItem>;
|
|
5
|
+
value: string | null;
|
|
6
|
+
onValueChange: (value: string | null) => void;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
selectedFallbackLabel?: ReactNode;
|
|
9
|
+
searchPlaceholder?: string;
|
|
10
|
+
emptyText?: string;
|
|
11
|
+
clearLabel?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
showChevron?: boolean;
|
|
15
|
+
testId?: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/Combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAKxD,OAAO,EAAU,KAAK,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAI7D,wBAAgB,QAAQ,CAAC,EACrB,KAAK,EACL,KAAK,EACL,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,QAAgB,EAChB,SAAgB,EAChB,WAAkB,EAClB,MAAM,GACT,EAAE;IACC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,SAAS,CAAC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CA2FA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { LuChevronsUpDown, LuX } from 'react-icons/lu';
|
|
5
|
+
import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
|
|
6
|
+
import { Button } from '../Button/Button';
|
|
7
|
+
import { Listbox } from '../Listbox/Listbox';
|
|
8
|
+
import { Popover } from '../Popover/Popover';
|
|
9
|
+
import { TextField } from '../TextField/TextField';
|
|
10
|
+
export function Combobox({ items, value, onValueChange, placeholder, selectedFallbackLabel, searchPlaceholder, emptyText, clearLabel, disabled = false, clearable = true, showChevron = true, testId, }) {
|
|
11
|
+
const { copy } = useOrcestrUiLocale();
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
const [query, setQuery] = useState('');
|
|
14
|
+
const selected = items.find((item) => item.value === value);
|
|
15
|
+
const filtered = useMemo(() => items.filter((item) => item.label.toLowerCase().includes(query.toLowerCase())), [items, query]);
|
|
16
|
+
return (_jsxs(Popover, { open: open, onOpenChange: (next) => {
|
|
17
|
+
setOpen(next);
|
|
18
|
+
if (!next)
|
|
19
|
+
setQuery('');
|
|
20
|
+
}, trigger: _jsx(Button, { v: 'surface', fullWidth: true, disabled: disabled, pressAnimation: 'none', className: 'oui-combobox-trigger', "data-state": open ? 'open' : 'closed', testId: testId, rightIcon: _jsxs("span", { className: 'oui-combobox-trigger-actions', children: [clearable && selected ? (_jsx("span", { "aria-label": clearLabel ?? copy.common.clear, className: 'oui-combobox-clear', onPointerDown: (event) => {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
}, onClick: (event) => {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
onValueChange(null);
|
|
27
|
+
}, children: _jsx(LuX, { size: 14 }) })) : null, showChevron ? _jsx(LuChevronsUpDown, { size: 15 }) : null] }), children: _jsx("span", { className: selected || selectedFallbackLabel ? 'oui-combobox-trigger-label' : 'oui-combobox-placeholder', children: selected?.label ?? selectedFallbackLabel ?? placeholder ?? copy.common.selectValue }) }), className: 'oui-combobox-content', testId: testId ? `${testId}-popover` : undefined, align: 'start', sideOffset: 4, matchTriggerWidth: true, disabled: disabled, children: [_jsx("div", { className: 'oui-combobox-search-wrap', children: _jsx(TextField, { autoFocus: true, size: 1, value: query, testId: testId ? `${testId}-search` : undefined, placeholder: searchPlaceholder ?? copy.common.search, onChange: (event) => setQuery(event.target.value) }) }), filtered.length === 0 ? (_jsx("div", { className: 'oui-combobox-empty', children: emptyText ?? copy.common.noOptions })) : (_jsx(Listbox, { className: 'oui-combobox-options', items: filtered, value: value, testId: testId ? `${testId}-listbox` : undefined, onValueChange: (next) => {
|
|
28
|
+
onValueChange(next);
|
|
29
|
+
setOpen(false);
|
|
30
|
+
setQuery('');
|
|
31
|
+
} }))] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type OrcestrActionItem } from '../Action/ActionTypes';
|
|
3
|
+
export type CommandPaletteItem = OrcestrActionItem & {
|
|
4
|
+
group?: string;
|
|
5
|
+
keywords?: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function CommandPalette({ open, onOpenChange, items, recentItems, onSelect, title, description, placeholder, emptyText, recentTitle, globalOpenEvents, testId, }: {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onOpenChange: (open: boolean) => void;
|
|
10
|
+
items: ReadonlyArray<CommandPaletteItem>;
|
|
11
|
+
recentItems?: ReadonlyArray<CommandPaletteItem>;
|
|
12
|
+
onSelect: (value: string) => void;
|
|
13
|
+
title?: ReactNode;
|
|
14
|
+
description?: ReactNode;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
emptyText?: ReactNode;
|
|
17
|
+
recentTitle?: string;
|
|
18
|
+
globalOpenEvents?: ReadonlyArray<string>;
|
|
19
|
+
testId?: string;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=CommandPalette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandPalette.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPalette.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAIf,OAAO,EAGH,KAAK,iBAAiB,EACzB,MAAM,uBAAuB,CAAC;AAO/B,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAQF,wBAAgB,cAAc,CAAC,EAC3B,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,WAAgB,EAChB,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,gBAAqB,EACrB,MAAM,GACT,EAAE;IACC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAChD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CA2QA"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
4
|
+
import { LuSearch } from 'react-icons/lu';
|
|
5
|
+
import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
|
|
6
|
+
import { actionItemSearchText, isActionItemDisabled, } from '../Action/ActionTypes';
|
|
7
|
+
import { ActionConfirmModal } from '../Action/ActionConfirmModal';
|
|
8
|
+
import { Collapse } from '../Collapse/Collapse';
|
|
9
|
+
import { Modal } from '../Modal/Modal';
|
|
10
|
+
import { Spinner } from '../Spinner/Spinner';
|
|
11
|
+
import { TextField } from '../TextField/TextField';
|
|
12
|
+
export function CommandPalette({ open, onOpenChange, items, recentItems = [], onSelect, title, description, placeholder, emptyText, recentTitle, globalOpenEvents = [], testId, }) {
|
|
13
|
+
const { copy } = useOrcestrUiLocale();
|
|
14
|
+
const actualTitle = title ?? copy.command.title;
|
|
15
|
+
const actualDescription = description ?? copy.command.description;
|
|
16
|
+
const actualPlaceholder = placeholder ?? copy.command.placeholder;
|
|
17
|
+
const actualEmptyText = emptyText ?? copy.command.empty;
|
|
18
|
+
const actualRecentTitle = recentTitle ?? copy.command.recent;
|
|
19
|
+
const listboxId = useId();
|
|
20
|
+
const [query, setQuery] = useState('');
|
|
21
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
22
|
+
const [confirmItem, setConfirmItem] = useState(null);
|
|
23
|
+
const optionsRef = useRef(null);
|
|
24
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
25
|
+
const filtered = useMemo(() => items.filter((item) => {
|
|
26
|
+
if (!normalizedQuery)
|
|
27
|
+
return true;
|
|
28
|
+
return [
|
|
29
|
+
actionItemSearchText(item),
|
|
30
|
+
item.group,
|
|
31
|
+
...(item.keywords ?? []),
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.some((value) => value.toLowerCase().includes(normalizedQuery));
|
|
35
|
+
}), [items, normalizedQuery]);
|
|
36
|
+
const groups = useMemo(() => {
|
|
37
|
+
const result = [];
|
|
38
|
+
const grouped = new Map();
|
|
39
|
+
if (!normalizedQuery && recentItems.length > 0) {
|
|
40
|
+
result.push({
|
|
41
|
+
group: actualRecentTitle,
|
|
42
|
+
items: [...recentItems],
|
|
43
|
+
recent: true,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
for (const item of filtered) {
|
|
47
|
+
const group = item.group ?? copy.command.group;
|
|
48
|
+
grouped.set(group, [...(grouped.get(group) ?? []), item]);
|
|
49
|
+
}
|
|
50
|
+
return [
|
|
51
|
+
...result,
|
|
52
|
+
...Array.from(grouped.entries()).map(([group, groupItems]) => ({
|
|
53
|
+
group,
|
|
54
|
+
items: groupItems,
|
|
55
|
+
})),
|
|
56
|
+
];
|
|
57
|
+
}, [actualRecentTitle, copy.command.group, filtered, normalizedQuery, recentItems]);
|
|
58
|
+
const options = useMemo(() => groups.flatMap((group) => group.items), [groups]);
|
|
59
|
+
const actualSelectedIndex = options.length === 0
|
|
60
|
+
? 0
|
|
61
|
+
: Math.min(selectedIndex, options.length - 1);
|
|
62
|
+
const selectedItem = options[actualSelectedIndex] ?? null;
|
|
63
|
+
const close = useCallback(() => {
|
|
64
|
+
onOpenChange(false);
|
|
65
|
+
setQuery('');
|
|
66
|
+
setSelectedIndex(0);
|
|
67
|
+
}, [onOpenChange]);
|
|
68
|
+
const selectItem = useCallback((item) => {
|
|
69
|
+
if (isActionItemDisabled(item))
|
|
70
|
+
return;
|
|
71
|
+
if (item.confirm) {
|
|
72
|
+
close();
|
|
73
|
+
setConfirmItem(item);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
item.onSelect?.();
|
|
77
|
+
onSelect(item.key);
|
|
78
|
+
close();
|
|
79
|
+
}, [close, onSelect]);
|
|
80
|
+
const moveSelected = useCallback((delta) => {
|
|
81
|
+
setSelectedIndex((current) => {
|
|
82
|
+
if (options.length === 0)
|
|
83
|
+
return 0;
|
|
84
|
+
return (current + delta + options.length) % options.length;
|
|
85
|
+
});
|
|
86
|
+
}, [options.length]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!open || options.length === 0)
|
|
89
|
+
return;
|
|
90
|
+
const node = optionsRef.current?.querySelector(`[data-oui-command-index="${actualSelectedIndex}"]`);
|
|
91
|
+
node?.scrollIntoView({ block: 'nearest' });
|
|
92
|
+
}, [actualSelectedIndex, open, options.length]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!globalOpenEvents.length)
|
|
95
|
+
return;
|
|
96
|
+
const openPalette = () => onOpenChange(true);
|
|
97
|
+
for (const eventName of globalOpenEvents) {
|
|
98
|
+
window.addEventListener(eventName, openPalette);
|
|
99
|
+
}
|
|
100
|
+
return () => {
|
|
101
|
+
for (const eventName of globalOpenEvents) {
|
|
102
|
+
window.removeEventListener(eventName, openPalette);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}, [globalOpenEvents, onOpenChange]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const onKeyDown = (event) => {
|
|
108
|
+
const isShortcut = (event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'k';
|
|
109
|
+
if (!isShortcut)
|
|
110
|
+
return;
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
onOpenChange(!open);
|
|
113
|
+
};
|
|
114
|
+
window.addEventListener('keydown', onKeyDown);
|
|
115
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
116
|
+
}, [onOpenChange, open]);
|
|
117
|
+
const handleKeyDown = (event) => {
|
|
118
|
+
if (event.key === 'ArrowDown') {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
moveSelected(1);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (event.key === 'ArrowUp') {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
moveSelected(-1);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (event.key === 'Home') {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
setSelectedIndex(0);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (event.key === 'End') {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
setSelectedIndex(Math.max(options.length - 1, 0));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (event.key === 'Enter' && selectedItem) {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
selectItem(selectedItem);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (event.key === 'Escape' && query.length > 0) {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
setQuery('');
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return (_jsxs(_Fragment, { children: [_jsx(Modal, { open: open, onOpenChange: (next) => {
|
|
149
|
+
if (next)
|
|
150
|
+
onOpenChange(true);
|
|
151
|
+
else
|
|
152
|
+
close();
|
|
153
|
+
}, title: actualTitle, description: actualDescription, maxWidth: 520, testId: testId, children: _jsxs("div", { className: 'oui-command-palette', "data-testid": testId ? `${testId}-panel` : undefined, onKeyDown: handleKeyDown, children: [_jsx(TextField, { autoFocus: true, className: 'oui-command-palette-search', leftSlot: _jsx(LuSearch, { size: 16 }), placeholder: actualPlaceholder, value: query, role: 'combobox', "aria-autocomplete": 'list', "aria-controls": listboxId, "aria-expanded": open, "aria-activedescendant": selectedItem
|
|
154
|
+
? commandOptionId(listboxId, actualSelectedIndex)
|
|
155
|
+
: undefined, onChange: (event) => setQuery(event.target.value) }), _jsx("div", { ref: optionsRef, id: listboxId, className: 'oui-command-palette-results', role: 'listbox', "aria-label": copy.common.commandPaletteResults, children: _jsx(Collapse, { open: true, className: 'oui-command-palette-collapse', children: groups.length > 0 ? (groups.map((groupData) => (_jsxs("div", { className: 'oui-command-palette-group', children: [_jsx("div", { className: 'oui-command-palette-group-title', "data-recent": groupData.recent ? 'true' : undefined, children: groupData.group }), _jsx("div", { className: 'oui-command-palette-items', children: groupData.items.map((item) => {
|
|
156
|
+
const index = options.indexOf(item);
|
|
157
|
+
const selected = index === actualSelectedIndex;
|
|
158
|
+
return (_jsxs("button", { id: commandOptionId(listboxId, index), type: 'button', role: 'option', "aria-selected": selected, className: 'oui-command-palette-item', "data-selected": selected ? 'true' : undefined, "data-loading": item.loading ? 'true' : undefined, "data-tone": item.tone, "data-oui-command-index": index, "aria-busy": item.loading ? 'true' : undefined, disabled: isActionItemDisabled(item), onMouseEnter: () => setSelectedIndex(index), onClick: () => selectItem(item), children: [item.icon || item.loading ? (_jsx("span", { className: 'oui-command-palette-item-icon', children: item.loading ? _jsx(Spinner, { size: 1 }) : item.icon })) : null, _jsxs("span", { className: 'oui-command-palette-item-main', children: [_jsx("span", { className: 'oui-command-palette-item-label', children: item.label }), item.description ? (_jsx("span", { className: 'oui-command-palette-item-description', children: item.description })) : null] }), item.shortcut ? (_jsx("span", { className: 'oui-command-palette-shortcut', children: item.shortcut })) : null] }, `${groupData.group}-${item.key}`));
|
|
159
|
+
}) })] }, groupData.group)))) : (_jsx("div", { className: 'oui-command-palette-empty', children: actualEmptyText })) }) })] }) }), _jsx(ActionConfirmModal, { item: confirmItem, open: confirmItem !== null, onCancel: () => setConfirmItem(null), onConfirm: () => {
|
|
160
|
+
confirmItem?.onSelect?.();
|
|
161
|
+
if (confirmItem)
|
|
162
|
+
onSelect(confirmItem.key);
|
|
163
|
+
setConfirmItem(null);
|
|
164
|
+
} })] }));
|
|
165
|
+
}
|
|
166
|
+
function commandOptionId(listboxId, index) {
|
|
167
|
+
return `${listboxId}-option-${index}`;
|
|
168
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Tone } from '../../theme/systemProps';
|
|
3
|
+
import { type ModalProps } from '../Modal/Modal';
|
|
4
|
+
export type ConfirmDialogTone = Extract<Tone, 'danger' | 'info' | 'neutral' | 'success' | 'warning'>;
|
|
5
|
+
export type ConfirmDialogProps = {
|
|
6
|
+
open: boolean;
|
|
7
|
+
onOpenChange: (open: boolean) => void;
|
|
8
|
+
title?: ReactNode;
|
|
9
|
+
description?: ReactNode;
|
|
10
|
+
message?: ReactNode;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
confirmLabel?: ReactNode;
|
|
13
|
+
cancelLabel?: ReactNode;
|
|
14
|
+
tone?: ConfirmDialogTone;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
confirmDisabled?: boolean;
|
|
17
|
+
cancelDisabled?: boolean;
|
|
18
|
+
closeOnOverlayClick?: boolean;
|
|
19
|
+
maxWidth?: ModalProps['maxWidth'];
|
|
20
|
+
testId?: string;
|
|
21
|
+
onConfirm: () => void;
|
|
22
|
+
onCancel?: () => void;
|
|
23
|
+
};
|
|
24
|
+
export declare function ConfirmDialog({ open, onOpenChange, title, description, message, children, confirmLabel, cancelLabel, tone, loading, confirmDisabled, cancelDisabled, closeOnOverlayClick, maxWidth, testId, onConfirm, onCancel, }: ConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=ConfirmDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmDialog.d.ts","sourceRoot":"","sources":["../../../src/components/ConfirmDialog/ConfirmDialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAGrC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAQ,KAAK,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAGtD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACnC,IAAI,EACJ,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CACxD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC1B,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,WAAW,EACX,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,IAAgB,EAChB,OAAe,EACf,eAAuB,EACvB,cAAsB,EACtB,mBAAmB,EACnB,QAAc,EACd,MAAM,EACN,SAAS,EACT,QAAQ,GACX,EAAE,kBAAkB,2CAyDpB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useOrcestrUiLocale } from '../../locale/LocaleProvider';
|
|
4
|
+
import { Button } from '../Button/Button';
|
|
5
|
+
import { Modal } from '../Modal/Modal';
|
|
6
|
+
import { Text } from '../Text/Text';
|
|
7
|
+
export function ConfirmDialog({ open, onOpenChange, title, description, message, children, confirmLabel, cancelLabel, tone = 'neutral', loading = false, confirmDisabled = false, cancelDisabled = false, closeOnOverlayClick, maxWidth = 420, testId, onConfirm, onCancel, }) {
|
|
8
|
+
const { copy } = useOrcestrUiLocale();
|
|
9
|
+
const actualCancelLabel = cancelLabel ?? copy.common.close;
|
|
10
|
+
const actualConfirmLabel = confirmLabel ?? copy.common.save;
|
|
11
|
+
const canClose = !loading && !cancelDisabled;
|
|
12
|
+
const cancel = () => {
|
|
13
|
+
if (!canClose)
|
|
14
|
+
return;
|
|
15
|
+
onCancel?.();
|
|
16
|
+
onOpenChange(false);
|
|
17
|
+
};
|
|
18
|
+
return (_jsxs(Modal, { open: open, onOpenChange: (nextOpen) => {
|
|
19
|
+
if (nextOpen) {
|
|
20
|
+
onOpenChange(true);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
cancel();
|
|
24
|
+
}, title: title, description: description, maxWidth: maxWidth, closeOnOverlayClick: closeOnOverlayClick ?? canClose, testId: testId, footer: (_jsxs(_Fragment, { children: [_jsx(Button, { v: 'surface', onClick: cancel, disabled: !canClose, testId: testId ? `${testId}-cancel` : undefined, children: actualCancelLabel }), _jsx(Button, { tone: tone, loading: loading, disabled: confirmDisabled, onClick: onConfirm, testId: testId ? `${testId}-confirm` : undefined, children: actualConfirmLabel })] })), children: [message ? (_jsx(Text, { as: 'p', tone: 'muted', lh: 1.5, children: message })) : null, children] }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type MouseEvent, type ReactElement } from 'react';
|
|
2
|
+
import type { MenuItem } from '../Menu/Menu';
|
|
3
|
+
export declare function ContextMenu({ children, items, className, testId, }: {
|
|
4
|
+
children: ReactElement<{
|
|
5
|
+
onContextMenu?: (event: MouseEvent) => void;
|
|
6
|
+
}>;
|
|
7
|
+
items: ReadonlyArray<MenuItem>;
|
|
8
|
+
className?: string;
|
|
9
|
+
testId?: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=ContextMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenu.d.ts","sourceRoot":"","sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAMH,KAAK,UAAU,EACf,KAAK,YAAY,EACpB,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAK3C,wBAAgB,WAAW,CAAC,EACxB,QAAQ,EACR,KAAK,EACL,SAAS,EACT,MAAM,GACT,EAAE;IACC,QAAQ,EAAE,YAAY,CAAC;QAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;KAAC,CAAC,CAAC;IACtE,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,2CA6EA"}
|