@dxos/react-ui-attention 0.8.4-main.c85a9c8dae → 0.8.4-main.d05673bc65

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.
@@ -2,6 +2,7 @@ import { Atom, type Registry } from '@effect-atom/atom-react';
2
2
  import { type Attention } from './types';
3
3
  /**
4
4
  * Manages attention state for an application.
5
+ * Attention keys are slash-qualified graph IDs; ancestry is derived from progressive prefixes.
5
6
  */
6
7
  export declare class AttentionManager {
7
8
  private readonly _registry;
@@ -9,34 +10,35 @@ export declare class AttentionManager {
9
10
  private readonly _currentAtom;
10
11
  constructor(_registry: Registry.Registry, initial?: string[]);
11
12
  /**
12
- * Atom for the currently attended element path.
13
+ * Atom for the currently attended element IDs.
13
14
  */
14
15
  get current(): Atom.Atom<string[]>;
15
16
  /**
16
- * Gets the currently attended element path.
17
+ * Gets the currently attended element IDs.
17
18
  */
18
19
  getCurrent(): readonly string[];
19
20
  /**
20
- * Subscribe to changes in the current attention path.
21
+ * Subscribe to changes in the current attention IDs.
21
22
  */
22
23
  subscribeCurrent(cb: (current: readonly string[]) => void): () => void;
23
24
  /**
24
- * All attention paths.
25
+ * All tracked qualified IDs.
25
26
  */
26
- keys(): string[][];
27
+ keys(): string[];
27
28
  /**
28
- * Get the attention state for a given path.
29
+ * Get the attention state for a given qualified ID.
29
30
  */
30
- get(key: string[]): Attention;
31
+ get(id: string): Attention;
31
32
  /**
32
- * Subscribe to changes in the attention state for a given path.
33
+ * Subscribe to changes in the attention state for a given qualified ID.
33
34
  */
34
- subscribe(key: string[], cb: (attention: Attention) => void): () => void;
35
+ subscribe(id: string, cb: (attention: Attention) => void): () => void;
35
36
  private _getAtom;
36
37
  private _set;
37
38
  }
38
39
  /**
39
- * 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).
40
42
  */
41
43
  export declare const getAttendables: (selector: string, cursor: Element, acc?: string[]) => string[];
42
44
  export type AttendableId = {
@@ -45,4 +47,21 @@ export type AttendableId = {
45
47
  export type Related = {
46
48
  related?: boolean;
47
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 starts with the attendable path separator.
57
+ */
58
+ export declare const isSeparatorPrefixed: (qualifiedId: string) => boolean;
59
+ /**
60
+ * Get the parent qualified ID (everything before the last `/` segment).
61
+ */
62
+ export declare const getParentId: (qualifiedId: string | undefined) => string | undefined;
63
+ /**
64
+ * Extract the segment ID (last segment) of a qualified ID.
65
+ */
66
+ export declare const getSegmentId: (qualifiedId: string) => string;
48
67
  //# sourceMappingURL=attention.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attention.d.ts","sourceRoot":"","sources":["../../../src/attention.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAI9D,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAKpE;;GAEG;AACH,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJ5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiE;IACtF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0B;gBAGpC,SAAS,EAAE,QAAQ,CAAC,QAAQ,EAC7C,OAAO,GAAE,MAAM,EAAO;IAQxB;;OAEG;IACH,IAAI,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAEjC;IAED;;OAEG;IACH,UAAU,IAAI,SAAS,MAAM,EAAE;IAI/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,SAAS,MA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EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI;IAOtE;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE;IAIhB;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAK1B;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;IAQrE,OAAO,CAAC,QAAQ;IAuEhB,OAAO,CAAC,IAAI;CAQb;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,QAAQ,OAAO,EAAE,MAAK,MAAM,EAAO,KAAG,MAAM,EAoB5F,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,MAAM,OAAO,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,aAAa,MAAM,KAAG,MAAM,EAG9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,KAAG,OAGzD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,aAAa,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAOtE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,aAAa,MAAM,KAAG,MAElD,CAAC"}
@@ -7,33 +7,31 @@ declare const ATTENDABLE_ATTRIBUTE = "data-attendable-id";
7
7
  declare const ATTENTION_SOURCE_ATTRIBUTE = "data-w-attention-source";
8
8
  type AttentionContextValue = {
9
9
  attention: AttentionManager;
10
- path: string[];
11
10
  };
12
11
  declare const useAttentionContext: (consumerName: string) => AttentionContextValue;
12
+ /**
13
+ * Subscribe to the attention state for a qualified graph ID.
14
+ */
13
15
  declare const useAttention: (attendableId?: string) => Attention;
14
16
  declare const useAttended: () => readonly string[];
15
17
  /**
16
18
  * Computes HTML element attributes to apply so the attention system can detect changes.
17
- * @param attendableId
18
19
  */
19
20
  declare const useAttentionAttributes: (attendableId?: string) => Record<string, string | undefined>;
20
- declare const useAttentionPath: () => string[];
21
21
  declare const RootAttentionProvider: ({ children, attention: propsAttention, onChange, }: PropsWithChildren<Partial<{
22
22
  attention: AttentionManager;
23
23
  onChange: (nextAttended: string[]) => void;
24
24
  }>>) => React.JSX.Element;
25
- declare const AttentionProvider: ({ id, children }: PropsWithChildren<{
26
- id: string;
27
- }>) => React.JSX.Element;
28
25
  export type AttendableContainerProps = ThemedClassName<ComponentPropsWithRef<'div'> & {
29
26
  id: string;
30
27
  asChild?: boolean;
31
28
  }>;
32
29
  /**
33
- * Note that DeckPlugin and StackPlugin both handle attention on their own, and when rendering content in those cases it
34
- * is not necessary to also render an `AttendableContainer`. This component is primarily for Storybook stories and other
35
- * testing scenarios, or the rare cases where an attendable entity is rendered outside of either of those plugins.
30
+ * Note that DeckPlugin and StackPlugin both handle attention on their own,
31
+ * and when rendering content in those cases it is not necessary to also render an `AttendableContainer`.
32
+ * This component is primarily for Storybook stories and other testing scenarios,
33
+ * or the rare cases where an attendable entity is rendered outside of either of those plugins.
36
34
  */
37
35
  declare const AttendableContainer: React.ForwardRefExoticComponent<Omit<AttendableContainerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
38
- export { RootAttentionProvider, AttentionProvider, AttendableContainer, useAttentionContext, useAttention, useAttended, useAttentionAttributes, useAttentionPath, ATTENTION_NAME, ATTENDABLE_ATTRIBUTE, ATTENTION_SOURCE_ATTRIBUTE, };
36
+ export { RootAttentionProvider, AttendableContainer, useAttentionContext, useAttention, useAttended, useAttentionAttributes, ATTENTION_NAME, ATTENDABLE_ATTRIBUTE, ATTENTION_SOURCE_ATTRIBUTE, };
39
37
  //# sourceMappingURL=AttentionProvider.d.ts.map
@@ -1 +1 @@
1
- {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