@dxos/react-ui 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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-CEKVHJ27.mjs → chunk-2FKSMWNY.mjs} +117 -117
- package/dist/lib/browser/chunk-2FKSMWNY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2804 -1957
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +56 -32
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-2NHEX4AD.mjs → chunk-ZNBLTSHI.mjs} +117 -117
- package/dist/lib/node-esm/chunk-ZNBLTSHI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +2804 -1957
- 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 +56 -32
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- 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/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.d.ts +107 -0
- package/dist/types/src/components/Card/Card.d.ts.map +1 -0
- package/dist/types/src/components/Card/Card.stories.d.ts +21 -0
- package/dist/types/src/components/Card/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Card/index.d.ts +2 -0
- package/dist/types/src/components/Card/index.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/AlertDialog.d.ts +12 -3
- 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 +11 -4
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +3 -6
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ErrorFallback/ErrorFallback.d.ts +11 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.stories.d.ts +7 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.stories.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts +8 -0
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ThrowError.d.ts +9 -0
- package/dist/types/src/components/ErrorFallback/ThrowError.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/index.d.ts +5 -0
- package/dist/types/src/components/ErrorFallback/index.d.ts.map +1 -0
- package/dist/types/src/components/Image/Image.d.ts +14 -0
- package/dist/types/src/components/Image/Image.d.ts.map +1 -0
- package/dist/types/src/components/Image/Image.stories.d.ts +33 -0
- package/dist/types/src/components/Image/Image.stories.d.ts.map +1 -0
- package/dist/types/src/components/Image/index.d.ts +2 -0
- package/dist/types/src/components/Image/index.d.ts.map +1 -0
- package/dist/types/src/components/Input/Input.d.ts +2 -5
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +7 -7
- package/dist/types/src/components/Input/Input.stories.d.ts.map +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/List/Treegrid.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +9 -10
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +0 -3
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +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 -3
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +21 -26
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +41 -9
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +6 -1
- 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/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 +32 -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/Status/Status.stories.d.ts +4 -2
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.stories.d.ts +0 -5
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +1 -0
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts +12 -0
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +33 -7
- 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/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +8 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/exemplars/generics.stories.d.ts +18 -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/exemplars/virtualizer.stories.d.ts +11 -0
- package/dist/types/src/exemplars/virtualizer.stories.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- 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/Column/Column.d.ts +26 -0
- package/dist/types/src/primitives/Column/Column.d.ts.map +1 -0
- package/dist/types/src/primitives/Column/Column.stories.d.ts +6 -0
- package/dist/types/src/primitives/Column/Column.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Column/index.d.ts +2 -0
- package/dist/types/src/primitives/Column/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Container.d.ts +8 -0
- package/dist/types/src/primitives/Container/Container.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts +6 -0
- package/dist/types/src/primitives/Container/Container.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/index.d.ts +2 -0
- package/dist/types/src/primitives/Container/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/Flex.d.ts +13 -0
- package/dist/types/src/primitives/Flex/Flex.d.ts.map +1 -0
- package/dist/types/src/primitives/Flex/Flex.stories.d.ts +8 -0
- package/dist/types/src/primitives/Flex/Flex.stories.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/Grid/Grid.d.ts +15 -0
- package/dist/types/src/primitives/Grid/Grid.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/Grid.stories.d.ts +8 -0
- package/dist/types/src/primitives/Grid/Grid.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/index.d.ts +2 -0
- package/dist/types/src/primitives/Grid/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/Panel.d.ts +26 -0
- package/dist/types/src/primitives/Panel/Panel.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/Panel.stories.d.ts +6 -0
- package/dist/types/src/primitives/Panel/Panel.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/index.d.ts +2 -0
- package/dist/types/src/primitives/Panel/index.d.ts.map +1 -0
- package/dist/types/src/primitives/index.d.ts +6 -0
- package/dist/types/src/primitives/index.d.ts.map +1 -0
- package/dist/types/src/testing/Loading.d.ts +9 -0
- package/dist/types/src/testing/Loading.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withLayout.d.ts +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 +3 -2
- package/dist/types/src/testing/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +11 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -21
- package/src/components/Avatars/Avatar.stories.tsx +5 -6
- package/src/components/Avatars/Avatar.tsx +5 -12
- package/src/components/Avatars/AvatarGroup.stories.tsx +2 -2
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +3 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +11 -37
- package/src/components/Button/Button.stories.tsx +3 -3
- package/src/components/Button/Button.tsx +6 -12
- package/src/components/Button/IconButton.stories.tsx +4 -4
- package/src/components/Button/IconButton.tsx +1 -1
- package/src/components/Button/Toggle.stories.tsx +2 -2
- package/src/components/Button/ToggleGroup.stories.tsx +2 -2
- package/src/components/Card/Card.stories.tsx +151 -0
- package/src/components/Card/Card.tsx +347 -0
- package/src/components/Card/index.ts +5 -0
- package/src/components/Clipboard/CopyButton.tsx +3 -3
- package/src/components/Dialog/AlertDialog.stories.tsx +15 -15
- package/src/components/Dialog/AlertDialog.tsx +116 -16
- package/src/components/Dialog/Dialog.stories.tsx +40 -15
- package/src/components/Dialog/Dialog.tsx +75 -45
- package/src/components/ErrorFallback/ErrorFallback.stories.tsx +50 -0
- package/src/components/ErrorFallback/ErrorFallback.tsx +70 -0
- package/src/components/ErrorFallback/ErrorStack.tsx +80 -0
- package/src/components/ErrorFallback/ThrowError.tsx +37 -0
- package/src/components/ErrorFallback/index.ts +9 -0
- package/src/components/Icon/Icon.stories.tsx +2 -2
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/Image/Image.stories.tsx +86 -0
- package/src/components/Image/Image.tsx +223 -0
- package/src/components/Image/index.ts +5 -0
- package/src/components/Input/Input.stories.tsx +20 -39
- package/src/components/Input/Input.tsx +20 -65
- package/src/components/Link/Link.stories.tsx +2 -2
- package/src/components/Link/Link.tsx +2 -2
- package/src/components/List/List.stories.tsx +15 -22
- package/src/components/List/List.tsx +11 -16
- package/src/components/List/ListDropIndicator.tsx +7 -7
- package/src/components/List/Tree.stories.tsx +4 -4
- package/src/components/List/TreeDropIndicator.tsx +6 -6
- package/src/components/List/Treegrid.stories.tsx +3 -3
- package/src/components/List/Treegrid.tsx +10 -15
- package/src/components/Main/Main.stories.tsx +41 -23
- package/src/components/Main/Main.tsx +138 -81
- package/src/components/Menu/ContextMenu.stories.tsx +2 -2
- package/src/components/Menu/ContextMenu.tsx +9 -33
- package/src/components/Menu/DropdownMenu.stories.tsx +2 -2
- package/src/components/Menu/DropdownMenu.tsx +10 -10
- package/src/components/Message/Message.stories.tsx +25 -10
- package/src/components/Message/Message.tsx +17 -29
- package/src/components/Popover/Popover.stories.tsx +4 -4
- package/src/components/Popover/Popover.tsx +23 -20
- package/src/components/ScrollArea/ScrollArea.stories.tsx +152 -76
- package/src/components/ScrollArea/ScrollArea.tsx +72 -116
- package/src/components/ScrollArea/index.ts +1 -1
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +41 -22
- package/src/components/ScrollContainer/ScrollContainer.tsx +18 -13
- package/src/components/Select/Select.stories.tsx +2 -2
- package/src/components/Select/Select.tsx +11 -27
- package/src/components/Separator/Separator.tsx +1 -1
- 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 +83 -0
- package/src/components/Splitter/Splitter.tsx +126 -0
- package/src/components/Splitter/index.ts +5 -0
- package/src/components/Status/Status.stories.tsx +21 -17
- package/src/components/Status/Status.tsx +2 -2
- package/src/components/Tag/Tag.stories.tsx +4 -9
- package/src/components/Tag/Tag.tsx +2 -7
- package/src/components/ThemeProvider/ThemeProvider.stories.tsx +32 -0
- package/src/components/ThemeProvider/ThemeProvider.tsx +4 -3
- package/src/components/Toast/Toast.stories.tsx +2 -2
- package/src/components/Toast/Toast.tsx +10 -14
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
- package/src/components/Toolbar/Toolbar.tsx +174 -12
- package/src/components/Tooltip/Tooltip.stories.tsx +15 -13
- package/src/components/Tooltip/Tooltip.tsx +3 -2
- package/src/components/index.ts +9 -5
- package/src/exemplars/generics.stories.tsx +49 -0
- package/src/exemplars/slot.stories.tsx +107 -0
- package/src/exemplars/tabster.stories.tsx +127 -0
- package/src/exemplars/virtualizer.stories.tsx +137 -0
- package/src/index.ts +1 -0
- package/src/playground/Controls.stories.tsx +3 -10
- package/src/playground/Custom.stories.tsx +10 -10
- package/src/playground/Typography.stories.tsx +3 -3
- package/src/primitives/Column/Column.stories.tsx +78 -0
- package/src/primitives/Column/Column.tsx +134 -0
- package/src/primitives/Column/index.ts +5 -0
- package/src/primitives/Container/Container.stories.tsx +30 -0
- package/src/primitives/Container/Container.tsx +22 -0
- package/src/primitives/Container/index.ts +5 -0
- package/src/primitives/Flex/Flex.stories.tsx +58 -0
- package/src/primitives/Flex/Flex.tsx +29 -0
- package/src/primitives/Flex/index.ts +5 -0
- package/src/primitives/Grid/Grid.stories.tsx +57 -0
- package/src/primitives/Grid/Grid.tsx +35 -0
- package/src/primitives/Grid/index.ts +5 -0
- package/src/primitives/Panel/Panel.stories.tsx +67 -0
- package/src/primitives/Panel/Panel.tsx +119 -0
- package/src/primitives/Panel/index.ts +5 -0
- package/src/primitives/index.ts +9 -0
- package/src/testing/Loading.tsx +26 -0
- package/src/testing/decorators/withLayout.tsx +21 -7
- package/src/testing/decorators/withLayoutVariants.tsx +18 -21
- package/src/testing/decorators/withTheme.tsx +19 -17
- package/src/testing/index.ts +2 -0
- package/src/translations.ts +19 -0
- package/dist/lib/browser/chunk-CEKVHJ27.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2NHEX4AD.mjs.map +0 -7
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts +0 -15
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts.map +0 -1
- package/dist/types/src/components/AnchoredOverflow/index.d.ts +0 -2
- package/dist/types/src/components/AnchoredOverflow/index.d.ts.map +0 -1
- package/src/components/AnchoredOverflow/AnchoredOverflow.tsx +0 -59
- package/src/components/AnchoredOverflow/index.ts +0 -5
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Root as CheckboxPrimitive, type CheckboxProps as CheckboxPrimitiveProps } from '@radix-ui/react-checkbox';
|
|
6
6
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
7
|
-
import React, { type ComponentPropsWithRef, type ForwardRefExoticComponent, forwardRef
|
|
7
|
+
import React, { type ComponentPropsWithRef, type ForwardRefExoticComponent, forwardRef } from 'react';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
DescriptionAndValidation as DescriptionAndValidationPrimitive,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
useInputContext,
|
|
29
29
|
} from '@dxos/react-input';
|
|
30
30
|
import { mx } from '@dxos/ui-theme';
|
|
31
|
-
import { type
|
|
31
|
+
import { type Density, type Elevation, type Size } from '@dxos/ui-types';
|
|
32
32
|
|
|
33
33
|
import { useDensityContext, useElevationContext, useThemeContext } from '../../hooks';
|
|
34
34
|
import { type ThemedClassName } from '../../util';
|
|
@@ -40,10 +40,10 @@ type InputSharedProps = Partial<{ density: Density; elevation: Elevation; varian
|
|
|
40
40
|
|
|
41
41
|
type LabelProps = ThemedClassName<LabelPrimitiveProps> & { srOnly?: boolean };
|
|
42
42
|
|
|
43
|
-
const Label = forwardRef<HTMLLabelElement, LabelProps>(({
|
|
43
|
+
const Label = forwardRef<HTMLLabelElement, LabelProps>(({ classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
44
44
|
const { tx } = useThemeContext();
|
|
45
45
|
return (
|
|
46
|
-
<LabelPrimitive {...props} className={tx('input.label',
|
|
46
|
+
<LabelPrimitive {...props} className={tx('input.label', { srOnly }, classNames)} ref={forwardedRef}>
|
|
47
47
|
{children}
|
|
48
48
|
</LabelPrimitive>
|
|
49
49
|
);
|
|
@@ -52,14 +52,10 @@ const Label = forwardRef<HTMLLabelElement, LabelProps>(({ srOnly, classNames, ch
|
|
|
52
52
|
type DescriptionProps = ThemedClassName<DescriptionPrimitiveProps> & { srOnly?: boolean };
|
|
53
53
|
|
|
54
54
|
const Description = forwardRef<HTMLSpanElement, DescriptionProps>(
|
|
55
|
-
({
|
|
55
|
+
({ classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
56
56
|
const { tx } = useThemeContext();
|
|
57
57
|
return (
|
|
58
|
-
<DescriptionPrimitive
|
|
59
|
-
{...props}
|
|
60
|
-
className={tx('input.description', 'input__description', { srOnly }, classNames)}
|
|
61
|
-
ref={forwardedRef}
|
|
62
|
-
>
|
|
58
|
+
<DescriptionPrimitive {...props} className={tx('input.description', { srOnly }, classNames)} ref={forwardedRef}>
|
|
63
59
|
{children}
|
|
64
60
|
</DescriptionPrimitive>
|
|
65
61
|
);
|
|
@@ -69,18 +65,13 @@ const Description = forwardRef<HTMLSpanElement, DescriptionProps>(
|
|
|
69
65
|
type ValidationProps = ThemedClassName<ValidationPrimitiveProps> & { srOnly?: boolean };
|
|
70
66
|
|
|
71
67
|
const Validation = forwardRef<HTMLSpanElement, InputScopedProps<ValidationProps>>(
|
|
72
|
-
({ __inputScope,
|
|
68
|
+
({ __inputScope, classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
73
69
|
const { tx } = useThemeContext();
|
|
74
70
|
const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
75
71
|
return (
|
|
76
72
|
<ValidationPrimitive
|
|
77
73
|
{...props}
|
|
78
|
-
className={tx(
|
|
79
|
-
'input.validation',
|
|
80
|
-
`input__validation-message input__validation-message--${validationValence}`,
|
|
81
|
-
{ srOnly, validationValence },
|
|
82
|
-
classNames,
|
|
83
|
-
)}
|
|
74
|
+
className={tx('input.validation', { srOnly, validationValence }, classNames)}
|
|
84
75
|
ref={forwardedRef}
|
|
85
76
|
>
|
|
86
77
|
{children}
|
|
@@ -92,12 +83,12 @@ const Validation = forwardRef<HTMLSpanElement, InputScopedProps<ValidationProps>
|
|
|
92
83
|
type DescriptionAndValidationProps = ThemedClassName<DescriptionAndValidationPrimitiveProps> & { srOnly?: boolean };
|
|
93
84
|
|
|
94
85
|
const DescriptionAndValidation = forwardRef<HTMLParagraphElement, DescriptionAndValidationProps>(
|
|
95
|
-
({
|
|
86
|
+
({ classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
96
87
|
const { tx } = useThemeContext();
|
|
97
88
|
return (
|
|
98
89
|
<DescriptionAndValidationPrimitive
|
|
99
90
|
{...props}
|
|
100
|
-
className={tx('input.descriptionAndValidation',
|
|
91
|
+
className={tx('input.descriptionAndValidation', { srOnly }, classNames)}
|
|
101
92
|
ref={forwardedRef}
|
|
102
93
|
>
|
|
103
94
|
{children}
|
|
@@ -106,54 +97,23 @@ const DescriptionAndValidation = forwardRef<HTMLParagraphElement, DescriptionAnd
|
|
|
106
97
|
},
|
|
107
98
|
);
|
|
108
99
|
|
|
109
|
-
type PinInputProps = InputSharedProps &
|
|
110
|
-
Omit<PinInputPrimitiveProps, 'segmentClassName' | 'inputClassName'> & {
|
|
111
|
-
segmentClassName?: ClassNameValue;
|
|
112
|
-
inputClassName?: ClassNameValue;
|
|
113
|
-
};
|
|
100
|
+
type PinInputProps = ThemedClassName<InputSharedProps & Omit<PinInputPrimitiveProps, 'className' | 'segmentClassName'>>;
|
|
114
101
|
|
|
115
102
|
const PinInput = forwardRef<HTMLInputElement, PinInputProps>(
|
|
116
|
-
(
|
|
117
|
-
{
|
|
118
|
-
density: propsDensity,
|
|
119
|
-
elevation: propsElevation,
|
|
120
|
-
segmentClassName: propsSegmentClassName,
|
|
121
|
-
inputClassName,
|
|
122
|
-
variant,
|
|
123
|
-
...props
|
|
124
|
-
},
|
|
125
|
-
forwardedRef,
|
|
126
|
-
) => {
|
|
103
|
+
({ classNames, density: propsDensity, elevation: propsElevation, ...props }, forwardedRef) => {
|
|
127
104
|
const { hasIosKeyboard } = useThemeContext();
|
|
128
105
|
const { tx } = useThemeContext();
|
|
129
106
|
const density = useDensityContext(propsDensity);
|
|
130
107
|
const elevation = useElevationContext(propsElevation);
|
|
131
108
|
|
|
132
|
-
const segmentClassName = useCallback(
|
|
133
|
-
({ focused, validationValence }: Parameters<Exclude<PinInputPrimitiveProps['segmentClassName'], undefined>>[0]) =>
|
|
134
|
-
tx(
|
|
135
|
-
'input.input',
|
|
136
|
-
'input--pin-segment',
|
|
137
|
-
{
|
|
138
|
-
variant: 'static',
|
|
139
|
-
focused,
|
|
140
|
-
disabled: props.disabled,
|
|
141
|
-
density,
|
|
142
|
-
elevation,
|
|
143
|
-
validationValence,
|
|
144
|
-
},
|
|
145
|
-
propsSegmentClassName,
|
|
146
|
-
),
|
|
147
|
-
[tx, props.disabled, elevation, propsElevation, density],
|
|
148
|
-
);
|
|
149
109
|
return (
|
|
150
110
|
<PinInputPrimitive
|
|
151
111
|
{...{
|
|
152
112
|
...props,
|
|
153
|
-
segmentClassName,
|
|
154
113
|
...(props.autoFocus && !hasIosKeyboard && { autoFocus: true }),
|
|
155
114
|
}}
|
|
156
|
-
|
|
115
|
+
className={tx('input.inputWithSegments', { disabled: props.disabled }, classNames) || ''}
|
|
116
|
+
segmentClassName={tx('input.segment', { disabled: props.disabled, density, elevation }) || ''}
|
|
157
117
|
ref={forwardedRef}
|
|
158
118
|
/>
|
|
159
119
|
);
|
|
@@ -174,13 +134,11 @@ const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>
|
|
|
174
134
|
forwardedRef,
|
|
175
135
|
) => {
|
|
176
136
|
const { hasIosKeyboard } = useThemeContext();
|
|
177
|
-
const
|
|
137
|
+
const { tx } = useThemeContext();
|
|
178
138
|
const density = useDensityContext(propsDensity);
|
|
179
139
|
const elevation = useElevationContext(propsElevation);
|
|
180
140
|
const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
181
141
|
|
|
182
|
-
const { tx } = themeContextValue;
|
|
183
|
-
|
|
184
142
|
return (
|
|
185
143
|
<TextInputPrimitive
|
|
186
144
|
{...props}
|
|
@@ -188,7 +146,6 @@ const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>
|
|
|
188
146
|
{...{ 'data-1p-ignore': noAutoFill }}
|
|
189
147
|
className={tx(
|
|
190
148
|
'input.input',
|
|
191
|
-
'input',
|
|
192
149
|
{
|
|
193
150
|
variant,
|
|
194
151
|
disabled: props.disabled,
|
|
@@ -219,8 +176,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, InputScopedProps<TextAreaProps>
|
|
|
219
176
|
<TextAreaPrimitive
|
|
220
177
|
{...props}
|
|
221
178
|
className={tx(
|
|
222
|
-
'input.
|
|
223
|
-
'input--text-area',
|
|
179
|
+
'input.textArea',
|
|
224
180
|
{
|
|
225
181
|
variant,
|
|
226
182
|
disabled: props.disabled,
|
|
@@ -228,7 +184,6 @@ const TextArea = forwardRef<HTMLTextAreaElement, InputScopedProps<TextAreaProps>
|
|
|
228
184
|
elevation,
|
|
229
185
|
validationValence,
|
|
230
186
|
},
|
|
231
|
-
'-mbe-labelSpacingBlock',
|
|
232
187
|
classNames,
|
|
233
188
|
)}
|
|
234
189
|
{...(props.autoFocus && !hasIosKeyboard && { autoFocus: true })}
|
|
@@ -249,11 +204,11 @@ const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
|
249
204
|
(
|
|
250
205
|
{
|
|
251
206
|
__inputScope,
|
|
207
|
+
classNames,
|
|
252
208
|
checked: propsChecked,
|
|
253
209
|
defaultChecked: propsDefaultChecked,
|
|
254
210
|
onCheckedChange: propsOnCheckedChange,
|
|
255
211
|
size,
|
|
256
|
-
classNames,
|
|
257
212
|
...props
|
|
258
213
|
},
|
|
259
214
|
forwardedRef,
|
|
@@ -278,13 +233,13 @@ const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
|
278
233
|
'aria-invalid': 'true' as const,
|
|
279
234
|
'aria-errormessage': errorMessageId,
|
|
280
235
|
}),
|
|
281
|
-
className: tx('input.checkbox',
|
|
236
|
+
className: tx('input.checkbox', { size }, 'shrink-0', classNames),
|
|
282
237
|
}}
|
|
283
238
|
ref={forwardedRef}
|
|
284
239
|
>
|
|
285
240
|
<Icon
|
|
286
241
|
icon={checked === 'indeterminate' ? 'ph--minus--regular' : 'ph--check--regular'}
|
|
287
|
-
classNames={tx('input.checkboxIndicator',
|
|
242
|
+
classNames={tx('input.checkboxIndicator', { size, checked })}
|
|
288
243
|
/>
|
|
289
244
|
</CheckboxPrimitive>
|
|
290
245
|
);
|
|
@@ -299,10 +254,10 @@ const Switch = forwardRef<HTMLInputElement, InputScopedProps<SwitchProps>>(
|
|
|
299
254
|
(
|
|
300
255
|
{
|
|
301
256
|
__inputScope,
|
|
257
|
+
classNames,
|
|
302
258
|
checked: propsChecked,
|
|
303
259
|
defaultChecked: propsDefaultChecked,
|
|
304
260
|
onCheckedChange: propsOnCheckedChange,
|
|
305
|
-
classNames,
|
|
306
261
|
...props
|
|
307
262
|
},
|
|
308
263
|
forwardedRef,
|
|
@@ -9,9 +9,9 @@ import { withTheme } from '../../testing';
|
|
|
9
9
|
import { Link } from './Link';
|
|
10
10
|
|
|
11
11
|
const meta = {
|
|
12
|
-
title: 'ui/react-ui-core/Link',
|
|
12
|
+
title: 'ui/react-ui-core/components/Link',
|
|
13
13
|
component: Link,
|
|
14
|
-
decorators: [withTheme],
|
|
14
|
+
decorators: [withTheme()],
|
|
15
15
|
} satisfies Meta<typeof Link>;
|
|
16
16
|
|
|
17
17
|
export default meta;
|
|
@@ -18,7 +18,7 @@ export type LinkProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.a
|
|
|
18
18
|
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
19
19
|
({ asChild, variant, classNames, ...props }, forwardedRef) => {
|
|
20
20
|
const { tx } = useThemeContext();
|
|
21
|
-
const
|
|
22
|
-
return <
|
|
21
|
+
const Comp = asChild ? Slot : Primitive.a;
|
|
22
|
+
return <Comp {...props} className={tx('link.root', { variant }, classNames)} ref={forwardedRef} />;
|
|
23
23
|
},
|
|
24
24
|
);
|
|
@@ -9,14 +9,7 @@ import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
|
9
9
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
10
10
|
import React, { type ReactNode, useCallback, useState } from 'react';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
getSize,
|
|
14
|
-
ghostHover,
|
|
15
|
-
ghostSelected,
|
|
16
|
-
ghostSelectedTrackingInterFromNormal,
|
|
17
|
-
mx,
|
|
18
|
-
surfaceShadow,
|
|
19
|
-
} from '@dxos/ui-theme';
|
|
12
|
+
import { getSize, ghostHover, ghostSelected, mx, surfaceShadow } from '@dxos/ui-theme';
|
|
20
13
|
|
|
21
14
|
import { withTheme } from '../../testing';
|
|
22
15
|
import { Icon } from '../Icon';
|
|
@@ -24,9 +17,9 @@ import { Icon } from '../Icon';
|
|
|
24
17
|
import { List, ListItem, type ListScopedProps } from './List';
|
|
25
18
|
|
|
26
19
|
const meta = {
|
|
27
|
-
title: 'ui/react-ui-core/List',
|
|
20
|
+
title: 'ui/react-ui-core/components/List',
|
|
28
21
|
component: List,
|
|
29
|
-
decorators: [withTheme],
|
|
22
|
+
decorators: [withTheme()],
|
|
30
23
|
} satisfies Meta<typeof List>;
|
|
31
24
|
|
|
32
25
|
export default meta;
|
|
@@ -44,11 +37,11 @@ const UniformListItem = ({ id, text }: { id: string; text: string }) => {
|
|
|
44
37
|
style={{ transform: CSS.Transform.toString(transform) }}
|
|
45
38
|
>
|
|
46
39
|
<ListItem.Endcap>
|
|
47
|
-
<Icon icon='ph--dots-six-vertical--regular' classNames={mx(getSize(5), '
|
|
40
|
+
<Icon icon='ph--dots-six-vertical--regular' classNames={mx(getSize(5), 'mt-2.5')} />
|
|
48
41
|
</ListItem.Endcap>
|
|
49
|
-
<ListItem.Heading classNames='grow
|
|
42
|
+
<ListItem.Heading classNames='grow pt-2'>{text}</ListItem.Heading>
|
|
50
43
|
<ListItem.Endcap>
|
|
51
|
-
<Icon icon='ph--push-pin--regular' classNames={mx(getSize(5), '
|
|
44
|
+
<Icon icon='ph--push-pin--regular' classNames={mx(getSize(5), 'mt-2.5')} />
|
|
52
45
|
</ListItem.Endcap>
|
|
53
46
|
</ListItem.Root>
|
|
54
47
|
);
|
|
@@ -110,13 +103,13 @@ const ManySizesDraggableListItem = ({
|
|
|
110
103
|
style={{ transform: CSS.Translate.toString(transform) }}
|
|
111
104
|
>
|
|
112
105
|
<ListItem.Endcap>
|
|
113
|
-
<Icon icon='ph--dots-six-vertical--regular' classNames={mx(getSize(5), '
|
|
106
|
+
<Icon icon='ph--dots-six-vertical--regular' classNames={mx(getSize(5), 'mt-2.5')} />
|
|
114
107
|
</ListItem.Endcap>
|
|
115
|
-
<ListItem.Heading classNames='grow
|
|
108
|
+
<ListItem.Heading classNames='grow pt-2' asChild>
|
|
116
109
|
{text}
|
|
117
110
|
</ListItem.Heading>
|
|
118
111
|
<ListItem.Endcap>
|
|
119
|
-
<Icon icon='ph--push-pin--regular' classNames={mx(getSize(5), '
|
|
112
|
+
<Icon icon='ph--push-pin--regular' classNames={mx(getSize(5), 'mt-2.5')} />
|
|
120
113
|
</ListItem.Endcap>
|
|
121
114
|
</ListItem.Root>
|
|
122
115
|
);
|
|
@@ -130,9 +123,9 @@ export const ManySizesDraggable: Story = {
|
|
|
130
123
|
text: (
|
|
131
124
|
<p
|
|
132
125
|
className={mx(
|
|
133
|
-
index % 3 === 0 ? '
|
|
126
|
+
index % 3 === 0 ? 'h-20' : index % 2 === 0 ? 'h-12' : 'h-8',
|
|
134
127
|
surfaceShadow({ elevation: 'positioned' }),
|
|
135
|
-
'
|
|
128
|
+
'mb-2 p-2 bg-white dark:bg-neutral-800 rounded-sm',
|
|
136
129
|
)}
|
|
137
130
|
>{`List item ${index + 1}`}</p>
|
|
138
131
|
),
|
|
@@ -186,9 +179,9 @@ export const Collapsible: Story = {
|
|
|
186
179
|
<ListItem.Root key={id} id={id} collapsible={index !== 2} defaultOpen={index % 2 === 0}>
|
|
187
180
|
<div role='none' className='grow flex'>
|
|
188
181
|
{index !== 2 ? <ListItem.OpenTrigger /> : <ListItem.MockOpenTrigger />}
|
|
189
|
-
<ListItem.Heading classNames='grow
|
|
182
|
+
<ListItem.Heading classNames='grow pt-2'>{text}</ListItem.Heading>
|
|
190
183
|
<ListItem.Endcap>
|
|
191
|
-
<Icon icon='ph--push-pin--regular' classNames={mx(getSize(5), '
|
|
184
|
+
<Icon icon='ph--push-pin--regular' classNames={mx(getSize(5), 'mt-2.5')} />
|
|
192
185
|
</ListItem.Endcap>
|
|
193
186
|
</div>
|
|
194
187
|
{index !== 2 && <ListItem.CollapsibleContent>{body}</ListItem.CollapsibleContent>}
|
|
@@ -229,11 +222,11 @@ export const SelectableListbox: Story = {
|
|
|
229
222
|
key={id}
|
|
230
223
|
tabIndex={0}
|
|
231
224
|
selected={selectedId === id}
|
|
232
|
-
classNames={mx(ghostHover, ghostSelected
|
|
225
|
+
classNames={mx(ghostHover, ghostSelected)}
|
|
233
226
|
onClick={() => setSelectedId(id)}
|
|
234
227
|
onKeyUp={(event) => handleKeyUp(event, id)}
|
|
235
228
|
>
|
|
236
|
-
<ListItem.Heading classNames='flex
|
|
229
|
+
<ListItem.Heading classNames='flex px-1 items-center grow truncate'>{text}</ListItem.Heading>
|
|
237
230
|
</ListItem.Root>
|
|
238
231
|
))}
|
|
239
232
|
</List>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
5
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
6
7
|
import React, { type ComponentPropsWithoutRef, type FC, type ForwardRefExoticComponent, forwardRef } from 'react';
|
|
7
8
|
|
|
@@ -40,7 +41,7 @@ const List = forwardRef<HTMLOListElement, ListProps>(({ classNames, children, ..
|
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
43
|
<DensityProvider density={density}>
|
|
43
|
-
<ListPrimitive {...props} className={tx('list.root',
|
|
44
|
+
<ListPrimitive {...props} className={tx('list.root', {}, classNames)} ref={forwardedRef}>
|
|
44
45
|
{children}
|
|
45
46
|
</ListPrimitive>
|
|
46
47
|
</DensityProvider>
|
|
@@ -51,18 +52,18 @@ type ListItemEndcapProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & {
|
|
|
51
52
|
|
|
52
53
|
const ListItemEndcap = forwardRef<HTMLDivElement, ListItemEndcapProps>(
|
|
53
54
|
({ children, classNames, asChild, ...props }, forwardedRef) => {
|
|
54
|
-
const
|
|
55
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
55
56
|
const density = useDensityContext();
|
|
56
57
|
const { tx } = useThemeContext();
|
|
57
58
|
return (
|
|
58
|
-
<
|
|
59
|
+
<Comp
|
|
59
60
|
{...(!asChild && { role: 'none' })}
|
|
60
61
|
{...props}
|
|
61
|
-
className={tx('list.item.endcap',
|
|
62
|
+
className={tx('list.item.endcap', { density }, classNames)}
|
|
62
63
|
ref={forwardedRef}
|
|
63
64
|
>
|
|
64
65
|
{children}
|
|
65
|
-
</
|
|
66
|
+
</Comp>
|
|
66
67
|
);
|
|
67
68
|
},
|
|
68
69
|
);
|
|
@@ -73,13 +74,7 @@ const MockListItemOpenTrigger = ({
|
|
|
73
74
|
}: ThemedClassName<Omit<ComponentPropsWithoutRef<'div'>, 'children'>>) => {
|
|
74
75
|
const density = useDensityContext();
|
|
75
76
|
const { tx } = useThemeContext();
|
|
76
|
-
return (
|
|
77
|
-
<div
|
|
78
|
-
role='none'
|
|
79
|
-
{...props}
|
|
80
|
-
className={tx('list.item.openTrigger', 'list__listItem__openTrigger--mock', { density }, classNames)}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
77
|
+
return <div role='none' {...props} className={tx('list.item.openTrigger', { density }, classNames)} />;
|
|
83
78
|
};
|
|
84
79
|
|
|
85
80
|
type ListItemHeadingProps = ThemedClassName<ListPrimitiveItemHeadingProps>;
|
|
@@ -91,7 +86,7 @@ const ListItemHeading = forwardRef<HTMLParagraphElement, ListItemHeadingProps>(
|
|
|
91
86
|
return (
|
|
92
87
|
<ListPrimitiveItemHeading
|
|
93
88
|
{...props}
|
|
94
|
-
className={tx('list.item.heading',
|
|
89
|
+
className={tx('list.item.heading', { density }, classNames)}
|
|
95
90
|
ref={forwardedRef}
|
|
96
91
|
>
|
|
97
92
|
{children}
|
|
@@ -110,14 +105,14 @@ const ListItemOpenTrigger = forwardRef<HTMLButtonElement, ListItemOpenTriggerPro
|
|
|
110
105
|
return (
|
|
111
106
|
<ListPrimitiveItemOpenTrigger
|
|
112
107
|
{...props}
|
|
113
|
-
className={tx('list.item.openTrigger',
|
|
108
|
+
className={tx('list.item.openTrigger', { density }, classNames)}
|
|
114
109
|
ref={forwardedRef}
|
|
115
110
|
>
|
|
116
111
|
{children || (
|
|
117
112
|
<Icon
|
|
118
113
|
size={3}
|
|
119
114
|
icon={open ? 'ph--caret-down--bold' : 'ph--caret-right--bold'}
|
|
120
|
-
classNames={tx('list.item.openTriggerIcon',
|
|
115
|
+
classNames={tx('list.item.openTriggerIcon', {})}
|
|
121
116
|
/>
|
|
122
117
|
)}
|
|
123
118
|
</ListPrimitiveItemOpenTrigger>
|
|
@@ -134,7 +129,7 @@ const ListItemRoot = forwardRef<HTMLLIElement, ListItemRootProps>(
|
|
|
134
129
|
return (
|
|
135
130
|
<ListPrimitiveItem
|
|
136
131
|
{...props}
|
|
137
|
-
className={tx('list.item.root',
|
|
132
|
+
className={tx('list.item.root', { density, collapsible: props.collapsible }, classNames)}
|
|
138
133
|
ref={forwardedRef}
|
|
139
134
|
>
|
|
140
135
|
{children}
|
|
@@ -16,16 +16,16 @@ const edgeToOrientationMap: Record<Edge, Orientation> = {
|
|
|
16
16
|
|
|
17
17
|
const orientationStyles: Record<Orientation, HTMLAttributes<HTMLElement>['className']> = {
|
|
18
18
|
horizontal:
|
|
19
|
-
'h-
|
|
19
|
+
'h-(--line-thickness) left-[calc(var(--line-inset)+var(--terminal-radius))] right-(--line-inset) before:left-(--terminal-inset)',
|
|
20
20
|
vertical:
|
|
21
|
-
'
|
|
21
|
+
'w-(--line-thickness) top-[calc(var(--line-inset)+var(--terminal-radius))] bottom-(--line-inset) before:top-(--terminal-inset)',
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const edgeStyles: Record<Edge, HTMLAttributes<HTMLElement>['className']> = {
|
|
25
|
-
top: 'top-
|
|
26
|
-
right: 'right-
|
|
27
|
-
bottom: 'bottom-
|
|
28
|
-
left: 'left-
|
|
25
|
+
top: 'top-(--line-offset) before:top-(--offset-terminal)',
|
|
26
|
+
right: 'right-(--line-offset) before:right-(--offset-terminal)',
|
|
27
|
+
bottom: 'bottom-(--line-offset) before:bottom-(--offset-terminal)',
|
|
28
|
+
left: 'left-(--line-offset) before:left-(--offset-terminal)',
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const strokeSize = 2;
|
|
@@ -64,7 +64,7 @@ export const ListDropIndicator = ({
|
|
|
64
64
|
'--offset-terminal': `${offsetToAlignTerminalWithLine}px`,
|
|
65
65
|
} as CSSProperties
|
|
66
66
|
}
|
|
67
|
-
className={`absolute z-10 pointer-events-none bg-
|
|
67
|
+
className={`absolute z-10 pointer-events-none bg-accent-surface before:content-[''] before:w-(--terminal-size) before:h-(--terminal-size) box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accent-surface before:rounded-full ${orientationStyles[orientation]} ${edgeStyles[edge]}`}
|
|
68
68
|
/>
|
|
69
69
|
);
|
|
70
70
|
};
|
|
@@ -35,10 +35,10 @@ const StorybookTreeItem = ({ data, prefix }: StorybookTreeItemProps) => {
|
|
|
35
35
|
<TreeItem.Root key={id} id={id} collapsible={!valueIsScalar} defaultOpen>
|
|
36
36
|
<div role='none' className='grow flex'>
|
|
37
37
|
{valueIsScalar ? <TreeItem.MockOpenTrigger /> : <TreeItem.OpenTrigger />}
|
|
38
|
-
<TreeItem.Heading classNames='grow
|
|
38
|
+
<TreeItem.Heading classNames='grow pt-1'>{valueIsScalar ? String(value) : key}</TreeItem.Heading>
|
|
39
39
|
</div>
|
|
40
40
|
{!valueIsScalar && (
|
|
41
|
-
<TreeItem.Body className='
|
|
41
|
+
<TreeItem.Body className='ps-2'>
|
|
42
42
|
<Tree.Branch>
|
|
43
43
|
<StorybookTreeItem data={value} prefix={id} />
|
|
44
44
|
</Tree.Branch>
|
|
@@ -56,10 +56,10 @@ const DefaultStory = ({ data }: StorybookTreeProps) => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
const meta = {
|
|
59
|
-
title: 'ui/react-ui-core/Tree',
|
|
59
|
+
title: 'ui/react-ui-core/components/Tree',
|
|
60
60
|
component: Tree as any,
|
|
61
61
|
render: DefaultStory,
|
|
62
|
-
decorators: [withTheme],
|
|
62
|
+
decorators: [withTheme()],
|
|
63
63
|
} satisfies Meta<typeof DefaultStory>;
|
|
64
64
|
|
|
65
65
|
export default meta;
|
|
@@ -21,14 +21,14 @@ const edgeToOrientationMap: Record<InstructionType, Orientation> = {
|
|
|
21
21
|
const orientationStyles: Record<Orientation, HTMLAttributes<HTMLElement>['className']> = {
|
|
22
22
|
// TODO(wittjosiah): Stop using left/right here.
|
|
23
23
|
sibling:
|
|
24
|
-
'
|
|
25
|
-
child: '
|
|
24
|
+
'h-(--line-thickness) left-(--horizontal-indent) right-0 bg-accent-surface before:left-(--negative-terminal-size)',
|
|
25
|
+
child: 'inset-0 border-[length:var(--line-thickness)] before:invisible',
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const instructionStyles: Record<InstructionType, HTMLAttributes<HTMLElement>['className']> = {
|
|
29
|
-
'reorder-above': '
|
|
30
|
-
'reorder-below': '
|
|
31
|
-
'make-child': 'border-
|
|
29
|
+
'reorder-above': 'top-(--line-offset) before:top-(--offset-terminal)',
|
|
30
|
+
'reorder-below': 'bottom-(--line-offset) before:bottom-(--offset-terminal)',
|
|
31
|
+
'make-child': 'border-accent-surface',
|
|
32
32
|
// TODO(wittjosiah): This is not occurring in the current implementation.
|
|
33
33
|
reparent: '',
|
|
34
34
|
};
|
|
@@ -64,7 +64,7 @@ export const TreeDropIndicator = ({ instruction, gap = 0 }: DropIndicatorProps)
|
|
|
64
64
|
'--horizontal-indent': `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`,
|
|
65
65
|
} as CSSProperties
|
|
66
66
|
}
|
|
67
|
-
className={`absolute z-10 pointer-events-none before:
|
|
67
|
+
className={`absolute z-10 pointer-events-none before:w-(--terminal-size) before:h-(--terminal-size) box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accent-surface before:rounded-full ${orientationStyles[orientation]} ${instructionStyles[desiredInstruction.type]}`}
|
|
68
68
|
></div>
|
|
69
69
|
);
|
|
70
70
|
};
|
|
@@ -133,7 +133,7 @@ const DefaultStory = () => {
|
|
|
133
133
|
{...(parentOf && { parentOf: parentOf.join(Treegrid.PARENT_OF_SEPARATOR) })}
|
|
134
134
|
>
|
|
135
135
|
<Treegrid.Cell indent classNames='flex items-center'>
|
|
136
|
-
{node.icon && <Icon icon={node.icon} classNames='
|
|
136
|
+
{node.icon && <Icon icon={node.icon} classNames='w-[1em] h-[1em] my-1' />}
|
|
137
137
|
{node.title}
|
|
138
138
|
</Treegrid.Cell>
|
|
139
139
|
</Treegrid.Row>
|
|
@@ -144,10 +144,10 @@ const DefaultStory = () => {
|
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
const meta = {
|
|
147
|
-
title: 'ui/react-ui-core/Treegrid',
|
|
147
|
+
title: 'ui/react-ui-core/components/Treegrid',
|
|
148
148
|
component: Treegrid.Root as any,
|
|
149
149
|
render: DefaultStory,
|
|
150
|
-
decorators: [withTheme],
|
|
150
|
+
decorators: [withTheme()],
|
|
151
151
|
} satisfies Meta<typeof DefaultStory>;
|
|
152
152
|
|
|
153
153
|
export default meta;
|
|
@@ -45,7 +45,7 @@ type TreegridRootProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.
|
|
|
45
45
|
const TreegridRoot = forwardRef<HTMLDivElement, TreegridRootProps>(
|
|
46
46
|
({ asChild, classNames, children, style, gridTemplateColumns, ...props }, forwardedRef) => {
|
|
47
47
|
const { tx } = useThemeContext();
|
|
48
|
-
const
|
|
48
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
49
49
|
const { findFirstFocusable } = useFocusFinders();
|
|
50
50
|
|
|
51
51
|
const handleKeyDown = useCallback(
|
|
@@ -95,16 +95,16 @@ const TreegridRoot = forwardRef<HTMLDivElement, TreegridRootProps>(
|
|
|
95
95
|
);
|
|
96
96
|
|
|
97
97
|
return (
|
|
98
|
-
<
|
|
98
|
+
<Comp
|
|
99
99
|
role='treegrid'
|
|
100
|
-
onKeyDown={handleKeyDown}
|
|
101
100
|
{...props}
|
|
102
|
-
className={tx('treegrid.root',
|
|
101
|
+
className={tx('treegrid.root', {}, classNames)}
|
|
103
102
|
style={{ ...style, gridTemplateColumns }}
|
|
103
|
+
onKeyDown={handleKeyDown}
|
|
104
104
|
ref={forwardedRef}
|
|
105
105
|
>
|
|
106
106
|
{children}
|
|
107
|
-
</
|
|
107
|
+
</Comp>
|
|
108
108
|
);
|
|
109
109
|
},
|
|
110
110
|
);
|
|
@@ -135,7 +135,7 @@ const TreegridRow = forwardRef<HTMLDivElement, TreegridRowScopedProps<TreegridRo
|
|
|
135
135
|
forwardedRef,
|
|
136
136
|
) => {
|
|
137
137
|
const { tx } = useThemeContext();
|
|
138
|
-
const
|
|
138
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
139
139
|
const pathParts = id.split(PATH_SEPARATOR);
|
|
140
140
|
const level = pathParts.length - 1;
|
|
141
141
|
const [open, onOpenChange] = useControllableState({
|
|
@@ -146,17 +146,17 @@ const TreegridRow = forwardRef<HTMLDivElement, TreegridRowScopedProps<TreegridRo
|
|
|
146
146
|
|
|
147
147
|
return (
|
|
148
148
|
<TreegridRowProvider open={open} onOpenChange={onOpenChange} scope={__treegridRowScope}>
|
|
149
|
-
<
|
|
149
|
+
<Comp
|
|
150
150
|
role='row'
|
|
151
151
|
aria-level={level}
|
|
152
|
-
className={tx('treegrid.row',
|
|
152
|
+
className={tx('treegrid.row', { level }, classNames)}
|
|
153
153
|
{...(parentOf && { 'aria-expanded': open, 'aria-owns': parentOf })}
|
|
154
154
|
{...props}
|
|
155
155
|
id={id}
|
|
156
156
|
ref={forwardedRef}
|
|
157
157
|
>
|
|
158
158
|
{children}
|
|
159
|
-
</
|
|
159
|
+
</Comp>
|
|
160
160
|
</TreegridRowProvider>
|
|
161
161
|
);
|
|
162
162
|
},
|
|
@@ -168,12 +168,7 @@ const TreegridCell = forwardRef<HTMLDivElement, TreegridCellProps>(
|
|
|
168
168
|
({ classNames, children, indent, ...props }, forwardedRef) => {
|
|
169
169
|
const { tx } = useThemeContext();
|
|
170
170
|
return (
|
|
171
|
-
<div
|
|
172
|
-
role='gridcell'
|
|
173
|
-
className={tx('treegrid.cell', 'treegrid__cell', { indent }, classNames)}
|
|
174
|
-
{...props}
|
|
175
|
-
ref={forwardedRef}
|
|
176
|
-
>
|
|
171
|
+
<div role='gridcell' className={tx('treegrid.cell', { indent }, classNames)} {...props} ref={forwardedRef}>
|
|
177
172
|
{children}
|
|
178
173
|
</div>
|
|
179
174
|
);
|