@dxos/react-ui-attention 0.8.4-main.ead640a → 0.8.4-main.f466a3d56e

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 (74) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/chunk-D2BLVJ6Z.mjs +421 -0
  3. package/dist/lib/browser/chunk-D2BLVJ6Z.mjs.map +7 -0
  4. package/dist/lib/browser/chunk-I4VO2RQM.mjs +255 -0
  5. package/dist/lib/browser/chunk-I4VO2RQM.mjs.map +7 -0
  6. package/dist/lib/browser/index.mjs +89 -23
  7. package/dist/lib/browser/index.mjs.map +4 -4
  8. package/dist/lib/browser/meta.json +1 -1
  9. package/dist/lib/browser/testing/index.mjs +22 -5
  10. package/dist/lib/browser/testing/index.mjs.map +3 -3
  11. package/dist/lib/browser/types/index.mjs +29 -0
  12. package/dist/lib/browser/types/index.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-6INLBC62.mjs +423 -0
  14. package/dist/lib/node-esm/chunk-6INLBC62.mjs.map +7 -0
  15. package/dist/lib/node-esm/chunk-ZTUVSH4P.mjs +256 -0
  16. package/dist/lib/node-esm/chunk-ZTUVSH4P.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +89 -23
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +22 -5
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/lib/node-esm/types/index.mjs +30 -0
  23. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  24. package/dist/types/src/attention.d.ts +60 -20
  25. package/dist/types/src/attention.d.ts.map +1 -1
  26. package/dist/types/src/components/AttentionGlyph/AttentionGlyph.d.ts.map +1 -0
  27. package/dist/types/src/components/AttentionGlyph/AttentionGlyph.stories.d.ts.map +1 -0
  28. package/dist/types/src/components/AttentionGlyph/index.d.ts +2 -0
  29. package/dist/types/src/components/AttentionGlyph/index.d.ts.map +1 -0
  30. package/dist/types/src/components/AttentionProvider/AttentionProvider.d.ts +34 -0
  31. package/dist/types/src/components/AttentionProvider/AttentionProvider.d.ts.map +1 -0
  32. package/dist/types/src/components/AttentionProvider/AttentionProvider.stories.d.ts.map +1 -0
  33. package/dist/types/src/components/AttentionProvider/index.d.ts +2 -0
  34. package/dist/types/src/components/AttentionProvider/index.d.ts.map +1 -0
  35. package/dist/types/src/components/{SelectionProvider.d.ts → SelectionProvider/SelectionProvider.d.ts} +7 -6
  36. package/dist/types/src/components/SelectionProvider/SelectionProvider.d.ts.map +1 -0
  37. package/dist/types/src/components/SelectionProvider/index.d.ts +2 -0
  38. package/dist/types/src/components/SelectionProvider/index.d.ts.map +1 -0
  39. package/dist/types/src/selection.d.ts +23 -3
  40. package/dist/types/src/selection.d.ts.map +1 -1
  41. package/dist/types/src/testing/decorators/withAttention.d.ts +5 -1
  42. package/dist/types/src/testing/decorators/withAttention.d.ts.map +1 -1
  43. package/dist/types/src/types/index.d.ts +3 -0
  44. package/dist/types/src/types/index.d.ts.map +1 -0
  45. package/dist/types/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +34 -32
  47. package/src/attention.test.ts +188 -27
  48. package/src/attention.ts +179 -75
  49. package/src/components/{AttentionGlyph.stories.tsx → AttentionGlyph/AttentionGlyph.stories.tsx} +2 -2
  50. package/src/components/{AttentionGlyph.tsx → AttentionGlyph/AttentionGlyph.tsx} +13 -6
  51. package/src/components/AttentionGlyph/index.ts +5 -0
  52. package/src/components/{AttentionProvider.stories.tsx → AttentionProvider/AttentionProvider.stories.tsx} +3 -4
  53. package/src/components/AttentionProvider/AttentionProvider.tsx +176 -0
  54. package/src/components/AttentionProvider/index.ts +5 -0
  55. package/src/components/SelectionProvider/SelectionProvider.tsx +174 -0
  56. package/src/components/SelectionProvider/index.ts +5 -0
  57. package/src/selection.ts +121 -79
  58. package/src/testing/decorators/withAttention.ts +22 -4
  59. package/src/types/index.ts +9 -0
  60. package/dist/lib/browser/chunk-HELLA3BH.mjs +0 -675
  61. package/dist/lib/browser/chunk-HELLA3BH.mjs.map +0 -7
  62. package/dist/lib/node-esm/chunk-FBZV7QG7.mjs +0 -677
  63. package/dist/lib/node-esm/chunk-FBZV7QG7.mjs.map +0 -7
  64. package/dist/types/src/components/AttentionGlyph.d.ts.map +0 -1
  65. package/dist/types/src/components/AttentionGlyph.stories.d.ts.map +0 -1
  66. package/dist/types/src/components/AttentionProvider.d.ts +0 -38
  67. package/dist/types/src/components/AttentionProvider.d.ts.map +0 -1
  68. package/dist/types/src/components/AttentionProvider.stories.d.ts.map +0 -1
  69. package/dist/types/src/components/SelectionProvider.d.ts.map +0 -1
  70. package/src/components/AttentionProvider.tsx +0 -201
  71. package/src/components/SelectionProvider.tsx +0 -120
  72. /package/dist/types/src/components/{AttentionGlyph.d.ts → AttentionGlyph/AttentionGlyph.d.ts} +0 -0
  73. /package/dist/types/src/components/{AttentionGlyph.stories.d.ts → AttentionGlyph/AttentionGlyph.stories.d.ts} +0 -0
  74. /package/dist/types/src/components/{AttentionProvider.stories.d.ts → AttentionProvider/AttentionProvider.stories.d.ts} +0 -0
@@ -0,0 +1,255 @@
1
+ import {
2
+ AttentionManager,
3
+ SelectionManager,
4
+ defaultSelection,
5
+ getAttendables
6
+ } from "./chunk-D2BLVJ6Z.mjs";
7
+
8
+ // src/components/AttentionProvider/AttentionProvider.tsx
9
+ import { RegistryContext } from "@effect-atom/atom-react";
10
+ import { createContext } from "@radix-ui/react-context";
11
+ import { Primitive } from "@radix-ui/react-primitive";
12
+ import { Slot } from "@radix-ui/react-slot";
13
+ import React, { forwardRef, useCallback, useContext, useEffect, useMemo, useState } from "react";
14
+ import { log } from "@dxos/log";
15
+ import { useDefaultValue } from "@dxos/react-hooks";
16
+ import { mx } from "@dxos/ui-theme";
17
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-attention/src/components/AttentionProvider/AttentionProvider.tsx";
18
+ var ATTENTION_NAME = "Attention";
19
+ var ATTENDABLE_ATTRIBUTE = "data-attendable-id";
20
+ var ATTENTION_SOURCE_ATTRIBUTE = "data-w-attention-source";
21
+ var [AttentionContextProvider, useAttentionContext] = createContext(ATTENTION_NAME, {
22
+ attention: void 0
23
+ });
24
+ var UNKNOWN_ATTENDABLE = {
25
+ hasAttention: false,
26
+ isAncestor: false,
27
+ isRelated: false
28
+ };
29
+ var useAttention = (attendableId) => {
30
+ const { attention } = useAttentionContext(ATTENTION_NAME);
31
+ const [state, setState] = useState(UNKNOWN_ATTENDABLE);
32
+ useEffect(() => {
33
+ if (!attendableId || !attention) {
34
+ setState(UNKNOWN_ATTENDABLE);
35
+ return;
36
+ }
37
+ const currentState = attention.get(attendableId);
38
+ setState(currentState);
39
+ return attention.subscribe(attendableId, (newState) => {
40
+ setState(newState);
41
+ });
42
+ }, [
43
+ attention,
44
+ attendableId
45
+ ]);
46
+ return state;
47
+ };
48
+ var useAttended = () => {
49
+ const { attention } = useAttentionContext(ATTENTION_NAME);
50
+ const [current, setCurrent] = useState([]);
51
+ useEffect(() => {
52
+ if (!attention) {
53
+ return;
54
+ }
55
+ setCurrent(attention.getCurrent());
56
+ return attention.subscribeCurrent((newCurrent) => {
57
+ setCurrent(newCurrent);
58
+ });
59
+ }, [
60
+ attention
61
+ ]);
62
+ return current;
63
+ };
64
+ var useAttentionAttributes = (attendableId) => {
65
+ const { hasAttention } = useAttention(attendableId);
66
+ return useMemo(() => {
67
+ const attributes = {
68
+ [ATTENDABLE_ATTRIBUTE]: attendableId
69
+ };
70
+ if (hasAttention) {
71
+ attributes[ATTENTION_SOURCE_ATTRIBUTE] = "true";
72
+ }
73
+ return attributes;
74
+ }, [
75
+ attendableId,
76
+ hasAttention
77
+ ]);
78
+ };
79
+ var RootAttentionProvider = ({ children, attention: propsAttention, onChange }) => {
80
+ const registry = useContext(RegistryContext);
81
+ const attention = useDefaultValue(propsAttention, () => new AttentionManager(registry));
82
+ const handleFocus = useCallback((event) => {
83
+ log("focus", {
84
+ related: event.relatedTarget,
85
+ target: event.target
86
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 84, S: void 0 });
87
+ const selector = [
88
+ "[data-attendable-id]",
89
+ ...Array.from(document.querySelectorAll("[aria-controls]")).map((el) => `[id="${el.getAttribute("aria-controls")}"]`)
90
+ ].join(",");
91
+ const prev = attention.getCurrent();
92
+ const next = getAttendables(selector, event.target);
93
+ if (next.length > 0 && (prev.length !== next.length || !!prev.find((id, index) => next[index] !== id))) {
94
+ attention.update(next);
95
+ onChange?.(next);
96
+ }
97
+ }, [
98
+ attention,
99
+ onChange
100
+ ]);
101
+ return /* @__PURE__ */ React.createElement(AttentionContextProvider, {
102
+ attention
103
+ }, /* @__PURE__ */ React.createElement("div", {
104
+ className: "contents",
105
+ onFocusCapture: handleFocus
106
+ }, children));
107
+ };
108
+ var AttendableContainer = /* @__PURE__ */ forwardRef(({ id, classNames, children, asChild, ...props }, forwardedRef) => {
109
+ const attentionAttrs = useAttentionAttributes(id);
110
+ const Comp = asChild ? Slot : Primitive.div;
111
+ return /* @__PURE__ */ React.createElement(Comp, {
112
+ role: "none",
113
+ ...props,
114
+ ...attentionAttrs,
115
+ className: mx("dx-attention-surface", props.tabIndex === 0 && "dx-focus-ring-inset-over-all", classNames),
116
+ ref: forwardedRef
117
+ }, children);
118
+ });
119
+
120
+ // src/components/SelectionProvider/SelectionProvider.tsx
121
+ import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
122
+ import { createContext as createContext2 } from "@radix-ui/react-context";
123
+ import * as Match from "effect/Match";
124
+ import React2, { useCallback as useCallback2, useContext as useContext2, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
125
+ import { useDefaultValue as useDefaultValue2 } from "@dxos/react-hooks";
126
+ var SELECTION_NAME = "Selection";
127
+ var [SelectionContextProvider, useSelectionContext] = createContext2(SELECTION_NAME, {
128
+ selection: void 0
129
+ });
130
+ var SelectionProvider = ({ children, selection: selectionProp }) => {
131
+ const registry = useContext2(RegistryContext2);
132
+ const selection = useDefaultValue2(selectionProp, () => new SelectionManager(registry));
133
+ return /* @__PURE__ */ React2.createElement(SelectionContextProvider, {
134
+ selection
135
+ }, children);
136
+ };
137
+ var useSelectionManager = () => {
138
+ const { selection } = useSelectionContext(SELECTION_NAME);
139
+ return selection;
140
+ };
141
+ var getDefaultResult = (mode) => {
142
+ return Match.type().pipe(Match.when({
143
+ mode: "single"
144
+ }, (selection) => selection.id), Match.when({
145
+ mode: "multi"
146
+ }, (selection) => selection.ids), Match.when({
147
+ mode: "range"
148
+ }, (selection) => selection.from && selection.to ? {
149
+ from: selection.from,
150
+ to: selection.to
151
+ } : void 0), Match.when({
152
+ mode: "multi-range"
153
+ }, (selection) => selection.ranges), Match.exhaustive)(defaultSelection(mode));
154
+ };
155
+ var useSelected = (contextId, mode = "multi") => {
156
+ const { selection } = useSelectionContext(SELECTION_NAME);
157
+ const [state, setState] = useState2(() => contextId && selection ? selection.getSelected(contextId, mode) : getDefaultResult(mode));
158
+ useEffect2(() => {
159
+ if (!contextId || !selection) {
160
+ setState(getDefaultResult(mode));
161
+ return;
162
+ }
163
+ setState(selection.getSelected(contextId, mode));
164
+ return selection.subscribe(() => {
165
+ setState(selection.getSelected(contextId, mode));
166
+ });
167
+ }, [
168
+ selection,
169
+ contextId,
170
+ mode
171
+ ]);
172
+ return state;
173
+ };
174
+ var useSelectionActions = (contextIds) => {
175
+ const stableContextIds = useMemo2(() => contextIds, [
176
+ JSON.stringify(contextIds)
177
+ ]);
178
+ const { selection } = useSelectionContext(SELECTION_NAME);
179
+ const singleSelect = useCallback2((id) => {
180
+ if (!selection) {
181
+ return;
182
+ }
183
+ for (const contextId of stableContextIds) {
184
+ selection.updateSingle(contextId, id);
185
+ }
186
+ }, [
187
+ selection,
188
+ stableContextIds
189
+ ]);
190
+ const multiSelect = useCallback2((ids) => {
191
+ if (!selection) {
192
+ return;
193
+ }
194
+ for (const contextId of stableContextIds) {
195
+ selection.updateMulti(contextId, ids);
196
+ }
197
+ }, [
198
+ selection,
199
+ stableContextIds
200
+ ]);
201
+ const rangeSelect = useCallback2((from, to) => {
202
+ if (!selection) {
203
+ return;
204
+ }
205
+ for (const contextId of stableContextIds) {
206
+ selection.updateRange(contextId, from, to);
207
+ }
208
+ }, [
209
+ selection,
210
+ stableContextIds
211
+ ]);
212
+ const toggle = useCallback2((id) => {
213
+ if (!selection) {
214
+ return;
215
+ }
216
+ for (const contextId of stableContextIds) {
217
+ selection.toggleSelection(contextId, id);
218
+ }
219
+ }, [
220
+ selection,
221
+ stableContextIds
222
+ ]);
223
+ const clear = useCallback2(() => {
224
+ if (!selection) {
225
+ return;
226
+ }
227
+ for (const contextId of stableContextIds) {
228
+ selection.clearSelection(contextId);
229
+ }
230
+ }, [
231
+ selection,
232
+ stableContextIds
233
+ ]);
234
+ return {
235
+ singleSelect,
236
+ multiSelect,
237
+ rangeSelect,
238
+ toggle,
239
+ clear
240
+ };
241
+ };
242
+
243
+ export {
244
+ useAttentionContext,
245
+ useAttention,
246
+ useAttended,
247
+ useAttentionAttributes,
248
+ RootAttentionProvider,
249
+ AttendableContainer,
250
+ SelectionProvider,
251
+ useSelectionManager,
252
+ useSelected,
253
+ useSelectionActions
254
+ };
255
+ //# sourceMappingURL=chunk-I4VO2RQM.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/AttentionProvider/AttentionProvider.tsx", "../../../src/components/SelectionProvider/SelectionProvider.tsx"],
4
+ "sourcesContent": ["//\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 useCallback,\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 { type Attention, AttentionManager, getAttendables } from '../../attention';\n\nconst ATTENTION_NAME = 'Attention';\nconst ATTENDABLE_ATTRIBUTE = 'data-attendable-id';\nconst ATTENTION_SOURCE_ATTRIBUTE = 'data-w-attention-source';\n\ntype AttentionContextValue = {\n attention: AttentionManager;\n};\n\nconst [AttentionContextProvider, useAttentionContext] = createContext<AttentionContextValue>(ATTENTION_NAME, {\n attention: undefined as unknown as AttentionManager,\n});\n\nconst UNKNOWN_ATTENDABLE = { hasAttention: false, isAncestor: false, isRelated: false } as Attention;\n\n/**\n * Subscribe to the attention state for a qualified graph ID.\n */\n// TODO(burdon): Unify with seleciton and change to contextId?\nconst useAttention = (attendableId?: string): Attention => {\n const { attention } = useAttentionContext(ATTENTION_NAME);\n const [state, setState] = useState<Attention>(UNKNOWN_ATTENDABLE);\n useEffect(() => {\n if (!attendableId || !attention) {\n setState(UNKNOWN_ATTENDABLE);\n return;\n }\n\n const currentState = attention.get(attendableId);\n setState(currentState);\n\n return attention.subscribe(attendableId, (newState) => {\n setState(newState);\n });\n }, [attention, attendableId]);\n\n return state;\n};\n\nconst useAttended = () => {\n const { attention } = useAttentionContext(ATTENTION_NAME);\n const [current, setCurrent] = useState<readonly string[]>([]);\n useEffect(() => {\n if (!attention) {\n return;\n }\n\n setCurrent(attention.getCurrent());\n\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 */\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\ntype RootAttentionProviderProps = PropsWithChildren<{\n attention?: AttentionManager;\n onChange?: (nextAttended: string[]) => void;\n}>;\n\nconst RootAttentionProvider = ({ children, attention: propsAttention, onChange }: RootAttentionProviderProps) => {\n const registry = useContext(RegistryContext);\n const attention = useDefaultValue(propsAttention, () => new AttentionManager(registry));\n\n const handleFocus = useCallback(\n (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 [attention, onChange],\n );\n\n return (\n <AttentionContextProvider attention={attention}>\n <div className='contents' onFocusCapture={handleFocus}>\n {children}\n </div>\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,\n * and when rendering content in those cases it is not necessary to also render an `AttendableContainer`.\n * This component is primarily for Storybook stories and other testing scenarios,\n * 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 Comp = asChild ? Slot : Primitive.div;\n return (\n <Comp\n role='none'\n {...props}\n {...attentionAttrs}\n className={mx('dx-attention-surface', props.tabIndex === 0 && 'dx-focus-ring-inset-over-all', classNames)}\n ref={forwardedRef}\n >\n {children}\n </Comp>\n );\n },\n);\n\nexport {\n RootAttentionProvider,\n AttendableContainer,\n useAttentionContext,\n useAttention,\n useAttended,\n useAttentionAttributes,\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\n// Default value lets consumers like `useSelected` render outside a\n// `SelectionProvider` (e.g. isolated stories) without throwing —\n// `selection` reads as `undefined` and the hook falls back to the\n// per-mode default result. Without this default, Radix `createContext`\n// throws \"Selection must be used within Selection\" on every consumer.\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 */\nexport const SelectionProvider = ({\n children,\n selection: selectionProp,\n}: PropsWithChildren<{ selection?: SelectionManager }>) => {\n const registry = useContext(RegistryContext);\n const selection = useDefaultValue(selectionProp, () => new SelectionManager(registry));\n\n return <SelectionContextProvider selection={selection}>{children}</SelectionContextProvider>;\n};\n\n/**\n * Get the selection contexts.\n */\nexport const useSelectionManager = (): SelectionManager => {\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' }, (selection) => selection.id),\n Match.when({ mode: 'multi' }, (selection) => selection.ids),\n Match.when({ mode: 'range' }, (selection) =>\n selection.from && selection.to ? { from: selection.from, to: selection.to } : undefined,\n ),\n Match.when({ mode: 'multi-range' }, (selection) => selection.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 */\nexport const useSelectionActions = (contextIds: string[]): UseSelectionActions => {\n const stableContextIds = useMemo(() => contextIds, [JSON.stringify(contextIds)]);\n const { selection } = useSelectionContext(SELECTION_NAME);\n\n // No-op when rendered outside a `SelectionProvider` (e.g. an isolated\n // story or a test harness) — `selection` is `undefined` from the\n // context default value. Matches the pre-co-locate behaviour.\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": "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",
6
+ "names": ["RegistryContext", "createContext", "Primitive", "Slot", "React", "forwardRef", "useCallback", "useContext", "useEffect", "useMemo", "useState", "log", "useDefaultValue", "mx", "ATTENTION_NAME", "ATTENTION_SOURCE_ATTRIBUTE", "AttentionContextProvider", "attention", "undefined", "UNKNOWN_ATTENDABLE", "isAncestor", "isRelated", "setState", "useState", "useEffect", "attendableId", "subscribe", "newState", "useAttended", "setCurrent", "newCurrent", "attributes", "ATTENDABLE_ATTRIBUTE", "hasAttention", "useDefaultValue", "propsAttention", "AttentionManager", "registry", "handleFocus", "useCallback", "event", "log", "target", "selector", "join", "prev", "getCurrent", "next", "onChange", "div", "className", "onFocusCapture", "children", "Comp", "role", "attentionAttrs", "ref", "RootAttentionProvider", "RegistryContext", "createContext", "Match", "React", "useCallback", "useContext", "useEffect", "useMemo", "useState", "useDefaultValue", "SELECTION_NAME", "SelectionContextProvider", "useSelectionContext", "createContext", "selection", "undefined", "SelectionProvider", "children", "selectionProp", "registry", "useContext", "RegistryContext", "useDefaultValue", "SelectionManager", "React", "useSelectionManager", "getDefaultResult", "mode", "type", "pipe", "when", "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,53 +1,119 @@
1
1
  import {
2
- ATTENABLE_ATTRIBUTE,
3
- ATTENDABLE_PATH_SEPARATOR,
4
- ATTENTION_NAME,
5
- ATTENTION_SOURCE_ATTRIBUTE,
6
2
  AttendableContainer,
7
- AttentionGlyph,
8
- AttentionManager,
9
- AttentionProvider,
10
- AttentionSchema,
11
3
  RootAttentionProvider,
12
- SelectionManager,
13
4
  SelectionProvider,
14
- SelectionSchema,
15
- Syncing,
16
- defaultSelection,
17
- getAttendables,
18
- getSelectionSet,
19
5
  useAttended,
20
6
  useAttention,
21
7
  useAttentionAttributes,
22
8
  useAttentionContext,
23
- useAttentionPath,
24
9
  useSelected,
25
10
  useSelectionActions,
26
11
  useSelectionManager
27
- } from "./chunk-HELLA3BH.mjs";
12
+ } from "./chunk-I4VO2RQM.mjs";
13
+ import {
14
+ AttentionManager,
15
+ SelectionManager,
16
+ SelectionSchema,
17
+ defaultSelection,
18
+ expandAttendableId,
19
+ getAttendables,
20
+ getLinkedVariant,
21
+ getParentId,
22
+ getSegmentId,
23
+ getSelectionSet,
24
+ isLinkedSegment,
25
+ linkedSegment
26
+ } from "./chunk-D2BLVJ6Z.mjs";
27
+
28
+ // src/components/AttentionGlyph/AttentionGlyph.tsx
29
+ import React, { forwardRef, useMemo } from "react";
30
+ import { Icon } from "@dxos/react-ui";
31
+ import { mx } from "@dxos/ui-theme";
32
+ var attentionGlyphStyles = mx("inline-block rounded-xs w-3 h-3 bg-transparent text-accent-text transition-colors", "[[data-contains-attended=true]_&]:bg-attention-contains", "[[data-attention=true]_&]:bg-accent-surface", "[[data-attention=true]_&]:text-accent-foreground", "[[aria-current][data-attention=true]_&]:bg-accent-surface", "[[aria-current][data-attention=true]_&]:text-accent-foreground", '[[aria-selected="true"][data-attention=true]_&]:bg-accent-surface', '[[aria-selected="true"][data-attention=true]_&]:text-accent-foreground');
33
+ var presenceIconStyles = mx("w-3 h-3");
34
+ var PresenceOne = () => {
35
+ return /* @__PURE__ */ React.createElement("svg", {
36
+ width: "12",
37
+ height: "12",
38
+ viewBox: "0 0 12 12",
39
+ className: presenceIconStyles,
40
+ fill: "none",
41
+ xmlns: "http://www.w3.org/2000/svg"
42
+ }, /* @__PURE__ */ React.createElement("circle", {
43
+ cx: "6",
44
+ cy: "6",
45
+ r: "2.5",
46
+ fill: "currentColor"
47
+ }));
48
+ };
49
+ var PresenceMany = () => {
50
+ return /* @__PURE__ */ React.createElement("svg", {
51
+ width: "12",
52
+ height: "12",
53
+ viewBox: "0 0 12 12",
54
+ className: presenceIconStyles,
55
+ fill: "none",
56
+ xmlns: "http://www.w3.org/2000/svg"
57
+ }, /* @__PURE__ */ React.createElement("path", {
58
+ d: "M6.75 8.27311C7.38815 7.72296 7.79212 6.90866 7.79212 6C7.79212 5.09134 7.38815 4.27704 6.75 3.72689C7.06722 3.58122 7.42019 3.5 7.79212 3.5C9.17283 3.5 10.2921 4.61929 10.2921 6C10.2921 7.38071 9.17283 8.5 7.79212 8.5C7.42019 8.5 7.06723 8.41878 6.75 8.27311Z",
59
+ fill: "currentColor"
60
+ }), /* @__PURE__ */ React.createElement("circle", {
61
+ cx: "4.25",
62
+ cy: "6",
63
+ r: "2.5",
64
+ fill: "currentColor"
65
+ }));
66
+ };
67
+ var Syncing = () => {
68
+ const animationProps = useMemo(() => ({
69
+ // Synchronize animations.
70
+ animationDelay: `-${Date.now() % 2e3}ms`
71
+ }), []);
72
+ return /* @__PURE__ */ React.createElement("div", {
73
+ role: "status",
74
+ className: "flex items-center"
75
+ }, /* @__PURE__ */ React.createElement(Icon, {
76
+ icon: "ph--circle-notch--bold",
77
+ size: 3,
78
+ style: animationProps,
79
+ classNames: "text-subdued animate-[spin_2s_linear_infinite]"
80
+ }));
81
+ };
82
+ var AttentionGlyph = /* @__PURE__ */ forwardRef(({ presence, attended, syncing, containsAttended, classNames, ...props }, forwardedRef) => {
83
+ const icon = syncing ? /* @__PURE__ */ React.createElement(Syncing, null) : presence === "many" ? /* @__PURE__ */ React.createElement(PresenceMany, null) : presence === "one" ? /* @__PURE__ */ React.createElement(PresenceOne, null) : null;
84
+ return /* @__PURE__ */ React.createElement("div", {
85
+ className: "flex group",
86
+ "data-attention": attended,
87
+ "data-contains-attended": containsAttended
88
+ }, /* @__PURE__ */ React.createElement("span", {
89
+ role: "none",
90
+ ...props,
91
+ className: mx(attentionGlyphStyles, classNames),
92
+ ref: forwardedRef
93
+ }, icon));
94
+ });
28
95
  export {
29
- ATTENABLE_ATTRIBUTE,
30
- ATTENDABLE_PATH_SEPARATOR,
31
- ATTENTION_NAME,
32
- ATTENTION_SOURCE_ATTRIBUTE,
33
96
  AttendableContainer,
34
97
  AttentionGlyph,
35
98
  AttentionManager,
36
- AttentionProvider,
37
- AttentionSchema,
38
99
  RootAttentionProvider,
39
100
  SelectionManager,
40
101
  SelectionProvider,
41
102
  SelectionSchema,
42
103
  Syncing,
43
104
  defaultSelection,
105
+ expandAttendableId,
44
106
  getAttendables,
107
+ getLinkedVariant,
108
+ getParentId,
109
+ getSegmentId,
45
110
  getSelectionSet,
111
+ isLinkedSegment,
112
+ linkedSegment,
46
113
  useAttended,
47
114
  useAttention,
48
115
  useAttentionAttributes,
49
116
  useAttentionContext,
50
- useAttentionPath,
51
117
  useSelected,
52
118
  useSelectionActions,
53
119
  useSelectionManager
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
3
+ "sources": ["../../../src/components/AttentionGlyph/AttentionGlyph.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Primitive } from '@radix-ui/react-primitive';\nimport React, { type CSSProperties, type ComponentPropsWithRef, forwardRef, useMemo } from 'react';\n\nimport { Icon, type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nconst attentionGlyphStyles = mx(\n 'inline-block rounded-xs w-3 h-3 bg-transparent text-accent-text transition-colors',\n '[[data-contains-attended=true]_&]:bg-attention-contains',\n '[[data-attention=true]_&]:bg-accent-surface',\n '[[data-attention=true]_&]:text-accent-foreground',\n '[[aria-current][data-attention=true]_&]:bg-accent-surface',\n '[[aria-current][data-attention=true]_&]:text-accent-foreground',\n '[[aria-selected=\"true\"][data-attention=true]_&]:bg-accent-surface',\n '[[aria-selected=\"true\"][data-attention=true]_&]:text-accent-foreground',\n);\n\nconst presenceIconStyles = mx('w-3 h-3');\n\nconst PresenceOne = () => {\n return (\n <svg\n width='12'\n height='12'\n viewBox='0 0 12 12'\n className={presenceIconStyles}\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n >\n <circle cx='6' cy='6' r='2.5' fill='currentColor' />\n </svg>\n );\n};\n\nconst PresenceMany = () => {\n return (\n <svg\n width='12'\n height='12'\n viewBox='0 0 12 12'\n className={presenceIconStyles}\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n >\n <path\n d='M6.75 8.27311C7.38815 7.72296 7.79212 6.90866 7.79212 6C7.79212 5.09134 7.38815 4.27704 6.75 3.72689C7.06722 3.58122 7.42019 3.5 7.79212 3.5C9.17283 3.5 10.2921 4.61929 10.2921 6C10.2921 7.38071 9.17283 8.5 7.79212 8.5C7.42019 8.5 7.06723 8.41878 6.75 8.27311Z'\n fill='currentColor'\n />\n <circle cx='4.25' cy='6' r='2.5' fill='currentColor' />\n </svg>\n );\n};\n\nexport const Syncing = () => {\n const animationProps = useMemo<CSSProperties>(\n () => ({\n // Synchronize animations.\n animationDelay: `-${Date.now() % 2_000}ms`,\n }),\n [],\n );\n\n return (\n <div role='status' className='flex items-center'>\n <Icon\n icon='ph--circle-notch--bold'\n size={3}\n style={animationProps}\n classNames='text-subdued animate-[spin_2s_linear_infinite]'\n />\n </div>\n );\n};\n\nexport type AttentionGlyphProps = {\n attended?: boolean;\n containsAttended?: boolean;\n syncing?: boolean;\n presence?: 'none' | 'one' | 'many';\n} & ThemedClassName<Omit<ComponentPropsWithRef<typeof Primitive.span>, 'children'>>;\n\nexport const AttentionGlyph = forwardRef<HTMLSpanElement, AttentionGlyphProps>(\n ({ presence, attended, syncing, containsAttended, classNames, ...props }, forwardedRef) => {\n const icon = syncing ? (\n <Syncing />\n ) : presence === 'many' ? (\n <PresenceMany />\n ) : presence === 'one' ? (\n <PresenceOne />\n ) : null;\n\n return (\n <div className='flex group' data-attention={attended} data-contains-attended={containsAttended}>\n <span role='none' {...props} className={mx(attentionGlyphStyles, classNames)} ref={forwardedRef}>\n {icon}\n </span>\n </div>\n );\n },\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAOA,SAAyDC,YAAYC,eAAe;AAE3F,SAASC,YAAkC;AAC3C,SAASC,UAAU;AAEnB,IAAMC,uBAAuBD,GAC3B,qFACA,2DACA,+CACA,oDACA,6DACA,kEACA,qEACA,wEAAA;AAGF,IAAME,qBAAqBF,GAAG,SAAA;AAE9B,IAAMG,cAAc,MAAA;AAClB,SACE,sBAAA,cAACC,OAAAA;IACCC,OAAM;IACNC,QAAO;IACPC,SAAQ;IACRC,WAAWN;IACXO,MAAK;IACLC,OAAM;KAEN,sBAAA,cAACC,UAAAA;IAAOC,IAAG;IAAIC,IAAG;IAAIC,GAAE;IAAML,MAAK;;AAGzC;AAEA,IAAMM,eAAe,MAAA;AACnB,SACE,sBAAA,cAACX,OAAAA;IACCC,OAAM;IACNC,QAAO;IACPC,SAAQ;IACRC,WAAWN;IACXO,MAAK;IACLC,OAAM;KAEN,sBAAA,cAACM,QAAAA;IACCC,GAAE;IACFR,MAAK;MAEP,sBAAA,cAACE,UAAAA;IAAOC,IAAG;IAAOC,IAAG;IAAIC,GAAE;IAAML,MAAK;;AAG5C;AAEO,IAAMS,UAAU,MAAA;AACrB,QAAMC,iBAAiBrB,QACrB,OAAO;;IAELsB,gBAAgB,IAAIC,KAAKC,IAAG,IAAK,GAAA;EACnC,IACA,CAAA,CAAE;AAGJ,SACE,sBAAA,cAACC,OAAAA;IAAIC,MAAK;IAAShB,WAAU;KAC3B,sBAAA,cAACT,MAAAA;IACC0B,MAAK;IACLC,MAAM;IACNC,OAAOR;IACPS,YAAW;;AAInB;AASO,IAAMC,iBAAiBhC,2BAC5B,CAAC,EAAEiC,UAAUC,UAAUC,SAASC,kBAAkBL,YAAY,GAAGM,MAAAA,GAASC,iBAAAA;AACxE,QAAMV,OAAOO,UACX,sBAAA,cAACd,SAAAA,IAAAA,IACCY,aAAa,SACf,sBAAA,cAACf,cAAAA,IAAAA,IACCe,aAAa,QACf,sBAAA,cAAC3B,aAAAA,IAAAA,IACC;AAEJ,SACE,sBAAA,cAACoB,OAAAA;IAAIf,WAAU;IAAa4B,kBAAgBL;IAAUM,0BAAwBJ;KAC5E,sBAAA,cAACK,QAAAA;IAAKd,MAAK;IAAQ,GAAGU;IAAO1B,WAAWR,GAAGC,sBAAsB2B,UAAAA;IAAaW,KAAKJ;KAChFV,IAAAA,CAAAA;AAIT,CAAA;",
6
+ "names": ["React", "forwardRef", "useMemo", "Icon", "mx", "attentionGlyphStyles", "presenceIconStyles", "PresenceOne", "svg", "width", "height", "viewBox", "className", "fill", "xmlns", "circle", "cx", "cy", "r", "PresenceMany", "path", "d", "Syncing", "animationProps", "animationDelay", "Date", "now", "div", "role", "icon", "size", "style", "classNames", "AttentionGlyph", "presence", "attended", "syncing", "containsAttended", "props", "forwardedRef", "data-attention", "data-contains-attended", "span", "ref"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/attention.ts":{"bytes":16979,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/components/AttentionGlyph.tsx":{"bytes":11199,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/components/AttentionProvider.tsx":{"bytes":21193,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"src/attention.ts","kind":"import-statement","original":"../attention"}],"format":"esm"},"src/selection.ts":{"bytes":23117,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"format":"esm"},"src/components/SelectionProvider.tsx":{"bytes":11930,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"src/selection.ts","kind":"import-statement","original":"../selection"}],"format":"esm"},"src/components/index.ts":{"bytes":708,"imports":[{"path":"src/components/AttentionGlyph.tsx","kind":"import-statement","original":"./AttentionGlyph"},{"path":"src/components/AttentionProvider.tsx","kind":"import-statement","original":"./AttentionProvider"},{"path":"src/components/SelectionProvider.tsx","kind":"import-statement","original":"./SelectionProvider"}],"format":"esm"},"src/index.ts":{"bytes":645,"imports":[{"path":"src/attention.ts","kind":"import-statement","original":"./attention"},{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/selection.ts","kind":"import-statement","original":"./selection"}],"format":"esm"},"src/testing/decorators/withAttention.ts":{"bytes":1279,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"../../components"}],"format":"esm"},"src/testing/decorators/index.ts":{"bytes":493,"imports":[{"path":"src/testing/decorators/withAttention.ts","kind":"import-statement","original":"./withAttention"}],"format":"esm"},"src/testing/index.ts":{"bytes":471,"imports":[{"path":"src/testing/decorators/index.ts","kind":"import-statement","original":"./decorators"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-HELLA3BH.mjs","kind":"import-statement"}],"exports":["ATTENABLE_ATTRIBUTE","ATTENDABLE_PATH_SEPARATOR","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttendableContainer","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","SelectionManager","SelectionProvider","SelectionSchema","Syncing","defaultSelection","getAttendables","getSelectionSet","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useAttentionPath","useSelected","useSelectionActions","useSelectionManager"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":1115},"dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":670},"dist/lib/browser/testing/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-HELLA3BH.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true}],"exports":["withAttention"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/decorators/withAttention.ts":{"bytesInOutput":148},"src/testing/decorators/index.ts":{"bytesInOutput":0},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":320},"dist/lib/browser/chunk-HELLA3BH.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":41111},"dist/lib/browser/chunk-HELLA3BH.mjs":{"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["ATTENABLE_ATTRIBUTE","ATTENDABLE_PATH_SEPARATOR","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttendableContainer","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","SelectionManager","SelectionProvider","SelectionSchema","Syncing","defaultSelection","getAttendables","getSelectionSet","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useAttentionPath","useSelected","useSelectionActions","useSelectionManager"],"inputs":{"src/attention.ts":{"bytesInOutput":3762},"src/components/AttentionGlyph.tsx":{"bytesInOutput":3714},"src/components/AttentionProvider.tsx":{"bytesInOutput":3705},"src/selection.ts":{"bytesInOutput":6340},"src/components/SelectionProvider.tsx":{"bytesInOutput":2760},"src/components/index.ts":{"bytesInOutput":0}},"bytes":21013}}}
1
+ {"inputs":{"src/attention.ts":{"bytes":25933,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true}],"format":"esm"},"src/components/AttentionGlyph/AttentionGlyph.tsx":{"bytes":9920,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/components/AttentionGlyph/index.ts":{"bytes":394,"imports":[{"path":"src/components/AttentionGlyph/AttentionGlyph.tsx","kind":"import-statement","original":"./AttentionGlyph"}],"format":"esm"},"src/components/AttentionProvider/AttentionProvider.tsx":{"bytes":18161,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"src/attention.ts","kind":"import-statement","original":"../../attention"}],"format":"esm"},"src/components/AttentionProvider/index.ts":{"bytes":401,"imports":[{"path":"src/components/AttentionProvider/AttentionProvider.tsx","kind":"import-statement","original":"./AttentionProvider"}],"format":"esm"},"src/selection.ts":{"bytes":27361,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/components/SelectionProvider/SelectionProvider.tsx":{"bytes":16598,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"src/selection.ts","kind":"import-statement","original":"../../selection"}],"format":"esm"},"src/components/SelectionProvider/index.ts":{"bytes":401,"imports":[{"path":"src/components/SelectionProvider/SelectionProvider.tsx","kind":"import-statement","original":"./SelectionProvider"}],"format":"esm"},"src/components/index.ts":{"bytes":616,"imports":[{"path":"src/components/AttentionGlyph/index.ts","kind":"import-statement","original":"./AttentionGlyph"},{"path":"src/components/AttentionProvider/index.ts","kind":"import-statement","original":"./AttentionProvider"},{"path":"src/components/SelectionProvider/index.ts","kind":"import-statement","original":"./SelectionProvider"}],"format":"esm"},"src/index.ts":{"bytes":560,"imports":[{"path":"src/attention.ts","kind":"import-statement","original":"./attention"},{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/selection.ts","kind":"import-statement","original":"./selection"}],"format":"esm"},"src/testing/decorators/withAttention.ts":{"bytes":3505,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/attention.ts","kind":"import-statement","original":"../../attention"},{"path":"src/components/index.ts","kind":"import-statement","original":"../../components"}],"format":"esm"},"src/testing/decorators/index.ts":{"bytes":389,"imports":[{"path":"src/testing/decorators/withAttention.ts","kind":"import-statement","original":"./withAttention"}],"format":"esm"},"src/testing/index.ts":{"bytes":382,"imports":[{"path":"src/testing/decorators/index.ts","kind":"import-statement","original":"./decorators"}],"format":"esm"},"src/types/index.ts":{"bytes":1067,"imports":[{"path":"src/attention.ts","kind":"import-statement","original":"../attention"},{"path":"src/selection.ts","kind":"import-statement","original":"../selection"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5178},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-I4VO2RQM.mjs","kind":"import-statement"},{"path":"dist/lib/browser/chunk-D2BLVJ6Z.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["AttendableContainer","AttentionGlyph","AttentionManager","RootAttentionProvider","SelectionManager","SelectionProvider","SelectionSchema","Syncing","defaultSelection","expandAttendableId","getAttendables","getLinkedVariant","getParentId","getSegmentId","getSelectionSet","isLinkedSegment","linkedSegment","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useSelected","useSelectionActions","useSelectionManager"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0},"src/components/AttentionGlyph/AttentionGlyph.tsx":{"bytesInOutput":2968}},"bytes":4044},"dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1875},"dist/lib/browser/testing/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-I4VO2RQM.mjs","kind":"import-statement"},{"path":"dist/lib/browser/chunk-D2BLVJ6Z.mjs","kind":"import-statement"},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["withAttention"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/decorators/withAttention.ts":{"bytesInOutput":610},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":863},"dist/lib/browser/chunk-I4VO2RQM.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17646},"dist/lib/browser/chunk-I4VO2RQM.mjs":{"imports":[{"path":"dist/lib/browser/chunk-D2BLVJ6Z.mjs","kind":"import-statement"},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true}],"exports":["AttendableContainer","RootAttentionProvider","SelectionProvider","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useSelected","useSelectionActions","useSelectionManager"],"inputs":{"src/components/AttentionProvider/AttentionProvider.tsx":{"bytesInOutput":3786},"src/components/SelectionProvider/SelectionProvider.tsx":{"bytesInOutput":3529}},"bytes":7816},"dist/lib/browser/types/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/browser/types/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-D2BLVJ6Z.mjs","kind":"import-statement"}],"exports":["AttentionManager","SelectionManager","SelectionSchema","defaultSelection","expandAttendableId","getAttendables","getLinkedVariant","getParentId","getSegmentId","getSelectionSet","isLinkedSegment","linkedSegment"],"entryPoint":"src/types/index.ts","inputs":{"src/types/index.ts":{"bytesInOutput":0}},"bytes":536},"dist/lib/browser/chunk-D2BLVJ6Z.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":25344},"dist/lib/browser/chunk-D2BLVJ6Z.mjs":{"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"exports":["AttentionManager","SelectionManager","SelectionSchema","defaultSelection","expandAttendableId","getAttendables","getLinkedVariant","getParentId","getSegmentId","getSelectionSet","isLinkedSegment","linkedSegment"],"inputs":{"src/attention.ts":{"bytesInOutput":5433},"src/selection.ts":{"bytesInOutput":6966}},"bytes":12721}}}
@@ -1,11 +1,28 @@
1
1
  import {
2
- RootAttentionProvider
3
- } from "../chunk-HELLA3BH.mjs";
2
+ RootAttentionProvider,
3
+ SelectionProvider
4
+ } from "../chunk-I4VO2RQM.mjs";
5
+ import {
6
+ AttentionManager
7
+ } from "../chunk-D2BLVJ6Z.mjs";
4
8
 
5
9
  // src/testing/decorators/withAttention.ts
6
- import { createElement } from "react";
7
- var withAttention = (Story) => {
8
- return createElement(RootAttentionProvider, {}, createElement(Story));
10
+ import { Registry, RegistryContext } from "@effect-atom/atom-react";
11
+ import { createElement, useMemo } from "react";
12
+ var withAttention = (initialAttendedId) => {
13
+ return (Story) => {
14
+ const registry = useMemo(() => Registry.make(), []);
15
+ const attention = useMemo(() => initialAttendedId ? new AttentionManager(registry, [
16
+ initialAttendedId
17
+ ]) : void 0, [
18
+ registry
19
+ ]);
20
+ return createElement(RegistryContext.Provider, {
21
+ value: registry
22
+ }, createElement(RootAttentionProvider, {
23
+ attention
24
+ }, createElement(SelectionProvider, {}, createElement(Story))));
25
+ };
9
26
  };
10
27
  export {
11
28
  withAttention
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/testing/decorators/withAttention.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport { createElement } from 'react';\n\nimport { RootAttentionProvider } from '../../components';\n\nexport const withAttention: Decorator = (Story) => {\n return createElement(RootAttentionProvider, {}, createElement(Story));\n};\n"],
5
- "mappings": ";;;;;AAKA,SAASA,qBAAqB;AAIvB,IAAMC,gBAA2B,CAACC,UAAAA;AACvC,SAAOC,cAAcC,uBAAuB,CAAC,GAAGD,cAAcD,KAAAA,CAAAA;AAChE;",
6
- "names": ["createElement", "withAttention", "Story", "createElement", "RootAttentionProvider"]
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Registry, RegistryContext } from '@effect-atom/atom-react';\nimport { type Decorator } from '@storybook/react';\nimport { createElement, useMemo } from 'react';\n\nimport { AttentionManager } from '../../attention';\nimport { RootAttentionProvider, SelectionProvider } from '../../components';\n\n/**\n * Storybook decorator that provides attention context.\n * @param initialAttendedId Optional ID to set as initially attended.\n */\nexport const withAttention = (initialAttendedId?: string): Decorator => {\n return (Story) => {\n const registry = useMemo(() => Registry.make(), []);\n const attention = useMemo(\n () => (initialAttendedId ? new AttentionManager(registry, [initialAttendedId]) : undefined),\n [registry],\n );\n\n return createElement(\n RegistryContext.Provider,\n { value: registry },\n createElement(RootAttentionProvider, { attention }, createElement(SelectionProvider, {}, createElement(Story))),\n );\n };\n};\n"],
5
+ "mappings": ";;;;;;;;;AAIA,SAASA,UAAUC,uBAAuB;AAE1C,SAASC,eAAeC,eAAe;AAShC,IAAMC,gBAAgB,CAACC,sBAAAA;AAC5B,SAAO,CAACC,UAAAA;AACN,UAAMC,WAAWC,QAAQ,MAAMC,SAASC,KAAI,GAAI,CAAA,CAAE;AAClD,UAAMC,YAAYH,QAChB,MAAOH,oBAAoB,IAAIO,iBAAiBL,UAAU;MAACF;KAAkB,IAAIQ,QACjF;MAACN;KAAS;AAGZ,WAAOO,cACLC,gBAAgBC,UAChB;MAAEC,OAAOV;IAAS,GAClBO,cAAcI,uBAAuB;MAAEP;IAAU,GAAGG,cAAcK,mBAAmB,CAAC,GAAGL,cAAcR,KAAAA,CAAAA,CAAAA,CAAAA;EAE3G;AACF;",
6
+ "names": ["Registry", "RegistryContext", "createElement", "useMemo", "withAttention", "initialAttendedId", "Story", "registry", "useMemo", "Registry", "make", "attention", "AttentionManager", "undefined", "createElement", "RegistryContext", "Provider", "value", "RootAttentionProvider", "SelectionProvider"]
7
7
  }
@@ -0,0 +1,29 @@
1
+ import {
2
+ AttentionManager,
3
+ SelectionManager,
4
+ SelectionSchema,
5
+ defaultSelection,
6
+ expandAttendableId,
7
+ getAttendables,
8
+ getLinkedVariant,
9
+ getParentId,
10
+ getSegmentId,
11
+ getSelectionSet,
12
+ isLinkedSegment,
13
+ linkedSegment
14
+ } from "../chunk-D2BLVJ6Z.mjs";
15
+ export {
16
+ AttentionManager,
17
+ SelectionManager,
18
+ SelectionSchema,
19
+ defaultSelection,
20
+ expandAttendableId,
21
+ getAttendables,
22
+ getLinkedVariant,
23
+ getParentId,
24
+ getSegmentId,
25
+ getSelectionSet,
26
+ isLinkedSegment,
27
+ linkedSegment
28
+ };
29
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }