@dxos/react-ui-attention 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/lib/browser/chunk-DAIZNFKL.mjs +668 -0
  2. package/dist/lib/browser/chunk-DAIZNFKL.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +86 -13
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +20 -7
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/browser/types.mjs +1 -0
  9. package/dist/lib/browser/types.mjs.map +7 -0
  10. package/dist/lib/node-esm/chunk-HZTQDMTS.mjs +670 -0
  11. package/dist/lib/node-esm/chunk-HZTQDMTS.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +86 -13
  13. package/dist/lib/node-esm/index.mjs.map +4 -4
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +20 -7
  16. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  17. package/dist/lib/node-esm/types.mjs +2 -0
  18. package/dist/lib/node-esm/types.mjs.map +7 -0
  19. package/dist/types/src/attention.d.ts +56 -20
  20. package/dist/types/src/attention.d.ts.map +1 -1
  21. package/dist/types/src/components/AttentionGlyph.d.ts.map +1 -1
  22. package/dist/types/src/components/AttentionGlyph.stories.d.ts +9 -20
  23. package/dist/types/src/components/AttentionGlyph.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/AttentionProvider.d.ts +15 -16
  25. package/dist/types/src/components/AttentionProvider.d.ts.map +1 -1
  26. package/dist/types/src/components/AttentionProvider.stories.d.ts +6 -4
  27. package/dist/types/src/components/AttentionProvider.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/SelectionProvider.d.ts +6 -5
  29. package/dist/types/src/components/SelectionProvider.d.ts.map +1 -1
  30. package/dist/types/src/selection.d.ts +49 -17
  31. package/dist/types/src/selection.d.ts.map +1 -1
  32. package/dist/types/src/testing/decorators/withAttention.d.ts +5 -1
  33. package/dist/types/src/testing/decorators/withAttention.d.ts.map +1 -1
  34. package/dist/types/src/types.d.ts +9 -0
  35. package/dist/types/src/types.d.ts.map +1 -0
  36. package/dist/types/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +35 -31
  38. package/src/attention.test.ts +188 -27
  39. package/src/attention.ts +175 -74
  40. package/src/components/AttentionGlyph.stories.tsx +17 -14
  41. package/src/components/AttentionGlyph.tsx +14 -7
  42. package/src/components/AttentionProvider.stories.tsx +12 -9
  43. package/src/components/AttentionProvider.tsx +80 -97
  44. package/src/components/SelectionProvider.tsx +66 -19
  45. package/src/selection.ts +135 -65
  46. package/src/testing/decorators/withAttention.ts +21 -4
  47. package/src/types.ts +13 -0
  48. package/dist/lib/browser/chunk-QPEFFJ4E.mjs +0 -616
  49. package/dist/lib/browser/chunk-QPEFFJ4E.mjs.map +0 -7
  50. package/dist/lib/node-esm/chunk-F2JRKDYV.mjs +0 -618
  51. package/dist/lib/node-esm/chunk-F2JRKDYV.mjs.map +0 -7
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/attention.ts", "../../../src/components/AttentionProvider.tsx", "../../../src/selection.ts", "../../../src/components/SelectionProvider.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\n\nimport { type Attention } from './types';\n\n/**\n * Manages attention state for an application.\n * Attention keys are slash-qualified graph IDs; ancestry is derived from progressive prefixes.\n */\nexport class AttentionManager {\n private readonly _map = new Map<string, Atom.Writable<Attention>>();\n private readonly _currentAtom: Atom.Writable<string[]>;\n\n constructor(\n private readonly _registry: Registry.Registry,\n initial: string[] = [],\n ) {\n this._currentAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n if (initial.length > 0) {\n this.update(initial);\n }\n }\n\n /**\n * Atom for the currently attended element IDs.\n */\n get current(): Atom.Atom<string[]> {\n return this._currentAtom;\n }\n\n /**\n * Gets the currently attended element IDs.\n */\n getCurrent(): readonly string[] {\n return this._registry.get(this._currentAtom);\n }\n\n /**\n * Subscribe to changes in the current attention IDs.\n */\n subscribeCurrent(cb: (current: readonly string[]) => void): () => void {\n this._registry.get(this._currentAtom);\n return this._registry.subscribe(this._currentAtom, () => {\n cb(this._registry.get(this._currentAtom));\n });\n }\n\n /**\n * All tracked qualified IDs.\n */\n keys(): string[] {\n return Array.from(this._map.keys());\n }\n\n /**\n * Get the attention state for a given qualified ID.\n */\n get(id: string): Attention {\n const atom = this._getAtom(id);\n return this._registry.get(atom);\n }\n\n /**\n * Subscribe to changes in the attention state for a given qualified ID.\n */\n subscribe(id: string, cb: (attention: Attention) => void): () => void {\n const atom = this._getAtom(id);\n this._registry.get(atom);\n return this._registry.subscribe(atom, () => {\n cb(this._registry.get(atom));\n });\n }\n\n private _getAtom(id: string): Atom.Writable<Attention> {\n const existing = this._map.get(id);\n if (existing) {\n return existing;\n }\n\n const newAtom = Atom.make<Attention>({ hasAttention: false, isAncestor: false, isRelated: false }).pipe(\n Atom.keepAlive,\n );\n this._map.set(id, newAtom);\n return newAtom;\n }\n\n /**\n * Update the currently attended element.\n * Takes the array of qualified IDs collected from the DOM; the first element is the primary attended item.\n * Ancestry is derived from the progressive prefixes of the primary ID.\n * Relatedness is derived from the segment ID: any tracked key whose last `/` segment matches the\n * attended ID's segment ID is marked `isRelated`. Additionally, if the primary ID is a linked segment\n * (starts with `~`), its immediate parent gets `isRelated` alongside `isAncestor`.\n *\n * @internal\n */\n update(nextIds: string[]): void {\n const primaryId = nextIds[0];\n if (!primaryId) {\n return;\n }\n\n const currentIds = this.getCurrent();\n const prevPrimaryId = currentIds[0];\n // Clear previous attention state: ancestors, primary, and related keys.\n if (prevPrimaryId) {\n const prevPrefixes = expandAttendableId(prevPrimaryId);\n for (const prefix of prevPrefixes) {\n this._set(prefix, {});\n }\n const prevSegmentId = getSegmentId(prevPrimaryId);\n for (const key of this.keys()) {\n if (getSegmentId(key) === prevSegmentId) {\n this._set(key, {});\n }\n }\n }\n\n this._registry.set(this._currentAtom, nextIds);\n\n // Set ancestors and primary.\n const prefixes = expandAttendableId(primaryId);\n const prefixSet = new Set(prefixes);\n const linkedParent = isLinkedSegment(primaryId) ? getParentId(primaryId) : undefined;\n\n for (const prefix of prefixes) {\n if (prefix === primaryId) {\n this._set(prefix, { hasAttention: true });\n } else if (prefix === linkedParent) {\n this._set(prefix, { isAncestor: true, isRelated: true });\n } else {\n this._set(prefix, { isAncestor: true });\n }\n }\n\n // Set related keys: any tracked key sharing the same segment ID.\n const segmentId = getSegmentId(primaryId);\n for (const key of this.keys()) {\n if (!prefixSet.has(key) && getSegmentId(key) === segmentId) {\n this._set(key, { isRelated: true });\n }\n }\n }\n\n private _set(id: string, attention: Partial<Attention>): void {\n const atom = this._getAtom(id);\n this._registry.set(atom, {\n hasAttention: attention.hasAttention ?? false,\n isAncestor: attention.isAncestor ?? false,\n isRelated: attention.isRelated ?? false,\n });\n }\n}\n\n/**\n * Accumulates all attendable IDs between the element provided and the root, inclusive.\n * Each `data-attendable-id` value is treated as a single qualified ID (no splitting).\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 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/**\n * Prefix for linked segments. A linked segment's attention state is shared with its parent:\n * when a linked node has attention, the parent is marked as both ancestor and related.\n */\nconst LINKED_PREFIX = '~';\n\n/**\n * Decompose a qualified graph ID into progressive prefixes for ancestry tracking.\n * e.g. `root/a/b/c` yields `['root', 'root/a', 'root/a/b', 'root/a/b/c']`.\n */\nexport const expandAttendableId = (qualifiedId: string): string[] => {\n const segments = qualifiedId.split('/');\n return segments.map((_, index) => segments.slice(0, index + 1).join('/'));\n};\n\n/**\n * Whether the last segment of a qualified ID is a linked segment (starts with `~`).\n * Linked segments share their attention state with the parent node.\n */\nexport const isLinkedSegment = (qualifiedId: string): boolean => {\n const lastSegment = qualifiedId.split('/').pop() ?? '';\n return lastSegment.startsWith(LINKED_PREFIX);\n};\n\n/**\n * Build a linked segment ID from a variant name (e.g., `'settings'` -> `'~settings'`).\n * Nodes identified by linked segments share their attention state with the parent node.\n */\nexport const linkedSegment = (variant: string): string => `${LINKED_PREFIX}${variant}`;\n\n/**\n * Extract the variant name from the last segment of a qualified ID, stripping the linked prefix.\n * e.g. `'root/space/obj/~settings'` -> `'settings'`.\n * If the segment is not linked (no `~` prefix), returns the segment as-is.\n */\nexport const getLinkedVariant = (qualifiedId: string): string => {\n const lastSegment = qualifiedId.split('/').pop() ?? '';\n return lastSegment.startsWith(LINKED_PREFIX) ? lastSegment.slice(LINKED_PREFIX.length) : lastSegment;\n};\n\n/**\n * Get the parent qualified ID (everything before the last `/` segment).\n */\nexport const getParentId = (qualifiedId: string | undefined): string | undefined => {\n if (!qualifiedId) {\n return undefined;\n }\n\n const lastSlash = qualifiedId.lastIndexOf('/');\n return lastSlash > 0 ? qualifiedId.slice(0, lastSlash) : undefined;\n};\n\n/**\n * Extract the segment ID (last segment) of a qualified ID.\n */\nexport const getSegmentId = (qualifiedId: string): string => {\n return qualifiedId.split('/').pop() ?? qualifiedId;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport { createContext } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport React, {\n type ComponentPropsWithRef,\n type FocusEvent,\n type PropsWithChildren,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { log } from '@dxos/log';\nimport { useDefaultValue } from '@dxos/react-hooks';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { AttentionManager, getAttendables } from '../attention';\nimport { type Attention } from '../types';\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 */\nconst useAttention = (attendableId?: string): Attention => {\n const { attention } = useAttentionContext(ATTENTION_NAME);\n const [state, setState] = useState<Attention>(UNKNOWN_ATTENDABLE);\n\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\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\nconst RootAttentionProvider = ({\n children,\n attention: propsAttention,\n onChange,\n}: PropsWithChildren<\n Partial<{\n attention: AttentionManager;\n onChange: (nextAttended: string[]) => void;\n }>\n>) => {\n const registry = useContext(RegistryContext);\n const attention = useDefaultValue(propsAttention, () => new AttentionManager(registry));\n\n const handleFocus = (event: FocusEvent) => {\n // NOTE(thure): Use the following to debug focus movement across the app:\n log('focus', { related: event.relatedTarget, target: event.target });\n\n const selector = [\n '[data-attendable-id]',\n ...Array.from(document.querySelectorAll('[aria-controls]')).map(\n (el) => `[id=\"${el.getAttribute('aria-controls')}\"]`,\n ),\n ].join(',');\n const prev = attention.getCurrent();\n const next = getAttendables(selector, event.target);\n // TODO(wittjosiah): Not allowing empty state means that the attended item is not strictly guaranteed to be in the DOM.\n // Currently this depends on the deck in order to ensure that when the attended item is removed something else is attended.\n // Only update state if the result is different and not empty.\n if (next.length > 0 && (prev.length !== next.length || !!prev.find((id, index) => next[index] !== id))) {\n attention.update(next);\n onChange?.(next);\n }\n };\n\n return (\n <AttentionContextProvider attention={attention}>\n <div role='none' 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 ATTENTION_NAME,\n ATTENDABLE_ATTRIBUTE,\n ATTENTION_SOURCE_ATTRIBUTE,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\n\nimport { invariant } from '@dxos/invariant';\n\n// TODO(burdon): Reconcile with @dxos/graph.\n\nexport type SelectionMode = 'single' | 'multi' | 'range' | 'multi-range';\n\nexport const SelectionSchema = Schema.Union(\n Schema.Struct({ mode: Schema.Literal('single'), id: Schema.optional(Schema.String) }).pipe(Schema.mutable),\n Schema.Struct({ mode: Schema.Literal('multi'), ids: Schema.Array(Schema.String).pipe(Schema.mutable) }).pipe(\n Schema.mutable,\n ),\n Schema.Struct({\n mode: Schema.Literal('range'),\n from: Schema.optional(Schema.String),\n to: Schema.optional(Schema.String),\n }).pipe(Schema.mutable),\n Schema.Struct({\n mode: Schema.Literal('multi-range'),\n ranges: Schema.Array(Schema.Struct({ from: Schema.String, to: Schema.String })).pipe(Schema.mutable),\n }).pipe(Schema.mutable),\n).pipe(Schema.mutable);\n\nexport type Selection = Schema.Schema.Type<typeof SelectionSchema>;\n\nexport const defaultSelection = Match.type<SelectionMode>().pipe(\n Match.withReturnType<Selection>(),\n Match.when('single', () => ({ mode: 'single' })),\n Match.when('multi', () => ({ mode: 'multi', ids: [] })),\n Match.when('range', () => ({ mode: 'range' })),\n Match.when('multi-range', () => ({ mode: 'multi-range', ranges: [] })),\n Match.exhaustive,\n);\n\nexport type SelectionResult<T extends SelectionMode> = T extends 'single'\n ? string | undefined\n : T extends 'multi'\n ? string[]\n : T extends 'range'\n ? { from: string; to: string } | undefined\n : T extends 'multi-range'\n ? { from: string; to: string }[]\n : never;\n\n// TODO(burdon): Refactor.\nexport const getSelectionSet = (selectionManager: SelectionManager, contextId?: string) => {\n const ids = new Set<string>(contextId ? [contextId] : []);\n for (const context of selectionManager.getSelectionContexts()) {\n const selection = selectionManager.getSelection(context);\n if (selection?.mode === 'multi') {\n for (const id of selection.ids) {\n ids.add(id);\n }\n }\n }\n\n return ids;\n};\n\n/**\n * Manages selection state for different contexts.\n * Each context maintains its own selection mode and state.\n */\nexport class SelectionManager {\n private readonly _state: Atom.Writable<{ selections: Record<string, Selection> }>;\n\n constructor(\n private readonly _registry: Registry.Registry,\n initial: Record<string, Selection> = {},\n ) {\n this._state = Atom.make<{ selections: Record<string, Selection> }>({\n selections: { ...initial },\n });\n }\n\n /**\n * Get the state atom for reactive access in the graph system.\n */\n get state(): Atom.Atom<{ selections: Record<string, Selection> }> {\n return this._state;\n }\n\n /**\n * Gets the current state.\n */\n getState(): { selections: Record<string, Selection> } {\n return this._registry.get(this._state);\n }\n\n /**\n * Subscribe to changes in the selection state.\n */\n subscribe(cb: (state: { selections: Record<string, Selection> }) => void): () => void {\n this._registry.get(this._state);\n return this._registry.subscribe(this._state, () => {\n cb(this._registry.get(this._state));\n });\n }\n\n getSelectionContexts(): string[] {\n return Object.keys(this._registry.get(this._state).selections);\n }\n\n getSelection(contextId: string): Selection | undefined;\n getSelection<T extends SelectionMode>(contextId: string, mode: T): Selection;\n getSelection<T extends SelectionMode | undefined>(\n contextId: string,\n mode: T = undefined as T,\n ): Selection | undefined {\n const state = this._registry.get(this._state);\n const selection = state.selections[contextId];\n if (!mode || selection) {\n return selection;\n }\n\n // Create new selection for the context.\n const newSelection = defaultSelection(mode);\n this._registry.update(this._state, (state) => ({\n selections: { ...state.selections, [contextId]: newSelection },\n }));\n return newSelection;\n }\n\n // TODO(burdon): Disambiguate with getSelection?\n getSelected<T extends SelectionMode>(contextId: string, mode: T = 'multi' as T): SelectionResult<T> {\n const selection = this.getSelection(contextId, mode);\n invariant(selection?.mode === mode, 'Selection mode mismatch');\n // Cast required because TypeScript can't infer the relationship between T and the matched result.\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => s.id),\n Match.when({ mode: 'multi' }, (s) => s.ids),\n Match.when({ mode: 'range' }, (s) => (s.from && s.to ? { from: s.from, to: s.to } : undefined)),\n Match.when({ mode: 'multi-range' }, (s) => s.ranges),\n Match.exhaustive,\n )(selection) as SelectionResult<T>;\n }\n\n updateSingle(contextId: string, id: string): void {\n const selection = this.getSelection(contextId, 'single');\n invariant(selection?.mode === 'single', 'Selection mode is not single');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, id },\n },\n }));\n }\n\n updateMulti(contextId: string, ids: string[]) {\n const selection = this.getSelection(contextId, 'multi');\n invariant(selection?.mode === 'multi', 'Selection mode is not multi');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ids: [...ids] },\n },\n }));\n }\n\n updateRange(contextId: string, from: string, to: string) {\n const selection = this.getSelection(contextId, 'range');\n invariant(selection?.mode === 'range', 'Selection mode is not range');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, from, to },\n },\n }));\n }\n\n updateMultiRange(contextId: string, ranges: { from: string; to: string }[]) {\n const selection = this.getSelection(contextId, 'multi-range');\n invariant(selection?.mode === 'multi-range', 'Selection mode is not multi-range');\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ranges: [...ranges] },\n },\n }));\n }\n\n clearSelection(contextId: string): void {\n const selection = this.getSelection(contextId);\n if (!selection) {\n return;\n }\n\n const clearedSelection = Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (s) => ({ ...s, id: undefined })),\n Match.when({ mode: 'multi' }, (s) => ({ ...s, ids: [] })),\n Match.when({ mode: 'range' }, (s) => ({ ...s, from: undefined, to: undefined })),\n Match.when({ mode: 'multi-range' }, (s) => ({ ...s, ranges: [] })),\n Match.exhaustive,\n )(selection);\n\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: clearedSelection,\n },\n }));\n }\n\n toggleSelection(contextId: string, id: string): void {\n const selection = this.getSelection(contextId, 'multi');\n invariant(selection?.mode === 'multi', 'Selection mode is not multi');\n\n const newIds = selection.ids.includes(id)\n ? selection.ids.filter((existingId) => existingId !== id)\n : [...selection.ids, id];\n\n this._registry.update(this._state, (state) => ({\n selections: {\n ...state.selections,\n [contextId]: { ...selection, ids: newIds },\n },\n }));\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport { createContext } from '@radix-ui/react-context';\nimport * as Match from 'effect/Match';\nimport React, { type PropsWithChildren, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\nimport { useDefaultValue } from '@dxos/react-hooks';\n\nimport {\n type Selection,\n SelectionManager,\n type SelectionMode,\n type SelectionResult,\n defaultSelection,\n} from '../selection';\n\nconst SELECTION_NAME = 'Selection';\n\ntype SelectionContextValue = {\n selection: SelectionManager;\n};\n\nconst [SelectionContextProvider, useSelectionContext] = createContext<SelectionContextValue>(SELECTION_NAME, {\n selection: undefined as unknown as SelectionManager,\n});\n\n/**\n * Manages selection state across the app for multiple contexts.\n */\n// TODO(burdon): When is the selection removed?\nexport const SelectionProvider = ({\n children,\n selection: propsSelection,\n}: PropsWithChildren<{ selection?: SelectionManager }>) => {\n const registry = useContext(RegistryContext);\n const selection = useDefaultValue(propsSelection, () => new SelectionManager(registry));\n return <SelectionContextProvider selection={selection}>{children}</SelectionContextProvider>;\n};\n\n/**\n * Get the selection contexts.\n */\nexport const useSelectionManager = () => {\n const { selection } = useSelectionContext(SELECTION_NAME);\n return selection;\n};\n\nconst getDefaultResult = <T extends SelectionMode>(mode: T): SelectionResult<T> => {\n return Match.type<Selection>().pipe(\n Match.when({ mode: 'single' }, (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 */\n// TODO(burdon): Mode not used.\nexport const useSelectionActions = (contextIds: string[], mode: SelectionMode = 'multi'): UseSelectionActions => {\n const stableContextIds = useMemo(() => contextIds, [JSON.stringify(contextIds)]); // TODO(burdon): Avoid stringify.\n const { selection } = useSelectionContext(SELECTION_NAME);\n\n const singleSelect = useCallback(\n (id: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateSingle(contextId, id);\n }\n },\n [selection, stableContextIds],\n );\n\n const multiSelect = useCallback(\n (ids: string[]) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateMulti(contextId, ids);\n }\n },\n [selection, stableContextIds],\n );\n\n const rangeSelect = useCallback(\n (from: string, to: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.updateRange(contextId, from, to);\n }\n },\n [selection, stableContextIds],\n );\n\n const toggle = useCallback(\n (id: string) => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.toggleSelection(contextId, id);\n }\n },\n [selection, stableContextIds],\n );\n\n const clear = useCallback(() => {\n if (!selection) {\n return;\n }\n for (const contextId of stableContextIds) {\n selection.clearSelection(contextId);\n }\n }, [selection, stableContextIds]);\n\n return { singleSelect, multiSelect, rangeSelect, toggle, clear };\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,YAA2B;AAQ7B,IAAMC,mBAAN,MAAMA;;EACMC,OAAO,oBAAIC,IAAAA;EACXC;EAEjB,YACmBC,WACjBC,UAAoB,CAAA,GACpB;SAFiBD,YAAAA;AAGjB,SAAKD,eAAeJ,KAAKO,KAAe,CAAA,CAAE,EAAEC,KAAKR,KAAKS,SAAS;AAC/D,QAAIH,QAAQI,SAAS,GAAG;AACtB,WAAKC,OAAOL,OAAAA;IACd;EACF;;;;EAKA,IAAIM,UAA+B;AACjC,WAAO,KAAKR;EACd;;;;EAKAS,aAAgC;AAC9B,WAAO,KAAKR,UAAUS,IAAI,KAAKV,YAAY;EAC7C;;;;EAKAW,iBAAiBC,IAAsD;AACrE,SAAKX,UAAUS,IAAI,KAAKV,YAAY;AACpC,WAAO,KAAKC,UAAUY,UAAU,KAAKb,cAAc,MAAA;AACjDY,SAAG,KAAKX,UAAUS,IAAI,KAAKV,YAAY,CAAA;IACzC,CAAA;EACF;;;;EAKAc,OAAiB;AACf,WAAOC,MAAMC,KAAK,KAAKlB,KAAKgB,KAAI,CAAA;EAClC;;;;EAKAJ,IAAIO,IAAuB;AACzB,UAAMC,OAAO,KAAKC,SAASF,EAAAA;AAC3B,WAAO,KAAKhB,UAAUS,IAAIQ,IAAAA;EAC5B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ttentionManager", "_map", "Map", "_currentAtom", "_registry", "initial", "make", "pipe", "keepAlive", "length", "update", "current", "getCurrent", "get", "subscribeCurrent", "cb", "subscribe", "keys", "Array", "from", "id", "atom", "_getAtom", "existing", "newAtom", "hasAttention", "isAncestor", "isRelated", "set", "nextIds", "primaryId", "currentIds", "prevPrimaryId", "prevPrefixes", "expandAttendableId", "prefix", "_set", "prevSegmentId", "getSegmentId", "key", "prefixes", "prefixSet", "Set", "linkedParent", "isLinkedSegment", "getParentId", "undefined", "segmentId", "has", "attention", "getAttendables", "selector", "cursor", "acc", "closestAttendable", "closest", "attendableId", "getAttribute", "trigger", "document", "querySelector", "push", "parentElement", "LINKED_PREFIX", "qualifiedId", "segments", "split", "map", "_", "index", "slice", "join", "lastSegment", "pop", "startsWith", "linkedSegment", "variant", "getLinkedVariant", "lastSlash", "lastIndexOf", "RegistryContext", "createContext", "Primitive", "Slot", "React", "forwardRef", "useContext", "useEffect", "useMemo", "useState", "log", "useDefaultValue", "mx", "ATTENTION_NAME", "ATTENTION_SOURCE_ATTRIBUTE", "AttentionContextProvider", "attention", "undefined", "UNKNOWN_ATTENDABLE", "isAncestor", "isRelated", "setState", "useEffect", "attendableId", "subscribe", "newState", "useAttended", "setCurrent", "newCurrent", "attributes", "ATTENDABLE_ATTRIBUTE", "hasAttention", "useDefaultValue", "propsAttention", "AttentionManager", "registry", "handleFocus", "event", "log", "target", "selector", "join", "prev", "getCurrent", "next", "onChange", "div", "role", "onFocusCapture", "children", "Comp", "attentionAttrs", "className", "ref", "RootAttentionProvider", "Atom", "Match", "Schema", "invariant", "__dxlog_file", "SelectionSchema", "id", "pipe", "mutable", "Struct", "mode", "String", "optional", "to", "Array", "defaultSelection", "when", "ranges", "getSelectionSet", "contextId", "selection", "_state", "make", "selections", "initial", "_registry", "cb", "get", "getSelectionContexts", "getSelection", "undefined", "state", "newSelection", "getSelected", "s", "ids", "from", "exhaustive", "updateSingle", "update", "updateMulti", "updateRange", "updateMultiRange", "clearSelection", "toggleSelection", "newIds", "includes", "RegistryContext", "createContext", "Match", "React", "useCallback", "useContext", "useEffect", "useMemo", "useState", "useDefaultValue", "SELECTION_NAME", "SelectionContextProvider", "useSelectionContext", "createContext", "selection", "undefined", "SelectionProvider", "children", "propsSelection", "registry", "useContext", "RegistryContext", "useDefaultValue", "SelectionManager", "React", "useSelectionManager", "getDefaultResult", "mode", "type", "pipe", "when", "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,52 +1,125 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
- ATTENABLE_ATTRIBUTE,
4
- ATTENDABLE_PATH_SEPARATOR,
3
+ ATTENDABLE_ATTRIBUTE,
5
4
  ATTENTION_NAME,
6
5
  ATTENTION_SOURCE_ATTRIBUTE,
7
6
  AttendableContainer,
8
- AttentionGlyph,
9
7
  AttentionManager,
10
- AttentionProvider,
11
- AttentionSchema,
12
8
  RootAttentionProvider,
13
9
  SelectionManager,
14
10
  SelectionProvider,
15
- Syncing,
11
+ SelectionSchema,
16
12
  defaultSelection,
13
+ expandAttendableId,
17
14
  getAttendables,
15
+ getLinkedVariant,
16
+ getParentId,
17
+ getSegmentId,
18
18
  getSelectionSet,
19
+ isLinkedSegment,
20
+ linkedSegment,
19
21
  useAttended,
20
22
  useAttention,
21
23
  useAttentionAttributes,
22
24
  useAttentionContext,
23
- useAttentionPath,
24
25
  useSelected,
25
26
  useSelectionActions,
26
27
  useSelectionManager
27
- } from "./chunk-F2JRKDYV.mjs";
28
+ } from "./chunk-HZTQDMTS.mjs";
29
+
30
+ // src/components/AttentionGlyph.tsx
31
+ import React, { forwardRef, useMemo } from "react";
32
+ import { Icon } from "@dxos/react-ui";
33
+ import { mx } from "@dxos/ui-theme";
34
+ var attentionGlyphStyles = mx("inline-block rounded-xs w-3 h-3 bg-transparent text-accent-text transition-colors", "[[data-contains-attended=true]_&]:bg-attention-contains", "[[data-attention=true]_&]:bg-accent-surface", "[[data-attention=true]_&]:text-accent-surface-text", "[[aria-current][data-attention=true]_&]:bg-accent-surface", "[[aria-current][data-attention=true]_&]:text-accent-surface-text", '[[aria-selected="true"][data-attention=true]_&]:bg-accent-surface', '[[aria-selected="true"][data-attention=true]_&]:text-accent-surface-text');
35
+ var presenceIconStyles = mx("w-3 h-3");
36
+ var PresenceOne = () => {
37
+ return /* @__PURE__ */ React.createElement("svg", {
38
+ width: "12",
39
+ height: "12",
40
+ viewBox: "0 0 12 12",
41
+ className: presenceIconStyles,
42
+ fill: "none",
43
+ xmlns: "http://www.w3.org/2000/svg"
44
+ }, /* @__PURE__ */ React.createElement("circle", {
45
+ cx: "6",
46
+ cy: "6",
47
+ r: "2.5",
48
+ fill: "currentColor"
49
+ }));
50
+ };
51
+ var PresenceMany = () => {
52
+ return /* @__PURE__ */ React.createElement("svg", {
53
+ width: "12",
54
+ height: "12",
55
+ viewBox: "0 0 12 12",
56
+ className: presenceIconStyles,
57
+ fill: "none",
58
+ xmlns: "http://www.w3.org/2000/svg"
59
+ }, /* @__PURE__ */ React.createElement("path", {
60
+ 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",
61
+ fill: "currentColor"
62
+ }), /* @__PURE__ */ React.createElement("circle", {
63
+ cx: "4.25",
64
+ cy: "6",
65
+ r: "2.5",
66
+ fill: "currentColor"
67
+ }));
68
+ };
69
+ var Syncing = () => {
70
+ const animationProps = useMemo(() => ({
71
+ // Synchronize animations.
72
+ animationDelay: `-${Date.now() % 2e3}ms`
73
+ }), []);
74
+ return /* @__PURE__ */ React.createElement("div", {
75
+ role: "status",
76
+ className: "flex items-center"
77
+ }, /* @__PURE__ */ React.createElement(Icon, {
78
+ icon: "ph--circle-notch--bold",
79
+ size: 3,
80
+ style: animationProps,
81
+ classNames: "text-subdued animate-[spin_2s_linear_infinite]"
82
+ }));
83
+ };
84
+ var AttentionGlyph = /* @__PURE__ */ forwardRef(({ presence, attended, syncing, containsAttended, classNames, ...props }, forwardedRef) => {
85
+ const icon = syncing ? /* @__PURE__ */ React.createElement(Syncing, null) : presence === "many" ? /* @__PURE__ */ React.createElement(PresenceMany, null) : presence === "one" ? /* @__PURE__ */ React.createElement(PresenceOne, null) : null;
86
+ return /* @__PURE__ */ React.createElement("div", {
87
+ role: "none",
88
+ className: "flex group",
89
+ "data-attention": attended,
90
+ "data-contains-attended": containsAttended
91
+ }, /* @__PURE__ */ React.createElement("span", {
92
+ role: "none",
93
+ ...props,
94
+ className: mx(attentionGlyphStyles, classNames),
95
+ ref: forwardedRef
96
+ }, icon));
97
+ });
28
98
  export {
29
- ATTENABLE_ATTRIBUTE,
30
- ATTENDABLE_PATH_SEPARATOR,
99
+ ATTENDABLE_ATTRIBUTE,
31
100
  ATTENTION_NAME,
32
101
  ATTENTION_SOURCE_ATTRIBUTE,
33
102
  AttendableContainer,
34
103
  AttentionGlyph,
35
104
  AttentionManager,
36
- AttentionProvider,
37
- AttentionSchema,
38
105
  RootAttentionProvider,
39
106
  SelectionManager,
40
107
  SelectionProvider,
108
+ SelectionSchema,
41
109
  Syncing,
42
110
  defaultSelection,
111
+ expandAttendableId,
43
112
  getAttendables,
113
+ getLinkedVariant,
114
+ getParentId,
115
+ getSegmentId,
44
116
  getSelectionSet,
117
+ isLinkedSegment,
118
+ linkedSegment,
45
119
  useAttended,
46
120
  useAttention,
47
121
  useAttentionAttributes,
48
122
  useAttentionContext,
49
- useAttentionPath,
50
123
  useSelected,
51
124
  useSelectionActions,
52
125
  useSelectionManager
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
3
+ "sources": ["../../../src/components/AttentionGlyph.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Primitive } from '@radix-ui/react-primitive';\nimport React, { type CSSProperties, type ComponentPropsWithRef, forwardRef, useMemo } from 'react';\n\nimport { Icon, type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nconst attentionGlyphStyles = mx(\n 'inline-block rounded-xs w-3 h-3 bg-transparent text-accent-text transition-colors',\n '[[data-contains-attended=true]_&]:bg-attention-contains',\n '[[data-attention=true]_&]:bg-accent-surface',\n '[[data-attention=true]_&]:text-accent-surface-text',\n '[[aria-current][data-attention=true]_&]:bg-accent-surface',\n '[[aria-current][data-attention=true]_&]:text-accent-surface-text',\n '[[aria-selected=\"true\"][data-attention=true]_&]:bg-accent-surface',\n '[[aria-selected=\"true\"][data-attention=true]_&]:text-accent-surface-text',\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 role='none' className='flex group' data-attention={attended} data-contains-attended={containsAttended}>\n <span role='none' {...props} className={mx(attentionGlyphStyles, classNames)} ref={forwardedRef}>\n {icon}\n </span>\n </div>\n );\n },\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAOA,SAAyDC,YAAYC,eAAe;AAE3F,SAASC,YAAkC;AAC3C,SAASC,UAAU;AAEnB,IAAMC,uBAAuBD,GAC3B,qFACA,2DACA,+CACA,sDACA,6DACA,oEACA,qEACA,0EAAA;AAGF,IAAME,qBAAqBF,GAAG,SAAA;AAE9B,IAAMG,cAAc,MAAA;AAClB,SACE,sBAAA,cAACC,OAAAA;IACCC,OAAM;IACNC,QAAO;IACPC,SAAQ;IACRC,WAAWN;IACXO,MAAK;IACLC,OAAM;KAEN,sBAAA,cAACC,UAAAA;IAAOC,IAAG;IAAIC,IAAG;IAAIC,GAAE;IAAML,MAAK;;AAGzC;AAEA,IAAMM,eAAe,MAAA;AACnB,SACE,sBAAA,cAACX,OAAAA;IACCC,OAAM;IACNC,QAAO;IACPC,SAAQ;IACRC,WAAWN;IACXO,MAAK;IACLC,OAAM;KAEN,sBAAA,cAACM,QAAAA;IACCC,GAAE;IACFR,MAAK;MAEP,sBAAA,cAACE,UAAAA;IAAOC,IAAG;IAAOC,IAAG;IAAIC,GAAE;IAAML,MAAK;;AAG5C;AAEO,IAAMS,UAAU,MAAA;AACrB,QAAMC,iBAAiBrB,QACrB,OAAO;;IAELsB,gBAAgB,IAAIC,KAAKC,IAAG,IAAK,GAAA;EACnC,IACA,CAAA,CAAE;AAGJ,SACE,sBAAA,cAACC,OAAAA;IAAIC,MAAK;IAAShB,WAAU;KAC3B,sBAAA,cAACT,MAAAA;IACC0B,MAAK;IACLC,MAAM;IACNC,OAAOR;IACPS,YAAW;;AAInB;AASO,IAAMC,iBAAiBhC,2BAC5B,CAAC,EAAEiC,UAAUC,UAAUC,SAASC,kBAAkBL,YAAY,GAAGM,MAAAA,GAASC,iBAAAA;AACxE,QAAMV,OAAOO,UACX,sBAAA,cAACd,SAAAA,IAAAA,IACCY,aAAa,SACf,sBAAA,cAACf,cAAAA,IAAAA,IACCe,aAAa,QACf,sBAAA,cAAC3B,aAAAA,IAAAA,IACC;AAEJ,SACE,sBAAA,cAACoB,OAAAA;IAAIC,MAAK;IAAOhB,WAAU;IAAa4B,kBAAgBL;IAAUM,0BAAwBJ;KACxF,sBAAA,cAACK,QAAAA;IAAKd,MAAK;IAAQ,GAAGU;IAAO1B,WAAWR,GAAGC,sBAAsB2B,UAAAA;IAAaW,KAAKJ;KAChFV,IAAAA,CAAAA;AAIT,CAAA;",
6
+ "names": ["React", "forwardRef", "useMemo", "Icon", "mx", "attentionGlyphStyles", "presenceIconStyles", "PresenceOne", "svg", "width", "height", "viewBox", "className", "fill", "xmlns", "circle", "cx", "cy", "r", "PresenceMany", "path", "d", "Syncing", "animationProps", "animationDelay", "Date", "now", "div", "role", "icon", "size", "style", "classNames", "AttentionGlyph", "presence", "attended", "syncing", "containsAttended", "props", "forwardedRef", "data-attention", "data-contains-attended", "span", "ref"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/attention.ts":{"bytes":16516,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/components/AttentionGlyph.tsx":{"bytes":11200,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/components/AttentionProvider.tsx":{"bytes":20795,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"src/attention.ts","kind":"import-statement","original":"../attention"}],"format":"esm"},"src/selection.ts":{"bytes":17905,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"format":"esm"},"src/components/SelectionProvider.tsx":{"bytes":11919,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"src/selection.ts","kind":"import-statement","original":"../selection"}],"format":"esm"},"src/components/index.ts":{"bytes":708,"imports":[{"path":"src/components/AttentionGlyph.tsx","kind":"import-statement","original":"./AttentionGlyph"},{"path":"src/components/AttentionProvider.tsx","kind":"import-statement","original":"./AttentionProvider"},{"path":"src/components/SelectionProvider.tsx","kind":"import-statement","original":"./SelectionProvider"}],"format":"esm"},"src/index.ts":{"bytes":645,"imports":[{"path":"src/attention.ts","kind":"import-statement","original":"./attention"},{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/selection.ts","kind":"import-statement","original":"./selection"}],"format":"esm"},"src/testing/decorators/withAttention.ts":{"bytes":1337,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"../../components"}],"format":"esm"},"src/testing/decorators/index.ts":{"bytes":493,"imports":[{"path":"src/testing/decorators/withAttention.ts","kind":"import-statement","original":"./withAttention"}],"format":"esm"},"src/testing/index.ts":{"bytes":471,"imports":[{"path":"src/testing/decorators/index.ts","kind":"import-statement","original":"./decorators"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-F2JRKDYV.mjs","kind":"import-statement"}],"exports":["ATTENABLE_ATTRIBUTE","ATTENDABLE_PATH_SEPARATOR","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttendableContainer","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","SelectionManager","SelectionProvider","Syncing","defaultSelection","getAttendables","getSelectionSet","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useAttentionPath","useSelected","useSelectionActions","useSelectionManager"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":1169},"dist/lib/node-esm/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":698},"dist/lib/node-esm/testing/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-F2JRKDYV.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true}],"exports":["withAttention"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/decorators/withAttention.ts":{"bytesInOutput":164},"src/testing/decorators/index.ts":{"bytesInOutput":0},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":428},"dist/lib/node-esm/chunk-F2JRKDYV.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":38662},"dist/lib/node-esm/chunk-F2JRKDYV.mjs":{"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["ATTENABLE_ATTRIBUTE","ATTENDABLE_PATH_SEPARATOR","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttendableContainer","AttentionGlyph","AttentionManager","AttentionProvider","AttentionSchema","RootAttentionProvider","SelectionManager","SelectionProvider","Syncing","defaultSelection","getAttendables","getSelectionSet","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useAttentionPath","useSelected","useSelectionActions","useSelectionManager"],"inputs":{"src/attention.ts":{"bytesInOutput":3644},"src/components/AttentionGlyph.tsx":{"bytesInOutput":3714},"src/components/AttentionProvider.tsx":{"bytesInOutput":3705},"src/selection.ts":{"bytesInOutput":4858},"src/components/SelectionProvider.tsx":{"bytesInOutput":2762},"src/components/index.ts":{"bytesInOutput":0}},"bytes":19489}}}
1
+ {"inputs":{"src/attention.ts":{"bytes":25853,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true}],"format":"esm"},"src/components/AttentionGlyph.tsx":{"bytes":9988,"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/AttentionProvider.tsx":{"bytes":17946,"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/selection.ts":{"bytes":27613,"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.tsx":{"bytes":15523,"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/index.ts":{"bytes":616,"imports":[{"path":"src/components/AttentionGlyph.tsx","kind":"import-statement","original":"./AttentionGlyph"},{"path":"src/components/AttentionProvider.tsx","kind":"import-statement","original":"./AttentionProvider"},{"path":"src/components/SelectionProvider.tsx","kind":"import-statement","original":"./SelectionProvider"}],"format":"esm"},"src/index.ts":{"bytes":560,"imports":[{"path":"src/attention.ts","kind":"import-statement","original":"./attention"},{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/selection.ts","kind":"import-statement","original":"./selection"}],"format":"esm"},"src/types.ts":{"bytes":532,"imports":[],"format":"esm"},"src/testing/decorators/withAttention.ts":{"bytes":3501,"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"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5195},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-HZTQDMTS.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["ATTENDABLE_ATTRIBUTE","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttendableContainer","AttentionGlyph","AttentionManager","RootAttentionProvider","SelectionManager","SelectionProvider","SelectionSchema","Syncing","defaultSelection","expandAttendableId","getAttendables","getLinkedVariant","getParentId","getSegmentId","getSelectionSet","isLinkedSegment","linkedSegment","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useSelected","useSelectionActions","useSelectionManager"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0},"src/components/AttentionGlyph.tsx":{"bytesInOutput":2992}},"bytes":4250},"dist/lib/node-esm/types.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/types.mjs":{"imports":[],"exports":[],"entryPoint":"src/types.ts","inputs":{"src/types.ts":{"bytesInOutput":0}},"bytes":127},"dist/lib/node-esm/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1872},"dist/lib/node-esm/testing/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-HZTQDMTS.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":915},"dist/lib/node-esm/chunk-HZTQDMTS.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":42373},"dist/lib/node-esm/chunk-HZTQDMTS.mjs":{"imports":[{"path":"@effect-atom/atom-react","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":"@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":"effect/Match","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","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":["ATTENDABLE_ATTRIBUTE","ATTENTION_NAME","ATTENTION_SOURCE_ATTRIBUTE","AttendableContainer","AttentionManager","RootAttentionProvider","SelectionManager","SelectionProvider","SelectionSchema","defaultSelection","expandAttendableId","getAttendables","getLinkedVariant","getParentId","getSegmentId","getSelectionSet","isLinkedSegment","linkedSegment","useAttended","useAttention","useAttentionAttributes","useAttentionContext","useSelected","useSelectionActions","useSelectionManager"],"inputs":{"src/attention.ts":{"bytesInOutput":5433},"src/components/AttentionProvider.tsx":{"bytesInOutput":3725},"src/selection.ts":{"bytesInOutput":7024},"src/components/SelectionProvider.tsx":{"bytesInOutput":3533}},"bytes":20494}}}
@@ -1,14 +1,27 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
- RootAttentionProvider
4
- } from "../chunk-F2JRKDYV.mjs";
3
+ AttentionManager,
4
+ RootAttentionProvider,
5
+ SelectionProvider
6
+ } from "../chunk-HZTQDMTS.mjs";
5
7
 
6
8
  // src/testing/decorators/withAttention.ts
7
- import { createElement } from "react";
8
- var withAttention = (Story) => {
9
- return createElement(RootAttentionProvider, {
10
- children: createElement(Story)
11
- });
9
+ import { Registry, RegistryContext } from "@effect-atom/atom-react";
10
+ import { createElement, useMemo } from "react";
11
+ var withAttention = (initialAttendedId) => {
12
+ return (Story) => {
13
+ const registry = useMemo(() => Registry.make(), []);
14
+ const attention = useMemo(() => initialAttendedId ? new AttentionManager(registry, [
15
+ initialAttendedId
16
+ ]) : void 0, [
17
+ registry
18
+ ]);
19
+ return createElement(RegistryContext.Provider, {
20
+ value: registry
21
+ }, createElement(RootAttentionProvider, {
22
+ attention
23
+ }, createElement(SelectionProvider, {}, createElement(Story))));
24
+ };
12
25
  };
13
26
  export {
14
27
  withAttention
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/testing/decorators/withAttention.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport { createElement } from 'react';\n\nimport { RootAttentionProvider } from '../../components';\n\nexport const withAttention: Decorator = (Story) => {\n return createElement(RootAttentionProvider, { children: createElement(Story) });\n};\n"],
5
- "mappings": ";;;;;;AAKA,SAASA,qBAAqB;AAIvB,IAAMC,gBAA2B,CAACC,UAAAA;AACvC,SAAOC,cAAcC,uBAAuB;IAAEC,UAAUF,cAAcD,KAAAA;EAAO,CAAA;AAC/E;",
6
- "names": ["createElement", "withAttention", "Story", "createElement", "RootAttentionProvider", "children"]
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Registry, RegistryContext } from '@effect-atom/atom-react';\nimport { type Decorator } from '@storybook/react';\nimport { createElement, useMemo } from 'react';\n\nimport { AttentionManager } from '../../attention';\nimport { RootAttentionProvider, SelectionProvider } from '../../components';\n\n/**\n * Storybook decorator that provides attention context.\n * @param initialAttendedId Optional ID to set as initially attended.\n */\nexport const withAttention = (initialAttendedId?: string): Decorator => {\n return (Story) => {\n const registry = useMemo(() => Registry.make(), []);\n const attention = useMemo(\n () => (initialAttendedId ? new AttentionManager(registry, [initialAttendedId]) : undefined),\n [registry],\n );\n return createElement(\n RegistryContext.Provider,\n { value: registry },\n createElement(RootAttentionProvider, { attention }, createElement(SelectionProvider, {}, createElement(Story))),\n );\n };\n};\n"],
5
+ "mappings": ";;;;;;;;AAIA,SAASA,UAAUC,uBAAuB;AAE1C,SAASC,eAAeC,eAAe;AAShC,IAAMC,gBAAgB,CAACC,sBAAAA;AAC5B,SAAO,CAACC,UAAAA;AACN,UAAMC,WAAWC,QAAQ,MAAMC,SAASC,KAAI,GAAI,CAAA,CAAE;AAClD,UAAMC,YAAYH,QAChB,MAAOH,oBAAoB,IAAIO,iBAAiBL,UAAU;MAACF;KAAkB,IAAIQ,QACjF;MAACN;KAAS;AAEZ,WAAOO,cACLC,gBAAgBC,UAChB;MAAEC,OAAOV;IAAS,GAClBO,cAAcI,uBAAuB;MAAEP;IAAU,GAAGG,cAAcK,mBAAmB,CAAC,GAAGL,cAAcR,KAAAA,CAAAA,CAAAA,CAAAA;EAE3G;AACF;",
6
+ "names": ["Registry", "RegistryContext", "createElement", "useMemo", "withAttention", "initialAttendedId", "Story", "registry", "useMemo", "Registry", "make", "attention", "AttentionManager", "undefined", "createElement", "RegistryContext", "Provider", "value", "RootAttentionProvider", "SelectionProvider"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,37 +1,44 @@
1
- import { Schema } from 'effect';
2
- import { type Live } from '@dxos/live-object';
3
- export declare const ATTENDABLE_PATH_SEPARATOR = "~";
4
- export declare const AttentionSchema: Schema.mutable<Schema.Struct<{
5
- hasAttention: typeof Schema.Boolean;
6
- isAncestor: typeof Schema.Boolean;
7
- isRelated: typeof Schema.Boolean;
8
- }>>;
9
- export type Attention = Schema.Schema.Type<typeof AttentionSchema>;
1
+ import { Atom, type Registry } from '@effect-atom/atom-react';
2
+ import { type Attention } from './types';
10
3
  /**
11
4
  * Manages attention state for an application.
5
+ * Attention keys are slash-qualified graph IDs; ancestry is derived from progressive prefixes.
12
6
  */
13
7
  export declare class AttentionManager {
8
+ private readonly _registry;
14
9
  private readonly _map;
15
- private readonly _state;
16
- constructor(initial?: string[]);
10
+ private readonly _currentAtom;
11
+ constructor(_registry: Registry.Registry, initial?: string[]);
17
12
  /**
18
- * Currently attended element.
19
- *
20
- * @reactive
13
+ * Atom for the currently attended element IDs.
21
14
  */
22
- get current(): Live<readonly string[]>;
15
+ get current(): Atom.Atom<string[]>;
23
16
  /**
24
- * All attention paths.
17
+ * Gets the currently attended element IDs.
25
18
  */
26
- keys(): string[][];
19
+ getCurrent(): readonly string[];
27
20
  /**
28
- * Get the attention state for a given path.
21
+ * Subscribe to changes in the current attention IDs.
29
22
  */
30
- get(key: string[]): Live<Attention>;
23
+ subscribeCurrent(cb: (current: readonly string[]) => void): () => void;
24
+ /**
25
+ * All tracked qualified IDs.
26
+ */
27
+ keys(): string[];
28
+ /**
29
+ * Get the attention state for a given qualified ID.
30
+ */
31
+ get(id: string): Attention;
32
+ /**
33
+ * Subscribe to changes in the attention state for a given qualified ID.
34
+ */
35
+ subscribe(id: string, cb: (attention: Attention) => void): () => void;
36
+ private _getAtom;
31
37
  private _set;
32
38
  }
33
39
  /**
34
- * Accumulates all attendable id’s between the element provided and the root, inclusive.
40
+ * Accumulates all attendable IDs between the element provided and the root, inclusive.
41
+ * Each `data-attendable-id` value is treated as a single qualified ID (no splitting).
35
42
  */
36
43
  export declare const getAttendables: (selector: string, cursor: Element, acc?: string[]) => string[];
37
44
  export type AttendableId = {
@@ -40,4 +47,33 @@ export type AttendableId = {
40
47
  export type Related = {
41
48
  related?: boolean;
42
49
  };
50
+ /**
51
+ * Decompose a qualified graph ID into progressive prefixes for ancestry tracking.
52
+ * e.g. `root/a/b/c` yields `['root', 'root/a', 'root/a/b', 'root/a/b/c']`.
53
+ */
54
+ export declare const expandAttendableId: (qualifiedId: string) => string[];
55
+ /**
56
+ * Whether the last segment of a qualified ID is a linked segment (starts with `~`).
57
+ * Linked segments share their attention state with the parent node.
58
+ */
59
+ export declare const isLinkedSegment: (qualifiedId: string) => boolean;
60
+ /**
61
+ * Build a linked segment ID from a variant name (e.g., `'settings'` -> `'~settings'`).
62
+ * Nodes identified by linked segments share their attention state with the parent node.
63
+ */
64
+ export declare const linkedSegment: (variant: string) => string;
65
+ /**
66
+ * Extract the variant name from the last segment of a qualified ID, stripping the linked prefix.
67
+ * e.g. `'root/space/obj/~settings'` -> `'settings'`.
68
+ * If the segment is not linked (no `~` prefix), returns the segment as-is.
69
+ */
70
+ export declare const getLinkedVariant: (qualifiedId: string) => string;
71
+ /**
72
+ * Get the parent qualified ID (everything before the last `/` segment).
73
+ */
74
+ export declare const getParentId: (qualifiedId: string | undefined) => string | undefined;
75
+ /**
76
+ * Extract the segment ID (last segment) of a qualified ID.
77
+ */
78
+ export declare const getSegmentId: (qualifiedId: string) => string;
43
79
  //# sourceMappingURL=attention.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attention.d.ts","sourceRoot":"","sources":["../../../src/attention.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAIpD,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,eAAO,MAAM,eAAe;;;;GAM3B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAC;AAKnE;;GAEG;AAEH,qBAAa,gBAAgB;IAG3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwD;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgD;gBAE3D,OAAO,GAAE,MAAM,EAAO;IAMlC;;;;OAIG;IACH,IAAI,OAAO,IAAI,IAAI,CAAC,SAAS,MAAM,EAAE,CAAC,CAErC;IAED;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE,EAAE;IAIlB;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;IA8CnC,OAAO,CAAC,IAAI;CAMb;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,QAAQ,OAAO,EAAE,MAAK,MAAM,EAAO,KAAG,MAAM,EAqB5F,CAAC;AAEF,MAA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SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;AAEpF,eAAO,MAAM,cAAc,0GAkB1B,CAAC"}
1
+ {"version":3,"file":"AttentionGlyph.d.ts","sourceRoot":"","sources":["../../../../src/components/AttentionGlyph.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,EAAsB,KAAK,qBAAqB,EAAuB,MAAM,OAAO,CAAC;AAEnG,OAAO,EAAQ,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAkD5D,eAAO,MAAM,OAAO,yBAmBnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;CACpC,GAAG,eAAe,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;AAEpF,eAAO,MAAM,cAAc,0GAkB1B,CAAC"}
@@ -1,27 +1,16 @@
1
- import '@dxos-theme';
1
+ import { type StoryObj } from '@storybook/react-vite';
2
2
  import React from 'react';
3
3
  import { type AttentionGlyphProps } from './AttentionGlyph';
4
- declare const _default: {
4
+ declare const meta: {
5
5
  title: string;
6
- component: React.ForwardRefExoticComponent<Omit<AttentionGlyphProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
6
+ component: any;
7
7
  render: (props: AttentionGlyphProps) => React.JSX.Element;
8
8
  decorators: import("@storybook/react").Decorator[];
9
9
  };
10
- export default _default;
11
- export declare const Default: {
12
- args: {};
13
- };
14
- export declare const Attention: {
15
- args: {
16
- attended: boolean;
17
- };
18
- };
19
- export declare const Contains: {
20
- args: {
21
- containsAttended: boolean;
22
- };
23
- };
24
- export declare const Syncing: {
25
- render: () => React.JSX.Element;
26
- };
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+ export declare const Default: Story;
13
+ export declare const Attention: Story;
14
+ export declare const Contains: Story;
15
+ export declare const Syncing: Story;
27
16
  //# sourceMappingURL=AttentionGlyph.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AttentionGlyph.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/AttentionGlyph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAA2C,MAAM,OAAO,CAAC;AAMhE,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;;;;oBAEtD,mBAAmB;;;AAgBzC,wBAKE;AAEF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;CAErB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;CAEpB,CAAC;AAEF,eAAO,MAAM,OAAO;;CAqCnB,CAAC"}
1
+ {"version":3,"file":"AttentionGlyph.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/AttentionGlyph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAA2C,MAAM,OAAO,CAAC;AAMhE,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAkB5E,QAAA,MAAM,IAAI;;eAEqB,GAAG;oBAlBL,mBAAmB;;CAqBX,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAEvB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAEtB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAqCrB,CAAC"}