@dxos/react-ui 0.8.4-main.f9ba587 → 0.8.4-main.fffef41
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-T6YPS45E.mjs → chunk-N5GDJTT2.mjs} +704 -373
- package/dist/lib/browser/chunk-N5GDJTT2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +11 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +57 -30
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-TYVQJ4KW.mjs → chunk-SP7VQH72.mjs} +704 -373
- package/dist/lib/node-esm/chunk-SP7VQH72.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +11 -1
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +57 -30
- 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 +1 -1
- 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 +2 -3
- 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/{Buttons → Button}/ToggleGroup.d.ts +7 -8
- 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.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/{Dialogs → Dialog}/Dialog.d.ts +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +25 -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.map +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts +1 -1
- 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 +2 -4
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +10 -11
- 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 +2 -2
- 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/ContextMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +6 -44
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts +8 -8
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts +6 -41
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.d.ts +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +7 -16
- 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 +6 -34
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +6 -32
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +37 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -0
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +18 -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 +1 -1
- 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/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.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 +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +1 -1
- 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 +12 -12
- 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 +4 -3
- package/dist/types/src/components/index.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/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/{withSurfaceVariantsLayout.d.ts → withLayoutVariants.d.ts} +2 -2
- 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/domino.d.ts +18 -0
- package/dist/types/src/util/domino.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +3 -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 +26 -23
- package/src/components/Avatars/Avatar.stories.tsx +19 -10
- package/src/components/Avatars/Avatar.tsx +3 -3
- package/src/components/Avatars/AvatarGroup.stories.tsx +10 -6
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +17 -12
- package/src/components/Breadcrumb/Breadcrumb.tsx +3 -3
- package/src/components/{Buttons → Button}/Button.stories.tsx +10 -11
- package/src/components/{Buttons → Button}/IconButton.stories.tsx +11 -8
- package/src/components/{Buttons → Button}/IconButton.tsx +16 -14
- package/src/components/Button/Toggle.stories.tsx +37 -0
- package/src/components/{Buttons → Button}/ToggleGroup.stories.tsx +13 -10
- package/src/components/{Buttons → Button}/ToggleGroup.tsx +17 -4
- package/src/components/Clipboard/ClipboardProvider.tsx +1 -1
- package/src/components/Clipboard/CopyButton.tsx +4 -3
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/{Dialogs → Dialog}/AlertDialog.stories.tsx +15 -12
- package/src/components/{Dialogs → Dialog}/AlertDialog.tsx +13 -13
- package/src/components/{Dialogs → Dialog}/Dialog.stories.tsx +17 -15
- package/src/components/{Dialogs → Dialog}/Dialog.tsx +13 -13
- package/src/components/ElevationProvider/ElevationProvider.tsx +1 -1
- package/src/components/Icon/Icon.stories.tsx +113 -0
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/Input/Input.stories.tsx +12 -14
- package/src/components/Input/Input.tsx +16 -16
- package/src/components/Link/Link.stories.tsx +10 -6
- package/src/components/{Lists → List}/List.stories.tsx +22 -20
- package/src/components/{Lists → List}/List.tsx +15 -16
- 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/ContextMenu.stories.tsx +11 -8
- package/src/components/Menus/ContextMenu.tsx +1 -0
- package/src/components/Menus/DropdownMenu.stories.tsx +12 -9
- package/src/components/Menus/DropdownMenu.tsx +45 -16
- package/src/components/Message/Message.stories.tsx +11 -7
- package/src/components/Message/Message.tsx +1 -1
- package/src/components/Popover/Popover.stories.tsx +12 -9
- package/src/components/Popover/Popover.tsx +29 -12
- package/src/components/ScrollArea/ScrollArea.stories.tsx +12 -9
- package/src/components/ScrollArea/ScrollArea.tsx +4 -4
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +69 -0
- package/src/components/ScrollContainer/ScrollContainer.tsx +231 -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 -9
- package/src/components/Status/Status.stories.tsx +9 -6
- package/src/components/Tag/Tag.stories.tsx +18 -9
- package/src/components/ThemeProvider/ThemeProvider.tsx +3 -2
- package/src/components/ThemeProvider/TranslationsProvider.tsx +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 +21 -19
- package/src/components/Toolbar/Toolbar.tsx +20 -8
- package/src/components/Tooltip/Tooltip.stories.tsx +16 -12
- package/src/components/Tooltip/Tooltip.tsx +5 -4
- package/src/components/index.ts +4 -3
- package/src/hooks/useSafeArea.ts +3 -2
- package/src/hooks/useSafeCollisionPadding.ts +1 -1
- package/src/hooks/useVisualViewport.ts +4 -4
- package/src/playground/Controls.stories.tsx +20 -17
- 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 +56 -0
- package/src/testing/decorators/{withSurfaceVariantsLayout.tsx → withLayoutVariants.tsx} +2 -2
- package/src/testing/decorators/withTheme.tsx +31 -0
- package/src/util/domino.ts +53 -0
- package/src/util/index.ts +3 -1
- package/src/util/usePx.ts +61 -0
- package/dist/lib/browser/chunk-T6YPS45E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TYVQJ4KW.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.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.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/testing/decorators/withSurfaceVariantsLayout.d.ts.map +0 -1
- package/src/components/Buttons/Toggle.stories.tsx +0 -33
- package/src/testing/decorators/withTheme.ts +0 -22
- /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/src/components/{Buttons → Button}/Button.tsx +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
|
@@ -2,34 +2,35 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { CaretDown, CaretRight } from '@phosphor-icons/react';
|
|
6
5
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
|
-
import React, { type ComponentPropsWithoutRef, type FC,
|
|
6
|
+
import React, { type ComponentPropsWithoutRef, type FC, type ForwardRefExoticComponent, forwardRef } from 'react';
|
|
8
7
|
|
|
9
8
|
import {
|
|
9
|
+
LIST_ITEM_NAME,
|
|
10
|
+
LIST_NAME,
|
|
11
|
+
ListItemCollapsibleContent,
|
|
12
|
+
type ListItemCollapsibleContentProps,
|
|
13
|
+
type ListItemScopedProps,
|
|
10
14
|
List as ListPrimitive,
|
|
11
|
-
|
|
12
|
-
type ListScopedProps,
|
|
15
|
+
ListItem as ListPrimitiveItem,
|
|
13
16
|
ListItemHeading as ListPrimitiveItemHeading,
|
|
14
17
|
type ListItemHeadingProps as ListPrimitiveItemHeadingProps,
|
|
15
18
|
ListItemOpenTrigger as ListPrimitiveItemOpenTrigger,
|
|
16
19
|
type ListItemOpenTriggerProps as ListPrimitiveItemOpenTriggerProps,
|
|
17
|
-
ListItemCollapsibleContent,
|
|
18
|
-
type ListItemCollapsibleContentProps,
|
|
19
|
-
ListItem as ListPrimitiveItem,
|
|
20
20
|
type ListItemProps as ListPrimitiveItemProps,
|
|
21
|
-
type
|
|
22
|
-
|
|
23
|
-
LIST_ITEM_NAME,
|
|
21
|
+
type ListProps as ListPrimitiveProps,
|
|
22
|
+
type ListScopedProps,
|
|
24
23
|
useListContext,
|
|
25
24
|
useListItemContext,
|
|
26
25
|
} from '@dxos/react-list';
|
|
27
26
|
import { type Density } from '@dxos/react-ui-types';
|
|
28
27
|
|
|
29
|
-
import { ListDropIndicator } from './ListDropIndicator';
|
|
30
28
|
import { useDensityContext, useThemeContext } from '../../hooks';
|
|
31
29
|
import { type ThemedClassName } from '../../util';
|
|
32
30
|
import { DensityProvider } from '../DensityProvider';
|
|
31
|
+
import { Icon } from '../Icon';
|
|
32
|
+
|
|
33
|
+
import { ListDropIndicator } from './ListDropIndicator';
|
|
33
34
|
|
|
34
35
|
type ListProps = ThemedClassName<ListPrimitiveProps> & { density?: Density };
|
|
35
36
|
|
|
@@ -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 Icon = open ? CaretDown : CaretRight;
|
|
110
110
|
return (
|
|
111
111
|
<ListPrimitiveItemOpenTrigger
|
|
112
112
|
{...props}
|
|
@@ -115,10 +115,9 @@ const ListItemOpenTrigger = forwardRef<HTMLButtonElement, ListItemOpenTriggerPro
|
|
|
115
115
|
>
|
|
116
116
|
{children || (
|
|
117
117
|
<Icon
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}}
|
|
118
|
+
size={3}
|
|
119
|
+
icon={open ? 'ph--caret-down--bold' : 'ph--caret-right--bold'}
|
|
120
|
+
classNames={tx('list.item.openTriggerIcon', 'list__listItem__openTrigger__icon', {})}
|
|
122
121
|
/>
|
|
123
122
|
)}
|
|
124
123
|
</ListPrimitiveItemOpenTrigger>
|
|
@@ -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
|
);
|
|
@@ -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 { Main, useSidebars } from './Main';
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
|
-
import { Button } from '../
|
|
9
|
+
import { Button } from '../Button';
|
|
10
|
+
|
|
11
|
+
import { Main, useSidebars } from './Main';
|
|
12
12
|
|
|
13
13
|
type StoryMainArgs = {};
|
|
14
14
|
|
|
@@ -45,15 +45,23 @@ const DefaultStory = (_args: StoryMainArgs) => {
|
|
|
45
45
|
);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const meta = {
|
|
49
49
|
title: 'ui/react-ui-core/Main',
|
|
50
50
|
component: Main.Root,
|
|
51
51
|
render: DefaultStory,
|
|
52
52
|
decorators: [withTheme],
|
|
53
|
-
parameters: {
|
|
54
|
-
|
|
53
|
+
parameters: {
|
|
54
|
+
layout: 'fullscreen',
|
|
55
|
+
chromatic: {
|
|
56
|
+
disableSnapshot: false,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
60
|
+
|
|
61
|
+
export default meta;
|
|
62
|
+
|
|
63
|
+
type Story = StoryObj<typeof meta>;
|
|
55
64
|
|
|
56
|
-
export const Default = {
|
|
65
|
+
export const Default: Story = {
|
|
57
66
|
args: {},
|
|
58
|
-
layout: 'fullscreen',
|
|
59
67
|
};
|
|
@@ -2,49 +2,41 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { useFocusableGroup } from '@fluentui/react-tabster';
|
|
5
6
|
import { createContext } from '@radix-ui/react-context';
|
|
6
|
-
import { Root as DialogRoot,
|
|
7
|
+
import { DialogContent, Root as DialogRoot, DialogTitle } from '@radix-ui/react-dialog';
|
|
7
8
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
9
|
import { Slot } from '@radix-ui/react-slot';
|
|
9
10
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
10
11
|
import React, {
|
|
11
12
|
type ComponentPropsWithRef,
|
|
13
|
+
type ComponentPropsWithoutRef,
|
|
12
14
|
type Dispatch,
|
|
13
|
-
|
|
15
|
+
type KeyboardEvent,
|
|
14
16
|
type PropsWithChildren,
|
|
15
17
|
type SetStateAction,
|
|
18
|
+
forwardRef,
|
|
16
19
|
useCallback,
|
|
17
20
|
useEffect,
|
|
18
21
|
useRef,
|
|
19
22
|
useState,
|
|
20
|
-
type KeyboardEvent,
|
|
21
|
-
type ComponentPropsWithoutRef,
|
|
22
23
|
} from 'react';
|
|
23
24
|
|
|
24
25
|
import { log } from '@dxos/log';
|
|
25
|
-
import {
|
|
26
|
+
import { useForwardedRef, useMediaQuery } from '@dxos/react-hooks';
|
|
26
27
|
|
|
27
|
-
import { useSwipeToDismiss } from './useSwipeToDismiss';
|
|
28
28
|
import { useThemeContext } from '../../hooks';
|
|
29
29
|
import { type ThemedClassName } from '../../util';
|
|
30
30
|
import { type Label, toLocalizedString, useTranslation } from '../ThemeProvider';
|
|
31
31
|
|
|
32
|
+
import { useSwipeToDismiss } from './useSwipeToDismiss';
|
|
33
|
+
|
|
34
|
+
const MAIN_NAME = 'Main';
|
|
32
35
|
const MAIN_ROOT_NAME = 'MainRoot';
|
|
33
36
|
const NAVIGATION_SIDEBAR_NAME = 'NavigationSidebar';
|
|
34
37
|
const COMPLEMENTARY_SIDEBAR_NAME = 'ComplementarySidebar';
|
|
35
|
-
const MAIN_NAME = 'Main';
|
|
36
38
|
const GENERIC_CONSUMER_NAME = 'GenericConsumer';
|
|
37
39
|
|
|
38
|
-
type SidebarState = 'expanded' | 'collapsed' | 'closed';
|
|
39
|
-
|
|
40
|
-
type MainContextValue = {
|
|
41
|
-
resizing: boolean;
|
|
42
|
-
navigationSidebarState: SidebarState;
|
|
43
|
-
setNavigationSidebarState: Dispatch<SetStateAction<SidebarState | undefined>>;
|
|
44
|
-
complementarySidebarState: SidebarState;
|
|
45
|
-
setComplementarySidebarState: Dispatch<SetStateAction<SidebarState | undefined>>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
40
|
const landmarkAttr = 'data-main-landmark';
|
|
49
41
|
|
|
50
42
|
/**
|
|
@@ -69,20 +61,38 @@ const useLandmarkMover = (propsOnKeyDown: ComponentPropsWithoutRef<'div'>['onKey
|
|
|
69
61
|
},
|
|
70
62
|
[propsOnKeyDown],
|
|
71
63
|
);
|
|
72
|
-
const focusableGroupAttrs = window ? {} : { tabBehavior: 'limited', ignoreDefaultKeydown: { Tab: true } };
|
|
73
64
|
|
|
74
|
-
|
|
65
|
+
// TODO(thure): This was disconnected once before in #8818;
|
|
66
|
+
// if this should change again to support the browser extension, please ensure the change doesn’t break web, desktop and mobile.
|
|
67
|
+
const focusableGroupAttrs = useFocusableGroup({ tabBehavior: 'limited', ignoreDefaultKeydown: { Tab: true } });
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
onKeyDown: handleKeyDown,
|
|
71
|
+
[landmarkAttr]: landmark,
|
|
72
|
+
tabIndex: 0,
|
|
73
|
+
...focusableGroupAttrs,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type SidebarState = 'expanded' | 'collapsed' | 'closed';
|
|
78
|
+
|
|
79
|
+
type MainContextValue = {
|
|
80
|
+
resizing: boolean;
|
|
81
|
+
navigationSidebarState: SidebarState;
|
|
82
|
+
setNavigationSidebarState: Dispatch<SetStateAction<SidebarState | undefined>>;
|
|
83
|
+
complementarySidebarState: SidebarState;
|
|
84
|
+
setComplementarySidebarState: Dispatch<SetStateAction<SidebarState | undefined>>;
|
|
75
85
|
};
|
|
76
86
|
|
|
77
87
|
const [MainProvider, useMainContext] = createContext<MainContextValue>(MAIN_NAME, {
|
|
78
88
|
resizing: false,
|
|
79
89
|
navigationSidebarState: 'closed',
|
|
80
|
-
setNavigationSidebarState: (
|
|
90
|
+
setNavigationSidebarState: (_nextState) => {
|
|
81
91
|
// TODO(burdon): Standardize with other context missing errors using raise.
|
|
82
92
|
log.warn('Attempt to set sidebar state without initializing `MainRoot`');
|
|
83
93
|
},
|
|
84
94
|
complementarySidebarState: 'closed',
|
|
85
|
-
setComplementarySidebarState: (
|
|
95
|
+
setComplementarySidebarState: (_nextState) => {
|
|
86
96
|
// TODO(burdon): Standardize with other context missing errors using raise.
|
|
87
97
|
log.warn('Attempt to set sidebar state without initializing `MainRoot`');
|
|
88
98
|
},
|
|
@@ -135,7 +145,7 @@ const MainRoot = ({
|
|
|
135
145
|
children,
|
|
136
146
|
...props
|
|
137
147
|
}: MainRootProps) => {
|
|
138
|
-
const [isLg] = useMediaQuery('lg'
|
|
148
|
+
const [isLg] = useMediaQuery('lg');
|
|
139
149
|
const [navigationSidebarState = isLg ? 'expanded' : 'collapsed', setNavigationSidebarState] =
|
|
140
150
|
useControllableState<SidebarState>({
|
|
141
151
|
prop: propsNavigationSidebarState,
|
|
@@ -204,7 +214,7 @@ const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
|
204
214
|
{ classNames, children, swipeToDismiss, onOpenAutoFocus, state, resizing, onStateChange, side, label, ...props },
|
|
205
215
|
forwardedRef,
|
|
206
216
|
) => {
|
|
207
|
-
const [isLg] = useMediaQuery('lg'
|
|
217
|
+
const [isLg] = useMediaQuery('lg');
|
|
208
218
|
const { tx } = useThemeContext();
|
|
209
219
|
const { t } = useTranslation();
|
|
210
220
|
const ref = useForwardedRef(forwardedRef);
|
|
@@ -212,10 +222,15 @@ const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
|
212
222
|
useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
|
|
213
223
|
onDismiss: () => onStateChange?.('closed'),
|
|
214
224
|
});
|
|
225
|
+
// NOTE(thure): This is a workaround for something further down the tree grabbing focus on Escape. Adding this
|
|
226
|
+
// intervention to `Tabs.Root` or `Tabs.Tabpenel` instances is somehow ineffectual.
|
|
215
227
|
const handleKeyDown = useCallback(
|
|
216
228
|
(event: KeyboardEvent<HTMLDivElement>) => {
|
|
217
|
-
|
|
218
|
-
|
|
229
|
+
const focusGroupParent = (event.target as HTMLElement).closest('[data-tabster]');
|
|
230
|
+
if (event.key === 'Escape' && focusGroupParent) {
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
event.stopPropagation();
|
|
233
|
+
(focusGroupParent as HTMLElement).focus();
|
|
219
234
|
}
|
|
220
235
|
props.onKeyDown?.(event);
|
|
221
236
|
},
|
|
@@ -233,8 +248,8 @@ const MainSidebar = forwardRef<HTMLDivElement, MainSidebarProps>(
|
|
|
233
248
|
data-state={state}
|
|
234
249
|
data-resizing={resizing ? 'true' : 'false'}
|
|
235
250
|
className={tx('main.sidebar', 'main__sidebar', {}, classNames)}
|
|
236
|
-
|
|
237
|
-
{...(state === 'closed' && { inert:
|
|
251
|
+
onKeyDownCapture={handleKeyDown}
|
|
252
|
+
{...(state === 'closed' && { inert: true })}
|
|
238
253
|
ref={ref}
|
|
239
254
|
>
|
|
240
255
|
{children}
|
|
@@ -323,7 +338,7 @@ MainContent.displayName = MAIN_NAME;
|
|
|
323
338
|
type MainOverlayProps = ThemedClassName<Omit<ComponentPropsWithRef<typeof Primitive.div>, 'children'>>;
|
|
324
339
|
|
|
325
340
|
const MainOverlay = forwardRef<HTMLDivElement, MainOverlayProps>(({ classNames, ...props }, forwardedRef) => {
|
|
326
|
-
const [isLg] = useMediaQuery('lg'
|
|
341
|
+
const [isLg] = useMediaQuery('lg');
|
|
327
342
|
const { navigationSidebarState, setNavigationSidebarState, complementarySidebarState, setComplementarySidebarState } =
|
|
328
343
|
useMainContext(MAIN_NAME);
|
|
329
344
|
const { tx } = useThemeContext();
|
|
@@ -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 from 'react';
|
|
8
7
|
|
|
9
|
-
import { ContextMenu } from './ContextMenu';
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
9
|
|
|
10
|
+
import { ContextMenu } from './ContextMenu';
|
|
11
|
+
|
|
12
12
|
const DefaultStory = () => {
|
|
13
13
|
// NOTE(thure): Since long-tap will select text in some OSs, apply `select-none` to `ContextMenu.Trigger` where possible.
|
|
14
14
|
return (
|
|
@@ -91,15 +91,18 @@ const DefaultStory = () => {
|
|
|
91
91
|
);
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
const meta = {
|
|
95
95
|
title: 'ui/react-ui-core/ContextMenu',
|
|
96
|
-
component: ContextMenu,
|
|
96
|
+
component: ContextMenu.Root as any,
|
|
97
97
|
render: DefaultStory,
|
|
98
98
|
decorators: [withTheme],
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
100
|
+
|
|
101
|
+
export default meta;
|
|
102
|
+
|
|
103
|
+
type Story = StoryObj<typeof meta>;
|
|
101
104
|
|
|
102
|
-
export const Default = {
|
|
105
|
+
export const Default: Story = {
|
|
103
106
|
args: {},
|
|
104
107
|
parameters: {
|
|
105
108
|
chromatic: { delay: 1600 },
|
|
@@ -34,6 +34,7 @@ const ContextMenuContent = forwardRef<HTMLDivElement, ContextMenuContentProps>(
|
|
|
34
34
|
return (
|
|
35
35
|
<ContextMenuPrimitive.Content
|
|
36
36
|
{...props}
|
|
37
|
+
data-arrow-keys='up down'
|
|
37
38
|
collisionPadding={safeCollisionPadding}
|
|
38
39
|
className={tx('menu.content', 'menu', { elevation }, classNames)}
|
|
39
40
|
ref={forwardedRef}
|
|
@@ -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, { useRef, useState } from 'react';
|
|
8
7
|
|
|
9
|
-
import { DropdownMenu } from './DropdownMenu';
|
|
10
8
|
import { withTheme } from '../../testing';
|
|
11
|
-
import { Button } from '../
|
|
9
|
+
import { Button } from '../Button';
|
|
10
|
+
|
|
11
|
+
import { DropdownMenu } from './DropdownMenu';
|
|
12
12
|
|
|
13
13
|
const DefaultStory = () => {
|
|
14
14
|
return (
|
|
@@ -91,15 +91,18 @@ const DefaultStory = () => {
|
|
|
91
91
|
);
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
const meta = {
|
|
95
95
|
title: 'ui/react-ui-core/DropdownMenu',
|
|
96
|
-
component: DropdownMenu,
|
|
96
|
+
component: DropdownMenu.Root,
|
|
97
97
|
render: DefaultStory,
|
|
98
98
|
decorators: [withTheme],
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
100
|
+
|
|
101
|
+
export default meta;
|
|
102
|
+
|
|
103
|
+
type Story = StoryObj<typeof meta>;
|
|
101
104
|
|
|
102
|
-
export const Default = {
|
|
105
|
+
export const Default: Story = {
|
|
103
106
|
args: {},
|
|
104
107
|
parameters: {
|
|
105
108
|
chromatic: { delay: 1600 },
|