@dxos/react-ui-stack 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
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/index.mjs +922 -57
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +923 -57
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/{exemplars → components}/CardStack/CardStack.d.ts +18 -13
- package/dist/types/src/components/CardStack/CardStack.d.ts.map +1 -0
- package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +1 -0
- package/dist/types/src/{exemplars → components}/CardStack/CardStackDragPreview.d.ts +1 -1
- package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +1 -0
- package/dist/types/src/components/CardStack/index.d.ts.map +1 -0
- package/dist/types/src/components/Stack/Stack.d.ts +1 -1
- package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
- package/dist/types/src/components/StackContext.d.ts +1 -1
- package/dist/types/src/components/StackContext.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.d.ts +5 -9
- package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemContent.d.ts +2 -45
- package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemSigil.d.ts +2 -2
- package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/LayoutControls.d.ts +3 -0
- package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/{defs.d.ts → types.d.ts} +1 -1
- package/dist/types/src/components/types.d.ts.map +1 -0
- package/dist/types/src/hooks/useStackDropForElements.d.ts +7 -5
- package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -37
- package/src/{exemplars → components}/CardStack/CardStack.stories.tsx +9 -9
- package/src/{exemplars → components}/CardStack/CardStack.tsx +114 -57
- package/src/{exemplars → components}/CardStack/CardStackDragPreview.tsx +3 -3
- package/src/components/Stack/Stack.stories.tsx +1 -1
- package/src/components/Stack/Stack.tsx +5 -3
- package/src/components/StackContext.tsx +1 -1
- package/src/components/StackItem/StackItem.stories.tsx +4 -2
- package/src/components/StackItem/StackItem.tsx +24 -12
- package/src/components/StackItem/StackItemContent.tsx +15 -48
- package/src/components/StackItem/StackItemHeading.tsx +1 -1
- package/src/components/StackItem/StackItemSigil.tsx +3 -3
- package/src/components/deprecated/LayoutControls.tsx +3 -0
- package/src/components/index.ts +2 -2
- package/src/hooks/useStackDropForElements.ts +17 -10
- package/src/index.ts +0 -3
- package/src/playwright/playwright.config.ts +1 -1
- package/src/translations.ts +1 -1
- package/dist/lib/browser/chunk-3F2KBXLP.mjs +0 -1482
- package/dist/lib/browser/chunk-3F2KBXLP.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -31
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SYKFLQGK.mjs +0 -1484
- package/dist/lib/node-esm/chunk-SYKFLQGK.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -32
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/components/Image/Image.d.ts +0 -14
- package/dist/types/src/components/Image/Image.d.ts.map +0 -1
- package/dist/types/src/components/Image/Image.stories.d.ts +0 -33
- package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
- package/dist/types/src/components/Image/index.d.ts +0 -2
- package/dist/types/src/components/Image/index.d.ts.map +0 -1
- package/dist/types/src/components/defs.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/Card.d.ts +0 -69
- package/dist/types/src/exemplars/Card/Card.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/Card.stories.d.ts +0 -21
- package/dist/types/src/exemplars/Card/Card.stories.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/CardDragPreview.d.ts +0 -6
- package/dist/types/src/exemplars/Card/CardDragPreview.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/fragments.d.ts +0 -13
- package/dist/types/src/exemplars/Card/fragments.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/index.d.ts +0 -4
- package/dist/types/src/exemplars/Card/index.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/CardStackDragPreview.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/index.d.ts.map +0 -1
- package/dist/types/src/exemplars/index.d.ts +0 -3
- package/dist/types/src/exemplars/index.d.ts.map +0 -1
- package/dist/types/src/testing/CardContainer.d.ts +0 -6
- package/dist/types/src/testing/CardContainer.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/src/components/Image/Image.stories.tsx +0 -84
- package/src/components/Image/Image.tsx +0 -222
- package/src/components/Image/index.ts +0 -5
- package/src/exemplars/Card/Card.stories.tsx +0 -64
- package/src/exemplars/Card/Card.tsx +0 -210
- package/src/exemplars/Card/CardDragPreview.tsx +0 -22
- package/src/exemplars/Card/fragments.ts +0 -24
- package/src/exemplars/Card/index.ts +0 -7
- package/src/exemplars/index.ts +0 -6
- package/src/testing/CardContainer.tsx +0 -37
- package/src/testing/index.ts +0 -5
- /package/dist/types/src/{exemplars → components}/CardStack/CardStack.stories.d.ts +0 -0
- /package/dist/types/src/{exemplars → components}/CardStack/index.d.ts +0 -0
- /package/src/{exemplars → components}/CardStack/index.ts +0 -0
- /package/src/components/{defs.ts → types.ts} +0 -0
|
@@ -5,82 +5,47 @@
|
|
|
5
5
|
import React, { type ComponentPropsWithoutRef, forwardRef, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
-
import { mx } from '@dxos/
|
|
8
|
+
import { mx } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
10
|
import { useStack, useStackItem } from '../StackContext';
|
|
11
11
|
|
|
12
|
-
// TODO(burdon): Add prop for container-max-width?
|
|
13
12
|
export type StackItemContentProps = ThemedClassName<Omit<ComponentPropsWithoutRef<'div'>, 'role' | 'scrollable'>> & {
|
|
14
|
-
/**
|
|
15
|
-
* This flag is required in order to clarify a developer experience that seemed like it needed extra boilerplate
|
|
16
|
-
* (`row-span-2`) or was buggy. See the description of the StackItem.Content component itself for more information.
|
|
17
|
-
*/
|
|
18
13
|
toolbar?: boolean;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Whether to provide for the layout of a statusbar after the content.
|
|
22
|
-
*/
|
|
23
14
|
statusbar?: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Whether to support y-axis scrolling.
|
|
27
|
-
*/
|
|
28
|
-
scrollable?: boolean;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Whether to set a certain aspect ratio on the content, including the toolbar and statusbar.
|
|
32
|
-
* This is provided for convenience and consistency; it can instead be specified by the `classNames` or `style` props as needed.
|
|
33
|
-
*/
|
|
34
|
-
size?: 'intrinsic' | 'video' | 'square';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Whether the consumer intends to do something custom and typical affordances should not apply.
|
|
38
|
-
* @deprecated Replace with override for gridTempateRows.
|
|
39
|
-
*/
|
|
40
|
-
layoutManaged?: boolean;
|
|
41
15
|
};
|
|
42
16
|
|
|
43
17
|
/**
|
|
44
|
-
* This component should be used by plugins for rendering content within a stack item
|
|
45
|
-
* The `toolbar` flag must be provided since this component provides for the layout of content with the toolbar.
|
|
18
|
+
* This component should be used by plugins for rendering content within a stack item (i.e., a “plank” or “section”).
|
|
46
19
|
*/
|
|
47
20
|
export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps>(
|
|
48
|
-
(
|
|
49
|
-
{ children, toolbar, statusbar, layoutManaged, classNames, size = 'intrinsic', scrollable, ...props },
|
|
50
|
-
forwardedRef,
|
|
51
|
-
) => {
|
|
21
|
+
({ classNames, children, toolbar, statusbar, ...props }, forwardedRef) => {
|
|
52
22
|
const { size: stackItemSize } = useStack();
|
|
53
23
|
const { role } = useStackItem();
|
|
54
24
|
const style = useMemo(
|
|
55
|
-
() =>
|
|
56
|
-
|
|
57
|
-
?
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
].join(' '),
|
|
64
|
-
},
|
|
65
|
-
[toolbar, statusbar, layoutManaged],
|
|
25
|
+
() => ({
|
|
26
|
+
gridTemplateRows: [
|
|
27
|
+
...(toolbar ? [role === 'section' ? 'calc(var(--toolbar-size) - 1px)' : 'var(--toolbar-size)'] : []),
|
|
28
|
+
'1fr',
|
|
29
|
+
...(statusbar ? ['var(--statusbar-size)'] : []),
|
|
30
|
+
].join(' '),
|
|
31
|
+
}),
|
|
32
|
+
[toolbar, statusbar],
|
|
66
33
|
);
|
|
67
34
|
|
|
68
35
|
return (
|
|
69
36
|
<div
|
|
70
|
-
role='none'
|
|
71
37
|
{...props}
|
|
38
|
+
role='none'
|
|
39
|
+
style={style}
|
|
72
40
|
className={mx(
|
|
73
41
|
'group grid grid-cols-[100%] density-coarse',
|
|
74
|
-
size === 'video' ? 'aspect-video' : size === 'square' && 'aspect-square',
|
|
75
42
|
stackItemSize === 'contain' && 'min-bs-0 overflow-hidden',
|
|
76
|
-
scrollable ? 'min-bs-0 overflow-y-auto scrollbar-thin contain-layout' : 'overflow-hidden',
|
|
77
43
|
role === 'section' &&
|
|
78
44
|
toolbar &&
|
|
79
45
|
'[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:block-start-0 [&_.dx-toolbar]:-mbe-px [&_.dx-toolbar]:min-is-0',
|
|
80
46
|
toolbar && '[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator',
|
|
81
47
|
classNames,
|
|
82
48
|
)}
|
|
83
|
-
style={style}
|
|
84
49
|
data-popover-collision-boundary={true}
|
|
85
50
|
ref={forwardedRef}
|
|
86
51
|
>
|
|
@@ -89,3 +54,5 @@ export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps
|
|
|
89
54
|
);
|
|
90
55
|
},
|
|
91
56
|
);
|
|
57
|
+
|
|
58
|
+
StackItemContent.displayName = 'StackItemContent';
|
|
@@ -12,7 +12,7 @@ import React, {
|
|
|
12
12
|
|
|
13
13
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
14
14
|
import { type AttendableId, type Related, useAttention } from '@dxos/react-ui-attention';
|
|
15
|
-
import { mx } from '@dxos/
|
|
15
|
+
import { mx } from '@dxos/ui-theme';
|
|
16
16
|
|
|
17
17
|
import { useStack } from '../StackContext';
|
|
18
18
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { Fragment, type PropsWithChildren, forwardRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
8
|
import { keySymbols } from '@dxos/keyboard';
|
|
9
9
|
import { Button, type ButtonProps, DropdownMenu, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { type AttendableId, type Related, useAttention } from '@dxos/react-ui-attention';
|
|
11
|
-
import { descriptionText, mx } from '@dxos/
|
|
11
|
+
import { descriptionText, mx } from '@dxos/ui-theme';
|
|
12
12
|
import { getHostPlatform } from '@dxos/util';
|
|
13
13
|
|
|
14
14
|
import { translationKey } from '../../translations';
|
|
@@ -23,7 +23,7 @@ export type KeyBinding = {
|
|
|
23
23
|
unknown?: string;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export type StackItemSigilAction = Pick<ActionLike, 'id' | 'properties' | 'data'>;
|
|
26
|
+
export type StackItemSigilAction = Pick<Node.ActionLike, 'id' | 'properties' | 'data'>;
|
|
27
27
|
|
|
28
28
|
export type StackItemSigilButtonProps = Omit<ButtonProps, 'variant'> &
|
|
29
29
|
AttendableId &
|
|
@@ -30,6 +30,9 @@ const LayoutControl = ({ icon, label, ...props }: Omit<ButtonProps, 'children'>
|
|
|
30
30
|
return <IconButton iconOnly icon={icon} label={label} tooltipSide='bottom' variant='ghost' {...props} />;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated
|
|
35
|
+
*/
|
|
33
36
|
export const LayoutControls = forwardRef<HTMLDivElement, LayoutControlsProps>(
|
|
34
37
|
(
|
|
35
38
|
{ onClick, variant = 'default', capabilities: can, isSolo, pin, close = false, children, ...props },
|
package/src/components/index.ts
CHANGED
|
@@ -12,8 +12,21 @@ import { type Orientation, type StackItemData, type StackItemRearrangeHandler }
|
|
|
12
12
|
|
|
13
13
|
const noop = () => {};
|
|
14
14
|
|
|
15
|
+
export type UseStackDropForElementsProps = {
|
|
16
|
+
id?: string;
|
|
17
|
+
element: HTMLDivElement | null;
|
|
18
|
+
scrollElement?: HTMLDivElement | null;
|
|
19
|
+
orientation: Orientation;
|
|
20
|
+
selfDroppable: boolean;
|
|
21
|
+
onRearrange?: StackItemRearrangeHandler;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type UseStackDropForElements = {
|
|
25
|
+
dropping: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
15
28
|
/**
|
|
16
|
-
* Hook to handle drag
|
|
29
|
+
* Hook to handle drag-and-drop functionality for Stack components.
|
|
17
30
|
*/
|
|
18
31
|
export const useStackDropForElements = ({
|
|
19
32
|
id,
|
|
@@ -22,14 +35,7 @@ export const useStackDropForElements = ({
|
|
|
22
35
|
orientation,
|
|
23
36
|
selfDroppable,
|
|
24
37
|
onRearrange,
|
|
25
|
-
}: {
|
|
26
|
-
id?: string;
|
|
27
|
-
element: HTMLDivElement | null;
|
|
28
|
-
scrollElement?: HTMLDivElement | null;
|
|
29
|
-
orientation: Orientation;
|
|
30
|
-
selfDroppable: boolean;
|
|
31
|
-
onRearrange?: StackItemRearrangeHandler;
|
|
32
|
-
}) => {
|
|
38
|
+
}: UseStackDropForElementsProps): UseStackDropForElements => {
|
|
33
39
|
const [dropping, setDropping] = useState(false);
|
|
34
40
|
|
|
35
41
|
useLayoutEffect(() => {
|
|
@@ -39,6 +45,7 @@ export const useStackDropForElements = ({
|
|
|
39
45
|
|
|
40
46
|
const acceptSourceType = orientation === 'horizontal' ? 'column' : 'card';
|
|
41
47
|
|
|
48
|
+
// TODO(burdon): Use monitor?
|
|
42
49
|
return combine(
|
|
43
50
|
selfDroppable
|
|
44
51
|
? dropTargetForElements({
|
|
@@ -78,7 +85,7 @@ export const useStackDropForElements = ({
|
|
|
78
85
|
})
|
|
79
86
|
: noop,
|
|
80
87
|
);
|
|
81
|
-
}, [element, scrollElement, selfDroppable, orientation,
|
|
88
|
+
}, [id, element, scrollElement, selfDroppable, orientation, onRearrange]);
|
|
82
89
|
|
|
83
90
|
return { dropping };
|
|
84
91
|
};
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export default defineConfig({
|
|
|
10
10
|
...e2ePreset(import.meta.dirname),
|
|
11
11
|
// TODO(wittjosiah): Avoid hard-coding ports.
|
|
12
12
|
webServer: {
|
|
13
|
-
command: 'moon run storybook:serve-e2e -- --port=9003',
|
|
13
|
+
command: 'moon run storybook-react:serve-e2e -- --port=9003',
|
|
14
14
|
port: 9003,
|
|
15
15
|
reuseExistingServer: false,
|
|
16
16
|
},
|