@dxos/react-ui-attention 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/dist/lib/browser/chunk-D2BLVJ6Z.mjs +421 -0
- package/dist/lib/browser/chunk-D2BLVJ6Z.mjs.map +7 -0
- package/dist/lib/browser/chunk-I4VO2RQM.mjs +255 -0
- package/dist/lib/browser/chunk-I4VO2RQM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +165 -23
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +22 -5
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +29 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6INLBC62.mjs +423 -0
- package/dist/lib/node-esm/chunk-6INLBC62.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZTUVSH4P.mjs +256 -0
- package/dist/lib/node-esm/chunk-ZTUVSH4P.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +165 -23
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +22 -5
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +30 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/attention.d.ts +60 -20
- package/dist/types/src/attention.d.ts.map +1 -1
- package/dist/types/src/components/AttentionGlyph/AttentionGlyph.d.ts.map +1 -0
- package/dist/types/src/components/AttentionGlyph/AttentionGlyph.stories.d.ts +16 -0
- package/dist/types/src/components/AttentionGlyph/AttentionGlyph.stories.d.ts.map +1 -0
- package/dist/types/src/components/AttentionGlyph/index.d.ts +2 -0
- package/dist/types/src/components/AttentionGlyph/index.d.ts.map +1 -0
- package/dist/types/src/components/AttentionProvider/AttentionProvider.d.ts +34 -0
- package/dist/types/src/components/AttentionProvider/AttentionProvider.d.ts.map +1 -0
- package/dist/types/src/components/AttentionProvider/AttentionProvider.stories.d.ts +12 -0
- package/dist/types/src/components/AttentionProvider/AttentionProvider.stories.d.ts.map +1 -0
- package/dist/types/src/components/AttentionProvider/index.d.ts +2 -0
- package/dist/types/src/components/AttentionProvider/index.d.ts.map +1 -0
- package/dist/types/src/components/{SelectionProvider.d.ts → SelectionProvider/SelectionProvider.d.ts} +7 -6
- package/dist/types/src/components/SelectionProvider/SelectionProvider.d.ts.map +1 -0
- package/dist/types/src/components/SelectionProvider/index.d.ts +2 -0
- package/dist/types/src/components/SelectionProvider/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/selection.d.ts +24 -4
- package/dist/types/src/selection.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withAttention.d.ts +5 -1
- package/dist/types/src/testing/decorators/withAttention.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/useArticleKeyboardNavigation.d.ts +42 -0
- package/dist/types/src/useArticleKeyboardNavigation.d.ts.map +1 -0
- package/dist/types/src/useArticleKeyboardNavigation.test.d.ts +2 -0
- package/dist/types/src/useArticleKeyboardNavigation.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -32
- package/src/attention.test.ts +188 -27
- package/src/attention.ts +179 -74
- package/src/components/{AttentionGlyph.stories.tsx → AttentionGlyph/AttentionGlyph.stories.tsx} +17 -14
- package/src/components/{AttentionGlyph.tsx → AttentionGlyph/AttentionGlyph.tsx} +14 -7
- package/src/components/AttentionGlyph/index.ts +5 -0
- package/src/components/{AttentionProvider.stories.tsx → AttentionProvider/AttentionProvider.stories.tsx} +12 -10
- package/src/components/AttentionProvider/AttentionProvider.tsx +176 -0
- package/src/components/AttentionProvider/index.ts +5 -0
- package/src/components/SelectionProvider/SelectionProvider.tsx +174 -0
- package/src/components/SelectionProvider/index.ts +5 -0
- package/src/index.ts +1 -0
- package/src/selection.ts +123 -80
- package/src/testing/decorators/withAttention.ts +22 -4
- package/src/types/index.ts +9 -0
- package/src/useArticleKeyboardNavigation.test.ts +50 -0
- package/src/useArticleKeyboardNavigation.ts +116 -0
- package/dist/lib/browser/chunk-PXMGIYAQ.mjs +0 -650
- package/dist/lib/browser/chunk-PXMGIYAQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-V2PNA7ZV.mjs +0 -652
- package/dist/lib/node-esm/chunk-V2PNA7ZV.mjs.map +0 -7
- package/dist/types/src/components/AttentionGlyph.d.ts.map +0 -1
- package/dist/types/src/components/AttentionGlyph.stories.d.ts +0 -27
- package/dist/types/src/components/AttentionGlyph.stories.d.ts.map +0 -1
- package/dist/types/src/components/AttentionProvider.d.ts +0 -38
- package/dist/types/src/components/AttentionProvider.d.ts.map +0 -1
- package/dist/types/src/components/AttentionProvider.stories.d.ts +0 -10
- package/dist/types/src/components/AttentionProvider.stories.d.ts.map +0 -1
- package/dist/types/src/components/SelectionProvider.d.ts.map +0 -1
- package/src/components/AttentionProvider.tsx +0 -198
- package/src/components/SelectionProvider.tsx +0 -120
- /package/dist/types/src/components/{AttentionGlyph.d.ts → AttentionGlyph/AttentionGlyph.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": ";;;;;;;;AAIA,SAASA,uBAAuB;AAChC,SAASC,qBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AACrB,OAAOC,SAILC,YACAC,aACAC,YACAC,WACAC,SACAC,gBACK;AAEP,SAASC,WAAW;AACpB,SAASC,uBAAu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,MAAA;AACxB,QAAI,CAACvC,WAAW;AACd;IACF;AACA,eAAWyB,aAAaS,kBAAkB;AACxClC,gBAAUgD,eAAevB,SAAAA;IAC3B;EACF,GAAG;IAACzB;IAAWkC;GAAiB;AAEhC,SAAO;IAAEI;IAAcG;IAAaE;IAAaE;IAAQE;EAAM;AACjE;",
|
|
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,195 @@
|
|
|
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-
|
|
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-bg", "[[data-attention=true]_&]:text-accent-fg", "[[aria-current][data-attention=true]_&]:bg-accent-bg", "[[aria-current][data-attention=true]_&]:text-accent-fg", '[[aria-selected="true"][data-attention=true]_&]:bg-accent-bg', '[[aria-selected="true"][data-attention=true]_&]:text-accent-fg');
|
|
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
|
+
...props,
|
|
90
|
+
className: mx(attentionGlyphStyles, classNames),
|
|
91
|
+
ref: forwardedRef
|
|
92
|
+
}, icon));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/useArticleKeyboardNavigation.ts
|
|
96
|
+
import { useEffect, useMemo as useMemo2 } from "react";
|
|
97
|
+
import { Keyboard } from "@dxos/keyboard";
|
|
98
|
+
var advance = ({ ids, currentId, delta }) => {
|
|
99
|
+
if (ids.length === 0) {
|
|
100
|
+
return void 0;
|
|
101
|
+
}
|
|
102
|
+
const idx = currentId ? ids.indexOf(currentId) : -1;
|
|
103
|
+
if (idx === -1) {
|
|
104
|
+
return delta === 1 ? ids[0] : ids[ids.length - 1];
|
|
105
|
+
}
|
|
106
|
+
const next = Math.max(0, Math.min(ids.length - 1, idx + delta));
|
|
107
|
+
return ids[next];
|
|
108
|
+
};
|
|
109
|
+
var useArticleKeyboardNavigation = ({ articleId, items, currentId, getId, onSelect }) => {
|
|
110
|
+
const { hasAttention } = useAttention(articleId);
|
|
111
|
+
const ids = useMemo2(() => items.map((item) => getId ? getId(item) : item.id), [
|
|
112
|
+
items,
|
|
113
|
+
getId
|
|
114
|
+
]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (!hasAttention) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const context = Keyboard.singleton.getContext(articleId);
|
|
120
|
+
const prevContext = Keyboard.singleton.getCurrentContext();
|
|
121
|
+
Keyboard.singleton.setCurrentContext(articleId);
|
|
122
|
+
const nextBinding = {
|
|
123
|
+
shortcut: "j",
|
|
124
|
+
handler: () => {
|
|
125
|
+
const target = advance({
|
|
126
|
+
ids,
|
|
127
|
+
currentId,
|
|
128
|
+
delta: 1
|
|
129
|
+
});
|
|
130
|
+
if (target !== void 0) {
|
|
131
|
+
onSelect(target);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
data: "Next item",
|
|
135
|
+
disableInput: true
|
|
136
|
+
};
|
|
137
|
+
const prevBinding = {
|
|
138
|
+
shortcut: "k",
|
|
139
|
+
handler: () => {
|
|
140
|
+
const target = advance({
|
|
141
|
+
ids,
|
|
142
|
+
currentId,
|
|
143
|
+
delta: -1
|
|
144
|
+
});
|
|
145
|
+
if (target !== void 0) {
|
|
146
|
+
onSelect(target);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
data: "Previous item",
|
|
150
|
+
disableInput: true
|
|
151
|
+
};
|
|
152
|
+
context.bind(nextBinding);
|
|
153
|
+
context.bind(prevBinding);
|
|
154
|
+
return () => {
|
|
155
|
+
context.unbind("j");
|
|
156
|
+
context.unbind("k");
|
|
157
|
+
if (Keyboard.singleton.getCurrentContext() === articleId) {
|
|
158
|
+
Keyboard.singleton.setCurrentContext(prevContext);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}, [
|
|
162
|
+
articleId,
|
|
163
|
+
ids,
|
|
164
|
+
currentId,
|
|
165
|
+
onSelect,
|
|
166
|
+
hasAttention
|
|
167
|
+
]);
|
|
168
|
+
};
|
|
28
169
|
export {
|
|
29
|
-
ATTENABLE_ATTRIBUTE,
|
|
30
|
-
ATTENDABLE_PATH_SEPARATOR,
|
|
31
|
-
ATTENTION_NAME,
|
|
32
|
-
ATTENTION_SOURCE_ATTRIBUTE,
|
|
33
170
|
AttendableContainer,
|
|
34
171
|
AttentionGlyph,
|
|
35
172
|
AttentionManager,
|
|
36
|
-
AttentionProvider,
|
|
37
|
-
AttentionSchema,
|
|
38
173
|
RootAttentionProvider,
|
|
39
174
|
SelectionManager,
|
|
40
175
|
SelectionProvider,
|
|
41
176
|
SelectionSchema,
|
|
42
177
|
Syncing,
|
|
178
|
+
advance,
|
|
43
179
|
defaultSelection,
|
|
180
|
+
expandAttendableId,
|
|
44
181
|
getAttendables,
|
|
182
|
+
getLinkedVariant,
|
|
183
|
+
getParentId,
|
|
184
|
+
getSegmentId,
|
|
45
185
|
getSelectionSet,
|
|
186
|
+
isLinkedSegment,
|
|
187
|
+
linkedSegment,
|
|
188
|
+
useArticleKeyboardNavigation,
|
|
46
189
|
useAttended,
|
|
47
190
|
useAttention,
|
|
48
191
|
useAttentionAttributes,
|
|
49
192
|
useAttentionContext,
|
|
50
|
-
useAttentionPath,
|
|
51
193
|
useSelected,
|
|
52
194
|
useSelectionActions,
|
|
53
195
|
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", "../../../src/useArticleKeyboardNavigation.ts"],
|
|
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-bg',\n '[[data-attention=true]_&]:text-accent-fg',\n '[[aria-current][data-attention=true]_&]:bg-accent-bg',\n '[[aria-current][data-attention=true]_&]:text-accent-fg',\n '[[aria-selected=\"true\"][data-attention=true]_&]:bg-accent-bg',\n '[[aria-selected=\"true\"][data-attention=true]_&]:text-accent-fg',\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 {...props} className={mx(attentionGlyphStyles, classNames)} ref={forwardedRef}>\n {icon}\n </span>\n </div>\n );\n },\n);\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { useEffect, useMemo } from 'react';\n\nimport { Keyboard } from '@dxos/keyboard';\n\nimport { useAttention } from './components';\n\n/**\n * Compute the id to select after pressing 'j' (delta = 1) or 'k' (delta = -1).\n * Clamps at the list ends — pressing 'j' on the last item keeps the last item\n * selected (vim-style), and 'k' on the first item keeps the first.\n *\n * When no current selection exists, returns the first id (for delta = 1) or the\n * last id (for delta = -1) so the user can enter the list with either key.\n */\nexport const advance = ({\n ids,\n currentId,\n delta,\n}: {\n ids: readonly string[];\n currentId: string | undefined;\n delta: 1 | -1;\n}): string | undefined => {\n if (ids.length === 0) {\n return undefined;\n }\n\n const idx = currentId ? ids.indexOf(currentId) : -1;\n if (idx === -1) {\n return delta === 1 ? ids[0] : ids[ids.length - 1];\n }\n\n const next = Math.max(0, Math.min(ids.length - 1, idx + delta));\n return ids[next];\n};\n\nexport type UseArticleKeyboardNavigationOptions<T> = {\n /** Stable id for the article (used as the keyboard context path). */\n articleId: string;\n /** Ordered list of selectable items as they appear in the article. */\n items: readonly T[];\n /** Currently-selected id, if any. */\n currentId: string | undefined;\n /** Extracts the id from an item. Defaults to `item.id`. */\n getId?: (item: T) => string;\n /** Called with the id to select when the user presses 'j' or 'k'. */\n onSelect: (id: string) => void;\n};\n\n/**\n * Wire 'j' (next) and 'k' (previous) keyboard shortcuts for an article that\n * navigates a list of items (e.g., messages, events). Bindings are scoped to\n * the article's keyboard context so they only fire while the article has attention.\n *\n * Pass the items directly; ids are derived via `getId` (defaults to `item.id`).\n * Clamps at list boundaries. Active only when the article is attended.\n */\nexport const useArticleKeyboardNavigation: {\n <T extends { id: string }>(options: UseArticleKeyboardNavigationOptions<T>): void;\n <T>(options: UseArticleKeyboardNavigationOptions<T> & { getId: (item: T) => string }): void;\n} = <T>({ articleId, items, currentId, getId, onSelect }: UseArticleKeyboardNavigationOptions<T>): void => {\n const { hasAttention } = useAttention(articleId);\n\n // `getId` is optional only when `T extends { id: string }` (enforced by the overloads above),\n // so the fallback is sound; the cast bridges the generic erased by the implementation signature.\n const ids = useMemo(() => items.map((item) => (getId ? getId(item) : (item as { id: string }).id)), [items, getId]);\n\n useEffect(() => {\n if (!hasAttention) {\n return;\n }\n\n const context = Keyboard.singleton.getContext(articleId);\n const prevContext = Keyboard.singleton.getCurrentContext();\n Keyboard.singleton.setCurrentContext(articleId);\n\n const nextBinding = {\n shortcut: 'j',\n handler: () => {\n const target = advance({ ids, currentId, delta: 1 });\n if (target !== undefined) {\n onSelect(target);\n }\n },\n data: 'Next item',\n disableInput: true,\n };\n const prevBinding = {\n shortcut: 'k',\n handler: () => {\n const target = advance({ ids, currentId, delta: -1 });\n if (target !== undefined) {\n onSelect(target);\n }\n },\n data: 'Previous item',\n disableInput: true,\n };\n\n context.bind(nextBinding);\n context.bind(prevBinding);\n\n return () => {\n context.unbind('j');\n context.unbind('k');\n // Restore the prior context if we were the ones who set it.\n if (Keyboard.singleton.getCurrentContext() === articleId) {\n Keyboard.singleton.setCurrentContext(prevContext);\n }\n };\n }, [articleId, ids, currentId, onSelect, hasAttention]);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAOA,SAAyDC,YAAYC,eAAe;AAE3F,SAASC,YAAkC;AAC3C,SAASC,UAAU;AAEnB,IAAMC,uBAAuBD,GAC3B,qFACA,2DACA,0CACA,4CACA,wDACA,0DACA,gEACA,gEAAA;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,U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SAAAA;AAErC,UAAMkB,cAAc;MAClBC,UAAU;MACVC,SAAS,MAAA;AACP,cAAMC,SAASlC,QAAQ;UAAEC;UAAKC;UAAWC,OAAO;QAAE,CAAA;AAClD,YAAI+B,WAAW7B,QAAW;AACxBW,mBAASkB,MAAAA;QACX;MACF;MACAC,MAAM;MACNC,cAAc;IAChB;AACA,UAAMC,cAAc;MAClBL,UAAU;MACVC,SAAS,MAAA;AACP,cAAMC,SAASlC,QAAQ;UAAEC;UAAKC;UAAWC,OAAO;QAAG,CAAA;AACnD,YAAI+B,WAAW7B,QAAW;AACxBW,mBAASkB,MAAAA;QACX;MACF;MACAC,MAAM;MACNC,cAAc;IAChB;AAEAZ,YAAQc,KAAKP,WAAAA;AACbP,YAAQc,KAAKD,WAAAA;AAEb,WAAO,MAAA;AACLb,cAAQe,OAAO,GAAA;AACff,cAAQe,OAAO,GAAA;AAEf,UAAId,SAASC,UAAUG,kBAAiB,MAAOhB,WAAW;AACxDY,iBAASC,UAAUI,kBAAkBF,WAAAA;MACvC;IACF;EACF,GAAG;IAACf;IAAWZ;IAAKC;IAAWc;IAAUC;GAAa;AACxD;",
|
|
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", "useEffect", "useMemo", "Keyboard", "advance", "ids", "currentId", "delta", "length", "undefined", "idx", "indexOf", "next", "Math", "max", "min", "useArticleKeyboardNavigation", "articleId", "items", "getId", "onSelect", "hasAttention", "useAttention", "useMemo", "map", "item", "id", "useEffect", "context", "Keyboard", "singleton", "getContext", "prevContext", "getCurrentContext", "setCurrentContext", "nextBinding", "shortcut", "handler", "target", "data", "disableInput", "prevBinding", "bind", "unbind"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/attention.ts":{"bytes":
|
|
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":9775,"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/useArticleKeyboardNavigation.ts":{"bytes":11610,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"src/index.ts":{"bytes":700,"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"},{"path":"src/useArticleKeyboardNavigation.ts","kind":"import-statement","original":"./useArticleKeyboardNavigation"}],"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":11016},"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},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true}],"exports":["AttendableContainer","AttentionGlyph","AttentionManager","RootAttentionProvider","SelectionManager","SelectionProvider","SelectionSchema","Syncing","advance","defaultSelection","expandAttendableId","getAttendables","getLinkedVariant","getParentId","getSegmentId","getSelectionSet","isLinkedSegment","linkedSegment","useArticleKeyboardNavigation","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useSelected","useSelectionActions","useSelectionManager"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0},"src/components/AttentionGlyph/AttentionGlyph.tsx":{"bytesInOutput":2911},"src/useArticleKeyboardNavigation.ts":{"bytesInOutput":1896}},"bytes":5966},"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}}}
|