@dxos/react-ui-stack 0.6.13-main.ed424a1 → 0.6.13-staging.1e988a3

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 (43) hide show
  1. package/dist/lib/browser/index.mjs +8 -9
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/testing/index.mjs +1 -1
  5. package/dist/lib/browser/testing/index.mjs.map +3 -3
  6. package/dist/lib/node/index.cjs +6 -7
  7. package/dist/lib/node/index.cjs.map +3 -3
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/testing/index.cjs.map +2 -2
  10. package/dist/types/src/components/CaretDownUp.d.ts.map +1 -1
  11. package/dist/types/src/components/Deck.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Section.d.ts +3 -2
  13. package/dist/types/src/components/Section.d.ts.map +1 -1
  14. package/dist/types/src/playwright/playwright.config.d.ts +2 -2
  15. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  16. package/dist/types/src/testing/TableContent.d.ts.map +1 -1
  17. package/dist/types/src/testing/generator.d.ts +2 -2
  18. package/dist/types/src/testing/generator.d.ts.map +1 -1
  19. package/package.json +21 -28
  20. package/src/components/CaretDownUp.tsx +0 -1
  21. package/src/components/Deck.stories.tsx +26 -16
  22. package/src/components/Section.tsx +18 -9
  23. package/src/playwright/playwright.config.ts +2 -13
  24. package/src/playwright/smoke.spec.ts +19 -11
  25. package/src/testing/TableContent.tsx +0 -1
  26. package/src/testing/generator.ts +4 -4
  27. package/dist/lib/node-esm/index.mjs +0 -378
  28. package/dist/lib/node-esm/index.mjs.map +0 -7
  29. package/dist/lib/node-esm/meta.json +0 -1
  30. package/dist/lib/node-esm/testing/index.mjs +0 -161
  31. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  32. package/dist/types/src/next/Stack.d.ts +0 -9
  33. package/dist/types/src/next/Stack.d.ts.map +0 -1
  34. package/dist/types/src/next/Stack.stories.d.ts +0 -8
  35. package/dist/types/src/next/Stack.stories.d.ts.map +0 -1
  36. package/dist/types/src/next/StackItem.d.ts +0 -14
  37. package/dist/types/src/next/StackItem.d.ts.map +0 -1
  38. package/dist/types/src/next/index.d.ts +0 -2
  39. package/dist/types/src/next/index.d.ts.map +0 -1
  40. package/src/next/Stack.stories.tsx +0 -146
  41. package/src/next/Stack.tsx +0 -30
  42. package/src/next/StackItem.tsx +0 -78
  43. package/src/next/index.ts +0 -5
@@ -4,13 +4,23 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import { CaretLeft, CaretLineLeft, CaretLineRight, CaretRight, SidebarSimple, X } from '@phosphor-icons/react';
7
+ import {
8
+ Books,
9
+ CardsThree,
10
+ CaretLeft,
11
+ CaretLineLeft,
12
+ CaretLineRight,
13
+ CaretRight,
14
+ SidebarSimple,
15
+ TextAa,
16
+ X,
17
+ } from '@phosphor-icons/react';
8
18
  import React, { type PropsWithChildren, useState, type ComponentProps } from 'react';
9
19
 
10
20
  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';
21
+ import { Button, Main } from '@dxos/react-ui';
22
+ import { AttentionProvider } from '@dxos/react-ui-attention';
23
+ import { PlankHeading, plankHeadingIconProps, Deck as NaturalDeck, Plank } from '@dxos/react-ui-deck';
14
24
  import { Mosaic, type MosaicDataItem } from '@dxos/react-ui-mosaic';
15
25
  import { withTheme } from '@dxos/storybook-utils';
16
26
  import { arrayMove } from '@dxos/util';
@@ -41,7 +51,7 @@ const SimpleContent = ({ data }: { data: MosaicDataItem & { title?: string; body
41
51
  const rollItems = (n: number): StackSectionItem[] => {
42
52
  return [...Array(n)].map(() => ({
43
53
  id: faker.string.uuid(),
44
- icon: 'ph--text-aa--regular',
54
+ icon: TextAa,
45
55
  isResizable: true,
46
56
  object: {
47
57
  id: faker.string.uuid(),
@@ -64,7 +74,7 @@ const StackPlank = ({ label, items, id, children }: PropsWithChildren<PlankProps
64
74
  <>
65
75
  <PlankHeading.Root classNames='pli-px'>
66
76
  <PlankHeading.Button>
67
- <Icon icon='ph--cards-three--regular' size={5} />
77
+ <CardsThree {...plankHeadingIconProps} />
68
78
  </PlankHeading.Button>
69
79
  <PlankHeading.Label classNames='flex-1 truncate'>{label}</PlankHeading.Label>
70
80
  {children}
@@ -102,10 +112,10 @@ export default {
102
112
  export const StaticBasicStacks = {
103
113
  args: {},
104
114
  render: () => {
105
- const [attention] = useState({ attended: [] });
115
+ const [attended] = useState(new Set<string>());
106
116
  return (
107
117
  <Mosaic.Root>
108
- <RootAttentionProvider attention={attention}>
118
+ <AttentionProvider attended={attended}>
109
119
  <Mosaic.DragOverlay />
110
120
  <NaturalDeck.Root classNames='fixed inset-0 z-0'>
111
121
  <DemoStackPlank />
@@ -116,7 +126,7 @@ export const StaticBasicStacks = {
116
126
  <DemoStackPlank />
117
127
  <DemoStackPlank />
118
128
  </NaturalDeck.Root>
119
- </RootAttentionProvider>
129
+ </AttentionProvider>
120
130
  </Mosaic.Root>
121
131
  );
122
132
  },
@@ -125,10 +135,10 @@ export const StaticBasicStacks = {
125
135
  export const StaticBasicStacksWithOverscrolling = {
126
136
  args: {},
127
137
  render: () => {
128
- const [attention] = useState({ attended: [] });
138
+ const [attended] = useState(new Set<string>());
129
139
  return (
130
140
  <Mosaic.Root>
131
- <RootAttentionProvider attention={attention}>
141
+ <AttentionProvider attended={attended}>
132
142
  <Mosaic.DragOverlay />
133
143
  <NaturalDeck.Root classNames='fixed inset-0 z-0'>
134
144
  <DemoStackPlank />
@@ -139,7 +149,7 @@ export const StaticBasicStacksWithOverscrolling = {
139
149
  <DemoStackPlank />
140
150
  <DemoStackPlank />
141
151
  </NaturalDeck.Root>
142
- </RootAttentionProvider>
152
+ </AttentionProvider>
143
153
  </Mosaic.Root>
144
154
  );
145
155
  },
@@ -195,7 +205,7 @@ export const DynamicBasicStacks = () => {
195
205
  return acc;
196
206
  }, {}),
197
207
  );
198
- const [attention] = useState({ attended: [] });
208
+ const [attended] = useState(new Set<string>());
199
209
 
200
210
  const [navOpen, setNavOpen] = useState(true);
201
211
  const [c11yOpen, setC11yOpen] = useState(false);
@@ -234,7 +244,7 @@ export const DynamicBasicStacks = () => {
234
244
  <>
235
245
  <PlankHeading.Root classNames='pli-px'>
236
246
  <PlankHeading.Button>
237
- <Icon icon='ph--books--regular' size={5} />
247
+ <Books {...plankHeadingIconProps} />
238
248
  </PlankHeading.Button>
239
249
  <PlankHeading.Label classNames='grow'>Menu</PlankHeading.Label>
240
250
  {c11yContent === MENU ? (
@@ -285,7 +295,7 @@ export const DynamicBasicStacks = () => {
285
295
 
286
296
  return (
287
297
  <Mosaic.Root>
288
- <RootAttentionProvider attention={attention}>
298
+ <AttentionProvider attended={attended}>
289
299
  <Main.Root complementarySidebarOpen={c11yOpen} navigationSidebarOpen={navOpen}>
290
300
  <Main.Overlay />
291
301
  <Mosaic.DragOverlay />
@@ -359,7 +369,7 @@ export const DynamicBasicStacks = () => {
359
369
  )}
360
370
  </NaturalDeck.Root>
361
371
  </Main.Root>
362
- </RootAttentionProvider>
372
+ </AttentionProvider>
363
373
  </Mosaic.Root>
364
374
  );
365
375
  };
@@ -3,7 +3,15 @@
3
3
  //
4
4
 
5
5
  import { useFocusableGroup, useTabsterAttributes } from '@fluentui/react-tabster';
6
- import { ArrowLineDown, ArrowLineUp, ArrowSquareOut, CaretUpDown, Trash } from '@phosphor-icons/react';
6
+ import {
7
+ ArrowLineDown,
8
+ ArrowLineUp,
9
+ ArrowSquareOut,
10
+ CaretUpDown,
11
+ DotsNine,
12
+ type IconProps,
13
+ Trash,
14
+ } from '@phosphor-icons/react';
7
15
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
8
16
  import React, {
9
17
  forwardRef,
@@ -18,7 +26,6 @@ import React, {
18
26
  import {
19
27
  Button,
20
28
  DropdownMenu,
21
- Icon,
22
29
  type Label,
23
30
  List,
24
31
  ListItem,
@@ -28,7 +35,7 @@ import {
28
35
  toLocalizedString,
29
36
  useTranslation,
30
37
  } from '@dxos/react-ui';
31
- import { useAttendableAttributes } from '@dxos/react-ui-attention';
38
+ import { createAttendableAttributes, useHasAttention } from '@dxos/react-ui-attention';
32
39
  import { DropDownMenuDragHandleTrigger, resizeHandle, resizeHandleHorizontal } from '@dxos/react-ui-deck';
33
40
  import {
34
41
  type MosaicActiveType,
@@ -85,14 +92,14 @@ export type StackSectionItem = MosaicDataItem & {
85
92
  };
86
93
  // TODO(wittjosiah): Common type? Factor out?
87
94
  metadata?: {
88
- icon?: string;
95
+ icon?: FC<IconProps>;
89
96
  placeholder?: Label;
90
97
  viewActions?: (item: StackSectionItem) => StackAction;
91
98
  };
92
99
  };
93
100
 
94
101
  export type StackAction = {
95
- icon: string;
102
+ icon: FC<IconProps>;
96
103
  label: Label;
97
104
  onClick: () => void;
98
105
  };
@@ -126,7 +133,7 @@ export const Section: ForwardRefExoticComponent<SectionProps & RefAttributes<HTM
126
133
  {
127
134
  id,
128
135
  title,
129
- icon = 'ph--placeholder--regular',
136
+ icon: Icon = DotsNine,
130
137
  size = 'intrinsic',
131
138
  collapsed,
132
139
  active,
@@ -150,7 +157,8 @@ export const Section: ForwardRefExoticComponent<SectionProps & RefAttributes<HTM
150
157
  mover: { cyclic: true, direction: 1, memorizeCurrent: false },
151
158
  });
152
159
  const sectionContentGroup = useFocusableGroup({});
153
- const attendableAttrs = useAttendableAttributes(id);
160
+ const attendableAttrs = createAttendableAttributes(id);
161
+ const hasAttention = useHasAttention(id);
154
162
 
155
163
  return (
156
164
  <CollapsiblePrimitive.Root
@@ -172,9 +180,10 @@ export const Section: ForwardRefExoticComponent<SectionProps & RefAttributes<HTM
172
180
  role='none'
173
181
  className={mx(
174
182
  'grid col-span-2 grid-cols-subgrid',
175
- 'bg-base attention-surface',
183
+ 'bg-base focus-within:border-separator focus-within:attention-within',
176
184
  hoverableControls,
177
185
  hoverableFocusedWithinControls,
186
+ (active || hasAttention) && 'attention-surface border-separator',
178
187
  (active === 'origin' || active === 'rearrange' || active === 'destination') && 'opacity-0',
179
188
  )}
180
189
  >
@@ -197,7 +206,7 @@ export const Section: ForwardRefExoticComponent<SectionProps & RefAttributes<HTM
197
206
  }}
198
207
  >
199
208
  <DropDownMenuDragHandleTrigger active={!!active} variant='ghost' classNames='m-0' {...draggableProps}>
200
- <Icon icon={icon} size={5} classNames='transition-opacity' />
209
+ <Icon className={mx(getSize(5), 'transition-opacity')} />
201
210
  </DropDownMenuDragHandleTrigger>
202
211
  <DropdownMenu.Portal>
203
212
  <DropdownMenu.Content>
@@ -2,17 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { nxE2EPreset } from '@nx/playwright/preset';
6
- import { defineConfig } from '@playwright/test';
5
+ import { defaultPlaywrightConfig } from '@dxos/test/playwright';
7
6
 
8
- import { e2ePreset } from '@dxos/test-utils/playwright';
9
-
10
- export default defineConfig({
11
- ...nxE2EPreset(__filename, { testDir: __dirname }),
12
- ...e2ePreset(__dirname),
13
- webServer: {
14
- command: 'pnpm -w nx storybook-e2e stories',
15
- port: 9009,
16
- reuseExistingServer: !process.env.CI,
17
- },
18
- });
7
+ export default defaultPlaywrightConfig;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { expect, test } from '@playwright/test';
6
6
 
7
- import { setupPage } from '@dxos/test-utils/playwright';
7
+ import { setupPage } from '@dxos/test/playwright';
8
8
 
9
9
  import { StackManager } from '../testing';
10
10
 
@@ -13,8 +13,10 @@ const storybookUrl = (storyId: string) => `http://localhost:9009/iframe.html?id=
13
13
 
14
14
  test.describe('Stack', () => {
15
15
  test('remove', async ({ browser }) => {
16
- const { page } = await setupPage(browser, { url: storybookUrl('react-ui-stack-stack--transfer') });
17
- await page.getByTestId('stack-transfer').waitFor({ state: 'visible' });
16
+ const { page } = await setupPage(browser, {
17
+ url: storybookUrl('react-ui-stack-stack--transfer'),
18
+ waitFor: (page) => page.getByTestId('stack-transfer').isVisible(),
19
+ });
18
20
 
19
21
  const stack = new StackManager(page.getByTestId('stack-1'));
20
22
  await expect(stack.sections()).toHaveCount(8);
@@ -26,8 +28,10 @@ test.describe('Stack', () => {
26
28
  });
27
29
 
28
30
  test('rearrange', async ({ browser }) => {
29
- const { page } = await setupPage(browser, { url: storybookUrl('react-ui-stack-stack--transfer') });
30
- await page.getByTestId('stack-transfer').waitFor({ state: 'visible' });
31
+ const { page } = await setupPage(browser, {
32
+ url: storybookUrl('react-ui-stack-stack--transfer'),
33
+ waitFor: (page) => page.getByTestId('stack-transfer').isVisible(),
34
+ });
31
35
 
32
36
  const stack = new StackManager(page.getByTestId('stack-1'));
33
37
  const sectionText = await stack.section(0).locator.innerText();
@@ -38,13 +42,15 @@ test.describe('Stack', () => {
38
42
  });
39
43
 
40
44
  test('transfer', async ({ browser, browserName }) => {
41
- if (browserName !== 'chromium') {
42
- // TODO(wittjosiah): This test is flaky in Webkit & Firefox.
45
+ if (browserName === 'webkit') {
46
+ // TODO(wittjosiah): This test is failing consistently on WebKit in CI specifically.
43
47
  test.skip();
44
48
  }
45
49
 
46
- const { page } = await setupPage(browser, { url: storybookUrl('react-ui-stack-stack--transfer') });
47
- await page.getByTestId('stack-transfer').waitFor({ state: 'visible' });
50
+ const { page } = await setupPage(browser, {
51
+ url: storybookUrl('react-ui-stack-stack--transfer'),
52
+ waitFor: (page) => page.getByTestId('stack-transfer').isVisible(),
53
+ });
48
54
 
49
55
  const stack1 = new StackManager(page.getByTestId('stack-1'));
50
56
  const stack2 = new StackManager(page.getByTestId('stack-2'));
@@ -63,8 +69,10 @@ test.describe('Stack', () => {
63
69
  });
64
70
 
65
71
  test('copy', async ({ browser }) => {
66
- const { page } = await setupPage(browser, { url: storybookUrl('react-ui-stack-stack--copy') });
67
- await page.getByTestId('stack-copy').waitFor({ state: 'visible' });
72
+ const { page } = await setupPage(browser, {
73
+ url: storybookUrl('react-ui-stack-stack--copy'),
74
+ waitFor: (page) => page.getByTestId('stack-copy').isVisible(),
75
+ });
68
76
 
69
77
  const stack1 = new StackManager(page.getByTestId('stack-1'));
70
78
  const stack2 = new StackManager(page.getByTestId('stack-2'));
@@ -1,7 +1,6 @@
1
1
  //
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
-
5
4
  import { Plugs, PlugsConnected } from '@phosphor-icons/react';
6
5
  import React from 'react';
7
6
 
@@ -2,13 +2,13 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { create, type ReactiveObject, S } from '@dxos/echo-schema';
6
- import { faker } from '@dxos/random';
7
-
8
5
  // TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/react-ui/testing.
9
6
 
10
7
  // TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).
11
8
 
9
+ import { S, create, type EchoReactiveObject } from '@dxos/echo-schema';
10
+ import { faker } from '@dxos/random';
11
+
12
12
  // TODO(burdon): Util.
13
13
  export const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>
14
14
  Array.from({ length })
@@ -23,7 +23,7 @@ type ObjectDataGenerator = {
23
23
  createData: () => any;
24
24
  };
25
25
 
26
- type ObjectFactory<T extends ReactiveObject<any>> = {
26
+ type ObjectFactory<T extends EchoReactiveObject<any>> = {
27
27
  schema?: S.Schema<any>; // TODO(burdon): Support both typed and expando schema.
28
28
  createObject: () => T;
29
29
  };