@dxos/react-ui-mosaic 0.8.4-main.bc674ce → 0.8.4-main.c85a9c8dae

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 (186) hide show
  1. package/dist/lib/browser/chunk-7S4PIFKU.mjs +953 -0
  2. package/dist/lib/browser/chunk-7S4PIFKU.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +596 -70
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/playwright/index.mjs +138 -0
  7. package/dist/lib/browser/playwright/index.mjs.map +7 -0
  8. package/dist/lib/browser/testing/index.mjs +61 -232
  9. package/dist/lib/browser/testing/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/chunk-MK6KU66S.mjs +955 -0
  11. package/dist/lib/node-esm/chunk-MK6KU66S.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +596 -70
  13. package/dist/lib/node-esm/index.mjs.map +4 -4
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/playwright/index.mjs +140 -0
  16. package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
  17. package/dist/lib/node-esm/testing/index.mjs +61 -232
  18. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  19. package/dist/types/src/components/Board/Board.d.ts +81 -0
  20. package/dist/types/src/components/Board/Board.d.ts.map +1 -0
  21. package/dist/types/src/components/{Mosaic/Mosaic.stories.d.ts → Board/Board.stories.d.ts} +15 -1
  22. package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
  23. package/dist/types/src/components/Board/Column.d.ts +40 -0
  24. package/dist/types/src/components/Board/Column.d.ts.map +1 -0
  25. package/dist/types/src/components/Board/Item.d.ts +9 -0
  26. package/dist/types/src/components/Board/Item.d.ts.map +1 -0
  27. package/dist/types/src/components/Board/index.d.ts +2 -0
  28. package/dist/types/src/components/Board/index.d.ts.map +1 -0
  29. package/dist/types/src/components/Focus/Focus.d.ts +5 -4
  30. package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
  31. package/dist/types/src/components/Focus/index.d.ts +0 -1
  32. package/dist/types/src/components/Focus/index.d.ts.map +1 -1
  33. package/dist/types/src/components/Mosaic/Container.d.ts +42 -0
  34. package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -0
  35. package/dist/types/src/components/Mosaic/Mosaic.d.ts +35 -118
  36. package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
  37. package/dist/types/src/components/Mosaic/Placeholder.d.ts +21 -0
  38. package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -0
  39. package/dist/types/src/components/Mosaic/Root.d.ts +36 -0
  40. package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -0
  41. package/dist/types/src/components/Mosaic/Stack.d.ts +23 -0
  42. package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -0
  43. package/dist/types/src/components/{Stack → Mosaic}/Stack.stories.d.ts +2 -2
  44. package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -0
  45. package/dist/types/src/components/Mosaic/Tile.d.ts +48 -0
  46. package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -0
  47. package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -1
  48. package/dist/types/src/components/Mosaic/types.d.ts +9 -2
  49. package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
  50. package/dist/types/src/components/index.d.ts +1 -4
  51. package/dist/types/src/components/index.d.ts.map +1 -1
  52. package/dist/types/src/hooks/index.d.ts +1 -0
  53. package/dist/types/src/hooks/index.d.ts.map +1 -1
  54. package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts +15 -0
  55. package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -0
  56. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +1 -1
  57. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -1
  58. package/dist/types/src/hooks/useVisibleItems.d.ts +2 -2
  59. package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -1
  60. package/dist/types/src/playwright/board-manager.d.ts +45 -0
  61. package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
  62. package/dist/types/src/playwright/index.d.ts +9 -0
  63. package/dist/types/src/playwright/index.d.ts.map +1 -0
  64. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  65. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  66. package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
  67. package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
  68. package/dist/types/src/testing/CardContainer.d.ts +5 -4
  69. package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
  70. package/dist/types/src/testing/DefaultStackTile.d.ts +2 -2
  71. package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
  72. package/dist/types/src/testing/index.d.ts +1 -1
  73. package/dist/types/src/testing/index.d.ts.map +1 -1
  74. package/dist/types/src/testing/types.d.ts +21 -0
  75. package/dist/types/src/testing/types.d.ts.map +1 -0
  76. package/dist/types/src/translations.d.ts +5 -1
  77. package/dist/types/src/translations.d.ts.map +1 -1
  78. package/dist/types/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +43 -28
  80. package/src/components/Board/Board.stories.tsx +273 -0
  81. package/src/components/Board/Board.tsx +191 -0
  82. package/src/components/Board/Column.tsx +300 -0
  83. package/src/components/Board/Item.tsx +116 -0
  84. package/src/components/{Layout → Board}/index.ts +1 -1
  85. package/src/components/Focus/Focus.tsx +26 -17
  86. package/src/components/Focus/index.ts +0 -2
  87. package/src/components/Mosaic/Container.tsx +289 -0
  88. package/src/components/Mosaic/Mosaic.tsx +35 -913
  89. package/src/components/Mosaic/Placeholder.tsx +133 -0
  90. package/src/components/Mosaic/Root.tsx +292 -0
  91. package/src/components/{Stack → Mosaic}/Stack.stories.tsx +30 -26
  92. package/src/components/Mosaic/Stack.tsx +246 -0
  93. package/src/components/Mosaic/Tile.tsx +242 -0
  94. package/src/components/Mosaic/extension.ts +1 -1
  95. package/src/components/Mosaic/styles.ts +9 -8
  96. package/src/components/Mosaic/types.ts +15 -3
  97. package/src/components/index.ts +1 -4
  98. package/src/hooks/index.ts +1 -0
  99. package/src/hooks/useContainerDebug.tsx +4 -2
  100. package/src/hooks/useDefaultColumnEventHandler.ts +35 -0
  101. package/src/hooks/useEventHandlerAdapter.ts +15 -6
  102. package/src/hooks/useVisibleItems.ts +7 -2
  103. package/src/playwright/board-manager.ts +154 -0
  104. package/src/playwright/index.ts +13 -0
  105. package/src/playwright/playwright.config.ts +17 -0
  106. package/src/playwright/smoke.spec.ts +138 -0
  107. package/src/testing/CardContainer.tsx +30 -18
  108. package/src/testing/DefaultStackTile.tsx +27 -16
  109. package/src/testing/index.ts +1 -1
  110. package/src/testing/types.ts +38 -0
  111. package/src/translations.ts +5 -1
  112. package/dist/lib/browser/chunk-UMBPEG4F.mjs +0 -1637
  113. package/dist/lib/browser/chunk-UMBPEG4F.mjs.map +0 -7
  114. package/dist/lib/browser/index.css +0 -13
  115. package/dist/lib/browser/index.css.map +0 -7
  116. package/dist/lib/browser/testing/index.css +0 -13
  117. package/dist/lib/browser/testing/index.css.map +0 -7
  118. package/dist/lib/node-esm/chunk-X6GV7SMK.mjs +0 -1639
  119. package/dist/lib/node-esm/chunk-X6GV7SMK.mjs.map +0 -7
  120. package/dist/lib/node-esm/index.css +0 -13
  121. package/dist/lib/node-esm/index.css.map +0 -7
  122. package/dist/lib/node-esm/testing/index.css +0 -13
  123. package/dist/lib/node-esm/testing/index.css.map +0 -7
  124. package/dist/types/src/components/Card/Card.d.ts +0 -121
  125. package/dist/types/src/components/Card/Card.d.ts.map +0 -1
  126. package/dist/types/src/components/Card/Card.stories.d.ts +0 -21
  127. package/dist/types/src/components/Card/Card.stories.d.ts.map +0 -1
  128. package/dist/types/src/components/Card/CardDragPreview.d.ts +0 -6
  129. package/dist/types/src/components/Card/CardDragPreview.d.ts.map +0 -1
  130. package/dist/types/src/components/Card/index.d.ts +0 -4
  131. package/dist/types/src/components/Card/index.d.ts.map +0 -1
  132. package/dist/types/src/components/Card/styles.d.ts +0 -13
  133. package/dist/types/src/components/Card/styles.d.ts.map +0 -1
  134. package/dist/types/src/components/Focus/styles.d.ts +0 -6
  135. package/dist/types/src/components/Focus/styles.d.ts.map +0 -1
  136. package/dist/types/src/components/Image/Image.d.ts +0 -14
  137. package/dist/types/src/components/Image/Image.d.ts.map +0 -1
  138. package/dist/types/src/components/Image/Image.stories.d.ts +0 -33
  139. package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
  140. package/dist/types/src/components/Image/index.d.ts +0 -2
  141. package/dist/types/src/components/Image/index.d.ts.map +0 -1
  142. package/dist/types/src/components/Layout/Layout.d.ts +0 -33
  143. package/dist/types/src/components/Layout/Layout.d.ts.map +0 -1
  144. package/dist/types/src/components/Layout/Layout.stories.d.ts +0 -10
  145. package/dist/types/src/components/Layout/Layout.stories.d.ts.map +0 -1
  146. package/dist/types/src/components/Layout/index.d.ts +0 -2
  147. package/dist/types/src/components/Layout/index.d.ts.map +0 -1
  148. package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts.map +0 -1
  149. package/dist/types/src/components/Scrollable/Scrollable.d.ts +0 -24
  150. package/dist/types/src/components/Scrollable/Scrollable.d.ts.map +0 -1
  151. package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts +0 -10
  152. package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts.map +0 -1
  153. package/dist/types/src/components/Scrollable/index.d.ts +0 -2
  154. package/dist/types/src/components/Scrollable/index.d.ts.map +0 -1
  155. package/dist/types/src/components/Stack/Stack.d.ts +0 -22
  156. package/dist/types/src/components/Stack/Stack.d.ts.map +0 -1
  157. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +0 -1
  158. package/dist/types/src/components/Stack/index.d.ts +0 -2
  159. package/dist/types/src/components/Stack/index.d.ts.map +0 -1
  160. package/dist/types/src/testing/Board.d.ts +0 -45
  161. package/dist/types/src/testing/Board.d.ts.map +0 -1
  162. package/dist/types/src/testing/Slot.stories.d.ts +0 -14
  163. package/dist/types/src/testing/Slot.stories.d.ts.map +0 -1
  164. package/dist/types/src/testing/Virtualizer.stories.d.ts +0 -12
  165. package/dist/types/src/testing/Virtualizer.stories.d.ts.map +0 -1
  166. package/src/components/Card/Card.stories.tsx +0 -148
  167. package/src/components/Card/Card.tsx +0 -458
  168. package/src/components/Card/CardDragPreview.tsx +0 -23
  169. package/src/components/Card/index.ts +0 -8
  170. package/src/components/Card/styles.ts +0 -23
  171. package/src/components/Focus/styles.ts +0 -24
  172. package/src/components/Image/Image.stories.tsx +0 -86
  173. package/src/components/Image/Image.tsx +0 -223
  174. package/src/components/Image/index.ts +0 -5
  175. package/src/components/Layout/Layout.stories.tsx +0 -59
  176. package/src/components/Layout/Layout.tsx +0 -108
  177. package/src/components/Mosaic/Mosaic.stories.tsx +0 -113
  178. package/src/components/Scrollable/Scrollable.stories.tsx +0 -59
  179. package/src/components/Scrollable/Scrollable.tsx +0 -88
  180. package/src/components/Scrollable/index.ts +0 -5
  181. package/src/components/Scrollable/scrollable.css +0 -20
  182. package/src/components/Stack/Stack.tsx +0 -210
  183. package/src/components/Stack/index.ts +0 -5
  184. package/src/testing/Board.tsx +0 -278
  185. package/src/testing/Slot.stories.tsx +0 -101
  186. package/src/testing/Virtualizer.stories.tsx +0 -133
@@ -1,458 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Slot } from '@radix-ui/react-slot';
6
- import React, {
7
- type ComponentPropsWithoutRef,
8
- type HTMLAttributes,
9
- type PropsWithChildren,
10
- createContext,
11
- forwardRef,
12
- useContext,
13
- } from 'react';
14
-
15
- import {
16
- Button,
17
- type Density,
18
- DropdownMenu,
19
- Icon,
20
- type IconProps,
21
- type ThemedClassName,
22
- Toolbar,
23
- type ToolbarRootProps,
24
- useTranslation,
25
- } from '@dxos/react-ui';
26
- import { mx } from '@dxos/ui-theme';
27
-
28
- import { translationKey } from '../../translations';
29
- import { Image } from '../Image';
30
-
31
- import { styles } from './styles';
32
-
33
- type CardSharedProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> & {
34
- asChild?: boolean;
35
- className?: string;
36
- };
37
-
38
- //
39
- // Context
40
- //
41
-
42
- type CardContextValue = {
43
- menuItems?: CardMenuItem<any>[];
44
- };
45
-
46
- /** @deprecated Create context for menus. */
47
- const CardContext = createContext<CardContextValue>({});
48
-
49
- //
50
- // Root
51
- //
52
-
53
- type CardRootProps = CardSharedProps & {
54
- id?: string;
55
- border?: boolean;
56
- fullWidth?: boolean;
57
- };
58
-
59
- const CardRoot = forwardRef<HTMLDivElement, CardRootProps>(
60
- (
61
- { children, classNames, className, id, asChild, role = 'group', border = true, fullWidth, ...props },
62
- forwardedRef,
63
- ) => {
64
- const Root = asChild ? Slot : 'div';
65
-
66
- return (
67
- <Root
68
- {...(id && { 'data-object-id': id })}
69
- {...props}
70
- role={role}
71
- className={mx(styles.root, border && styles.border, fullWidth && '!max-is-none', className, classNames)}
72
- ref={forwardedRef}
73
- >
74
- {children}
75
- </Root>
76
- );
77
- },
78
- );
79
-
80
- //
81
- // Toolbar
82
- //
83
-
84
- type CardToolbarProps = ToolbarRootProps & {
85
- // TODO(burdon): Generalize: 1. systematic across theme; 2. should affect rows, etc.
86
- density?: Density;
87
- };
88
-
89
- const CardToolbar = forwardRef<HTMLDivElement, CardToolbarProps>(
90
- ({ children, classNames, density = 'fine', ...props }, forwardedRef) => {
91
- return (
92
- <Toolbar.Root
93
- {...props}
94
- classNames={[
95
- 'density-fine bg-transparent',
96
- density === 'fine' ? styles.grid_3 : styles.grid_3_coarse,
97
- classNames,
98
- ]}
99
- ref={forwardedRef}
100
- >
101
- {children}
102
- </Toolbar.Root>
103
- );
104
- },
105
- );
106
-
107
- const CardToolbarIconButton = Toolbar.IconButton;
108
- const CardToolbarSeparator = Toolbar.Separator;
109
-
110
- //
111
- // DragHandle
112
- //
113
-
114
- type CardDragHandleProps = {};
115
-
116
- const CardDragHandle = forwardRef<HTMLButtonElement, CardDragHandleProps>((_, forwardedRef) => {
117
- const { t } = useTranslation(translationKey);
118
-
119
- return (
120
- <Toolbar.IconButton
121
- data-testid='card-drag-handle'
122
- noTooltip
123
- iconOnly
124
- icon='ph--dots-six-vertical--regular'
125
- variant='ghost'
126
- label={t('drag handle label')}
127
- classNames='cursor-pointer'
128
- size={5}
129
- disabled={!forwardedRef}
130
- ref={forwardedRef}
131
- />
132
- );
133
- });
134
-
135
- //
136
- // Close
137
- //
138
-
139
- type CardCloseProps = { onClick?: () => void };
140
-
141
- const CardClose = forwardRef<HTMLButtonElement, CardCloseProps>(({ onClick }, forwardedRef) => {
142
- const { t } = useTranslation(translationKey);
143
-
144
- return (
145
- <Toolbar.IconButton
146
- iconOnly
147
- icon='ph--x--regular'
148
- variant='ghost'
149
- label={t('card close label')}
150
- classNames='cursor-pointer'
151
- size={5}
152
- onClick={onClick}
153
- ref={forwardedRef}
154
- />
155
- );
156
- });
157
-
158
- //
159
- // Menu
160
- //
161
-
162
- type CardMenuItem<T extends any | void = void> = {
163
- label: string;
164
- onClick: (context: T) => void;
165
- };
166
-
167
- type CardMenuProps<T extends any | void = void> = {
168
- context?: T;
169
- items?: CardMenuItem<T>[];
170
- };
171
-
172
- const CardMenu = <T extends any | void = void>({ context, items }: CardMenuProps<T>) => {
173
- const { t } = useTranslation(translationKey);
174
- const { menuItems } = useContext(CardContext) ?? {};
175
- const combinedItems = [...(items ?? []), ...((menuItems as CardMenuItem<T>[]) ?? [])];
176
-
177
- return (
178
- <DropdownMenu.Root>
179
- <DropdownMenu.Trigger disabled={!combinedItems.length} asChild>
180
- <Card.ToolbarIconButton
181
- iconOnly
182
- variant='ghost'
183
- icon='ph--dots-three-vertical--regular'
184
- label={t('action menu label')}
185
- />
186
- </DropdownMenu.Trigger>
187
- {(combinedItems?.length ?? 0) > 0 && (
188
- <DropdownMenu.Portal>
189
- <DropdownMenu.Content>
190
- <DropdownMenu.Viewport>
191
- {combinedItems?.map(({ label, onClick: onSelect }, i) => (
192
- <DropdownMenu.Item key={i} onSelect={() => onSelect(context as T)}>
193
- {label}
194
- </DropdownMenu.Item>
195
- ))}
196
- </DropdownMenu.Viewport>
197
- <DropdownMenu.Arrow />
198
- </DropdownMenu.Content>
199
- </DropdownMenu.Portal>
200
- )}
201
- </DropdownMenu.Root>
202
- );
203
- };
204
-
205
- //
206
- // Title
207
- //
208
-
209
- type CardTitleProps = CardSharedProps;
210
-
211
- const CardTitle = forwardRef<HTMLDivElement, CardTitleProps>(
212
- ({ children, classNames, className, asChild, role = 'heading', ...props }, forwardedRef) => {
213
- const Root = asChild ? Slot : 'div';
214
-
215
- return (
216
- <Root {...props} role={role} className={mx('grow truncate', classNames, className)} ref={forwardedRef}>
217
- {children}
218
- </Root>
219
- );
220
- },
221
- );
222
-
223
- //
224
- // Content
225
- // TODO(burdon): Root for card--content role (possibly multiple).
226
- // - Able to add menu options/set title, etc. via context.
227
- // TODO(burdon): Consider collapsible sections (surfaces).
228
- //
229
-
230
- type CardContentProps = PropsWithChildren;
231
-
232
- const CardContent = forwardRef<HTMLDivElement, CardContentProps>(({ children, ...props }, forwardedRef) => {
233
- return (
234
- <div role='none' className='contents [&>:last-child]:pbe-1' {...props} ref={forwardedRef}>
235
- {children}
236
- </div>
237
- );
238
- });
239
-
240
- //
241
- // Row
242
- //
243
-
244
- type CardRowProps = CardSharedProps & { icon?: string };
245
-
246
- const CardRow = forwardRef<HTMLDivElement, CardRowProps>(
247
- ({ children, classNames, className, role = 'none', icon, ...props }, forwardedRef) => {
248
- return (
249
- <div {...props} role={role} className={mx(styles.grid_2, 'pli-1', classNames, className)} ref={forwardedRef}>
250
- {(icon && <CardIcon classNames='text-subdued' icon={icon} />) || <div />}
251
- {children}
252
- </div>
253
- );
254
- },
255
- );
256
-
257
- //
258
- // Heading
259
- //
260
-
261
- type CardHeadingProps = CardSharedProps & { variant?: 'default' | 'subtitle' };
262
-
263
- const CardHeading = forwardRef<HTMLDivElement, CardHeadingProps>(
264
- ({ children, classNames, className, asChild, role = 'heading', variant = 'default', ...props }, forwardedRef) => {
265
- const Root = asChild ? Slot : 'div';
266
- // NOTE: Padding align first line of text with center of icon.
267
- const variantClassNames: Record<string, string> = {
268
- default: 'plb-1',
269
- subtitle: 'plb-2 text-xs text-description font-medium uppercase',
270
- };
271
-
272
- return (
273
- <Root {...props} role={role} className={mx(variantClassNames[variant], classNames, className)} ref={forwardedRef}>
274
- {children}
275
- </Root>
276
- );
277
- },
278
- );
279
-
280
- //
281
- // Text
282
- //
283
-
284
- type CardTextProps = CardSharedProps & { truncate?: boolean; variant?: 'default' | 'description' };
285
-
286
- const CardText = forwardRef<HTMLDivElement, CardTextProps>(
287
- (
288
- { children, classNames, className, asChild, role = 'none', truncate, variant = 'default', ...props },
289
- forwardedRef,
290
- ) => {
291
- const Root = asChild ? Slot : 'div';
292
- // NOTE: Padding align first line of text with center of icon.
293
- const variantClassNames: Record<string, { root: string; span?: string }> = {
294
- default: {
295
- root: 'plb-1',
296
- },
297
- description: {
298
- root: 'plb-1.5',
299
- span: 'text-sm text-description line-clamp-3',
300
- },
301
- };
302
-
303
- return (
304
- <Root
305
- {...props}
306
- role={role}
307
- className={mx('flex overflow-hidden', variantClassNames[variant].root, classNames, className)}
308
- ref={forwardedRef}
309
- >
310
- <span className={mx(variantClassNames[variant].span, truncate && 'truncate')}>{children}</span>
311
- </Root>
312
- );
313
- },
314
- );
315
-
316
- //
317
- // Poster
318
- //
319
-
320
- type CardPosterProps = ThemedClassName<
321
- {
322
- alt: string;
323
- aspect?: 'video' | 'auto';
324
- } & Partial<{ image: string; icon: string }>
325
- >;
326
-
327
- const CardPoster = (props: CardPosterProps) => {
328
- const aspect = props.aspect === 'auto' ? 'aspect-auto' : 'aspect-video';
329
- if (props.image) {
330
- return (
331
- <div role='none' className='mbe-1'>
332
- <Image classNames={[styles.poster, aspect, props.classNames]} src={props.image} alt={props.alt} />
333
- </div>
334
- );
335
- }
336
-
337
- if (props.icon) {
338
- return (
339
- <div
340
- role='image'
341
- className={mx('grid place-items-center bg-inputSurface text-subdued', styles.poster, aspect, props.classNames)}
342
- aria-label={props.alt}
343
- >
344
- <Icon icon={props.icon} size={10} />
345
- </div>
346
- );
347
- }
348
- };
349
-
350
- //
351
- // Action
352
- //
353
-
354
- type CardActionProps = { icon?: string; label: string; actionIcon?: string; onClick?: () => void };
355
-
356
- const CardAction = ({ icon, actionIcon = 'ph--arrow-right--regular', label, onClick }: CardActionProps) => {
357
- return (
358
- <div role='none' className='is-full pli-1'>
359
- <Button
360
- variant='ghost'
361
- classNames={mx(styles.grid_3, '!p-0 is-full text-start overflow-hidden')}
362
- onClick={onClick}
363
- >
364
- {icon ? <CardIcon classNames='text-subdued' icon={icon} /> : <div />}
365
- <span className={mx('min-is-0 flex-1 truncate', !actionIcon && 'col-span-2')}>{label}</span>
366
- {actionIcon && <CardIcon icon={actionIcon} />}
367
- </Button>
368
- </div>
369
- );
370
- };
371
-
372
- //
373
- // Link
374
- //
375
-
376
- type CardLinkProps = { label: string; href: string };
377
-
378
- const CardLink = ({ label, href }: CardLinkProps) => {
379
- return (
380
- <div role='none' className='is-full pli-1'>
381
- <a
382
- className={mx(styles.grid_3, 'group !p-0 dx-button dx-focus-ring !min-bs-1')}
383
- data-variant='ghost'
384
- href={href}
385
- target='_blank'
386
- rel='noreferrer'
387
- >
388
- <CardIcon classNames='text-subdued' icon='ph--link--regular' />
389
- <span className={mx('min-is-0 flex-1 truncate')}>{label}</span>
390
- <CardIcon classNames='invisible group-hover:visible' icon='ph--arrow-square-out--regular' />
391
- </a>
392
- </div>
393
- );
394
- };
395
-
396
- //
397
- // IconBlock
398
- //
399
-
400
- const CardIconBlock = ({
401
- classNames,
402
- children,
403
- role = 'none',
404
- ...props
405
- }: ThemedClassName<PropsWithChildren<HTMLAttributes<HTMLDivElement>>>) => {
406
- return (
407
- <div
408
- {...props}
409
- role={role}
410
- className={mx('grid bs-[var(--rail-item)] is-[var(--rail-item)] place-items-center', classNames)}
411
- >
412
- {children}
413
- </div>
414
- );
415
- };
416
-
417
- //
418
- // Icon
419
- //
420
-
421
- const CardIcon = ({ toolbar, ...props }: IconProps & { toolbar?: boolean }) => {
422
- return (
423
- <CardIconBlock>
424
- <Icon {...props} size={toolbar ? 5 : 4} />
425
- </CardIconBlock>
426
- );
427
- };
428
-
429
- //
430
- // Card
431
- //
432
-
433
- export const Card = {
434
- Context: CardContext,
435
- Root: CardRoot,
436
-
437
- // Toolbar
438
- Toolbar: CardToolbar,
439
- ToolbarIconButton: CardToolbarIconButton,
440
- ToolbarSeparator: CardToolbarSeparator,
441
- DragHandle: CardDragHandle,
442
- Title: CardTitle,
443
- Close: CardClose,
444
- Menu: CardMenu,
445
- Icon: CardIcon,
446
- IconBlock: CardIconBlock,
447
-
448
- // Content
449
- Content: CardContent,
450
- Row: CardRow,
451
- Heading: CardHeading,
452
- Text: CardText,
453
- Poster: CardPoster,
454
- Action: CardAction,
455
- Link: CardLink,
456
- };
457
-
458
- export type { CardContextValue, CardRootProps, CardToolbarProps, CardMenuProps };
@@ -1,23 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { type PropsWithChildren } from 'react';
6
-
7
- import { mx } from '@dxos/ui-theme';
8
-
9
- import { styles } from './styles';
10
-
11
- // TODO(burdon): Why p-2?
12
- const CardDragPreviewRoot = ({ children }: PropsWithChildren<{}>) => {
13
- return <div className='p-2'>{children}</div>;
14
- };
15
-
16
- const CardDragPreviewContent = ({ children }: PropsWithChildren<{}>) => {
17
- return <div className={mx(styles.root, 'ring-focusLine ring-neutralFocusIndicator')}>{children}</div>;
18
- };
19
-
20
- export const CardDragPreview = {
21
- Root: CardDragPreviewRoot,
22
- Content: CardDragPreviewContent,
23
- };
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export { styles as cardStyles } from './styles';
6
-
7
- export * from './Card';
8
- export * from './CardDragPreview';
@@ -1,23 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type ClassNameValue } from '@dxos/react-ui';
6
-
7
- export const styles = {
8
- root: 'group/card relative min-bs-[--rail-item] overflow-hidden is-full card-min-width __card-max-width',
9
- border:
10
- 'bg-cardSurface border border-separator dark:border-subduedSeparator rounded-sm dx-focus-ring-group-y-indicator',
11
-
12
- /**
13
- * Row grid.
14
- * NOTE: Rows should provide their own line padding (since they may need to encapsulate buttons, etc.)
15
- */
16
- grid_3: 'grid grid-cols-[var(--rail-item)_minmax(0,1fr)_var(--rail-item)] gap-x-1',
17
- grid_2: 'grid grid-cols-[var(--rail-item)_minmax(0,1fr)] gap-x-1',
18
-
19
- // TODO(burdon): Address density.
20
- grid_3_coarse: 'grid grid-cols-[var(--l0-avatar-size)_minmax(0,1fr)_var(--rail-item)] gap-x-1',
21
-
22
- poster: 'max-bs-[200px]',
23
- } satisfies Record<string, ClassNameValue>;
@@ -1,24 +0,0 @@
1
- //
2
- // Copyright 2026 DXOS.org
3
- //
4
-
5
- import { type ClassNameValue } from '@dxos/react-ui';
6
-
7
- // TODO(burdon): Theme?
8
- export const styles = {
9
- container: {
10
- // TODO(burdon): Handle selection (aria-current?)
11
- // TODO(burdon): Use ring instead of border?
12
- root: [
13
- 'outline-none border border-separator rounded-sm',
14
- // Focus (e.g., via tabster).
15
- // TODO(burdon): Why is ! required?
16
- 'focus:!border-accentSurface',
17
- // Active (e.g., drop target).
18
- 'data-[focus-state=active]:border-neutralFocusIndicator',
19
- // Error
20
- // TODO(burdon): Error token.
21
- 'data-[focus-state=error]:border-rose-500',
22
- ],
23
- },
24
- } satisfies Record<string, Record<string, ClassNameValue>>;
@@ -1,86 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useMemo } from 'react';
7
-
8
- import { faker } from '@dxos/random';
9
- import { withTheme } from '@dxos/react-ui/testing';
10
-
11
- import { Image } from './Image';
12
-
13
- const seed = Math.random();
14
-
15
- faker.seed(seed);
16
-
17
- const meta = {
18
- title: 'ui/react-ui-mosaic/Image',
19
- component: Image,
20
- render: (args) => (
21
- <div className='absolute inset-0 flex justify-center items-center'>
22
- <Image {...args} />
23
- </div>
24
- ),
25
- decorators: [withTheme],
26
- parameters: {
27
- layout: 'centered',
28
- },
29
- } satisfies Meta<typeof Image>;
30
-
31
- export default meta;
32
-
33
- type Story = StoryObj<typeof meta>;
34
-
35
- export const Default: Story = {
36
- args: {
37
- src: faker.image.url(),
38
- },
39
- };
40
-
41
- const classNames = 'bs-[12rem] is-[18rem]';
42
-
43
- /**
44
- * Access to image at 'https://dxos.network/dxos-logotype-blue.png'
45
- * from origin 'http://localhost:9009' has been blocked by CORS policy:
46
- * No 'Access-Control-Allow-Origin' header is present on the requested resource.
47
- */
48
- export const Cors: Story = {
49
- args: {
50
- src: 'https://dxos.network/dxos-logotype-blue.png',
51
- classNames,
52
- },
53
- };
54
-
55
- export const Corners: Story = {
56
- args: {
57
- src: 'https://picsum.photos/seed/picsum/200/200',
58
- classNames,
59
- },
60
- };
61
-
62
- export const SVG: Story = {
63
- args: {
64
- src: 'https://dxos.network/bg-kube.svg',
65
- classNames,
66
- },
67
- };
68
-
69
- export const Many: Story = {
70
- args: {
71
- src: 'https://dxos.network/bg-kube.svg',
72
- },
73
- render: () => {
74
- const images = useMemo(
75
- () => Array.from({ length: 9 }, (_, i) => `https://picsum.photos/seed/${seed + i}/500/500`),
76
- [],
77
- );
78
- return (
79
- <div className='is-[60rem] grid grid-cols-3 grid-rows-3 gap-8'>
80
- {images.map((src, i) => (
81
- <Image key={i} src={src} classNames={classNames} />
82
- ))}
83
- </div>
84
- );
85
- },
86
- };