@dxos/react-ui 0.8.4-main.e8ec1fe → 0.8.4-main.ef1bc66f44
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/lib/browser/chunk-EJYV4HAH.mjs +774 -0
- package/dist/lib/browser/chunk-EJYV4HAH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3197 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +34 -45
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-YTLZCZ2M.mjs +776 -0
- package/dist/lib/node-esm/chunk-YTLZCZ2M.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3197 -66
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +34 -45
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts +7 -0
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.d.ts +1 -1
- package/dist/types/src/components/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/Button/IconButton.d.ts +2 -1
- package/dist/types/src/components/Button/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Button/ToggleGroup.d.ts +4 -4
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts +4 -4
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts +24 -9
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +7 -5
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +5 -2
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +2 -2
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts +1 -1
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +8 -9
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Menus → Menu}/ContextMenu.d.ts +6 -6
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +1 -0
- package/dist/types/src/components/Menu/ContextMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/DropdownMenu.d.ts +3 -4
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -0
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/Menu/index.d.ts.map +1 -0
- package/dist/types/src/components/Message/Message.d.ts +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +25 -26
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +46 -8
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +4 -2
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +2 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts +9 -9
- package/dist/types/src/components/Separator/Separator.d.ts +1 -1
- package/dist/types/src/components/Skeleton/Skeleton.d.ts +12 -0
- package/dist/types/src/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/types/src/components/Skeleton/Skeleton.stories.d.ts +17 -0
- package/dist/types/src/components/Skeleton/Skeleton.stories.d.ts.map +1 -0
- package/dist/types/src/components/Skeleton/index.d.ts +2 -0
- package/dist/types/src/components/Skeleton/index.d.ts.map +1 -0
- package/dist/types/src/components/Splitter/Splitter.d.ts +26 -0
- package/dist/types/src/components/Splitter/Splitter.d.ts.map +1 -0
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts +7 -0
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts.map +1 -0
- package/dist/types/src/components/Splitter/index.d.ts +2 -0
- package/dist/types/src/components/Splitter/index.d.ts.map +1 -0
- package/dist/types/src/components/Tag/Tag.d.ts +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +2 -2
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -8
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts +2 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +4 -4
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +13 -12
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/exemplars/generics.stories.d.ts +17 -0
- package/dist/types/src/exemplars/generics.stories.d.ts.map +1 -0
- package/dist/types/src/exemplars/slot.stories.d.ts +14 -0
- package/dist/types/src/exemplars/slot.stories.d.ts.map +1 -0
- package/dist/types/src/exemplars/tabster.stories.d.ts +8 -0
- package/dist/types/src/exemplars/tabster.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/useDensityContext.d.ts +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Container/Container.d.ts +23 -0
- package/dist/types/src/primitives/Container/Container.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts +11 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Layout.d.ts +18 -0
- package/dist/types/src/primitives/Container/Layout.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Layout.stories.d.ts +10 -0
- package/dist/types/src/primitives/Container/Layout.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/index.d.ts +3 -0
- package/dist/types/src/primitives/Container/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/Flex.d.ts +8 -0
- package/dist/types/src/primitives/Flex/Flex.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/index.d.ts +2 -0
- package/dist/types/src/primitives/Flex/index.d.ts.map +1 -0
- package/dist/types/src/primitives/index.d.ts +3 -0
- package/dist/types/src/primitives/index.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withLayout.d.ts +3 -3
- package/dist/types/src/testing/decorators/withLayout.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts +1 -1
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withTheme.d.ts +3 -2
- package/dist/types/src/testing/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -2
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -32
- package/src/components/AnchoredOverflow/AnchoredOverflow.tsx +8 -0
- package/src/components/Avatars/Avatar.stories.tsx +4 -4
- package/src/components/Avatars/Avatar.tsx +1 -1
- package/src/components/Avatars/AvatarGroup.stories.tsx +2 -2
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +2 -2
- package/src/components/Button/Button.stories.tsx +2 -2
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/Button/IconButton.stories.tsx +2 -2
- package/src/components/Button/IconButton.tsx +8 -3
- package/src/components/Button/Toggle.stories.tsx +2 -2
- package/src/components/Button/ToggleGroup.stories.tsx +2 -2
- package/src/components/Clipboard/CopyButton.tsx +3 -3
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/Dialog/AlertDialog.stories.tsx +2 -2
- package/src/components/Dialog/Dialog.stories.tsx +57 -23
- package/src/components/Dialog/Dialog.tsx +181 -40
- package/src/components/ElevationProvider/ElevationProvider.tsx +1 -1
- package/src/components/Icon/Icon.stories.tsx +3 -3
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/Input/Input.stories.tsx +12 -11
- package/src/components/Input/Input.tsx +13 -5
- package/src/components/Link/Link.stories.tsx +2 -2
- package/src/components/List/List.stories.tsx +18 -14
- package/src/components/List/List.tsx +1 -1
- package/src/components/List/Tree.stories.tsx +2 -2
- package/src/components/List/Treegrid.stories.tsx +2 -2
- package/src/components/List/Treegrid.tsx +1 -1
- package/src/components/Main/Main.stories.tsx +41 -20
- package/src/components/Main/Main.tsx +92 -45
- package/src/components/{Menus → Menu}/ContextMenu.stories.tsx +2 -2
- package/src/components/{Menus → Menu}/DropdownMenu.stories.tsx +2 -2
- package/src/components/{Menus → Menu}/DropdownMenu.tsx +61 -57
- package/src/components/Message/Message.stories.tsx +3 -3
- package/src/components/Message/Message.tsx +30 -5
- package/src/components/Popover/Popover.stories.tsx +2 -2
- package/src/components/Popover/Popover.tsx +35 -33
- package/src/components/ScrollArea/ScrollArea.stories.tsx +166 -40
- package/src/components/ScrollArea/ScrollArea.tsx +86 -80
- package/src/components/ScrollArea/index.ts +1 -1
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +3 -2
- package/src/components/ScrollContainer/ScrollContainer.tsx +99 -92
- package/src/components/Select/Select.stories.tsx +2 -2
- package/src/components/Skeleton/Skeleton.stories.tsx +52 -0
- package/src/components/Skeleton/Skeleton.tsx +26 -0
- package/src/components/Skeleton/index.ts +5 -0
- package/src/components/Splitter/Splitter.stories.tsx +73 -0
- package/src/components/Splitter/Splitter.tsx +123 -0
- package/src/components/Splitter/index.ts +5 -0
- package/src/components/Status/Status.stories.tsx +2 -2
- package/src/components/Tag/Tag.stories.tsx +4 -4
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +2 -3
- package/src/components/ThemeProvider/TranslationsProvider.tsx +1 -16
- package/src/components/ThemeProvider/index.ts +3 -3
- package/src/components/Toast/Toast.stories.tsx +2 -2
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
- package/src/components/Toolbar/Toolbar.tsx +31 -12
- package/src/components/Tooltip/Tooltip.stories.tsx +2 -2
- package/src/components/Tooltip/Tooltip.tsx +22 -20
- package/src/components/index.ts +3 -1
- package/src/exemplars/generics.stories.tsx +44 -0
- package/src/exemplars/slot.stories.tsx +108 -0
- package/src/exemplars/tabster.stories.tsx +127 -0
- package/src/hooks/useDensityContext.ts +1 -1
- package/src/hooks/useElevationContext.ts +1 -1
- package/src/index.ts +2 -1
- package/src/playground/Controls.stories.tsx +3 -4
- package/src/playground/Custom.stories.tsx +2 -2
- package/src/playground/Typography.stories.tsx +2 -2
- package/src/primitives/Container/Container.stories.tsx +67 -0
- package/src/primitives/Container/Container.tsx +82 -0
- package/src/primitives/Container/Layout.stories.tsx +57 -0
- package/src/primitives/Container/Layout.tsx +61 -0
- package/src/primitives/Container/index.ts +6 -0
- package/src/primitives/Flex/Flex.tsx +26 -0
- package/src/primitives/Flex/index.ts +5 -0
- package/src/primitives/index.ts +6 -0
- package/src/testing/decorators/withLayout.tsx +22 -15
- package/src/testing/decorators/withLayoutVariants.tsx +3 -3
- package/src/testing/decorators/withTheme.tsx +21 -18
- package/src/util/index.ts +2 -2
- package/dist/lib/browser/chunk-53MI2QCM.mjs +0 -4707
- package/dist/lib/browser/chunk-53MI2QCM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ID67AFFF.mjs +0 -4709
- package/dist/lib/node-esm/chunk-ID67AFFF.mjs.map +0 -7
- package/dist/types/src/components/Menus/ContextMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/Menus/index.d.ts.map +0 -1
- package/dist/types/src/util/ThemedClassName.d.ts +0 -5
- package/dist/types/src/util/ThemedClassName.d.ts.map +0 -1
- package/dist/types/src/util/domino.d.ts +0 -18
- package/dist/types/src/util/domino.d.ts.map +0 -1
- package/src/util/ThemedClassName.ts +0 -7
- package/src/util/domino.ts +0 -53
- /package/dist/types/src/components/{Menus → Menu}/ContextMenu.stories.d.ts +0 -0
- /package/dist/types/src/components/{Menus → Menu}/DropdownMenu.stories.d.ts +0 -0
- /package/dist/types/src/components/{Menus → Menu}/index.d.ts +0 -0
- /package/src/components/{Menus → Menu}/ContextMenu.tsx +0 -0
- /package/src/components/{Menus → Menu}/index.ts +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Input } from '../../components';
|
|
9
|
+
import { withTheme } from '../../testing';
|
|
10
|
+
|
|
11
|
+
import { Container, type ContainerRootProps } from './Container';
|
|
12
|
+
|
|
13
|
+
const DefaultStory = (props: ContainerRootProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<div className='plb-2 is-[20rem] border border-separator rounded-sm'>
|
|
16
|
+
<Container.Root {...props}>
|
|
17
|
+
<Container.Column>
|
|
18
|
+
<Input.Root>
|
|
19
|
+
<Input.Label>Label</Input.Label>
|
|
20
|
+
<Input.TextInput />
|
|
21
|
+
</Input.Root>
|
|
22
|
+
</Container.Column>
|
|
23
|
+
</Container.Root>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const meta: Meta<typeof Container.Root> = {
|
|
29
|
+
title: 'ui/react-ui-core/primitives/Container',
|
|
30
|
+
component: Container.Root,
|
|
31
|
+
render: DefaultStory,
|
|
32
|
+
decorators: [withTheme()],
|
|
33
|
+
parameters: {
|
|
34
|
+
layout: 'centered',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
|
|
40
|
+
type Story = StoryObj<typeof meta>;
|
|
41
|
+
|
|
42
|
+
// TODO(burdon): Requires container.
|
|
43
|
+
export const Default = () => {
|
|
44
|
+
return (
|
|
45
|
+
<Container.Root>
|
|
46
|
+
<Container.Column>Column</Container.Column>
|
|
47
|
+
</Container.Root>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const SM: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
variant: 'sm',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const MD: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
variant: 'md',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const LG: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
variant: 'lg',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createContext } from '@radix-ui/react-context';
|
|
6
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
7
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
8
|
+
import React, { type PropsWithChildren, type Ref, forwardRef } from 'react';
|
|
9
|
+
|
|
10
|
+
import { type ColumnPadding } from '@dxos/ui-theme';
|
|
11
|
+
import { type SlottableProps } from '@dxos/ui-types';
|
|
12
|
+
|
|
13
|
+
import { useThemeContext } from '../../hooks';
|
|
14
|
+
|
|
15
|
+
// TODO(burdon): Replace Form, Container, Card spacing.
|
|
16
|
+
// TODO(burdon): Scrolling (reconcile with Mosaic Viewport).
|
|
17
|
+
// TODO(burdon): Reconcile AnchoredOverflow.
|
|
18
|
+
|
|
19
|
+
//
|
|
20
|
+
// Context
|
|
21
|
+
//
|
|
22
|
+
|
|
23
|
+
type ContainerContext = {
|
|
24
|
+
variant?: ColumnPadding;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const [ContainerProvider, useContext] = createContext<ContainerContext>('Container');
|
|
28
|
+
|
|
29
|
+
//
|
|
30
|
+
// Root
|
|
31
|
+
//
|
|
32
|
+
|
|
33
|
+
type RootProps = PropsWithChildren<Partial<ContainerContext>>;
|
|
34
|
+
|
|
35
|
+
const Root = ({ variant, children }: RootProps) => {
|
|
36
|
+
return <ContainerProvider {...{ variant }}>{children}</ContainerProvider>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//
|
|
40
|
+
// Column
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
const CONTAINER_COLUMN_NAME = 'Container.Column';
|
|
44
|
+
|
|
45
|
+
type ColumnProps = SlottableProps<HTMLDivElement> & { variant?: ColumnPadding };
|
|
46
|
+
|
|
47
|
+
const Column = forwardRef(
|
|
48
|
+
(
|
|
49
|
+
{ classNames, className, asChild, role = 'none', children, variant, ...props }: ColumnProps,
|
|
50
|
+
ref: Ref<HTMLDivElement>,
|
|
51
|
+
) => {
|
|
52
|
+
const { tx } = useThemeContext();
|
|
53
|
+
const Root = asChild ? Slot : Primitive.div;
|
|
54
|
+
const context = useContext(CONTAINER_COLUMN_NAME);
|
|
55
|
+
return (
|
|
56
|
+
<Root
|
|
57
|
+
{...props}
|
|
58
|
+
className={tx('container.column', 'container__column', { variant: variant ?? context.variant }, [
|
|
59
|
+
className,
|
|
60
|
+
classNames,
|
|
61
|
+
])}
|
|
62
|
+
role={role}
|
|
63
|
+
ref={ref}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</Root>
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
Column.displayName = CONTAINER_COLUMN_NAME;
|
|
72
|
+
|
|
73
|
+
//
|
|
74
|
+
// Container
|
|
75
|
+
//
|
|
76
|
+
|
|
77
|
+
export const Container = {
|
|
78
|
+
Root,
|
|
79
|
+
Column,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type { RootProps as ContainerRootProps, ColumnProps as ContainerColumnProps };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Input, ScrollArea, Toolbar } from '../../components';
|
|
9
|
+
import { withLayout, withTheme } from '../../testing';
|
|
10
|
+
|
|
11
|
+
import { Layout } from './Layout';
|
|
12
|
+
|
|
13
|
+
const DefaultStory = ({ count }: { count: number }) => {
|
|
14
|
+
return (
|
|
15
|
+
<Layout.Main toolbar statusbar>
|
|
16
|
+
<Toolbar.Root classNames='gap-2'>
|
|
17
|
+
<Toolbar.IconButton icon='ph--plus--regular' variant='primary' label='Add' />
|
|
18
|
+
<Input.Root>
|
|
19
|
+
<Input.TextInput placeholder='Search' />
|
|
20
|
+
</Input.Root>
|
|
21
|
+
<Toolbar.IconButton icon='ph--dots-three-vertical--regular' iconOnly label='Menu' />
|
|
22
|
+
</Toolbar.Root>
|
|
23
|
+
<ScrollArea.Root thin orientation='vertical'>
|
|
24
|
+
<ScrollArea.Viewport classNames='pli-2 plb-1 gap-1'>
|
|
25
|
+
{Array.from({ length: count }).map((_, index) => (
|
|
26
|
+
<div key={index} role='listitem' className='pli-2 plb-1 border border-separator'>
|
|
27
|
+
{index}
|
|
28
|
+
</div>
|
|
29
|
+
))}
|
|
30
|
+
</ScrollArea.Viewport>
|
|
31
|
+
</ScrollArea.Root>
|
|
32
|
+
<Toolbar.Root classNames='justify-between'>
|
|
33
|
+
<Toolbar.IconButton variant='ghost' icon='ph--house--regular' iconOnly label='Add' size={4} />
|
|
34
|
+
<Toolbar.IconButton variant='ghost' icon='ph--alarm--regular' iconOnly label='Status' size={4} />
|
|
35
|
+
</Toolbar.Root>
|
|
36
|
+
</Layout.Main>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const meta: Meta<typeof DefaultStory> = {
|
|
41
|
+
title: 'ui/react-ui-core/primitives/Layout',
|
|
42
|
+
component: DefaultStory,
|
|
43
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
44
|
+
parameters: {
|
|
45
|
+
layout: 'fullscreen',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const Default: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
count: 100,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren, forwardRef, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { mx } from '@dxos/ui-theme';
|
|
8
|
+
import { type ThemedClassName } from '@dxos/ui-types';
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
// Main
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
type MainProps = ThemedClassName<
|
|
15
|
+
PropsWithChildren<{
|
|
16
|
+
role?: string;
|
|
17
|
+
toolbar?: boolean;
|
|
18
|
+
statusbar?: boolean;
|
|
19
|
+
}>
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
const Main = forwardRef<HTMLDivElement, MainProps>(
|
|
23
|
+
({ classNames, children, role, toolbar, statusbar }, forwardedRef) => {
|
|
24
|
+
const style = useMemo(
|
|
25
|
+
() => ({
|
|
26
|
+
gridTemplateRows: [toolbar && 'var(--toolbar-size)', '1fr', statusbar && 'var(--statusbar-size)']
|
|
27
|
+
.filter(Boolean)
|
|
28
|
+
.join(' '),
|
|
29
|
+
}),
|
|
30
|
+
[toolbar, statusbar],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
ref={forwardedRef}
|
|
36
|
+
role={role ?? 'none'}
|
|
37
|
+
style={style}
|
|
38
|
+
className={mx(
|
|
39
|
+
'bs-full is-full grid grid-cols-[100%] overflow-hidden',
|
|
40
|
+
toolbar && [
|
|
41
|
+
'[.dx-main-mobile-layout_&>.dx-toolbar]:pli-3 [&>.dx-toolbar]:relative',
|
|
42
|
+
'[&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator',
|
|
43
|
+
],
|
|
44
|
+
classNames,
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
//
|
|
54
|
+
// Layout
|
|
55
|
+
//
|
|
56
|
+
|
|
57
|
+
export const Layout = {
|
|
58
|
+
Main,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type { MainProps as LayoutMainProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type HTMLAttributes } from 'react';
|
|
6
|
+
|
|
7
|
+
import { mx } from '@dxos/ui-theme';
|
|
8
|
+
import { type ThemedClassName } from '@dxos/ui-types';
|
|
9
|
+
|
|
10
|
+
export type FlexProps = ThemedClassName<
|
|
11
|
+
HTMLAttributes<HTMLDivElement> & {
|
|
12
|
+
column?: boolean;
|
|
13
|
+
grow?: boolean;
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export const Flex = ({ children, classNames, role, column, grow }: FlexProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
role={role ?? 'none'}
|
|
21
|
+
className={mx('flex', column && 'flex-col', grow && 'flex-1 overflow-hidden', classNames)}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -3,45 +3,52 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Decorator } from '@storybook/react';
|
|
6
|
-
import React, { type FC, type PropsWithChildren } from 'react';
|
|
6
|
+
import React, { type FC, type PropsWithChildren, memo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type ClassNameValue, type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
-
import { mx } from '@dxos/
|
|
9
|
+
import { mx } from '@dxos/ui-theme';
|
|
10
10
|
|
|
11
11
|
export type ContainerProps = ThemedClassName<PropsWithChildren>;
|
|
12
12
|
|
|
13
|
-
export type ContainerType = '
|
|
13
|
+
export type ContainerType = 'fullscreen' | 'column';
|
|
14
14
|
|
|
15
15
|
export type WithLayoutProps =
|
|
16
16
|
| FC<ContainerProps>
|
|
17
|
-
| {
|
|
17
|
+
| {
|
|
18
|
+
classNames?: ClassNameValue;
|
|
19
|
+
layout?: ContainerType;
|
|
20
|
+
scroll?: boolean;
|
|
21
|
+
};
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Adds layout container.
|
|
21
25
|
*/
|
|
22
26
|
export const withLayout =
|
|
23
|
-
(props: WithLayoutProps): Decorator =>
|
|
27
|
+
(props: WithLayoutProps = {}): Decorator =>
|
|
24
28
|
(Story) => {
|
|
29
|
+
// Prevent re-rendering of the story.
|
|
30
|
+
const MemoizedStory = memo(Story);
|
|
25
31
|
if (typeof props === 'function') {
|
|
26
32
|
const Container = props;
|
|
27
33
|
return (
|
|
28
34
|
<Container>
|
|
29
|
-
<
|
|
35
|
+
<MemoizedStory />
|
|
36
|
+
</Container>
|
|
37
|
+
);
|
|
38
|
+
} else {
|
|
39
|
+
const { layout = 'fullscreen', classNames, scroll } = props;
|
|
40
|
+
const Container = layouts[layout] ?? layouts.fullscreen;
|
|
41
|
+
return (
|
|
42
|
+
<Container classNames={mx(classNames, scroll ? 'overflow-y-auto' : 'overflow-hidden')}>
|
|
43
|
+
<MemoizedStory />
|
|
30
44
|
</Container>
|
|
31
45
|
);
|
|
32
46
|
}
|
|
33
|
-
|
|
34
|
-
const Container = layouts[(props as any).container as ContainerType] ?? layouts.default;
|
|
35
|
-
return (
|
|
36
|
-
<Container classNames={mx(props.classNames, props.scroll ? 'overflow-y-auto' : 'overflow-hidden')}>
|
|
37
|
-
<Story />
|
|
38
|
-
</Container>
|
|
39
|
-
);
|
|
40
47
|
};
|
|
41
48
|
|
|
42
49
|
const layouts: Record<ContainerType, FC<ContainerProps>> = {
|
|
43
|
-
|
|
44
|
-
<div role='none' className={mx(classNames)}>
|
|
50
|
+
fullscreen: ({ children, classNames }: ContainerProps) => (
|
|
51
|
+
<div role='none' className={mx('fixed inset-0 flex overflow-hidden bg-deckSurface', classNames)}>
|
|
45
52
|
{children}
|
|
46
53
|
</div>
|
|
47
54
|
),
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { type Decorator } from '@storybook/react';
|
|
6
6
|
import React, { type ComponentType, type PropsWithChildren } from 'react';
|
|
7
7
|
|
|
8
|
-
import { mx, surfaceShadow } from '@dxos/
|
|
9
|
-
import { type Density, type Elevation } from '@dxos/
|
|
8
|
+
import { mx, surfaceShadow } from '@dxos/ui-theme';
|
|
9
|
+
import { type Density, type Elevation } from '@dxos/ui-types';
|
|
10
10
|
|
|
11
11
|
type Config = {
|
|
12
12
|
elevations?: { elevation: Elevation; surface?: string }[];
|
|
@@ -14,7 +14,7 @@ type Config = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const Container = ({ children, elevation, surface }: PropsWithChildren<{ elevation: Elevation; surface?: string }>) => (
|
|
17
|
-
<div className={mx('rounded-md border border-separator
|
|
17
|
+
<div className={mx('rounded-md border border-separator', surface, surfaceShadow({ elevation }))}>{children}</div>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const Panel = ({
|
|
@@ -5,27 +5,30 @@
|
|
|
5
5
|
import { type Decorator } from '@storybook/react';
|
|
6
6
|
import React, { memo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { defaultTx } from '@dxos/
|
|
8
|
+
import { defaultTx } from '@dxos/ui-theme';
|
|
9
|
+
import { type ThemeMode } from '@dxos/ui-types';
|
|
9
10
|
|
|
10
|
-
import { type
|
|
11
|
+
import { type ThemeContextValue, ThemeProvider, Tooltip } from '../../components';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* Adds theme decorator
|
|
14
|
+
* Adds theme decorator.
|
|
14
15
|
*/
|
|
15
|
-
export const withTheme
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
export const withTheme =
|
|
17
|
+
({ tx = defaultTx, ...props }: Partial<ThemeContextValue> = {}): Decorator =>
|
|
18
|
+
(Story, context) => {
|
|
19
|
+
const {
|
|
20
|
+
globals: { theme },
|
|
21
|
+
parameters: { translations },
|
|
22
|
+
} = context;
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
// Prevent re-rendering of the story.
|
|
25
|
+
const MemoizedStory = memo(Story);
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
27
|
+
return (
|
|
28
|
+
<ThemeProvider {...props} tx={tx} themeMode={theme as ThemeMode} resourceExtensions={translations} noCache>
|
|
29
|
+
<Tooltip.Provider>
|
|
30
|
+
<MemoizedStory />
|
|
31
|
+
</Tooltip.Provider>
|
|
32
|
+
</ThemeProvider>
|
|
33
|
+
);
|
|
34
|
+
};
|