@dxos/react-ui 0.8.4-main.67995b8 → 0.8.4-main.69d29f4
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 +774 -0
- package/dist/lib/browser/chunk-CEKVHJ27.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3069 -59
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +65 -49
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-2NHEX4AD.mjs +776 -0
- package/dist/lib/node-esm/chunk-2NHEX4AD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3069 -59
- 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 +65 -49
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- 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 +5 -31
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +5 -11
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts +8 -20
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Buttons → Button}/Button.d.ts +2 -2
- package/dist/types/src/components/Button/Button.d.ts.map +1 -0
- package/dist/types/src/components/Button/Button.stories.d.ts +17 -0
- package/dist/types/src/components/Button/Button.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/IconButton.d.ts +4 -4
- package/dist/types/src/components/Button/IconButton.d.ts.map +1 -0
- package/dist/types/src/components/Button/IconButton.stories.d.ts +13 -0
- package/dist/types/src/components/Button/IconButton.stories.d.ts.map +1 -0
- package/dist/types/src/components/Button/Toggle.d.ts.map +1 -0
- package/dist/types/src/components/Button/Toggle.stories.d.ts +16 -0
- package/dist/types/src/components/Button/Toggle.stories.d.ts.map +1 -0
- package/dist/types/src/components/Button/ToggleGroup.d.ts +27 -0
- package/dist/types/src/components/Button/ToggleGroup.d.ts.map +1 -0
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts +27 -0
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts.map +1 -0
- package/dist/types/src/components/Button/index.d.ts.map +1 -0
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
- 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/{Dialogs → Dialog}/AlertDialog.d.ts +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/AlertDialog.stories.d.ts +11 -0
- package/dist/types/src/components/Dialog/AlertDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts +40 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +27 -0
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/index.d.ts.map +1 -0
- 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 +2 -2
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.stories.d.ts +17 -0
- package/dist/types/src/components/Icon/Icon.stories.d.ts.map +1 -0
- package/dist/types/src/components/Input/Input.d.ts +6 -5
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +11 -12
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Link/Link.stories.d.ts +8 -8
- package/dist/types/src/components/Link/Link.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Lists → List}/List.d.ts +3 -3
- package/dist/types/src/components/List/List.d.ts.map +1 -0
- package/dist/types/src/components/List/List.stories.d.ts +14 -0
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -0
- package/dist/types/src/components/List/ListDropIndicator.d.ts.map +1 -0
- package/dist/types/src/components/{Lists → List}/Tree.d.ts +1 -1
- package/dist/types/src/components/List/Tree.d.ts.map +1 -0
- package/dist/types/src/components/List/Tree.stories.d.ts +15 -0
- package/dist/types/src/components/List/Tree.stories.d.ts.map +1 -0
- package/dist/types/src/components/List/TreeDropIndicator.d.ts.map +1 -0
- package/dist/types/src/components/{Lists → List}/Treegrid.d.ts +1 -1
- package/dist/types/src/components/{Lists → List}/Treegrid.d.ts.map +1 -1
- package/dist/types/src/components/List/Treegrid.stories.d.ts +12 -0
- package/dist/types/src/components/List/Treegrid.stories.d.ts.map +1 -0
- package/dist/types/src/components/List/index.d.ts.map +1 -0
- package/dist/types/src/components/Main/Main.d.ts +10 -19
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +6 -7
- 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 +12 -0
- package/dist/types/src/components/Menu/ContextMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/DropdownMenu.d.ts +8 -8
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -0
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts +15 -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 +8 -17
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +3 -3
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +6 -34
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +10 -8
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +8 -30
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +39 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +19 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScrollContainer/index.d.ts +2 -0
- package/dist/types/src/components/ScrollContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/Select/Select.d.ts +10 -10
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +4 -9
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Separator/Separator.d.ts +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts +2 -8
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- 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/Tag/Tag.stories.d.ts +12 -12
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +2 -3
- 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 +5 -5
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts +6 -44
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +17 -17
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +6 -50
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +2 -4
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +8 -61
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -4
- package/dist/types/src/components/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 +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeArea.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisualViewport.d.ts +2 -2
- package/dist/types/src/hooks/useVisualViewport.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +5 -9
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts +12 -4
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts +5 -11
- package/dist/types/src/playground/Typography.stories.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/index.d.ts +2 -1
- package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayout.d.ts +15 -0
- package/dist/types/src/testing/decorators/withLayout.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts +12 -0
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withTheme.d.ts +3 -0
- package/dist/types/src/testing/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/usePx.d.ts +8 -0
- package/dist/types/src/util/usePx.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -31
- package/src/components/Avatars/Avatar.stories.tsx +21 -12
- package/src/components/Avatars/Avatar.tsx +4 -4
- package/src/components/Avatars/AvatarGroup.stories.tsx +10 -6
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +17 -12
- package/src/components/Breadcrumb/Breadcrumb.tsx +1 -1
- package/src/components/{Buttons → Button}/Button.stories.tsx +8 -9
- package/src/components/{Buttons → Button}/Button.tsx +1 -1
- package/src/components/{Buttons → Button}/IconButton.stories.tsx +11 -8
- package/src/components/{Buttons → Button}/IconButton.tsx +22 -15
- package/src/components/{Buttons → Button}/Toggle.stories.tsx +13 -9
- package/src/components/{Buttons → Button}/ToggleGroup.stories.tsx +10 -7
- package/src/components/{Buttons → Button}/ToggleGroup.tsx +17 -4
- package/src/components/Clipboard/ClipboardProvider.tsx +1 -1
- package/src/components/Clipboard/CopyButton.tsx +6 -5
- package/src/components/DensityProvider/DensityProvider.tsx +2 -2
- package/src/components/{Dialogs → Dialog}/AlertDialog.stories.tsx +15 -12
- package/src/components/{Dialogs → Dialog}/AlertDialog.tsx +13 -13
- package/src/components/Dialog/Dialog.stories.tsx +97 -0
- package/src/components/{Dialogs → Dialog}/Dialog.tsx +151 -51
- package/src/components/ElevationProvider/ElevationProvider.tsx +2 -2
- package/src/components/Icon/Icon.stories.tsx +113 -0
- package/src/components/Icon/Icon.tsx +2 -2
- package/src/components/Input/Input.stories.tsx +13 -15
- package/src/components/Input/Input.tsx +28 -19
- package/src/components/Link/Link.stories.tsx +10 -6
- package/src/components/{Lists → List}/List.stories.tsx +32 -26
- package/src/components/{Lists → List}/List.tsx +17 -13
- package/src/components/{Lists → List}/ListDropIndicator.tsx +1 -1
- package/src/components/{Lists → List}/Tree.stories.tsx +11 -8
- package/src/components/{Lists → List}/Tree.tsx +4 -3
- package/src/components/{Lists → List}/TreeDropIndicator.tsx +1 -1
- package/src/components/{Lists → List}/Treegrid.stories.tsx +12 -6
- package/src/components/{Lists → List}/Treegrid.tsx +58 -17
- package/src/components/Main/Main.stories.tsx +17 -9
- package/src/components/Main/Main.tsx +43 -28
- package/src/components/{Menus → Menu}/ContextMenu.stories.tsx +11 -8
- package/src/components/{Menus → Menu}/ContextMenu.tsx +1 -0
- package/src/components/{Menus → Menu}/DropdownMenu.stories.tsx +12 -9
- package/src/components/{Menus → Menu}/DropdownMenu.tsx +102 -71
- package/src/components/Message/Message.stories.tsx +12 -8
- package/src/components/Message/Message.tsx +30 -5
- package/src/components/Popover/Popover.stories.tsx +12 -9
- package/src/components/Popover/Popover.tsx +64 -45
- package/src/components/ScrollArea/ScrollArea.stories.tsx +64 -11
- package/src/components/ScrollArea/ScrollArea.tsx +54 -8
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +70 -0
- package/src/components/ScrollContainer/ScrollContainer.tsx +233 -0
- package/src/components/ScrollContainer/index.ts +5 -0
- package/src/components/Select/Select.stories.tsx +15 -12
- package/src/components/Select/Select.tsx +9 -8
- package/src/components/Status/Status.stories.tsx +9 -6
- package/src/components/Tag/Tag.stories.tsx +20 -11
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +3 -4
- package/src/components/ThemeProvider/TranslationsProvider.tsx +3 -18
- package/src/components/ThemeProvider/index.ts +3 -3
- package/src/components/Toast/Toast.stories.tsx +12 -9
- package/src/components/Toast/Toast.tsx +9 -9
- package/src/components/Toolbar/Toolbar.stories.tsx +14 -12
- package/src/components/Toolbar/Toolbar.tsx +37 -10
- package/src/components/Tooltip/Tooltip.stories.tsx +16 -12
- package/src/components/Tooltip/Tooltip.tsx +27 -24
- package/src/components/index.ts +5 -4
- package/src/hooks/useDensityContext.ts +1 -1
- package/src/hooks/useElevationContext.ts +1 -1
- package/src/hooks/useSafeArea.ts +3 -2
- package/src/hooks/useVisualViewport.ts +4 -4
- package/src/index.ts +1 -1
- package/src/playground/Controls.stories.tsx +12 -8
- package/src/playground/Custom.stories.tsx +13 -24
- package/src/playground/Typography.stories.tsx +8 -6
- package/src/testing/decorators/index.ts +2 -1
- package/src/testing/decorators/withLayout.tsx +63 -0
- package/src/testing/decorators/{withSurfaceVariantsLayout.tsx → withLayoutVariants.tsx} +5 -5
- package/src/testing/decorators/withTheme.tsx +32 -0
- package/src/util/index.ts +3 -1
- package/src/util/usePx.ts +61 -0
- package/dist/lib/browser/chunk-2COVUP44.mjs +0 -4373
- package/dist/lib/browser/chunk-2COVUP44.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GHXHND5V.mjs +0 -4375
- package/dist/lib/node-esm/chunk-GHXHND5V.mjs.map +0 -7
- package/dist/types/src/components/Buttons/Button.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +0 -12
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/IconButton.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts +0 -22
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/Toggle.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts +0 -19
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/ToggleGroup.d.ts +0 -28
- package/dist/types/src/components/Buttons/ToggleGroup.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +0 -39
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +0 -1
- package/dist/types/src/components/Buttons/index.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/AlertDialog.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +0 -43
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/Dialog.d.ts +0 -31
- package/dist/types/src/components/Dialogs/Dialog.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +0 -48
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/Dialogs/index.d.ts.map +0 -1
- package/dist/types/src/components/Lists/List.d.ts.map +0 -1
- package/dist/types/src/components/Lists/List.stories.d.ts +0 -37
- package/dist/types/src/components/Lists/List.stories.d.ts.map +0 -1
- package/dist/types/src/components/Lists/ListDropIndicator.d.ts.map +0 -1
- package/dist/types/src/components/Lists/Tree.d.ts.map +0 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts +0 -41
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +0 -1
- package/dist/types/src/components/Lists/TreeDropIndicator.d.ts.map +0 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts +0 -10
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +0 -1
- package/dist/types/src/components/Lists/index.d.ts.map +0 -1
- package/dist/types/src/components/Menus/ContextMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +0 -50
- 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 +0 -50
- 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/testing/decorators/withSurfaceVariantsLayout.d.ts +0 -12
- package/dist/types/src/testing/decorators/withSurfaceVariantsLayout.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/src/components/Dialogs/Dialog.stories.tsx +0 -65
- package/src/testing/decorators/withTheme.ts +0 -25
- package/src/util/ThemedClassName.ts +0 -7
- /package/dist/types/src/components/{Buttons → Button}/Toggle.d.ts +0 -0
- /package/dist/types/src/components/{Buttons → Button}/index.d.ts +0 -0
- /package/dist/types/src/components/{Dialogs → Dialog}/index.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/ListDropIndicator.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/TreeDropIndicator.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/index.d.ts +0 -0
- /package/dist/types/src/components/{Menus → Menu}/index.d.ts +0 -0
- /package/src/components/{Buttons → Button}/Toggle.tsx +0 -0
- /package/src/components/{Buttons → Button}/index.ts +0 -0
- /package/src/components/{Dialogs → Dialog}/index.ts +0 -0
- /package/src/components/{Lists → List}/index.ts +0 -0
- /package/src/components/{Menus → Menu}/index.ts +0 -0
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj, type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import { baseSurface, modalSurface,
|
|
11
|
-
import { type MessageValence } from '@dxos/
|
|
8
|
+
import { baseSurface, modalSurface, mx, surfaceShadow } from '@dxos/ui-theme';
|
|
9
|
+
import { type MessageValence } from '@dxos/ui-types';
|
|
10
|
+
|
|
11
|
+
import { withTheme } from '../../testing';
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
type CheckboxProps,
|
|
15
15
|
Input,
|
|
16
16
|
type PinInputProps,
|
|
17
17
|
type SwitchProps,
|
|
18
|
-
type TextInputProps,
|
|
19
18
|
type TextAreaProps,
|
|
19
|
+
type TextInputProps,
|
|
20
20
|
} from './Input';
|
|
21
|
-
import { withTheme } from '../../testing';
|
|
22
21
|
|
|
23
22
|
type VariantMap = {
|
|
24
23
|
text: TextInputProps;
|
|
@@ -75,10 +74,10 @@ const Wrapper = ({
|
|
|
75
74
|
const DefaultStory = (props: BaseProps) => {
|
|
76
75
|
return (
|
|
77
76
|
<div className='space-b-4'>
|
|
78
|
-
<div className={mx(baseSurface, 'p-4')}>
|
|
77
|
+
<div className={mx(baseSurface, 'p-4 rounded-md')}>
|
|
79
78
|
<Wrapper {...props} />
|
|
80
79
|
</div>
|
|
81
|
-
<div className={mx(
|
|
80
|
+
<div className={mx('bg-cardSurface', 'p-4 rounded-md', surfaceShadow({ elevation: 'positioned' }))}>
|
|
82
81
|
<Wrapper {...props} />
|
|
83
82
|
</div>
|
|
84
83
|
<div className={mx(modalSurface, 'p-4 rounded-md', surfaceShadow({ elevation: 'dialog' }))}>
|
|
@@ -88,13 +87,12 @@ const DefaultStory = (props: BaseProps) => {
|
|
|
88
87
|
);
|
|
89
88
|
};
|
|
90
89
|
|
|
91
|
-
const meta
|
|
90
|
+
const meta = {
|
|
92
91
|
title: 'ui/react-ui-core/Input',
|
|
93
|
-
component: Input.Root,
|
|
92
|
+
component: Input.Root as any,
|
|
94
93
|
render: DefaultStory,
|
|
95
94
|
decorators: [withTheme],
|
|
96
|
-
|
|
97
|
-
};
|
|
95
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
98
96
|
|
|
99
97
|
export default meta;
|
|
100
98
|
|
|
@@ -221,10 +219,10 @@ export const Checkbox: Story = {
|
|
|
221
219
|
},
|
|
222
220
|
};
|
|
223
221
|
|
|
224
|
-
export const Switch = {
|
|
222
|
+
export const Switch: Story = {
|
|
225
223
|
args: {
|
|
226
224
|
kind: 'switch',
|
|
227
225
|
label: 'This is a switch',
|
|
228
|
-
description: '
|
|
226
|
+
description: "It's either off... or on.",
|
|
229
227
|
},
|
|
230
228
|
};
|
|
@@ -2,34 +2,33 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type IconWeight } from '@phosphor-icons/react';
|
|
6
5
|
import { Root as CheckboxPrimitive, type CheckboxProps as CheckboxPrimitiveProps } from '@radix-ui/react-checkbox';
|
|
7
6
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
8
|
-
import React, { type ComponentPropsWithRef,
|
|
7
|
+
import React, { type ComponentPropsWithRef, type ForwardRefExoticComponent, forwardRef, useCallback } from 'react';
|
|
9
8
|
|
|
10
9
|
import {
|
|
10
|
+
DescriptionAndValidation as DescriptionAndValidationPrimitive,
|
|
11
|
+
type DescriptionAndValidationProps as DescriptionAndValidationPrimitiveProps,
|
|
12
|
+
Description as DescriptionPrimitive,
|
|
13
|
+
type DescriptionProps as DescriptionPrimitiveProps,
|
|
14
|
+
INPUT_NAME,
|
|
11
15
|
InputRoot,
|
|
12
16
|
type InputRootProps,
|
|
17
|
+
type InputScopedProps,
|
|
18
|
+
Label as LabelPrimitive,
|
|
19
|
+
type LabelProps as LabelPrimitiveProps,
|
|
13
20
|
PinInput as PinInputPrimitive,
|
|
14
21
|
type PinInputProps as PinInputPrimitiveProps,
|
|
15
|
-
TextInput as TextInputPrimitive,
|
|
16
|
-
type TextInputProps as TextInputPrimitiveProps,
|
|
17
22
|
TextArea as TextAreaPrimitive,
|
|
18
23
|
type TextAreaProps as TextAreaPrimitiveProps,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type InputScopedProps,
|
|
22
|
-
Description as DescriptionPrimitive,
|
|
23
|
-
DescriptionAndValidation as DescriptionAndValidationPrimitive,
|
|
24
|
-
type DescriptionAndValidationProps as DescriptionAndValidationPrimitiveProps,
|
|
25
|
-
type DescriptionProps as DescriptionPrimitiveProps,
|
|
26
|
-
Label as LabelPrimitive,
|
|
27
|
-
type LabelProps as LabelPrimitiveProps,
|
|
24
|
+
TextInput as TextInputPrimitive,
|
|
25
|
+
type TextInputProps as TextInputPrimitiveProps,
|
|
28
26
|
Validation as ValidationPrimitive,
|
|
29
27
|
type ValidationProps as ValidationPrimitiveProps,
|
|
28
|
+
useInputContext,
|
|
30
29
|
} from '@dxos/react-input';
|
|
31
|
-
import { mx } from '@dxos/
|
|
32
|
-
import { type
|
|
30
|
+
import { mx } from '@dxos/ui-theme';
|
|
31
|
+
import { type ClassNameValue, type Density, type Elevation, type Size } from '@dxos/ui-types';
|
|
33
32
|
|
|
34
33
|
import { useDensityContext, useElevationContext, useThemeContext } from '../../hooks';
|
|
35
34
|
import { type ThemedClassName } from '../../util';
|
|
@@ -163,10 +162,17 @@ const PinInput = forwardRef<HTMLInputElement, PinInputProps>(
|
|
|
163
162
|
|
|
164
163
|
// TODO(burdon): Implement inline icon within button: e.g., https://www.radix-ui.com/themes/playground#text-field
|
|
165
164
|
|
|
166
|
-
type
|
|
165
|
+
type AutoFillProps = {
|
|
166
|
+
noAutoFill?: boolean;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
type TextInputProps = InputSharedProps & ThemedClassName<TextInputPrimitiveProps> & AutoFillProps;
|
|
167
170
|
|
|
168
171
|
const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>(
|
|
169
|
-
(
|
|
172
|
+
(
|
|
173
|
+
{ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, noAutoFill, ...props },
|
|
174
|
+
forwardedRef,
|
|
175
|
+
) => {
|
|
170
176
|
const { hasIosKeyboard } = useThemeContext();
|
|
171
177
|
const themeContextValue = useThemeContext();
|
|
172
178
|
const density = useDensityContext(propsDensity);
|
|
@@ -178,6 +184,8 @@ const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>
|
|
|
178
184
|
return (
|
|
179
185
|
<TextInputPrimitive
|
|
180
186
|
{...props}
|
|
187
|
+
// TODO(wittjosiah): Factor out autofill properies.
|
|
188
|
+
{...{ 'data-1p-ignore': noAutoFill }}
|
|
181
189
|
className={tx(
|
|
182
190
|
'input.input',
|
|
183
191
|
'input',
|
|
@@ -230,7 +238,9 @@ const TextArea = forwardRef<HTMLTextAreaElement, InputScopedProps<TextAreaProps>
|
|
|
230
238
|
},
|
|
231
239
|
);
|
|
232
240
|
|
|
233
|
-
type CheckboxProps = ThemedClassName<Omit<CheckboxPrimitiveProps, 'children'>> & {
|
|
241
|
+
type CheckboxProps = ThemedClassName<Omit<CheckboxPrimitiveProps, 'children'>> & {
|
|
242
|
+
size?: Size;
|
|
243
|
+
};
|
|
234
244
|
|
|
235
245
|
const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
236
246
|
HTMLButtonElement,
|
|
@@ -243,7 +253,6 @@ const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
|
243
253
|
defaultChecked: propsDefaultChecked,
|
|
244
254
|
onCheckedChange: propsOnCheckedChange,
|
|
245
255
|
size,
|
|
246
|
-
weight = 'bold',
|
|
247
256
|
classNames,
|
|
248
257
|
...props
|
|
249
258
|
},
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import { Link } from './Link';
|
|
8
7
|
import { withTheme } from '../../testing';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
import { Link } from './Link';
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
11
12
|
title: 'ui/react-ui-core/Link',
|
|
12
13
|
component: Link,
|
|
13
14
|
decorators: [withTheme],
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
} satisfies Meta<typeof Link>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
16
20
|
|
|
17
|
-
export const Default = { args: { children: 'Hello', href: '#' } };
|
|
21
|
+
export const Default: Story = { args: { children: 'Hello', href: '#' } };
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { DndContext, type DragEndEvent, type DragStartEvent } from '@dnd-kit/core';
|
|
8
|
-
import {
|
|
6
|
+
import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
9
7
|
import { CSS } from '@dnd-kit/utilities';
|
|
10
8
|
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
11
|
-
import
|
|
9
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
10
|
+
import React, { type ReactNode, useCallback, useState } from 'react';
|
|
12
11
|
|
|
13
12
|
import {
|
|
14
13
|
getSize,
|
|
@@ -17,18 +16,22 @@ import {
|
|
|
17
16
|
ghostSelectedTrackingInterFromNormal,
|
|
18
17
|
mx,
|
|
19
18
|
surfaceShadow,
|
|
20
|
-
} from '@dxos/
|
|
19
|
+
} from '@dxos/ui-theme';
|
|
21
20
|
|
|
22
|
-
import { List, ListItem, type ListScopedProps } from './List';
|
|
23
21
|
import { withTheme } from '../../testing';
|
|
24
22
|
import { Icon } from '../Icon';
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
import { List, ListItem, type ListScopedProps } from './List';
|
|
25
|
+
|
|
26
|
+
const meta = {
|
|
27
27
|
title: 'ui/react-ui-core/List',
|
|
28
28
|
component: List,
|
|
29
29
|
decorators: [withTheme],
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
} satisfies Meta<typeof List>;
|
|
31
|
+
|
|
32
|
+
export default meta;
|
|
33
|
+
|
|
34
|
+
type Story = StoryObj<typeof meta>;
|
|
32
35
|
|
|
33
36
|
const UniformListItem = ({ id, text }: { id: string; text: string }) => {
|
|
34
37
|
const { attributes, listeners, setNodeRef, transform } = useSortable({ id });
|
|
@@ -51,7 +54,7 @@ const UniformListItem = ({ id, text }: { id: string; text: string }) => {
|
|
|
51
54
|
);
|
|
52
55
|
};
|
|
53
56
|
|
|
54
|
-
export const UniformSizeDraggable = {
|
|
57
|
+
export const UniformSizeDraggable: Story = {
|
|
55
58
|
render: ({ ...args }) => {
|
|
56
59
|
const [items, setItems] = useState(
|
|
57
60
|
[...Array(12)].map((_, index) => ({
|
|
@@ -60,16 +63,20 @@ export const UniformSizeDraggable = {
|
|
|
60
63
|
})),
|
|
61
64
|
);
|
|
62
65
|
|
|
63
|
-
const handleDragEnd = (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
const handleDragEnd = useCallback(
|
|
67
|
+
(event: DragEndEvent) => {
|
|
68
|
+
const { active, over } = event;
|
|
69
|
+
if (active.id !== over?.id) {
|
|
70
|
+
setItems((items) => {
|
|
71
|
+
const oldIndex = items.findIndex((item) => item.id === active.id);
|
|
72
|
+
const newIndex = items.findIndex((item) => item.id === over?.id);
|
|
73
|
+
return arrayMove(items, oldIndex, newIndex);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
[items],
|
|
78
|
+
);
|
|
79
|
+
|
|
73
80
|
return (
|
|
74
81
|
<DndContext onDragEnd={handleDragEnd}>
|
|
75
82
|
<SortableContext items={items.map(({ id }) => id)} strategy={verticalListSortingStrategy}>
|
|
@@ -115,7 +122,7 @@ const ManySizesDraggableListItem = ({
|
|
|
115
122
|
);
|
|
116
123
|
};
|
|
117
124
|
|
|
118
|
-
export const ManySizesDraggable = {
|
|
125
|
+
export const ManySizesDraggable: Story = {
|
|
119
126
|
render: ({ ...args }) => {
|
|
120
127
|
const [items, setItems] = useState(
|
|
121
128
|
[...Array(12)].map((_, index) => ({
|
|
@@ -163,7 +170,7 @@ export const ManySizesDraggable = {
|
|
|
163
170
|
args: {},
|
|
164
171
|
};
|
|
165
172
|
|
|
166
|
-
export const Collapsible = {
|
|
173
|
+
export const Collapsible: Story = {
|
|
167
174
|
render: ({ ...args }) => {
|
|
168
175
|
const [items, _setItems] = useState(
|
|
169
176
|
[...Array(12)].map((_, index) => ({
|
|
@@ -192,11 +199,10 @@ export const Collapsible = {
|
|
|
192
199
|
},
|
|
193
200
|
args: {
|
|
194
201
|
variant: 'unordered',
|
|
195
|
-
// toggleOpenLabel: 'Open/close storybook list item', // TODO(burdon): ???
|
|
196
202
|
},
|
|
197
203
|
};
|
|
198
204
|
|
|
199
|
-
export const SelectableListbox = {
|
|
205
|
+
export const SelectableListbox: Story = {
|
|
200
206
|
render: () => {
|
|
201
207
|
const [selectedId, setSelectedId] = useState<string>();
|
|
202
208
|
const arrowNavigationAttrs = useArrowNavigationGroup({ axis: 'vertical' });
|
|
@@ -223,11 +229,11 @@ export const SelectableListbox = {
|
|
|
223
229
|
key={id}
|
|
224
230
|
tabIndex={0}
|
|
225
231
|
selected={selectedId === id}
|
|
226
|
-
classNames={mx(
|
|
232
|
+
classNames={mx(ghostHover, ghostSelected, ghostSelectedTrackingInterFromNormal)}
|
|
227
233
|
onClick={() => setSelectedId(id)}
|
|
228
234
|
onKeyUp={(event) => handleKeyUp(event, id)}
|
|
229
235
|
>
|
|
230
|
-
<ListItem.Heading classNames='
|
|
236
|
+
<ListItem.Heading classNames='flex pli-1 items-center grow truncate'>{text}</ListItem.Heading>
|
|
231
237
|
</ListItem.Root>
|
|
232
238
|
))}
|
|
233
239
|
</List>
|
|
@@ -3,34 +3,35 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Slot } from '@radix-ui/react-slot';
|
|
6
|
-
import React, { type ComponentPropsWithoutRef, type FC,
|
|
6
|
+
import React, { type ComponentPropsWithoutRef, type FC, type ForwardRefExoticComponent, forwardRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
+
LIST_ITEM_NAME,
|
|
10
|
+
LIST_NAME,
|
|
11
|
+
ListItemCollapsibleContent,
|
|
12
|
+
type ListItemCollapsibleContentProps,
|
|
13
|
+
type ListItemScopedProps,
|
|
9
14
|
List as ListPrimitive,
|
|
10
|
-
|
|
11
|
-
type ListScopedProps,
|
|
15
|
+
ListItem as ListPrimitiveItem,
|
|
12
16
|
ListItemHeading as ListPrimitiveItemHeading,
|
|
13
17
|
type ListItemHeadingProps as ListPrimitiveItemHeadingProps,
|
|
14
18
|
ListItemOpenTrigger as ListPrimitiveItemOpenTrigger,
|
|
15
19
|
type ListItemOpenTriggerProps as ListPrimitiveItemOpenTriggerProps,
|
|
16
|
-
ListItemCollapsibleContent,
|
|
17
|
-
type ListItemCollapsibleContentProps,
|
|
18
|
-
ListItem as ListPrimitiveItem,
|
|
19
20
|
type ListItemProps as ListPrimitiveItemProps,
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
LIST_ITEM_NAME,
|
|
21
|
+
type ListProps as ListPrimitiveProps,
|
|
22
|
+
type ListScopedProps,
|
|
23
23
|
useListContext,
|
|
24
24
|
useListItemContext,
|
|
25
25
|
} from '@dxos/react-list';
|
|
26
|
-
import { type Density } from '@dxos/
|
|
26
|
+
import { type Density } from '@dxos/ui-types';
|
|
27
27
|
|
|
28
|
-
import { ListDropIndicator } from './ListDropIndicator';
|
|
29
28
|
import { useDensityContext, useThemeContext } from '../../hooks';
|
|
30
29
|
import { type ThemedClassName } from '../../util';
|
|
31
30
|
import { DensityProvider } from '../DensityProvider';
|
|
32
31
|
import { Icon } from '../Icon';
|
|
33
32
|
|
|
33
|
+
import { ListDropIndicator } from './ListDropIndicator';
|
|
34
|
+
|
|
34
35
|
type ListProps = ThemedClassName<ListPrimitiveProps> & { density?: Density };
|
|
35
36
|
|
|
36
37
|
const List = forwardRef<HTMLOListElement, ListProps>(({ classNames, children, ...props }, forwardedRef) => {
|
|
@@ -106,7 +107,6 @@ const ListItemOpenTrigger = forwardRef<HTMLButtonElement, ListItemOpenTriggerPro
|
|
|
106
107
|
const { tx } = useThemeContext();
|
|
107
108
|
const density = useDensityContext();
|
|
108
109
|
const { open } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
|
|
109
|
-
const iconName = open ? 'ph--caret-down--bold' : 'ph--caret-right--bold';
|
|
110
110
|
return (
|
|
111
111
|
<ListPrimitiveItemOpenTrigger
|
|
112
112
|
{...props}
|
|
@@ -114,7 +114,11 @@ const ListItemOpenTrigger = forwardRef<HTMLButtonElement, ListItemOpenTriggerPro
|
|
|
114
114
|
ref={forwardedRef}
|
|
115
115
|
>
|
|
116
116
|
{children || (
|
|
117
|
-
<Icon
|
|
117
|
+
<Icon
|
|
118
|
+
size={3}
|
|
119
|
+
icon={open ? 'ph--caret-down--bold' : 'ph--caret-right--bold'}
|
|
120
|
+
classNames={tx('list.item.openTriggerIcon', 'list__listItem__openTrigger__icon', {})}
|
|
121
|
+
/>
|
|
118
122
|
)}
|
|
119
123
|
</ListPrimitiveItemOpenTrigger>
|
|
120
124
|
);
|
|
@@ -18,7 +18,7 @@ const orientationStyles: Record<Orientation, HTMLAttributes<HTMLElement>['classN
|
|
|
18
18
|
horizontal:
|
|
19
19
|
'h-[--line-thickness] left-[calc(var(--line-inset)+var(--terminal-radius))] right-[--line-inset] before:left-[--terminal-inset]',
|
|
20
20
|
vertical:
|
|
21
|
-
'
|
|
21
|
+
'is-[--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']> = {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
9
|
-
import { Tree, TreeItem } from './Tree';
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
9
|
|
|
10
|
+
import { Tree, TreeItem } from './Tree';
|
|
11
|
+
|
|
12
12
|
type StorybookTreeProps = {
|
|
13
13
|
data: any;
|
|
14
14
|
};
|
|
@@ -55,15 +55,18 @@ const DefaultStory = ({ data }: StorybookTreeProps) => {
|
|
|
55
55
|
return <StorybookTreeItem data={data} />;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
const meta = {
|
|
59
59
|
title: 'ui/react-ui-core/Tree',
|
|
60
|
-
component: Tree,
|
|
60
|
+
component: Tree as any,
|
|
61
61
|
render: DefaultStory,
|
|
62
62
|
decorators: [withTheme],
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
64
|
+
|
|
65
|
+
export default meta;
|
|
66
|
+
|
|
67
|
+
type Story = StoryObj<typeof meta>;
|
|
65
68
|
|
|
66
|
-
export const Default = {
|
|
69
|
+
export const Default: Story = {
|
|
67
70
|
args: {
|
|
68
71
|
data: {
|
|
69
72
|
foo: 100,
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type ComponentPropsWithoutRef, type FC,
|
|
5
|
+
import React, { type ComponentPropsWithoutRef, type FC, type ForwardRefExoticComponent, forwardRef } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ThemedClassName } from '../../util';
|
|
6
8
|
|
|
7
9
|
import {
|
|
10
|
+
LIST_ITEM_NAME,
|
|
8
11
|
List,
|
|
9
12
|
ListItem,
|
|
10
13
|
type ListItemCollapsibleContentProps,
|
|
@@ -13,11 +16,9 @@ import {
|
|
|
13
16
|
type ListItemRootProps,
|
|
14
17
|
type ListProps,
|
|
15
18
|
type ListScopedProps,
|
|
16
|
-
LIST_ITEM_NAME,
|
|
17
19
|
useListItemContext,
|
|
18
20
|
} from './List';
|
|
19
21
|
import { TreeDropIndicator } from './TreeDropIndicator';
|
|
20
|
-
import { type ThemedClassName } from '../../util';
|
|
21
22
|
|
|
22
23
|
type TreeRootProps = ListProps;
|
|
23
24
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
6
|
-
import React, { type
|
|
6
|
+
import React, { type CSSProperties, type HTMLAttributes } from 'react';
|
|
7
7
|
|
|
8
8
|
// Tree item hitbox
|
|
9
9
|
// https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/hitbox/constellation/index/about.mdx#tree-item
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
8
|
import { faker } from '@dxos/random';
|
|
8
9
|
|
|
9
|
-
import { Treegrid } from './Treegrid';
|
|
10
10
|
import { withTheme } from '../../testing';
|
|
11
11
|
import { Icon } from '../Icon';
|
|
12
12
|
|
|
13
|
+
import { Treegrid } from './Treegrid';
|
|
14
|
+
|
|
13
15
|
faker.seed(1234);
|
|
14
16
|
|
|
15
17
|
type StorybookNode = {
|
|
@@ -86,7 +88,7 @@ const content = {
|
|
|
86
88
|
icon: 'ph--planet--regular',
|
|
87
89
|
},
|
|
88
90
|
],
|
|
89
|
-
}
|
|
91
|
+
} as StorybookNode;
|
|
90
92
|
|
|
91
93
|
function* visitor(node: StorybookNode, isOpen?: (node: StorybookNode) => boolean): Generator<StorybookIteratorNode> {
|
|
92
94
|
const stack: StorybookIteratorNode[] = [
|
|
@@ -141,11 +143,15 @@ const DefaultStory = () => {
|
|
|
141
143
|
);
|
|
142
144
|
};
|
|
143
145
|
|
|
144
|
-
|
|
146
|
+
const meta = {
|
|
145
147
|
title: 'ui/react-ui-core/Treegrid',
|
|
146
|
-
component: Treegrid.Root,
|
|
148
|
+
component: Treegrid.Root as any,
|
|
147
149
|
render: DefaultStory,
|
|
148
150
|
decorators: [withTheme],
|
|
149
|
-
}
|
|
151
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
152
|
+
|
|
153
|
+
export default meta;
|
|
154
|
+
|
|
155
|
+
type Story = StoryObj<typeof meta>;
|
|
150
156
|
|
|
151
|
-
export const Default = {};
|
|
157
|
+
export const Default: Story = {};
|
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useFocusFinders } from '@fluentui/react-tabster';
|
|
6
|
+
import { type Scope, createContextScope } from '@radix-ui/react-context';
|
|
7
7
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
8
|
import { Slot } from '@radix-ui/react-slot';
|
|
9
9
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
10
|
-
import React, {
|
|
10
|
+
import React, {
|
|
11
|
+
type CSSProperties,
|
|
12
|
+
type ComponentPropsWithRef,
|
|
13
|
+
type KeyboardEvent,
|
|
14
|
+
forwardRef,
|
|
15
|
+
useCallback,
|
|
16
|
+
} from 'react';
|
|
11
17
|
|
|
12
18
|
import { useThemeContext } from '../../hooks';
|
|
13
19
|
import { type ThemedClassName } from '../../util';
|
|
@@ -40,12 +46,58 @@ const TreegridRoot = forwardRef<HTMLDivElement, TreegridRootProps>(
|
|
|
40
46
|
({ asChild, classNames, children, style, gridTemplateColumns, ...props }, forwardedRef) => {
|
|
41
47
|
const { tx } = useThemeContext();
|
|
42
48
|
const Root = asChild ? Slot : Primitive.div;
|
|
43
|
-
const
|
|
49
|
+
const { findFirstFocusable } = useFocusFinders();
|
|
50
|
+
|
|
51
|
+
const handleKeyDown = useCallback(
|
|
52
|
+
(event: KeyboardEvent<HTMLDivElement>) => {
|
|
53
|
+
switch (event.key) {
|
|
54
|
+
case 'ArrowDown':
|
|
55
|
+
case 'ArrowUp': {
|
|
56
|
+
const direction = event.key === 'ArrowDown' ? 'down' : 'up';
|
|
57
|
+
const target = event.target as HTMLElement;
|
|
58
|
+
|
|
59
|
+
// Find ancestor with data-arrow-keys containing the relevant direction.
|
|
60
|
+
const ancestorWithArrowKeys = target.closest(`[data-arrow-keys*="${direction}"], [data-arrow-keys="all"]`);
|
|
61
|
+
|
|
62
|
+
// If no ancestor with data-arrow-keys found, proceed with row navigation.
|
|
63
|
+
if (!ancestorWithArrowKeys) {
|
|
64
|
+
// Find the closest row
|
|
65
|
+
const currentRow = target.closest('[role="row"]');
|
|
66
|
+
if (currentRow) {
|
|
67
|
+
// Find the treegrid container.
|
|
68
|
+
const treegrid = currentRow.closest('[role="treegrid"]');
|
|
69
|
+
if (treegrid) {
|
|
70
|
+
// Get all rows in the treegrid.
|
|
71
|
+
const rows = Array.from(treegrid.querySelectorAll('[role="row"]'));
|
|
72
|
+
const currentIndex = rows.indexOf(currentRow as Element);
|
|
73
|
+
|
|
74
|
+
// Find next or previous row.
|
|
75
|
+
const nextIndex = direction === 'down' ? currentIndex + 1 : currentIndex - 1;
|
|
76
|
+
const targetRow = rows[nextIndex];
|
|
77
|
+
|
|
78
|
+
if (targetRow) {
|
|
79
|
+
// Focus the first focusable element in the target row.
|
|
80
|
+
const firstFocusable = findFirstFocusable(targetRow as HTMLElement);
|
|
81
|
+
if (firstFocusable) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
firstFocusable.focus();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
props.onKeyDown?.(event);
|
|
93
|
+
},
|
|
94
|
+
[findFirstFocusable],
|
|
95
|
+
);
|
|
44
96
|
|
|
45
97
|
return (
|
|
46
98
|
<Root
|
|
47
99
|
role='treegrid'
|
|
48
|
-
{
|
|
100
|
+
onKeyDown={handleKeyDown}
|
|
49
101
|
{...props}
|
|
50
102
|
className={tx('treegrid.root', 'treegrid', {}, classNames)}
|
|
51
103
|
style={{ ...style, gridTemplateColumns }}
|
|
@@ -91,13 +143,6 @@ const TreegridRow = forwardRef<HTMLDivElement, TreegridRowScopedProps<TreegridRo
|
|
|
91
143
|
onChange: propsOnOpenChange,
|
|
92
144
|
defaultProp: defaultOpen,
|
|
93
145
|
});
|
|
94
|
-
const focusableGroupAttrs = useFocusableGroup({ tabBehavior: 'limited' });
|
|
95
|
-
const arrowGroupAttrs = useArrowNavigationGroup({
|
|
96
|
-
axis: 'horizontal',
|
|
97
|
-
tabbable: false,
|
|
98
|
-
circular: false,
|
|
99
|
-
memorizeCurrent: false,
|
|
100
|
-
});
|
|
101
146
|
|
|
102
147
|
return (
|
|
103
148
|
<TreegridRowProvider open={open} onOpenChange={onOpenChange} scope={__treegridRowScope}>
|
|
@@ -106,15 +151,11 @@ const TreegridRow = forwardRef<HTMLDivElement, TreegridRowScopedProps<TreegridRo
|
|
|
106
151
|
aria-level={level}
|
|
107
152
|
className={tx('treegrid.row', 'treegrid__row', { level }, classNames)}
|
|
108
153
|
{...(parentOf && { 'aria-expanded': open, 'aria-owns': parentOf })}
|
|
109
|
-
tabIndex={0}
|
|
110
|
-
{...focusableGroupAttrs}
|
|
111
154
|
{...props}
|
|
112
155
|
id={id}
|
|
113
156
|
ref={forwardedRef}
|
|
114
157
|
>
|
|
115
|
-
|
|
116
|
-
{children}
|
|
117
|
-
</div>
|
|
158
|
+
{children}
|
|
118
159
|
</Root>
|
|
119
160
|
</TreegridRowProvider>
|
|
120
161
|
);
|