@dxos/react-ui-stack 0.8.3 → 0.8.4-main.28f8d3d
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-FV7KWSG5.mjs +1198 -0
- package/dist/lib/browser/chunk-FV7KWSG5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +40 -1160
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/{node/testing/index.cjs → browser/playwright/index.mjs} +8 -28
- package/dist/lib/{node/testing/index.cjs.map → browser/playwright/index.mjs.map} +3 -3
- package/dist/lib/browser/testing/index.mjs +25 -51
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-ISLFXOAT.mjs +1200 -0
- package/dist/lib/node-esm/chunk-ISLFXOAT.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +40 -1161
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/playwright/index.mjs +63 -0
- package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +24 -51
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- 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/Stack/Stack.stories.d.ts +1 -1
- package/dist/types/src/components/Stack/Stack.stories.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 +4 -4
- package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.stories.d.ts +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 -2
- package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
- package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/exemplars/Card/Card.d.ts +6 -10
- package/dist/types/src/exemplars/Card/Card.d.ts.map +1 -1
- package/dist/types/src/exemplars/Card/Card.stories.d.ts +13 -0
- package/dist/types/src/exemplars/Card/Card.stories.d.ts.map +1 -0
- package/dist/types/src/exemplars/Card/fragments.d.ts +1 -2
- package/dist/types/src/exemplars/Card/fragments.d.ts.map +1 -1
- package/dist/types/src/exemplars/CardStack/CardStack.d.ts +7 -1
- package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +1 -1
- package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts +9 -0
- package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/useStackDropForElements.d.ts +1 -1
- package/dist/types/src/hooks/useStackDropForElements.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/playwright/index.d.ts +2 -0
- package/dist/types/src/playwright/index.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/stack-manager.d.ts.map +1 -0
- package/dist/types/src/testing/CardContainer.d.ts +6 -0
- package/dist/types/src/testing/CardContainer.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/translations.d.ts +13 -14
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -25
- package/src/components/Stack/Stack.stories.tsx +5 -4
- package/src/components/Stack/Stack.tsx +5 -5
- package/src/components/StackContext.tsx +1 -1
- package/src/components/StackItem/StackItem.stories.tsx +2 -2
- package/src/components/StackItem/StackItem.tsx +12 -11
- package/src/components/StackItem/StackItemContent.tsx +4 -3
- package/src/components/StackItem/StackItemHeading.tsx +3 -3
- package/src/components/StackItem/StackItemResizeHandle.tsx +2 -1
- package/src/components/StackItem/StackItemSigil.tsx +2 -1
- package/src/components/index.ts +1 -1
- package/src/exemplars/Card/Card.stories.tsx +78 -0
- package/src/exemplars/Card/Card.tsx +36 -31
- package/src/exemplars/Card/CardDragPreview.tsx +2 -2
- package/src/exemplars/Card/fragments.ts +1 -3
- package/src/exemplars/CardStack/CardStack.stories.tsx +173 -0
- package/src/exemplars/CardStack/CardStack.tsx +19 -2
- package/src/hooks/useStackDropForElements.ts +5 -2
- package/src/index.ts +3 -4
- package/src/playwright/index.ts +5 -0
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +7 -5
- package/src/testing/CardContainer.tsx +37 -0
- package/src/testing/index.ts +1 -1
- package/src/translations.ts +5 -3
- package/dist/lib/node/index.cjs +0 -1220
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/types/src/exemplars/Card/Card.stories-todo.d.ts +0 -1
- package/dist/types/src/exemplars/Card/Card.stories-todo.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/CardStack.stories-todo.d.ts +0 -1
- package/dist/types/src/exemplars/CardStack/CardStack.stories-todo.d.ts.map +0 -1
- package/dist/types/src/testing/stack-manager.d.ts.map +0 -1
- package/src/exemplars/Card/Card.stories-todo.tsx +0 -135
- package/src/exemplars/CardStack/CardStack.stories-todo.tsx +0 -80
- package/src/playwright/playwright.config.cts +0 -18
- /package/dist/types/src/{testing → playwright}/stack-manager.d.ts +0 -0
- /package/src/{testing → playwright}/stack-manager.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-stack",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.28f8d3d",
|
|
4
4
|
"description": "A stack component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -14,18 +14,23 @@
|
|
|
14
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
15
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
16
|
},
|
|
17
|
+
"./playwright": {
|
|
18
|
+
"types": "./dist/types/src/playwright/index.d.ts",
|
|
19
|
+
"browser": "./dist/lib/browser/playwright/index.mjs",
|
|
20
|
+
"node": "./dist/lib/node-esm/playwright/index.mjs"
|
|
21
|
+
},
|
|
17
22
|
"./testing": {
|
|
18
23
|
"types": "./dist/types/src/testing/index.d.ts",
|
|
19
24
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
20
|
-
"node":
|
|
21
|
-
"require": "./dist/lib/node/testing/index.cjs",
|
|
22
|
-
"default": "./dist/lib/node-esm/testing/index.mjs"
|
|
23
|
-
}
|
|
25
|
+
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
"types": "dist/types/src/index.d.ts",
|
|
27
29
|
"typesVersions": {
|
|
28
30
|
"*": {
|
|
31
|
+
"playwright": [
|
|
32
|
+
"dist/types/src/playwright/index.d.ts"
|
|
33
|
+
],
|
|
29
34
|
"testing": [
|
|
30
35
|
"dist/types/src/testing/index.d.ts"
|
|
31
36
|
]
|
|
@@ -49,37 +54,36 @@
|
|
|
49
54
|
"@radix-ui/react-slot": "1.1.2",
|
|
50
55
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
51
56
|
"react-resize-detector": "^11.0.1",
|
|
52
|
-
"@dxos/echo-schema": "0.8.
|
|
53
|
-
"@dxos/keyboard": "0.8.
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
57
|
+
"@dxos/echo-schema": "0.8.4-main.28f8d3d",
|
|
58
|
+
"@dxos/keyboard": "0.8.4-main.28f8d3d",
|
|
59
|
+
"@dxos/live-object": "0.8.4-main.28f8d3d",
|
|
60
|
+
"@dxos/react-ui-attention": "0.8.4-main.28f8d3d",
|
|
61
|
+
"@dxos/storybook-utils": "0.8.4-main.28f8d3d",
|
|
62
|
+
"@dxos/react-ui-dnd": "0.8.4-main.28f8d3d",
|
|
63
|
+
"@dxos/util": "0.8.4-main.28f8d3d"
|
|
58
64
|
},
|
|
59
65
|
"devDependencies": {
|
|
60
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
61
66
|
"@types/react": "~18.2.0",
|
|
62
67
|
"@types/react-dom": "~18.2.0",
|
|
63
68
|
"react": "~18.2.0",
|
|
64
69
|
"react-dom": "~18.2.0",
|
|
65
70
|
"vite": "5.4.7",
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/echo-schema": "0.8.
|
|
69
|
-
"@dxos/react-ui": "0.8.
|
|
70
|
-
"@dxos/random": "0.8.
|
|
71
|
-
"@dxos/react-ui-theme": "0.8.
|
|
72
|
-
"@dxos/test-utils": "0.8.
|
|
73
|
-
"@dxos/storybook-utils": "0.8.
|
|
71
|
+
"@dxos/client": "0.8.4-main.28f8d3d",
|
|
72
|
+
"@dxos/app-graph": "0.8.4-main.28f8d3d",
|
|
73
|
+
"@dxos/echo-schema": "0.8.4-main.28f8d3d",
|
|
74
|
+
"@dxos/react-ui": "0.8.4-main.28f8d3d",
|
|
75
|
+
"@dxos/random": "0.8.4-main.28f8d3d",
|
|
76
|
+
"@dxos/react-ui-theme": "0.8.4-main.28f8d3d",
|
|
77
|
+
"@dxos/test-utils": "0.8.4-main.28f8d3d",
|
|
78
|
+
"@dxos/storybook-utils": "0.8.4-main.28f8d3d"
|
|
74
79
|
},
|
|
75
80
|
"peerDependencies": {
|
|
76
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
77
81
|
"react": "~18.2.0",
|
|
78
82
|
"react-dom": "~18.2.0",
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/react-ui
|
|
82
|
-
"@dxos/react-ui": "0.8.
|
|
83
|
+
"@dxos/random": "0.8.4-main.28f8d3d",
|
|
84
|
+
"@dxos/client": "0.8.4-main.28f8d3d",
|
|
85
|
+
"@dxos/react-ui": "0.8.4-main.28f8d3d",
|
|
86
|
+
"@dxos/react-ui-theme": "0.8.4-main.28f8d3d"
|
|
83
87
|
},
|
|
84
88
|
"publishConfig": {
|
|
85
89
|
"access": "public"
|
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
8
|
-
import { type Meta, type StoryObj } from '@storybook/react';
|
|
9
|
-
import React, {
|
|
8
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
9
|
+
import React, { useCallback, useState } from 'react';
|
|
10
10
|
|
|
11
11
|
import { faker } from '@dxos/random';
|
|
12
12
|
import { withTheme } from '@dxos/storybook-utils';
|
|
13
13
|
|
|
14
|
-
import { Stack } from './Stack';
|
|
15
|
-
import { StackItem } from '../StackItem';
|
|
16
14
|
import { type StackItemData } from '../defs';
|
|
15
|
+
import { StackItem } from '../StackItem';
|
|
16
|
+
|
|
17
|
+
import { Stack } from './Stack';
|
|
17
18
|
|
|
18
19
|
type StoryStackItem = {
|
|
19
20
|
id: string;
|
|
@@ -5,22 +5,22 @@
|
|
|
5
5
|
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
6
6
|
import { composeRefs } from '@radix-ui/react-compose-refs';
|
|
7
7
|
import React, {
|
|
8
|
-
Children,
|
|
9
8
|
type CSSProperties,
|
|
9
|
+
Children,
|
|
10
10
|
type ComponentPropsWithRef,
|
|
11
11
|
forwardRef,
|
|
12
|
-
useState,
|
|
13
|
-
useMemo,
|
|
14
12
|
useCallback,
|
|
15
13
|
useEffect,
|
|
14
|
+
useMemo,
|
|
15
|
+
useState,
|
|
16
16
|
} from 'react';
|
|
17
17
|
|
|
18
|
-
import { type ThemedClassName
|
|
18
|
+
import { ListItem, type ThemedClassName } from '@dxos/react-ui';
|
|
19
19
|
import { mx } from '@dxos/react-ui-theme';
|
|
20
20
|
|
|
21
21
|
import { useStackDropForElements } from '../../hooks';
|
|
22
|
-
import { StackContext } from '../StackContext';
|
|
23
22
|
import { type StackContextValue } from '../defs';
|
|
23
|
+
import { StackContext } from '../StackContext';
|
|
24
24
|
|
|
25
25
|
export type Orientation = 'horizontal' | 'vertical';
|
|
26
26
|
export type Size = 'intrinsic' | 'contain' | 'contain-fit-content';
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { createContext, useContext } from 'react';
|
|
6
6
|
|
|
7
|
+
import { type StackItemRearrangeHandler, type StackItemSize } from './defs';
|
|
7
8
|
import { type Orientation, type Size } from './Stack';
|
|
8
|
-
import { type StackItemSize, type StackItemRearrangeHandler } from './defs';
|
|
9
9
|
|
|
10
10
|
export type StackContextValue = {
|
|
11
11
|
orientation: Orientation;
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { DropdownMenu, Icon } from '@dxos/react-ui';
|
|
11
11
|
import { withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
13
|
import { StackItem } from './StackItem';
|
|
@@ -7,46 +7,47 @@ import { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-d
|
|
|
7
7
|
import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';
|
|
8
8
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
9
9
|
import {
|
|
10
|
+
type Edge,
|
|
10
11
|
attachClosestEdge,
|
|
11
12
|
extractClosestEdge,
|
|
12
|
-
type Edge,
|
|
13
13
|
} from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
14
14
|
import { useFocusableGroup } from '@fluentui/react-tabster';
|
|
15
15
|
import { composeRefs } from '@radix-ui/react-compose-refs';
|
|
16
16
|
import React, {
|
|
17
|
-
forwardRef,
|
|
18
|
-
useLayoutEffect,
|
|
19
|
-
useState,
|
|
20
17
|
type ComponentPropsWithRef,
|
|
21
|
-
useCallback,
|
|
22
18
|
type ReactNode,
|
|
19
|
+
forwardRef,
|
|
20
|
+
useCallback,
|
|
21
|
+
useLayoutEffect,
|
|
23
22
|
useMemo,
|
|
23
|
+
useState,
|
|
24
24
|
} from 'react';
|
|
25
25
|
import { createPortal } from 'react-dom';
|
|
26
26
|
|
|
27
|
-
import { type ThemedClassName
|
|
27
|
+
import { ListItem, type ThemedClassName } from '@dxos/react-ui';
|
|
28
28
|
import { resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';
|
|
29
29
|
import { mx } from '@dxos/react-ui-theme';
|
|
30
30
|
|
|
31
|
+
import { type StackItemData, type StackItemSize } from '../defs';
|
|
32
|
+
import { type ItemDragState, StackItemContext, idle, useStack, useStackItem } from '../StackContext';
|
|
33
|
+
|
|
31
34
|
import { StackItemContent, type StackItemContentProps } from './StackItemContent';
|
|
32
35
|
import { StackItemDragHandle, type StackItemDragHandleProps } from './StackItemDragHandle';
|
|
33
36
|
import {
|
|
34
37
|
StackItemHeading,
|
|
35
38
|
StackItemHeadingLabel,
|
|
36
|
-
type StackItemHeadingProps,
|
|
37
39
|
type StackItemHeadingLabelProps,
|
|
40
|
+
type StackItemHeadingProps,
|
|
38
41
|
StackItemHeadingStickyContent,
|
|
39
42
|
} from './StackItemHeading';
|
|
40
43
|
import { StackItemResizeHandle, type StackItemResizeHandleProps } from './StackItemResizeHandle';
|
|
41
44
|
import {
|
|
42
45
|
StackItemSigil,
|
|
43
|
-
type StackItemSigilProps,
|
|
44
46
|
type StackItemSigilAction,
|
|
45
|
-
type StackItemSigilButtonProps,
|
|
46
47
|
StackItemSigilButton,
|
|
48
|
+
type StackItemSigilButtonProps,
|
|
49
|
+
type StackItemSigilProps,
|
|
47
50
|
} from './StackItemSigil';
|
|
48
|
-
import { useStack, StackItemContext, idle, type ItemDragState, useStackItem } from '../StackContext';
|
|
49
|
-
import { type StackItemSize, type StackItemData } from '../defs';
|
|
50
51
|
|
|
51
52
|
// NOTE: 48rem fills the screen on a MacbookPro with the sidebars closed.
|
|
52
53
|
export const DEFAULT_HORIZONTAL_SIZE = 48 satisfies StackItemSize;
|
|
@@ -9,7 +9,7 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
9
9
|
|
|
10
10
|
import { useStack, useStackItem } from '../StackContext';
|
|
11
11
|
|
|
12
|
-
export type StackItemContentProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & {
|
|
12
|
+
export type StackItemContentProps = ThemedClassName<Omit<ComponentPropsWithoutRef<'div'>, 'role'>> & {
|
|
13
13
|
/**
|
|
14
14
|
* This flag is required in order to clarify a developer experience that seemed like it needed extra boilerplate
|
|
15
15
|
* (`row-span-2`) or was buggy. See the description of the StackItem.Content component itself for more information.
|
|
@@ -54,15 +54,16 @@ export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps
|
|
|
54
54
|
},
|
|
55
55
|
[toolbar, statusbar, layoutManaged],
|
|
56
56
|
);
|
|
57
|
+
|
|
57
58
|
return (
|
|
58
59
|
<div
|
|
59
60
|
role='none'
|
|
60
61
|
{...props}
|
|
61
62
|
className={mx(
|
|
62
|
-
'group grid grid-cols-[100%]',
|
|
63
|
+
'group grid grid-cols-[100%] density-coarse',
|
|
63
64
|
stackItemSize === 'contain' && 'min-bs-0 overflow-hidden',
|
|
64
65
|
size === 'video' ? 'aspect-video' : size === 'square' && 'aspect-square',
|
|
65
|
-
toolbar && '[
|
|
66
|
+
toolbar && '[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator',
|
|
66
67
|
role === 'section' &&
|
|
67
68
|
toolbar &&
|
|
68
69
|
'[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:block-start-0 [&_.dx-toolbar]:-mbe-px [&_.dx-toolbar]:min-is-0',
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { useFocusableGroup } from '@fluentui/react-tabster';
|
|
6
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
7
|
import React, {
|
|
8
|
-
type ComponentPropsWithoutRef,
|
|
9
8
|
type ComponentPropsWithRef,
|
|
10
|
-
|
|
9
|
+
type ComponentPropsWithoutRef,
|
|
11
10
|
type PropsWithChildren,
|
|
11
|
+
forwardRef,
|
|
12
12
|
} from 'react';
|
|
13
13
|
|
|
14
14
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
15
|
-
import {
|
|
15
|
+
import { type AttendableId, type Related, useAttention } from '@dxos/react-ui-attention';
|
|
16
16
|
import { mx } from '@dxos/react-ui-theme';
|
|
17
17
|
|
|
18
18
|
import { useStack } from '../StackContext';
|
|
@@ -6,9 +6,10 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { ResizeHandle } from '@dxos/react-ui-dnd';
|
|
8
8
|
|
|
9
|
-
import { DEFAULT_EXTRINSIC_SIZE } from './StackItem';
|
|
10
9
|
import { useStack, useStackItem } from '../StackContext';
|
|
11
10
|
|
|
11
|
+
import { DEFAULT_EXTRINSIC_SIZE } from './StackItem';
|
|
12
|
+
|
|
12
13
|
const MIN_WIDTH = 20;
|
|
13
14
|
const MIN_HEIGHT = 3;
|
|
14
15
|
|
|
@@ -11,9 +11,10 @@ import { type AttendableId, type Related, useAttention } from '@dxos/react-ui-at
|
|
|
11
11
|
import { descriptionText, mx } from '@dxos/react-ui-theme';
|
|
12
12
|
import { getHostPlatform } from '@dxos/util';
|
|
13
13
|
|
|
14
|
-
import { MenuSignifierHorizontal } from './MenuSignifier';
|
|
15
14
|
import { translationKey } from '../../translations';
|
|
16
15
|
|
|
16
|
+
import { MenuSignifierHorizontal } from './MenuSignifier';
|
|
17
|
+
|
|
17
18
|
export type KeyBinding = {
|
|
18
19
|
windows?: string;
|
|
19
20
|
macos?: string;
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { faker } from '@dxos/random';
|
|
11
|
+
import { withTheme } from '@dxos/storybook-utils';
|
|
12
|
+
|
|
13
|
+
import { Card } from './Card';
|
|
14
|
+
|
|
15
|
+
// Set a seed for reproducible random values
|
|
16
|
+
faker.seed(0);
|
|
17
|
+
|
|
18
|
+
type CardStoryProps = {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
image: string;
|
|
22
|
+
showImage: boolean;
|
|
23
|
+
showIcon: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const meta: Meta<CardStoryProps> = {
|
|
27
|
+
title: 'ui/react-ui-stack/Card',
|
|
28
|
+
decorators: [withTheme],
|
|
29
|
+
argTypes: {
|
|
30
|
+
title: {
|
|
31
|
+
control: 'text',
|
|
32
|
+
description: 'Card title',
|
|
33
|
+
},
|
|
34
|
+
description: {
|
|
35
|
+
control: 'text',
|
|
36
|
+
description: 'Card description',
|
|
37
|
+
},
|
|
38
|
+
image: {
|
|
39
|
+
control: 'text',
|
|
40
|
+
description: 'URL for the poster image',
|
|
41
|
+
},
|
|
42
|
+
showImage: {
|
|
43
|
+
control: 'boolean',
|
|
44
|
+
description: 'Whether to show the image',
|
|
45
|
+
},
|
|
46
|
+
showIcon: {
|
|
47
|
+
control: 'boolean',
|
|
48
|
+
description: 'Whether to show an icon (when image is not shown)',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
args: {
|
|
52
|
+
title: faker.commerce.productName(),
|
|
53
|
+
description: faker.lorem.paragraph(),
|
|
54
|
+
image: faker.image.url(),
|
|
55
|
+
showImage: true,
|
|
56
|
+
showIcon: true,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default meta;
|
|
61
|
+
|
|
62
|
+
export const Default: StoryObj<CardStoryProps> = {
|
|
63
|
+
render: ({ title, description, image, showImage, showIcon }: CardStoryProps) => (
|
|
64
|
+
<div className='max-is-md'>
|
|
65
|
+
<Card.StaticRoot>
|
|
66
|
+
<Card.Toolbar>
|
|
67
|
+
<Card.DragHandle toolbarItem />
|
|
68
|
+
<Card.ToolbarSeparator variant='gap' />
|
|
69
|
+
<Card.ToolbarIconButton iconOnly variant='ghost' icon='ph--x--regular' label={'remove card label'} />
|
|
70
|
+
</Card.Toolbar>
|
|
71
|
+
{showImage && <Card.Poster alt={title} image={image} />}
|
|
72
|
+
{!showImage && showIcon && <Card.Poster alt={title} icon='ph--building-office--regular' />}
|
|
73
|
+
<Card.Heading>{title}</Card.Heading>
|
|
74
|
+
{description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
|
|
75
|
+
</Card.StaticRoot>
|
|
76
|
+
</div>
|
|
77
|
+
),
|
|
78
|
+
};
|
|
@@ -5,40 +5,27 @@
|
|
|
5
5
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
6
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
7
|
import React, {
|
|
8
|
-
type ComponentPropsWithoutRef,
|
|
9
8
|
type ComponentPropsWithRef,
|
|
9
|
+
type ComponentPropsWithoutRef,
|
|
10
10
|
type FC,
|
|
11
|
-
forwardRef,
|
|
12
11
|
type PropsWithChildren,
|
|
12
|
+
forwardRef,
|
|
13
13
|
} from 'react';
|
|
14
14
|
|
|
15
15
|
import { Icon, IconButton, type ThemedClassName, Toolbar, type ToolbarRootProps, useTranslation } from '@dxos/react-ui';
|
|
16
16
|
import { hoverableControls, mx } from '@dxos/react-ui-theme';
|
|
17
17
|
|
|
18
|
-
import { cardChrome, cardContent, cardHeading, cardRoot, cardText, cardSpacing } from './fragments';
|
|
19
18
|
import { StackItem } from '../../components';
|
|
20
19
|
import { translationKey } from '../../translations';
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
import { cardChrome, cardHeading, cardRoot, cardSpacing, cardText } from './fragments';
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
({ children, classNames, asChild, role = 'none', ...props }, forwardedRef) => {
|
|
26
|
-
const Root = asChild ? Slot : 'div';
|
|
27
|
-
const rootProps = asChild ? { classNames: [cardRoot, classNames] } : { className: mx(cardRoot, classNames), role };
|
|
28
|
-
return (
|
|
29
|
-
<Root {...props} {...rootProps} ref={forwardedRef}>
|
|
30
|
-
{children}
|
|
31
|
-
</Root>
|
|
32
|
-
);
|
|
33
|
-
},
|
|
34
|
-
);
|
|
23
|
+
type SharedCardProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { asChild?: boolean };
|
|
35
24
|
|
|
36
|
-
const
|
|
25
|
+
const CardStaticRoot = forwardRef<HTMLDivElement, SharedCardProps>(
|
|
37
26
|
({ children, classNames, asChild, role = 'group', ...props }, forwardedRef) => {
|
|
38
27
|
const Root = asChild ? Slot : 'div';
|
|
39
|
-
const rootProps = asChild
|
|
40
|
-
? { classNames: [cardContent, classNames] }
|
|
41
|
-
: { className: mx(cardContent, classNames), role };
|
|
28
|
+
const rootProps = asChild ? { classNames: [cardRoot, classNames] } : { className: mx(cardRoot, classNames), role };
|
|
42
29
|
return (
|
|
43
30
|
<Root {...props} {...rootProps} ref={forwardedRef}>
|
|
44
31
|
{children}
|
|
@@ -49,21 +36,40 @@ const CardContent = forwardRef<HTMLDivElement, SharedCardProps>(
|
|
|
49
36
|
|
|
50
37
|
/**
|
|
51
38
|
* This should be used by Surface fulfillments in cases where the content may or may not already be encapsulated (e.g.
|
|
52
|
-
* in a Popover) and knows this based on the `role` it receives. This will render a `Card.
|
|
39
|
+
* in a Popover) and knows this based on the `role` it receives. This will render a `Card.StaticRoot` by default, otherwise
|
|
53
40
|
* it will render a `div` primitive with the appropriate styling for specific handled situations.
|
|
54
41
|
*/
|
|
55
|
-
const
|
|
56
|
-
|
|
42
|
+
const CardSurfaceRoot = ({
|
|
43
|
+
role = 'never',
|
|
44
|
+
children,
|
|
45
|
+
classNames,
|
|
46
|
+
}: ThemedClassName<PropsWithChildren<{ role?: string }>>) => {
|
|
47
|
+
if (['card--popover', 'card--intrinsic', 'card--extrinsic'].includes(role)) {
|
|
57
48
|
return (
|
|
58
|
-
<div
|
|
49
|
+
<div
|
|
50
|
+
className={mx(
|
|
51
|
+
role === 'card--popover'
|
|
52
|
+
? 'popover-card-width'
|
|
53
|
+
: ['card--intrinsic', 'card--extrinsic'].includes(role)
|
|
54
|
+
? 'contents'
|
|
55
|
+
: '',
|
|
56
|
+
classNames,
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
59
|
{children}
|
|
60
60
|
</div>
|
|
61
61
|
);
|
|
62
62
|
} else {
|
|
63
63
|
return (
|
|
64
|
-
<
|
|
64
|
+
<CardStaticRoot
|
|
65
|
+
classNames={[
|
|
66
|
+
role === 'card--transclusion' && 'mlb-[1em]',
|
|
67
|
+
role === 'card--transclusion' && hoverableControls,
|
|
68
|
+
classNames,
|
|
69
|
+
]}
|
|
70
|
+
>
|
|
65
71
|
{children}
|
|
66
|
-
</
|
|
72
|
+
</CardStaticRoot>
|
|
67
73
|
);
|
|
68
74
|
}
|
|
69
75
|
};
|
|
@@ -84,7 +90,7 @@ const CardHeading = forwardRef<HTMLDivElement, SharedCardProps>(
|
|
|
84
90
|
|
|
85
91
|
const CardToolbar = forwardRef<HTMLDivElement, ToolbarRootProps>(({ children, classNames, ...props }, forwardedRef) => {
|
|
86
92
|
return (
|
|
87
|
-
<Toolbar.Root {...props} classNames={['bg-transparent', classNames]} ref={forwardedRef}>
|
|
93
|
+
<Toolbar.Root {...props} classNames={['bg-transparent density-coarse', classNames]} ref={forwardedRef}>
|
|
88
94
|
{children}
|
|
89
95
|
</Toolbar.Root>
|
|
90
96
|
);
|
|
@@ -101,7 +107,7 @@ const CardDragHandle = forwardRef<HTMLButtonElement, { toolbarItem?: boolean }>(
|
|
|
101
107
|
iconOnly
|
|
102
108
|
icon='ph--dots-six-vertical--regular'
|
|
103
109
|
variant='ghost'
|
|
104
|
-
label={t('
|
|
110
|
+
label={t('drag handle label')}
|
|
105
111
|
classNames='pli-2'
|
|
106
112
|
ref={forwardedRef}
|
|
107
113
|
/>
|
|
@@ -164,9 +170,8 @@ const CardText = forwardRef<HTMLParagraphElement, SharedCardProps>(
|
|
|
164
170
|
);
|
|
165
171
|
|
|
166
172
|
export const Card = {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
Container: CardConditionalContent,
|
|
173
|
+
StaticRoot: CardStaticRoot,
|
|
174
|
+
SurfaceRoot: CardSurfaceRoot,
|
|
170
175
|
Heading: CardHeading,
|
|
171
176
|
Toolbar: CardToolbar,
|
|
172
177
|
ToolbarIconButton: CardToolbarIconButton,
|
|
@@ -179,4 +184,4 @@ export const Card = {
|
|
|
179
184
|
Text: CardText,
|
|
180
185
|
};
|
|
181
186
|
|
|
182
|
-
export { cardRoot,
|
|
187
|
+
export { cardRoot, cardHeading, cardText, cardChrome, cardSpacing };
|
|
@@ -6,14 +6,14 @@ import React, { type PropsWithChildren } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { mx } from '@dxos/react-ui-theme';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { cardRoot } from './fragments';
|
|
10
10
|
|
|
11
11
|
const CardDragPreviewRoot = ({ children }: PropsWithChildren<{}>) => {
|
|
12
12
|
return <div className='p-2'>{children}</div>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const CardDragPreviewContent = ({ children }: PropsWithChildren<{}>) => {
|
|
16
|
-
return <div className={mx(
|
|
16
|
+
return <div className={mx(cardRoot, 'ring-focusLine ring-neutralFocusIndicator')}>{children}</div>;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const CardDragPreview = {
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export const cardRoot =
|
|
6
|
-
|
|
7
|
-
export const cardContent =
|
|
5
|
+
export const cardRoot =
|
|
8
6
|
'rounded overflow-hidden bg-cardSurface border border-separator dark:border-subduedSeparator dx-focus-ring-group-y-indicator relative min-bs-[--rail-item] group/card';
|
|
9
7
|
|
|
10
8
|
export const cardSpacing = 'pli-cardSpacingInline mlb-cardSpacingBlock';
|