@dxos/react-ui-attention 0.16.0 → 0.17.0

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 (58) hide show
  1. package/dist/lib/chunk-ViewStateProvider.mjs +1 -1
  2. package/dist/lib/chunk-types.mjs +240 -9
  3. package/dist/lib/chunk-types.mjs.map +1 -1
  4. package/dist/lib/index.mjs +242 -56
  5. package/dist/lib/index.mjs.map +1 -1
  6. package/dist/lib/testing.mjs +1 -1
  7. package/dist/lib/types.mjs +1 -1
  8. package/dist/types/src/components/AttentionGlyph/AttentionGlyph.d.ts +6 -11
  9. package/dist/types/src/components/AttentionGlyph/AttentionGlyph.d.ts.map +1 -1
  10. package/dist/types/src/components/AttentionGlyph/AttentionGlyph.stories.d.ts +13 -6
  11. package/dist/types/src/components/AttentionGlyph/AttentionGlyph.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/RemoteCursor/RemoteCursor.d.ts +18 -0
  13. package/dist/types/src/components/RemoteCursor/RemoteCursor.d.ts.map +1 -0
  14. package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.d.ts +32 -0
  15. package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.d.ts.map +1 -0
  16. package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.test.d.ts +2 -0
  17. package/dist/types/src/components/RemoteCursor/RemoteCursorLayer.test.d.ts.map +1 -0
  18. package/dist/types/src/components/RemoteCursor/index.d.ts +3 -0
  19. package/dist/types/src/components/RemoteCursor/index.d.ts.map +1 -0
  20. package/dist/types/src/components/ScrollScope/ScrollScope.d.ts +11 -0
  21. package/dist/types/src/components/ScrollScope/ScrollScope.d.ts.map +1 -0
  22. package/dist/types/src/components/ScrollScope/ScrollScope.stories.d.ts +15 -0
  23. package/dist/types/src/components/ScrollScope/ScrollScope.stories.d.ts.map +1 -0
  24. package/dist/types/src/components/ScrollScope/index.d.ts +2 -0
  25. package/dist/types/src/components/ScrollScope/index.d.ts.map +1 -0
  26. package/dist/types/src/components/index.d.ts +2 -0
  27. package/dist/types/src/components/index.d.ts.map +1 -1
  28. package/dist/types/src/types/Activity.d.ts +71 -0
  29. package/dist/types/src/types/Activity.d.ts.map +1 -0
  30. package/dist/types/src/types/Activity.test.d.ts +2 -0
  31. package/dist/types/src/types/Activity.test.d.ts.map +1 -0
  32. package/dist/types/src/types/ScrollPosition.d.ts +24 -0
  33. package/dist/types/src/types/ScrollPosition.d.ts.map +1 -0
  34. package/dist/types/src/types/ViewLocation.d.ts +16 -0
  35. package/dist/types/src/types/ViewLocation.d.ts.map +1 -0
  36. package/dist/types/src/types/ViewState.d.ts +44 -2
  37. package/dist/types/src/types/ViewState.d.ts.map +1 -1
  38. package/dist/types/src/types/index.d.ts +3 -0
  39. package/dist/types/src/types/index.d.ts.map +1 -1
  40. package/dist/types/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +17 -16
  42. package/src/components/AttentionGlyph/AttentionGlyph.stories.tsx +424 -31
  43. package/src/components/AttentionGlyph/AttentionGlyph.tsx +80 -56
  44. package/src/components/RemoteCursor/RemoteCursor.tsx +55 -0
  45. package/src/components/RemoteCursor/RemoteCursorLayer.test.tsx +98 -0
  46. package/src/components/RemoteCursor/RemoteCursorLayer.tsx +97 -0
  47. package/src/components/RemoteCursor/index.ts +6 -0
  48. package/src/components/ScrollScope/ScrollScope.stories.tsx +97 -0
  49. package/src/components/ScrollScope/ScrollScope.tsx +59 -0
  50. package/src/components/ScrollScope/index.ts +5 -0
  51. package/src/components/index.ts +2 -0
  52. package/src/types/Activity.test.ts +53 -0
  53. package/src/types/Activity.ts +110 -0
  54. package/src/types/ScrollPosition.ts +34 -0
  55. package/src/types/ViewLocation.ts +28 -0
  56. package/src/types/ViewState.test.ts +74 -1
  57. package/src/types/ViewState.ts +217 -4
  58. package/src/types/index.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-attention",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Signifier components and providers for attention system.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -36,31 +36,32 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@ark-ui/react": "^5.39.1",
39
+ "@dxos/invariant": "0.17.0",
40
+ "@dxos/keys": "0.17.0",
41
+ "@dxos/log": "0.17.0",
42
+ "@dxos/react-focus": "0.17.0",
43
+ "@dxos/react-hooks": "0.17.0",
44
+ "@dxos/react-ui": "0.17.0",
45
+ "@dxos/ui-theme": "0.17.0",
46
+ "@dxos/ui-types": "0.17.0",
39
47
  "@effect/atom-react": "4.0.4",
40
- "effect": "4.0.4",
41
- "@dxos/invariant": "0.16.0",
42
- "@dxos/log": "0.16.0",
43
- "@dxos/react-focus": "0.16.0",
44
- "@dxos/react-hooks": "0.16.0",
45
- "@dxos/react-ui": "0.16.0",
46
- "@dxos/ui-theme": "0.16.0",
47
- "@dxos/ui-types": "0.16.0"
48
+ "effect": "4.0.4"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@storybook/react-vite": "^10.6.0",
51
52
  "@testing-library/jest-dom": "^6.9.1",
52
53
  "@testing-library/react": "^16.3.2",
53
- "@types/react": "~19.2.17",
54
- "@types/react-dom": "~19.2.3",
55
- "react": "~19.2.7",
56
- "react-dom": "~19.2.7",
54
+ "@types/react": "~19.3.0",
55
+ "@types/react-dom": "~19.3.0",
56
+ "react": "~19.3.1",
57
+ "react-dom": "~19.3.1",
57
58
  "vite": "^8.3.4"
58
59
  },
59
60
  "peerDependencies": {
61
+ "@dxos/ui-theme": "^0.17.0",
60
62
  "effect": "4.0.4",
61
- "react": "~19.2.7",
62
- "react-dom": "~19.2.7",
63
- "@dxos/ui-theme": "^0.16.0"
63
+ "react": "~19.3.1",
64
+ "react-dom": "~19.3.1"
64
65
  },
65
66
  "publishConfig": {
66
67
  "access": "public"
@@ -3,13 +3,15 @@
3
3
  //
4
4
 
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React from 'react';
6
+ import React, { type PropsWithChildren } from 'react';
7
7
  import { expect, within } from 'storybook/test';
8
8
 
9
9
  import '@dxos/react-ui/theme.css';
10
+ import * as Icon from '@dxos/react-ui/Icon';
10
11
  import { SIZE_ARG_TYPES, type SizeArgs, withLayout, withSizes, withTheme } from '@dxos/react-ui/testing';
11
12
 
12
- import { AttentionGlyph, type AttentionGlyphPresence, type AttentionGlyphProps } from './AttentionGlyph.tsx';
13
+ import * as Activity from '../../types/Activity.ts';
14
+ import { AttentionGlyph, type AttentionGlyphProps } from './AttentionGlyph.tsx';
13
15
 
14
16
  /** The `withSizes` row holding the story rendered at `size`. */
15
17
  const sizeRow = (root: HTMLElement, size: string) => {
@@ -20,44 +22,429 @@ const sizeRow = (root: HTMLElement, size: string) => {
20
22
  return element;
21
23
  };
22
24
 
23
- type StoryArgs = SizeArgs & Pick<AttentionGlyphProps, 'attended' | 'containsAttended' | 'syncing'>;
25
+ /** Attention is not a treatment: the glyph takes it as props. */
26
+ type AttentionName = 'attended' | 'contains-attended';
24
27
 
25
- const PRESENCES: AttentionGlyphPresence[] = ['none', 'one', 'many'];
28
+ type Example = {
29
+ readonly label: string;
30
+ /** What produces it in the app; examples without one only show what a treatment can describe. */
31
+ readonly source?: string;
32
+ readonly treatment: Activity.Treatment;
33
+ };
34
+
35
+ /** Treatments in use, then examples of what other activity could draw. */
36
+ const EXAMPLES = {
37
+ 'viewer': {
38
+ label: 'One viewer',
39
+ source: 'presence',
40
+ treatment: { slot: 'mark', icon: 'dot', hue: 'primary', priority: 10 },
41
+ },
42
+ 'viewers': {
43
+ label: 'Several viewers',
44
+ source: 'presence',
45
+ treatment: { slot: 'mark', icon: 'dots', hue: 'primary', priority: 10 },
46
+ },
47
+ 'agent': {
48
+ label: 'Agent working',
49
+ source: 'assistant',
50
+ treatment: { slot: 'mark', icon: 'star', priority: 30, animate: true },
51
+ },
52
+ 'editing': {
53
+ label: 'Someone editing',
54
+ treatment: { slot: 'mark', icon: 'ph--pencil-simple--fill', priority: 15, animate: true },
55
+ },
56
+ 'warning': {
57
+ label: 'Needs a fix',
58
+ treatment: { slot: 'mark', icon: 'ph--warning--fill', hue: 'warning', priority: 25 },
59
+ },
60
+ 'busy': {
61
+ label: 'Busy',
62
+ treatment: { slot: 'fill', hue: 'amber', priority: 10, animate: true },
63
+ },
64
+ 'pinned': {
65
+ label: 'Pinned',
66
+ treatment: { slot: 'fill', hue: 'violet', opacity: 0.4, priority: 20 },
67
+ },
68
+ 'failed': { label: 'Failed', treatment: { slot: 'edge', hue: 'error', priority: 40 } },
69
+ 'following': { label: 'Following someone', treatment: { slot: 'edge', hue: 'violet', priority: 30 } },
70
+ 'call': { label: 'Live call', treatment: { slot: 'edge', hue: 'green', priority: 20 } },
71
+ 'working': { label: 'Working', treatment: { slot: 'edge', hue: 'amber', priority: 10 } },
72
+ 'scheduled': { label: 'Scheduled soon', treatment: { slot: 'edge', hue: 'teal', dashed: true, priority: 0 } },
73
+ 'asked': {
74
+ label: 'Agent asked you',
75
+ treatment: { slot: 'corner', hue: 'amber', priority: 40, animate: true },
76
+ },
77
+ 'mention': { label: 'Mention or reply', treatment: { slot: 'corner', hue: 'rose', priority: 30 } },
78
+ 'changed': { label: 'Changed since seen', treatment: { slot: 'corner', hue: 'primary', priority: 20 } },
79
+ 'read-only': {
80
+ label: 'Read-only',
81
+ treatment: { slot: 'corner', hue: 'neutral', shape: 'ring', priority: 10 },
82
+ },
83
+ } satisfies Record<string, Example>;
84
+
85
+ type ExampleName = keyof typeof EXAMPLES;
26
86
 
27
- const DefaultStory = ({ attended, containsAttended, syncing }: StoryArgs) => (
87
+ type Name = AttentionName | ExampleName;
88
+
89
+ const isAttention = (name: Name): name is AttentionName => name === 'attended' || name === 'contains-attended';
90
+
91
+ const nameLabel = (name: Name) =>
92
+ name === 'attended' ? 'Attended' : name === 'contains-attended' ? 'Contains attended' : EXAMPLES[name].label;
93
+
94
+ const treatmentsOf = (names: readonly Name[]): Activity.Treatment[] =>
95
+ names.flatMap((name) => (isAttention(name) ? [] : [EXAMPLES[name].treatment]));
96
+
97
+ const glyphProps = (names: readonly Name[]): AttentionGlyphProps => ({
98
+ attended: names.includes('attended'),
99
+ containsAttended: names.includes('contains-attended'),
100
+ treatments: treatmentsOf(names),
101
+ });
102
+
103
+ const SLOT_LABELS: Record<Activity.Slot, string> = {
104
+ fill: 'Fill: a hue and its opacity, under attention',
105
+ mark: 'Mark: a built-in shape or any icon, in a hue',
106
+ edge: 'Edge: a hue, solid or dashed',
107
+ corner: 'Corner: a hue, as a dot or a ring',
108
+ };
109
+
110
+ const Section = ({ title, children }: PropsWithChildren<{ title: string }>) => (
111
+ <section className='flex flex-col gap-2'>
112
+ <h2 className='text-sm text-description'>{title}</h2>
113
+ {children}
114
+ </section>
115
+ );
116
+
117
+ const Row = ({ icon, label, treatments }: { icon: string; label: string; treatments: Name[] }) => (
118
+ <div className='flex items-center gap-2 px-2 py-1 rounded-sm bg-group-surface' data-testid={label}>
119
+ <Icon.Icon icon={icon} />
120
+ <span className='grow truncate'>{label}</span>
121
+ <AttentionGlyph {...glyphProps(treatments)} classNames='mx-1' />
122
+ </div>
123
+ );
124
+
125
+ //
126
+ // Examples.
127
+ //
128
+
129
+ const ExamplesStory = () => (
130
+ <Section title='Each treatment describes how it draws; in use first, then examples. The number is its priority'>
131
+ <div className='grid grid-cols-4 gap-4'>
132
+ {Activity.Slots.map((slot) => (
133
+ <div key={slot} className='flex flex-col gap-2 p-3 rounded-md bg-group-surface' data-testid={`slot-${slot}`}>
134
+ <h3 className='text-sm'>{SLOT_LABELS[slot]}</h3>
135
+ {Object.entries<Example>(EXAMPLES)
136
+ .filter(([, example]) => example.treatment.slot === slot)
137
+ .map(([name, example]) => (
138
+ <div key={name} className='flex items-center gap-2 text-sm' data-testid={name}>
139
+ <span className='w-4 text-xs text-description'>{example.treatment.priority}</span>
140
+ <AttentionGlyph treatments={[example.treatment]} classNames='mx-1' />
141
+ <span className='grow'>{example.label}</span>
142
+ {example.source && <span className='text-xs text-description'>{example.source}</span>}
143
+ </div>
144
+ ))}
145
+ </div>
146
+ ))}
147
+ </div>
148
+ </Section>
149
+ );
150
+
151
+ //
152
+ // Resolution.
153
+ //
154
+
155
+ const RESOLUTIONS: { slot: Activity.Slot; requested: Name[] }[] = [
156
+ { slot: 'fill', requested: ['busy', 'attended'] },
157
+ { slot: 'mark', requested: ['agent', 'viewer', 'viewers'] },
158
+ { slot: 'edge', requested: ['working', 'call', 'failed'] },
159
+ { slot: 'corner', requested: ['changed', 'read-only', 'asked'] },
160
+ ];
161
+
162
+ const ResolutionStory = () => (
163
+ <Section title='Resolving a slot: the winner renders, the rest go to the tooltip'>
164
+ <div className='grid grid-cols-[6rem_auto_2rem_1fr] items-center gap-x-4 gap-y-2 text-sm'>
165
+ {RESOLUTIONS.map(({ slot, requested }) => {
166
+ const { attended, containsAttended, treatments = [] } = glyphProps(requested);
167
+ const resolved = Activity.resolve(treatments, { attention: attended || containsAttended })[slot];
168
+ const winner = requested.find((name) =>
169
+ isAttention(name) ? slot === 'fill' && !resolved : EXAMPLES[name].treatment === resolved,
170
+ );
171
+ return (
172
+ <React.Fragment key={slot}>
173
+ <span className='capitalize text-description'>{slot}</span>
174
+ <div className='flex items-center gap-1'>
175
+ {requested.map((treatment) => (
176
+ <AttentionGlyph
177
+ key={treatment}
178
+ {...glyphProps([treatment])}
179
+ classNames={['mx-1', treatment !== winner && 'opacity-40']}
180
+ />
181
+ ))}
182
+ </div>
183
+ <Icon.Icon icon='ph--arrow-right--regular' />
184
+ <div className='flex items-center gap-2'>
185
+ <AttentionGlyph {...glyphProps(requested)} classNames='mx-1' data-testid={`resolved-${slot}`} />
186
+ <span>{winner && nameLabel(winner)} wins</span>
187
+ </div>
188
+ </React.Fragment>
189
+ );
190
+ })}
191
+ </div>
192
+ </Section>
193
+ );
194
+
195
+ //
196
+ // Combinations.
197
+ //
198
+
199
+ const COMBINATIONS: { icon: string; label: string; caption: string; treatments: Name[] }[] = [
200
+ { icon: 'ph--file-text--regular', label: 'Meeting notes', caption: 'Nothing happening', treatments: [] },
201
+ { icon: 'ph--file-text--regular', label: 'Roadmap', caption: 'Attended', treatments: ['attended'] },
202
+ {
203
+ icon: 'ph--folder--regular',
204
+ label: 'Q4 planning',
205
+ caption: 'Contains attended',
206
+ treatments: ['contains-attended'],
207
+ },
208
+ { icon: 'ph--file-text--regular', label: 'Design brief', caption: 'One viewer', treatments: ['viewer'] },
209
+ { icon: 'ph--file-text--regular', label: 'Launch plan', caption: 'Several viewers', treatments: ['viewers'] },
210
+ {
211
+ icon: 'ph--sparkle--regular',
212
+ label: 'Chat: summarise launch',
213
+ caption: 'Assistant working',
214
+ treatments: ['agent'],
215
+ },
216
+ {
217
+ icon: 'ph--sparkle--regular',
218
+ label: 'Chat: book travel',
219
+ caption: 'Agent and asked you',
220
+ treatments: ['agent', 'asked'],
221
+ },
222
+ {
223
+ icon: 'ph--file-text--regular',
224
+ label: 'Roadmap',
225
+ caption: 'Attended, viewer, working',
226
+ treatments: ['attended', 'viewer', 'working'],
227
+ },
228
+ {
229
+ icon: 'ph--video--regular',
230
+ label: 'Standup notes',
231
+ caption: 'Viewers, live call, mention',
232
+ treatments: ['viewers', 'call', 'mention'],
233
+ },
234
+ {
235
+ icon: 'ph--folder--regular',
236
+ label: 'Q4 planning',
237
+ caption: 'Contains attended, failed',
238
+ treatments: ['contains-attended', 'failed'],
239
+ },
240
+ {
241
+ icon: 'ph--file-text--regular',
242
+ label: 'Spec v2',
243
+ caption: 'One of each slot',
244
+ treatments: ['attended', 'editing', 'following', 'changed'],
245
+ },
246
+ ];
247
+
248
+ const CombinationsStory = () => (
249
+ <Section title='Across slots: any one from each'>
250
+ <div className='grid grid-cols-3 gap-x-4 gap-y-3'>
251
+ {COMBINATIONS.map(({ icon, label, caption, treatments }) => (
252
+ <div key={caption} className='flex flex-col gap-1'>
253
+ <Row icon={icon} label={label} treatments={treatments} />
254
+ <span className='px-1 text-xs text-description'>{caption}</span>
255
+ </div>
256
+ ))}
257
+ </div>
258
+ </Section>
259
+ );
260
+
261
+ //
262
+ // Motion.
263
+ //
264
+
265
+ const MOTIONS: { caption: string; label: string; icon: string; treatments: Name[] }[] = [
266
+ {
267
+ caption: 'Editing moves; nothing competes',
268
+ icon: 'ph--file-text--regular',
269
+ label: 'Spec v2',
270
+ treatments: ['attended', 'editing', 'following', 'changed'],
271
+ },
272
+ {
273
+ caption: 'Asked you moves; the sparkle holds still',
274
+ icon: 'ph--sparkle--regular',
275
+ label: 'Chat: book travel',
276
+ treatments: ['agent', 'working', 'asked'],
277
+ },
278
+ {
279
+ caption: 'The edge never moves, so editing does',
280
+ icon: 'ph--file-text--regular',
281
+ label: 'Launch plan',
282
+ treatments: ['editing', 'working'],
283
+ },
284
+ {
285
+ caption: 'A still mark lets the busy fill move',
286
+ icon: 'ph--robot--regular',
287
+ label: 'Triage agent',
288
+ treatments: ['busy', 'viewer', 'failed'],
289
+ },
290
+ ];
291
+
292
+ const MotionStory = () => (
293
+ <Section title='One thing moves: corner, then mark, then fill; the edge stays still'>
294
+ <div className='grid grid-cols-[1fr_16rem] items-center gap-x-4 gap-y-2 text-sm'>
295
+ {MOTIONS.map(({ caption, label, icon, treatments }) => (
296
+ <React.Fragment key={caption}>
297
+ <span className='text-description'>{caption}</span>
298
+ <Row icon={icon} label={label} treatments={treatments} />
299
+ </React.Fragment>
300
+ ))}
301
+ </div>
302
+ </Section>
303
+ );
304
+
305
+ //
306
+ // Agent session.
307
+ //
308
+
309
+ const AGENT_VIEWERS: { title: string; treatments: Name[] }[] = [
310
+ { title: 'Nobody', treatments: [] },
311
+ { title: 'Someone else', treatments: ['viewer'] },
312
+ { title: 'You', treatments: ['attended'] },
313
+ ];
314
+
315
+ const AGENT_STATES: { title: string; treatments: Name[] }[] = [
316
+ { title: 'Idle', treatments: [] },
317
+ { title: 'Agent working', treatments: ['agent'] },
318
+ { title: 'Turn failed', treatments: ['failed'] },
319
+ ];
320
+
321
+ const AgentSessionStory = () => (
322
+ <Section title='An agent session: the star pulses while it works, and a failed turn leaves a red edge'>
323
+ <div className='grid grid-cols-[8rem_repeat(3,minmax(0,1fr))] items-center gap-x-3 gap-y-2 text-sm'>
324
+ <span className='text-description'>Open by</span>
325
+ {AGENT_STATES.map(({ title }) => (
326
+ <span key={title} className='text-description'>
327
+ {title}
328
+ </span>
329
+ ))}
330
+ {AGENT_VIEWERS.map((viewers) => (
331
+ <React.Fragment key={viewers.title}>
332
+ <span className='text-description'>{viewers.title}</span>
333
+ {AGENT_STATES.map((state) => (
334
+ <Row
335
+ key={state.title}
336
+ icon='ph--sparkle--regular'
337
+ label='Trip ideas'
338
+ treatments={[...viewers.treatments, ...state.treatments]}
339
+ />
340
+ ))}
341
+ </React.Fragment>
342
+ ))}
343
+ </div>
344
+ </Section>
345
+ );
346
+
347
+ const AllStory = () => (
348
+ <div className='flex flex-col gap-8 p-4'>
349
+ <ExamplesStory />
350
+ <ResolutionStory />
351
+ <CombinationsStory />
352
+ <MotionStory />
353
+ <AgentSessionStory />
354
+ </div>
355
+ );
356
+
357
+ //
358
+ // Sizes.
359
+ //
360
+
361
+ type SizeStoryArgs = SizeArgs & Pick<AttentionGlyphProps, 'attended' | 'containsAttended'>;
362
+
363
+ const SizesStory = ({ attended, containsAttended }: SizeStoryArgs) => (
28
364
  <div className='flex items-center gap-4'>
29
- {PRESENCES.map((presence) => (
30
- <AttentionGlyph
31
- key={presence}
32
- presence={presence}
33
- {...{ attended, containsAttended, syncing }}
34
- data-testid={presence}
35
- />
36
- ))}
37
- <AttentionGlyph attended presence='one' data-testid='attended' />
365
+ <AttentionGlyph {...{ attended, containsAttended }} data-testid='none' />
366
+ <AttentionGlyph {...{ attended, containsAttended }} treatments={treatmentsOf(['viewer'])} data-testid='viewer' />
367
+ <AttentionGlyph {...{ attended, containsAttended }} treatments={treatmentsOf(['viewers'])} data-testid='viewers' />
368
+ <AttentionGlyph attended treatments={treatmentsOf(['viewer'])} data-testid='attended' />
38
369
  <AttentionGlyph containsAttended data-testid='contains' />
39
- <AttentionGlyph syncing data-testid='syncing' />
370
+ <AttentionGlyph treatments={treatmentsOf(['viewers', 'working', 'asked'])} data-testid='busy' />
40
371
  </div>
41
372
  );
42
373
 
43
- const meta: Meta<StoryArgs> = {
374
+ const meta: Meta = {
44
375
  title: 'ui/react-ui-core/components/AttentionGlyph',
45
- render: DefaultStory,
46
- decorators: [withSizes(), withLayout({ classNames: 'p-0 w-[24rem]' }), withTheme()],
47
- args: { size: 'md', attended: false, containsAttended: false, syncing: false },
48
- argTypes: SIZE_ARG_TYPES,
376
+ decorators: [withTheme()],
49
377
  parameters: { layout: 'centered' },
50
378
  };
51
379
 
52
380
  export default meta;
53
381
 
54
- type Story = StoryObj<typeof meta>;
382
+ type Story = StoryObj;
383
+
384
+ /** Everything the glyph can draw: the vocabulary, how slots resolve, combinations and the motion rule. */
385
+ export const Default: StoryObj<SizeArgs> = {
386
+ render: AllStory,
387
+ decorators: [withSizes()],
388
+ args: { size: 'md' },
389
+ argTypes: SIZE_ARG_TYPES,
390
+ parameters: { layout: 'fullscreen' },
391
+ };
392
+
393
+ export const Examples: Story = {
394
+ render: () => (
395
+ <div className='p-4 w-[68rem]'>
396
+ <ExamplesStory />
397
+ </div>
398
+ ),
399
+ };
400
+
401
+ export const Resolution: Story = {
402
+ render: () => (
403
+ <div className='p-4 w-[40rem]'>
404
+ <ResolutionStory />
405
+ </div>
406
+ ),
407
+ };
408
+
409
+ export const Combinations: Story = {
410
+ render: () => (
411
+ <div className='p-4 w-[56rem]'>
412
+ <CombinationsStory />
413
+ </div>
414
+ ),
415
+ };
55
416
 
56
- export const Default: Story = {};
417
+ export const AgentStar: StoryObj<SizeArgs> = {
418
+ render: () => (
419
+ <div className='p-4'>
420
+ <AgentSessionStory />
421
+ </div>
422
+ ),
423
+ decorators: [withSizes()],
424
+ args: { size: 'xl' },
425
+ argTypes: SIZE_ARG_TYPES,
426
+ parameters: { layout: 'fullscreen' },
427
+ };
428
+
429
+ export const Motion: Story = {
430
+ render: () => (
431
+ <div className='p-4 w-[40rem]'>
432
+ <MotionStory />
433
+ </div>
434
+ ),
435
+ };
436
+
437
+ export const Sizes: StoryObj<SizeStoryArgs> = {
438
+ render: SizesStory,
439
+ decorators: [withSizes(), withLayout({ classNames: 'p-0 w-[24rem]' })],
440
+ args: { size: 'md', attended: false, containsAttended: false },
441
+ argTypes: SIZE_ARG_TYPES,
442
+ };
57
443
 
58
- /** The glyph is 3/4 of the icon size; its state colours it, and its mark shows presence or a spinner. */
59
- export const Test: Story = {
60
- args: { allSizes: true },
444
+ /** The glyph is 3/4 of the icon size; attention colours its fill, and activity draws one treatment per slot. */
445
+ export const Test: StoryObj<SizeStoryArgs> = {
446
+ ...Sizes,
447
+ args: { ...Sizes.args, allSizes: true },
61
448
  play: async ({ canvasElement }) => {
62
449
  const canvas = within(sizeRow(canvasElement, 'md'));
63
450
  const rest = canvas.getByTestId('none');
@@ -66,9 +453,9 @@ export const Test: Story = {
66
453
  await expect(within(sizeRow(canvasElement, 'xl')).getByTestId('none').getBoundingClientRect().width).toBe(18);
67
454
  await expect(rest.childElementCount).toBe(0);
68
455
 
69
- // Presence marks are decorative; one and many draw different marks.
70
- const one = canvas.getByTestId('one').querySelector('svg');
71
- const many = canvas.getByTestId('many').querySelector('svg');
456
+ // Marks are decorative; one and several viewers draw different marks.
457
+ const one = canvas.getByTestId('viewer').querySelector('svg');
458
+ const many = canvas.getByTestId('viewers').querySelector('svg');
72
459
  await expect(one).toHaveAttribute('aria-hidden', 'true');
73
460
  await expect(one?.innerHTML).not.toBe(many?.innerHTML);
74
461
 
@@ -79,8 +466,14 @@ export const Test: Story = {
79
466
  await expect(background('contains')).not.toBe('rgba(0, 0, 0, 0)');
80
467
  await expect(background('contains')).not.toBe(background('attended'));
81
468
 
82
- // Syncing replaces the mark with a spinner turning every two seconds.
83
- const spinner = canvas.getByTestId('syncing').querySelector<SVGElement>('[data-scope="icon"]');
84
- await expect(spinner ? getComputedStyle(spinner).animationDuration : '').toBe('2s');
469
+ // Every slot draws at once, and only the corner (asked) animates.
470
+ const busy = canvas.getByTestId('busy');
471
+ await expect(busy).toHaveAttribute('data-moving', 'corner');
472
+ await expect(busy.querySelector('[data-part="edge"]')).not.toBeNull();
473
+ await expect(busy.querySelector('[data-part="mark"]')).not.toBeNull();
474
+ const corner = busy.querySelector<SVGElement>('[data-part="corner"]');
475
+ const edge = busy.querySelector<SVGElement>('[data-part="edge"]');
476
+ await expect(corner ? getComputedStyle(corner).animationName : '').toBe('dx-attention-glyph-pulse');
477
+ await expect(edge ? getComputedStyle(edge).animationName : '').toBe('none');
85
478
  },
86
479
  };