@orcestr/ui 0.0.3 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Alert/Alert.d.ts +5 -4
- package/dist/components/Alert/Alert.d.ts.map +1 -1
- package/dist/components/Alert/Alert.js +5 -2
- package/dist/components/AppShell/AppShell.d.ts +13 -0
- package/dist/components/AppShell/AppShell.d.ts.map +1 -1
- package/dist/components/AppShell/AppShell.js +14 -9
- package/dist/components/AppSidebar/AppSidebar.d.ts +36 -0
- package/dist/components/AppSidebar/AppSidebar.d.ts.map +1 -0
- package/dist/components/AppSidebar/AppSidebar.js +117 -0
- package/dist/components/Badge/Badge.d.ts +8 -6
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/Badge.js +4 -4
- package/dist/components/BadgeSelectMenu/BadgeSelectMenu.d.ts +22 -0
- package/dist/components/BadgeSelectMenu/BadgeSelectMenu.d.ts.map +1 -0
- package/dist/components/BadgeSelectMenu/BadgeSelectMenu.js +50 -0
- package/dist/components/Box/Box.d.ts +2 -0
- package/dist/components/Box/Box.d.ts.map +1 -1
- package/dist/components/Box/Box.js +15 -2
- package/dist/components/Button/Button.d.ts +7 -3
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +23 -3
- package/dist/components/Card/Card.d.ts +26 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/Card.js +25 -0
- package/dist/components/Checkbox/Checkbox.d.ts +6 -2
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +13 -4
- package/dist/components/Collapse/Collapse.d.ts.map +1 -1
- package/dist/components/Collapse/Collapse.js +5 -25
- package/dist/components/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.js +10 -9
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.js +5 -2
- package/dist/components/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +2 -2
- package/dist/components/CopyButton/CopyButton.d.ts +24 -0
- package/dist/components/CopyButton/CopyButton.d.ts.map +1 -0
- package/dist/components/CopyButton/CopyButton.js +81 -0
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +9 -1
- package/dist/components/Dialog/Dialog.d.ts +69 -1
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.js +48 -1
- package/dist/components/Drawer/Drawer.d.ts +2 -1
- package/dist/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/components/Drawer/Drawer.js +4 -4
- package/dist/components/EntityPicker/EntityPicker.d.ts +2 -1
- package/dist/components/EntityPicker/EntityPicker.d.ts.map +1 -1
- package/dist/components/EntityPicker/EntityPicker.js +2 -2
- package/dist/components/Flex/Flex.d.ts +5 -1
- package/dist/components/Flex/Flex.d.ts.map +1 -1
- package/dist/components/Flex/Flex.js +16 -3
- package/dist/components/Grid/Grid.d.ts +9 -2
- package/dist/components/Grid/Grid.d.ts.map +1 -1
- package/dist/components/Grid/Grid.js +22 -1
- package/dist/components/IconButton/IconButton.d.ts +19 -7
- package/dist/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.js +40 -5
- package/dist/components/IconTextButton/IconTextButton.d.ts +20 -0
- package/dist/components/IconTextButton/IconTextButton.d.ts.map +1 -0
- package/dist/components/IconTextButton/IconTextButton.js +24 -0
- package/dist/components/InlineEdit/InlineEdit.d.ts +63 -0
- package/dist/components/InlineEdit/InlineEdit.d.ts.map +1 -0
- package/dist/components/InlineEdit/InlineEdit.js +98 -0
- package/dist/components/LinkButton/LinkButton.d.ts +25 -0
- package/dist/components/LinkButton/LinkButton.d.ts.map +1 -0
- package/dist/components/LinkButton/LinkButton.js +12 -0
- package/dist/components/Modal/Modal.d.ts +29 -6
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.js +37 -13
- package/dist/components/Overlay/OverlayProvider.d.ts +1 -0
- package/dist/components/Overlay/OverlayProvider.d.ts.map +1 -1
- package/dist/components/Overlay/OverlayProvider.js +18 -1
- package/dist/components/PaginatedCombobox/PaginatedCombobox.d.ts +2 -1
- package/dist/components/PaginatedCombobox/PaginatedCombobox.d.ts.map +1 -1
- package/dist/components/PaginatedCombobox/PaginatedCombobox.js +3 -3
- package/dist/components/Popover/Popover.d.ts +37 -3
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/Popover/Popover.js +56 -9
- package/dist/components/ScrollArea/ScrollArea.d.ts +4 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +30 -4
- package/dist/components/Section/Section.d.ts +2 -0
- package/dist/components/Section/Section.d.ts.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +24 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.js +28 -2
- package/dist/components/Select/Select.d.ts +36 -4
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.js +70 -3
- package/dist/components/Separator/Separator.d.ts +3 -1
- package/dist/components/Separator/Separator.d.ts.map +1 -1
- package/dist/components/Separator/Separator.js +4 -2
- package/dist/components/SpecialModal/SpecialModal.d.ts +43 -0
- package/dist/components/SpecialModal/SpecialModal.d.ts.map +1 -0
- package/dist/components/SpecialModal/SpecialModal.js +34 -0
- package/dist/components/Spinner/Spinner.d.ts +3 -1
- package/dist/components/Spinner/Spinner.d.ts.map +1 -1
- package/dist/components/Spinner/Spinner.js +2 -2
- package/dist/components/State/State.d.ts +8 -1
- package/dist/components/State/State.d.ts.map +1 -1
- package/dist/components/State/State.js +2 -2
- package/dist/components/Switch/Switch.d.ts +2 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -1
- package/dist/components/Switch/Switch.js +2 -1
- package/dist/components/Table/Table.d.ts +64 -0
- package/dist/components/Table/Table.d.ts.map +1 -0
- package/dist/components/Table/Table.js +38 -0
- package/dist/components/Tabs/Tabs.d.ts +33 -2
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +201 -5
- package/dist/components/Text/Text.d.ts +13 -3
- package/dist/components/Text/Text.d.ts.map +1 -1
- package/dist/components/Text/Text.js +16 -3
- package/dist/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.js +1 -1
- package/dist/components/TextField/TextField.d.ts.map +1 -1
- package/dist/components/TextField/TextField.js +1 -1
- package/dist/components/Toast/Toast.d.ts +1 -4
- package/dist/components/Toast/Toast.d.ts.map +1 -1
- package/dist/components/Toast/Toast.js +72 -37
- package/dist/components/Tooltip/Tooltip.d.ts +11 -3
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +58 -9
- package/dist/example/CodePreview.d.ts +2 -1
- package/dist/example/CodePreview.d.ts.map +1 -1
- package/dist/example/CodePreview.js +16 -51
- package/dist/example/ExampleActionsSection.d.ts.map +1 -1
- package/dist/example/ExampleActionsSection.js +3 -3
- package/dist/example/ExampleApplicationSection.d.ts +7 -0
- package/dist/example/ExampleApplicationSection.d.ts.map +1 -0
- package/dist/example/ExampleApplicationSection.js +88 -0
- package/dist/example/ExampleBasicsSections.d.ts +1 -1
- package/dist/example/ExampleBasicsSections.d.ts.map +1 -1
- package/dist/example/ExampleBasicsSections.js +15 -13
- package/dist/example/ExampleDataSection.d.ts.map +1 -1
- package/dist/example/ExampleDataSection.js +31 -30
- package/dist/example/ExampleFieldsSection.d.ts.map +1 -1
- package/dist/example/ExampleFieldsSection.js +51 -3
- package/dist/example/ExampleFoundationsSection.js +1 -1
- package/dist/example/ExampleOverlays.d.ts.map +1 -1
- package/dist/example/ExampleOverlays.js +7 -2
- package/dist/example/ExampleOverlaysSection.d.ts.map +1 -1
- package/dist/example/ExampleOverlaysSection.js +20 -30
- package/dist/example/ExampleSelectionSection.d.ts +3 -1
- package/dist/example/ExampleSelectionSection.d.ts.map +1 -1
- package/dist/example/ExampleSelectionSection.js +10 -3
- package/dist/example/ExampleStateSection.d.ts +3 -0
- package/dist/example/ExampleStateSection.d.ts.map +1 -1
- package/dist/example/ExampleStateSection.js +65 -9
- package/dist/example/ExampleThemePlayground.d.ts +84 -54
- package/dist/example/ExampleThemePlayground.d.ts.map +1 -1
- package/dist/example/ExampleThemePlayground.js +129 -63
- package/dist/example/UiExamplePage.d.ts.map +1 -1
- package/dist/example/UiExamplePage.js +39 -19
- package/dist/example/codeSamples.d.ts +8 -1
- package/dist/example/codeSamples.d.ts.map +1 -1
- package/dist/example/codeSamples.js +590 -119
- package/dist/example/exampleData.d.ts.map +1 -1
- package/dist/example/exampleData.js +18 -10
- package/dist/example/styles.css +277 -146
- package/dist/hooks/useFloatingPosition.js +1 -1
- package/dist/hooks/usePresence.d.ts.map +1 -1
- package/dist/hooks/usePresence.js +9 -7
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/styles/orcestr-ui.css +3002 -872
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +109 -53
- package/dist/theme/defaultTheme.d.ts.map +1 -1
- package/dist/theme/defaultTheme.js +356 -223
- package/dist/theme/systemProps.d.ts +48 -28
- package/dist/theme/systemProps.d.ts.map +1 -1
- package/dist/theme/systemProps.js +103 -1
- package/dist/theme/themeTypes.d.ts +44 -35
- package/dist/theme/themeTypes.d.ts.map +1 -1
- package/dist/utils/slot.d.ts +11 -0
- package/dist/utils/slot.d.ts.map +1 -0
- package/dist/utils/slot.js +18 -0
- package/package.json +4 -1
- package/dist/components/Workflow/Workflow.d.ts +0 -82
- package/dist/components/Workflow/Workflow.d.ts.map +0 -1
- package/dist/components/Workflow/Workflow.js +0 -73
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import type
|
|
3
|
-
export type AlertProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> & {
|
|
4
|
-
tone?: Exclude<
|
|
2
|
+
import { type SystemProps, type ToneInput } from '../../theme/systemProps';
|
|
3
|
+
export type AlertProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> & SystemProps & {
|
|
4
|
+
tone?: Exclude<ToneInput, 'primary' | 'secondary' | 'muted'>;
|
|
5
|
+
v?: 'soft' | 'surface';
|
|
5
6
|
title?: ReactNode;
|
|
6
7
|
icon?: ReactNode;
|
|
7
8
|
action?: ReactNode;
|
|
8
9
|
testId?: string;
|
|
9
10
|
};
|
|
10
|
-
export declare function Alert({ tone, title, icon, action, className, children, testId, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function Alert({ tone, v, title, icon, action, className, style, children, testId, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
//# sourceMappingURL=Alert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,cAAc,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,cAAc,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAErD,OAAO,EAGH,KAAK,WAAW,EAChB,KAAK,SAAS,EACjB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,GAClE,WAAW,GAAG;IACd,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC,CAAC;IAC7D,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,KAAK,CAAC,EAClB,IAAa,EACb,CAAU,EACV,KAAK,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,EACN,GAAG,KAAK,EACX,EAAE,UAAU,2CAsBZ"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { normalizeTone, splitSystemProps, } from '../../theme/systemProps';
|
|
3
4
|
import { cn } from '../../utils/cn';
|
|
4
5
|
import { stateIcon } from '../State/stateIcon';
|
|
5
|
-
export function Alert({ tone = 'info', title, icon, action, className, children, testId, ...props }) {
|
|
6
|
-
|
|
6
|
+
export function Alert({ tone = 'info', v = 'soft', title, icon, action, className, style, children, testId, ...props }) {
|
|
7
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
8
|
+
const actualTone = normalizeTone(tone, 'info');
|
|
9
|
+
return (_jsxs("div", { className: cn('oui-alert', className), "data-tone": actualTone, "data-variant": v, "data-testid": testId, role: actualTone === 'danger' ? 'alert' : 'status', style: { ...systemStyle, ...style }, ...restProps, children: [_jsx("span", { className: 'oui-alert-icon', children: icon ?? stateIcon(actualTone) }), _jsxs("span", { className: 'oui-alert-main', children: [title ? _jsx("strong", { children: title }) : null, children ? _jsx("span", { children: children }) : null] }), action ? _jsx("span", { className: 'oui-alert-action', children: action }) : null] }));
|
|
7
10
|
}
|
|
@@ -11,12 +11,18 @@ export type AppShellNavItem = {
|
|
|
11
11
|
href?: string;
|
|
12
12
|
onSelect?: () => void;
|
|
13
13
|
};
|
|
14
|
+
export type AppShellSide = 'left' | 'right';
|
|
14
15
|
export type AppShellProps = ComponentPropsWithoutRef<'div'> & SystemProps & {
|
|
15
16
|
sidebar: ReactNode;
|
|
16
17
|
header?: ReactNode;
|
|
18
|
+
sidebarMode?: 'auto' | 'desktop' | 'mobile';
|
|
19
|
+
sidebarSide?: AppShellSide;
|
|
17
20
|
sidebarOpen?: boolean;
|
|
21
|
+
desktopSidebarOpen?: boolean;
|
|
18
22
|
onSidebarOpenChange?: (open: boolean) => void;
|
|
19
23
|
sidebarWidth?: number | string;
|
|
24
|
+
headerHeight?: number | string;
|
|
25
|
+
mobileBreakpoint?: number;
|
|
20
26
|
maxWidth?: number | string;
|
|
21
27
|
contentInset?: number | string;
|
|
22
28
|
testId?: string;
|
|
@@ -24,9 +30,14 @@ export type AppShellProps = ComponentPropsWithoutRef<'div'> & SystemProps & {
|
|
|
24
30
|
export declare const AppShell: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & SystemProps & {
|
|
25
31
|
sidebar: ReactNode;
|
|
26
32
|
header?: ReactNode;
|
|
33
|
+
sidebarMode?: "auto" | "desktop" | "mobile";
|
|
34
|
+
sidebarSide?: AppShellSide;
|
|
27
35
|
sidebarOpen?: boolean;
|
|
36
|
+
desktopSidebarOpen?: boolean;
|
|
28
37
|
onSidebarOpenChange?: (open: boolean) => void;
|
|
29
38
|
sidebarWidth?: number | string;
|
|
39
|
+
headerHeight?: number | string;
|
|
40
|
+
mobileBreakpoint?: number;
|
|
30
41
|
maxWidth?: number | string;
|
|
31
42
|
contentInset?: number | string;
|
|
32
43
|
testId?: string;
|
|
@@ -37,6 +48,7 @@ export type AppShellHeaderProps = Omit<ComponentPropsWithoutRef<'header'>, 'titl
|
|
|
37
48
|
sidebarOpen?: boolean;
|
|
38
49
|
onSidebarOpenChange?: (open: boolean) => void;
|
|
39
50
|
navigationLabel?: string;
|
|
51
|
+
navigationVisibility?: 'always' | 'mobile';
|
|
40
52
|
visibility?: 'always' | 'mobile';
|
|
41
53
|
testId?: string;
|
|
42
54
|
};
|
|
@@ -46,6 +58,7 @@ export declare const AppShellHeader: import("react").ForwardRefExoticComponent<O
|
|
|
46
58
|
sidebarOpen?: boolean;
|
|
47
59
|
onSidebarOpenChange?: (open: boolean) => void;
|
|
48
60
|
navigationLabel?: string;
|
|
61
|
+
navigationVisibility?: "always" | "mobile";
|
|
49
62
|
visibility?: "always" | "mobile";
|
|
50
63
|
testId?: string;
|
|
51
64
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShell.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIH,KAAK,wBAAwB,EAE7B,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAmB,KAAK,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAS3E,MAAM,MAAM,eAAe,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,wBAAwB,CAAC,KAAK,CAAC,GACvD,WAAW,GAAG;IACV,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,C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AW,GAAG;IACV,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,cAAc;WAPZ,SAAS;cACN,SAAS;aACV,SAAS;YACV,SAAS;aACR,MAAM;kDA4BtB,CAAC"}
|
|
@@ -11,31 +11,36 @@ import { IconButton } from '../IconButton/IconButton';
|
|
|
11
11
|
import { ScrollArea } from '../ScrollArea/ScrollArea';
|
|
12
12
|
import { Separator } from '../Separator/Separator';
|
|
13
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 [
|
|
14
|
+
export const AppShell = forwardRef(function AppShell({ className, style, sidebar, header, sidebarMode = 'auto', sidebarSide = 'left', sidebarOpen = false, desktopSidebarOpen = true, onSidebarOpenChange, sidebarWidth = 260, headerHeight = 56, mobileBreakpoint = 860, maxWidth = 1440, contentInset = 28, children, testId, ...props }, ref) {
|
|
15
|
+
const [autoDrawerMode, setAutoDrawerMode] = useState(false);
|
|
16
|
+
const [drawerPortalContainer, setDrawerPortalContainer] = useState(null);
|
|
16
17
|
const { systemStyle, restProps } = splitSystemProps(props);
|
|
18
|
+
const drawerMode = sidebarMode === 'auto' ? autoDrawerMode : sidebarMode === 'mobile';
|
|
17
19
|
const shellStyle = {
|
|
18
20
|
'--oui-app-shell-sidebar-width': shellSizeValue(sidebarWidth),
|
|
21
|
+
'--oui-app-shell-header-h': shellSizeValue(headerHeight),
|
|
19
22
|
'--oui-app-shell-max-width': shellSizeValue(maxWidth),
|
|
20
23
|
'--oui-app-shell-inset': shellSizeValue(contentInset),
|
|
21
24
|
...systemStyle,
|
|
22
25
|
...style,
|
|
23
26
|
};
|
|
24
27
|
useEffect(() => {
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
if (sidebarMode !== 'auto')
|
|
29
|
+
return;
|
|
30
|
+
const media = window.matchMedia(`(max-width: ${mobileBreakpoint}px)`);
|
|
31
|
+
const update = () => setAutoDrawerMode(media.matches);
|
|
27
32
|
update();
|
|
28
33
|
media.addEventListener('change', update);
|
|
29
34
|
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: [
|
|
35
|
+
}, [mobileBreakpoint, sidebarMode]);
|
|
36
|
+
return (_jsxs("div", { ref: ref, className: cn('oui-app-shell', className), "data-sidebar-open": sidebarOpen ? 'true' : 'false', "data-desktop-sidebar-open": desktopSidebarOpen ? 'true' : 'false', "data-sidebar-side": sidebarSide, "data-sidebar-mode": drawerMode ? 'mobile' : 'desktop', "data-has-header": header ? 'true' : undefined, "data-testid": testId, style: shellStyle, ...restProps, children: [_jsxs("div", { className: 'oui-app-shell-frame', children: [!drawerMode ? (_jsx("div", { className: 'oui-app-shell-sidebar-desktop', children: sidebar })) : null, drawerMode && drawerPortalContainer ? (_jsx(Drawer, { open: sidebarOpen, onOpenChange: (nextOpen) => onSidebarOpenChange?.(nextOpen), side: sidebarSide, size: sidebarWidth, lockScroll: false, portalContainer: drawerPortalContainer, showCloseButton: false, backdropClassName: 'oui-app-shell-sidebar-drawer-overlay', panelClassName: 'oui-app-shell-sidebar-drawer-panel', bodyClassName: 'oui-app-shell-sidebar-drawer-body', testId: testId ? `${testId}-sidebar-drawer` : undefined, children: sidebar })) : null, _jsxs("main", { className: 'oui-app-shell-main', children: [header, children] })] }), drawerMode ? (_jsx("div", { ref: setDrawerPortalContainer, className: 'oui-app-shell-drawer-root' })) : null] }));
|
|
32
37
|
});
|
|
33
|
-
export const AppShellHeader = forwardRef(function AppShellHeader({ className, style, title, actions, sidebarOpen = false, onSidebarOpenChange, navigationLabel, visibility = 'always', children, testId, ...props }, ref) {
|
|
38
|
+
export const AppShellHeader = forwardRef(function AppShellHeader({ className, style, title, actions, sidebarOpen = false, onSidebarOpenChange, navigationLabel, navigationVisibility = 'always', visibility = 'always', children, testId, ...props }, ref) {
|
|
34
39
|
const { copy } = useOrcestrUiLocale();
|
|
35
40
|
const actualNavigationLabel = navigationLabel ??
|
|
36
41
|
(sidebarOpen ? copy.common.closeNavigation : copy.common.openNavigation);
|
|
37
42
|
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] }));
|
|
43
|
+
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, { className: 'oui-app-shell-header-nav-button', v: 'pad', icon: sidebarOpen ? _jsx(LuX, { size: 19 }) : _jsx(LuMenu, { size: 19 }), "aria-label": actualNavigationLabel, "aria-expanded": sidebarOpen, "data-navigation-visibility": navigationVisibility, 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
44
|
});
|
|
40
45
|
export const AppShellSidebar = forwardRef(function AppShellSidebar({ className, style, title, description, footer, onClose, closeLabel, children, testId, ...props }, ref) {
|
|
41
46
|
const { copy } = useOrcestrUiLocale();
|
|
@@ -72,7 +77,7 @@ export const AppShellNav = forwardRef(function AppShellNav({ className, style, i
|
|
|
72
77
|
});
|
|
73
78
|
export const PageTitleBlock = forwardRef(function PageTitleBlock({ className, style, title, caption, action, badge, testId, ...props }, ref) {
|
|
74
79
|
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: '
|
|
80
|
+
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: 'primary', 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
81
|
});
|
|
77
82
|
function AppShellNavButton({ item, onNavigate, testId, }) {
|
|
78
83
|
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] }));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType, type ReactNode } from 'react';
|
|
2
|
+
import { type SystemProps } from '../../theme/systemProps';
|
|
3
|
+
export type AppSidebarSide = 'left' | 'right';
|
|
4
|
+
export type AppSidebarItem = {
|
|
5
|
+
key: string;
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
href?: string;
|
|
9
|
+
component?: ElementType;
|
|
10
|
+
active?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onSelect?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type AppSidebarGroup = {
|
|
15
|
+
key: string;
|
|
16
|
+
items: readonly AppSidebarItem[];
|
|
17
|
+
};
|
|
18
|
+
export type AppSidebarProps = Omit<ComponentPropsWithoutRef<'aside'>, 'title'> & SystemProps & {
|
|
19
|
+
header?: ReactNode;
|
|
20
|
+
groups: readonly AppSidebarGroup[];
|
|
21
|
+
footer?: ReactNode;
|
|
22
|
+
side?: AppSidebarSide;
|
|
23
|
+
itemH?: number;
|
|
24
|
+
onNavigate?: (item: AppSidebarItem) => void;
|
|
25
|
+
testId?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const AppSidebar: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "title"> & SystemProps & {
|
|
28
|
+
header?: ReactNode;
|
|
29
|
+
groups: readonly AppSidebarGroup[];
|
|
30
|
+
footer?: ReactNode;
|
|
31
|
+
side?: AppSidebarSide;
|
|
32
|
+
itemH?: number;
|
|
33
|
+
onNavigate?: (item: AppSidebarItem) => void;
|
|
34
|
+
testId?: string;
|
|
35
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
36
|
+
//# sourceMappingURL=AppSidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/AppSidebar/AppSidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKH,KAAK,wBAAwB,EAE7B,KAAK,WAAW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_jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useLayoutEffect, useRef, } from 'react';
|
|
4
|
+
import { splitSystemProps } from '../../theme/systemProps';
|
|
5
|
+
import { cn } from '../../utils/cn';
|
|
6
|
+
import { ScrollArea } from '../ScrollArea/ScrollArea';
|
|
7
|
+
import { Separator } from '../Separator/Separator';
|
|
8
|
+
export const AppSidebar = forwardRef(function AppSidebar({ className, style, header, groups, footer, side = 'left', itemH = 40, onNavigate, testId, ...props }, ref) {
|
|
9
|
+
const contentRef = useRef(null);
|
|
10
|
+
const indicatorRef = useRef(null);
|
|
11
|
+
const indicatorPlacedRef = useRef(false);
|
|
12
|
+
const transitionFrameRef = useRef(0);
|
|
13
|
+
const activeKey = groups
|
|
14
|
+
.flatMap((group) => group.items)
|
|
15
|
+
.find((item) => item.active)?.key;
|
|
16
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
17
|
+
const sidebarStyle = {
|
|
18
|
+
'--oui-app-sidebar-item-h': `${itemH}px`,
|
|
19
|
+
...systemStyle,
|
|
20
|
+
...style,
|
|
21
|
+
};
|
|
22
|
+
const updateActiveIndicator = useCallback((animate = true) => {
|
|
23
|
+
const root = contentRef.current;
|
|
24
|
+
const indicator = indicatorRef.current;
|
|
25
|
+
const activeItem = root?.querySelector('[data-sidebar-active="true"]');
|
|
26
|
+
if (!root || !indicator || !activeItem) {
|
|
27
|
+
if (indicator)
|
|
28
|
+
indicator.style.opacity = '0';
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const itemHeight = activeItem.offsetHeight;
|
|
32
|
+
if (itemHeight <= 0) {
|
|
33
|
+
indicator.style.opacity = '0';
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const skipTransition = !indicatorPlacedRef.current || !animate;
|
|
37
|
+
if (skipTransition) {
|
|
38
|
+
cancelAnimationFrame(transitionFrameRef.current);
|
|
39
|
+
indicator.style.transition = 'none';
|
|
40
|
+
}
|
|
41
|
+
indicator.style.height = `${itemHeight}px`;
|
|
42
|
+
indicator.style.transform = `translateY(${sidebarItemOffsetTop(root, activeItem)}px)`;
|
|
43
|
+
indicator.style.opacity = '1';
|
|
44
|
+
if (skipTransition) {
|
|
45
|
+
indicatorPlacedRef.current = true;
|
|
46
|
+
indicator.getBoundingClientRect();
|
|
47
|
+
transitionFrameRef.current = requestAnimationFrame(() => {
|
|
48
|
+
indicator.style.transition = '';
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
useLayoutEffect(() => {
|
|
53
|
+
const root = contentRef.current;
|
|
54
|
+
const indicator = indicatorRef.current;
|
|
55
|
+
if (!root || !indicator) {
|
|
56
|
+
if (indicator)
|
|
57
|
+
indicator.style.opacity = '0';
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!indicatorPlacedRef.current) {
|
|
61
|
+
updateActiveIndicator(false);
|
|
62
|
+
}
|
|
63
|
+
let frame = 0;
|
|
64
|
+
let nextFrame = 0;
|
|
65
|
+
const scheduleUpdate = () => {
|
|
66
|
+
cancelAnimationFrame(frame);
|
|
67
|
+
cancelAnimationFrame(nextFrame);
|
|
68
|
+
frame = requestAnimationFrame(() => {
|
|
69
|
+
nextFrame = requestAnimationFrame(() => updateActiveIndicator());
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
scheduleUpdate();
|
|
73
|
+
let resizeObserver = null;
|
|
74
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
75
|
+
resizeObserver = new ResizeObserver(scheduleUpdate);
|
|
76
|
+
resizeObserver.observe(root);
|
|
77
|
+
const activeItem = root.querySelector('[data-sidebar-active="true"]');
|
|
78
|
+
if (activeItem)
|
|
79
|
+
resizeObserver.observe(activeItem);
|
|
80
|
+
}
|
|
81
|
+
window.addEventListener('resize', scheduleUpdate);
|
|
82
|
+
return () => {
|
|
83
|
+
cancelAnimationFrame(frame);
|
|
84
|
+
cancelAnimationFrame(nextFrame);
|
|
85
|
+
cancelAnimationFrame(transitionFrameRef.current);
|
|
86
|
+
resizeObserver?.disconnect();
|
|
87
|
+
window.removeEventListener('resize', scheduleUpdate);
|
|
88
|
+
};
|
|
89
|
+
}, [activeKey, groups, updateActiveIndicator]);
|
|
90
|
+
return (_jsxs("aside", { ref: ref, className: cn('oui-app-sidebar', className), "data-side": side, "data-testid": testId, style: sidebarStyle, ...restProps, children: [header ? _jsx("div", { className: 'oui-app-sidebar-head', children: header }) : null, _jsx(ScrollArea, { type: 'auto', scrollbars: 'vertical', className: 'oui-app-sidebar-scroll', children: _jsxs("div", { ref: contentRef, className: 'oui-app-sidebar-content', children: [_jsx("div", { ref: indicatorRef, className: 'oui-app-sidebar-indicator' }), _jsx("div", { className: 'oui-app-sidebar-groups', children: groups.map((group, index) => (_jsxs("div", { className: 'oui-app-sidebar-group', children: [index > 0 ? (_jsx(Separator, { className: 'oui-app-sidebar-separator' })) : null, _jsx("nav", { className: 'oui-app-sidebar-nav', children: group.items.map((item) => (_jsx(AppSidebarNavItem, { item: item, onNavigate: onNavigate }, item.key))) })] }, group.key))) })] }) }), footer ? (_jsxs(_Fragment, { children: [_jsx(Separator, { className: 'oui-app-sidebar-footer-separator' }), _jsx("div", { className: 'oui-app-sidebar-footer', children: footer })] })) : null] }));
|
|
91
|
+
});
|
|
92
|
+
function sidebarItemOffsetTop(root, item) {
|
|
93
|
+
let top = 0;
|
|
94
|
+
let node = item;
|
|
95
|
+
while (node && node !== root) {
|
|
96
|
+
top += node.offsetTop;
|
|
97
|
+
node = node.offsetParent;
|
|
98
|
+
}
|
|
99
|
+
return node === root ? top : item.offsetTop;
|
|
100
|
+
}
|
|
101
|
+
function AppSidebarNavItem({ item, onNavigate, }) {
|
|
102
|
+
const content = (_jsxs(_Fragment, { children: [item.icon ? _jsx("span", { className: 'oui-app-sidebar-item-icon', children: item.icon }) : null, _jsx("span", { className: 'oui-app-sidebar-item-label', children: item.label })] }));
|
|
103
|
+
const commonProps = {
|
|
104
|
+
className: 'oui-app-sidebar-item',
|
|
105
|
+
'data-sidebar-active': item.active ? 'true' : undefined,
|
|
106
|
+
'aria-current': item.active ? 'page' : undefined,
|
|
107
|
+
onClick: () => {
|
|
108
|
+
item.onSelect?.();
|
|
109
|
+
onNavigate?.(item);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
if (item.href && !item.disabled) {
|
|
113
|
+
const LinkComponent = item.component ?? 'a';
|
|
114
|
+
return (_jsx(LinkComponent, { href: item.href, ...commonProps, children: content }));
|
|
115
|
+
}
|
|
116
|
+
return (_jsx("button", { type: 'button', disabled: item.disabled, ...commonProps, children: content }));
|
|
117
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import { type SystemProps, type
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
2
|
+
import { type SystemProps, type ToneInput, type UiSize } from '../../theme/systemProps';
|
|
3
3
|
export type BadgeProps = ComponentPropsWithoutRef<'span'> & SystemProps & {
|
|
4
|
-
tone?:
|
|
4
|
+
tone?: ToneInput;
|
|
5
5
|
size?: UiSize;
|
|
6
|
-
v?: 'soft' | 'solid' | 'outline';
|
|
6
|
+
v?: 'soft' | 'solid' | 'outline' | 'surface';
|
|
7
|
+
icon?: ReactNode;
|
|
7
8
|
testId?: string;
|
|
8
9
|
};
|
|
9
10
|
export declare const Badge: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & SystemProps & {
|
|
10
|
-
tone?:
|
|
11
|
+
tone?: ToneInput;
|
|
11
12
|
size?: UiSize;
|
|
12
|
-
v?: "soft" | "solid" | "outline";
|
|
13
|
+
v?: "soft" | "solid" | "outline" | "surface";
|
|
14
|
+
icon?: ReactNode;
|
|
13
15
|
testId?: string;
|
|
14
16
|
} & import("react").RefAttributes<HTMLSpanElement>>;
|
|
15
17
|
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,wBAAwB,EAAE,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAGhF,OAAO,EAEH,KAAK,WAAW,EAEhB,KAAK,SAAS,EACd,KAAK,MAAM,EAEd,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG,wBAAwB,CAAC,MAAM,CAAC,GACrD,WAAW,GAAG;IACV,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,KAAK;WAPH,SAAS;WACT,MAAM;QACT,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS;WACrC,SAAS;aACP,MAAM;mDAiCrB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { cn } from '../../utils/cn';
|
|
4
|
-
import { splitSystemProps, } from '../../theme/systemProps';
|
|
5
|
-
export const Badge = forwardRef(function Badge({ className, style, tone = 'neutral', size = 2, v = 'soft', testId, ...props }, ref) {
|
|
4
|
+
import { splitSystemProps, normalizeTone, } from '../../theme/systemProps';
|
|
5
|
+
export const Badge = forwardRef(function Badge({ className, style, tone = 'neutral', size = 2, v = 'soft', icon, testId, children, ...props }, ref) {
|
|
6
6
|
const { systemStyle, restProps } = splitSystemProps(props);
|
|
7
|
-
return (
|
|
7
|
+
return (_jsxs("span", { ref: ref, className: cn('oui-badge', className), "data-tone": normalizeTone(tone), "data-size": size, "data-variant": v, "data-testid": testId, style: { ...systemStyle, ...style }, ...restProps, children: [icon ? _jsx("span", { className: 'oui-badge-icon', children: icon }) : null, children] }));
|
|
8
8
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type SystemProps, type ToneInput, type UiSize } from '../../theme/systemProps';
|
|
3
|
+
export type BadgeSelectItem<V extends string = string> = {
|
|
4
|
+
value: V;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type BadgeSelectMenuProps<V extends string = string> = SystemProps & {
|
|
9
|
+
value: V | null;
|
|
10
|
+
items: ReadonlyArray<BadgeSelectItem<V>>;
|
|
11
|
+
onValueChange: (value: V) => void;
|
|
12
|
+
tone?: ToneInput;
|
|
13
|
+
width?: number | string;
|
|
14
|
+
maxHeight?: number;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
size?: UiSize;
|
|
17
|
+
badgeStyle?: CSSProperties;
|
|
18
|
+
className?: string;
|
|
19
|
+
testId?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function BadgeSelectMenu<V extends string = string>({ value, items, onValueChange, tone, width, maxHeight, disabled, size, badgeStyle, className, testId, ...props }: BadgeSelectMenuProps<V>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=BadgeSelectMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BadgeSelectMenu.d.ts","sourceRoot":"","sources":["../../../src/components/BadgeSelectMenu/BadgeSelectMenu.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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { LuCheck } from 'react-icons/lu';
|
|
5
|
+
import { Badge } from '../Badge/Badge';
|
|
6
|
+
import { Popover } from '../Popover/Popover';
|
|
7
|
+
import { splitSystemProps } from '../../theme/systemProps';
|
|
8
|
+
import { cn } from '../../utils/cn';
|
|
9
|
+
export function BadgeSelectMenu({ value, items, onValueChange, tone = 'neutral', width = 220, maxHeight = 280, disabled = false, size, badgeStyle, className, testId, ...props }) {
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
const [highlightedValue, setHighlightedValue] = useState(null);
|
|
12
|
+
const { systemStyle, restProps } = splitSystemProps(props);
|
|
13
|
+
const currentValue = value ?? items[0]?.value ?? null;
|
|
14
|
+
const currentItem = useMemo(() => items.find((item) => item.value === currentValue) ?? null, [currentValue, items]);
|
|
15
|
+
const currentLabel = currentItem?.label ?? currentValue;
|
|
16
|
+
const triggerBadge = (_jsx(Badge, { tone: tone, v: 'soft', r: 7, size: size, "data-state": open ? 'open' : 'closed', className: 'oui-badge-select-trigger', testId: testId, style: {
|
|
17
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
18
|
+
flexShrink: 0,
|
|
19
|
+
opacity: disabled ? 0.6 : 1,
|
|
20
|
+
...systemStyle,
|
|
21
|
+
...badgeStyle,
|
|
22
|
+
}, children: currentLabel }));
|
|
23
|
+
if (disabled) {
|
|
24
|
+
return triggerBadge;
|
|
25
|
+
}
|
|
26
|
+
return (_jsx(Popover, { open: open, onOpenChange: (nextOpen) => {
|
|
27
|
+
setOpen(nextOpen);
|
|
28
|
+
if (!nextOpen)
|
|
29
|
+
setHighlightedValue(null);
|
|
30
|
+
}, trigger: triggerBadge, className: cn('oui-select-content oui-badge-select-content', className), contentStyle: {
|
|
31
|
+
width,
|
|
32
|
+
maxWidth: 320,
|
|
33
|
+
}, sideOffset: 4, testId: testId ? `${testId}-menu` : undefined, ...restProps, children: _jsx("div", { className: 'oui-combobox-scroll oui-combobox-options oui-badge-select-options', style: { maxHeight }, children: items.map((item) => {
|
|
34
|
+
const isSelected = item.value === currentValue;
|
|
35
|
+
const isHighlighted = item.value === highlightedValue;
|
|
36
|
+
return (_jsxs("button", { type: 'button', className: 'oui-combobox-option oui-badge-select-option', "data-selected": isSelected ? 'true' : 'false', "data-highlighted": isHighlighted ? 'true' : 'false', disabled: item.disabled, onMouseEnter: () => {
|
|
37
|
+
if (!item.disabled)
|
|
38
|
+
setHighlightedValue(item.value);
|
|
39
|
+
}, onFocus: () => {
|
|
40
|
+
if (!item.disabled)
|
|
41
|
+
setHighlightedValue(item.value);
|
|
42
|
+
}, onClick: () => {
|
|
43
|
+
if (item.disabled)
|
|
44
|
+
return;
|
|
45
|
+
setOpen(false);
|
|
46
|
+
setHighlightedValue(null);
|
|
47
|
+
onValueChange(item.value);
|
|
48
|
+
}, children: [_jsx("span", { className: 'oui-combobox-option-main', children: item.label }), isSelected ? (_jsx(LuCheck, { className: 'oui-combobox-check', size: 15 })) : null] }, item.value));
|
|
49
|
+
}) }) }));
|
|
50
|
+
}
|
|
@@ -2,10 +2,12 @@ import { type ComponentPropsWithoutRef, type ElementType } from 'react';
|
|
|
2
2
|
import { type SystemProps } from '../../theme/systemProps';
|
|
3
3
|
export type BoxProps = ComponentPropsWithoutRef<'div'> & SystemProps & {
|
|
4
4
|
as?: ElementType;
|
|
5
|
+
asChild?: boolean;
|
|
5
6
|
testId?: string;
|
|
6
7
|
};
|
|
7
8
|
export declare const Box: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & SystemProps & {
|
|
8
9
|
as?: ElementType;
|
|
10
|
+
asChild?: boolean;
|
|
9
11
|
testId?: string;
|
|
10
12
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
11
13
|
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAEnB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAmB,KAAK,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAG3E,MAAM,MAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAClD,WAAW,GAAG;IACV,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,GAAG;SALH,WAAW;cACN,OAAO;aACR,MAAM;+CA8BrB,CAAC"}
|
|
@@ -2,7 +2,20 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef, } from 'react';
|
|
3
3
|
import { cn } from '../../utils/cn';
|
|
4
4
|
import { splitSystemProps } from '../../theme/systemProps';
|
|
5
|
-
|
|
5
|
+
import { renderSlot } from '../../utils/slot';
|
|
6
|
+
export const Box = forwardRef(function Box({ as: Component = 'div', asChild = false, className, style, testId, children, ...props }, ref) {
|
|
6
7
|
const { systemStyle, restProps } = splitSystemProps(props);
|
|
7
|
-
|
|
8
|
+
const commonProps = {
|
|
9
|
+
className: cn('oui-box', className),
|
|
10
|
+
'data-testid': testId,
|
|
11
|
+
style: { ...systemStyle, ...style },
|
|
12
|
+
...restProps,
|
|
13
|
+
};
|
|
14
|
+
if (asChild) {
|
|
15
|
+
return renderSlot(children, {
|
|
16
|
+
...commonProps,
|
|
17
|
+
ref: ref,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return (_jsx(Component, { ref: ref, ...commonProps, children: children }));
|
|
8
21
|
});
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import { type SystemProps, type
|
|
2
|
+
import { type SystemProps, type ToneInput, type UiSize } from '../../theme/systemProps';
|
|
3
3
|
import type { ButtonPressAnimation } from '../../theme/themeTypes';
|
|
4
4
|
export type ButtonVariant = 'solid' | 'soft' | 'surface' | 'pad' | 'ghost' | 'outline';
|
|
5
5
|
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & SystemProps & {
|
|
6
6
|
size?: UiSize;
|
|
7
7
|
v?: ButtonVariant;
|
|
8
|
-
tone?:
|
|
8
|
+
tone?: ToneInput;
|
|
9
9
|
loading?: boolean;
|
|
10
10
|
fullWidth?: boolean;
|
|
11
11
|
leftIcon?: ReactNode;
|
|
12
12
|
rightIcon?: ReactNode;
|
|
13
13
|
pressAnimation?: ButtonPressAnimation;
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
children?: ReactNode;
|
|
14
16
|
testId?: string;
|
|
15
17
|
};
|
|
16
18
|
export declare const Button: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & SystemProps & {
|
|
17
19
|
size?: UiSize;
|
|
18
20
|
v?: ButtonVariant;
|
|
19
|
-
tone?:
|
|
21
|
+
tone?: ToneInput;
|
|
20
22
|
loading?: boolean;
|
|
21
23
|
fullWidth?: boolean;
|
|
22
24
|
leftIcon?: ReactNode;
|
|
23
25
|
rightIcon?: ReactNode;
|
|
24
26
|
pressAnimation?: ButtonPressAnimation;
|
|
27
|
+
asChild?: boolean;
|
|
28
|
+
children?: ReactNode;
|
|
25
29
|
testId?: string;
|
|
26
30
|
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
27
31
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,oBAAoB,EAEzB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAGf,OAAO,EAEH,KAAK,WAAW,EAEhB,KAAK,SAAS,EACd,KAAK,MAAM,EAEd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAIjE,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,SAAS,CAAC;IACjB,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,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,eAAO,MAAM,MAAM;WAbJ,MAAM;QACT,aAAa;WACV,SAAS;cACN,OAAO;gBACL,OAAO;eACR,SAAS;gBACR,SAAS;qBACJ,oBAAoB;cAC3B,OAAO;eACN,SAAS;aACX,MAAM;qDA6DrB,CAAC"}
|
|
@@ -2,12 +2,32 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useContext, } from 'react';
|
|
4
4
|
import { cn } from '../../utils/cn';
|
|
5
|
-
import { splitSystemProps, } from '../../theme/systemProps';
|
|
5
|
+
import { splitSystemProps, normalizeTone, } from '../../theme/systemProps';
|
|
6
6
|
import { OrcestrThemeContext } from '../../theme/useTheme';
|
|
7
|
+
import { renderSlot } from '../../utils/slot';
|
|
7
8
|
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
|
+
export const Button = forwardRef(function Button({ className, style, size = 3, v = 'solid', tone = 'neutral', loading = false, fullWidth = false, leftIcon, rightIcon, pressAnimation, asChild = false, testId, children, disabled, type = 'button', ...props }, ref) {
|
|
9
10
|
const themeContext = useContext(OrcestrThemeContext);
|
|
10
11
|
const actualPressAnimation = pressAnimation ?? themeContext?.theme.motion.pressAnimation ?? 'soft';
|
|
11
12
|
const { systemStyle, restProps } = splitSystemProps(props);
|
|
12
|
-
|
|
13
|
+
const commonProps = {
|
|
14
|
+
className: cn('oui-button', fullWidth && 'oui-button-full', className),
|
|
15
|
+
'data-size': size,
|
|
16
|
+
'data-variant': v,
|
|
17
|
+
'data-tone': normalizeTone(tone),
|
|
18
|
+
'data-press-animation': actualPressAnimation,
|
|
19
|
+
'data-loading': loading ? 'true' : undefined,
|
|
20
|
+
'data-testid': testId,
|
|
21
|
+
'aria-busy': loading || undefined,
|
|
22
|
+
style: { ...systemStyle, ...style },
|
|
23
|
+
...restProps,
|
|
24
|
+
};
|
|
25
|
+
if (asChild) {
|
|
26
|
+
return renderSlot(children, {
|
|
27
|
+
...commonProps,
|
|
28
|
+
ref: ref,
|
|
29
|
+
'aria-disabled': disabled || loading ? true : undefined,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return (_jsxs("button", { ref: ref, type: type, ...commonProps, disabled: disabled || loading, children: [loading ? _jsx(Spinner, { size: 1 }) : leftIcon, _jsx("span", { className: 'oui-button-label', children: children }), rightIcon] }));
|
|
13
33
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType, type ReactNode } from 'react';
|
|
2
|
+
import { type SystemProps, type UiSize } from '../../theme/systemProps';
|
|
3
|
+
export type CardVariant = 'ghost' | 'surface' | 'soft' | 'classic';
|
|
4
|
+
export type CardProps<C extends ElementType = 'div'> = SystemProps & {
|
|
5
|
+
as?: C;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: ComponentPropsWithoutRef<'div'>['style'];
|
|
9
|
+
size?: UiSize;
|
|
10
|
+
v?: CardVariant;
|
|
11
|
+
interactive?: boolean;
|
|
12
|
+
asChild?: boolean;
|
|
13
|
+
testId?: string;
|
|
14
|
+
} & Omit<ComponentPropsWithoutRef<C>, keyof SystemProps | 'as' | 'children' | 'className' | 'style' | 'size'>;
|
|
15
|
+
export declare const Card: import("react").ForwardRefExoticComponent<SystemProps & {
|
|
16
|
+
as?: "div" | undefined;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: ComponentPropsWithoutRef<"div">["style"];
|
|
20
|
+
size?: UiSize;
|
|
21
|
+
v?: CardVariant;
|
|
22
|
+
interactive?: boolean;
|
|
23
|
+
asChild?: boolean;
|
|
24
|
+
testId?: string;
|
|
25
|
+
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SystemProps | "children" | "style" | "className" | "as"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
26
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAEhB,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAIxF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,IAAI,WAAW,GAAG;IACjE,EAAE,CAAC,EAAE,CAAC,CAAC;IACP,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,WAAW,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;AAE9G,eAAO,MAAM,IAAI;;eAVF,SAAS;gBACR,MAAM;YACV,wBAAwB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;WACzC,MAAM;QACT,WAAW;kBACD,OAAO;cACX,OAAO;aACR,MAAM;wOA6CjB,CAAC"}
|