@dxos/react-ui-stack 0.6.14-staging.934c9de → 0.6.14-staging.9b873ce

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 (91) hide show
  1. package/dist/lib/browser/index.mjs +494 -335
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/testing/index.mjs +3 -6
  5. package/dist/lib/browser/testing/index.mjs.map +3 -3
  6. package/dist/lib/node/index.cjs +478 -326
  7. package/dist/lib/node/index.cjs.map +4 -4
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/testing/index.cjs +3 -6
  10. package/dist/lib/node/testing/index.cjs.map +3 -3
  11. package/dist/lib/node-esm/index.mjs +494 -335
  12. package/dist/lib/node-esm/index.mjs.map +4 -4
  13. package/dist/lib/node-esm/meta.json +1 -1
  14. package/dist/lib/node-esm/testing/index.mjs +3 -6
  15. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  16. package/dist/types/src/components/LayoutControls.d.ts +19 -0
  17. package/dist/types/src/components/LayoutControls.d.ts.map +1 -0
  18. package/dist/types/src/components/MenuSignifier.d.ts +4 -0
  19. package/dist/types/src/components/MenuSignifier.d.ts.map +1 -0
  20. package/dist/types/src/components/Stack.d.ts +12 -12
  21. package/dist/types/src/components/Stack.d.ts.map +1 -1
  22. package/dist/types/src/components/Stack.stories.d.ts +6 -83
  23. package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/StackContext.d.ts +19 -0
  25. package/dist/types/src/components/StackContext.d.ts.map +1 -0
  26. package/dist/types/src/components/StackItem.d.ts +41 -0
  27. package/dist/types/src/components/StackItem.d.ts.map +1 -0
  28. package/dist/types/src/components/StackItemContent.d.ts +9 -0
  29. package/dist/types/src/components/StackItemContent.d.ts.map +1 -0
  30. package/dist/types/src/components/StackItemHeading.d.ts +8 -0
  31. package/dist/types/src/components/StackItemHeading.d.ts.map +1 -0
  32. package/dist/types/src/components/StackItemResizeHandle.d.ts +3 -0
  33. package/dist/types/src/components/StackItemResizeHandle.d.ts.map +1 -0
  34. package/dist/types/src/components/StackItemSigil.d.ts +31 -0
  35. package/dist/types/src/components/StackItemSigil.d.ts.map +1 -0
  36. package/dist/types/src/components/index.d.ts +2 -1
  37. package/dist/types/src/components/index.d.ts.map +1 -1
  38. package/dist/types/src/testing/EditorContent.d.ts +2 -2
  39. package/dist/types/src/testing/EditorContent.d.ts.map +1 -1
  40. package/dist/types/src/testing/stack-manager.d.ts +0 -1
  41. package/dist/types/src/testing/stack-manager.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +8 -8
  43. package/package.json +19 -20
  44. package/src/components/LayoutControls.tsx +131 -0
  45. package/src/components/MenuSignifier.tsx +33 -0
  46. package/src/components/Stack.stories.tsx +109 -182
  47. package/src/components/Stack.tsx +61 -156
  48. package/src/components/StackContext.tsx +38 -0
  49. package/src/components/StackItem.tsx +173 -0
  50. package/src/components/StackItemContent.tsx +49 -0
  51. package/src/components/StackItemHeading.tsx +55 -0
  52. package/src/components/StackItemResizeHandle.tsx +115 -0
  53. package/src/components/StackItemSigil.tsx +170 -0
  54. package/src/components/index.ts +3 -2
  55. package/src/playwright/smoke.spec.ts +3 -3
  56. package/src/testing/EditorContent.tsx +4 -4
  57. package/src/testing/stack-manager.ts +3 -7
  58. package/src/translations.ts +8 -8
  59. package/dist/types/src/components/CaretDownUp.d.ts +0 -4
  60. package/dist/types/src/components/CaretDownUp.d.ts.map +0 -1
  61. package/dist/types/src/components/ContentTypes.stories.d.ts +0 -96
  62. package/dist/types/src/components/ContentTypes.stories.d.ts.map +0 -1
  63. package/dist/types/src/components/Deck.stories.d.ts +0 -19
  64. package/dist/types/src/components/Deck.stories.d.ts.map +0 -1
  65. package/dist/types/src/components/Section.d.ts +0 -53
  66. package/dist/types/src/components/Section.d.ts.map +0 -1
  67. package/dist/types/src/components/Section.stories.d.ts +0 -36
  68. package/dist/types/src/components/Section.stories.d.ts.map +0 -1
  69. package/dist/types/src/components/style-fragments.d.ts +0 -2
  70. package/dist/types/src/components/style-fragments.d.ts.map +0 -1
  71. package/dist/types/src/next/Stack.d.ts +0 -9
  72. package/dist/types/src/next/Stack.d.ts.map +0 -1
  73. package/dist/types/src/next/Stack.stories.d.ts +0 -8
  74. package/dist/types/src/next/Stack.stories.d.ts.map +0 -1
  75. package/dist/types/src/next/StackItem.d.ts +0 -14
  76. package/dist/types/src/next/StackItem.d.ts.map +0 -1
  77. package/dist/types/src/next/index.d.ts +0 -2
  78. package/dist/types/src/next/index.d.ts.map +0 -1
  79. package/dist/types/src/testing/TableContent.d.ts +0 -20
  80. package/dist/types/src/testing/TableContent.d.ts.map +0 -1
  81. package/src/components/CaretDownUp.tsx +0 -31
  82. package/src/components/ContentTypes.stories.tsx +0 -104
  83. package/src/components/Deck.stories.tsx +0 -362
  84. package/src/components/Section.stories.tsx +0 -50
  85. package/src/components/Section.tsx +0 -378
  86. package/src/components/style-fragments.ts +0 -5
  87. package/src/next/Stack.stories.tsx +0 -148
  88. package/src/next/Stack.tsx +0 -30
  89. package/src/next/StackItem.tsx +0 -78
  90. package/src/next/index.ts +0 -5
  91. package/src/testing/TableContent.tsx +0 -119
@@ -1,362 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { CaretLeft, CaretLineLeft, CaretLineRight, CaretRight, SidebarSimple, X } from '@phosphor-icons/react';
8
- import React, { type PropsWithChildren, useState, type ComponentProps } from 'react';
9
-
10
- import { faker } from '@dxos/random';
11
- import { Button, Icon, Main } from '@dxos/react-ui';
12
- import { RootAttentionProvider } from '@dxos/react-ui-attention';
13
- import { PlankHeading, Deck as NaturalDeck, Plank } from '@dxos/react-ui-deck';
14
- import { Mosaic, type MosaicDataItem } from '@dxos/react-ui-mosaic';
15
- import { withTheme } from '@dxos/storybook-utils';
16
- import { arrayMove } from '@dxos/util';
17
-
18
- import { SectionToolbar, type StackSectionItem } from './Section';
19
- import { Stack } from './Stack';
20
-
21
- faker.seed(3);
22
-
23
- const Toolbar = () => {
24
- return (
25
- <SectionToolbar classNames='flex items-center gap-2'>
26
- <p>File</p>
27
- <p>Edit</p>
28
- <p>View</p>
29
- </SectionToolbar>
30
- );
31
- };
32
-
33
- const SimpleContent = ({ data }: { data: MosaicDataItem & { title?: string; body?: string } }) => (
34
- <>
35
- <Toolbar />
36
- <div className='text-xl mlb-2'>{data.title}</div>
37
- <p>{data.body}</p>
38
- </>
39
- );
40
-
41
- const rollItems = (n: number): StackSectionItem[] => {
42
- return [...Array(n)].map(() => ({
43
- id: faker.string.uuid(),
44
- icon: 'ph--text-aa--regular',
45
- isResizable: true,
46
- object: {
47
- id: faker.string.uuid(),
48
- title: faker.lorem.words(3),
49
- body: faker.lorem.paragraph(),
50
- },
51
- }));
52
- };
53
-
54
- type PlankProps = { items: StackSectionItem[]; label: string; id: string };
55
-
56
- const rollStackPlank = (n: number): PlankProps => ({
57
- items: rollItems(n),
58
- id: faker.string.uuid(),
59
- label: faker.lorem.words(3),
60
- });
61
-
62
- const StackPlank = ({ label, items, id, children }: PropsWithChildren<PlankProps>) => {
63
- return (
64
- <>
65
- <PlankHeading.Root classNames='pli-px'>
66
- <PlankHeading.Button>
67
- <Icon icon='ph--cards-three--regular' size={5} />
68
- </PlankHeading.Button>
69
- <PlankHeading.Label classNames='flex-1 truncate'>{label}</PlankHeading.Label>
70
- {children}
71
- </PlankHeading.Root>
72
- <Stack
73
- items={items}
74
- SectionContent={SimpleContent}
75
- id={id}
76
- classNames='p-px overflow-y-auto row-end-[content-end] row-start-[toolbar-start] mbs-0 mbe-0'
77
- />
78
- </>
79
- );
80
- };
81
-
82
- const DemoStackPlank = (rootProps: Partial<ComponentProps<typeof Plank.Root>>) => {
83
- const [props] = useState(rollStackPlank(12));
84
- return (
85
- <Plank.Root {...rootProps}>
86
- <Plank.Content>
87
- <StackPlank {...props} />
88
- </Plank.Content>
89
- <Plank.ResizeHandle />
90
- </Plank.Root>
91
- );
92
- };
93
-
94
- export default {
95
- // NOTE(thure): This is intentionally organized under `react-ui-deck` so that related stories appear together in Storybook despite needing to live in separate packages based on dependencies.
96
- title: 'ui/react-ui-deck/Deck',
97
- component: NaturalDeck.Root,
98
- decorators: [withTheme],
99
- args: {},
100
- };
101
-
102
- export const StaticBasicStacks = {
103
- args: {},
104
- render: () => {
105
- return (
106
- <Mosaic.Root>
107
- <RootAttentionProvider>
108
- <Mosaic.DragOverlay />
109
- <NaturalDeck.Root classNames='fixed inset-0 z-0'>
110
- <DemoStackPlank />
111
- <DemoStackPlank />
112
- <DemoStackPlank />
113
- <DemoStackPlank />
114
- <DemoStackPlank />
115
- <DemoStackPlank />
116
- <DemoStackPlank />
117
- </NaturalDeck.Root>
118
- </RootAttentionProvider>
119
- </Mosaic.Root>
120
- );
121
- },
122
- };
123
-
124
- export const StaticBasicStacksWithOverscrolling = {
125
- args: {},
126
- render: () => {
127
- return (
128
- <Mosaic.Root>
129
- <RootAttentionProvider>
130
- <Mosaic.DragOverlay />
131
- <NaturalDeck.Root classNames='fixed inset-0 z-0'>
132
- <DemoStackPlank />
133
- <DemoStackPlank />
134
- <DemoStackPlank />
135
- <DemoStackPlank />
136
- <DemoStackPlank />
137
- <DemoStackPlank />
138
- <DemoStackPlank />
139
- </NaturalDeck.Root>
140
- </RootAttentionProvider>
141
- </Mosaic.Root>
142
- );
143
- },
144
- };
145
-
146
- const IncrementButtons = ({
147
- index,
148
- setOpenPlanks,
149
- openPlanks,
150
- }: {
151
- index: number;
152
- openPlanks: string[];
153
- setOpenPlanks: (setter: (prevOpenPlanksSet: Set<string>) => Set<string>) => void;
154
- }) => {
155
- return (
156
- <>
157
- <Button
158
- disabled={index < 1}
159
- variant='ghost'
160
- classNames='p-1'
161
- onClick={() =>
162
- setOpenPlanks((prev: Set<string>) => {
163
- return new Set([...arrayMove(openPlanks, index, index - 1), ...Array.from(prev)]);
164
- })
165
- }
166
- >
167
- <CaretLeft />
168
- </Button>
169
- <Button
170
- disabled={index > openPlanks.length - 2}
171
- variant='ghost'
172
- classNames='p-1'
173
- onClick={() =>
174
- setOpenPlanks((prev) => {
175
- return new Set([...arrayMove(openPlanks, index, index + 1), ...Array.from(prev)]);
176
- })
177
- }
178
- >
179
- <CaretRight />
180
- </Button>
181
- </>
182
- );
183
- };
184
-
185
- const MENU = 'menu';
186
-
187
- export const DynamicBasicStacks = () => {
188
- const [planks] = useState(
189
- [...Array(12)]
190
- .map(() => rollStackPlank(12))
191
- .reduce((acc: Record<string, PlankProps>, plank) => {
192
- acc[plank.id] = plank;
193
- return acc;
194
- }, {}),
195
- );
196
-
197
- const [navOpen, setNavOpen] = useState(true);
198
- const [c11yOpen, setC11yOpen] = useState(false);
199
-
200
- const [navContent, setDirectNavContent] = useState<string | null>(MENU);
201
- const [c11yContent, setDirectC11yContent] = useState<string | null>(null);
202
-
203
- const [openPlanksSet, setDirectOpenPlanks] = useState<Set<string>>(new Set([MENU]));
204
- const openPlanks = Array.from(openPlanksSet);
205
- const openPlanksInDeck = openPlanks.filter((id) => ![navContent, c11yContent].includes(id));
206
-
207
- const setNavContent = (nextContent: string | null) => {
208
- setDirectNavContent(nextContent);
209
- setNavOpen(!!nextContent);
210
- };
211
-
212
- const setC11yContent = (nextContent: string | null) => {
213
- setDirectC11yContent(nextContent);
214
- setC11yOpen(!!nextContent);
215
- };
216
-
217
- const setOpenPlanks = (setter: (prevOpenPlanksSet: Set<string>) => Set<string>) => {
218
- const nextOpenPlanksSet = setter(openPlanksSet);
219
- setDirectOpenPlanks(nextOpenPlanksSet);
220
- if (navContent && !nextOpenPlanksSet.has(navContent)) {
221
- setNavContent(null);
222
- }
223
- if (c11yContent && !nextOpenPlanksSet.has(c11yContent)) {
224
- setC11yContent(null);
225
- }
226
- };
227
-
228
- console.log('[open planks]', openPlanksInDeck, openPlanksSet);
229
-
230
- const menuChildren = (
231
- <>
232
- <PlankHeading.Root classNames='pli-px'>
233
- <PlankHeading.Button>
234
- <Icon icon='ph--books--regular' size={5} />
235
- </PlankHeading.Button>
236
- <PlankHeading.Label classNames='grow'>Menu</PlankHeading.Label>
237
- {c11yContent === MENU ? (
238
- <Button variant='ghost' classNames='p-1' onClick={() => setC11yContent(null)}>
239
- <CaretLineLeft />
240
- </Button>
241
- ) : navContent === MENU ? (
242
- <Button variant='ghost' classNames='p-1' onClick={() => setNavContent(null)}>
243
- <CaretLineRight />
244
- </Button>
245
- ) : (
246
- <>
247
- <Button variant='ghost' classNames='p-1' onClick={() => setNavContent(MENU)}>
248
- <CaretLineLeft />
249
- </Button>
250
- <IncrementButtons
251
- openPlanks={openPlanksInDeck}
252
- index={openPlanksInDeck.indexOf(MENU)}
253
- setOpenPlanks={setOpenPlanks}
254
- />
255
- <Button variant='ghost' classNames='p-1' onClick={() => setC11yContent(MENU)}>
256
- <CaretLineRight />
257
- </Button>
258
- </>
259
- )}
260
- </PlankHeading.Root>
261
- <div role='none' className='p-1'>
262
- {Object.values(planks).map(({ label, id }) => {
263
- return (
264
- <Button
265
- key={id}
266
- variant={openPlanksSet.has(id) ? 'primary' : 'default'}
267
- classNames='truncate is-full block mlb-2'
268
- onClick={() =>
269
- setOpenPlanks((prev) => {
270
- prev.has(id) ? prev.delete(id) : prev.add(id);
271
- return new Set(Array.from(prev));
272
- })
273
- }
274
- >
275
- {label}
276
- </Button>
277
- );
278
- })}
279
- </div>
280
- </>
281
- );
282
-
283
- return (
284
- <Mosaic.Root>
285
- <RootAttentionProvider>
286
- <Main.Root complementarySidebarOpen={c11yOpen} navigationSidebarOpen={navOpen}>
287
- <Main.Overlay />
288
- <Mosaic.DragOverlay />
289
- <Main.Notch>
290
- <Button variant='ghost' classNames='p-1' onClick={() => setNavOpen(!navOpen)}>
291
- <SidebarSimple />
292
- </Button>
293
- <Button variant='ghost' classNames='p-1' onClick={() => setC11yOpen(!c11yOpen)}>
294
- <SidebarSimple mirrored />
295
- </Button>
296
- </Main.Notch>
297
- <Main.NavigationSidebar>
298
- {navContent &&
299
- (navContent === MENU ? (
300
- menuChildren
301
- ) : (
302
- <StackPlank {...planks[navContent]}>
303
- <Button variant='ghost' classNames='p-1' onClick={() => setNavContent(null)}>
304
- <CaretLineRight />
305
- </Button>
306
- </StackPlank>
307
- ))}
308
- </Main.NavigationSidebar>
309
- <Main.ComplementarySidebar>
310
- {c11yContent &&
311
- (c11yContent === MENU ? (
312
- menuChildren
313
- ) : (
314
- <StackPlank {...planks[c11yContent]}>
315
- <Button variant='ghost' classNames='p-1' onClick={() => setC11yContent(null)}>
316
- <CaretLineLeft />
317
- </Button>
318
- </StackPlank>
319
- ))}
320
- </Main.ComplementarySidebar>
321
- <NaturalDeck.Root classNames='fixed inset-0 z-0'>
322
- {openPlanksInDeck.map((id, index, arr) =>
323
- id === MENU ? (
324
- <Plank.Root key={MENU}>
325
- <Plank.Content>{menuChildren}</Plank.Content>
326
- <Plank.ResizeHandle />
327
- </Plank.Root>
328
- ) : (
329
- <Plank.Root key={id}>
330
- <Plank.Content>
331
- <StackPlank {...planks[id]}>
332
- <Button variant='ghost' classNames='p-1' onClick={() => setNavContent(id)}>
333
- <CaretLineLeft />
334
- </Button>
335
- <IncrementButtons {...{ index, setOpenPlanks, openPlanks: openPlanksInDeck }} />
336
- <Button variant='ghost' classNames='p-1' onClick={() => setC11yContent(id)}>
337
- <CaretLineRight />
338
- </Button>
339
- <Button
340
- variant='ghost'
341
- classNames='p-1'
342
- onClick={() =>
343
- setOpenPlanks((prev) => {
344
- prev.delete(id);
345
- return new Set(Array.from(prev));
346
- })
347
- }
348
- >
349
- <X />
350
- </Button>
351
- </StackPlank>
352
- </Plank.Content>
353
- <Plank.ResizeHandle />
354
- </Plank.Root>
355
- ),
356
- )}
357
- </NaturalDeck.Root>
358
- </Main.Root>
359
- </RootAttentionProvider>
360
- </Mosaic.Root>
361
- );
362
- };
@@ -1,50 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import React from 'react';
8
-
9
- import { List } from '@dxos/react-ui';
10
- import { textBlockWidth, groupSurface, mx } from '@dxos/react-ui-theme';
11
- import { withTheme } from '@dxos/storybook-utils';
12
-
13
- import { Section, type SectionProps } from './Section';
14
-
15
- export default {
16
- title: 'ui/react-ui-stack/Section',
17
- component: Section as any,
18
- decorators: [withTheme],
19
- args: {
20
- id: 'section',
21
- title: 'Section',
22
- },
23
- render: (args: SectionProps) => {
24
- return (
25
- <List classNames={textBlockWidth}>
26
- <Section {...args}>
27
- <div className={mx('h-full p-2', groupSurface)}>Content Area</div>
28
- </Section>
29
- </List>
30
- );
31
- },
32
- };
33
-
34
- export const Default = {};
35
-
36
- export const ActiveRearrange = {
37
- args: { active: 'rearrange' },
38
- };
39
-
40
- export const ActiveOrigin = {
41
- args: { active: 'origin' },
42
- };
43
-
44
- export const ActiveDestination = {
45
- args: { active: 'destination' },
46
- };
47
-
48
- export const ActiveOverlay = {
49
- args: { active: 'overlay' },
50
- };