@dxos/react-ui-attention 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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 (47) hide show
  1. package/dist/lib/browser/{chunk-HJRZWOEX.mjs → chunk-4SEURHOL.mjs} +122 -106
  2. package/dist/lib/browser/chunk-4SEURHOL.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-GMKHOVJ5.mjs +1 -0
  4. package/dist/lib/browser/chunk-GMKHOVJ5.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +17 -12
  6. package/dist/lib/browser/index.mjs.map +3 -3
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +16 -7
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/browser/types.mjs +1 -6
  11. package/dist/lib/node-esm/{chunk-7TQWDE4M.mjs → chunk-6PQ4P7AL.mjs} +122 -105
  12. package/dist/lib/node-esm/chunk-6PQ4P7AL.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-UHVMYYIB.mjs +2 -0
  14. package/dist/lib/node-esm/chunk-UHVMYYIB.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +17 -12
  16. package/dist/lib/node-esm/index.mjs.map +3 -3
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/testing/index.mjs +16 -7
  19. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/types.mjs +1 -6
  21. package/dist/types/src/attention.d.ts +41 -10
  22. package/dist/types/src/attention.d.ts.map +1 -1
  23. package/dist/types/src/components/AttentionGlyph.d.ts.map +1 -1
  24. package/dist/types/src/components/AttentionProvider.d.ts +9 -11
  25. package/dist/types/src/components/AttentionProvider.d.ts.map +1 -1
  26. package/dist/types/src/components/SelectionProvider.d.ts.map +1 -1
  27. package/dist/types/src/testing/decorators/withAttention.d.ts +5 -1
  28. package/dist/types/src/testing/decorators/withAttention.d.ts.map +1 -1
  29. package/dist/types/src/types.d.ts +0 -1
  30. package/dist/types/src/types.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +16 -16
  33. package/src/attention.test.ts +179 -23
  34. package/src/attention.ts +132 -54
  35. package/src/components/AttentionGlyph.stories.tsx +3 -3
  36. package/src/components/AttentionGlyph.tsx +12 -5
  37. package/src/components/AttentionProvider.stories.tsx +2 -2
  38. package/src/components/AttentionProvider.tsx +21 -48
  39. package/src/components/SelectionProvider.tsx +6 -4
  40. package/src/testing/decorators/withAttention.ts +18 -7
  41. package/src/types.ts +0 -3
  42. package/dist/lib/browser/chunk-HJRZWOEX.mjs.map +0 -7
  43. package/dist/lib/browser/chunk-PAZBZOO2.mjs +0 -7
  44. package/dist/lib/browser/chunk-PAZBZOO2.mjs.map +0 -7
  45. package/dist/lib/node-esm/chunk-7TQWDE4M.mjs.map +0 -7
  46. package/dist/lib/node-esm/chunk-PMGNPL4M.mjs +0 -9
  47. package/dist/lib/node-esm/chunk-PMGNPL4M.mjs.map +0 -7
@@ -23,49 +23,42 @@ import { type ThemedClassName } from '@dxos/react-ui';
23
23
  import { mx } from '@dxos/ui-theme';
24
24
 
25
25
  import { AttentionManager, getAttendables } from '../attention';
26
- import { ATTENDABLE_PATH_SEPARATOR, type Attention } from '../types';
26
+ import { type Attention } from '../types';
27
27
 
28
28
  const ATTENTION_NAME = 'Attention';
29
29
  const ATTENDABLE_ATTRIBUTE = 'data-attendable-id';
30
- const ATTENTION_SOURCE_ATTRIBUTE = 'data-is-attention-source';
30
+ const ATTENTION_SOURCE_ATTRIBUTE = 'data-w-attention-source';
31
31
 
32
32
  type AttentionContextValue = {
33
33
  attention: AttentionManager;
34
- path: string[];
35
34
  };
36
35
 
37
36
  const [AttentionContextProvider, useAttentionContext] = createContext<AttentionContextValue>(ATTENTION_NAME, {
38
37
  attention: undefined as unknown as AttentionManager,
39
- path: [],
40
38
  });
41
39
 
42
40
  const UNKNOWN_ATTENDABLE = { hasAttention: false, isAncestor: false, isRelated: false } as Attention;
43
41
 
42
+ /**
43
+ * Subscribe to the attention state for a qualified graph ID.
44
+ */
44
45
  const useAttention = (attendableId?: string): Attention => {
45
- const { attention, path } = useAttentionContext(ATTENTION_NAME);
46
+ const { attention } = useAttentionContext(ATTENTION_NAME);
46
47
  const [state, setState] = useState<Attention>(UNKNOWN_ATTENDABLE);
47
48
 
48
- const key = useMemo(() => {
49
- if (!attendableId) {
50
- return undefined;
51
- }
52
- return [...attendableId.split(ATTENDABLE_PATH_SEPARATOR), ...path];
53
- }, [attendableId, path]);
54
-
55
49
  useEffect(() => {
56
- if (!key || !attention) {
50
+ if (!attendableId || !attention) {
57
51
  setState(UNKNOWN_ATTENDABLE);
58
52
  return;
59
53
  }
60
54
 
61
- // Set initial state.
62
- setState(attention.get(key));
55
+ const currentState = attention.get(attendableId);
56
+ setState(currentState);
63
57
 
64
- // Subscribe to changes.
65
- return attention.subscribe(key, (newState) => {
58
+ return attention.subscribe(attendableId, (newState) => {
66
59
  setState(newState);
67
60
  });
68
- }, [attention, key]);
61
+ }, [attention, attendableId]);
69
62
 
70
63
  return state;
71
64
  };
@@ -79,10 +72,8 @@ const useAttended = () => {
79
72
  return;
80
73
  }
81
74
 
82
- // Set initial state.
83
75
  setCurrent(attention.getCurrent());
84
76
 
85
- // Subscribe to changes.
86
77
  return attention.subscribeCurrent((newCurrent) => {
87
78
  setCurrent(newCurrent);
88
79
  });
@@ -93,7 +84,6 @@ const useAttended = () => {
93
84
 
94
85
  /**
95
86
  * Computes HTML element attributes to apply so the attention system can detect changes.
96
- * @param attendableId
97
87
  */
98
88
  const useAttentionAttributes = (attendableId?: string) => {
99
89
  const { hasAttention } = useAttention(attendableId);
@@ -107,11 +97,6 @@ const useAttentionAttributes = (attendableId?: string) => {
107
97
  }, [attendableId, hasAttention]);
108
98
  };
109
99
 
110
- const useAttentionPath = () => {
111
- const { path } = useAttentionContext(ATTENTION_NAME);
112
- return path;
113
- };
114
-
115
100
  const RootAttentionProvider = ({
116
101
  children,
117
102
  attention: propsAttention,
@@ -147,7 +132,7 @@ const RootAttentionProvider = ({
147
132
  };
148
133
 
149
134
  return (
150
- <AttentionContextProvider attention={attention} path={[]}>
135
+ <AttentionContextProvider attention={attention}>
151
136
  <div role='none' className='contents' onFocusCapture={handleFocus}>
152
137
  {children}
153
138
  </div>
@@ -155,53 +140,41 @@ const RootAttentionProvider = ({
155
140
  );
156
141
  };
157
142
 
158
- const AttentionProvider = ({ id, children }: PropsWithChildren<{ id: string }>) => {
159
- const { attention, path } = useAttentionContext(ATTENTION_NAME);
160
- const nextPath = useMemo(() => [id, ...path], [id, path]);
161
-
162
- return (
163
- <AttentionContextProvider attention={attention} path={nextPath}>
164
- {children}
165
- </AttentionContextProvider>
166
- );
167
- };
168
-
169
143
  export type AttendableContainerProps = ThemedClassName<
170
144
  ComponentPropsWithRef<'div'> & { id: string; asChild?: boolean }
171
145
  >;
172
146
 
173
147
  /**
174
- * Note that DeckPlugin and StackPlugin both handle attention on their own, and when rendering content in those cases it
175
- * is not necessary to also render an `AttendableContainer`. This component is primarily for Storybook stories and other
176
- * testing scenarios, or the rare cases where an attendable entity is rendered outside of either of those plugins.
148
+ * Note that DeckPlugin and StackPlugin both handle attention on their own,
149
+ * and when rendering content in those cases it is not necessary to also render an `AttendableContainer`.
150
+ * This component is primarily for Storybook stories and other testing scenarios,
151
+ * or the rare cases where an attendable entity is rendered outside of either of those plugins.
177
152
  */
178
153
  const AttendableContainer = forwardRef<HTMLDivElement, AttendableContainerProps>(
179
154
  ({ id, classNames, children, asChild, ...props }, forwardedRef) => {
180
155
  const attentionAttrs = useAttentionAttributes(id);
181
- const Root = asChild ? Slot : Primitive.div;
156
+ const Comp = asChild ? Slot : Primitive.div;
182
157
  return (
183
- <Root
158
+ <Comp
184
159
  role='none'
185
- {...attentionAttrs}
186
160
  {...props}
187
- className={mx('attention-surface', props.tabIndex === 0 && 'dx-focus-ring-inset-over-all', classNames)}
161
+ {...attentionAttrs}
162
+ className={mx('dx-attention-surface', props.tabIndex === 0 && 'dx-focus-ring-inset-over-all', classNames)}
188
163
  ref={forwardedRef}
189
164
  >
190
165
  {children}
191
- </Root>
166
+ </Comp>
192
167
  );
193
168
  },
194
169
  );
195
170
 
196
171
  export {
197
172
  RootAttentionProvider,
198
- AttentionProvider,
199
173
  AttendableContainer,
200
174
  useAttentionContext,
201
175
  useAttention,
202
176
  useAttended,
203
177
  useAttentionAttributes,
204
- useAttentionPath,
205
178
  ATTENTION_NAME,
206
179
  ATTENDABLE_ATTRIBUTE,
207
180
  ATTENTION_SOURCE_ATTRIBUTE,
@@ -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
  };
package/src/types.ts CHANGED
@@ -2,9 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- // NOTE: Chosen from RFC 1738's `safe` characters: http://www.faqs.org/rfcs/rfc1738.html
6
- export const ATTENDABLE_PATH_SEPARATOR = '~';
7
-
8
5
  export type Attention = {
9
6
  hasAttention: boolean;
10
7
  isAncestor: boolean;
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/attention.ts", "../../../src/components/AttentionProvider.tsx", "../../../src/selection.ts", "../../../src/components/SelectionProvider.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\n\nimport { ComplexMap } from '@dxos/util';\n\nimport { ATTENDABLE_PATH_SEPARATOR, type Attention } from './types';\n\n// TODO(wittjosiah): Use mosaic path utility?\nconst stringKey = (key: string[]) => key.join(',');\n\n/**\n * Manages attention state for an application.\n */\nexport class AttentionManager {\n // Each attention path is associated with an attention atom.\n // The lookup is not a reactive object to ensure that attention for each path is subscribable independently.\n private readonly _map = new ComplexMap<string[], Atom.Writable<Attention>>(stringKey);\n private readonly _currentAtom: Atom.Writable<string[]>;\n\n constructor(\n private readonly _registry: Registry.Registry,\n initial: string[] = [],\n ) {\n this._currentAtom = Atom.make<string[]>([]);\n if (initial.length > 0) {\n this.update(initial);\n }\n }\n\n /**\n * Atom for the currently attended element path.\n */\n get current(): Atom.Atom<string[]> {\n return this._currentAtom;\n }\n\n /**\n * Gets the currently attended element path.\n */\n getCurrent(): readonly string[] {\n return this._registry.get(this._currentAtom);\n }\n\n /**\n * Subscribe to changes in the current attention path.\n */\n subscribeCurrent(cb: (current: readonly string[]) => void): () => void {\n this._registry.get(this._currentAtom);\n return this._registry.subscribe(this._currentAtom, () => {\n cb(this._registry.get(this._currentAtom));\n });\n }\n\n /**\n * All attention paths.\n */\n keys(): string[][] {\n return Array.from(this._map.keys());\n }\n\n /**\n * Get the attention state for a given path.\n */\n get(key: string[]): Attention {\n const atom = this._getAtom(key);\n return this._registry.get(atom);\n }\n\n /**\n * Subscribe to changes in the attention state for a given path.\n */\n subscribe(key: string[], cb: (attention: Attention) => void): () => void {\n const atom = this._getAtom(key);\n this._registry.get(atom);\n return this._registry.subscribe(atom, () => {\n cb(this._registry.get(atom));\n });\n }\n\n private _getAtom(key: string[]): Atom.Writable<Attention> {\n const existing = this._map.get(key);\n if (existing) {\n return existing;\n }\n\n const newAtom = Atom.make<Attention>({ hasAttention: false, isAncestor: false, isRelated: false });\n this._map.set(key, newAtom);\n return newAtom;\n }\n\n /**\n * Update the currently attended element.\n *\n * @internal\n */\n update(nextKey: string[]): void {\n const currentKey = this.getCurrent();\n const currentRelatedTo = currentKey[0];\n const nextRelatedTo = nextKey[0];\n\n // Ensure related attention object is initialized.\n this._getAtom([nextRelatedTo]);\n\n const currentRelatedKeys = this.keys().filter((key) => key[0] === currentRelatedTo);\n const nextRelatedKeys = this.keys().filter(\n (key) => key[0] === nextRelatedTo && stringKey(key) !== stringKey(nextKey),\n );\n const prevRelatedKeys = currentRelatedKeys.filter(\n (curr) => !nextRelatedKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n const currentAncestorKeys = currentKey.slice(1).map((_, i) => currentKey.slice(i + 1, currentKey.length));\n const nextAncestorKeys = nextKey.slice(1).map((_, i) => nextKey.slice(i + 1, nextKey.length));\n const prevAncestorKeys = currentAncestorKeys.filter(\n (curr) => !nextAncestorKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n this._registry.set(this._currentAtom, nextKey);\n prevRelatedKeys.forEach((key) => this._set(key, {}));\n prevAncestorKeys.forEach((key) => this._set(key, {}));\n nextRelatedKeys.forEach((key) => this._set(key, { isRelated: true }));\n nextAncestorKeys.forEach((key) => this._set(key, { isAncestor: true }));\n this._set(nextKey, { hasAttention: true });\n }\n\n private _set(key: string[], attention: Partial<Attention>): void {\n const atom = this._getAtom(key);\n this._registry.set(atom, {\n hasAttention: attention.hasAttention ?? false,\n isAncestor: attention.isAncestor ?? false,\n isRelated: attention.isRelated ?? false,\n });\n }\n}\n\n/**\n * Accumulates all attendable id's between the element provided and the root, inclusive.\n */\nexport const getAttendables = (selector: string, cursor: Element, acc: string[] = []): string[] => {\n // Find the closest element with `data-attendable-id`, if any; start from cursor and move up the DOM tree.\n const closestAttendable = cursor.closest(selector);\n if (closestAttendable) {\n const attendableId = closestAttendable.getAttribute('data-attendable-id');\n if (!attendableId) {\n // This has an id of an aria-controls elsewhere on the page, move cursor to that trigger.\n const trigger = document.querySelector(`[aria-controls=\"${closestAttendable.getAttribute('id')}\"]`);\n if (!trigger) {\n return acc;\n } else {\n return getAttendables(selector, trigger, acc);\n }\n } else {\n acc.push(...attendableId.split(ATTENDABLE_PATH_SEPARATOR));\n // TODO: Attempt tail recursion.\n return !closestAttendable.parentElement ? acc : getAttendables(selector, closestAttendable.parentElement, acc);\n }\n }\n\n return [...new Set(acc)];\n};\n\nexport type AttendableId = { attendableId?: string };\n\nexport type Related = { related?: boolean };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport { createContext } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport React, {\n type ComponentPropsWithRef,\n type FocusEvent,\n type PropsWithChildren,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { log } from '@dxos/log';\nimport { useDefaultValue } from '@dxos/react-hooks';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { AttentionManager, getAttendables } from '../attention';\nimport { ATTENDABLE_PATH_SEPARATOR, type Attention } from '../types';\n\nconst ATTENTION_NAME = 'Attention';\nconst ATTENDABLE_ATTRIBUTE = 'data-attendable-id';\nconst ATTENTION_SOURCE_ATTRIBUTE = 'data-is-attention-source';\n\ntype AttentionContextValue = {\n attention: AttentionManager;\n path: string[];\n};\n\nconst [AttentionContextProvider, useAttentionContext] = createContext<AttentionContextValue>(ATTENTION_NAME, {\n attention: undefined as unknown as AttentionManager,\n path: [],\n});\n\nconst UNKNOWN_ATTENDABLE = { hasAttention: false, isAncestor: false, isRelated: false } as Attention;\n\nconst useAttention = (attendableId?: string): Attention => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n const [state, setState] = useState<Attention>(UNKNOWN_ATTENDABLE);\n\n const key = useMemo(() => {\n if (!attendableId) {\n return undefined;\n }\n return [...attendableId.split(ATTENDABLE_PATH_SEPARATOR), ...path];\n }, [attendableId, path]);\n\n useEffect(() => {\n if (!key || !attention) {\n setState(UNKNOWN_ATTENDABLE);\n return;\n }\n\n // Set initial state.\n setState(attention.get(key));\n\n // Subscribe to changes.\n return attention.subscribe(key, (newState) => {\n setState(newState);\n });\n }, [attention, key]);\n\n return state;\n};\n\nconst useAttended = () => {\n const { attention } = useAttentionContext(ATTENTION_NAME);\n const [current, setCurrent] = useState<readonly string[]>([]);\n\n useEffect(() => {\n if (!attention) {\n return;\n }\n\n // Set initial state.\n setCurrent(attention.getCurrent());\n\n // Subscribe to changes.\n return attention.subscribeCurrent((newCurrent) => {\n setCurrent(newCurrent);\n });\n }, [attention]);\n\n return current;\n};\n\n/**\n * Computes HTML element attributes to apply so the attention system can detect changes.\n * @param attendableId\n */\nconst useAttentionAttributes = (attendableId?: string) => {\n const { hasAttention } = useAttention(attendableId);\n return useMemo(() => {\n const attributes: Record<string, string | undefined> = { [ATTENDABLE_ATTRIBUTE]: attendableId };\n if (hasAttention) {\n attributes[ATTENTION_SOURCE_ATTRIBUTE] = 'true';\n }\n\n return attributes;\n }, [attendableId, hasAttention]);\n};\n\nconst useAttentionPath = () => {\n const { path } = useAttentionContext(ATTENTION_NAME);\n return path;\n};\n\nconst RootAttentionProvider = ({\n children,\n attention: propsAttention,\n onChange,\n}: PropsWithChildren<\n Partial<{\n attention: AttentionManager;\n onChange: (nextAttended: string[]) => void;\n }>\n>) => {\n const registry = useContext(RegistryContext);\n const attention = useDefaultValue(propsAttention, () => new AttentionManager(registry));\n\n const handleFocus = (event: FocusEvent) => {\n // NOTE(thure): Use the following to debug focus movement across the app:\n log('focus', { related: event.relatedTarget, target: event.target });\n\n const selector = [\n '[data-attendable-id]',\n ...Array.from(document.querySelectorAll('[aria-controls]')).map(\n (el) => `[id=\"${el.getAttribute('aria-controls')}\"]`,\n ),\n ].join(',');\n const prev = attention.getCurrent();\n const next = getAttendables(selector, event.target);\n // TODO(wittjosiah): Not allowing empty state means that the attended item is not strictly guaranteed to be in the DOM.\n // Currently this depends on the deck in order to ensure that when the attended item is removed something else is attended.\n // Only update state if the result is different and not empty.\n if (next.length > 0 && (prev.length !== next.length || !!prev.find((id, index) => next[index] !== id))) {\n attention.update(next);\n onChange?.(next);\n }\n };\n\n return (\n <AttentionContextProvider attention={attention} path={[]}>\n <div role='none' className='contents' onFocusCapture={handleFocus}>\n {children}\n </div>\n </AttentionContextProvider>\n );\n};\n\nconst AttentionProvider = ({ id, children }: PropsWithChildren<{ id: string }>) => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n const nextPath = useMemo(() => [id, ...path], [id, path]);\n\n return (\n <AttentionContextProvider attention={attention} path={nextPath}>\n {children}\n </AttentionContextProvider>\n );\n};\n\nexport type AttendableContainerProps = ThemedClassName<\n ComponentPropsWithRef<'div'> & { id: string; asChild?: boolean }\n>;\n\n/**\n * Note that DeckPlugin and StackPlugin both handle attention on their own, and when rendering content in those cases it\n * is not necessary to also render an `AttendableContainer`. This component is primarily for Storybook stories and other\n * testing scenarios, or the rare cases where an attendable entity is rendered outside of either of those plugins.\n */\nconst AttendableContainer = forwardRef<HTMLDivElement, AttendableContainerProps>(\n ({ id, classNames, children, asChild, ...props }, forwardedRef) => {\n const attentionAttrs = useAttentionAttributes(id);\n const Root = asChild ? Slot : Primitive.div;\n return (\n <Root\n role='none'\n {...attentionAttrs}\n {...props}\n className={mx('attention-surface', props.tabIndex === 0 && 'dx-focus-ring-inset-over-all', classNames)}\n ref={forwardedRef}\n >\n {children}\n </Root>\n );\n },\n);\n\nexport {\n RootAttentionProvider,\n AttentionProvider,\n AttendableContainer,\n useAttentionContext,\n useAttention,\n useAttended,\n useAttentionAttributes,\n useAttentionPath,\n ATTENTION_NAME,\n ATTENDABLE_ATTRIBUTE,\n ATTENTION_SOURCE_ATTRIBUTE,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\n\nimport { invariant } from '@dxos/invariant';\n\n// TODO(burdon): Reconcile with @dxos/graph.\n\nexport type SelectionMode = 'single' | 'multi' | 'range' | 'multi-range';\n\nexport const SelectionSchema = Schema.Union(\n Schema.Struct({ mode: Schema.Literal('single'), id: Schema.optional(Schema.String) }).pipe(Schema.mutable),\n Schema.Struct({ mode: Schema.Literal('multi'), ids: Schema.Array(Schema.String).pipe(Schema.mutable) }).pipe(\n Schema.mutable,\n ),\n Schema.Struct({\n mode: Schema.Literal('range'),\n from: Schema.optional(Schema.String),\n to: Schema.optional(Schema.String),\n }).pipe(Schema.mutable),\n Schema.Struct({\n mode: Schema.Literal('multi-range'),\n ranges: Schema.Array(Schema.Struct({ from: Schema.String, to: Schema.String })).pipe(Schema.mutable),\n }).pipe(Schema.mutable),\n).pipe(Schema.mutable);\n\nexport type Selection = Schema.Schema.Type<typeof SelectionSchema>;\n\nexport const defaultSelection = Match.type<SelectionMode>().pipe(\n Match.withReturnType<Selection>(),\n Match.when('single', () => ({ mode: 'single' })),\n Match.when('multi', () => ({ mode: 'multi', ids: [] })),\n Match.when('range', () => ({ mode: 'range' })),\n Match.when('multi-range', () => ({ mode: 'multi-range', ranges: [] })),\n Match.exhaustive,\n);\n\nexport type SelectionResult<T extends SelectionMode> = T extends 'single'\n ? string | undefined\n : T extends 'multi'\n ? string[]\n : T extends 'range'\n ? { from: string; to: string } | undefined\n : T extends 'multi-range'\n ? { from: string; to: string }[]\n : never;\n\n// TODO(burdon): Refactor.\nexport const getSelectionSet = (selectionManager: SelectionManager, contextId?: string) => {\n const ids = new Set<string>(contextId ? [contextId] : []);\n for (const context of selectionManager.getSelectionContexts()) {\n const selection = selectionManager.getSelection(context);\n if (selection?.mode === 'multi') {\n for (const id of selection.ids) {\n ids.add(id);\n }\n }\n }\n\n return ids;\n};\n\n/**\n * Manages selection state for different contexts.\n * Each context maintains its own selection mode and state.\n */\nexport class SelectionManager {\n private readonly _state: Atom.Writable<{ selections: Record<string, Selection> }>;\n\n constructor(\n private readonly _registry: Registry.Registry,\n initial: Record<string, Selection> = {},\n ) {\n this._state = Atom.make<{ selections: Record<string, Selection> }>({\n selections: { ...initial },\n });\n }\n\n /**\n * Get the state atom for reactive access in the graph system.\n */\n get state(): Atom.Atom<{ selections: Record<string, Selection> }> {\n return this._state;\n }\n\n /**\n * Gets the current state.\n */\n getState(): { selections: Record<string, Selection> } {\n return this._registry.get(this._state);\n }\n\n /**\n * Subscribe to changes in the selection state.\n */\n subscribe(cb: (state: { selections: Record<string, Selection> }) => void): () => void {\n this._registry.get(this._state);\n return this._registry.subscribe(this._state, () => {\n cb(this._registry.get(this._state));\n });\n }\n\n getSelectionContexts(): string[] {\n return Object.keys(this._registry.get(this._state).selections);\n }\n\n getSelection(contextId: string): Selection | undefined;\n getSelection<T extends SelectionMode>(contextId: string, mode: T): Selection;\n getSelection<T extends SelectionMode | undefined>(\n contextId: string,\n mode: T = undefined as T,\n ): Selection | undefined {\n const state = this._registry.get(this._state);\n const selection = state.selections[contextId];\n if (!mode || selection) {\n return selection;\n }\n\n // Create new selection for the context.\n const newSelection = defaultSelection(mode);\n this._registry.update(this._state, (state) => ({\n selections: { ...state.selections, [contextId]: newSelection },\n }));\n return newSelection;\n }\n\n // TODO(burdon): Disambiguate with getSelection?\n getSelected<T extends SelectionMode>(contextId: string, mode: T = 'multi' as T): SelectionResult<T> {\n const selection = this.getSelection(contextId, mode);\n invariant(selection?.mode === mode, 'Selection mode mismatch');\n // Cast required because TypeScript can't infer the relationship between T and the matched result.\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => s.id),\n Match.when({ mode: 'multi' }, (s) => s.ids),\n Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),\n Match.when({ mode: 'multi-range' }, (s) => s.ranges),\n Match.exhaustive,\n )(selection) as SelectionResult<T>;\n }\n\n updateSingle(contextId: string, id: string): void {\n const selection = this.getSelection(contextId, 'single');\n invariant(selection?.mode === 'single', 'Selection mode is not single');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, id },\n },\n }));\n }\n\n updateMulti(contextId: string, ids: string[]) {\n const selection = this.getSelection(contextId, 'multi');\n invariant(selection?.mode === 'multi', 'Selection mode is not multi');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ids: [...ids] },\n },\n }));\n }\n\n updateRange(contextId: string, from: string, to: string) {\n const selection = this.getSelection(contextId, 'range');\n invariant(selection?.mode === 'range', 'Selection mode is not range');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, from, to },\n },\n }));\n }\n\n updateMultiRange(contextId: string, ranges: { from: string; to: string }[]) {\n const selection = this.getSelection(contextId, 'multi-range');\n invariant(selection?.mode === 'multi-range', 'Selection mode is not multi-range');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ranges: [...ranges] },\n },\n }));\n }\n\n clearSelection(contextId: string): void {\n const selection = this.getSelection(contextId);\n if (!selection) {\n return;\n }\n\n const clearedSelection = Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => ({ ...s, id: undefined })),\n Match.when({ mode: 'multi' }, (s) => ({ ...s, ids: [] })),\n Match.when({ mode: 'range' }, (s) => ({ ...s, from: undefined, to: undefined })),\n Match.when({ mode: 'multi-range' }, (s) => ({ ...s, ranges: [] })),\n Match.exhaustive,\n )(selection);\n\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: clearedSelection,\n },\n }));\n }\n\n toggleSelection(contextId: string, id: string): void {\n const selection = this.getSelection(contextId, 'multi');\n invariant(selection?.mode === 'multi', 'Selection mode is not multi');\n\n const newIds = selection.ids.includes(id)\n ? selection.ids.filter((existingId) => existingId !== id)\n : [...selection.ids, id];\n\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ids: newIds },\n },\n }));\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport { createContext } from '@radix-ui/react-context';\nimport * as Match from 'effect/Match';\nimport React, { type PropsWithChildren, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\nimport { useDefaultValue } from '@dxos/react-hooks';\n\nimport {\n type Selection,\n SelectionManager,\n type SelectionMode,\n type SelectionResult,\n defaultSelection,\n} from '../selection';\n\nconst SELECTION_NAME = 'Selection';\n\ntype SelectionContextValue = {\n selection: SelectionManager;\n};\n\nconst [SelectionContextProvider, useSelectionContext] = createContext<SelectionContextValue>(SELECTION_NAME, {\n selection: undefined as unknown as SelectionManager,\n});\n\n/**\n * Manages selection state across the app for multiple contexts.\n */\n// TODO(burdon): When is the selection removed?\nexport const SelectionProvider = ({\n children,\n selection: propsSelection,\n}: PropsWithChildren<{ selection?: SelectionManager }>) => {\n const registry = useContext(RegistryContext);\n const selection = useDefaultValue(propsSelection, () => new SelectionManager(registry));\n return <SelectionContextProvider selection={selection}>{children}</SelectionContextProvider>;\n};\n\n/**\n * Get the selection contexts.\n */\nexport const useSelectionManager = () => {\n const { selection } = useSelectionContext(SELECTION_NAME);\n return selection;\n};\n\nconst getDefaultResult = <T extends SelectionMode>(mode: T): SelectionResult<T> => {\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => s.id),\n Match.when({ mode: 'multi' }, (s) => s.ids),\n Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),\n Match.when({ mode: 'multi-range' }, (s) => s.ranges),\n Match.exhaustive,\n )(defaultSelection(mode)) as SelectionResult<T>;\n};\n\n/**\n * Get the selected objects for a given context.\n */\nexport const useSelected = <T extends SelectionMode>(\n contextId?: string,\n mode: T = 'multi' as T,\n): SelectionResult<T> => {\n const { selection } = useSelectionContext(SELECTION_NAME);\n const [state, setState] = useState<SelectionResult<T>>(() =>\n contextId && selection ? selection.getSelected(contextId, mode) : getDefaultResult(mode),\n );\n\n useEffect(() => {\n if (!contextId || !selection) {\n setState(getDefaultResult(mode));\n return;\n }\n\n // Set initial state.\n setState(selection.getSelected(contextId, mode));\n\n // Subscribe to changes.\n return selection.subscribe(() => {\n setState(selection.getSelected(contextId, mode));\n });\n }, [selection, contextId, mode]);\n\n return state;\n};\n\nexport type UseSelectionActions = {\n singleSelect: (id: string) => void;\n multiSelect: (ids: string[]) => void;\n rangeSelect: (from: string, to: string) => void;\n toggle: (id: string) => void;\n clear: () => void;\n};\n\n/**\n * Provides functions to manage the selection state for multiple contexts.\n */\n// TODO(burdon): Mode not used.\nexport const useSelectionActions = (contextIds: string[], mode: SelectionMode = 'multi'): UseSelectionActions => {\n const stableContextIds = useMemo(() => contextIds, [JSON.stringify(contextIds)]); // TODO(burdon): Avoid stringify.\n const { selection } = useSelectionContext(SELECTION_NAME);\n\n const singleSelect = useCallback(\n (id: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateSingle(contextId, id);\n }\n },\n [selection, stableContextIds],\n );\n\n const multiSelect = useCallback(\n (ids: string[]) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateMulti(contextId, ids);\n }\n },\n [selection, stableContextIds],\n );\n\n const rangeSelect = useCallback(\n (from: string, to: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateRange(contextId, from, to);\n }\n },\n [selection, stableContextIds],\n );\n\n const toggle = useCallback(\n (id: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.toggleSelection(contextId, id);\n }\n },\n [selection, stableContextIds],\n );\n\n const clear = useCallback(() => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.clearSelection(contextId);\n }\n }, [selection, stableContextIds]);\n\n return { singleSelect, multiSelect, rangeSelect, toggle, clear };\n};\n"],
5
- "mappings": ";;;;;AAIA,SAASA,YAA2B;AAEpC,SAASC,kBAAkB;AAK3B,IAAMC,YAAY,CAACC,QAAkBA,IAAIC,KAAK,GAAA;AAKvC,IAAMC,mBAAN,MAAMA;;;;EAGMC,OAAO,IAAIC,WAA+CL,SAAAA;EAC1DM;EAEjB,YACmBC,WACjBC,UAAoB,CAAA,GACpB;SAFiBD,YAAAA;AAGjB,SAAKD,eAAeG,KAAKC,KAAe,CAAA,CAAE;AAC1C,QAAIF,QAAQG,SAAS,GAAG;AACtB,WAAKC,OAAOJ,OAAAA;IACd;EACF;;;;EAKA,IAAIK,UAA+B;AACjC,WAAO,KAAKP;EACd;;;;EAKAQ,aAAgC;AAC9B,WAAO,KAAKP,UAAUQ,IAAI,KAAKT,YAAY;EAC7C;;;;EAKAU,iBAAiBC,IAAsD;AACrE,SAA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AAAA;AACC,QAAI,CAAClB,WAAW;AACd;IACF;AACA,eAAW0B,aAAaS,kBAAkB;AACxCnC,gBAAUyC,aAAaf,WAAWR,EAAAA;IACpC;EACF,GACA;IAAClB;IAAWmC;GAAiB;AAG/B,QAAMO,cAAcF,YAClB,CAACrB,QAAAA;AACC,QAAI,CAACnB,WAAW;AACd;IACF;AACA,eAAW0B,aAAaS,kBAAkB;AACxCnC,gBAAU2C,YAAYjB,WAAWP,GAAAA;IACnC;EACF,GACA;IAACnB;IAAWmC;GAAiB;AAG/B,QAAMS,cAAcJ,YAClB,CAACpB,MAAcC,OAAAA;AACb,QAAI,CAACrB,WAAW;AACd;IACF;AACA,eAAW0B,aAAaS,kBAAkB;AACxCnC,gBAAU6C,YAAYnB,WAAWN,MAAMC,EAAAA;IACzC;EACF,GACA;IAACrB;IAAWmC;GAAiB;AAG/B,QAAMW,SAASN,YACb,CAACtB,OAAAA;AACC,QAAI,CAAClB,WAAW;AACd;IACF;AACA,eAAW0B,aAAaS,kBAAkB;AACxCnC,gBAAU+C,gBAAgBrB,WAAWR,EAAAA;IACvC;EACF,GACA;IAAClB;IAAWmC;GAAiB;AAG/B,QAAMa,QAAQR,YAAY,MAAA;AACxB,QAAI,CAACxC,WAAW;AACd;IACF;AACA,eAAW0B,aAAaS,kBAAkB;AACxCnC,gBAAUiD,eAAevB,SAAAA;IAC3B;EACF,GAAG;IAAC1B;IAAWmC;GAAiB;AAEhC,SAAO;IAAEI;IAAcG;IAAaE;IAAaE;IAAQE;EAAM;AACjE;",
6
- "names": ["Atom", "ComplexMap", "stringKey", "key", "join", "AttentionManager", "_map", "ComplexMap", "_currentAtom", "_registry", "initial", "Atom", "make", "length", "update", "current", "getCurrent", "get", "subscribeCurrent", "cb", "subscribe", "keys", "Array", "from", "atom", "_getAtom", "existing", "newAtom", "hasAttention", "isAncestor", "isRelated", "set", "nextKey", "currentKey", "currentRelatedTo", "nextRelatedTo", "currentRelatedKeys", "filter", "nextRelatedKeys", "prevRelatedKeys", "curr", "find", "next", "currentAncestorKeys", "slice", "map", "_", "i", "nextAncestorKeys", "prevAncestorKeys", "forEach", "_set", "attention", "getAttendables", "selector", "cursor", "acc", "closestAttendable", "closest", "attendableId", "getAttribute", "trigger", "document", "querySelector", "push", "split", "ATTENDABLE_PATH_SEPARATOR", "parentElement", "Set", "RegistryContext", "createContext", "Primitive", "Slot", "React", "forwardRef", "useContext", "useEffect", "useMemo", "useState", "log", "useDefaultValue", "mx", "ATTENTION_NAME", "ATTENDABLE_ATTRIBUTE", "ATTENTION_SOURCE_ATTRIBUTE", "AttentionContextProvider", "useAttentionContext", "createContext", "attention", "undefined", "path", "UNKNOWN_ATTENDABLE", "hasAttention", "isAncestor", "isRelated", "useAttention", "attendableId", "state", "setState", "useState", "key", "useMemo", "split", "ATTENDABLE_PATH_SEPARATOR", "useEffect", "get", "subscribe", "newState", "useAttended", "current", "setCurrent", "getCurrent", "subscribeCurrent", "newCurrent", "useAttentionAttributes", "attributes", "useAttentionPath", "RootAttentionProvider", "children", "propsAttention", "onChange", "registry", "useContext", "RegistryContext", "useDefaultValue", "AttentionManager", "handleFocus", "event", "log", "related", "relatedTarget", "target", "selector", "Array", "from", "document", "querySelectorAll", "map", "el", "getAttribute", "join", "prev", "next", "getAttendables", "length", "find", "id", "index", "update", "div", "role", "className", "onFocusCapture", "AttentionProvider", "nextPath", "AttendableContainer", "forwardRef", "classNames", "asChild", "props", "forwardedRef", "attentionAttrs", "Root", "Slot", "Primitive", "mx", "tabIndex", "ref", "Atom", "Match", "Schema", "invariant", "SelectionSchema", "Union", "Struct", "mode", "Literal", "id", "optional", "String", "pipe", "mutable", "ids", "Array", "from", "to", "ranges", "defaultSelection", "type", "withReturnType", "when", "exhaustive", "getSelectionSet", "selectionManager", "contextId", "Set", "context", "getSelectionContexts", "selection", "getSelection", "add", "SelectionManager", "_state", "_registry", "initial", "make", "selections", "state", "getState", "get", "subscribe", "cb", "Object", "keys", "undefined", "newSelection", "update", "getSelected", "s", "updateSingle", "updateMulti", "updateRange", "updateMultiRange", "clearSelection", "clearedSelection", "toggleSelection", "newIds", "includes", "filter", "existingId", "RegistryContext", "createContext", "Match", "React", "useCallback", "useContext", "useEffect", "useMemo", "useState", "useDefaultValue", "SELECTION_NAME", "SelectionContextProvider", "useSelectionContext", "createContext", "selection", "undefined", "SelectionProvider", "children", "propsSelection", "registry", "useContext", "RegistryContext", "useDefaultValue", "SelectionManager", "React", "useSelectionManager", "getDefaultResult", "mode", "type", "pipe", "when", "s", "id", "ids", "from", "to", "ranges", "exhaustive", "defaultSelection", "useSelected", "contextId", "state", "setState", "useState", "getSelected", "useEffect", "subscribe", "useSelectionActions", "contextIds", "stableContextIds", "useMemo", "JSON", "stringify", "singleSelect", "useCallback", "updateSingle", "multiSelect", "updateMulti", "rangeSelect", "updateRange", "toggle", "toggleSelection", "clear", "clearSelection"]
7
- }
@@ -1,7 +0,0 @@
1
- // src/types.ts
2
- var ATTENDABLE_PATH_SEPARATOR = "~";
3
-
4
- export {
5
- ATTENDABLE_PATH_SEPARATOR
6
- };
7
- //# sourceMappingURL=chunk-PAZBZOO2.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// NOTE: Chosen from RFC 1738's `safe` characters: http://www.faqs.org/rfcs/rfc1738.html\nexport const ATTENDABLE_PATH_SEPARATOR = '~';\n\nexport type Attention = {\n hasAttention: boolean;\n isAncestor: boolean;\n isRelated: boolean;\n};\n\nexport type CurrentState = {\n current: string[];\n};\n"],
5
- "mappings": ";AAKO,IAAMA,4BAA4B;",
6
- "names": ["ATTENDABLE_PATH_SEPARATOR"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/attention.ts", "../../../src/components/AttentionProvider.tsx", "../../../src/selection.ts", "../../../src/components/SelectionProvider.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\n\nimport { ComplexMap } from '@dxos/util';\n\nimport { ATTENDABLE_PATH_SEPARATOR, type Attention } from './types';\n\n// TODO(wittjosiah): Use mosaic path utility?\nconst stringKey = (key: string[]) => key.join(',');\n\n/**\n * Manages attention state for an application.\n */\nexport class AttentionManager {\n // Each attention path is associated with an attention atom.\n // The lookup is not a reactive object to ensure that attention for each path is subscribable independently.\n private readonly _map = new ComplexMap<string[], Atom.Writable<Attention>>(stringKey);\n private readonly _currentAtom: Atom.Writable<string[]>;\n\n constructor(\n private readonly _registry: Registry.Registry,\n initial: string[] = [],\n ) {\n this._currentAtom = Atom.make<string[]>([]);\n if (initial.length > 0) {\n this.update(initial);\n }\n }\n\n /**\n * Atom for the currently attended element path.\n */\n get current(): Atom.Atom<string[]> {\n return this._currentAtom;\n }\n\n /**\n * Gets the currently attended element path.\n */\n getCurrent(): readonly string[] {\n return this._registry.get(this._currentAtom);\n }\n\n /**\n * Subscribe to changes in the current attention path.\n */\n subscribeCurrent(cb: (current: readonly string[]) => void): () => void {\n this._registry.get(this._currentAtom);\n return this._registry.subscribe(this._currentAtom, () => {\n cb(this._registry.get(this._currentAtom));\n });\n }\n\n /**\n * All attention paths.\n */\n keys(): string[][] {\n return Array.from(this._map.keys());\n }\n\n /**\n * Get the attention state for a given path.\n */\n get(key: string[]): Attention {\n const atom = this._getAtom(key);\n return this._registry.get(atom);\n }\n\n /**\n * Subscribe to changes in the attention state for a given path.\n */\n subscribe(key: string[], cb: (attention: Attention) => void): () => void {\n const atom = this._getAtom(key);\n this._registry.get(atom);\n return this._registry.subscribe(atom, () => {\n cb(this._registry.get(atom));\n });\n }\n\n private _getAtom(key: string[]): Atom.Writable<Attention> {\n const existing = this._map.get(key);\n if (existing) {\n return existing;\n }\n\n const newAtom = Atom.make<Attention>({ hasAttention: false, isAncestor: false, isRelated: false });\n this._map.set(key, newAtom);\n return newAtom;\n }\n\n /**\n * Update the currently attended element.\n *\n * @internal\n */\n update(nextKey: string[]): void {\n const currentKey = this.getCurrent();\n const currentRelatedTo = currentKey[0];\n const nextRelatedTo = nextKey[0];\n\n // Ensure related attention object is initialized.\n this._getAtom([nextRelatedTo]);\n\n const currentRelatedKeys = this.keys().filter((key) => key[0] === currentRelatedTo);\n const nextRelatedKeys = this.keys().filter(\n (key) => key[0] === nextRelatedTo && stringKey(key) !== stringKey(nextKey),\n );\n const prevRelatedKeys = currentRelatedKeys.filter(\n (curr) => !nextRelatedKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n const currentAncestorKeys = currentKey.slice(1).map((_, i) => currentKey.slice(i + 1, currentKey.length));\n const nextAncestorKeys = nextKey.slice(1).map((_, i) => nextKey.slice(i + 1, nextKey.length));\n const prevAncestorKeys = currentAncestorKeys.filter(\n (curr) => !nextAncestorKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n this._registry.set(this._currentAtom, nextKey);\n prevRelatedKeys.forEach((key) => this._set(key, {}));\n prevAncestorKeys.forEach((key) => this._set(key, {}));\n nextRelatedKeys.forEach((key) => this._set(key, { isRelated: true }));\n nextAncestorKeys.forEach((key) => this._set(key, { isAncestor: true }));\n this._set(nextKey, { hasAttention: true });\n }\n\n private _set(key: string[], attention: Partial<Attention>): void {\n const atom = this._getAtom(key);\n this._registry.set(atom, {\n hasAttention: attention.hasAttention ?? false,\n isAncestor: attention.isAncestor ?? false,\n isRelated: attention.isRelated ?? false,\n });\n }\n}\n\n/**\n * Accumulates all attendable id's between the element provided and the root, inclusive.\n */\nexport const getAttendables = (selector: string, cursor: Element, acc: string[] = []): string[] => {\n // Find the closest element with `data-attendable-id`, if any; start from cursor and move up the DOM tree.\n const closestAttendable = cursor.closest(selector);\n if (closestAttendable) {\n const attendableId = closestAttendable.getAttribute('data-attendable-id');\n if (!attendableId) {\n // This has an id of an aria-controls elsewhere on the page, move cursor to that trigger.\n const trigger = document.querySelector(`[aria-controls=\"${closestAttendable.getAttribute('id')}\"]`);\n if (!trigger) {\n return acc;\n } else {\n return getAttendables(selector, trigger, acc);\n }\n } else {\n acc.push(...attendableId.split(ATTENDABLE_PATH_SEPARATOR));\n // TODO: Attempt tail recursion.\n return !closestAttendable.parentElement ? acc : getAttendables(selector, closestAttendable.parentElement, acc);\n }\n }\n\n return [...new Set(acc)];\n};\n\nexport type AttendableId = { attendableId?: string };\n\nexport type Related = { related?: boolean };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport { createContext } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport React, {\n type ComponentPropsWithRef,\n type FocusEvent,\n type PropsWithChildren,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { log } from '@dxos/log';\nimport { useDefaultValue } from '@dxos/react-hooks';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { AttentionManager, getAttendables } from '../attention';\nimport { ATTENDABLE_PATH_SEPARATOR, type Attention } from '../types';\n\nconst ATTENTION_NAME = 'Attention';\nconst ATTENDABLE_ATTRIBUTE = 'data-attendable-id';\nconst ATTENTION_SOURCE_ATTRIBUTE = 'data-is-attention-source';\n\ntype AttentionContextValue = {\n attention: AttentionManager;\n path: string[];\n};\n\nconst [AttentionContextProvider, useAttentionContext] = createContext<AttentionContextValue>(ATTENTION_NAME, {\n attention: undefined as unknown as AttentionManager,\n path: [],\n});\n\nconst UNKNOWN_ATTENDABLE = { hasAttention: false, isAncestor: false, isRelated: false } as Attention;\n\nconst useAttention = (attendableId?: string): Attention => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n const [state, setState] = useState<Attention>(UNKNOWN_ATTENDABLE);\n\n const key = useMemo(() => {\n if (!attendableId) {\n return undefined;\n }\n return [...attendableId.split(ATTENDABLE_PATH_SEPARATOR), ...path];\n }, [attendableId, path]);\n\n useEffect(() => {\n if (!key || !attention) {\n setState(UNKNOWN_ATTENDABLE);\n return;\n }\n\n // Set initial state.\n setState(attention.get(key));\n\n // Subscribe to changes.\n return attention.subscribe(key, (newState) => {\n setState(newState);\n });\n }, [attention, key]);\n\n return state;\n};\n\nconst useAttended = () => {\n const { attention } = useAttentionContext(ATTENTION_NAME);\n const [current, setCurrent] = useState<readonly string[]>([]);\n\n useEffect(() => {\n if (!attention) {\n return;\n }\n\n // Set initial state.\n setCurrent(attention.getCurrent());\n\n // Subscribe to changes.\n return attention.subscribeCurrent((newCurrent) => {\n setCurrent(newCurrent);\n });\n }, [attention]);\n\n return current;\n};\n\n/**\n * Computes HTML element attributes to apply so the attention system can detect changes.\n * @param attendableId\n */\nconst useAttentionAttributes = (attendableId?: string) => {\n const { hasAttention } = useAttention(attendableId);\n return useMemo(() => {\n const attributes: Record<string, string | undefined> = { [ATTENDABLE_ATTRIBUTE]: attendableId };\n if (hasAttention) {\n attributes[ATTENTION_SOURCE_ATTRIBUTE] = 'true';\n }\n\n return attributes;\n }, [attendableId, hasAttention]);\n};\n\nconst useAttentionPath = () => {\n const { path } = useAttentionContext(ATTENTION_NAME);\n return path;\n};\n\nconst RootAttentionProvider = ({\n children,\n attention: propsAttention,\n onChange,\n}: PropsWithChildren<\n Partial<{\n attention: AttentionManager;\n onChange: (nextAttended: string[]) => void;\n }>\n>) => {\n const registry = useContext(RegistryContext);\n const attention = useDefaultValue(propsAttention, () => new AttentionManager(registry));\n\n const handleFocus = (event: FocusEvent) => {\n // NOTE(thure): Use the following to debug focus movement across the app:\n log('focus', { related: event.relatedTarget, target: event.target });\n\n const selector = [\n '[data-attendable-id]',\n ...Array.from(document.querySelectorAll('[aria-controls]')).map(\n (el) => `[id=\"${el.getAttribute('aria-controls')}\"]`,\n ),\n ].join(',');\n const prev = attention.getCurrent();\n const next = getAttendables(selector, event.target);\n // TODO(wittjosiah): Not allowing empty state means that the attended item is not strictly guaranteed to be in the DOM.\n // Currently this depends on the deck in order to ensure that when the attended item is removed something else is attended.\n // Only update state if the result is different and not empty.\n if (next.length > 0 && (prev.length !== next.length || !!prev.find((id, index) => next[index] !== id))) {\n attention.update(next);\n onChange?.(next);\n }\n };\n\n return (\n <AttentionContextProvider attention={attention} path={[]}>\n <div role='none' className='contents' onFocusCapture={handleFocus}>\n {children}\n </div>\n </AttentionContextProvider>\n );\n};\n\nconst AttentionProvider = ({ id, children }: PropsWithChildren<{ id: string }>) => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n const nextPath = useMemo(() => [id, ...path], [id, path]);\n\n return (\n <AttentionContextProvider attention={attention} path={nextPath}>\n {children}\n </AttentionContextProvider>\n );\n};\n\nexport type AttendableContainerProps = ThemedClassName<\n ComponentPropsWithRef<'div'> & { id: string; asChild?: boolean }\n>;\n\n/**\n * Note that DeckPlugin and StackPlugin both handle attention on their own, and when rendering content in those cases it\n * is not necessary to also render an `AttendableContainer`. This component is primarily for Storybook stories and other\n * testing scenarios, or the rare cases where an attendable entity is rendered outside of either of those plugins.\n */\nconst AttendableContainer = forwardRef<HTMLDivElement, AttendableContainerProps>(\n ({ id, classNames, children, asChild, ...props }, forwardedRef) => {\n const attentionAttrs = useAttentionAttributes(id);\n const Root = asChild ? Slot : Primitive.div;\n return (\n <Root\n role='none'\n {...attentionAttrs}\n {...props}\n className={mx('attention-surface', props.tabIndex === 0 && 'dx-focus-ring-inset-over-all', classNames)}\n ref={forwardedRef}\n >\n {children}\n </Root>\n );\n },\n);\n\nexport {\n RootAttentionProvider,\n AttentionProvider,\n AttendableContainer,\n useAttentionContext,\n useAttention,\n useAttended,\n useAttentionAttributes,\n useAttentionPath,\n ATTENTION_NAME,\n ATTENDABLE_ATTRIBUTE,\n ATTENTION_SOURCE_ATTRIBUTE,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\n\nimport { invariant } from '@dxos/invariant';\n\n// TODO(burdon): Reconcile with @dxos/graph.\n\nexport type SelectionMode = 'single' | 'multi' | 'range' | 'multi-range';\n\nexport const SelectionSchema = Schema.Union(\n Schema.Struct({ mode: Schema.Literal('single'), id: Schema.optional(Schema.String) }).pipe(Schema.mutable),\n Schema.Struct({ mode: Schema.Literal('multi'), ids: Schema.Array(Schema.String).pipe(Schema.mutable) }).pipe(\n Schema.mutable,\n ),\n Schema.Struct({\n mode: Schema.Literal('range'),\n from: Schema.optional(Schema.String),\n to: Schema.optional(Schema.String),\n }).pipe(Schema.mutable),\n Schema.Struct({\n mode: Schema.Literal('multi-range'),\n ranges: Schema.Array(Schema.Struct({ from: Schema.String, to: Schema.String })).pipe(Schema.mutable),\n }).pipe(Schema.mutable),\n).pipe(Schema.mutable);\n\nexport type Selection = Schema.Schema.Type<typeof SelectionSchema>;\n\nexport const defaultSelection = Match.type<SelectionMode>().pipe(\n Match.withReturnType<Selection>(),\n Match.when('single', () => ({ mode: 'single' })),\n Match.when('multi', () => ({ mode: 'multi', ids: [] })),\n Match.when('range', () => ({ mode: 'range' })),\n Match.when('multi-range', () => ({ mode: 'multi-range', ranges: [] })),\n Match.exhaustive,\n);\n\nexport type SelectionResult<T extends SelectionMode> = T extends 'single'\n ? string | undefined\n : T extends 'multi'\n ? string[]\n : T extends 'range'\n ? { from: string; to: string } | undefined\n : T extends 'multi-range'\n ? { from: string; to: string }[]\n : never;\n\n// TODO(burdon): Refactor.\nexport const getSelectionSet = (selectionManager: SelectionManager, contextId?: string) => {\n const ids = new Set<string>(contextId ? [contextId] : []);\n for (const context of selectionManager.getSelectionContexts()) {\n const selection = selectionManager.getSelection(context);\n if (selection?.mode === 'multi') {\n for (const id of selection.ids) {\n ids.add(id);\n }\n }\n }\n\n return ids;\n};\n\n/**\n * Manages selection state for different contexts.\n * Each context maintains its own selection mode and state.\n */\nexport class SelectionManager {\n private readonly _state: Atom.Writable<{ selections: Record<string, Selection> }>;\n\n constructor(\n private readonly _registry: Registry.Registry,\n initial: Record<string, Selection> = {},\n ) {\n this._state = Atom.make<{ selections: Record<string, Selection> }>({\n selections: { ...initial },\n });\n }\n\n /**\n * Get the state atom for reactive access in the graph system.\n */\n get state(): Atom.Atom<{ selections: Record<string, Selection> }> {\n return this._state;\n }\n\n /**\n * Gets the current state.\n */\n getState(): { selections: Record<string, Selection> } {\n return this._registry.get(this._state);\n }\n\n /**\n * Subscribe to changes in the selection state.\n */\n subscribe(cb: (state: { selections: Record<string, Selection> }) => void): () => void {\n this._registry.get(this._state);\n return this._registry.subscribe(this._state, () => {\n cb(this._registry.get(this._state));\n });\n }\n\n getSelectionContexts(): string[] {\n return Object.keys(this._registry.get(this._state).selections);\n }\n\n getSelection(contextId: string): Selection | undefined;\n getSelection<T extends SelectionMode>(contextId: string, mode: T): Selection;\n getSelection<T extends SelectionMode | undefined>(\n contextId: string,\n mode: T = undefined as T,\n ): Selection | undefined {\n const state = this._registry.get(this._state);\n const selection = state.selections[contextId];\n if (!mode || selection) {\n return selection;\n }\n\n // Create new selection for the context.\n const newSelection = defaultSelection(mode);\n this._registry.update(this._state, (state) => ({\n selections: { ...state.selections, [contextId]: newSelection },\n }));\n return newSelection;\n }\n\n // TODO(burdon): Disambiguate with getSelection?\n getSelected<T extends SelectionMode>(contextId: string, mode: T = 'multi' as T): SelectionResult<T> {\n const selection = this.getSelection(contextId, mode);\n invariant(selection?.mode === mode, 'Selection mode mismatch');\n // Cast required because TypeScript can't infer the relationship between T and the matched result.\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => s.id),\n Match.when({ mode: 'multi' }, (s) => s.ids),\n Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),\n Match.when({ mode: 'multi-range' }, (s) => s.ranges),\n Match.exhaustive,\n )(selection) as SelectionResult<T>;\n }\n\n updateSingle(contextId: string, id: string): void {\n const selection = this.getSelection(contextId, 'single');\n invariant(selection?.mode === 'single', 'Selection mode is not single');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, id },\n },\n }));\n }\n\n updateMulti(contextId: string, ids: string[]) {\n const selection = this.getSelection(contextId, 'multi');\n invariant(selection?.mode === 'multi', 'Selection mode is not multi');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ids: [...ids] },\n },\n }));\n }\n\n updateRange(contextId: string, from: string, to: string) {\n const selection = this.getSelection(contextId, 'range');\n invariant(selection?.mode === 'range', 'Selection mode is not range');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, from, to },\n },\n }));\n }\n\n updateMultiRange(contextId: string, ranges: { from: string; to: string }[]) {\n const selection = this.getSelection(contextId, 'multi-range');\n invariant(selection?.mode === 'multi-range', 'Selection mode is not multi-range');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ranges: [...ranges] },\n },\n }));\n }\n\n clearSelection(contextId: string): void {\n const selection = this.getSelection(contextId);\n if (!selection) {\n return;\n }\n\n const clearedSelection = Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => ({ ...s, id: undefined })),\n Match.when({ mode: 'multi' }, (s) => ({ ...s, ids: [] })),\n Match.when({ mode: 'range' }, (s) => ({ ...s, from: undefined, to: undefined })),\n Match.when({ mode: 'multi-range' }, (s) => ({ ...s, ranges: [] })),\n Match.exhaustive,\n )(selection);\n\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: clearedSelection,\n },\n }));\n }\n\n toggleSelection(contextId: string, id: string): void {\n const selection = this.getSelection(contextId, 'multi');\n invariant(selection?.mode === 'multi', 'Selection mode is not multi');\n\n const newIds = selection.ids.includes(id)\n ? selection.ids.filter((existingId) => existingId !== id)\n : [...selection.ids, id];\n\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ids: newIds },\n },\n }));\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport { createContext } from '@radix-ui/react-context';\nimport * as Match from 'effect/Match';\nimport React, { type PropsWithChildren, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\nimport { useDefaultValue } from '@dxos/react-hooks';\n\nimport {\n type Selection,\n SelectionManager,\n type SelectionMode,\n type SelectionResult,\n defaultSelection,\n} from '../selection';\n\nconst SELECTION_NAME = 'Selection';\n\ntype SelectionContextValue = {\n selection: SelectionManager;\n};\n\nconst [SelectionContextProvider, useSelectionContext] = createContext<SelectionContextValue>(SELECTION_NAME, {\n selection: undefined as unknown as SelectionManager,\n});\n\n/**\n * Manages selection state across the app for multiple contexts.\n */\n// TODO(burdon): When is the selection removed?\nexport const SelectionProvider = ({\n children,\n selection: propsSelection,\n}: PropsWithChildren<{ selection?: SelectionManager }>) => {\n const registry = useContext(RegistryContext);\n const selection = useDefaultValue(propsSelection, () => new SelectionManager(registry));\n return <SelectionContextProvider selection={selection}>{children}</SelectionContextProvider>;\n};\n\n/**\n * Get the selection contexts.\n */\nexport const useSelectionManager = () => {\n const { selection } = useSelectionContext(SELECTION_NAME);\n return selection;\n};\n\nconst getDefaultResult = <T extends SelectionMode>(mode: T): SelectionResult<T> => {\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => s.id),\n Match.when({ mode: 'multi' }, (s) => s.ids),\n Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),\n Match.when({ mode: 'multi-range' }, (s) => s.ranges),\n Match.exhaustive,\n )(defaultSelection(mode)) as SelectionResult<T>;\n};\n\n/**\n * Get the selected objects for a given context.\n */\nexport const useSelected = <T extends SelectionMode>(\n contextId?: string,\n mode: T = 'multi' as T,\n): SelectionResult<T> => {\n const { selection } = useSelectionContext(SELECTION_NAME);\n const [state, setState] = useState<SelectionResult<T>>(() =>\n contextId && selection ? selection.getSelected(contextId, mode) : getDefaultResult(mode),\n );\n\n useEffect(() => {\n if (!contextId || !selection) {\n setState(getDefaultResult(mode));\n return;\n }\n\n // Set initial state.\n setState(selection.getSelected(contextId, mode));\n\n // Subscribe to changes.\n return selection.subscribe(() => {\n setState(selection.getSelected(contextId, mode));\n });\n }, [selection, contextId, mode]);\n\n return state;\n};\n\nexport type UseSelectionActions = {\n singleSelect: (id: string) => void;\n multiSelect: (ids: string[]) => void;\n rangeSelect: (from: string, to: string) => void;\n toggle: (id: string) => void;\n clear: () => void;\n};\n\n/**\n * Provides functions to manage the selection state for multiple contexts.\n */\n// TODO(burdon): Mode not used.\nexport const useSelectionActions = (contextIds: string[], mode: SelectionMode = 'multi'): UseSelectionActions => {\n const stableContextIds = useMemo(() => contextIds, [JSON.stringify(contextIds)]); // TODO(burdon): Avoid stringify.\n const { selection } = useSelectionContext(SELECTION_NAME);\n\n const singleSelect = useCallback(\n (id: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateSingle(contextId, id);\n }\n },\n [selection, stableContextIds],\n );\n\n const multiSelect = useCallback(\n (ids: string[]) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateMulti(contextId, ids);\n }\n },\n [selection, stableContextIds],\n );\n\n const rangeSelect = useCallback(\n (from: string, to: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateRange(contextId, from, to);\n }\n },\n [selection, stableContextIds],\n );\n\n const toggle = useCallback(\n (id: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.toggleSelection(contextId, id);\n }\n },\n [selection, stableContextIds],\n );\n\n const clear = useCallback(() => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.clearSelection(contextId);\n }\n }, [selection, stableContextIds]);\n\n return { singleSelect, multiSelect, rangeSelect, toggle, clear };\n};\n"],
5
- "mappings": ";;;;;;AAIA,SAASA,YAA2B;AAEpC,SAASC,kBAAkB;AAK3B,IAAMC,YAAY,CAACC,QAAkBA,IAAIC,KAAK,GAAA;AAKvC,IAAMC,mBAAN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AAA;IAC3B;EACF,GAAG;IAAC1B;IAAWmC;GAAiB;AAEhC,SAAO;IAAEI;IAAcG;IAAaE;IAAaE;IAAQE;EAAM;AACjE;",
6
- "names": ["Atom", "ComplexMap", "stringKey", "key", "join", "AttentionManager", "_map", "ComplexMap", "_currentAtom", "_registry", "initial", "Atom", "make", "length", "update", "current", "getCurrent", "get", "subscribeCurrent", "cb", "subscribe", "keys", "Array", "from", "atom", "_getAtom", "existing", "newAtom", "hasAttention", "isAncestor", "isRelated", "set", "nextKey", "currentKey", "currentRelatedTo", "nextRelatedTo", "currentRelatedKeys", "filter", "nextRelatedKeys", "prevRelatedKeys", "curr", "find", "next", "currentAncestorKeys", "slice", "map", "_", "i", "nextAncestorKeys", "prevAncestorKeys", "forEach", "_set", "attention", "getAttendables", "selector", "cursor", "acc", "closestAttendable", "closest", "attendableId", "getAttribute", "trigger", "document", "querySelector", "push", "split", "ATTENDABLE_PATH_SEPARATOR", "parentElement", "Set", "RegistryContext", "createContext", "Primitive", "Slot", "React", "forwardRef", "useContext", "useEffect", "useMemo", "useState", "log", "useDefaultValue", "mx", "ATTENTION_NAME", "ATTENDABLE_ATTRIBUTE", "ATTENTION_SOURCE_ATTRIBUTE", "AttentionContextProvider", "useAttentionContext", "createContext", "attention", "undefined", "path", "UNKNOWN_ATTENDABLE", "hasAttention", "isAncestor", "isRelated", "useAttention", "attendableId", "state", "setState", "useState", "key", "useMemo", "split", "ATTENDABLE_PATH_SEPARATOR", "useEffect", "get", "subscribe", "newState", "useAttended", "current", "setCurrent", "getCurrent", "subscribeCurrent", "newCurrent", "useAttentionAttributes", "attributes", "useAttentionPath", "RootAttentionProvider", "children", "propsAttention", "onChange", "registry", "useContext", "RegistryContext", "useDefaultValue", "AttentionManager", "handleFocus", "event", "log", "related", "relatedTarget", "target", "selector", "Array", "from", "document", "querySelectorAll", "map", "el", "getAttribute", "join", "prev", "next", "getAttendables", "length", "find", "id", "index", "update", "div", "role", "className", "onFocusCapture", "AttentionProvider", "nextPath", "AttendableContainer", "forwardRef", "classNames", "asChild", "props", "forwardedRef", "attentionAttrs", "Root", "Slot", "Primitive", "mx", "tabIndex", "ref", "Atom", "Match", "Schema", "invariant", "SelectionSchema", "Union", "Struct", "mode", "Literal", "id", "optional", "String", "pipe", "mutable", "ids", "Array", "from", "to", "ranges", "defaultSelection", "type", "withReturnType", "when", "exhaustive", "getSelectionSet", "selectionManager", "contextId", "Set", "context", "getSelectionContexts", "selection", "getSelection", "add", "SelectionManager", "_state", "_registry", "initial", "make", "selections", "state", "getState", "get", "subscribe", "cb", "Object", "keys", "undefined", "newSelection", "update", "getSelected", "s", "updateSingle", "updateMulti", "updateRange", "updateMultiRange", "clearSelection", "clearedSelection", "toggleSelection", "newIds", "includes", "filter", "existingId", "RegistryContext", "createContext", "Match", "React", "useCallback", "useContext", "useEffect", "useMemo", "useState", "useDefaultValue", "SELECTION_NAME", "SelectionContextProvider", "useSelectionContext", "createContext", "selection", "undefined", "SelectionProvider", "children", "propsSelection", "registry", "useContext", "RegistryContext", "useDefaultValue", "SelectionManager", "React", "useSelectionManager", "getDefaultResult", "mode", "type", "pipe", "when", "s", "id", "ids", "from", "to", "ranges", "exhaustive", "defaultSelection", "useSelected", "contextId", "state", "setState", "useState", "getSelected", "useEffect", "subscribe", "useSelectionActions", "contextIds", "stableContextIds", "useMemo", "JSON", "stringify", "singleSelect", "useCallback", "updateSingle", "multiSelect", "updateMulti", "rangeSelect", "updateRange", "toggle", "toggleSelection", "clear", "clearSelection"]
7
- }
@@ -1,9 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // src/types.ts
4
- var ATTENDABLE_PATH_SEPARATOR = "~";
5
-
6
- export {
7
- ATTENDABLE_PATH_SEPARATOR
8
- };
9
- //# sourceMappingURL=chunk-PMGNPL4M.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// NOTE: Chosen from RFC 1738's `safe` characters: http://www.faqs.org/rfcs/rfc1738.html\nexport const ATTENDABLE_PATH_SEPARATOR = '~';\n\nexport type Attention = {\n hasAttention: boolean;\n isAncestor: boolean;\n isRelated: boolean;\n};\n\nexport type CurrentState = {\n current: string[];\n};\n"],
5
- "mappings": ";;;AAKO,IAAMA,4BAA4B;",
6
- "names": ["ATTENDABLE_PATH_SEPARATOR"]
7
- }