@dxos/react-ui 0.8.4-main.d05673bc65 → 0.8.4-main.dfabb4ec29
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-2FKSMWNY.mjs → chunk-BDBC6H6V.mjs} +79 -5
- package/dist/lib/browser/chunk-BDBC6H6V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +949 -758
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +30 -24
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/translations.mjs +18 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZNBLTSHI.mjs → chunk-3JSJK2ZY.mjs} +79 -5
- package/dist/lib/node-esm/chunk-3JSJK2ZY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +949 -758
- 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 +30 -24
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/translations.mjs +20 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/Avatars/Avatar.d.ts +1 -1
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.d.ts +2 -2
- package/dist/types/src/components/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.stories.d.ts +1 -1
- package/dist/types/src/components/Button/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/IconButton.d.ts +1 -0
- package/dist/types/src/components/Button/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Button/IconButton.stories.d.ts +3 -0
- package/dist/types/src/components/Button/IconButton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/Toggle.d.ts +2 -2
- package/dist/types/src/components/Button/Toggle.d.ts.map +1 -1
- package/dist/types/src/components/Button/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/ToggleGroup.d.ts +6 -6
- package/dist/types/src/components/Button/ToggleGroup.d.ts.map +1 -1
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts +2 -2
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.d.ts +68 -51
- package/dist/types/src/components/Card/Card.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.stories.d.ts +2 -2
- package/dist/types/src/components/Card/Card.stories.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/index.d.ts +10 -1
- package/dist/types/src/components/Clipboard/index.d.ts.map +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.d.ts +42 -31
- package/dist/types/src/components/Dialog/AlertDialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts +47 -30
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +3 -2
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/ErrorFallback/ErrorFallback.d.ts.map +1 -1
- package/dist/types/src/components/ErrorFallback/ErrorFallback.stories.d.ts.map +1 -1
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts +14 -3
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts.map +1 -1
- package/dist/types/src/components/ErrorFallback/ThrowError.d.ts.map +1 -1
- package/dist/types/src/components/Focus/Focus.d.ts +36 -0
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.stories.d.ts +9 -0
- package/dist/types/src/components/Focus/Focus.stories.d.ts.map +1 -0
- package/dist/types/src/components/Focus/index.d.ts +2 -0
- package/dist/types/src/components/Focus/index.d.ts.map +1 -0
- package/dist/types/src/components/Icon/Icon.d.ts +4 -0
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.stories.d.ts +11 -3
- package/dist/types/src/components/Icon/Icon.stories.d.ts.map +1 -1
- package/dist/types/src/components/Image/Image.d.ts +2 -1
- package/dist/types/src/components/Image/Image.d.ts.map +1 -1
- package/dist/types/src/components/Image/Image.stories.d.ts +3 -2
- package/dist/types/src/components/Image/Image.stories.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +14 -17
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +3 -3
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Link/Link.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts +5 -3
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/List.stories.d.ts +3 -1
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/ListDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/List/Tree.d.ts +2 -2
- package/dist/types/src/components/List/Tree.d.ts.map +1 -1
- package/dist/types/src/components/List/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/TreeDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/List/Treegrid.d.ts +5 -9
- package/dist/types/src/components/List/Treegrid.d.ts.map +1 -1
- package/dist/types/src/components/List/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +7 -3
- 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/Main/useSwipeToDismiss.d.ts.map +1 -1
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menu/ContextMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menu/DropdownMenu.d.ts +58 -49
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts +14 -1
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts.map +1 -1
- 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 +2 -2
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +38 -22
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +12 -9
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +18 -5
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +42 -13
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +5 -6
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +2 -2
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Separator/Separator.d.ts +3 -3
- package/dist/types/src/components/Separator/Separator.d.ts.map +1 -1
- package/dist/types/src/components/Skeleton/Skeleton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Splitter/Splitter.d.ts +19 -17
- package/dist/types/src/components/Splitter/Splitter.d.ts.map +1 -1
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.d.ts +3 -4
- package/dist/types/src/components/Status/Status.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +54 -55
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +16 -16
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +11 -19
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +10 -10
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +2 -2
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/exemplars/generics.stories.d.ts +6 -5
- package/dist/types/src/exemplars/generics.stories.d.ts.map +1 -1
- package/dist/types/src/exemplars/slot.stories.d.ts +1 -0
- package/dist/types/src/exemplars/slot.stories.d.ts.map +1 -1
- package/dist/types/src/exemplars/tabster.stories.d.ts.map +1 -1
- package/dist/types/src/exemplars/virtualizer.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/src/hooks/useIconHref.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeArea.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeCollisionPadding.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisualViewport.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Column/Column.d.ts +21 -14
- package/dist/types/src/primitives/Column/Column.d.ts.map +1 -1
- package/dist/types/src/primitives/Column/Column.stories.d.ts +19 -0
- package/dist/types/src/primitives/Column/Column.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Container/Container.d.ts +4 -5
- package/dist/types/src/primitives/Container/Container.d.ts.map +1 -1
- package/dist/types/src/primitives/Container/Container.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Flex/Flex.d.ts +5 -7
- package/dist/types/src/primitives/Flex/Flex.d.ts.map +1 -1
- package/dist/types/src/primitives/Flex/Flex.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Grid/Grid.d.ts +3 -8
- package/dist/types/src/primitives/Grid/Grid.d.ts.map +1 -1
- package/dist/types/src/primitives/Grid/Grid.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Panel/Panel.d.ts +24 -15
- package/dist/types/src/primitives/Panel/Panel.d.ts.map +1 -1
- package/dist/types/src/primitives/Panel/Panel.stories.d.ts.map +1 -1
- package/dist/types/src/testing/Loading.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayout.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withTheme.d.ts +1 -1
- package/dist/types/src/testing/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/usePx.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -25
- package/src/components/Avatars/Avatar.stories.tsx +2 -3
- package/src/components/Avatars/Avatar.tsx +1 -2
- package/src/components/Avatars/AvatarGroup.stories.tsx +0 -1
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -2
- package/src/components/Button/Button.stories.tsx +0 -1
- package/src/components/Button/Button.tsx +5 -13
- package/src/components/Button/IconButton.stories.tsx +6 -4
- package/src/components/Button/IconButton.tsx +3 -4
- package/src/components/Button/Toggle.stories.tsx +0 -1
- package/src/components/Button/Toggle.tsx +4 -4
- package/src/components/Button/ToggleGroup.stories.tsx +0 -1
- package/src/components/Button/ToggleGroup.tsx +12 -16
- package/src/components/Card/Card.stories.tsx +15 -15
- package/src/components/Card/Card.tsx +280 -115
- package/src/components/Clipboard/CopyButton.tsx +5 -6
- package/src/components/Dialog/AlertDialog.stories.tsx +5 -6
- package/src/components/Dialog/AlertDialog.tsx +67 -126
- package/src/components/Dialog/Dialog.stories.tsx +64 -9
- package/src/components/Dialog/Dialog.tsx +84 -88
- package/src/components/ErrorFallback/ErrorFallback.stories.tsx +3 -8
- package/src/components/ErrorFallback/ErrorStack.tsx +36 -2
- package/src/components/Focus/AUDIT.md +43 -0
- package/src/components/Focus/Focus.stories.tsx +230 -0
- package/src/components/Focus/Focus.tsx +201 -0
- package/src/components/Focus/index.ts +5 -0
- package/src/components/Icon/Icon.stories.tsx +43 -13
- package/src/components/Icon/Icon.tsx +14 -3
- package/src/components/Image/Image.stories.tsx +3 -3
- package/src/components/Image/Image.tsx +31 -8
- package/src/components/Input/Input.stories.tsx +3 -4
- package/src/components/Input/Input.tsx +7 -7
- package/src/components/Link/Link.stories.tsx +0 -1
- package/src/components/List/List.stories.tsx +1 -2
- package/src/components/List/List.tsx +7 -6
- package/src/components/List/ListDropIndicator.tsx +0 -1
- package/src/components/List/Tree.stories.tsx +2 -3
- package/src/components/List/Tree.tsx +0 -1
- package/src/components/List/Treegrid.stories.tsx +26 -27
- package/src/components/List/Treegrid.tsx +14 -14
- package/src/components/Main/Main.stories.tsx +0 -1
- package/src/components/Main/Main.tsx +1 -2
- package/src/components/Menu/ContextMenu.stories.tsx +0 -1
- package/src/components/Menu/DropdownMenu.stories.tsx +0 -1
- package/src/components/Menu/DropdownMenu.tsx +48 -42
- package/src/components/Message/Message.stories.tsx +7 -8
- package/src/components/Message/Message.tsx +23 -10
- package/src/components/Popover/Popover.stories.tsx +4 -5
- package/src/components/Popover/Popover.tsx +42 -42
- package/src/components/ScrollArea/ScrollArea.stories.tsx +89 -30
- package/src/components/ScrollArea/ScrollArea.tsx +39 -23
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +20 -18
- package/src/components/ScrollContainer/ScrollContainer.tsx +199 -92
- package/src/components/Select/Select.stories.tsx +5 -6
- package/src/components/Separator/Separator.tsx +4 -7
- package/src/components/Skeleton/Skeleton.stories.tsx +0 -1
- package/src/components/Splitter/Splitter.stories.tsx +29 -29
- package/src/components/Splitter/Splitter.tsx +35 -34
- package/src/components/Status/Status.stories.tsx +0 -1
- package/src/components/Status/Status.tsx +8 -5
- package/src/components/Tag/Tag.stories.tsx +0 -1
- package/src/components/ThemeProvider/ThemeProvider.stories.tsx +0 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +5 -4
- package/src/components/ThemeProvider/index.ts +1 -1
- package/src/components/Toast/Toast.stories.tsx +0 -1
- package/src/components/Toast/Toast.tsx +16 -31
- package/src/components/Toolbar/Toolbar.stories.tsx +0 -1
- package/src/components/Toolbar/Toolbar.tsx +21 -35
- package/src/components/Tooltip/Tooltip.stories.tsx +7 -8
- package/src/components/Tooltip/Tooltip.tsx +15 -16
- package/src/components/index.ts +1 -0
- package/src/exemplars/generics.stories.tsx +7 -15
- package/src/exemplars/slot.stories.tsx +65 -57
- package/src/exemplars/tabster.stories.tsx +1 -1
- package/src/exemplars/virtualizer.stories.tsx +4 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDensityContext.ts +2 -2
- package/src/playground/Custom.stories.tsx +6 -9
- package/src/primitives/Column/AUDIT.md +148 -0
- package/src/primitives/Column/Column.stories.tsx +122 -19
- package/src/primitives/Column/Column.tsx +73 -42
- package/src/primitives/Container/Container.stories.tsx +0 -1
- package/src/primitives/Container/Container.tsx +5 -8
- package/src/primitives/Flex/Flex.stories.tsx +0 -1
- package/src/primitives/Flex/Flex.tsx +10 -12
- package/src/primitives/Grid/Grid.stories.tsx +0 -1
- package/src/primitives/Grid/Grid.tsx +4 -9
- package/src/primitives/Panel/Panel.stories.tsx +9 -8
- package/src/primitives/Panel/Panel.tsx +64 -63
- package/src/testing/Loading.tsx +25 -4
- package/src/testing/decorators/withLayout.tsx +7 -17
- package/src/testing/decorators/withTheme.tsx +10 -7
- package/src/translations.ts +3 -3
- package/src/util/usePx.ts +1 -0
- package/dist/lib/browser/chunk-2FKSMWNY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZNBLTSHI.mjs.map +0 -7
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React
|
|
6
|
+
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { slottable } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
10
|
import { withTheme } from '../testing';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Generic component pattern using the slottable factory.
|
|
14
|
+
*/
|
|
15
|
+
const Component = slottable<HTMLDivElement>(({ children, ...props }, forwardedRef) => {
|
|
13
16
|
return (
|
|
14
17
|
<div {...props} ref={forwardedRef}>
|
|
15
18
|
{children}
|
|
@@ -17,21 +20,10 @@ const ComponentInner = forwardRef<HTMLDivElement, ComponentProps>(({ children, .
|
|
|
17
20
|
);
|
|
18
21
|
});
|
|
19
22
|
|
|
20
|
-
ComponentInner.displayName = 'Component';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Generic component pattern.
|
|
24
|
-
*/
|
|
25
|
-
type ComponentProps<P extends HTMLElement = any> = SlottableProps<P>;
|
|
26
|
-
|
|
27
|
-
const Component = ComponentInner as <P extends HTMLElement>(
|
|
28
|
-
props: SlottableProps<P> & { ref?: Ref<P> },
|
|
29
|
-
) => ReactElement;
|
|
30
|
-
|
|
31
23
|
const meta = {
|
|
32
24
|
title: 'ui/react-ui-core/exemplars/generics',
|
|
33
25
|
component: Component,
|
|
34
|
-
render: (props) => <Component
|
|
26
|
+
render: (props) => <Component {...props} />,
|
|
35
27
|
decorators: [withTheme()],
|
|
36
28
|
parameters: {
|
|
37
29
|
layout: 'centered',
|
|
@@ -3,84 +3,64 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
6
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
6
7
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
|
-
import React, {
|
|
8
|
+
import React, { PropsWithChildren } from 'react';
|
|
8
9
|
|
|
9
|
-
import { composableProps } from '@dxos/ui-theme';
|
|
10
|
-
import { type ComposableProps, type SlottableProps, type ThemedClassName } from '@dxos/ui-types';
|
|
10
|
+
import { composable, composableProps, mx, slottable } from '@dxos/ui-theme';
|
|
11
11
|
|
|
12
12
|
import { withTheme } from '../testing';
|
|
13
|
-
import {
|
|
13
|
+
import { ThemedClassName } from '../util';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Radix-style composition.
|
|
18
17
|
* All Radix primitive parts that render a DOM element accept an asChild prop.
|
|
19
|
-
* When asChild is set to true, Radix will not render a default DOM element,
|
|
18
|
+
* When asChild is set to true, Radix will not render a default DOM element,
|
|
19
|
+
* instead cloning the part's child and passing it the props and behavior required to make it functional.
|
|
20
20
|
* https://www.radix-ui.com/primitives/docs/guides/composition
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
const Outer =
|
|
24
|
-
({ children, asChild, ...props }, forwardedRef) => {
|
|
23
|
+
const Outer = slottable<HTMLDivElement, { priority?: number }>(
|
|
24
|
+
({ children, asChild, priority, ...props }, forwardedRef) => {
|
|
25
25
|
const Comp = asChild ? Slot : Primitive.div;
|
|
26
26
|
return (
|
|
27
|
-
<Comp
|
|
27
|
+
<Comp
|
|
28
|
+
{...composableProps<HTMLDivElement>(props, { classNames: 'p-2 border border-red-500 rounded' })}
|
|
29
|
+
ref={forwardedRef}
|
|
30
|
+
>
|
|
28
31
|
{children}
|
|
29
32
|
</Comp>
|
|
30
33
|
);
|
|
31
34
|
},
|
|
32
35
|
);
|
|
33
36
|
|
|
34
|
-
const Middle =
|
|
35
|
-
|
|
36
|
-
const Comp = asChild ? Slot : Primitive.div;
|
|
37
|
-
return (
|
|
38
|
-
<Comp {...composableProps<HTMLDivElement>(props, { role: 'none' })} ref={forwardedRef}>
|
|
39
|
-
{children}
|
|
40
|
-
</Comp>
|
|
41
|
-
);
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const Leaf = forwardRef<HTMLButtonElement, ComposableProps<HTMLButtonElement>>(
|
|
46
|
-
({ children, ...props }, forwardedRef) => {
|
|
47
|
-
return (
|
|
48
|
-
<button {...composableProps<HTMLButtonElement>(props, { role: 'none' })} ref={forwardedRef}>
|
|
49
|
-
{children}
|
|
50
|
-
</button>
|
|
51
|
-
);
|
|
52
|
-
},
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const TestSingle = (props: ThemedClassName<{ role?: string }>) => {
|
|
37
|
+
const Middle = slottable<HTMLDivElement>(({ children, asChild, ...props }, forwardedRef) => {
|
|
38
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
56
39
|
return (
|
|
57
|
-
<
|
|
58
|
-
<
|
|
59
|
-
|
|
40
|
+
<Comp
|
|
41
|
+
{...composableProps<HTMLDivElement>(props, { classNames: 'p-2 border border-red-500 rounded' })}
|
|
42
|
+
ref={forwardedRef}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</Comp>
|
|
60
46
|
);
|
|
61
|
-
};
|
|
47
|
+
});
|
|
62
48
|
|
|
63
|
-
const
|
|
49
|
+
const Leaf = composable<HTMLButtonElement>(({ children, ...props }, forwardedRef) => {
|
|
64
50
|
return (
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
51
|
+
<button
|
|
52
|
+
{...composableProps<HTMLButtonElement>(props, { classNames: 'p-2 border border-red-500 rounded' })}
|
|
53
|
+
ref={forwardedRef}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</button>
|
|
70
57
|
);
|
|
71
|
-
};
|
|
58
|
+
});
|
|
72
59
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<Leaf>
|
|
78
|
-
<div role='none'>Leaf</div>
|
|
79
|
-
</Leaf>
|
|
80
|
-
</Middle>
|
|
81
|
-
</Outer>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
60
|
+
/** This isn't a valid child for a `slottable` component. */
|
|
61
|
+
const Simple = ({ children, classNames }: ThemedClassName<PropsWithChildren>) => (
|
|
62
|
+
<div className={mx(classNames)}>{children}</div>
|
|
63
|
+
);
|
|
84
64
|
|
|
85
65
|
const meta = {
|
|
86
66
|
title: 'ui/react-ui-core/exemplars/slot',
|
|
@@ -95,13 +75,41 @@ export default meta;
|
|
|
95
75
|
type Story = StoryObj<typeof meta>;
|
|
96
76
|
|
|
97
77
|
export const Single: Story = {
|
|
98
|
-
render: () =>
|
|
78
|
+
render: () => (
|
|
79
|
+
<Outer asChild role='article' classNames='border-green-500' priority={1}>
|
|
80
|
+
<Leaf>Single asChild (non-compliant — see console)</Leaf>
|
|
81
|
+
</Outer>
|
|
82
|
+
),
|
|
99
83
|
};
|
|
100
84
|
|
|
101
85
|
export const Nested: Story = {
|
|
102
|
-
render: () =>
|
|
86
|
+
render: () => (
|
|
87
|
+
<Outer asChild role='article' classNames='border-blue-500'>
|
|
88
|
+
<Middle asChild>
|
|
89
|
+
<Leaf>Nested asChild</Leaf>
|
|
90
|
+
</Middle>
|
|
91
|
+
</Outer>
|
|
92
|
+
),
|
|
103
93
|
};
|
|
104
94
|
|
|
105
95
|
export const Inner: Story = {
|
|
106
|
-
render: () =>
|
|
96
|
+
render: () => (
|
|
97
|
+
<Outer asChild role='article' classNames='border-orange-500'>
|
|
98
|
+
<Middle asChild>
|
|
99
|
+
<Leaf>
|
|
100
|
+
<div>Leaf</div>
|
|
101
|
+
</Leaf>
|
|
102
|
+
</Middle>
|
|
103
|
+
</Outer>
|
|
104
|
+
),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const Error: Story = {
|
|
108
|
+
render: () => (
|
|
109
|
+
<Outer asChild role='none' classNames='p-2 border border-green-500 rounded'>
|
|
110
|
+
<Middle asChild>
|
|
111
|
+
<Simple>Simple</Simple>
|
|
112
|
+
</Middle>
|
|
113
|
+
</Outer>
|
|
114
|
+
),
|
|
107
115
|
};
|
|
@@ -43,7 +43,7 @@ const Column = forwardRef<HTMLDivElement, { items: string[] }>(({ items }, ref)
|
|
|
43
43
|
const tabsterAttrs = useMergedTabsterAttributes_unstable(focusableGroupAttrs, arrowNavigationAttrs);
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
|
-
<ScrollArea.Root
|
|
46
|
+
<ScrollArea.Root orientation='vertical' classNames={mx('w-[25rem]', border)}>
|
|
47
47
|
<ScrollArea.Viewport {...tabsterAttrs} classNames='p-4 gap-4' ref={ref}>
|
|
48
48
|
{items.map((item) => (
|
|
49
49
|
<Item key={item} value={item} />
|
|
@@ -6,11 +6,11 @@ import { type Meta } from '@storybook/react-vite';
|
|
|
6
6
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
7
7
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { random } from '@dxos/random';
|
|
10
10
|
import { Panel, ScrollArea, Toolbar } from '@dxos/react-ui';
|
|
11
11
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
random.seed(999);
|
|
14
14
|
|
|
15
15
|
type TestItem = {
|
|
16
16
|
name: string;
|
|
@@ -37,7 +37,7 @@ export const Default = {
|
|
|
37
37
|
const items = useMemo<TestItem[]>(
|
|
38
38
|
() =>
|
|
39
39
|
Array.from({ length: NUM_ITEMS }, () => ({
|
|
40
|
-
name:
|
|
40
|
+
name: random.lorem.paragraph(),
|
|
41
41
|
})),
|
|
42
42
|
[],
|
|
43
43
|
);
|
|
@@ -63,10 +63,9 @@ export const Default = {
|
|
|
63
63
|
<ScrollToolbar items={items} index={index} setIndex={setIndex} />
|
|
64
64
|
</Panel.Toolbar>
|
|
65
65
|
<Panel.Content asChild>
|
|
66
|
-
<ScrollArea.Root orientation='vertical'
|
|
66
|
+
<ScrollArea.Root orientation='vertical' centered>
|
|
67
67
|
<ScrollArea.Viewport classNames='p-2' ref={setViewport}>
|
|
68
68
|
<div
|
|
69
|
-
role='none'
|
|
70
69
|
style={{
|
|
71
70
|
position: 'relative',
|
|
72
71
|
height: virtualizer.getTotalSize(),
|
package/src/hooks/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './useDensityContext';
|
|
|
6
6
|
export * from './useElevationContext';
|
|
7
7
|
export * from './useIconHref';
|
|
8
8
|
export * from './useSafeArea';
|
|
9
|
+
export * from './useSafeCollisionPadding';
|
|
9
10
|
export * from './useTranslationsContext';
|
|
10
11
|
export * from './useThemeContext';
|
|
11
12
|
export * from './useVisualViewport';
|
|
@@ -8,7 +8,7 @@ import { type Density } from '@dxos/ui-types';
|
|
|
8
8
|
|
|
9
9
|
import { DensityContext } from '../components';
|
|
10
10
|
|
|
11
|
-
export const useDensityContext = (
|
|
11
|
+
export const useDensityContext = (densityProp?: Density): Density | undefined => {
|
|
12
12
|
const { density } = useContext(DensityContext);
|
|
13
|
-
return
|
|
13
|
+
return densityProp ?? density;
|
|
14
14
|
};
|
|
@@ -20,15 +20,14 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
20
20
|
</Button>
|
|
21
21
|
</div>
|
|
22
22
|
<div className='flex justify-center'>
|
|
23
|
-
<IconButton {...args} label='Test' icon='ph--
|
|
23
|
+
<IconButton {...args} label='Test' icon='ph--circle--regular' density='coarse' />
|
|
24
24
|
</div>
|
|
25
25
|
<div className='flex justify-center'>
|
|
26
26
|
<IconButton
|
|
27
27
|
{...args}
|
|
28
28
|
label='Test'
|
|
29
|
-
icon='ph--
|
|
29
|
+
icon='ph--circle--regular'
|
|
30
30
|
iconOnly
|
|
31
|
-
size={7}
|
|
32
31
|
density='coarse'
|
|
33
32
|
classNames='px-1.5'
|
|
34
33
|
/>
|
|
@@ -43,13 +42,13 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
43
42
|
</Button>
|
|
44
43
|
</div>
|
|
45
44
|
<div className='flex justify-center'>
|
|
46
|
-
<IconButton {...args} label='Test' icon='ph--
|
|
45
|
+
<IconButton {...args} label='Test' icon='ph--circle--regular' density='fine' classNames='px-2' />
|
|
47
46
|
</div>
|
|
48
47
|
<div className='flex justify-center'>
|
|
49
48
|
<IconButton
|
|
50
49
|
{...args}
|
|
51
50
|
label='Test'
|
|
52
|
-
icon='ph--
|
|
51
|
+
icon='ph--circle--regular'
|
|
53
52
|
iconOnly
|
|
54
53
|
density='fine'
|
|
55
54
|
classNames='py-1 px-1.5'
|
|
@@ -68,9 +67,8 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
68
67
|
<IconButton
|
|
69
68
|
{...args}
|
|
70
69
|
label='Test'
|
|
71
|
-
icon='ph--
|
|
70
|
+
icon='ph--circle--regular'
|
|
72
71
|
density='fine'
|
|
73
|
-
size={4}
|
|
74
72
|
classNames={'!h-[24px] !text-[14px] p-1 min-h-0 gap-0.5'}
|
|
75
73
|
/>
|
|
76
74
|
</div>
|
|
@@ -78,10 +76,9 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
78
76
|
<IconButton
|
|
79
77
|
{...args}
|
|
80
78
|
label='Test'
|
|
81
|
-
icon='ph--
|
|
79
|
+
icon='ph--circle--regular'
|
|
82
80
|
iconOnly
|
|
83
81
|
density='fine'
|
|
84
|
-
size={4}
|
|
85
82
|
classNames={'!h-[24px] !text-[14px] p-1 min-h-0'}
|
|
86
83
|
/>
|
|
87
84
|
</div>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Column architecture reference
|
|
2
|
+
|
|
3
|
+
## Background
|
|
4
|
+
|
|
5
|
+
`Column` establishes a 3-column CSS grid with left/right gutter columns and a center content
|
|
6
|
+
channel. Two CSS custom properties drive the system:
|
|
7
|
+
|
|
8
|
+
- `--gutter` — the gutter track width (e.g. `var(--dx-gutter-md)`); consumed by `ScrollArea.Viewport` for padding.
|
|
9
|
+
- `--dx-col` — the grid-column placement token; set by `Column.Root` and consumed by `withColumn` utilities.
|
|
10
|
+
|
|
11
|
+
## Column primitives
|
|
12
|
+
|
|
13
|
+
### Column.Root
|
|
14
|
+
|
|
15
|
+
```css
|
|
16
|
+
/* column.ts — columnRoot */
|
|
17
|
+
dx-column grid
|
|
18
|
+
/* inline style */
|
|
19
|
+
--gutter: <gutterSize>
|
|
20
|
+
--dx-col: 2 / span 1
|
|
21
|
+
grid-template-columns: <gutter> minmax(0,1fr) <gutter>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Sets the 3-column grid and both CSS variables. All `withColumn` utilities are no-ops outside this context.
|
|
25
|
+
|
|
26
|
+
### Column.Center
|
|
27
|
+
|
|
28
|
+
```css
|
|
29
|
+
/* column.ts — columnCenter */
|
|
30
|
+
[grid-column:var(--dx-col,auto)] min-h-0
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Places a single element in col 2 (the center track). Does not use subgrid — placement is explicit
|
|
34
|
+
on this element only, so arbitrary compound components (including `display: contents` wrappers) can
|
|
35
|
+
be nested safely.
|
|
36
|
+
|
|
37
|
+
### Column.Bleed
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
/* column.ts — columnBleed */
|
|
41
|
+
col-span-full grid grid-cols-subgrid min-h-0
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Spans all 3 columns and propagates the subgrid. Use for `ScrollArea`, full-width dividers, and
|
|
45
|
+
any content that should ignore the gutters.
|
|
46
|
+
|
|
47
|
+
### Column.Row
|
|
48
|
+
|
|
49
|
+
```css
|
|
50
|
+
/* column.ts — columnRow */
|
|
51
|
+
col-span-3 grid grid-cols-subgrid
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Three-slot icon row. Children map to: `[col-1: icon/slot] [col-2: content] [col-3: icon/action]`.
|
|
55
|
+
Must be a direct child of `Column.Root`.
|
|
56
|
+
|
|
57
|
+
## withColumn theme utilities
|
|
58
|
+
|
|
59
|
+
Exported from `@dxos/ui-theme`. Components import and call these in their theme functions to
|
|
60
|
+
participate in the Column grid without importing Column React components.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
withColumn.center();
|
|
64
|
+
// → '[grid-column:var(--dx-col,auto)]'
|
|
65
|
+
|
|
66
|
+
withColumn.propagate();
|
|
67
|
+
// → '[.dx-column_&]:col-span-full [.dx-column_&]:grid [.dx-column_&]:grid-cols-subgrid'
|
|
68
|
+
|
|
69
|
+
withColumn.consumed();
|
|
70
|
+
// → '[--dx-col:auto]'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
| Utility | Purpose | Where used |
|
|
74
|
+
| :------------ | :-------------------------------------------------------------------------------- | :---------------------------------------------------------------------------- |
|
|
75
|
+
| `center()` | Place element in col 2 via `--dx-col`. No-op outside Column or inside ScrollArea. | Dialog.Header, Dialog.ActionBar, Form.Content, Form.Actions, SearchList.Input |
|
|
76
|
+
| `propagate()` | Extend Column subgrid to children. No-op outside Column. | Dialog.Body, SearchList.Content |
|
|
77
|
+
| `consumed()` | Reset `--dx-col` after `--gutter` is consumed. | ScrollArea.Viewport |
|
|
78
|
+
|
|
79
|
+
## CSS custom property cascade
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
Column.Root
|
|
83
|
+
sets --gutter = var(--dx-gutter-<size>)
|
|
84
|
+
sets --dx-col = 2 / span 1
|
|
85
|
+
│
|
|
86
|
+
├─ Column.Center → grid-column: var(--dx-col) ← consumes --dx-col
|
|
87
|
+
├─ Column.Bleed → col-span-full, subgrid
|
|
88
|
+
├─ Column.Row → col-span-3, subgrid
|
|
89
|
+
│
|
|
90
|
+
└─ withColumn.center() → grid-column: var(--dx-col) ← consumes --dx-col
|
|
91
|
+
withColumn.propagate() → col-span-full, grid, subgrid (inside .dx-column only)
|
|
92
|
+
│
|
|
93
|
+
└─ ScrollArea.Root → col-span-full (inside .dx-column only)
|
|
94
|
+
ScrollArea.Viewport
|
|
95
|
+
applies pl/pr using --gutter
|
|
96
|
+
withColumn.consumed() → sets --dx-col: auto
|
|
97
|
+
│
|
|
98
|
+
└─ (nested components no longer auto-position)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Component integration
|
|
102
|
+
|
|
103
|
+
### Dialog
|
|
104
|
+
|
|
105
|
+
| Sub-component | withColumn applied | Effect |
|
|
106
|
+
| :----------------- | :---------------------------- | :---------------------------- |
|
|
107
|
+
| `Dialog.Content` | `Column.Root` (gutter `'sm'`) | Establishes the 3-col grid. |
|
|
108
|
+
| `Dialog.Header` | `withColumn.center()` | Placed in col 2. |
|
|
109
|
+
| `Dialog.Body` | `withColumn.propagate()` | Children inherit the subgrid. |
|
|
110
|
+
| `Dialog.ActionBar` | `withColumn.center()` | Placed in col 2. |
|
|
111
|
+
|
|
112
|
+
### Form
|
|
113
|
+
|
|
114
|
+
| Sub-component | withColumn applied | Effect |
|
|
115
|
+
| :------------- | :-------------------- | :---------------------------------- |
|
|
116
|
+
| `Form.Content` | `withColumn.center()` | Placed in col 2 when inside Column. |
|
|
117
|
+
| `Form.Actions` | `withColumn.center()` | Placed in col 2 when inside Column. |
|
|
118
|
+
|
|
119
|
+
### SearchList
|
|
120
|
+
|
|
121
|
+
| Sub-component | withColumn applied | Effect |
|
|
122
|
+
| :------------------------- | :----------------------- | :---------------------------------------------- |
|
|
123
|
+
| `SearchList.Content` | `withColumn.propagate()` | Extends subgrid to children when inside Column. |
|
|
124
|
+
| `SearchList.Input` wrapper | `withColumn.center()` | Input row placed in col 2. |
|
|
125
|
+
|
|
126
|
+
### Card
|
|
127
|
+
|
|
128
|
+
`Card.Row` uses its own inline subgrid CSS (`col-span-3 grid grid-cols-subgrid`) and does not
|
|
129
|
+
participate in an outer Column grid. `Card.Root` establishes a separate 3-column grid for its
|
|
130
|
+
own icon-slot layout.
|
|
131
|
+
|
|
132
|
+
## Subgrid chain integrity
|
|
133
|
+
|
|
134
|
+
Every intermediate container between `Column.Root` and a `ScrollArea.Root` must propagate the
|
|
135
|
+
subgrid, otherwise `ScrollArea.Root`'s `[.dx-column_&]:col-span-full` selector will not match
|
|
136
|
+
and the scrollbar will not extend to the gutter.
|
|
137
|
+
|
|
138
|
+
Required chain:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
Column.Root (.dx-column)
|
|
142
|
+
→ withColumn.propagate() container (col-span-full, grid, grid-cols-subgrid)
|
|
143
|
+
→ ScrollArea.Root (.dx-container, [.dx-column_&]:col-span-full)
|
|
144
|
+
→ ScrollArea.Viewport (applies --gutter padding, resets --dx-col)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
If any intermediate element wraps the ScrollArea without propagating, use `Column.Bleed` or
|
|
148
|
+
apply `withColumn.propagate()` to that wrapper.
|
|
@@ -7,18 +7,16 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { Input, ScrollArea } from '../../components';
|
|
9
9
|
import { withLayout, withTheme } from '../../testing';
|
|
10
|
-
import { Flex } from '../Flex';
|
|
11
|
-
|
|
12
10
|
import { Column } from './Column';
|
|
13
11
|
|
|
14
12
|
const List = () => {
|
|
15
13
|
return (
|
|
16
|
-
<ScrollArea.Root
|
|
14
|
+
<ScrollArea.Root centered>
|
|
17
15
|
<ScrollArea.Viewport>
|
|
18
16
|
{Array.from({ length: 100 }).map((_, i) => (
|
|
19
|
-
<
|
|
20
|
-
Item {i}
|
|
21
|
-
</
|
|
17
|
+
<Input.Root key={i}>
|
|
18
|
+
<Input.TextInput value={`Item ${i}`} readOnly />
|
|
19
|
+
</Input.Root>
|
|
22
20
|
))}
|
|
23
21
|
</ScrollArea.Viewport>
|
|
24
22
|
</ScrollArea.Root>
|
|
@@ -27,10 +25,10 @@ const List = () => {
|
|
|
27
25
|
|
|
28
26
|
const DefaultStory = () => {
|
|
29
27
|
return (
|
|
30
|
-
<Column.Root
|
|
31
|
-
<Column.
|
|
28
|
+
<Column.Root classNames='overflow-hidden' gutter='md'>
|
|
29
|
+
<Column.Center>
|
|
32
30
|
<h1 className='p-1 bg-blue-500 text-black'>Header</h1>
|
|
33
|
-
</Column.
|
|
31
|
+
</Column.Center>
|
|
34
32
|
|
|
35
33
|
<Column.Row>
|
|
36
34
|
<div className='p-1 bg-blue-500'>A</div>
|
|
@@ -38,26 +36,36 @@ const DefaultStory = () => {
|
|
|
38
36
|
<div className='p-1 bg-blue-500'>C</div>
|
|
39
37
|
</Column.Row>
|
|
40
38
|
|
|
41
|
-
<Column.
|
|
42
|
-
<div
|
|
39
|
+
<Column.Center asChild>
|
|
40
|
+
<div>
|
|
43
41
|
<Input.Root>
|
|
44
42
|
<Input.TextInput placeholder='Search' />
|
|
45
43
|
</Input.Root>
|
|
46
44
|
</div>
|
|
47
|
-
</Column.
|
|
45
|
+
</Column.Center>
|
|
48
46
|
|
|
49
|
-
<
|
|
47
|
+
<ScrollArea.Root orientation='vertical' padding>
|
|
48
|
+
<ScrollArea.Viewport>
|
|
49
|
+
<div className='flex flex-col gap-2'>
|
|
50
|
+
{Array.from({ length: 100 }).map((_, i) => (
|
|
51
|
+
<Input.Root key={i}>
|
|
52
|
+
<Input.TextInput value={`Item ${i}`} readOnly />
|
|
53
|
+
</Input.Root>
|
|
54
|
+
))}
|
|
55
|
+
</div>
|
|
56
|
+
</ScrollArea.Viewport>
|
|
57
|
+
</ScrollArea.Root>
|
|
50
58
|
|
|
51
|
-
<Column.
|
|
52
|
-
<
|
|
59
|
+
<Column.Center asChild>
|
|
60
|
+
<div className='flex flex-col'>
|
|
53
61
|
<h1 className='p-1 bg-red-500 text-black'>Section with overflow</h1>
|
|
54
62
|
<pre className='p-1 text-xs text-subdued overflow-auto'>{new Error().stack}</pre>
|
|
55
|
-
</
|
|
56
|
-
</Column.
|
|
63
|
+
</div>
|
|
64
|
+
</Column.Center>
|
|
57
65
|
|
|
58
|
-
<Column.
|
|
66
|
+
<Column.Center>
|
|
59
67
|
<div className='p-1 bg-green-500 text-black'>Footer</div>
|
|
60
|
-
</Column.
|
|
68
|
+
</Column.Center>
|
|
61
69
|
</Column.Root>
|
|
62
70
|
);
|
|
63
71
|
};
|
|
@@ -76,3 +84,98 @@ export default meta;
|
|
|
76
84
|
type Story = StoryObj<typeof meta>;
|
|
77
85
|
|
|
78
86
|
export const Default: Story = {};
|
|
87
|
+
|
|
88
|
+
const InputList = ({ items = 50 }: { items?: number }) => (
|
|
89
|
+
<div className='flex flex-col gap-2'>
|
|
90
|
+
{Array.from({ length: items }).map((_, index) => (
|
|
91
|
+
<Input.Root key={index}>
|
|
92
|
+
<Input.TextInput value={`Item ${index + 1}`} readOnly />
|
|
93
|
+
</Input.Root>
|
|
94
|
+
))}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export const WithScrollArea = {
|
|
99
|
+
decorators: [withLayout({ layout: 'column' })],
|
|
100
|
+
render: () => (
|
|
101
|
+
<Column.Root classNames='overflow-hidden' gutter='md'>
|
|
102
|
+
<Column.Center>
|
|
103
|
+
<h2>Header</h2>
|
|
104
|
+
</Column.Center>
|
|
105
|
+
<ScrollArea.Root padding centered orientation='vertical'>
|
|
106
|
+
<ScrollArea.Viewport>
|
|
107
|
+
<InputList items={30} />
|
|
108
|
+
</ScrollArea.Viewport>
|
|
109
|
+
</ScrollArea.Root>
|
|
110
|
+
<Column.Center>
|
|
111
|
+
<h2>Footer</h2>
|
|
112
|
+
</Column.Center>
|
|
113
|
+
</Column.Root>
|
|
114
|
+
),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Column.Center places a single element in the center column of the parent grid.
|
|
119
|
+
* Preferred for centered content — safe to nest
|
|
120
|
+
* compound components (Form.Root, Editor.Root, etc.) that render `display: contents`.
|
|
121
|
+
*/
|
|
122
|
+
export const WithCenter: Story = {
|
|
123
|
+
decorators: [withLayout({ classNames: 'w-[25rem]' })],
|
|
124
|
+
render: () => (
|
|
125
|
+
<Column.Root gutter='md'>
|
|
126
|
+
<Column.Center>
|
|
127
|
+
<h2>Header (Column.Center)</h2>
|
|
128
|
+
</Column.Center>
|
|
129
|
+
<Column.Center classNames='flex flex-col'>
|
|
130
|
+
<p>This text is inside Column.Center. It sits in the central column between the gutters.</p>
|
|
131
|
+
<Input.Root>
|
|
132
|
+
<Input.Label>Name</Input.Label>
|
|
133
|
+
<Input.TextInput placeholder='Enter name' />
|
|
134
|
+
</Input.Root>
|
|
135
|
+
</Column.Center>
|
|
136
|
+
<Column.Center>
|
|
137
|
+
<h2>Footer (Column.Center)</h2>
|
|
138
|
+
</Column.Center>
|
|
139
|
+
</Column.Root>
|
|
140
|
+
),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* ScrollArea auto-bleeds inside Column.Root (via [.dx-column_&]:col-span-full).
|
|
145
|
+
* No Column.Bleed wrapper needed.
|
|
146
|
+
*/
|
|
147
|
+
export const WithScrollAreaAutoBleed: Story = {
|
|
148
|
+
decorators: [withLayout({ layout: 'column', classNames: 'w-[25rem]' })],
|
|
149
|
+
render: () => (
|
|
150
|
+
<Column.Root classNames='overflow-hidden' gutter='md'>
|
|
151
|
+
<Column.Center>
|
|
152
|
+
<h2>Header (Column.Center)</h2>
|
|
153
|
+
</Column.Center>
|
|
154
|
+
<ScrollArea.Root orientation='vertical' padding thin>
|
|
155
|
+
<ScrollArea.Viewport>
|
|
156
|
+
<InputList items={30} />
|
|
157
|
+
</ScrollArea.Viewport>
|
|
158
|
+
</ScrollArea.Root>
|
|
159
|
+
<Column.Center>
|
|
160
|
+
<h2>Footer (Column.Center)</h2>
|
|
161
|
+
</Column.Center>
|
|
162
|
+
</Column.Root>
|
|
163
|
+
),
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const Experimental = {
|
|
167
|
+
render: () => {
|
|
168
|
+
return (
|
|
169
|
+
<div className='grid grid-cols-[2rem_1fr_2rem]'>
|
|
170
|
+
<div className='col-span-full grid grid-cols-subgrid'>
|
|
171
|
+
<div className='bg-red-surface'>A</div>
|
|
172
|
+
<div className='bg-green-surface'>B</div>
|
|
173
|
+
<div className='bg-blue-surface'>C</div>
|
|
174
|
+
</div>
|
|
175
|
+
<div className='col-span-full grid grid-cols-subgrid col-start-2'>
|
|
176
|
+
<div className='bg-green-surface'>B</div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
};
|