@dxos/react-ui-attention 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-attention",
3
- "version": "0.8.4-main.21d9917",
3
+ "version": "0.8.4-main.2244d791bb",
4
4
  "description": "Signifier components and providers for attention system.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -48,7 +48,7 @@
48
48
  "src"
49
49
  ],
50
50
  "dependencies": {
51
- "@effect-atom/atom-react": "^0.4.6",
51
+ "@effect-atom/atom-react": "^0.5.0",
52
52
  "@radix-ui/primitive": "1.1.1",
53
53
  "@radix-ui/react-compose-refs": "1.1.1",
54
54
  "@radix-ui/react-context": "1.1.1",
@@ -56,12 +56,12 @@
56
56
  "@radix-ui/react-primitive": "2.0.2",
57
57
  "@radix-ui/react-slot": "1.1.2",
58
58
  "@radix-ui/react-use-controllable-state": "1.1.0",
59
- "effect": "3.19.11",
60
- "@dxos/invariant": "0.8.4-main.21d9917",
61
- "@dxos/echo": "0.8.4-main.21d9917",
62
- "@dxos/react-hooks": "0.8.4-main.21d9917",
63
- "@dxos/util": "0.8.4-main.21d9917",
64
- "@dxos/log": "0.8.4-main.21d9917"
59
+ "effect": "3.19.16",
60
+ "@dxos/echo": "0.8.4-main.2244d791bb",
61
+ "@dxos/invariant": "0.8.4-main.2244d791bb",
62
+ "@dxos/react-hooks": "0.8.4-main.2244d791bb",
63
+ "@dxos/log": "0.8.4-main.2244d791bb",
64
+ "@dxos/util": "0.8.4-main.2244d791bb"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/react": "~19.2.7",
@@ -69,17 +69,17 @@
69
69
  "react": "~19.2.3",
70
70
  "react-dom": "~19.2.3",
71
71
  "vite": "7.1.9",
72
- "@dxos/random": "0.8.4-main.21d9917",
73
- "@dxos/react-ui": "0.8.4-main.21d9917",
74
- "@dxos/storybook-utils": "0.8.4-main.21d9917",
75
- "@dxos/ui-theme": "0.8.4-main.21d9917"
72
+ "@dxos/random": "0.8.4-main.2244d791bb",
73
+ "@dxos/react-ui": "0.8.4-main.2244d791bb",
74
+ "@dxos/ui-theme": "0.8.4-main.2244d791bb",
75
+ "@dxos/storybook-utils": "0.8.4-main.2244d791bb"
76
76
  },
77
77
  "peerDependencies": {
78
- "effect": "3.19.11",
78
+ "effect": "3.19.16",
79
79
  "react": "~19.2.3",
80
80
  "react-dom": "~19.2.3",
81
- "@dxos/ui-theme": "0.8.4-main.21d9917",
82
- "@dxos/react-ui": "0.8.4-main.21d9917"
81
+ "@dxos/react-ui": "0.8.4-main.2244d791bb",
82
+ "@dxos/ui-theme": "0.8.4-main.2244d791bb"
83
83
  },
84
84
  "publishConfig": {
85
85
  "access": "public"
@@ -31,7 +31,7 @@ const meta = {
31
31
  title: 'ui/react-ui-attention/AttentionGlyph',
32
32
  component: AttentionGlyph as any,
33
33
  render: DefaultStory,
34
- decorators: [withTheme],
34
+ decorators: [withTheme()],
35
35
  } satisfies Meta<typeof DefaultStory>;
36
36
 
37
37
  export default meta;
@@ -35,7 +35,7 @@ const Story = () => {
35
35
  const meta = {
36
36
  title: 'ui/react-ui-attention/AttentionProvider',
37
37
  render: Story,
38
- decorators: [withTheme, withAttention],
38
+ decorators: [withTheme(), withAttention()],
39
39
  } satisfies Meta;
40
40
 
41
41
  export default meta;
@@ -50,10 +50,12 @@ export const useSelectionManager = () => {
50
50
 
51
51
  const getDefaultResult = <T extends SelectionMode>(mode: T): SelectionResult<T> => {
52
52
  return Match.type<Selection>().pipe(
53
- Match.when({ mode: 'single' }, (s) => s.id),
54
- Match.when({ mode: 'multi' }, (s) => s.ids),
55
- Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),
56
- Match.when({ mode: 'multi-range' }, (s) => s.ranges),
53
+ Match.when({ mode: 'single' }, (selection) => selection.id),
54
+ Match.when({ mode: 'multi' }, (selection) => selection.ids),
55
+ Match.when({ mode: 'range' }, (selection) =>
56
+ selection.from && selection.to ? { from: selection.from, to: selection.to } : undefined,
57
+ ),
58
+ Match.when({ mode: 'multi-range' }, (selection) => selection.ranges),
57
59
  Match.exhaustive,
58
60
  )(defaultSelection(mode)) as SelectionResult<T>;
59
61
  };
@@ -6,13 +6,24 @@ import { Registry, RegistryContext } from '@effect-atom/atom-react';
6
6
  import { type Decorator } from '@storybook/react';
7
7
  import { createElement, useMemo } from 'react';
8
8
 
9
+ import { AttentionManager } from '../../attention';
9
10
  import { RootAttentionProvider, SelectionProvider } from '../../components';
10
11
 
11
- export const withAttention: Decorator = (Story) => {
12
- const registry = useMemo(() => Registry.make(), []);
13
- return createElement(
14
- RegistryContext.Provider,
15
- { value: registry },
16
- createElement(RootAttentionProvider, {}, createElement(SelectionProvider, {}, createElement(Story))),
17
- );
12
+ /**
13
+ * Storybook decorator that provides attention context.
14
+ * @param initialAttendedId Optional ID to set as initially attended.
15
+ */
16
+ export const withAttention = (initialAttendedId?: string): Decorator => {
17
+ return (Story) => {
18
+ const registry = useMemo(() => Registry.make(), []);
19
+ const attention = useMemo(
20
+ () => (initialAttendedId ? new AttentionManager(registry, [initialAttendedId]) : undefined),
21
+ [registry],
22
+ );
23
+ return createElement(
24
+ RegistryContext.Provider,
25
+ { value: registry },
26
+ createElement(RootAttentionProvider, { attention }, createElement(SelectionProvider, {}, createElement(Story))),
27
+ );
28
+ };
18
29
  };