@dxos/react-ui 0.8.4-main.5ea62a8 → 0.8.4-main.72ec0f3
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-P333G32W.mjs → chunk-53MI2QCM.mjs} +632 -299
- package/dist/lib/browser/chunk-53MI2QCM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +12 -1
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +57 -29
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-JRCE5UVS.mjs → chunk-ID67AFFF.mjs} +632 -299
- package/dist/lib/node-esm/chunk-ID67AFFF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +12 -1
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +57 -29
- 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 +1 -1
- 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 +1 -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 -7
- package/dist/types/src/components/Button/ToggleGroup.d.ts.map +1 -0
- package/dist/types/src/components/{Buttons → Button}/ToggleGroup.stories.d.ts +2 -12
- 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/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.map +1 -0
- package/dist/types/src/components/{Dialogs → Dialog}/Dialog.stories.d.ts +0 -1
- 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/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 +0 -2
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +0 -6
- 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/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/ContextMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +0 -6
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.d.ts +5 -4
- package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts +0 -6
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +0 -1
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +1 -1
- 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.stories.d.ts +0 -6
- 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 +0 -6
- package/dist/types/src/components/Select/Select.stories.d.ts.map +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.stories.d.ts +8 -8
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- 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 +12 -12
- 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 +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/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/{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 +2 -0
- 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 +24 -23
- package/src/components/Avatars/Avatar.stories.tsx +0 -2
- 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}/IconButton.stories.tsx +0 -3
- package/src/components/{Buttons → Button}/IconButton.tsx +14 -13
- package/src/components/{Buttons → Button}/Toggle.stories.tsx +5 -7
- package/src/components/{Buttons → Button}/ToggleGroup.stories.tsx +0 -3
- package/src/components/{Buttons → Button}/ToggleGroup.tsx +14 -1
- package/src/components/Clipboard/CopyButton.tsx +1 -1
- package/src/components/{Dialogs → Dialog}/AlertDialog.stories.tsx +1 -4
- package/src/components/{Dialogs → Dialog}/Dialog.stories.tsx +6 -4
- package/src/components/Icon/Icon.stories.tsx +113 -0
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/Input/Input.stories.tsx +0 -3
- package/src/components/Input/Input.tsx +3 -3
- package/src/components/Link/Link.stories.tsx +0 -3
- package/src/components/{Lists → List}/List.stories.tsx +2 -6
- 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/ContextMenu.stories.tsx +0 -3
- package/src/components/Menus/ContextMenu.tsx +1 -0
- package/src/components/Menus/DropdownMenu.stories.tsx +1 -4
- package/src/components/Menus/DropdownMenu.tsx +33 -6
- package/src/components/Message/Message.stories.tsx +0 -2
- package/src/components/Popover/Popover.stories.tsx +1 -4
- package/src/components/Popover/Popover.tsx +22 -5
- package/src/components/ScrollArea/ScrollArea.stories.tsx +1 -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 +3 -5
- package/src/components/Select/Select.tsx +5 -4
- package/src/components/Status/Status.stories.tsx +0 -3
- package/src/components/Tag/Tag.stories.tsx +8 -7
- package/src/components/Toast/Toast.stories.tsx +1 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -7
- package/src/components/Toolbar/Toolbar.tsx +18 -6
- package/src/components/Tooltip/Tooltip.stories.tsx +1 -4
- package/src/components/Tooltip/Tooltip.tsx +2 -1
- package/src/components/index.ts +4 -3
- 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 +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 +2 -0
- package/src/util/usePx.ts +61 -0
- package/dist/lib/browser/chunk-P333G32W.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JRCE5UVS.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.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.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/testing/decorators/withSurfaceVariantsLayout.d.ts.map +0 -1
- package/src/testing/decorators/withTheme.ts +0 -25
- /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}/Dialog.d.ts +0 -0
- /package/dist/types/src/components/{Dialogs → Dialog}/index.d.ts +0 -0
- /package/dist/types/src/components/{Lists → List}/List.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/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}/AlertDialog.tsx +0 -0
- /package/src/components/{Dialogs → Dialog}/Dialog.tsx +0 -0
- /package/src/components/{Dialogs → Dialog}/index.ts +0 -0
- /package/src/components/{Lists → List}/List.tsx +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
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useState } from '@preact-signals/safe-react/react';
|
|
6
|
+
import { createContext } from '@radix-ui/react-context';
|
|
7
|
+
import React, {
|
|
8
|
+
type HTMLAttributes,
|
|
9
|
+
type PropsWithChildren,
|
|
10
|
+
forwardRef,
|
|
11
|
+
useCallback,
|
|
12
|
+
useEffect,
|
|
13
|
+
useImperativeHandle,
|
|
14
|
+
useMemo,
|
|
15
|
+
useRef,
|
|
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/react-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
|
+
}>
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Scroll container that automatically scrolls to the bottom when new content is added.
|
|
59
|
+
*/
|
|
60
|
+
const Root = forwardRef<ScrollController, RootProps>(({ children, classNames, pin, fade }, forwardedRef) => {
|
|
61
|
+
const scrollerRef = useRef<HTMLDivElement>(null);
|
|
62
|
+
const autoScrollRef = useRef(false);
|
|
63
|
+
const [overflow, setOverflow] = useState(false);
|
|
64
|
+
const [pinned, setPinned] = useState(pin);
|
|
65
|
+
|
|
66
|
+
const timeoutRef = useRef<NodeJS.Timeout>(undefined);
|
|
67
|
+
const scrollToBottom = useCallback((behavior: ScrollBehavior = 'instant') => {
|
|
68
|
+
if (scrollerRef.current) {
|
|
69
|
+
// Temporarily hide scrollbar to prevent flicker.
|
|
70
|
+
autoScrollRef.current = true;
|
|
71
|
+
scrollerRef.current.classList.add('scrollbar-none');
|
|
72
|
+
scrollerRef.current.scrollTo({
|
|
73
|
+
top: scrollerRef.current.scrollHeight,
|
|
74
|
+
behavior,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
clearTimeout(timeoutRef.current);
|
|
78
|
+
if (behavior !== 'instant') {
|
|
79
|
+
timeoutRef.current = setTimeout(() => {
|
|
80
|
+
scrollerRef.current?.classList.remove('scrollbar-none');
|
|
81
|
+
autoScrollRef.current = false;
|
|
82
|
+
}, 500);
|
|
83
|
+
}
|
|
84
|
+
setPinned(true);
|
|
85
|
+
}
|
|
86
|
+
}, []);
|
|
87
|
+
|
|
88
|
+
const controller = useMemo(
|
|
89
|
+
() => ({
|
|
90
|
+
viewport: scrollerRef.current,
|
|
91
|
+
scrollToTop: () => {
|
|
92
|
+
invariant(scrollerRef.current);
|
|
93
|
+
scrollerRef.current.scrollTo({ top: 0, behavior: 'smooth' });
|
|
94
|
+
setPinned(false);
|
|
95
|
+
},
|
|
96
|
+
scrollToBottom: () => {
|
|
97
|
+
scrollToBottom('smooth');
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
[scrollToBottom, scrollerRef.current],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// Scroll controller imperative ref.
|
|
104
|
+
useImperativeHandle(forwardedRef, () => controller, [controller]);
|
|
105
|
+
|
|
106
|
+
// Listen for scroll events.
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!scrollerRef.current) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return combine(
|
|
113
|
+
// Check if user scrolls.
|
|
114
|
+
addEventListener(scrollerRef.current, 'wheel', () => {
|
|
115
|
+
setPinned(isBottom(scrollerRef.current));
|
|
116
|
+
}),
|
|
117
|
+
// Check if scrolls.
|
|
118
|
+
addEventListener(scrollerRef.current, 'scroll', () => {
|
|
119
|
+
setOverflow((scrollerRef.current?.scrollTop ?? 0) > 0);
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<ScrollContainerProvider pinned={pinned} controller={controller} scrollToBottom={scrollToBottom}>
|
|
126
|
+
<div className='relative grid flex-1 min-bs-0 overflow-hidden'>
|
|
127
|
+
{fade && (
|
|
128
|
+
<div
|
|
129
|
+
role='none'
|
|
130
|
+
data-visible={overflow}
|
|
131
|
+
className={mx(
|
|
132
|
+
// NOTE: Gradients may not be visible with dark reader extensions.
|
|
133
|
+
'z-10 absolute block-start-0 inset-inline-0 bs-24 is-full',
|
|
134
|
+
'opacity-0 duration-200 transition-opacity data-[visible="true"]:opacity-100',
|
|
135
|
+
'bg-gradient-to-b from-[--surface-bg] to-transparent pointer-events-none',
|
|
136
|
+
)}
|
|
137
|
+
/>
|
|
138
|
+
)}
|
|
139
|
+
<div className={mx('flex flex-col min-bs-0 overflow-y-auto scrollbar-thin', classNames)} ref={scrollerRef}>
|
|
140
|
+
{children}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</ScrollContainerProvider>
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
Root.displayName = 'ScrollContainer.Root';
|
|
148
|
+
|
|
149
|
+
//
|
|
150
|
+
// Viewport
|
|
151
|
+
//
|
|
152
|
+
|
|
153
|
+
type ViewportProps = ThemedClassName<PropsWithChildren<Omit<HTMLAttributes<HTMLDivElement>, 'className'>>>;
|
|
154
|
+
|
|
155
|
+
const Viewport = forwardRef<HTMLDivElement, ViewportProps>(({ classNames, children, ...props }, forwardedRef) => {
|
|
156
|
+
const contentRef = useForwardedRef(forwardedRef);
|
|
157
|
+
const { pinned, scrollToBottom } = useScrollContainerContext(Viewport.displayName!);
|
|
158
|
+
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (!pinned || !contentRef.current) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Setup resize observer to detect content changes.
|
|
165
|
+
const resizeObserver = new ResizeObserver(() => scrollToBottom());
|
|
166
|
+
scrollToBottom('instant');
|
|
167
|
+
|
|
168
|
+
resizeObserver.observe(contentRef.current);
|
|
169
|
+
return () => {
|
|
170
|
+
resizeObserver.disconnect();
|
|
171
|
+
};
|
|
172
|
+
}, [pinned, scrollToBottom]);
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<div className={mx('is-full', classNames)} {...props} ref={contentRef}>
|
|
176
|
+
{children}
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
Viewport.displayName = 'ScrollContainer.Viewport';
|
|
182
|
+
|
|
183
|
+
//
|
|
184
|
+
// ScrollDownButton
|
|
185
|
+
//
|
|
186
|
+
|
|
187
|
+
type ScrollDownButtonProps = ThemedClassName;
|
|
188
|
+
|
|
189
|
+
const ScrollDownButton = ({ classNames }: ScrollDownButtonProps) => {
|
|
190
|
+
const { pinned, scrollToBottom } = useScrollContainerContext(ScrollDownButton.displayName!);
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<div
|
|
194
|
+
role='none'
|
|
195
|
+
className={mx(
|
|
196
|
+
'absolute bottom-2 right-4 opacity-100 transition-opacity duration-300',
|
|
197
|
+
pinned && 'opacity-0',
|
|
198
|
+
classNames,
|
|
199
|
+
)}
|
|
200
|
+
>
|
|
201
|
+
<IconButton
|
|
202
|
+
variant='primary'
|
|
203
|
+
icon='ph--arrow-down--regular'
|
|
204
|
+
iconOnly
|
|
205
|
+
size={4}
|
|
206
|
+
label='Scroll down'
|
|
207
|
+
onClick={() => scrollToBottom()}
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
ScrollDownButton.displayName = 'ScrollContainer.ScrollDownButton';
|
|
214
|
+
|
|
215
|
+
//
|
|
216
|
+
// ScrollContainer
|
|
217
|
+
//
|
|
218
|
+
|
|
219
|
+
export { useScrollContainerContext };
|
|
220
|
+
|
|
221
|
+
export const ScrollContainer = {
|
|
222
|
+
Root,
|
|
223
|
+
Viewport,
|
|
224
|
+
ScrollDownButton,
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export type {
|
|
228
|
+
RootProps as ScrollContainerRootProps,
|
|
229
|
+
ViewportProps as ScrollContainerViewportProps,
|
|
230
|
+
ScrollDownButtonProps as ScrollContainerScrollDownButtonProps,
|
|
231
|
+
};
|
|
@@ -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>
|
|
@@ -59,6 +59,7 @@ const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(
|
|
|
59
59
|
return (
|
|
60
60
|
<SelectPrimitive.Content
|
|
61
61
|
{...props}
|
|
62
|
+
data-arrow-keys='up down'
|
|
62
63
|
collisionPadding={safeCollisionPadding}
|
|
63
64
|
className={tx('select.content', 'select__content', { elevation }, classNames)}
|
|
64
65
|
position='popper'
|
|
@@ -107,7 +108,7 @@ const SelectScrollDownButton = forwardRef<HTMLDivElement, SelectScrollDownButton
|
|
|
107
108
|
type SelectViewportProps = ThemedClassName<SelectPrimitive.SelectViewportProps>;
|
|
108
109
|
|
|
109
110
|
const SelectViewport = forwardRef<HTMLDivElement, SelectViewportProps>(
|
|
110
|
-
({ classNames,
|
|
111
|
+
({ classNames, children, ...props }, forwardedRef) => {
|
|
111
112
|
const { tx } = useThemeContext();
|
|
112
113
|
return (
|
|
113
114
|
<SelectPrimitive.SelectViewport
|
|
@@ -157,7 +158,7 @@ const SelectOption = forwardRef<HTMLDivElement, SelectItemProps>(({ children, cl
|
|
|
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,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,8 +2,6 @@
|
|
|
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
|
|
|
@@ -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 = {};
|
|
@@ -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,22 +18,34 @@ 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
|
+
textBlockWidth?: boolean;
|
|
28
|
+
layoutManaged?: boolean;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
}
|
|
31
|
+
>;
|
|
26
32
|
|
|
27
33
|
const ToolbarRoot = forwardRef<HTMLDivElement, ToolbarRootProps>(
|
|
28
|
-
({ classNames, children, layoutManaged, ...props }, forwardedRef) => {
|
|
34
|
+
({ classNames, children, layoutManaged, textBlockWidth: textBlockWidthParam, disabled, ...props }, forwardedRef) => {
|
|
29
35
|
const { tx } = useThemeContext();
|
|
36
|
+
const InnerRoot = textBlockWidthParam ? 'div' : Fragment;
|
|
37
|
+
const innerRootProps = textBlockWidthParam
|
|
38
|
+
? { role: 'none', className: tx('toolbar.inner', 'toolbar', { layoutManaged }, classNames) }
|
|
39
|
+
: {};
|
|
40
|
+
|
|
30
41
|
return (
|
|
31
42
|
<ToolbarPrimitive.Root
|
|
32
43
|
{...props}
|
|
33
|
-
|
|
44
|
+
data-arrow-keys={props.orientation === 'vertical' ? 'up down' : 'left right'}
|
|
45
|
+
className={tx('toolbar.root', 'toolbar', { layoutManaged, disabled }, classNames)}
|
|
34
46
|
ref={forwardedRef}
|
|
35
47
|
>
|
|
36
|
-
{children}
|
|
48
|
+
<InnerRoot {...innerRootProps}>{children}</InnerRoot>
|
|
37
49
|
</ToolbarPrimitive.Root>
|
|
38
50
|
);
|
|
39
51
|
},
|
|
@@ -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;
|
|
@@ -25,6 +25,7 @@ import React, {
|
|
|
25
25
|
type FC,
|
|
26
26
|
type MutableRefObject,
|
|
27
27
|
type ReactNode,
|
|
28
|
+
type RefObject,
|
|
28
29
|
type SyntheticEvent,
|
|
29
30
|
forwardRef,
|
|
30
31
|
useCallback,
|
|
@@ -218,7 +219,7 @@ const TooltipProvider: FC<TooltipProviderProps> = (props: TooltipScopedProps<Too
|
|
|
218
219
|
{content}
|
|
219
220
|
<TooltipArrow className={tx('tooltip.arrow', 'tooltip__arrow')} />
|
|
220
221
|
</TooltipContent>
|
|
221
|
-
<TooltipVirtualTrigger virtualRef={triggerRef} />
|
|
222
|
+
<TooltipVirtualTrigger virtualRef={triggerRef as RefObject<HTMLButtonElement>} />
|
|
222
223
|
{children}
|
|
223
224
|
</TooltipContextProvider>
|
|
224
225
|
</PopperPrimitive.Root>
|
package/src/components/index.ts
CHANGED
|
@@ -5,19 +5,20 @@
|
|
|
5
5
|
export * from './AnchoredOverflow';
|
|
6
6
|
export * from './Avatars';
|
|
7
7
|
export * from './Breadcrumb';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './Button';
|
|
9
9
|
export * from './Clipboard';
|
|
10
|
-
export * from './
|
|
10
|
+
export * from './Dialog';
|
|
11
11
|
export * from './Icon';
|
|
12
12
|
export * from './Input';
|
|
13
13
|
export * from './Link';
|
|
14
|
-
export * from './
|
|
14
|
+
export * from './List';
|
|
15
15
|
export * from './Main';
|
|
16
16
|
export * from './Menus';
|
|
17
17
|
export * from './Message';
|
|
18
18
|
export * from './Popover';
|
|
19
19
|
export * from './Status';
|
|
20
20
|
export * from './ScrollArea';
|
|
21
|
+
export * from './ScrollContainer';
|
|
21
22
|
export * from './Select';
|
|
22
23
|
export * from './Separator';
|
|
23
24
|
export * from './Tag';
|
package/src/hooks/useSafeArea.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useCallback, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useViewportResize } from '@dxos/react-hooks';
|
|
8
8
|
|
|
9
9
|
export type SafeAreaPadding = Record<'top' | 'right' | 'bottom' | 'left', number>;
|
|
10
10
|
|
|
@@ -20,6 +20,7 @@ export const useSafeArea = (): SafeAreaPadding => {
|
|
|
20
20
|
left: parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--safe-area-left')),
|
|
21
21
|
});
|
|
22
22
|
}, []);
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
useViewportResize(handleResize);
|
|
24
25
|
return padding;
|
|
25
26
|
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useCallback,
|
|
5
|
+
import { useCallback, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useViewportResize } from '@dxos/react-hooks';
|
|
8
8
|
|
|
9
|
-
export const useVisualViewport = (deps?: Parameters<typeof
|
|
9
|
+
export const useVisualViewport = (deps?: Parameters<typeof useViewportResize>[1]) => {
|
|
10
10
|
const [width, setWidth] = useState<number | null>(null);
|
|
11
11
|
const [height, setHeight] = useState<number | null>(null);
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ export const useVisualViewport = (deps?: Parameters<typeof useEffect>[1]) => {
|
|
|
17
17
|
}
|
|
18
18
|
}, []);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
useViewportResize(handleResize, deps);
|
|
21
21
|
|
|
22
22
|
return { width, height };
|
|
23
23
|
};
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { type Resource, type TFunction } from 'i18next';
|
|
|
6
6
|
export { Trans } from 'react-i18next';
|
|
7
7
|
|
|
8
8
|
export * from '@dxos/react-hooks';
|
|
9
|
-
export
|
|
9
|
+
export * from '@dxos/react-ui-types';
|
|
10
10
|
|
|
11
11
|
export * from './components';
|
|
12
12
|
export * from './hooks';
|
|
@@ -2,13 +2,12 @@
|
|
|
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, { useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Icon, Input, Select, Toggle, Toolbar } from '../components';
|
|
11
|
-
import {
|
|
9
|
+
import { withTheme } from '../testing';
|
|
10
|
+
import { withLayoutVariants } from '../testing';
|
|
12
11
|
|
|
13
12
|
const DefaultStory = () => {
|
|
14
13
|
const [checked, setChecked] = useState<boolean>(false);
|
|
@@ -85,8 +84,7 @@ const DefaultStory = () => {
|
|
|
85
84
|
const meta = {
|
|
86
85
|
title: 'ui/react-ui-core/Playground/Controls',
|
|
87
86
|
render: DefaultStory,
|
|
88
|
-
decorators: [
|
|
89
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
87
|
+
decorators: [withTheme, withLayoutVariants()],
|
|
90
88
|
} satisfies Meta<typeof Icon>;
|
|
91
89
|
|
|
92
90
|
export default meta;
|