@dxos/react-ui 0.8.4-main.1da679c → 0.8.4-main.21d9917
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 +3068 -61
- 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 +3068 -61
- 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.stories.d.ts +0 -6
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +0 -6
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts +0 -6
- 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/{Buttons → Button}/Button.stories.d.ts +1 -7
- package/dist/types/src/components/Button/Button.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/IconButton.d.ts +2 -2
- package/dist/types/src/components/Button/IconButton.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/IconButton.stories.d.ts +0 -6
- 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/{Buttons → Button}/ToggleGroup.d.ts +6 -10
- 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/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/Dialog/AlertDialog.d.ts.map +1 -0
- package/dist/types/src/components/{Dialogs → Dialog}/AlertDialog.stories.d.ts +0 -6
- 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/{Dialogs → Dialog}/Dialog.stories.d.ts +7 -6
- 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 +5 -4
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +1 -7
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Link/Link.stories.d.ts +0 -6
- package/dist/types/src/components/Link/Link.stories.d.ts.map +1 -1
- package/dist/types/src/components/{Lists → List}/List.d.ts +1 -1
- package/dist/types/src/components/List/List.d.ts.map +1 -0
- package/dist/types/src/components/{Lists → List}/List.stories.d.ts +0 -6
- 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/List/Tree.d.ts.map +1 -0
- package/dist/types/src/components/{Lists → List}/Tree.stories.d.ts +0 -6
- 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.map +1 -1
- 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 +9 -18
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +1 -2
- 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/{Menus → Menu}/ContextMenu.stories.d.ts +0 -6
- package/dist/types/src/components/Menu/ContextMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/DropdownMenu.d.ts +4 -5
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -0
- package/dist/types/src/components/{Menus → Menu}/DropdownMenu.stories.d.ts +0 -6
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts.map +1 -0
- package/dist/types/src/components/Menu/index.d.ts.map +1 -0
- package/dist/types/src/components/Message/Message.d.ts +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +1 -2
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +2 -2
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +0 -6
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +9 -7
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +2 -4
- 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 +0 -6
- 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 +0 -6
- 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 +8 -8
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +1 -2
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -8
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts +2 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +4 -4
- package/dist/types/src/components/Toast/Toast.stories.d.ts +0 -6
- 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 +0 -6
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +1 -3
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +0 -6
- 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 +0 -6
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts +1 -2
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts +0 -6
- 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 +33 -27
- package/src/components/Avatars/Avatar.stories.tsx +2 -4
- package/src/components/Avatars/Avatar.tsx +1 -1
- package/src/components/Avatars/AvatarGroup.stories.tsx +0 -3
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -4
- package/src/components/{Buttons → Button}/Button.stories.tsx +3 -5
- package/src/components/{Buttons → Button}/Button.tsx +1 -1
- package/src/components/{Buttons → Button}/IconButton.stories.tsx +0 -3
- package/src/components/{Buttons → Button}/IconButton.tsx +19 -13
- package/src/components/{Buttons → Button}/Toggle.stories.tsx +5 -7
- package/src/components/{Buttons → Button}/ToggleGroup.stories.tsx +0 -3
- package/src/components/Clipboard/CopyButton.tsx +4 -4
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/{Dialogs → Dialog}/AlertDialog.stories.tsx +1 -4
- package/src/components/Dialog/Dialog.stories.tsx +97 -0
- package/src/components/{Dialogs → Dialog}/Dialog.tsx +140 -40
- package/src/components/ElevationProvider/ElevationProvider.tsx +1 -1
- package/src/components/Icon/Icon.stories.tsx +113 -0
- package/src/components/Icon/Icon.tsx +2 -2
- package/src/components/Input/Input.stories.tsx +2 -5
- package/src/components/Input/Input.tsx +16 -7
- package/src/components/Link/Link.stories.tsx +0 -3
- package/src/components/{Lists → List}/List.stories.tsx +18 -18
- package/src/components/{Lists → List}/List.tsx +1 -1
- package/src/components/{Lists → List}/ListDropIndicator.tsx +1 -1
- package/src/components/{Lists → List}/Tree.stories.tsx +0 -3
- package/src/components/{Lists → List}/Treegrid.tsx +57 -16
- package/src/components/Main/Main.stories.tsx +4 -4
- package/src/components/Main/Main.tsx +28 -19
- package/src/components/{Menus → Menu}/ContextMenu.stories.tsx +0 -3
- package/src/components/{Menus → Menu}/DropdownMenu.stories.tsx +1 -4
- package/src/components/{Menus → Menu}/DropdownMenu.tsx +81 -60
- package/src/components/Message/Message.stories.tsx +1 -3
- package/src/components/Message/Message.tsx +30 -5
- package/src/components/Popover/Popover.stories.tsx +1 -4
- package/src/components/Popover/Popover.tsx +57 -38
- package/src/components/ScrollArea/ScrollArea.stories.tsx +54 -7
- package/src/components/ScrollArea/ScrollArea.tsx +50 -4
- 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 +3 -5
- package/src/components/Select/Select.tsx +4 -4
- package/src/components/Status/Status.stories.tsx +0 -3
- package/src/components/Tag/Tag.stories.tsx +10 -9
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +1 -3
- package/src/components/ThemeProvider/TranslationsProvider.tsx +1 -16
- package/src/components/ThemeProvider/index.ts +3 -3
- package/src/components/Toast/Toast.stories.tsx +1 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -7
- package/src/components/Toolbar/Toolbar.tsx +34 -8
- package/src/components/Tooltip/Tooltip.stories.tsx +1 -4
- package/src/components/Tooltip/Tooltip.tsx +24 -21
- 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 +3 -5
- package/src/playground/Custom.stories.tsx +9 -20
- package/src/playground/Typography.stories.tsx +0 -3
- 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-Y4PW3CX2.mjs +0 -4402
- package/dist/lib/browser/chunk-Y4PW3CX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L6LIOSFT.mjs +0 -4404
- package/dist/lib/node-esm/chunk-L6LIOSFT.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.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.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.map +0 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +0 -37
- 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.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.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.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.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.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.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +0 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +0 -1
- package/dist/types/src/components/Menus/index.d.ts.map +0 -1
- package/dist/types/src/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}/AlertDialog.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}/Tree.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/TreeDropIndicator.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/Treegrid.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/Treegrid.stories.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}/ToggleGroup.tsx +0 -0
- /package/src/components/{Buttons → Button}/index.ts +0 -0
- /package/src/components/{Dialogs → Dialog}/AlertDialog.tsx +0 -0
- /package/src/components/{Dialogs → Dialog}/index.ts +0 -0
- /package/src/components/{Lists → List}/Tree.tsx +0 -0
- /package/src/components/{Lists → List}/TreeDropIndicator.tsx +0 -0
- /package/src/components/{Lists → List}/Treegrid.stories.tsx +0 -0
- /package/src/components/{Lists → List}/index.ts +0 -0
- /package/src/components/{Menus → Menu}/ContextMenu.tsx +0 -0
- /package/src/components/{Menus → Menu}/index.ts +0 -0
|
@@ -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,14 +2,13 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
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
|
|
|
12
|
-
import {
|
|
10
|
+
import { withTheme } from '../../testing';
|
|
11
|
+
import { withLayoutVariants } from '../../testing';
|
|
13
12
|
|
|
14
13
|
import { Select } from './Select';
|
|
15
14
|
|
|
@@ -45,8 +44,7 @@ const DefaultStory = ({ items = [] }: StoryProps) => {
|
|
|
45
44
|
const meta = {
|
|
46
45
|
title: 'ui/react-ui-core/Select',
|
|
47
46
|
render: DefaultStory,
|
|
48
|
-
decorators: [
|
|
49
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
47
|
+
decorators: [withTheme, withLayoutVariants()],
|
|
50
48
|
} satisfies Meta<typeof DefaultStory>;
|
|
51
49
|
|
|
52
50
|
export default meta;
|
|
@@ -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;
|
|
@@ -39,7 +39,7 @@ const SelectTriggerButton = forwardRef<HTMLButtonElement, SelectTriggerButtonPro
|
|
|
39
39
|
<SelectPrimitive.Trigger asChild ref={forwardedRef}>
|
|
40
40
|
<Button {...props}>
|
|
41
41
|
<SelectPrimitive.Value placeholder={placeholder}>{children}</SelectPrimitive.Value>
|
|
42
|
-
<span className='
|
|
42
|
+
<span className='is-1 flex-1' />
|
|
43
43
|
<SelectPrimitive.Icon asChild>
|
|
44
44
|
<Icon size={3} icon='ph--caret-down--bold' />
|
|
45
45
|
</SelectPrimitive.Icon>
|
|
@@ -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
|
|
@@ -158,7 +158,7 @@ const SelectOption = forwardRef<HTMLDivElement, SelectItemProps>(({ children, cl
|
|
|
158
158
|
return (
|
|
159
159
|
<SelectPrimitive.Item {...props} className={tx('select.item', 'option', {}, classNames)} ref={forwardedRef}>
|
|
160
160
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
161
|
-
<span className='grow
|
|
161
|
+
<span className='grow is-1' />
|
|
162
162
|
{/* <SelectPrimitive.ItemIndicator className={tx('select.itemIndicator', 'option__indicator', {})}> */}
|
|
163
163
|
<Icon icon='ph--check--regular' />
|
|
164
164
|
{/* </SelectPrimitive.ItemIndicator> */}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
@@ -15,7 +13,6 @@ const meta = {
|
|
|
15
13
|
title: 'ui/react-ui-core/Status',
|
|
16
14
|
component: Status,
|
|
17
15
|
decorators: [withTheme],
|
|
18
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
19
16
|
} satisfies Meta<typeof Status>;
|
|
20
17
|
|
|
21
18
|
export default meta;
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import { hues } from '@dxos/
|
|
11
|
-
import { type ChromaticPalette, type MessageValence } from '@dxos/
|
|
8
|
+
import { hues } from '@dxos/ui-theme';
|
|
9
|
+
import { type ChromaticPalette, type MessageValence } from '@dxos/ui-types';
|
|
12
10
|
|
|
13
11
|
import { withTheme } from '../../testing';
|
|
14
12
|
|
|
@@ -19,11 +17,6 @@ const palettes = ['neutral', 'success', 'info', 'warning', 'error', ...hues] as
|
|
|
19
17
|
const meta = {
|
|
20
18
|
title: 'ui/react-ui-core/Tag',
|
|
21
19
|
component: Tag,
|
|
22
|
-
decorators: [withTheme],
|
|
23
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
24
|
-
} as const;
|
|
25
|
-
|
|
26
|
-
export const Default: Story = {
|
|
27
20
|
render: () => (
|
|
28
21
|
<div role='grid' className='grid grid-cols-5 gap-2 max-is-screen-md'>
|
|
29
22
|
{palettes.map((palette) => (
|
|
@@ -33,8 +26,16 @@ export const Default: Story = {
|
|
|
33
26
|
))}
|
|
34
27
|
</div>
|
|
35
28
|
),
|
|
29
|
+
decorators: [withTheme],
|
|
30
|
+
parameters: {
|
|
31
|
+
chromatic: {
|
|
32
|
+
disableSnapshot: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
36
35
|
} satisfies Meta<typeof Tag>;
|
|
37
36
|
|
|
38
37
|
export default meta;
|
|
39
38
|
|
|
40
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';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { createKeyborg } from 'keyborg';
|
|
6
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
10
|
import { type SafeAreaPadding, useSafeArea } from '../../hooks';
|
|
11
11
|
import { hasIosKeyboard } from '../../util';
|
|
@@ -14,8 +14,6 @@ import { ElevationProvider } from '../ElevationProvider';
|
|
|
14
14
|
|
|
15
15
|
import { TranslationsProvider, type TranslationsProviderProps } from './TranslationsProvider';
|
|
16
16
|
|
|
17
|
-
export type ThemeMode = 'dark' | 'light';
|
|
18
|
-
|
|
19
17
|
export type ThemeContextValue = {
|
|
20
18
|
tx: ThemeFunction<any>;
|
|
21
19
|
themeMode: ThemeMode;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Locale, enUS as dtLocaleEnUs } from 'date-fns/locale';
|
|
6
|
-
import i18Next, { type Resource
|
|
6
|
+
import i18Next, { type Resource } from 'i18next';
|
|
7
7
|
import React, { type ReactNode, Suspense, createContext, useContext, useEffect, useState } from 'react';
|
|
8
8
|
import { initReactI18next, useTranslation as useI18NextTranslation } from 'react-i18next';
|
|
9
9
|
|
|
@@ -11,21 +11,6 @@ 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,11 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { type ReactNode, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
|
-
import { Button } from '../
|
|
9
|
+
import { Button } from '../Button';
|
|
12
10
|
|
|
13
11
|
import { Toast } from './Toast';
|
|
14
12
|
|
|
@@ -51,7 +49,6 @@ const meta = {
|
|
|
51
49
|
component: Toast as any,
|
|
52
50
|
render: DefaultStory,
|
|
53
51
|
decorators: [withTheme],
|
|
54
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
55
52
|
} satisfies Meta<typeof DefaultStory>;
|
|
56
53
|
|
|
57
54
|
export default meta;
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
|
-
import { Toggle } from '../
|
|
9
|
+
import { Toggle } from '../Button';
|
|
12
10
|
import { Icon } from '../Icon';
|
|
13
11
|
import { Select } from '../Select';
|
|
14
12
|
|
|
@@ -65,9 +63,7 @@ const DefaultStory = (props: StorybookToolbarProps) => {
|
|
|
65
63
|
</Toolbar.Button>
|
|
66
64
|
<Toolbar.Separator />
|
|
67
65
|
<Toolbar.Button>Test</Toolbar.Button>
|
|
68
|
-
<Toolbar.
|
|
69
|
-
<Icon icon='ph--arrow-clockwise--regular' />
|
|
70
|
-
</Toolbar.Button>
|
|
66
|
+
<Toolbar.IconButton icon='ph--arrow-clockwise--regular' label='Refresh' iconOnly />
|
|
71
67
|
</Toolbar.Root>
|
|
72
68
|
);
|
|
73
69
|
};
|
|
@@ -77,7 +73,6 @@ const meta = {
|
|
|
77
73
|
component: Toolbar as any,
|
|
78
74
|
render: DefaultStory,
|
|
79
75
|
decorators: [withTheme],
|
|
80
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
81
76
|
} satisfies Meta<typeof DefaultStory>;
|
|
82
77
|
|
|
83
78
|
export default meta;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type { ToggleGroupItemProps as ToggleGroupItemPrimitiveProps } from '@radix-ui/react-toggle-group';
|
|
6
6
|
import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
|
|
7
|
-
import React, { forwardRef } from 'react';
|
|
7
|
+
import React, { Fragment, forwardRef } from 'react';
|
|
8
8
|
|
|
9
9
|
import { useThemeContext } from '../../hooks';
|
|
10
10
|
import { type ThemedClassName } from '../../util';
|
|
@@ -18,23 +18,38 @@ import {
|
|
|
18
18
|
Toggle,
|
|
19
19
|
type ToggleGroupItemProps,
|
|
20
20
|
type ToggleProps,
|
|
21
|
-
} from '../
|
|
21
|
+
} from '../Button';
|
|
22
22
|
import { Link, type LinkProps } from '../Link';
|
|
23
23
|
import { Separator, type SeparatorProps } from '../Separator';
|
|
24
24
|
|
|
25
|
-
type ToolbarRootProps = ThemedClassName<
|
|
25
|
+
type ToolbarRootProps = ThemedClassName<
|
|
26
|
+
ToolbarPrimitive.ToolbarProps & {
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
layoutManaged?: boolean; // TODO(burdon): Replace with Toolbar.Content to allow inner layout management?
|
|
29
|
+
textBlockWidth?: boolean;
|
|
30
|
+
}
|
|
31
|
+
>;
|
|
26
32
|
|
|
33
|
+
// TODO(burdon): Implement asChild.
|
|
27
34
|
const ToolbarRoot = forwardRef<HTMLDivElement, ToolbarRootProps>(
|
|
28
|
-
({ classNames, children, layoutManaged, ...props }, forwardedRef) => {
|
|
35
|
+
({ classNames, children, disabled, layoutManaged, textBlockWidth: textBlockWidthProp, ...props }, forwardedRef) => {
|
|
29
36
|
const { tx } = useThemeContext();
|
|
37
|
+
const InnerRoot = textBlockWidthProp ? 'div' : Fragment;
|
|
38
|
+
const innerRootProps = textBlockWidthProp
|
|
39
|
+
? {
|
|
40
|
+
role: 'none',
|
|
41
|
+
className: tx('toolbar.inner', 'toolbar', { layoutManaged }, classNames),
|
|
42
|
+
}
|
|
43
|
+
: {};
|
|
44
|
+
|
|
30
45
|
return (
|
|
31
46
|
<ToolbarPrimitive.Root
|
|
32
47
|
{...props}
|
|
33
48
|
data-arrow-keys={props.orientation === 'vertical' ? 'up down' : 'left right'}
|
|
34
|
-
className={tx('toolbar.root', 'toolbar', { layoutManaged }, classNames)}
|
|
49
|
+
className={tx('toolbar.root', 'toolbar', { layoutManaged, disabled }, classNames)}
|
|
35
50
|
ref={forwardedRef}
|
|
36
51
|
>
|
|
37
|
-
{children}
|
|
52
|
+
<InnerRoot {...innerRootProps}>{children}</InnerRoot>
|
|
38
53
|
</ToolbarPrimitive.Root>
|
|
39
54
|
);
|
|
40
55
|
},
|
|
@@ -55,7 +70,7 @@ type ToolbarIconButtonProps = IconButtonProps;
|
|
|
55
70
|
const ToolbarIconButton = forwardRef<HTMLButtonElement, ToolbarIconButtonProps>((props, forwardedRef) => {
|
|
56
71
|
return (
|
|
57
72
|
<ToolbarPrimitive.Button asChild>
|
|
58
|
-
<IconButton {...props} ref={forwardedRef} />
|
|
73
|
+
<IconButton {...props} noTooltip ref={forwardedRef} />
|
|
59
74
|
</ToolbarPrimitive.Button>
|
|
60
75
|
);
|
|
61
76
|
});
|
|
@@ -114,7 +129,18 @@ const ToolbarToggleGroupIconItem = forwardRef<HTMLButtonElement, ToolbarToggleGr
|
|
|
114
129
|
({ variant, density, elevation, classNames, icon, label, iconOnly, ...props }, forwardedRef) => {
|
|
115
130
|
return (
|
|
116
131
|
<ToolbarPrimitive.ToolbarToggleItem {...props} asChild>
|
|
117
|
-
<IconButton
|
|
132
|
+
<IconButton
|
|
133
|
+
{...{
|
|
134
|
+
variant,
|
|
135
|
+
density,
|
|
136
|
+
elevation,
|
|
137
|
+
classNames,
|
|
138
|
+
icon,
|
|
139
|
+
label,
|
|
140
|
+
iconOnly,
|
|
141
|
+
}}
|
|
142
|
+
ref={forwardedRef}
|
|
143
|
+
/>
|
|
118
144
|
</ToolbarPrimitive.ToolbarToggleItem>
|
|
119
145
|
);
|
|
120
146
|
},
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
8
|
import { faker } from '@dxos/random';
|
|
11
9
|
|
|
12
10
|
import { withTheme } from '../../testing';
|
|
13
|
-
import { Button } from '../
|
|
11
|
+
import { Button } from '../Button';
|
|
14
12
|
|
|
15
13
|
import { Tooltip } from './Tooltip';
|
|
16
14
|
|
|
@@ -36,7 +34,6 @@ const meta = {
|
|
|
36
34
|
component: Tooltip as any,
|
|
37
35
|
render: DefaultStory,
|
|
38
36
|
decorators: [withTheme],
|
|
39
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
40
37
|
} satisfies Meta<typeof DefaultStory>;
|
|
41
38
|
|
|
42
39
|
export default meta;
|