@dxos/react-ui-stack 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44

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.
Files changed (108) hide show
  1. package/dist/lib/browser/index.mjs +920 -57
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/playwright/index.mjs +10 -23
  5. package/dist/lib/browser/playwright/index.mjs.map +2 -2
  6. package/dist/lib/node-esm/index.mjs +921 -57
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/playwright/index.mjs +10 -23
  10. package/dist/lib/node-esm/playwright/index.mjs.map +2 -2
  11. package/dist/types/src/{exemplars → components}/CardStack/CardStack.d.ts +18 -13
  12. package/dist/types/src/components/CardStack/CardStack.d.ts.map +1 -0
  13. package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +1 -0
  14. package/dist/types/src/{exemplars → components}/CardStack/CardStackDragPreview.d.ts +4 -1
  15. package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +1 -0
  16. package/dist/types/src/components/CardStack/index.d.ts.map +1 -0
  17. package/dist/types/src/components/Stack/Stack.d.ts +7 -7
  18. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  19. package/dist/types/src/components/StackContext.d.ts +1 -1
  20. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  21. package/dist/types/src/components/StackItem/StackItem.d.ts +5 -9
  22. package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
  23. package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/StackItem/StackItemContent.d.ts +2 -45
  25. package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
  26. package/dist/types/src/components/StackItem/StackItemSigil.d.ts +2 -2
  27. package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
  28. package/dist/types/src/components/deprecated/LayoutControls.d.ts +3 -0
  29. package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +1 -1
  30. package/dist/types/src/components/index.d.ts +2 -2
  31. package/dist/types/src/components/index.d.ts.map +1 -1
  32. package/dist/types/src/components/{defs.d.ts → types.d.ts} +1 -1
  33. package/dist/types/src/components/types.d.ts.map +1 -0
  34. package/dist/types/src/hooks/useStackDropForElements.d.ts +8 -6
  35. package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
  36. package/dist/types/src/index.d.ts +0 -1
  37. package/dist/types/src/index.d.ts.map +1 -1
  38. package/dist/types/src/translations.d.ts +2 -2
  39. package/dist/types/src/translations.d.ts.map +1 -1
  40. package/dist/types/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +40 -37
  42. package/src/{exemplars → components}/CardStack/CardStack.stories.tsx +10 -10
  43. package/src/{exemplars → components}/CardStack/CardStack.tsx +113 -57
  44. package/src/{exemplars → components}/CardStack/CardStackDragPreview.tsx +12 -9
  45. package/src/components/Stack/Stack.stories.tsx +2 -2
  46. package/src/components/Stack/Stack.tsx +19 -17
  47. package/src/components/StackContext.tsx +1 -1
  48. package/src/components/StackItem/StackItem.stories.tsx +6 -4
  49. package/src/components/StackItem/StackItem.tsx +24 -12
  50. package/src/components/StackItem/StackItemContent.tsx +19 -50
  51. package/src/components/StackItem/StackItemHeading.tsx +1 -1
  52. package/src/components/StackItem/StackItemSigil.tsx +3 -3
  53. package/src/components/deprecated/LayoutControls.tsx +3 -0
  54. package/src/components/index.ts +2 -2
  55. package/src/hooks/useStackDropForElements.ts +58 -44
  56. package/src/index.ts +0 -3
  57. package/src/playwright/playwright.config.ts +1 -1
  58. package/src/translations.ts +1 -1
  59. package/dist/lib/browser/chunk-T4ZCIFCF.mjs +0 -1448
  60. package/dist/lib/browser/chunk-T4ZCIFCF.mjs.map +0 -7
  61. package/dist/lib/browser/testing/index.mjs +0 -31
  62. package/dist/lib/browser/testing/index.mjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-G2QYUH52.mjs +0 -1450
  64. package/dist/lib/node-esm/chunk-G2QYUH52.mjs.map +0 -7
  65. package/dist/lib/node-esm/testing/index.mjs +0 -32
  66. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  67. package/dist/types/src/components/Image/Image.d.ts +0 -14
  68. package/dist/types/src/components/Image/Image.d.ts.map +0 -1
  69. package/dist/types/src/components/Image/Image.stories.d.ts +0 -32
  70. package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
  71. package/dist/types/src/components/Image/index.d.ts +0 -2
  72. package/dist/types/src/components/Image/index.d.ts.map +0 -1
  73. package/dist/types/src/components/defs.d.ts.map +0 -1
  74. package/dist/types/src/exemplars/Card/Card.d.ts +0 -66
  75. package/dist/types/src/exemplars/Card/Card.d.ts.map +0 -1
  76. package/dist/types/src/exemplars/Card/Card.stories.d.ts +0 -21
  77. package/dist/types/src/exemplars/Card/Card.stories.d.ts.map +0 -1
  78. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts +0 -6
  79. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts.map +0 -1
  80. package/dist/types/src/exemplars/Card/fragments.d.ts +0 -13
  81. package/dist/types/src/exemplars/Card/fragments.d.ts.map +0 -1
  82. package/dist/types/src/exemplars/Card/index.d.ts +0 -4
  83. package/dist/types/src/exemplars/Card/index.d.ts.map +0 -1
  84. package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +0 -1
  85. package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts.map +0 -1
  86. package/dist/types/src/exemplars/CardStack/CardStackDragPreview.d.ts.map +0 -1
  87. package/dist/types/src/exemplars/CardStack/index.d.ts.map +0 -1
  88. package/dist/types/src/exemplars/index.d.ts +0 -3
  89. package/dist/types/src/exemplars/index.d.ts.map +0 -1
  90. package/dist/types/src/testing/CardContainer.d.ts +0 -6
  91. package/dist/types/src/testing/CardContainer.d.ts.map +0 -1
  92. package/dist/types/src/testing/index.d.ts +0 -2
  93. package/dist/types/src/testing/index.d.ts.map +0 -1
  94. package/src/components/Image/Image.stories.tsx +0 -78
  95. package/src/components/Image/Image.tsx +0 -192
  96. package/src/components/Image/index.ts +0 -5
  97. package/src/exemplars/Card/Card.stories.tsx +0 -64
  98. package/src/exemplars/Card/Card.tsx +0 -204
  99. package/src/exemplars/Card/CardDragPreview.tsx +0 -22
  100. package/src/exemplars/Card/fragments.ts +0 -24
  101. package/src/exemplars/Card/index.ts +0 -7
  102. package/src/exemplars/index.ts +0 -6
  103. package/src/testing/CardContainer.tsx +0 -37
  104. package/src/testing/index.ts +0 -5
  105. /package/dist/types/src/{exemplars → components}/CardStack/CardStack.stories.d.ts +0 -0
  106. /package/dist/types/src/{exemplars → components}/CardStack/index.d.ts +0 -0
  107. /package/src/{exemplars → components}/CardStack/index.ts +0 -0
  108. /package/src/components/{defs.ts → types.ts} +0 -0
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-stack",
3
- "version": "0.8.4-main.ead640a",
3
+ "version": "0.8.4-main.ef1bc66f44",
4
4
  "description": "A stack component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  ".": {
@@ -18,11 +22,6 @@
18
22
  "types": "./dist/types/src/playwright/index.d.ts",
19
23
  "browser": "./dist/lib/browser/playwright/index.mjs",
20
24
  "node": "./dist/lib/node-esm/playwright/index.mjs"
21
- },
22
- "./testing": {
23
- "types": "./dist/types/src/testing/index.d.ts",
24
- "browser": "./dist/lib/browser/testing/index.mjs",
25
- "node": "./dist/lib/node-esm/testing/index.mjs"
26
25
  }
27
26
  },
28
27
  "types": "dist/types/src/index.d.ts",
@@ -41,11 +40,11 @@
41
40
  "src"
42
41
  ],
43
42
  "dependencies": {
44
- "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
45
- "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
46
- "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
47
- "@fluentui/react-tabster": "^9.24.2",
48
- "@preact-signals/safe-react": "^0.9.0",
43
+ "@atlaskit/pragmatic-drag-and-drop": "1.7.7",
44
+ "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.2",
45
+ "@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
46
+ "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "3.2.10",
47
+ "@fluentui/react-tabster": "9.26.11",
49
48
  "@radix-ui/primitive": "1.1.1",
50
49
  "@radix-ui/react-compose-refs": "1.1.1",
51
50
  "@radix-ui/react-context": "1.1.1",
@@ -54,36 +53,40 @@
54
53
  "@radix-ui/react-slot": "1.1.2",
55
54
  "@radix-ui/react-use-controllable-state": "1.1.0",
56
55
  "react-resize-detector": "^11.0.1",
57
- "@dxos/echo": "0.8.4-main.ead640a",
58
- "@dxos/keyboard": "0.8.4-main.ead640a",
59
- "@dxos/react-ui-attention": "0.8.4-main.ead640a",
60
- "@dxos/react-ui-dnd": "0.8.4-main.ead640a",
61
- "@dxos/storybook-utils": "0.8.4-main.ead640a",
62
- "@dxos/live-object": "0.8.4-main.ead640a",
63
- "@dxos/util": "0.8.4-main.ead640a"
56
+ "@dxos/keyboard": "0.8.4-main.ef1bc66f44",
57
+ "@dxos/echo": "0.8.4-main.ef1bc66f44",
58
+ "@dxos/react-ui-attention": "0.8.4-main.ef1bc66f44",
59
+ "@dxos/react-ui-dnd": "0.8.4-main.ef1bc66f44",
60
+ "@dxos/util": "0.8.4-main.ef1bc66f44",
61
+ "@dxos/react-ui-mosaic": "0.8.4-main.ef1bc66f44"
64
62
  },
65
63
  "devDependencies": {
66
- "@types/react": "~19.2.2",
67
- "@types/react-dom": "~19.2.1",
68
- "react": "~19.2.0",
69
- "react-dom": "~19.2.0",
64
+ "@types/react": "~19.2.7",
65
+ "@types/react-dom": "~19.2.3",
66
+ "react": "~19.2.3",
67
+ "react-dom": "~19.2.3",
70
68
  "vite": "7.1.9",
71
- "@dxos/app-graph": "0.8.4-main.ead640a",
72
- "@dxos/client": "0.8.4-main.ead640a",
73
- "@dxos/echo": "0.8.4-main.ead640a",
74
- "@dxos/react-ui": "0.8.4-main.ead640a",
75
- "@dxos/random": "0.8.4-main.ead640a",
76
- "@dxos/react-ui-theme": "0.8.4-main.ead640a",
77
- "@dxos/storybook-utils": "0.8.4-main.ead640a",
78
- "@dxos/test-utils": "0.8.4-main.ead640a"
69
+ "@dxos/client": "0.8.4-main.ef1bc66f44",
70
+ "@dxos/app-framework": "0.8.4-main.ef1bc66f44",
71
+ "@dxos/echo": "0.8.4-main.ef1bc66f44",
72
+ "@dxos/app-graph": "0.8.4-main.ef1bc66f44",
73
+ "@dxos/echo-db": "0.8.4-main.ef1bc66f44",
74
+ "@dxos/react-ui": "0.8.4-main.ef1bc66f44",
75
+ "@dxos/random": "0.8.4-main.ef1bc66f44",
76
+ "@dxos/react-client": "0.8.4-main.ef1bc66f44",
77
+ "@dxos/schema": "0.8.4-main.ef1bc66f44",
78
+ "@dxos/storybook-utils": "0.8.4-main.ef1bc66f44",
79
+ "@dxos/test-utils": "0.8.4-main.ef1bc66f44",
80
+ "@dxos/types": "0.8.4-main.ef1bc66f44",
81
+ "@dxos/ui-theme": "0.8.4-main.ef1bc66f44"
79
82
  },
80
83
  "peerDependencies": {
81
- "react": "^19.0.0",
82
- "react-dom": "^19.0.0",
83
- "@dxos/client": "0.8.4-main.ead640a",
84
- "@dxos/random": "0.8.4-main.ead640a",
85
- "@dxos/react-ui-theme": "0.8.4-main.ead640a",
86
- "@dxos/react-ui": "0.8.4-main.ead640a"
84
+ "react": "~19.2.3",
85
+ "react-dom": "~19.2.3",
86
+ "@dxos/random": "0.8.4-main.ef1bc66f44",
87
+ "@dxos/client": "0.8.4-main.ef1bc66f44",
88
+ "@dxos/react-ui": "0.8.4-main.ef1bc66f44",
89
+ "@dxos/ui-theme": "0.8.4-main.ef1bc66f44"
87
90
  },
88
91
  "publishConfig": {
89
92
  "access": "public"
@@ -9,9 +9,9 @@ import React, { useCallback, useState } from 'react';
9
9
  import { faker } from '@dxos/random';
10
10
  import { IconButton } from '@dxos/react-ui';
11
11
  import { withTheme } from '@dxos/react-ui/testing';
12
+ import { Card, CardDragPreview } from '@dxos/react-ui-mosaic';
12
13
 
13
- import { StackItem } from '../../components';
14
- import { Card, CardDragPreview } from '../Card';
14
+ import { StackItem } from '../StackItem';
15
15
 
16
16
  import { CardStack } from './CardStack';
17
17
 
@@ -94,7 +94,7 @@ const CardStackStory = () => {
94
94
 
95
95
  return (
96
96
  <CardStack.Root classNames='is-96'>
97
- <CardStack.Content>
97
+ <CardStack.Content footer>
98
98
  <CardStack.Stack id='story column' onRearrange={handleRearrange} itemsCount={column.length}>
99
99
  {column.map((card, cardIndex, cardsArray) => {
100
100
  const cardItem = { id: card.id, type: 'card' as const };
@@ -109,10 +109,10 @@ const CardStackStory = () => {
109
109
  prevSiblingId={prevCardId}
110
110
  nextSiblingId={nextCardId}
111
111
  >
112
- <Card.StaticRoot>
112
+ <Card.Root>
113
113
  <Card.Toolbar>
114
114
  <StackItem.DragHandle asChild>
115
- <Card.DragHandle toolbarItem />
115
+ <Card.DragHandle />
116
116
  </StackItem.DragHandle>
117
117
  <Card.ToolbarSeparator variant='gap' />
118
118
  <Card.ToolbarIconButton
@@ -125,18 +125,18 @@ const CardStackStory = () => {
125
125
  </Card.Toolbar>
126
126
  <Card.Poster alt={card.title} image={card.image} />
127
127
  <Card.Heading>{card.title}</Card.Heading>
128
- <Card.Text classNames='line-clamp-2'>{card.description}</Card.Text>
129
- </Card.StaticRoot>
128
+ <Card.Text variant='description'>{card.description}</Card.Text>
129
+ </Card.Root>
130
130
  <StackItem.DragPreview>
131
131
  {() => (
132
132
  <CardDragPreview.Root>
133
133
  <CardDragPreview.Content>
134
134
  <Card.Toolbar>
135
- <Card.DragHandle toolbarItem />
135
+ <Card.DragHandle />
136
136
  </Card.Toolbar>
137
137
  <Card.Poster alt={card.title} image={card.image} />
138
138
  <Card.Heading>{card.title}</Card.Heading>
139
- <Card.Text classNames='line-clamp-2'>{card.description}</Card.Text>
139
+ <Card.Text variant='description'>{card.description}</Card.Text>
140
140
  </CardDragPreview.Content>
141
141
  </CardDragPreview.Root>
142
142
  )}
@@ -160,7 +160,7 @@ const CardStackStory = () => {
160
160
  const meta = {
161
161
  title: 'ui/react-ui-stack/CardStack',
162
162
  component: CardStackStory,
163
- decorators: [withTheme],
163
+ decorators: [withTheme()],
164
164
  parameters: {
165
165
  layout: 'fullscreen',
166
166
  },
@@ -6,17 +6,78 @@ import { Slot } from '@radix-ui/react-slot';
6
6
  import React, { type ComponentPropsWithoutRef, forwardRef } from 'react';
7
7
 
8
8
  import type { ThemedClassName } from '@dxos/react-ui';
9
- import { mx } from '@dxos/react-ui-theme';
9
+ import { Card } from '@dxos/react-ui-mosaic';
10
+ import { cardDefaultInlineSize, mx } from '@dxos/ui-theme';
10
11
 
11
- import { Stack, type StackProps, railGridHorizontalContainFitContent } from '../../components';
12
- import { Card } from '../Card';
12
+ import { Stack, type StackProps, railGridHorizontalContainFitContent } from '../Stack';
13
13
 
14
- type SharedCardStackProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & { asChild?: boolean };
14
+ /**
15
+ * This is `cardDefaultInlineSize` plus 2 times the sum of the inner and outer spacing applied by CardStack on the inline axis.
16
+ */
17
+ const cardStackDefaultInlineSizeRem = cardDefaultInlineSize + 2.125;
18
+
19
+ //
20
+ // Root
21
+ //
22
+
23
+ const cardStackRoot = 'flex flex-col';
24
+
25
+ const CardStackRoot = forwardRef<HTMLDivElement, SharedCardStackProps>(
26
+ ({ children, classNames, asChild, role = 'none', ...props }, forwardedRef) => {
27
+ const Root = asChild ? Slot : 'div';
28
+ const rootProps = asChild
29
+ ? { classNames: [cardStackRoot, classNames] }
30
+ : { className: mx(cardStackRoot, classNames), role };
31
+
32
+ return (
33
+ <Root {...props} {...rootProps} ref={forwardedRef}>
34
+ {children}
35
+ </Root>
36
+ );
37
+ },
38
+ );
39
+
40
+ //
41
+ // Content
42
+ // TODO(burdon): Rename Viewport (should be the component that scrolls).
43
+ //
44
+
45
+ const cardStackContent = 'shrink min-bs-0 grid dx-focus-ring-group-x-indicator bg-baseSurface';
46
+
47
+ type CardStackContentProps = SharedCardStackProps & {
48
+ footer?: boolean;
49
+ };
50
+
51
+ const CardStackContent = forwardRef<HTMLDivElement, CardStackContentProps>(
52
+ ({ children, classNames, asChild, role = 'none', footer, ...props }, forwardedRef) => {
53
+ const Root = asChild ? Slot : 'div';
54
+ const baseClassNames = footer ? [cardStackContent, railGridHorizontalContainFitContent] : [cardStackContent];
55
+ const rootProps = asChild
56
+ ? { classNames: [...baseClassNames, classNames] }
57
+ : { className: mx(...baseClassNames, classNames), role };
58
+
59
+ return (
60
+ <Root {...props} {...rootProps} data-scroll-separator='false' ref={forwardedRef}>
61
+ {children}
62
+ </Root>
63
+ );
64
+ },
65
+ );
66
+
67
+ //
68
+ // Stack
69
+ // TODO(burdon): Rename Content.
70
+ //
71
+
72
+ type SharedCardStackProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & {
73
+ asChild?: boolean;
74
+ };
15
75
 
16
76
  const CardStackStack = forwardRef<
17
77
  HTMLDivElement,
18
78
  Omit<StackProps, 'orientation' | 'size' | 'rail' | 'separatorOnScroll'>
19
79
  >(({ children, classNames, itemsCount = 0, ...props }, forwardedRef) => {
80
+ // NOTE: Should not have horizontal padding since separatorOnScroll should be full width.
20
81
  return (
21
82
  <Stack
22
83
  orientation='vertical'
@@ -24,7 +85,7 @@ const CardStackStack = forwardRef<
24
85
  rail={false}
25
86
  classNames={
26
87
  /* NOTE(thure): Do not let this element have zero intrinsic size, otherwise the drop indicator will not display. See #9035. */
27
- ['plb-1', itemsCount > 0 && 'plb-2', classNames]
88
+ ['plb-2', classNames]
28
89
  }
29
90
  itemsCount={itemsCount}
30
91
  separatorOnScroll={9}
@@ -37,33 +98,19 @@ const CardStackStack = forwardRef<
37
98
  );
38
99
  });
39
100
 
40
- const CardStackDragHandle = Card.DragHandle;
41
-
42
- const cardStackHeading = 'mli-2 order-first bg-transparent rounded-bs-md flex items-center';
43
-
44
- const CardStackHeading = forwardRef<HTMLDivElement, SharedCardStackProps>(
45
- ({ children, classNames, asChild, role = 'heading', ...props }, forwardedRef) => {
46
- const Root = asChild ? Slot : 'div';
47
- const rootProps = asChild
48
- ? { classNames: [cardStackHeading, classNames] }
49
- : { className: mx(cardStackHeading, classNames), role };
50
- return (
51
- <Root {...props} {...rootProps} ref={forwardedRef}>
52
- {children}
53
- </Root>
54
- );
55
- },
56
- );
101
+ //
102
+ // Item
103
+ //
57
104
 
58
- const cardStackFooter =
59
- 'plb-2 mli-2 border-bs border-transparent [[data-scroll-separator-end="true"]_&]:border-subduedSeparator';
105
+ const cardStackItem = 'contain-layout pli-2 plb-1 first-of-type:pbs-0 last-of-type:pbe-0';
60
106
 
61
- const CardStackFooter = forwardRef<HTMLDivElement, SharedCardStackProps>(
107
+ const CardStackItem = forwardRef<HTMLDivElement, SharedCardStackProps>(
62
108
  ({ children, classNames, asChild, role = 'none', ...props }, forwardedRef) => {
63
109
  const Root = asChild ? Slot : 'div';
64
110
  const rootProps = asChild
65
- ? { classNames: [cardStackFooter, classNames] }
66
- : { className: mx(cardStackFooter, classNames), role };
111
+ ? { classNames: [cardStackItem, classNames] }
112
+ : { className: mx(cardStackItem, classNames), role };
113
+
67
114
  return (
68
115
  <Root {...props} {...rootProps} ref={forwardedRef}>
69
116
  {children}
@@ -72,36 +119,19 @@ const CardStackFooter = forwardRef<HTMLDivElement, SharedCardStackProps>(
72
119
  },
73
120
  );
74
121
 
75
- const cardStackContent =
76
- 'shrink min-bs-0 bg-baseSurface border border-separator rounded-md grid dx-focus-ring-group-x-indicator kanban-drop';
122
+ //
123
+ // Heading
124
+ //
77
125
 
78
- type CardStackContentProps = SharedCardStackProps & {
79
- footer?: boolean;
80
- };
126
+ const cardStackHeading = 'mli-2 order-first bg-transparent rounded-bs-md flex items-center';
81
127
 
82
- const CardStackContent = forwardRef<HTMLDivElement, CardStackContentProps>(
83
- ({ children, classNames, asChild, role = 'none', footer = true, ...props }, forwardedRef) => {
128
+ const CardStackHeading = forwardRef<HTMLDivElement, SharedCardStackProps>(
129
+ ({ children, classNames, asChild, role = 'heading', ...props }, forwardedRef) => {
84
130
  const Root = asChild ? Slot : 'div';
85
- const baseClassNames = footer ? [cardStackContent, railGridHorizontalContainFitContent] : [cardStackContent];
86
131
  const rootProps = asChild
87
- ? { classNames: [...baseClassNames, classNames] }
88
- : { className: mx(...baseClassNames, classNames), role };
89
- return (
90
- <Root {...props} {...rootProps} data-scroll-separator='false' ref={forwardedRef}>
91
- {children}
92
- </Root>
93
- );
94
- },
95
- );
96
-
97
- const cardStackRoot = 'flex flex-col pli-2 plb-2';
132
+ ? { classNames: [cardStackHeading, classNames] }
133
+ : { className: mx(cardStackHeading, classNames), role };
98
134
 
99
- const CardStackRoot = forwardRef<HTMLDivElement, SharedCardStackProps>(
100
- ({ children, classNames, asChild, role = 'none', ...props }, forwardedRef) => {
101
- const Root = asChild ? Slot : 'div';
102
- const rootProps = asChild
103
- ? { classNames: [cardStackRoot, classNames] }
104
- : { className: mx(cardStackRoot, classNames), role };
105
135
  return (
106
136
  <Root {...props} {...rootProps} ref={forwardedRef}>
107
137
  {children}
@@ -110,14 +140,20 @@ const CardStackRoot = forwardRef<HTMLDivElement, SharedCardStackProps>(
110
140
  },
111
141
  );
112
142
 
113
- const cardStackItem = 'contain-layout pli-2 plb-1 first-of-type:pbs-0 last-of-type:pbe-0';
143
+ //
144
+ // Footer
145
+ //
114
146
 
115
- const CardStackItem = forwardRef<HTMLDivElement, SharedCardStackProps>(
147
+ const cardStackFooter =
148
+ 'plb-2 mli-2 border-bs border-transparent [[data-scroll-separator-end="true"]_&]:border-subduedSeparator';
149
+
150
+ const CardStackFooter = forwardRef<HTMLDivElement, SharedCardStackProps>(
116
151
  ({ children, classNames, asChild, role = 'none', ...props }, forwardedRef) => {
117
152
  const Root = asChild ? Slot : 'div';
118
153
  const rootProps = asChild
119
- ? { classNames: [cardStackItem, classNames] }
120
- : { className: mx(cardStackItem, classNames), role };
154
+ ? { classNames: [cardStackFooter, classNames] }
155
+ : { className: mx(cardStackFooter, classNames), role };
156
+
121
157
  return (
122
158
  <Root {...props} {...rootProps} ref={forwardedRef}>
123
159
  {children}
@@ -126,6 +162,19 @@ const CardStackItem = forwardRef<HTMLDivElement, SharedCardStackProps>(
126
162
  },
127
163
  );
128
164
 
165
+ //
166
+ // DragHandle
167
+ //
168
+
169
+ const CardStackDragHandle = Card.DragHandle;
170
+
171
+ //
172
+ // CardStack
173
+ //
174
+
175
+ /**
176
+ * @deprecated Replace with Mosaic.Stack.
177
+ */
129
178
  export const CardStack = {
130
179
  Root: CardStackRoot,
131
180
  Content: CardStackContent,
@@ -136,4 +185,11 @@ export const CardStack = {
136
185
  Item: CardStackItem,
137
186
  };
138
187
 
139
- export { cardStackRoot, cardStackFooter, cardStackHeading, cardStackContent, cardStackItem };
188
+ export {
189
+ cardStackRoot,
190
+ cardStackFooter,
191
+ cardStackHeading,
192
+ cardStackContent,
193
+ cardStackItem,
194
+ cardStackDefaultInlineSizeRem,
195
+ };
@@ -4,11 +4,11 @@
4
4
 
5
5
  import React, { type PropsWithChildren } from 'react';
6
6
 
7
- import { IconButton, useTranslation } from '@dxos/react-ui';
8
- import { mx } from '@dxos/react-ui-theme';
7
+ import { IconButton, ScrollArea, useTranslation } from '@dxos/react-ui';
8
+ import { mx } from '@dxos/ui-theme';
9
9
 
10
- import { type StackProps } from '../../components';
11
10
  import { translationKey } from '../../translations';
11
+ import { type StackProps } from '../Stack';
12
12
 
13
13
  const CardStackDragPreviewRoot = ({ children }: PropsWithChildren<{}>) => {
14
14
  return (
@@ -41,18 +41,21 @@ const CardStackDragPreviewContent = ({
41
41
  itemsCount = 0,
42
42
  }: PropsWithChildren<Pick<StackProps, 'itemsCount'>>) => {
43
43
  return (
44
- <div
45
- className={mx('overflow-y-auto flex-1 pli-2 flex flex-col gap-2', 'plb-1', itemsCount > 0 ? 'plb-2' : 'plb-1')}
46
- >
47
- {children}
48
- </div>
44
+ <ScrollArea.Root orientation='vertical'>
45
+ <ScrollArea.Viewport classNames={mx('pli-2 plb-1 gap-2', itemsCount > 0 ? 'plb-2' : 'plb-1')}>
46
+ {children}
47
+ </ScrollArea.Viewport>
48
+ </ScrollArea.Root>
49
49
  );
50
50
  };
51
51
 
52
52
  const CardStackDragPreviewFooter = ({ children }: PropsWithChildren<{}>) => {
53
- return <div className='p-2 border-t border-separator'>{children}</div>;
53
+ return <div className='p-2 border-bs border-separator'>{children}</div>;
54
54
  };
55
55
 
56
+ /**
57
+ * @deprecated
58
+ */
56
59
  export const CardStackDragPreview = {
57
60
  Root: CardStackDragPreviewRoot,
58
61
  Heading: CardStackDragPreviewHeading,
@@ -9,8 +9,8 @@ import React, { useCallback, useState } from 'react';
9
9
  import { faker } from '@dxos/random';
10
10
  import { withTheme } from '@dxos/react-ui/testing';
11
11
 
12
- import { type StackItemData } from '../defs';
13
12
  import { StackItem } from '../StackItem';
13
+ import { type StackItemData } from '../types';
14
14
 
15
15
  import { Stack } from './Stack';
16
16
 
@@ -132,7 +132,7 @@ const meta = {
132
132
  title: 'ui/react-ui-stack/Stack',
133
133
  component: DefaultStory,
134
134
  argTypes: { orientation: { control: 'radio', options: ['horizontal', 'vertical'] } },
135
- decorators: [withTheme],
135
+ decorators: [withTheme()],
136
136
  } satisfies Meta<typeof DefaultStory>;
137
137
 
138
138
  export default meta;
@@ -7,6 +7,7 @@ import React, {
7
7
  type CSSProperties,
8
8
  Children,
9
9
  type ComponentPropsWithRef,
10
+ type FocusEvent,
10
11
  type KeyboardEvent,
11
12
  forwardRef,
12
13
  useCallback,
@@ -16,13 +17,14 @@ import React, {
16
17
  } from 'react';
17
18
 
18
19
  import { ListItem, type ThemedClassName, useId } from '@dxos/react-ui';
19
- import { mx } from '@dxos/react-ui-theme';
20
+ import { mx } from '@dxos/ui-theme';
20
21
 
21
22
  import { useStackDropForElements } from '../../hooks';
22
- import { type StackContextValue } from '../defs';
23
23
  import { StackContext } from '../StackContext';
24
+ import { type StackContextValue } from '../types';
24
25
 
25
26
  export type Orientation = 'horizontal' | 'vertical';
27
+
26
28
  /**
27
29
  * Size is how Stack and its StackItems coordinate the dimensions of the items with the available space.
28
30
  * - `intrinsic` signals to Stack and its StackItems to occupy their intrinsic size
@@ -32,14 +34,6 @@ export type Orientation = 'horizontal' | 'vertical';
32
34
  */
33
35
  export type Size = 'intrinsic' | 'contain' | 'split';
34
36
 
35
- export type StackProps = Omit<ThemedClassName<ComponentPropsWithRef<'div'>>, 'aria-orientation'> &
36
- Partial<StackContextValue> & {
37
- itemsCount?: number;
38
- getDropElement?: (stackElement: HTMLDivElement) => HTMLDivElement;
39
- separatorOnScroll?: number;
40
- circularFocus?: boolean;
41
- };
42
-
43
37
  export const railGridHorizontal = 'grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]';
44
38
  export const railGridVertical = 'grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]';
45
39
 
@@ -61,6 +55,14 @@ const scrollIntoViewAndFocus = (el: HTMLElement, orientation: StackProps['orient
61
55
  return el.focus();
62
56
  };
63
57
 
58
+ export type StackProps = Omit<ThemedClassName<ComponentPropsWithRef<'div'>>, 'aria-orientation'> &
59
+ Partial<StackContextValue> & {
60
+ itemsCount?: number;
61
+ getDropElement?: (stackElement: HTMLDivElement) => HTMLDivElement;
62
+ separatorOnScroll?: number;
63
+ circularFocus?: boolean;
64
+ };
65
+
64
66
  export const Stack = forwardRef<HTMLDivElement, StackProps>(
65
67
  (
66
68
  {
@@ -68,7 +70,7 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
68
70
  classNames,
69
71
  style,
70
72
  orientation = 'vertical',
71
- rail = true,
73
+ rail = true, // TODO(burdon): Change default to false.
72
74
  size = 'intrinsic',
73
75
  onRearrange,
74
76
  itemsCount = Children.count(children),
@@ -121,7 +123,7 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
121
123
  * Handles blur events to track the last focused item within this stack.
122
124
  */
123
125
  const handleBlur = useCallback(
124
- (event: React.FocusEvent<HTMLDivElement>) => {
126
+ (event: FocusEvent<HTMLDivElement>) => {
125
127
  if (event.target) {
126
128
  const target = event.target as HTMLElement;
127
129
  const closestStackItem = target.closest(`[data-dx-item-id]`) as HTMLElement | null;
@@ -135,9 +137,9 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
135
137
  );
136
138
 
137
139
  /**
138
- * Handles moving focus using the arrow keys. Focus is only handled by the nearest stack; if the arrow key matches the
139
- * orientation, focus cycles between items, otherwise focus is passed to an adjacent stack item; or, if there is no
140
- * such stack item, focus is passed to the adjacent empty stack if one can be found.
140
+ * Handles moving focus using the arrow keys. Focus is only handled by the nearest stack;
141
+ * if the arrow key matches the orientation, focus cycles between items, otherwise focus is passed to an adjacent stack item;
142
+ * or, if there is no such stack item, focus is passed to the adjacent empty stack if one can be found.
141
143
  */
142
144
  const handleKeyDown = useCallback(
143
145
  (event: KeyboardEvent<HTMLDivElement>) => {
@@ -193,6 +195,7 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
193
195
  scrollIntoViewAndFocus(adjacentItem, closestStackOrientation);
194
196
  }
195
197
  }
198
+
196
199
  if (perpendicularDelta !== 0) {
197
200
  if (ancestorStack && ancestorOrientation !== closestStackOrientation) {
198
201
  const siblingStacks = Array.from(
@@ -241,12 +244,10 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
241
244
  closestStackOrientation === 'vertical' ? ownedItemRect.top : ownedItemRect.left;
242
245
 
243
246
  let closestDistance = Infinity;
244
-
245
247
  for (const item of adjacentStackItems) {
246
248
  const itemRect = item.getBoundingClientRect();
247
249
  const itemPosition = closestStackOrientation === 'vertical' ? itemRect.top : itemRect.left;
248
250
  const distance = Math.abs(itemPosition - targetPosition);
249
-
250
251
  if (distance < closestDistance) {
251
252
  closestDistance = distance;
252
253
  closestItem = item;
@@ -294,6 +295,7 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
294
295
  if (!rail) {
295
296
  return orientation === 'horizontal' ? 'grid-rows-1 pli-[--stack-gap]' : 'grid-cols-1 plb-[--stack-gap]';
296
297
  }
298
+
297
299
  if (orientation === 'horizontal') {
298
300
  return railGridHorizontal;
299
301
  } else {
@@ -4,8 +4,8 @@
4
4
 
5
5
  import { createContext, useContext } from 'react';
6
6
 
7
- import { type StackItemRearrangeHandler, type StackItemSize } from './defs';
8
7
  import { type Orientation, type Size } from './Stack';
8
+ import { type StackItemRearrangeHandler, type StackItemSize } from './types';
9
9
 
10
10
  export type StackContextValue = {
11
11
  orientation: Orientation;
@@ -12,8 +12,8 @@ import { StackItem, type StackItemRootProps } from './StackItem';
12
12
 
13
13
  const DefaultStory = (props: StackItemRootProps) => {
14
14
  return (
15
- <StackItem.Root role='section' {...props} classNames='w-[20rem] border border-separator'>
16
- <StackItem.Heading>
15
+ <StackItem.Root role='section' {...props} classNames='is-[20rem] border border-separator'>
16
+ <StackItem.Heading classNames='is-full border-be border-separator'>
17
17
  <span className='sr-only'>Title</span>
18
18
  <div role='none' className='sticky -block-start-px bg-[--sticky-bg] p-1 is-full'>
19
19
  <DropdownMenu.Root>
@@ -25,7 +25,9 @@ const DefaultStory = (props: StackItemRootProps) => {
25
25
  </DropdownMenu.Root>
26
26
  </div>
27
27
  </StackItem.Heading>
28
- <StackItem.Content>Content</StackItem.Content>
28
+ <StackItem.Content>
29
+ <div className='p-4 text-center'>Content</div>
30
+ </StackItem.Content>
29
31
  </StackItem.Root>
30
32
  );
31
33
  };
@@ -34,7 +36,7 @@ const meta = {
34
36
  title: 'ui/react-ui-stack/StackItem',
35
37
  component: StackItem.Root as any,
36
38
  render: DefaultStory,
37
- decorators: [withTheme],
39
+ decorators: [withTheme()],
38
40
  parameters: {
39
41
  layout: 'centered',
40
42
  },