@dxos/react-ui-attention 0.7.4 → 0.7.5-main.9d26e3a
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/dist/lib/browser/{chunk-XW26HKZY.mjs → chunk-6HZDGBSQ.mjs} +32 -9
- package/dist/lib/browser/chunk-6HZDGBSQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-H55DIJUD.cjs → chunk-KQ3CULUO.cjs} +34 -10
- package/dist/lib/node/chunk-KQ3CULUO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +17 -15
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +2 -2
- package/dist/lib/node-esm/{chunk-7ONRCT2C.mjs → chunk-5VF6FMOU.mjs} +32 -9
- package/dist/lib/node-esm/chunk-5VF6FMOU.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/components/AttentionGlyph.d.ts +4 -0
- package/dist/types/src/components/AttentionGlyph.d.ts.map +1 -1
- package/dist/types/src/components/AttentionGlyph.stories.d.ts +10 -11
- package/dist/types/src/components/AttentionGlyph.stories.d.ts.map +1 -1
- package/dist/types/src/components/AttentionProvider.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +11 -11
- package/src/attention.test.ts +0 -11
- package/src/components/AttentionGlyph.stories.tsx +54 -22
- package/src/components/AttentionGlyph.tsx +41 -8
- package/src/components/AttentionProvider.tsx +1 -0
- package/dist/lib/browser/chunk-XW26HKZY.mjs.map +0 -7
- package/dist/lib/node/chunk-H55DIJUD.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-7ONRCT2C.mjs.map +0 -7
|
@@ -107,9 +107,10 @@ var getAttendables = (selector, cursor, acc = []) => {
|
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
// packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx
|
|
110
|
-
import React, { forwardRef } from "react";
|
|
110
|
+
import React, { forwardRef, useMemo } from "react";
|
|
111
|
+
import { Icon } from "@dxos/react-ui";
|
|
111
112
|
import { mx } from "@dxos/react-ui-theme";
|
|
112
|
-
var attentionGlyphStyles = "inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse";
|
|
113
|
+
var attentionGlyphStyles = "inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-contains-attended=true]_&]:bg-attentionRelated [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse";
|
|
113
114
|
var presenceIconStyles = "is-3 bs-3 group-[[aria-current]_&:hover]/attentionGlyphButton:hidden group-[[aria-current]_&:focus]/attentionGlyphButton:hidden group-[[data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[data-attention=true]_&:focus]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:focus]/attentionGlyphButton:hidden";
|
|
114
115
|
var PresenceOne = () => {
|
|
115
116
|
return /* @__PURE__ */ React.createElement("svg", {
|
|
@@ -144,18 +145,39 @@ var PresenceMany = () => {
|
|
|
144
145
|
fill: "currentColor"
|
|
145
146
|
}));
|
|
146
147
|
};
|
|
147
|
-
var
|
|
148
|
-
|
|
148
|
+
var Syncing = () => {
|
|
149
|
+
const animationProps = useMemo(() => ({
|
|
150
|
+
// Synchronize animations.
|
|
151
|
+
animationDelay: `-${Date.now() % 2e3}ms`
|
|
152
|
+
}), []);
|
|
153
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
154
|
+
role: "status",
|
|
155
|
+
className: "flex items-center"
|
|
156
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
157
|
+
icon: "ph--circle-notch--regular",
|
|
158
|
+
size: 3,
|
|
159
|
+
style: animationProps,
|
|
160
|
+
classNames: "text-subdued animate-[spin_2s_linear_infinite]"
|
|
161
|
+
}));
|
|
162
|
+
};
|
|
163
|
+
var AttentionGlyph = /* @__PURE__ */ forwardRef(({ presence, attended, syncing, containsAttended, classNames, ...props }, forwardedRef) => {
|
|
164
|
+
const icon = syncing ? /* @__PURE__ */ React.createElement(Syncing, null) : presence === "many" ? /* @__PURE__ */ React.createElement(PresenceMany, null) : presence === "one" ? /* @__PURE__ */ React.createElement(PresenceOne, null) : null;
|
|
165
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
166
|
+
role: "none",
|
|
167
|
+
className: "flex",
|
|
168
|
+
"data-attention": attended,
|
|
169
|
+
"data-contains-attended": containsAttended
|
|
170
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
149
171
|
role: "none",
|
|
150
172
|
...props,
|
|
151
173
|
className: mx(attentionGlyphStyles, classNames),
|
|
152
174
|
ref: forwardedRef
|
|
153
|
-
},
|
|
175
|
+
}, icon));
|
|
154
176
|
});
|
|
155
177
|
|
|
156
178
|
// packages/ui/react-ui-attention/src/components/AttentionProvider.tsx
|
|
157
179
|
import { createContext } from "@radix-ui/react-context";
|
|
158
|
-
import React2, { useMemo } from "react";
|
|
180
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
159
181
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
160
182
|
var ATTENTION_NAME = "Attention";
|
|
161
183
|
var ATTENABLE_ATTRIBUTE = "data-attendable-id";
|
|
@@ -186,7 +208,7 @@ var useAttended = () => {
|
|
|
186
208
|
};
|
|
187
209
|
var useAttendableAttributes = (attendableId) => {
|
|
188
210
|
const { hasAttention } = useAttention(attendableId);
|
|
189
|
-
return
|
|
211
|
+
return useMemo2(() => {
|
|
190
212
|
const attributes = {
|
|
191
213
|
[ATTENABLE_ATTRIBUTE]: attendableId
|
|
192
214
|
};
|
|
@@ -228,7 +250,7 @@ var RootAttentionProvider = ({ children, attention: propsAttention, onChange })
|
|
|
228
250
|
};
|
|
229
251
|
var AttentionProvider = ({ id, children }) => {
|
|
230
252
|
const { attention, path } = useAttentionContext(ATTENTION_NAME);
|
|
231
|
-
const nextPath =
|
|
253
|
+
const nextPath = useMemo2(() => [
|
|
232
254
|
id,
|
|
233
255
|
...path
|
|
234
256
|
], [
|
|
@@ -245,6 +267,7 @@ export {
|
|
|
245
267
|
AttentionSchema,
|
|
246
268
|
AttentionManager,
|
|
247
269
|
getAttendables,
|
|
270
|
+
Syncing,
|
|
248
271
|
AttentionGlyph,
|
|
249
272
|
ATTENTION_NAME,
|
|
250
273
|
ATTENABLE_ATTRIBUTE,
|
|
@@ -257,4 +280,4 @@ export {
|
|
|
257
280
|
RootAttentionProvider,
|
|
258
281
|
AttentionProvider
|
|
259
282
|
};
|
|
260
|
-
//# sourceMappingURL=chunk-
|
|
283
|
+
//# sourceMappingURL=chunk-6HZDGBSQ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/attention.ts", "../../../src/components/AttentionGlyph.tsx", "../../../src/components/AttentionProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { untracked } from '@preact/signals-core';\n\nimport { S } from '@dxos/echo-schema';\nimport { create, type ReactiveObject } from '@dxos/live-object';\nimport { ComplexMap } from '@dxos/util';\n\nexport const AttentionSchema = S.mutable(\n S.Struct({\n hasAttention: S.Boolean,\n isAncestor: S.Boolean,\n isRelated: S.Boolean,\n }),\n);\n\nexport type Attention = S.Schema.Type<typeof AttentionSchema>;\n\n// TODO(wittjosiah): Use mosaic path utility?\nconst stringKey = (key: string[]) => key.join(',');\n\n/**\n * Manages attention state for an application.\n */\n// TODO(wittjosiah): Write unit tests.\nexport class AttentionManager {\n // Each attention path is associated with an attention object.\n // The lookup is not a reactive object to ensure that attention for each path is subscribable independently.\n private readonly _map = new ComplexMap<string[], ReactiveObject<Attention>>(stringKey);\n private readonly _state = create<{ current: string[] }>({ current: [] });\n\n constructor(initial: string[] = []) {\n if (initial.length > 0) {\n this.update(initial);\n }\n }\n\n /**\n * Currently attended element.\n */\n get current() {\n return this._state.current;\n }\n\n /**\n * All attention paths.\n */\n keys() {\n return Array.from(this._map.keys());\n }\n\n /**\n * Get the attention state for a given path.\n */\n get(key: string[]): ReactiveObject<Attention> {\n const object = this._map.get(key);\n if (object) {\n return object;\n }\n\n const newObject = create(AttentionSchema, { hasAttention: false, isAncestor: false, isRelated: false });\n this._map.set(key, newObject);\n return newObject;\n }\n\n /**\n * Update the currently attended element.\n */\n update(nextKey: string[]) {\n const currentKey = untracked(() => this.current);\n const currentRelatedTo = currentKey[0];\n const nextRelatedTo = nextKey[0];\n\n // Ensure related attention object is initialized.\n this.get([nextRelatedTo]);\n\n const currentRelatedKeys = this.keys().filter((key) => key[0] === currentRelatedTo);\n const nextRelatedKeys = this.keys().filter(\n (key) => key[0] === nextRelatedTo && stringKey(key) !== stringKey(nextKey),\n );\n const prevRelatedKeys = currentRelatedKeys.filter(\n (curr) => !nextRelatedKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n const currentAncestorKeys = currentKey.slice(1).map((_, i) => currentKey.slice(i + 1, currentKey.length));\n const nextAncestorKeys = nextKey.slice(1).map((_, i) => nextKey.slice(i + 1, nextKey.length));\n const prevAncestorKeys = currentAncestorKeys.filter(\n (curr) => !nextAncestorKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n this._state.current = nextKey;\n prevRelatedKeys.forEach((key) => this._set(key, {}));\n prevAncestorKeys.forEach((key) => this._set(key, {}));\n nextRelatedKeys.forEach((key) => this._set(key, { isRelated: true }));\n nextAncestorKeys.forEach((key) => this._set(key, { isAncestor: true }));\n this._set(nextKey, { hasAttention: true });\n }\n\n private _set(key: string[], attention: Partial<Attention>) {\n const object = this.get(key);\n object.hasAttention = attention.hasAttention ?? false;\n object.isAncestor = attention.isAncestor ?? false;\n object.isRelated = attention.isRelated ?? false;\n }\n}\n\n/**\n * Accumulates all attendable id’s between the element provided and the root, inclusive.\n */\nexport const getAttendables = (selector: string, cursor: Element, acc: string[] = []): string[] => {\n // Find the closest element with `data-attendable-id`, if any; start from cursor and move up the DOM tree.\n const closestAttendable = cursor.closest(selector);\n if (closestAttendable) {\n const attendableId = closestAttendable.getAttribute('data-attendable-id');\n if (!attendableId) {\n // this has an id of an aria-controls elsewhere on the page, move cursor to that trigger\n const trigger = document.querySelector(`[aria-controls=\"${closestAttendable.getAttribute('id')}\"]`);\n if (!trigger) {\n return acc;\n } else {\n return getAttendables(selector, trigger, acc);\n }\n } else {\n acc.push(attendableId);\n // (attempt tail recursion)\n return !closestAttendable.parentElement ? acc : getAttendables(selector, closestAttendable.parentElement, acc);\n }\n }\n\n return [...new Set(acc)];\n};\n\nexport type AttendableId = { attendableId?: string };\n\nexport type Related = { related?: boolean };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, type CSSProperties, forwardRef, useMemo } from 'react';\n\nimport { Icon, type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nconst attentionGlyphStyles =\n 'inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-contains-attended=true]_&]:bg-attentionRelated [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse';\n\nconst presenceIconStyles =\n 'is-3 bs-3 group-[[aria-current]_&:hover]/attentionGlyphButton:hidden group-[[aria-current]_&:focus]/attentionGlyphButton:hidden group-[[data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[data-attention=true]_&:focus]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:focus]/attentionGlyphButton:hidden';\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--regular'\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 role='none' className='flex' 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", "//\n// Copyright 2024 DXOS.org\n//\n\n// NOTE(thure): The following unused imports quell TS2742 (“likely not portable”).\n\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { createContext, type Scope, type CreateScope } from '@radix-ui/react-context';\nimport React, { useMemo, type FocusEvent, type PropsWithChildren } from 'react';\n\nimport { useDefaultValue } from '@dxos/react-ui';\n\nimport { type Attention, AttentionManager, getAttendables } from '../attention';\n\nconst ATTENTION_NAME = 'Attention';\nconst ATTENABLE_ATTRIBUTE = 'data-attendable-id';\nconst ATTENTION_SOURCE_ATTRIBUTE = 'data-is-attention-source';\n\ntype AttentionContextValue = {\n attention: AttentionManager;\n path: string[];\n};\n\nconst [AttentionContextProvider, useAttentionContext] = createContext<AttentionContextValue>(ATTENTION_NAME, {\n attention: new AttentionManager(),\n path: [],\n});\n\nconst UNKNOWN_ATTENDABLE = { hasAttention: false, isAncestor: false, isRelated: false };\n\nconst useAttention = (attendableId?: string): Attention => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n if (!attendableId) {\n return UNKNOWN_ATTENDABLE;\n }\n\n const current = [attendableId, ...path];\n return attention.get(current);\n};\n\nconst useAttended = () => {\n const { attention } = useAttentionContext(ATTENTION_NAME);\n return attention.current;\n};\n\n/**\n * Computes HTML element attributes to apply so the attention system can detect changes\n * @param attendableId\n */\nconst useAttendableAttributes = (attendableId?: string) => {\n const { hasAttention } = useAttention(attendableId);\n return useMemo(() => {\n const attributes: Record<string, string | undefined> = { [ATTENABLE_ATTRIBUTE]: attendableId };\n if (hasAttention) {\n attributes[ATTENTION_SOURCE_ATTRIBUTE] = 'true';\n }\n\n return attributes;\n }, [attendableId, hasAttention]);\n};\n\nconst useAttentionPath = () => {\n const { path } = useAttentionContext(ATTENTION_NAME);\n return path;\n};\n\nconst RootAttentionProvider = ({\n children,\n attention: propsAttention,\n onChange,\n}: PropsWithChildren<\n Partial<{\n attention: AttentionManager;\n onChange: (nextAttended: string[]) => void;\n }>\n>) => {\n const attention = useDefaultValue(propsAttention, () => new AttentionManager());\n const handleFocus = (event: FocusEvent) => {\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.current;\n const next = getAttendables(selector, event.target);\n // TODO(wittjosiah): Not allowing empty state means that the attended item is not strictly guaranteed to be in the DOM.\n // Currently this depends on the deck in order to ensure that when the attended item is removed something else is attended.\n // Only update state if the result is different and not empty.\n if (next.length > 0 && (prev.length !== next.length || !!prev.find((id, index) => next[index] !== id))) {\n attention.update(next);\n onChange?.(next);\n }\n };\n\n return (\n <AttentionContextProvider attention={attention} path={[]}>\n <div role='none' className='contents' onFocusCapture={handleFocus}>\n {children}\n </div>\n </AttentionContextProvider>\n );\n};\n\nconst AttentionProvider = ({ id, children }: PropsWithChildren<{ id: string }>) => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n const nextPath = useMemo(() => [id, ...path], [id, path]);\n\n return (\n <AttentionContextProvider attention={attention} path={nextPath}>\n {children}\n </AttentionContextProvider>\n );\n};\n\nexport {\n RootAttentionProvider,\n AttentionProvider,\n useAttentionContext,\n useAttention,\n useAttended,\n useAttendableAttributes,\n useAttentionPath,\n ATTENTION_NAME,\n ATTENABLE_ATTRIBUTE,\n ATTENTION_SOURCE_ATTRIBUTE,\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,iBAAiB;AAE1B,SAASC,SAAS;AAClB,SAASC,cAAmC;AAC5C,SAASC,kBAAkB;AAEpB,IAAMC,kBAAkBC,EAAEC,QAC/BD,EAAEE,OAAO;EACP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EAAER,IAAIrB,SAAQ,MAAqC;AAC5E,QAAM,EAAEjB,WAAWE,KAAI,IAAKJ,oBAAoBJ,cAAAA;AAChD,QAAMqD,WAAWlC,SAAQ,MAAM;IAACyB;OAAOpC;KAAO;IAACoC;IAAIpC;GAAK;AAExD,SACE,gBAAAuC,OAAA,cAAC5C,0BAAAA;IAAyBG;IAAsBE,MAAM6C;KACnD9B,QAAAA;AAGP;",
|
|
6
|
+
"names": ["untracked", "S", "create", "ComplexMap", "AttentionSchema", "S", "mutable", "Struct", "hasAttention", "Boolean", "isAncestor", "isRelated", "stringKey", "key", "join", "AttentionManager", "constructor", "initial", "_map", "ComplexMap", "_state", "create", "current", "length", "update", "keys", "Array", "from", "get", "object", "newObject", "set", "nextKey", "currentKey", "untracked", "currentRelatedTo", "nextRelatedTo", "currentRelatedKeys", "filter", "nextRelatedKeys", "prevRelatedKeys", "curr", "find", "next", "currentAncestorKeys", "slice", "map", "_", "i", "nextAncestorKeys", "prevAncestorKeys", "forEach", "_set", "attention", "getAttendables", "selector", "cursor", "acc", "closestAttendable", "closest", "attendableId", "getAttribute", "trigger", "document", "querySelector", "push", "parentElement", "Set", "React", "forwardRef", "useMemo", "Icon", "mx", "attentionGlyphStyles", "presenceIconStyles", "PresenceOne", "svg", "width", "height", "viewBox", "className", "fill", "xmlns", "circle", "cx", "cy", "r", "PresenceMany", "path", "d", "Syncing", "animationProps", "useMemo", "animationDelay", "Date", "now", "div", "role", "Icon", "icon", "size", "style", "classNames", "AttentionGlyph", "forwardRef", "presence", "attended", "syncing", "containsAttended", "props", "forwardedRef", "data-attention", "data-contains-attended", "span", "mx", "ref", "createContext", "React", "useMemo", "useDefaultValue", "ATTENTION_NAME", "ATTENABLE_ATTRIBUTE", "ATTENTION_SOURCE_ATTRIBUTE", "AttentionContextProvider", "useAttentionContext", "createContext", "attention", "AttentionManager", "path", "UNKNOWN_ATTENDABLE", "hasAttention", "isAncestor", "isRelated", "useAttention", "attendableId", "current", "get", "useAttended", "useAttendableAttributes", "useMemo", "attributes", "useAttentionPath", "RootAttentionProvider", "children", "propsAttention", "onChange", "useDefaultValue", "handleFocus", "event", "selector", "Array", "from", "document", "querySelectorAll", "map", "el", "getAttribute", "join", "prev", "next", "getAttendables", "target", "length", "find", "id", "index", "update", "React", "div", "role", "className", "onFocusCapture", "AttentionProvider", "nextPath"]
|
|
7
|
+
}
|
|
@@ -7,13 +7,14 @@ import {
|
|
|
7
7
|
AttentionProvider,
|
|
8
8
|
AttentionSchema,
|
|
9
9
|
RootAttentionProvider,
|
|
10
|
+
Syncing,
|
|
10
11
|
getAttendables,
|
|
11
12
|
useAttendableAttributes,
|
|
12
13
|
useAttended,
|
|
13
14
|
useAttention,
|
|
14
15
|
useAttentionContext,
|
|
15
16
|
useAttentionPath
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6HZDGBSQ.mjs";
|
|
17
18
|
export {
|
|
18
19
|
ATTENABLE_ATTRIBUTE,
|
|
19
20
|
ATTENTION_NAME,
|
|
@@ -23,6 +24,7 @@ export {
|
|
|
23
24
|
AttentionProvider,
|
|
24
25
|
AttentionSchema,
|
|
25
26
|
RootAttentionProvider,
|
|
27
|
+
Syncing,
|
|
26
28
|
getAttendables,
|
|
27
29
|
useAttendableAttributes,
|
|
28
30
|
useAttended,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/ui/react-ui-attention/src/attention.ts":{"bytes":16001,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/ui/react-ui-attention/src/attention.ts":{"bytes":16001,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx":{"bytes":10623,"imports":[{"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"},"packages/ui/react-ui-attention/src/components/AttentionProvider.tsx":{"bytes":13333,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-attention/src/attention.ts","kind":"import-statement","original":"../attention"}],"format":"esm"},"packages/ui/react-ui-attention/src/components/index.ts":{"bytes":644,"imports":[{"path":"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx","kind":"import-statement","original":"./AttentionGlyph"},{"path":"packages/ui/react-ui-attention/src/components/AttentionProvider.tsx","kind":"import-statement","original":"./AttentionProvider"}],"format":"esm"},"packages/ui/react-ui-attention/src/index.ts":{"bytes":597,"imports":[{"path":"packages/ui/react-ui-attention/src/attention.ts","kind":"import-statement","original":"./attention"},{"path":"packages/ui/react-ui-attention/src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"packages/ui/react-ui-attention/src/testing/decorators/withAttention.ts":{"bytes":1386,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-attention/src/components/index.ts","kind":"import-statement","original":"../../components"}],"format":"esm"},"packages/ui/react-ui-attention/src/testing/decorators/index.ts":{"bytes":534,"imports":[{"path":"packages/ui/react-ui-attention/src/testing/decorators/withAttention.ts","kind":"import-statement","original":"./withAttention"}],"format":"esm"},"packages/ui/react-ui-attention/src/testing/index.ts":{"bytes":516,"imports":[{"path":"packages/ui/react-ui-attention/src/testing/decorators/index.ts","kind":"import-statement","original":"./decorators"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-attention/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/ui/react-ui-attention/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/ui/react-ui-attention/dist/lib/browser/chunk-6HZDGBSQ.mjs","kind":"import-statement"}],"exports":["ATTENABLE_ATTRIBUTE","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","Syncing","getAttendables","useAttendableAttributes","useAttended","useAttention","useAttentionContext","useAttentionPath"],"entryPoint":"packages/ui/react-ui-attention/src/index.ts","inputs":{"packages/ui/react-ui-attention/src/index.ts":{"bytesInOutput":0}},"bytes":693},"packages/ui/react-ui-attention/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":697},"packages/ui/react-ui-attention/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/ui/react-ui-attention/dist/lib/browser/chunk-6HZDGBSQ.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true}],"exports":["withAttention"],"entryPoint":"packages/ui/react-ui-attention/src/testing/index.ts","inputs":{"packages/ui/react-ui-attention/src/testing/decorators/withAttention.ts":{"bytesInOutput":164},"packages/ui/react-ui-attention/src/testing/decorators/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-attention/src/testing/index.ts":{"bytesInOutput":0}},"bytes":367},"packages/ui/react-ui-attention/dist/lib/browser/chunk-6HZDGBSQ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":20157},"packages/ui/react-ui-attention/dist/lib/browser/chunk-6HZDGBSQ.mjs":{"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","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":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["ATTENABLE_ATTRIBUTE","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","Syncing","getAttendables","useAttendableAttributes","useAttended","useAttention","useAttentionContext","useAttentionPath"],"inputs":{"packages/ui/react-ui-attention/src/attention.ts":{"bytesInOutput":3522},"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx":{"bytesInOutput":3212},"packages/ui/react-ui-attention/src/components/AttentionProvider.tsx":{"bytesInOutput":2619},"packages/ui/react-ui-attention/src/components/index.ts":{"bytesInOutput":0}},"bytes":9905}}}
|
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_KQ3CULUO_exports = {};
|
|
30
|
+
__export(chunk_KQ3CULUO_exports, {
|
|
31
31
|
ATTENABLE_ATTRIBUTE: () => ATTENABLE_ATTRIBUTE,
|
|
32
32
|
ATTENTION_NAME: () => ATTENTION_NAME,
|
|
33
33
|
ATTENTION_SOURCE_ATTRIBUTE: () => ATTENTION_SOURCE_ATTRIBUTE,
|
|
@@ -36,6 +36,7 @@ __export(chunk_H55DIJUD_exports, {
|
|
|
36
36
|
AttentionProvider: () => AttentionProvider,
|
|
37
37
|
AttentionSchema: () => AttentionSchema,
|
|
38
38
|
RootAttentionProvider: () => RootAttentionProvider,
|
|
39
|
+
Syncing: () => Syncing,
|
|
39
40
|
getAttendables: () => getAttendables,
|
|
40
41
|
useAttendableAttributes: () => useAttendableAttributes,
|
|
41
42
|
useAttended: () => useAttended,
|
|
@@ -43,16 +44,17 @@ __export(chunk_H55DIJUD_exports, {
|
|
|
43
44
|
useAttentionContext: () => useAttentionContext,
|
|
44
45
|
useAttentionPath: () => useAttentionPath
|
|
45
46
|
});
|
|
46
|
-
module.exports = __toCommonJS(
|
|
47
|
+
module.exports = __toCommonJS(chunk_KQ3CULUO_exports);
|
|
47
48
|
var import_signals_core = require("@preact/signals-core");
|
|
48
49
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
49
50
|
var import_live_object = require("@dxos/live-object");
|
|
50
51
|
var import_util = require("@dxos/util");
|
|
51
52
|
var import_react = __toESM(require("react"));
|
|
53
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
52
54
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
53
55
|
var import_react_context = require("@radix-ui/react-context");
|
|
54
56
|
var import_react2 = __toESM(require("react"));
|
|
55
|
-
var
|
|
57
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
56
58
|
var AttentionSchema = import_echo_schema.S.mutable(import_echo_schema.S.Struct({
|
|
57
59
|
hasAttention: import_echo_schema.S.Boolean,
|
|
58
60
|
isAncestor: import_echo_schema.S.Boolean,
|
|
@@ -153,7 +155,7 @@ var getAttendables = (selector, cursor, acc = []) => {
|
|
|
153
155
|
...new Set(acc)
|
|
154
156
|
];
|
|
155
157
|
};
|
|
156
|
-
var attentionGlyphStyles = "inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse";
|
|
158
|
+
var attentionGlyphStyles = "inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-contains-attended=true]_&]:bg-attentionRelated [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse";
|
|
157
159
|
var presenceIconStyles = "is-3 bs-3 group-[[aria-current]_&:hover]/attentionGlyphButton:hidden group-[[aria-current]_&:focus]/attentionGlyphButton:hidden group-[[data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[data-attention=true]_&:focus]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:focus]/attentionGlyphButton:hidden";
|
|
158
160
|
var PresenceOne = () => {
|
|
159
161
|
return /* @__PURE__ */ import_react.default.createElement("svg", {
|
|
@@ -188,13 +190,34 @@ var PresenceMany = () => {
|
|
|
188
190
|
fill: "currentColor"
|
|
189
191
|
}));
|
|
190
192
|
};
|
|
191
|
-
var
|
|
192
|
-
|
|
193
|
+
var Syncing = () => {
|
|
194
|
+
const animationProps = (0, import_react.useMemo)(() => ({
|
|
195
|
+
// Synchronize animations.
|
|
196
|
+
animationDelay: `-${Date.now() % 2e3}ms`
|
|
197
|
+
}), []);
|
|
198
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
199
|
+
role: "status",
|
|
200
|
+
className: "flex items-center"
|
|
201
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Icon, {
|
|
202
|
+
icon: "ph--circle-notch--regular",
|
|
203
|
+
size: 3,
|
|
204
|
+
style: animationProps,
|
|
205
|
+
classNames: "text-subdued animate-[spin_2s_linear_infinite]"
|
|
206
|
+
}));
|
|
207
|
+
};
|
|
208
|
+
var AttentionGlyph = /* @__PURE__ */ (0, import_react.forwardRef)(({ presence, attended, syncing, containsAttended, classNames, ...props }, forwardedRef) => {
|
|
209
|
+
const icon = syncing ? /* @__PURE__ */ import_react.default.createElement(Syncing, null) : presence === "many" ? /* @__PURE__ */ import_react.default.createElement(PresenceMany, null) : presence === "one" ? /* @__PURE__ */ import_react.default.createElement(PresenceOne, null) : null;
|
|
210
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
211
|
+
role: "none",
|
|
212
|
+
className: "flex",
|
|
213
|
+
"data-attention": attended,
|
|
214
|
+
"data-contains-attended": containsAttended
|
|
215
|
+
}, /* @__PURE__ */ import_react.default.createElement("span", {
|
|
193
216
|
role: "none",
|
|
194
217
|
...props,
|
|
195
218
|
className: (0, import_react_ui_theme.mx)(attentionGlyphStyles, classNames),
|
|
196
219
|
ref: forwardedRef
|
|
197
|
-
},
|
|
220
|
+
}, icon));
|
|
198
221
|
});
|
|
199
222
|
var ATTENTION_NAME = "Attention";
|
|
200
223
|
var ATTENABLE_ATTRIBUTE = "data-attendable-id";
|
|
@@ -243,7 +266,7 @@ var useAttentionPath = () => {
|
|
|
243
266
|
return path;
|
|
244
267
|
};
|
|
245
268
|
var RootAttentionProvider = ({ children, attention: propsAttention, onChange }) => {
|
|
246
|
-
const attention = (0,
|
|
269
|
+
const attention = (0, import_react_ui2.useDefaultValue)(propsAttention, () => new AttentionManager());
|
|
247
270
|
const handleFocus = (event) => {
|
|
248
271
|
const selector = [
|
|
249
272
|
"[data-attendable-id]",
|
|
@@ -289,6 +312,7 @@ var AttentionProvider = ({ id, children }) => {
|
|
|
289
312
|
AttentionProvider,
|
|
290
313
|
AttentionSchema,
|
|
291
314
|
RootAttentionProvider,
|
|
315
|
+
Syncing,
|
|
292
316
|
getAttendables,
|
|
293
317
|
useAttendableAttributes,
|
|
294
318
|
useAttended,
|
|
@@ -296,4 +320,4 @@ var AttentionProvider = ({ id, children }) => {
|
|
|
296
320
|
useAttentionContext,
|
|
297
321
|
useAttentionPath
|
|
298
322
|
});
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
323
|
+
//# sourceMappingURL=chunk-KQ3CULUO.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/attention.ts", "../../../src/components/AttentionGlyph.tsx", "../../../src/components/AttentionProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { untracked } from '@preact/signals-core';\n\nimport { S } from '@dxos/echo-schema';\nimport { create, type ReactiveObject } from '@dxos/live-object';\nimport { ComplexMap } from '@dxos/util';\n\nexport const AttentionSchema = S.mutable(\n S.Struct({\n hasAttention: S.Boolean,\n isAncestor: S.Boolean,\n isRelated: S.Boolean,\n }),\n);\n\nexport type Attention = S.Schema.Type<typeof AttentionSchema>;\n\n// TODO(wittjosiah): Use mosaic path utility?\nconst stringKey = (key: string[]) => key.join(',');\n\n/**\n * Manages attention state for an application.\n */\n// TODO(wittjosiah): Write unit tests.\nexport class AttentionManager {\n // Each attention path is associated with an attention object.\n // The lookup is not a reactive object to ensure that attention for each path is subscribable independently.\n private readonly _map = new ComplexMap<string[], ReactiveObject<Attention>>(stringKey);\n private readonly _state = create<{ current: string[] }>({ current: [] });\n\n constructor(initial: string[] = []) {\n if (initial.length > 0) {\n this.update(initial);\n }\n }\n\n /**\n * Currently attended element.\n */\n get current() {\n return this._state.current;\n }\n\n /**\n * All attention paths.\n */\n keys() {\n return Array.from(this._map.keys());\n }\n\n /**\n * Get the attention state for a given path.\n */\n get(key: string[]): ReactiveObject<Attention> {\n const object = this._map.get(key);\n if (object) {\n return object;\n }\n\n const newObject = create(AttentionSchema, { hasAttention: false, isAncestor: false, isRelated: false });\n this._map.set(key, newObject);\n return newObject;\n }\n\n /**\n * Update the currently attended element.\n */\n update(nextKey: string[]) {\n const currentKey = untracked(() => this.current);\n const currentRelatedTo = currentKey[0];\n const nextRelatedTo = nextKey[0];\n\n // Ensure related attention object is initialized.\n this.get([nextRelatedTo]);\n\n const currentRelatedKeys = this.keys().filter((key) => key[0] === currentRelatedTo);\n const nextRelatedKeys = this.keys().filter(\n (key) => key[0] === nextRelatedTo && stringKey(key) !== stringKey(nextKey),\n );\n const prevRelatedKeys = currentRelatedKeys.filter(\n (curr) => !nextRelatedKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n const currentAncestorKeys = currentKey.slice(1).map((_, i) => currentKey.slice(i + 1, currentKey.length));\n const nextAncestorKeys = nextKey.slice(1).map((_, i) => nextKey.slice(i + 1, nextKey.length));\n const prevAncestorKeys = currentAncestorKeys.filter(\n (curr) => !nextAncestorKeys.find((next) => stringKey(curr) === stringKey(next)),\n );\n\n this._state.current = nextKey;\n prevRelatedKeys.forEach((key) => this._set(key, {}));\n prevAncestorKeys.forEach((key) => this._set(key, {}));\n nextRelatedKeys.forEach((key) => this._set(key, { isRelated: true }));\n nextAncestorKeys.forEach((key) => this._set(key, { isAncestor: true }));\n this._set(nextKey, { hasAttention: true });\n }\n\n private _set(key: string[], attention: Partial<Attention>) {\n const object = this.get(key);\n object.hasAttention = attention.hasAttention ?? false;\n object.isAncestor = attention.isAncestor ?? false;\n object.isRelated = attention.isRelated ?? false;\n }\n}\n\n/**\n * Accumulates all attendable id’s between the element provided and the root, inclusive.\n */\nexport const getAttendables = (selector: string, cursor: Element, acc: string[] = []): string[] => {\n // Find the closest element with `data-attendable-id`, if any; start from cursor and move up the DOM tree.\n const closestAttendable = cursor.closest(selector);\n if (closestAttendable) {\n const attendableId = closestAttendable.getAttribute('data-attendable-id');\n if (!attendableId) {\n // this has an id of an aria-controls elsewhere on the page, move cursor to that trigger\n const trigger = document.querySelector(`[aria-controls=\"${closestAttendable.getAttribute('id')}\"]`);\n if (!trigger) {\n return acc;\n } else {\n return getAttendables(selector, trigger, acc);\n }\n } else {\n acc.push(attendableId);\n // (attempt tail recursion)\n return !closestAttendable.parentElement ? acc : getAttendables(selector, closestAttendable.parentElement, acc);\n }\n }\n\n return [...new Set(acc)];\n};\n\nexport type AttendableId = { attendableId?: string };\n\nexport type Related = { related?: boolean };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, type CSSProperties, forwardRef, useMemo } from 'react';\n\nimport { Icon, type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nconst attentionGlyphStyles =\n 'inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-contains-attended=true]_&]:bg-attentionRelated [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse';\n\nconst presenceIconStyles =\n 'is-3 bs-3 group-[[aria-current]_&:hover]/attentionGlyphButton:hidden group-[[aria-current]_&:focus]/attentionGlyphButton:hidden group-[[data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[data-attention=true]_&:focus]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:focus]/attentionGlyphButton:hidden';\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--regular'\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 role='none' className='flex' 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", "//\n// Copyright 2024 DXOS.org\n//\n\n// NOTE(thure): The following unused imports quell TS2742 (“likely not portable”).\n\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { createContext, type Scope, type CreateScope } from '@radix-ui/react-context';\nimport React, { useMemo, type FocusEvent, type PropsWithChildren } from 'react';\n\nimport { useDefaultValue } from '@dxos/react-ui';\n\nimport { type Attention, AttentionManager, getAttendables } from '../attention';\n\nconst ATTENTION_NAME = 'Attention';\nconst ATTENABLE_ATTRIBUTE = 'data-attendable-id';\nconst ATTENTION_SOURCE_ATTRIBUTE = 'data-is-attention-source';\n\ntype AttentionContextValue = {\n attention: AttentionManager;\n path: string[];\n};\n\nconst [AttentionContextProvider, useAttentionContext] = createContext<AttentionContextValue>(ATTENTION_NAME, {\n attention: new AttentionManager(),\n path: [],\n});\n\nconst UNKNOWN_ATTENDABLE = { hasAttention: false, isAncestor: false, isRelated: false };\n\nconst useAttention = (attendableId?: string): Attention => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n if (!attendableId) {\n return UNKNOWN_ATTENDABLE;\n }\n\n const current = [attendableId, ...path];\n return attention.get(current);\n};\n\nconst useAttended = () => {\n const { attention } = useAttentionContext(ATTENTION_NAME);\n return attention.current;\n};\n\n/**\n * Computes HTML element attributes to apply so the attention system can detect changes\n * @param attendableId\n */\nconst useAttendableAttributes = (attendableId?: string) => {\n const { hasAttention } = useAttention(attendableId);\n return useMemo(() => {\n const attributes: Record<string, string | undefined> = { [ATTENABLE_ATTRIBUTE]: attendableId };\n if (hasAttention) {\n attributes[ATTENTION_SOURCE_ATTRIBUTE] = 'true';\n }\n\n return attributes;\n }, [attendableId, hasAttention]);\n};\n\nconst useAttentionPath = () => {\n const { path } = useAttentionContext(ATTENTION_NAME);\n return path;\n};\n\nconst RootAttentionProvider = ({\n children,\n attention: propsAttention,\n onChange,\n}: PropsWithChildren<\n Partial<{\n attention: AttentionManager;\n onChange: (nextAttended: string[]) => void;\n }>\n>) => {\n const attention = useDefaultValue(propsAttention, () => new AttentionManager());\n const handleFocus = (event: FocusEvent) => {\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.current;\n const next = getAttendables(selector, event.target);\n // TODO(wittjosiah): Not allowing empty state means that the attended item is not strictly guaranteed to be in the DOM.\n // Currently this depends on the deck in order to ensure that when the attended item is removed something else is attended.\n // Only update state if the result is different and not empty.\n if (next.length > 0 && (prev.length !== next.length || !!prev.find((id, index) => next[index] !== id))) {\n attention.update(next);\n onChange?.(next);\n }\n };\n\n return (\n <AttentionContextProvider attention={attention} path={[]}>\n <div role='none' className='contents' onFocusCapture={handleFocus}>\n {children}\n </div>\n </AttentionContextProvider>\n );\n};\n\nconst AttentionProvider = ({ id, children }: PropsWithChildren<{ id: string }>) => {\n const { attention, path } = useAttentionContext(ATTENTION_NAME);\n const nextPath = useMemo(() => [id, ...path], [id, path]);\n\n return (\n <AttentionContextProvider attention={attention} path={nextPath}>\n {children}\n </AttentionContextProvider>\n );\n};\n\nexport {\n RootAttentionProvider,\n AttentionProvider,\n useAttentionContext,\n useAttention,\n useAttended,\n useAttendableAttributes,\n useAttentionPath,\n ATTENTION_NAME,\n ATTENABLE_ATTRIBUTE,\n ATT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AAC+G,KAAK3F,KAAK,CAAC6F,IAAIC,UAAU7F,KAAK6F,KAAAA,MAAWD,EAAAA,IAAM;AACtGlF,gBAAU9B,OAAOoB,IAAAA;AACjBoF,iBAAWpF,IAAAA;IACb;EACF;AAEA,SACE4B,8BAAAA,QAAA,cAAC4C,0BAAAA;IAAyB9D;IAAsB+B,MAAM,CAAA;KACpDb,8BAAAA,QAAA,cAACqB,OAAAA;IAAIC,MAAK;IAAOjB,WAAU;IAAW6D,gBAAgBR;KACnDJ,QAAAA,CAAAA;AAIT;AAEA,IAAMa,oBAAoB,CAAC,EAAEH,IAAIV,SAAQ,MAAqC;AAC5E,QAAM,EAAExE,WAAW+B,KAAI,IAAKgC,oBAAoBJ,cAAAA;AAChD,QAAM2B,eAAWnD,cAAAA,SAAQ,MAAM;IAAC+C;OAAOnD;KAAO;IAACmD;IAAInD;GAAK;AAExD,SACEb,8BAAAA,QAAA,cAAC4C,0BAAAA;IAAyB9D;IAAsB+B,MAAMuD;KACnDd,QAAAA;AAGP;",
|
|
6
|
+
"names": ["import_react", "import_react_ui", "AttentionSchema", "S", "mutable", "Struct", "hasAttention", "Boolean", "isAncestor", "isRelated", "stringKey", "key", "join", "AttentionManager", "constructor", "initial", "ComplexMap", "_state", "create", "current", "length", "update", "keys", "Array", "from", "_map", "get", "object", "newObject", "set", "nextKey", "currentKey", "untracked", "currentRelatedTo", "nextRelatedTo", "currentRelatedKeys", "filter", "nextRelatedKeys", "prevRelatedKeys", "curr", "find", "next", "currentAncestorKeys", "slice", "map", "_", "i", "nextAncestorKeys", "prevAncestorKeys", "forEach", "_set", "attention", "getAttendables", "selector", "cursor", "acc", "closestAttendable", "closest", "attendableId", "getAttribute", "trigger", "document", "querySelector", "push", "parentElement", "Set", "attentionGlyphStyles", "presenceIconStyles", "PresenceOne", "React", "svg", "width", "height", "viewBox", "className", "fill", "xmlns", "circle", "cx", "cy", "r", "PresenceMany", "path", "d", "Syncing", "animationProps", "useMemo", "animationDelay", "Date", "now", "div", "role", "Icon", "icon", "size", "style", "classNames", "AttentionGlyph", "forwardRef", "presence", "attended", "syncing", "containsAttended", "props", "forwardedRef", "data-attention", "data-contains-attended", "span", "mx", "ref", "ATTENTION_NAME", "ATTENABLE_ATTRIBUTE", "ATTENTION_SOURCE_ATTRIBUTE", "AttentionContextProvider", "useAttentionContext", "createContext", "UNKNOWN_ATTENDABLE", "useAttention", "useAttended", "useAttendableAttributes", "attributes", "useAttentionPath", "RootAttentionProvider", "children", "propsAttention", "onChange", "useDefaultValue", "handleFocus", "event", "querySelectorAll", "el", "prev", "target", "id", "index", "onFocusCapture", "AttentionProvider", "nextPath"]
|
|
7
|
+
}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,23 +18,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var node_exports = {};
|
|
20
20
|
__export(node_exports, {
|
|
21
|
-
ATTENABLE_ATTRIBUTE: () =>
|
|
22
|
-
ATTENTION_NAME: () =>
|
|
23
|
-
ATTENTION_SOURCE_ATTRIBUTE: () =>
|
|
24
|
-
AttentionGlyph: () =>
|
|
25
|
-
AttentionManager: () =>
|
|
26
|
-
AttentionProvider: () =>
|
|
27
|
-
AttentionSchema: () =>
|
|
28
|
-
RootAttentionProvider: () =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
ATTENABLE_ATTRIBUTE: () => import_chunk_KQ3CULUO.ATTENABLE_ATTRIBUTE,
|
|
22
|
+
ATTENTION_NAME: () => import_chunk_KQ3CULUO.ATTENTION_NAME,
|
|
23
|
+
ATTENTION_SOURCE_ATTRIBUTE: () => import_chunk_KQ3CULUO.ATTENTION_SOURCE_ATTRIBUTE,
|
|
24
|
+
AttentionGlyph: () => import_chunk_KQ3CULUO.AttentionGlyph,
|
|
25
|
+
AttentionManager: () => import_chunk_KQ3CULUO.AttentionManager,
|
|
26
|
+
AttentionProvider: () => import_chunk_KQ3CULUO.AttentionProvider,
|
|
27
|
+
AttentionSchema: () => import_chunk_KQ3CULUO.AttentionSchema,
|
|
28
|
+
RootAttentionProvider: () => import_chunk_KQ3CULUO.RootAttentionProvider,
|
|
29
|
+
Syncing: () => import_chunk_KQ3CULUO.Syncing,
|
|
30
|
+
getAttendables: () => import_chunk_KQ3CULUO.getAttendables,
|
|
31
|
+
useAttendableAttributes: () => import_chunk_KQ3CULUO.useAttendableAttributes,
|
|
32
|
+
useAttended: () => import_chunk_KQ3CULUO.useAttended,
|
|
33
|
+
useAttention: () => import_chunk_KQ3CULUO.useAttention,
|
|
34
|
+
useAttentionContext: () => import_chunk_KQ3CULUO.useAttentionContext,
|
|
35
|
+
useAttentionPath: () => import_chunk_KQ3CULUO.useAttentionPath
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(node_exports);
|
|
37
|
-
var
|
|
38
|
+
var import_chunk_KQ3CULUO = require("./chunk-KQ3CULUO.cjs");
|
|
38
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
40
|
0 && (module.exports = {
|
|
40
41
|
ATTENABLE_ATTRIBUTE,
|
|
@@ -45,6 +46,7 @@ var import_chunk_H55DIJUD = require("./chunk-H55DIJUD.cjs");
|
|
|
45
46
|
AttentionProvider,
|
|
46
47
|
AttentionSchema,
|
|
47
48
|
RootAttentionProvider,
|
|
49
|
+
Syncing,
|
|
48
50
|
getAttendables,
|
|
49
51
|
useAttendableAttributes,
|
|
50
52
|
useAttended,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.cjs"],
|
|
4
|
-
"sourcesContent": ["import {\n ATTENABLE_ATTRIBUTE,\n ATTENTION_NAME,\n ATTENTION_SOURCE_ATTRIBUTE,\n AttentionGlyph,\n AttentionManager,\n AttentionProvider,\n AttentionSchema,\n RootAttentionProvider,\n getAttendables,\n useAttendableAttributes,\n useAttended,\n useAttention,\n useAttentionContext,\n useAttentionPath\n} from \"./chunk-
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n ATTENABLE_ATTRIBUTE,\n ATTENTION_NAME,\n ATTENTION_SOURCE_ATTRIBUTE,\n AttentionGlyph,\n AttentionManager,\n AttentionProvider,\n AttentionSchema,\n RootAttentionProvider,\n Syncing,\n getAttendables,\n useAttendableAttributes,\n useAttended,\n useAttention,\n useAttentionContext,\n useAttentionPath\n} from \"./chunk-KQ3CULUO.cjs\";\nexport {\n ATTENABLE_ATTRIBUTE,\n ATTENTION_NAME,\n ATTENTION_SOURCE_ATTRIBUTE,\n AttentionGlyph,\n AttentionManager,\n AttentionProvider,\n AttentionSchema,\n RootAttentionProvider,\n Syncing,\n getAttendables,\n useAttendableAttributes,\n useAttended,\n useAttention,\n useAttentionContext,\n useAttentionPath\n};\n//# sourceMappingURL=index.cjs.map\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAgBO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/ui/react-ui-attention/src/attention.ts":{"bytes":16001,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/ui/react-ui-attention/src/attention.ts":{"bytes":16001,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx":{"bytes":10623,"imports":[{"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"},"packages/ui/react-ui-attention/src/components/AttentionProvider.tsx":{"bytes":13333,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-attention/src/attention.ts","kind":"import-statement","original":"../attention"}],"format":"esm"},"packages/ui/react-ui-attention/src/components/index.ts":{"bytes":644,"imports":[{"path":"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx","kind":"import-statement","original":"./AttentionGlyph"},{"path":"packages/ui/react-ui-attention/src/components/AttentionProvider.tsx","kind":"import-statement","original":"./AttentionProvider"}],"format":"esm"},"packages/ui/react-ui-attention/src/index.ts":{"bytes":597,"imports":[{"path":"packages/ui/react-ui-attention/src/attention.ts","kind":"import-statement","original":"./attention"},{"path":"packages/ui/react-ui-attention/src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"packages/ui/react-ui-attention/src/testing/decorators/withAttention.ts":{"bytes":1386,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-attention/src/components/index.ts","kind":"import-statement","original":"../../components"}],"format":"esm"},"packages/ui/react-ui-attention/src/testing/decorators/index.ts":{"bytes":534,"imports":[{"path":"packages/ui/react-ui-attention/src/testing/decorators/withAttention.ts","kind":"import-statement","original":"./withAttention"}],"format":"esm"},"packages/ui/react-ui-attention/src/testing/index.ts":{"bytes":516,"imports":[{"path":"packages/ui/react-ui-attention/src/testing/decorators/index.ts","kind":"import-statement","original":"./decorators"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-attention/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/ui/react-ui-attention/dist/lib/node/index.cjs":{"imports":[{"path":"packages/ui/react-ui-attention/dist/lib/node/chunk-KQ3CULUO.cjs","kind":"import-statement"}],"exports":["ATTENABLE_ATTRIBUTE","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","Syncing","getAttendables","useAttendableAttributes","useAttended","useAttention","useAttentionContext","useAttentionPath"],"entryPoint":"packages/ui/react-ui-attention/src/index.ts","inputs":{"packages/ui/react-ui-attention/src/index.ts":{"bytesInOutput":0}},"bytes":693},"packages/ui/react-ui-attention/dist/lib/node/testing/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":697},"packages/ui/react-ui-attention/dist/lib/node/testing/index.cjs":{"imports":[{"path":"packages/ui/react-ui-attention/dist/lib/node/chunk-KQ3CULUO.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true}],"exports":["withAttention"],"entryPoint":"packages/ui/react-ui-attention/src/testing/index.ts","inputs":{"packages/ui/react-ui-attention/src/testing/decorators/withAttention.ts":{"bytesInOutput":164},"packages/ui/react-ui-attention/src/testing/decorators/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-attention/src/testing/index.ts":{"bytesInOutput":0}},"bytes":367},"packages/ui/react-ui-attention/dist/lib/node/chunk-KQ3CULUO.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":20157},"packages/ui/react-ui-attention/dist/lib/node/chunk-KQ3CULUO.cjs":{"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","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":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["ATTENABLE_ATTRIBUTE","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","Syncing","getAttendables","useAttendableAttributes","useAttended","useAttention","useAttentionContext","useAttentionPath"],"inputs":{"packages/ui/react-ui-attention/src/attention.ts":{"bytesInOutput":3522},"packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx":{"bytesInOutput":3212},"packages/ui/react-ui-attention/src/components/AttentionProvider.tsx":{"bytesInOutput":2619},"packages/ui/react-ui-attention/src/components/index.ts":{"bytesInOutput":0}},"bytes":9905}}}
|
|
@@ -21,10 +21,10 @@ __export(testing_exports, {
|
|
|
21
21
|
withAttention: () => withAttention
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(testing_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_chunk_KQ3CULUO = require("../chunk-KQ3CULUO.cjs");
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
var withAttention = (Story) => {
|
|
27
|
-
return (0, import_react.createElement)(
|
|
27
|
+
return (0, import_react.createElement)(import_chunk_KQ3CULUO.RootAttentionProvider, {
|
|
28
28
|
children: (0, import_react.createElement)(Story)
|
|
29
29
|
});
|
|
30
30
|
};
|
|
@@ -109,9 +109,10 @@ var getAttendables = (selector, cursor, acc = []) => {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
// packages/ui/react-ui-attention/src/components/AttentionGlyph.tsx
|
|
112
|
-
import React, { forwardRef } from "react";
|
|
112
|
+
import React, { forwardRef, useMemo } from "react";
|
|
113
|
+
import { Icon } from "@dxos/react-ui";
|
|
113
114
|
import { mx } from "@dxos/react-ui-theme";
|
|
114
|
-
var attentionGlyphStyles = "inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse";
|
|
115
|
+
var attentionGlyphStyles = "inline-block rounded-sm is-3 bs-3 bg-transparent text-accentText transition-colors [[data-contains-attended=true]_&]:bg-attentionRelated [[data-attention=true]_&]:bg-accentSurface [[data-attention=true]_&]:text-inverse [[aria-current][data-attention=true]_&]:bg-accentSurface [[aria-current][data-attention=true]_&]:text-inverse";
|
|
115
116
|
var presenceIconStyles = "is-3 bs-3 group-[[aria-current]_&:hover]/attentionGlyphButton:hidden group-[[aria-current]_&:focus]/attentionGlyphButton:hidden group-[[data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[data-attention=true]_&:focus]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:hover]/attentionGlyphButton:hidden group-[[aria-current][data-attention=true]_&:focus]/attentionGlyphButton:hidden";
|
|
116
117
|
var PresenceOne = () => {
|
|
117
118
|
return /* @__PURE__ */ React.createElement("svg", {
|
|
@@ -146,18 +147,39 @@ var PresenceMany = () => {
|
|
|
146
147
|
fill: "currentColor"
|
|
147
148
|
}));
|
|
148
149
|
};
|
|
149
|
-
var
|
|
150
|
-
|
|
150
|
+
var Syncing = () => {
|
|
151
|
+
const animationProps = useMemo(() => ({
|
|
152
|
+
// Synchronize animations.
|
|
153
|
+
animationDelay: `-${Date.now() % 2e3}ms`
|
|
154
|
+
}), []);
|
|
155
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
156
|
+
role: "status",
|
|
157
|
+
className: "flex items-center"
|
|
158
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
159
|
+
icon: "ph--circle-notch--regular",
|
|
160
|
+
size: 3,
|
|
161
|
+
style: animationProps,
|
|
162
|
+
classNames: "text-subdued animate-[spin_2s_linear_infinite]"
|
|
163
|
+
}));
|
|
164
|
+
};
|
|
165
|
+
var AttentionGlyph = /* @__PURE__ */ forwardRef(({ presence, attended, syncing, containsAttended, classNames, ...props }, forwardedRef) => {
|
|
166
|
+
const icon = syncing ? /* @__PURE__ */ React.createElement(Syncing, null) : presence === "many" ? /* @__PURE__ */ React.createElement(PresenceMany, null) : presence === "one" ? /* @__PURE__ */ React.createElement(PresenceOne, null) : null;
|
|
167
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
168
|
+
role: "none",
|
|
169
|
+
className: "flex",
|
|
170
|
+
"data-attention": attended,
|
|
171
|
+
"data-contains-attended": containsAttended
|
|
172
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
151
173
|
role: "none",
|
|
152
174
|
...props,
|
|
153
175
|
className: mx(attentionGlyphStyles, classNames),
|
|
154
176
|
ref: forwardedRef
|
|
155
|
-
},
|
|
177
|
+
}, icon));
|
|
156
178
|
});
|
|
157
179
|
|
|
158
180
|
// packages/ui/react-ui-attention/src/components/AttentionProvider.tsx
|
|
159
181
|
import { createContext } from "@radix-ui/react-context";
|
|
160
|
-
import React2, { useMemo } from "react";
|
|
182
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
161
183
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
162
184
|
var ATTENTION_NAME = "Attention";
|
|
163
185
|
var ATTENABLE_ATTRIBUTE = "data-attendable-id";
|
|
@@ -188,7 +210,7 @@ var useAttended = () => {
|
|
|
188
210
|
};
|
|
189
211
|
var useAttendableAttributes = (attendableId) => {
|
|
190
212
|
const { hasAttention } = useAttention(attendableId);
|
|
191
|
-
return
|
|
213
|
+
return useMemo2(() => {
|
|
192
214
|
const attributes = {
|
|
193
215
|
[ATTENABLE_ATTRIBUTE]: attendableId
|
|
194
216
|
};
|
|
@@ -230,7 +252,7 @@ var RootAttentionProvider = ({ children, attention: propsAttention, onChange })
|
|
|
230
252
|
};
|
|
231
253
|
var AttentionProvider = ({ id, children }) => {
|
|
232
254
|
const { attention, path } = useAttentionContext(ATTENTION_NAME);
|
|
233
|
-
const nextPath =
|
|
255
|
+
const nextPath = useMemo2(() => [
|
|
234
256
|
id,
|
|
235
257
|
...path
|
|
236
258
|
], [
|
|
@@ -247,6 +269,7 @@ export {
|
|
|
247
269
|
AttentionSchema,
|
|
248
270
|
AttentionManager,
|
|
249
271
|
getAttendables,
|
|
272
|
+
Syncing,
|
|
250
273
|
AttentionGlyph,
|
|
251
274
|
ATTENTION_NAME,
|
|
252
275
|
ATTENABLE_ATTRIBUTE,
|
|
@@ -259,4 +282,4 @@ export {
|
|
|
259
282
|
RootAttentionProvider,
|
|
260
283
|
AttentionProvider
|
|
261
284
|
};
|
|
262
|
-
//# sourceMappingURL=chunk-
|
|
285
|
+
//# sourceMappingURL=chunk-5VF6FMOU.mjs.map
|