@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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { faker } from '@dxos/random';
|
|
9
|
+
|
|
10
|
+
import { withLayout, withTheme } from '../../testing';
|
|
11
|
+
import { Button } from '../Button';
|
|
12
|
+
import { Toolbar } from '../Toolbar';
|
|
13
|
+
|
|
14
|
+
import { ScrollContainer, type ScrollContainerRootProps, type ScrollController } from './ScrollContainer';
|
|
15
|
+
|
|
16
|
+
const DefaultStory = (props: ScrollContainerRootProps) => {
|
|
17
|
+
const [lines, setLines] = useState<string[]>([]);
|
|
18
|
+
const [running, setRunning] = useState(true);
|
|
19
|
+
const scroller = useRef<ScrollController>(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!running) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const i = setInterval(() => {
|
|
26
|
+
setLines((lines) => [...lines, faker.lorem.paragraph()]);
|
|
27
|
+
}, 500);
|
|
28
|
+
|
|
29
|
+
return () => clearInterval(i);
|
|
30
|
+
}, [running]);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className='flex flex-col bs-full overflow-hidden'>
|
|
34
|
+
<Toolbar.Root>
|
|
35
|
+
<Button onClick={() => setRunning((running) => !running)}>{running ? 'Stop' : 'Start'}</Button>
|
|
36
|
+
<Button onClick={() => scroller.current?.scrollToBottom()}>Scroll to bottom</Button>
|
|
37
|
+
<div className='flex-1' />
|
|
38
|
+
<div>{lines.length}</div>
|
|
39
|
+
</Toolbar.Root>
|
|
40
|
+
<ScrollContainer.Root {...props} ref={scroller}>
|
|
41
|
+
<ScrollContainer.Viewport>
|
|
42
|
+
{lines.map((line, index) => (
|
|
43
|
+
<div key={index} className='p-2'>
|
|
44
|
+
{line}
|
|
45
|
+
</div>
|
|
46
|
+
))}
|
|
47
|
+
</ScrollContainer.Viewport>
|
|
48
|
+
<ScrollContainer.ScrollDownButton />
|
|
49
|
+
</ScrollContainer.Root>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const meta = {
|
|
55
|
+
title: 'ui/react-ui-core/ScrollContainer',
|
|
56
|
+
component: ScrollContainer.Root,
|
|
57
|
+
render: DefaultStory,
|
|
58
|
+
decorators: [withTheme, withLayout({ layout: 'column', classNames: 'is-[30rem]' })],
|
|
59
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
60
|
+
|
|
61
|
+
export default meta;
|
|
62
|
+
|
|
63
|
+
type Story = StoryObj<typeof meta>;
|
|
64
|
+
|
|
65
|
+
export const Default: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
pin: true,
|
|
68
|
+
fade: true,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createContext } from '@radix-ui/react-context';
|
|
6
|
+
import React, {
|
|
7
|
+
type HTMLAttributes,
|
|
8
|
+
type PropsWithChildren,
|
|
9
|
+
forwardRef,
|
|
10
|
+
useCallback,
|
|
11
|
+
useEffect,
|
|
12
|
+
useImperativeHandle,
|
|
13
|
+
useMemo,
|
|
14
|
+
useRef,
|
|
15
|
+
useState,
|
|
16
|
+
} from 'react';
|
|
17
|
+
|
|
18
|
+
// TODO(burdon): Move these deps to @dxos/dom-util.
|
|
19
|
+
import { addEventListener, combine } from '@dxos/async';
|
|
20
|
+
import { invariant } from '@dxos/invariant';
|
|
21
|
+
import { useForwardedRef } from '@dxos/react-hooks';
|
|
22
|
+
import { mx } from '@dxos/ui-theme';
|
|
23
|
+
|
|
24
|
+
import { type ThemedClassName } from '../../util';
|
|
25
|
+
import { IconButton } from '../Button';
|
|
26
|
+
|
|
27
|
+
const isBottom = (el: HTMLElement | null) => {
|
|
28
|
+
return !!(el && el.scrollHeight - el.scrollTop === el.clientHeight);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface ScrollController {
|
|
32
|
+
viewport: HTMLDivElement | null;
|
|
33
|
+
scrollToTop: (behavior?: ScrollBehavior) => void;
|
|
34
|
+
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type ScrollContainerContextValue = {
|
|
38
|
+
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
39
|
+
controller?: ScrollController;
|
|
40
|
+
pinned?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const [ScrollContainerProvider, useScrollContainerContext] =
|
|
44
|
+
createContext<ScrollContainerContextValue>('ScrollContainer');
|
|
45
|
+
|
|
46
|
+
//
|
|
47
|
+
// Root
|
|
48
|
+
//
|
|
49
|
+
|
|
50
|
+
type RootProps = ThemedClassName<
|
|
51
|
+
PropsWithChildren<{
|
|
52
|
+
pin?: boolean;
|
|
53
|
+
fade?: boolean;
|
|
54
|
+
behavior?: ScrollBehavior;
|
|
55
|
+
}>
|
|
56
|
+
>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Scroll container that automatically scrolls to the bottom when new content is added.
|
|
60
|
+
*/
|
|
61
|
+
const Root = forwardRef<ScrollController, RootProps>(
|
|
62
|
+
({ children, classNames, pin, fade, behavior: behaviorProp = 'smooth' }, forwardedRef) => {
|
|
63
|
+
const scrollerRef = useRef<HTMLDivElement>(null);
|
|
64
|
+
const autoScrollRef = useRef(false);
|
|
65
|
+
const [overflow, setOverflow] = useState(false);
|
|
66
|
+
const [pinned, setPinned] = useState(pin);
|
|
67
|
+
|
|
68
|
+
const timeoutRef = useRef<NodeJS.Timeout>(undefined);
|
|
69
|
+
const scrollToBottom = useCallback((behavior: ScrollBehavior = behaviorProp) => {
|
|
70
|
+
if (scrollerRef.current) {
|
|
71
|
+
// Temporarily hide scrollbar to prevent flicker.
|
|
72
|
+
autoScrollRef.current = true;
|
|
73
|
+
scrollerRef.current.classList.add('scrollbar-none');
|
|
74
|
+
scrollerRef.current.scrollTo({
|
|
75
|
+
top: scrollerRef.current.scrollHeight,
|
|
76
|
+
behavior,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
clearTimeout(timeoutRef.current);
|
|
80
|
+
if (behavior !== 'instant') {
|
|
81
|
+
timeoutRef.current = setTimeout(() => {
|
|
82
|
+
scrollerRef.current?.classList.remove('scrollbar-none');
|
|
83
|
+
autoScrollRef.current = false;
|
|
84
|
+
}, 500);
|
|
85
|
+
}
|
|
86
|
+
setPinned(true);
|
|
87
|
+
}
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
const controller = useMemo(
|
|
91
|
+
() => ({
|
|
92
|
+
viewport: scrollerRef.current,
|
|
93
|
+
scrollToTop: () => {
|
|
94
|
+
invariant(scrollerRef.current);
|
|
95
|
+
scrollerRef.current.scrollTo({ top: 0, behavior: 'smooth' });
|
|
96
|
+
setPinned(false);
|
|
97
|
+
},
|
|
98
|
+
scrollToBottom: () => {
|
|
99
|
+
scrollToBottom('smooth');
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
[scrollToBottom, scrollerRef.current],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// Scroll controller imperative ref.
|
|
106
|
+
useImperativeHandle(forwardedRef, () => controller, [controller]);
|
|
107
|
+
|
|
108
|
+
// Listen for scroll events.
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!scrollerRef.current) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return combine(
|
|
115
|
+
// Check if user scrolls.
|
|
116
|
+
addEventListener(scrollerRef.current, 'wheel', () => {
|
|
117
|
+
setPinned(isBottom(scrollerRef.current));
|
|
118
|
+
}),
|
|
119
|
+
// Check if scrolls.
|
|
120
|
+
addEventListener(scrollerRef.current, 'scroll', () => {
|
|
121
|
+
setOverflow((scrollerRef.current?.scrollTop ?? 0) > 0);
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<ScrollContainerProvider pinned={pinned} controller={controller} scrollToBottom={scrollToBottom}>
|
|
128
|
+
<div className='relative grid flex-1 min-bs-0 overflow-hidden'>
|
|
129
|
+
{fade && (
|
|
130
|
+
<div
|
|
131
|
+
role='none'
|
|
132
|
+
data-visible={overflow}
|
|
133
|
+
className={mx(
|
|
134
|
+
// NOTE: Gradients may not be visible with dark reader extensions.
|
|
135
|
+
'z-10 absolute block-start-0 inset-inline-0 bs-24 is-full',
|
|
136
|
+
'opacity-0 duration-200 transition-opacity data-[visible="true"]:opacity-100',
|
|
137
|
+
'bg-gradient-to-b from-[--surface-bg] to-transparent pointer-events-none',
|
|
138
|
+
)}
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
141
|
+
<div className={mx('flex flex-col min-bs-0 overflow-y-auto scrollbar-thin', classNames)} ref={scrollerRef}>
|
|
142
|
+
{children}
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</ScrollContainerProvider>
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
Root.displayName = 'ScrollContainer.Root';
|
|
151
|
+
|
|
152
|
+
//
|
|
153
|
+
// Viewport
|
|
154
|
+
//
|
|
155
|
+
|
|
156
|
+
type ViewportProps = ThemedClassName<PropsWithChildren<Omit<HTMLAttributes<HTMLDivElement>, 'className'>>>;
|
|
157
|
+
|
|
158
|
+
const Viewport = forwardRef<HTMLDivElement, ViewportProps>(({ classNames, children, ...props }, forwardedRef) => {
|
|
159
|
+
const contentRef = useForwardedRef(forwardedRef);
|
|
160
|
+
const { pinned, scrollToBottom } = useScrollContainerContext(Viewport.displayName!);
|
|
161
|
+
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!pinned || !contentRef.current) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Scroll instantly otherwise it might move while we're scrolling.
|
|
168
|
+
scrollToBottom();
|
|
169
|
+
|
|
170
|
+
// Setup resize observer to detect content changes.
|
|
171
|
+
const resizeObserver = new ResizeObserver(() => scrollToBottom());
|
|
172
|
+
resizeObserver.observe(contentRef.current);
|
|
173
|
+
return () => resizeObserver.disconnect();
|
|
174
|
+
}, [pinned, scrollToBottom]);
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div className={mx('is-full', classNames)} {...props} ref={contentRef}>
|
|
178
|
+
{children}
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
Viewport.displayName = 'ScrollContainer.Viewport';
|
|
184
|
+
|
|
185
|
+
//
|
|
186
|
+
// ScrollDownButton
|
|
187
|
+
//
|
|
188
|
+
|
|
189
|
+
type ScrollDownButtonProps = ThemedClassName;
|
|
190
|
+
|
|
191
|
+
const ScrollDownButton = ({ classNames }: ScrollDownButtonProps) => {
|
|
192
|
+
const { pinned, scrollToBottom } = useScrollContainerContext(ScrollDownButton.displayName!);
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<div
|
|
196
|
+
role='none'
|
|
197
|
+
className={mx(
|
|
198
|
+
'absolute bottom-2 right-4 opacity-100 transition-opacity duration-300',
|
|
199
|
+
pinned && 'opacity-0',
|
|
200
|
+
classNames,
|
|
201
|
+
)}
|
|
202
|
+
>
|
|
203
|
+
<IconButton
|
|
204
|
+
variant='primary'
|
|
205
|
+
icon='ph--arrow-down--regular'
|
|
206
|
+
iconOnly
|
|
207
|
+
size={4}
|
|
208
|
+
label='Scroll down'
|
|
209
|
+
onClick={() => scrollToBottom()}
|
|
210
|
+
/>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
ScrollDownButton.displayName = 'ScrollContainer.ScrollDownButton';
|
|
216
|
+
|
|
217
|
+
//
|
|
218
|
+
// ScrollContainer
|
|
219
|
+
//
|
|
220
|
+
|
|
221
|
+
export { useScrollContainerContext };
|
|
222
|
+
|
|
223
|
+
export const ScrollContainer = {
|
|
224
|
+
Root,
|
|
225
|
+
Viewport,
|
|
226
|
+
ScrollDownButton,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type {
|
|
230
|
+
RootProps as ScrollContainerRootProps,
|
|
231
|
+
ViewportProps as ScrollContainerViewportProps,
|
|
232
|
+
ScrollDownButtonProps as ScrollContainerScrollDownButtonProps,
|
|
233
|
+
};
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { faker } from '@dxos/random';
|
|
11
9
|
|
|
10
|
+
import { withTheme } from '../../testing';
|
|
11
|
+
import { withLayoutVariants } from '../../testing';
|
|
12
|
+
|
|
12
13
|
import { Select } from './Select';
|
|
13
|
-
import { withSurfaceVariantsLayout, withTheme } from '../../testing';
|
|
14
14
|
|
|
15
15
|
faker.seed(1234);
|
|
16
16
|
|
|
@@ -41,15 +41,18 @@ const DefaultStory = ({ items = [] }: StoryProps) => {
|
|
|
41
41
|
);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
const meta = {
|
|
45
|
+
title: 'ui/react-ui-core/Select',
|
|
46
|
+
render: DefaultStory,
|
|
47
|
+
decorators: [withTheme, withLayoutVariants()],
|
|
48
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
49
|
+
|
|
50
|
+
export default meta;
|
|
51
|
+
|
|
52
|
+
type Story = StoryObj<typeof meta>;
|
|
53
|
+
|
|
54
|
+
export const Default: Story = {
|
|
45
55
|
args: {
|
|
46
56
|
items: Array.from({ length: 16 }).map((_, i) => ({ id: `item-${i}`, text: faker.lorem.word() })),
|
|
47
57
|
},
|
|
48
58
|
};
|
|
49
|
-
|
|
50
|
-
export default {
|
|
51
|
-
title: 'ui/react-ui-core/Select',
|
|
52
|
-
render: DefaultStory,
|
|
53
|
-
decorators: [withSurfaceVariantsLayout(), withTheme],
|
|
54
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
55
|
-
};
|
|
@@ -8,7 +8,7 @@ import React, { forwardRef } from 'react';
|
|
|
8
8
|
import { useElevationContext, useThemeContext } from '../../hooks';
|
|
9
9
|
import { useSafeCollisionPadding } from '../../hooks/useSafeCollisionPadding';
|
|
10
10
|
import { type ThemedClassName } from '../../util';
|
|
11
|
-
import { Button, type ButtonProps } from '../
|
|
11
|
+
import { Button, type ButtonProps } from '../Button';
|
|
12
12
|
import { Icon } from '../Icon';
|
|
13
13
|
|
|
14
14
|
type SelectRootProps = SelectPrimitive.SelectProps;
|
|
@@ -35,14 +35,13 @@ type SelectTriggerButtonProps = Omit<ButtonProps, 'children'> & Pick<SelectValue
|
|
|
35
35
|
|
|
36
36
|
const SelectTriggerButton = forwardRef<HTMLButtonElement, SelectTriggerButtonProps>(
|
|
37
37
|
({ children, placeholder, ...props }, forwardedRef) => {
|
|
38
|
-
const { tx } = useThemeContext();
|
|
39
38
|
return (
|
|
40
39
|
<SelectPrimitive.Trigger asChild ref={forwardedRef}>
|
|
41
40
|
<Button {...props}>
|
|
42
41
|
<SelectPrimitive.Value placeholder={placeholder}>{children}</SelectPrimitive.Value>
|
|
43
|
-
<span className='
|
|
42
|
+
<span className='is-1 flex-1' />
|
|
44
43
|
<SelectPrimitive.Icon asChild>
|
|
45
|
-
<Icon icon='ph--caret-down--bold'
|
|
44
|
+
<Icon size={3} icon='ph--caret-down--bold' />
|
|
46
45
|
</SelectPrimitive.Icon>
|
|
47
46
|
</Button>
|
|
48
47
|
</SelectPrimitive.Trigger>
|
|
@@ -60,6 +59,7 @@ const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(
|
|
|
60
59
|
return (
|
|
61
60
|
<SelectPrimitive.Content
|
|
62
61
|
{...props}
|
|
62
|
+
data-arrow-keys='up down'
|
|
63
63
|
collisionPadding={safeCollisionPadding}
|
|
64
64
|
className={tx('select.content', 'select__content', { elevation }, classNames)}
|
|
65
65
|
position='popper'
|
|
@@ -82,7 +82,7 @@ const SelectScrollUpButton = forwardRef<HTMLDivElement, SelectScrollUpButtonProp
|
|
|
82
82
|
className={tx('select.scrollButton', 'select__scroll-button--up', {}, classNames)}
|
|
83
83
|
ref={forwardedRef}
|
|
84
84
|
>
|
|
85
|
-
{children ?? <Icon icon='ph--caret-up--bold' />}
|
|
85
|
+
{children ?? <Icon size={3} icon='ph--caret-up--bold' />}
|
|
86
86
|
</SelectPrimitive.SelectScrollUpButton>
|
|
87
87
|
);
|
|
88
88
|
},
|
|
@@ -99,7 +99,7 @@ const SelectScrollDownButton = forwardRef<HTMLDivElement, SelectScrollDownButton
|
|
|
99
99
|
className={tx('select.scrollButton', 'select__scroll-button--down', {}, classNames)}
|
|
100
100
|
ref={forwardedRef}
|
|
101
101
|
>
|
|
102
|
-
{children ?? <Icon icon='ph--caret-down--bold' />}
|
|
102
|
+
{children ?? <Icon size={3} icon='ph--caret-down--bold' />}
|
|
103
103
|
</SelectPrimitive.SelectScrollDownButton>
|
|
104
104
|
);
|
|
105
105
|
},
|
|
@@ -108,7 +108,7 @@ const SelectScrollDownButton = forwardRef<HTMLDivElement, SelectScrollDownButton
|
|
|
108
108
|
type SelectViewportProps = ThemedClassName<SelectPrimitive.SelectViewportProps>;
|
|
109
109
|
|
|
110
110
|
const SelectViewport = forwardRef<HTMLDivElement, SelectViewportProps>(
|
|
111
|
-
({ classNames,
|
|
111
|
+
({ classNames, children, ...props }, forwardedRef) => {
|
|
112
112
|
const { tx } = useThemeContext();
|
|
113
113
|
return (
|
|
114
114
|
<SelectPrimitive.SelectViewport
|
|
@@ -152,12 +152,13 @@ const SelectItemIndicator = forwardRef<HTMLDivElement, SelectItemIndicatorProps>
|
|
|
152
152
|
|
|
153
153
|
type SelectOptionProps = SelectItemProps;
|
|
154
154
|
|
|
155
|
+
// TODO(burdon): Option to show icon on left/right.
|
|
155
156
|
const SelectOption = forwardRef<HTMLDivElement, SelectItemProps>(({ children, classNames, ...props }, forwardedRef) => {
|
|
156
157
|
const { tx } = useThemeContext();
|
|
157
158
|
return (
|
|
158
159
|
<SelectPrimitive.Item {...props} className={tx('select.item', 'option', {}, classNames)} ref={forwardedRef}>
|
|
159
160
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
160
|
-
<span className='grow
|
|
161
|
+
<span className='grow is-1' />
|
|
161
162
|
{/* <SelectPrimitive.ItemIndicator className={tx('select.itemIndicator', 'option__indicator', {})}> */}
|
|
162
163
|
<Icon icon='ph--check--regular' />
|
|
163
164
|
{/* </SelectPrimitive.ItemIndicator> */}
|
|
@@ -2,19 +2,22 @@
|
|
|
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 { Status } from './Status';
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
import { Status } from './Status';
|
|
11
|
+
|
|
12
|
+
const meta = {
|
|
13
13
|
title: 'ui/react-ui-core/Status',
|
|
14
14
|
component: Status,
|
|
15
15
|
decorators: [withTheme],
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
} satisfies Meta<typeof Status>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
18
21
|
|
|
19
22
|
export const Normal = (props: any) => {
|
|
20
23
|
return (
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
//
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
4
6
|
import React from 'react';
|
|
5
7
|
|
|
6
|
-
import { hues } from '@dxos/
|
|
7
|
-
import '@dxos-
|
|
8
|
-
import { type ChromaticPalette, type MessageValence } from '@dxos/react-ui-types';
|
|
8
|
+
import { hues } from '@dxos/ui-theme';
|
|
9
|
+
import { type ChromaticPalette, type MessageValence } from '@dxos/ui-types';
|
|
9
10
|
|
|
10
|
-
import { Tag } from './Tag';
|
|
11
11
|
import { withTheme } from '../../testing';
|
|
12
12
|
|
|
13
|
+
import { Tag } from './Tag';
|
|
14
|
+
|
|
13
15
|
const palettes = ['neutral', 'success', 'info', 'warning', 'error', ...hues] as (ChromaticPalette | MessageValence)[];
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
const meta = {
|
|
16
18
|
title: 'ui/react-ui-core/Tag',
|
|
17
19
|
component: Tag,
|
|
18
|
-
decorators: [withTheme],
|
|
19
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
20
|
-
} as const;
|
|
21
|
-
|
|
22
|
-
export const Default = {
|
|
23
20
|
render: () => (
|
|
24
21
|
<div role='grid' className='grid grid-cols-5 gap-2 max-is-screen-md'>
|
|
25
22
|
{palettes.map((palette) => (
|
|
@@ -29,4 +26,16 @@ export const Default = {
|
|
|
29
26
|
))}
|
|
30
27
|
</div>
|
|
31
28
|
),
|
|
32
|
-
|
|
29
|
+
decorators: [withTheme],
|
|
30
|
+
parameters: {
|
|
31
|
+
chromatic: {
|
|
32
|
+
disableSnapshot: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
} satisfies Meta<typeof Tag>;
|
|
36
|
+
|
|
37
|
+
export default meta;
|
|
38
|
+
|
|
39
|
+
type Story = StoryObj<typeof meta>;
|
|
40
|
+
|
|
41
|
+
export const Default: Story = {};
|
|
@@ -6,7 +6,7 @@ import { Primitive } from '@radix-ui/react-primitive';
|
|
|
6
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
7
|
import React, { type ComponentPropsWithRef, forwardRef } from 'react';
|
|
8
8
|
|
|
9
|
-
import { type ChromaticPalette, type MessageValence, type NeutralPalette } from '@dxos/
|
|
9
|
+
import { type ChromaticPalette, type MessageValence, type NeutralPalette } from '@dxos/ui-types';
|
|
10
10
|
|
|
11
11
|
import { useThemeContext } from '../../hooks';
|
|
12
12
|
import { type ThemedClassName } from '../../util';
|
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createKeyborg } from 'keyborg';
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { type PropsWithChildren, createContext, useEffect, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type Density, type Elevation, type ThemeFunction } from '@dxos/
|
|
8
|
+
import { type Density, type Elevation, type ThemeFunction, type ThemeMode } from '@dxos/ui-types';
|
|
9
9
|
|
|
10
|
-
import { TranslationsProvider, type TranslationsProviderProps } from './TranslationsProvider';
|
|
11
10
|
import { type SafeAreaPadding, useSafeArea } from '../../hooks';
|
|
12
11
|
import { hasIosKeyboard } from '../../util';
|
|
13
12
|
import { DensityProvider } from '../DensityProvider';
|
|
14
13
|
import { ElevationProvider } from '../ElevationProvider';
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
import { TranslationsProvider, type TranslationsProviderProps } from './TranslationsProvider';
|
|
17
16
|
|
|
18
17
|
export type ThemeContextValue = {
|
|
19
18
|
tx: ThemeFunction<any>;
|
|
@@ -2,30 +2,15 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { enUS as dtLocaleEnUs
|
|
6
|
-
import i18Next, { type
|
|
7
|
-
import React, { type ReactNode,
|
|
5
|
+
import { type Locale, enUS as dtLocaleEnUs } from 'date-fns/locale';
|
|
6
|
+
import i18Next, { type Resource } from 'i18next';
|
|
7
|
+
import React, { type ReactNode, Suspense, createContext, useContext, useEffect, useState } from 'react';
|
|
8
8
|
import { initReactI18next, useTranslation as useI18NextTranslation } from 'react-i18next';
|
|
9
9
|
|
|
10
10
|
const initialLng = 'en-US';
|
|
11
11
|
const initialNs = 'dxos-common';
|
|
12
12
|
const initialDtLocale = dtLocaleEnUs;
|
|
13
13
|
|
|
14
|
-
// TODO(thure): `Parameters<TFunction>` causes typechecking issues because `TFunction` has so many signatures.
|
|
15
|
-
export type Label = string | [string, { ns: string; count?: number; defaultValue?: string }];
|
|
16
|
-
|
|
17
|
-
export const isLabel = (o: any): o is Label =>
|
|
18
|
-
typeof o === 'string' ||
|
|
19
|
-
(Array.isArray(o) &&
|
|
20
|
-
o.length === 2 &&
|
|
21
|
-
typeof o[0] === 'string' &&
|
|
22
|
-
!!o[1] &&
|
|
23
|
-
typeof o[1] === 'object' &&
|
|
24
|
-
'ns' in o[1] &&
|
|
25
|
-
typeof o[1].ns === 'string');
|
|
26
|
-
|
|
27
|
-
export const toLocalizedString = (label: Label, t: TFunction) => (Array.isArray(label) ? t(...label) : label);
|
|
28
|
-
|
|
29
14
|
export const resources = {
|
|
30
15
|
[initialLng]: {
|
|
31
16
|
[initialNs]: {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
export { type Label, isLabel, toLocalizedString, useTranslation } from './TranslationsProvider';
|
|
5
|
+
export { type Label, isLabel, toLocalizedString } from '@dxos/ui-types';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export * from './ThemeProvider';
|
|
8
|
+
export { useTranslation } from './TranslationsProvider';
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
6
|
import React, { type ReactNode, useState } from 'react';
|
|
8
7
|
|
|
9
|
-
import { Toast } from './Toast';
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
|
-
import { Button } from '../
|
|
9
|
+
import { Button } from '../Button';
|
|
10
|
+
|
|
11
|
+
import { Toast } from './Toast';
|
|
12
12
|
|
|
13
13
|
type ActionTriggerProps = { altText: string; trigger: ReactNode };
|
|
14
14
|
|
|
@@ -44,15 +44,18 @@ const DefaultStory = ({ title, description, actionTriggers, openTrigger, closeTr
|
|
|
44
44
|
);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const meta = {
|
|
48
48
|
title: 'ui/react-ui-core/Toast',
|
|
49
|
-
component: Toast,
|
|
49
|
+
component: Toast as any,
|
|
50
50
|
render: DefaultStory,
|
|
51
51
|
decorators: [withTheme],
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
53
|
+
|
|
54
|
+
export default meta;
|
|
55
|
+
|
|
56
|
+
type Story = StoryObj<typeof meta>;
|
|
54
57
|
|
|
55
|
-
export const Default = {
|
|
58
|
+
export const Default: Story = {
|
|
56
59
|
args: {
|
|
57
60
|
openTrigger: 'Open toast',
|
|
58
61
|
title: 'This is a toast',
|
|
@@ -5,22 +5,22 @@
|
|
|
5
5
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
6
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
7
|
import {
|
|
8
|
+
ToastAction as ToastActionPrimitive,
|
|
9
|
+
type ToastActionProps as ToastActionPrimitiveProps,
|
|
10
|
+
ToastClose as ToastClosePrimitive,
|
|
11
|
+
type ToastCloseProps as ToastClosePrimitiveProps,
|
|
12
|
+
ToastDescription as ToastDescriptionPrimitive,
|
|
13
|
+
type ToastDescriptionProps as ToastDescriptionPrimitiveProps,
|
|
8
14
|
ToastProvider as ToastProviderPrimitive,
|
|
9
15
|
type ToastProviderProps as ToastProviderPrimitiveProps,
|
|
10
|
-
ToastViewport as ToastViewportPrimitive,
|
|
11
|
-
type ToastViewportProps as ToastViewportPrimitiveProps,
|
|
12
16
|
Root as ToastRootPrimitive,
|
|
13
17
|
type ToastProps as ToastRootPrimitiveProps,
|
|
14
18
|
ToastTitle as ToastTitlePrimitive,
|
|
15
19
|
type ToastTitleProps as ToastTitlePrimitiveProps,
|
|
16
|
-
|
|
17
|
-
type
|
|
18
|
-
ToastAction as ToastActionPrimitive,
|
|
19
|
-
type ToastActionProps as ToastActionPrimitiveProps,
|
|
20
|
-
ToastClose as ToastClosePrimitive,
|
|
21
|
-
type ToastCloseProps as ToastClosePrimitiveProps,
|
|
20
|
+
ToastViewport as ToastViewportPrimitive,
|
|
21
|
+
type ToastViewportProps as ToastViewportPrimitiveProps,
|
|
22
22
|
} from '@radix-ui/react-toast';
|
|
23
|
-
import React, { type ComponentPropsWithRef,
|
|
23
|
+
import React, { type ComponentPropsWithRef, type FunctionComponent, forwardRef } from 'react';
|
|
24
24
|
|
|
25
25
|
import { useThemeContext } from '../../hooks';
|
|
26
26
|
import { type ThemedClassName } from '../../util';
|