@zeyos/zx 5.4.0 → 5.6.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 (145) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/README.md +23 -16
  3. package/dist/types/components/agent-thread/agent-thread.d.ts +583 -0
  4. package/dist/types/components/app-sidebar/app-sidebar.d.ts +33 -0
  5. package/dist/types/components/approval-card/approval-card.d.ts +596 -0
  6. package/dist/types/components/avatar/avatar.d.ts +91 -4
  7. package/dist/types/components/badge/badge.d.ts +5 -4
  8. package/dist/types/components/block-view/block-view.d.ts +205 -0
  9. package/dist/types/components/composer/composer.d.ts +736 -0
  10. package/dist/types/components/datebox/date-range-box.d.ts +15 -2
  11. package/dist/types/components/datebox/datebox.d.ts +37 -3
  12. package/dist/types/components/kbd/kbd.d.ts +41 -0
  13. package/dist/types/components/launcher/launcher.d.ts +4 -2
  14. package/dist/types/components/prose/prose.d.ts +69 -0
  15. package/dist/types/components/questionnaire/questionnaire.d.ts +0 -36
  16. package/dist/types/components/run-status/run-status.d.ts +393 -0
  17. package/dist/types/components/run-trace/run-trace.d.ts +624 -0
  18. package/dist/types/components/source-list/source-list.d.ts +177 -0
  19. package/dist/types/components/stat-tile/stat-tile.d.ts +20 -0
  20. package/dist/types/components/tag-picker/tag-picker.d.ts +11 -5
  21. package/dist/types/components/tree/tree.d.ts +44 -3
  22. package/dist/types/core/icons.d.ts +22 -1
  23. package/dist/types/core/messages.d.ts +135 -0
  24. package/dist/types/index.d.ts +12 -2
  25. package/dist/types/internal/agent-model.d.ts +587 -0
  26. package/dist/types/internal/app-rail.d.ts +10 -3
  27. package/dist/types/internal/highlight.d.ts +24 -0
  28. package/dist/types/internal/presence-loop.d.ts +148 -0
  29. package/dist/types/internal/row-actions.d.ts +151 -0
  30. package/dist/zx-zeyos.esm.js +4852 -4535
  31. package/dist/zx-zeyos.esm.min.js +4 -4
  32. package/dist/zx.css +3152 -434
  33. package/dist/zx.esm.js +13730 -6595
  34. package/dist/zx.esm.min.js +27 -8
  35. package/dist/zx.global.js +13730 -6595
  36. package/dist/zx.global.min.js +27 -8
  37. package/dist/zx.min.css +1 -1
  38. package/docs/api.json +1474 -205
  39. package/docs/llms.md +698 -39
  40. package/docs/llms.txt +12 -1
  41. package/package.json +1 -1
  42. package/src/components/account-menu/account-menu.js +2 -2
  43. package/src/components/agent-thread/agent-thread.css +417 -0
  44. package/src/components/agent-thread/agent-thread.js +1365 -0
  45. package/src/components/app-rail/app-rail.css +11 -11
  46. package/src/components/app-sidebar/app-sidebar.css +90 -17
  47. package/src/components/app-sidebar/app-sidebar.js +120 -12
  48. package/src/components/approval-card/approval-card.css +289 -0
  49. package/src/components/approval-card/approval-card.js +1377 -0
  50. package/src/components/avatar/avatar.css +56 -1
  51. package/src/components/avatar/avatar.js +148 -26
  52. package/src/components/badge/badge.css +33 -20
  53. package/src/components/badge/badge.js +5 -4
  54. package/src/components/block-view/block-view.css +300 -0
  55. package/src/components/block-view/block-view.js +523 -0
  56. package/src/components/breadcrumb/breadcrumb.css +28 -3
  57. package/src/components/breadcrumb/breadcrumb.js +2 -2
  58. package/src/components/button/button.css +24 -13
  59. package/src/components/button/button.js +20 -2
  60. package/src/components/calendar/calendar.css +14 -4
  61. package/src/components/card-view/card-view.js +2 -2
  62. package/src/components/chart/chart.js +20 -5
  63. package/src/components/check-button/check-button.css +11 -3
  64. package/src/components/check-button/check-button.js +3 -3
  65. package/src/components/composer/composer.css +403 -0
  66. package/src/components/composer/composer.js +1441 -0
  67. package/src/components/context-menu/context-menu.css +7 -1
  68. package/src/components/date-picker/date-picker.css +6 -0
  69. package/src/components/date-picker/date-picker.js +5 -5
  70. package/src/components/date-picker/date-range-picker.css +6 -0
  71. package/src/components/date-picker/date-range-picker.js +3 -3
  72. package/src/components/date-picker/month-picker.js +3 -3
  73. package/src/components/date-picker/time-picker.css +6 -0
  74. package/src/components/datebox/date-range-box.js +30 -6
  75. package/src/components/datebox/datebox.js +44 -7
  76. package/src/components/dialog/dialog.css +0 -1
  77. package/src/components/dialog/dialog.js +2 -1
  78. package/src/components/dock/dock.js +2 -2
  79. package/src/components/dropdown/dropdown.css +2 -1
  80. package/src/components/entity-ref/entity-ref.css +8 -1
  81. package/src/components/file-item/file-item.css +1 -1
  82. package/src/components/finder/finder.js +2 -2
  83. package/src/components/groupbox/groupbox.js +2 -2
  84. package/src/components/kanban-view/kanban-view.css +8 -4
  85. package/src/components/kanban-view/kanban-view.js +3 -3
  86. package/src/components/kbd/kbd.css +64 -0
  87. package/src/components/kbd/kbd.js +121 -0
  88. package/src/components/launcher/launcher.css +30 -25
  89. package/src/components/launcher/launcher.js +15 -21
  90. package/src/components/list-toolbar/list-toolbar.css +7 -1
  91. package/src/components/menu-button/menu-button.css +9 -2
  92. package/src/components/message/message.js +2 -2
  93. package/src/components/module-bar/module-bar.css +11 -1
  94. package/src/components/multi-value-editor/multi-value-editor.js +4 -4
  95. package/src/components/navigation-bar/navigation-bar.css +3 -2
  96. package/src/components/pagination/pagination.js +2 -2
  97. package/src/components/panel/panel.js +2 -2
  98. package/src/components/prose/prose.css +53 -0
  99. package/src/components/prose/prose.js +152 -0
  100. package/src/components/questionnaire/questionnaire.css +7 -17
  101. package/src/components/questionnaire/questionnaire.js +16 -1
  102. package/src/components/rating/rating.css +3 -1
  103. package/src/components/run-status/run-status.css +208 -0
  104. package/src/components/run-status/run-status.js +782 -0
  105. package/src/components/run-trace/run-trace.css +443 -0
  106. package/src/components/run-trace/run-trace.js +1209 -0
  107. package/src/components/search/search.js +2 -2
  108. package/src/components/select/glyphs.js +3 -3
  109. package/src/components/select/select.css +35 -7
  110. package/src/components/select/select.js +4 -4
  111. package/src/components/source-list/source-list.css +208 -0
  112. package/src/components/source-list/source-list.js +355 -0
  113. package/src/components/stat-tile/stat-tile.css +56 -2
  114. package/src/components/stat-tile/stat-tile.js +25 -2
  115. package/src/components/stepper/stepper.css +2 -1
  116. package/src/components/stepper/stepper.js +3 -3
  117. package/src/components/tabbox/tabbox.css +2 -2
  118. package/src/components/tabbox/tabbox.js +2 -2
  119. package/src/components/table/table.css +52 -16
  120. package/src/components/table/table.js +7 -5
  121. package/src/components/tag-picker/tag-picker.css +56 -43
  122. package/src/components/tag-picker/tag-picker.js +21 -16
  123. package/src/components/tree/tree.css +44 -0
  124. package/src/components/tree/tree.js +97 -9
  125. package/src/components/value-list/value-list.css +25 -4
  126. package/src/components/value-list/value-list.js +2 -1
  127. package/src/components/view/record-view.js +3 -3
  128. package/src/components/view-settings/view-settings.css +2 -1
  129. package/src/components/workspace-switcher/workspace-switcher.js +3 -3
  130. package/src/core/icons.js +34 -3
  131. package/src/core/messages.js +143 -0
  132. package/src/elements/define.js +1 -0
  133. package/src/index.js +12 -2
  134. package/src/internal/agent-model.js +488 -0
  135. package/src/internal/app-rail.js +5 -1
  136. package/src/internal/highlight.js +104 -0
  137. package/src/internal/presence-loop.js +343 -0
  138. package/src/internal/row-actions.js +203 -0
  139. package/styles/base.css +26 -1
  140. package/styles/prose.css +306 -0
  141. package/styles/tokens/dark.css +97 -120
  142. package/styles/tokens/global.css +24 -9
  143. package/styles/tokens/semantic.css +464 -184
  144. package/styles/tokens/themes.css +9 -0
  145. package/styles/zx.css +10 -0
@@ -47,7 +47,8 @@
47
47
 
48
48
  .zx-avatar__image[hidden],
49
49
  .zx-avatar__fallback[hidden],
50
- .zx-avatar__status[hidden] {
50
+ .zx-avatar__status[hidden],
51
+ .zx-avatar__activity[hidden] {
51
52
  display: none;
52
53
  }
53
54
 
@@ -80,7 +81,61 @@
80
81
  .zx-avatar__status[data-status="away"] { background: var(--zx-color-warning); }
81
82
  .zx-avatar__status[data-status="busy"] { background: var(--zx-color-danger); }
82
83
 
84
+ /*
85
+ * An agent's activity. Each one is a shape as well as a tone, so it reads where the colour does
86
+ * not: a solid dot for working, thinking and needs-you, a square for blocked, a hollow ring for
87
+ * idle, and a dashed ring for offline. The outline cuts the dot out of the avatar it sits on.
88
+ */
89
+ .zx-avatar__activity {
90
+ position: absolute;
91
+ inset-inline-end: 0;
92
+ inset-block-end: 0;
93
+ box-sizing: border-box;
94
+ inline-size: max(8px, calc(var(--zx-avatar-size) * .3));
95
+ block-size: max(8px, calc(var(--zx-avatar-size) * .3));
96
+ border-radius: 50%;
97
+ outline: 2px solid var(--zx-color-bg-raised);
98
+ background: var(--zx-color-text-muted);
99
+ }
100
+
101
+ .zx-avatar[data-activity="working"] > .zx-avatar__activity { background: var(--zx-color-success); }
102
+ .zx-avatar[data-activity="thinking"] > .zx-avatar__activity { background: var(--zx-color-info); }
103
+ .zx-avatar[data-activity="needs-you"] > .zx-avatar__activity { background: var(--zx-color-warning); }
104
+
105
+ /* A square, whatever the theme's radius: the shape is the signal. */
106
+ .zx-avatar[data-activity="blocked"] > .zx-avatar__activity {
107
+ border-radius: 15%;
108
+ background: var(--zx-color-danger);
109
+ }
110
+
111
+ .zx-avatar[data-activity="idle"] > .zx-avatar__activity {
112
+ border: 1.5px solid var(--zx-color-text-muted);
113
+ background: var(--zx-color-bg-raised);
114
+ }
115
+
116
+ .zx-avatar[data-activity="offline"] > .zx-avatar__activity {
117
+ border: 1.5px dashed var(--zx-color-text-subtle);
118
+ background: var(--zx-color-bg-raised);
119
+ }
120
+
121
+ /* An animated avatar pivots low, the way a head nods; the shared loop writes only `transform`. */
122
+ .zx-avatar[data-animate] {
123
+ transform-origin: 50% 75%;
124
+ }
125
+
126
+ @media (prefers-reduced-motion: no-preference) {
127
+ .zx-avatar[data-animate] {
128
+ will-change: transform;
129
+ }
130
+ }
131
+
83
132
  /* Forced colours drop the tint; a system-coloured edge keeps the fallback a shape. */
84
133
  @media (forced-colors: active) {
85
134
  .zx-avatar__fallback { border: 1px solid CanvasText; }
135
+ .zx-avatar[data-activity] > .zx-avatar__activity { background: CanvasText; }
136
+
137
+ .zx-avatar:is([data-activity="idle"], [data-activity="offline"]) > .zx-avatar__activity {
138
+ border-color: CanvasText;
139
+ background: Canvas;
140
+ }
86
141
  }
@@ -1,11 +1,16 @@
1
+ // @ts-check
1
2
  import { Component } from '../../core/component.js';
2
3
  import { h } from '../../core/dom.js';
4
+ import { ACTIVITY, AGENT_MESSAGES, normalizeActivity } from '../../internal/agent-model.js';
5
+ import { normalizePhase, presencePhase, trackPresence } from '../../internal/presence-loop.js';
3
6
 
4
7
  /**
5
8
  * A categorical tone from the design system's tone palette (`--zx-color-tone-*`).
6
9
  * @typedef {'blue'|'teal'|'green'|'amber'|'orange'|'red'|'pink'|'violet'|'slate'} AvatarTone
7
10
  */
8
11
 
12
+ /** @typedef {import('../../internal/agent-model.js').AgentActivity} AgentActivity */
13
+
9
14
  /**
10
15
  * @typedef {Object} AvatarOptions
11
16
  * @property {string|null} [src=null] Image URL.
@@ -18,8 +23,28 @@ import { h } from '../../core/dom.js';
18
23
  * @property {AvatarTone|null} [tone=null] Fallback colour from the tone palette. `null` derives a
19
24
  * stable tone from the name (or the initials when there is no name), so the same person gets the
20
25
  * same colour on every screen; see {@link avatarTone}.
21
- * @property {'online'|'away'|'busy'|'offline'|null} [status=null] Optional presence state.
26
+ * @property {'online'|'away'|'busy'|'offline'|null} [status=null] Optional presence state of a
27
+ * person. An agent's `activity` takes its place: when both are given, only the activity is drawn
28
+ * and named.
22
29
  * @property {string|null} [statusLabel=null] Text alternative for the presence state.
30
+ * @property {AgentActivity|null} [activity=null] What an agent is doing: `'idle'`, `'thinking'`,
31
+ * `'working'`, `'needs-you'`, `'blocked'` or `'offline'`. Drawn as a dot whose shape and tone
32
+ * differ per activity (a square for blocked, a hollow ring for idle, a dashed ring for offline);
33
+ * its word joins the accessible name and the dot's tooltip. Wins over `status`.
34
+ * @property {string|null} [activityLabel=null] The activity's word, when the default ("Working",
35
+ * "Needs you", …) is not the one to show.
36
+ * @property {boolean} [animate=false] Moves the avatar with its activity — idle breathes, thinking
37
+ * sways, working bobs, needs-you leans and blinks — in the one animation loop every animated
38
+ * avatar on the page shares. Motion is never the only signal, stops off screen and while the page
39
+ * is hidden, and returns the avatar to rest under reduced motion (the system's, or a
40
+ * `data-zx-motion="reduced"` region). While it is on, the root's `transform` belongs to the loop.
41
+ * @property {number|null} [phase=null] Where in its activity's cycle the avatar moves, as a
42
+ * fraction from 0 up to 1 (whole turns wrap): two avatars of the same agent on one screen — a
43
+ * roster and an inspector — at different phases never move in step, and 0.5 puts them half a cycle
44
+ * apart. `null` derives the phase from the name (or the initials), so the same agent always moves
45
+ * the same way.
46
+ * @property {Record<string, string>|Record<string, Record<string, string>>} [msg] Localized
47
+ * messages: the activity words, `agent.activity.<activity>`.
23
48
  */
24
49
 
25
50
  /**
@@ -36,9 +61,16 @@ const HASHED_TONES = Object.freeze(AVATAR_TONES.filter((tone) => tone !== 'slate
36
61
  /** Below this rendered size the fallback has room for one initial, not two. */
37
62
  const SINGLE_INITIAL_BELOW = 24;
38
63
 
64
+ /** The presence states a person can have. */
65
+ const PRESENCE = Object.freeze(['online', 'away', 'busy', 'offline']);
66
+
67
+ /** The values `set()` accepts. */
68
+ const SETTABLE = Object.freeze(['src', 'name', 'initials', 'label', 'size', 'shape', 'tone', 'status', 'statusLabel',
69
+ 'activity', 'activityLabel', 'animate', 'phase']);
70
+
39
71
  /**
40
72
  * Stable-size user image with a deterministic fallback — initials on a tone picked from the name —
41
- * and an optional presence state.
73
+ * and an optional presence state for a person, or activity for an agent.
42
74
  * @extends {Component<AvatarOptions>}
43
75
  */
44
76
  export class Avatar extends Component {
@@ -54,7 +86,12 @@ export class Avatar extends Component {
54
86
  shape: 'circle',
55
87
  tone: null,
56
88
  status: null,
57
- statusLabel: null
89
+ statusLabel: null,
90
+ activity: null,
91
+ activityLabel: null,
92
+ animate: false,
93
+ phase: null,
94
+ msg: AGENT_MESSAGES
58
95
  };
59
96
 
60
97
  /** @returns {HTMLElement} */
@@ -75,8 +112,14 @@ export class Avatar extends Component {
75
112
  shape: this.options.shape,
76
113
  tone: this.options.tone,
77
114
  status: this.options.status,
78
- statusLabel: this.options.statusLabel
115
+ statusLabel: this.options.statusLabel,
116
+ activity: this.options.activity ?? null,
117
+ activityLabel: this.options.activityLabel ?? null,
118
+ animate: Boolean(this.options.animate),
119
+ phase: this.options.phase ?? null
79
120
  };
121
+ /** @type {import('../../internal/presence-loop.js').PresenceHandle|null} */
122
+ this._presence = null;
80
123
 
81
124
  const image = /** @type {HTMLImageElement} */ (h('img', {
82
125
  ref: 'image',
@@ -95,7 +138,13 @@ export class Avatar extends Component {
95
138
  ariaHidden: 'true',
96
139
  hidden: true
97
140
  });
98
- root.replaceChildren(image, fallback, status);
141
+ const activity = h('span', {
142
+ ref: 'activity',
143
+ class: 'zx-avatar__activity',
144
+ ariaHidden: 'true',
145
+ hidden: true
146
+ });
147
+ root.replaceChildren(image, fallback, status, activity);
99
148
  this.listen(image, 'load', () => {
100
149
  if (this._isCurrentImageSource()) this._showImage(true);
101
150
  });
@@ -107,14 +156,15 @@ export class Avatar extends Component {
107
156
  }
108
157
 
109
158
  /**
110
- * Replaces avatar identity and presentation values.
159
+ * Replaces avatar identity and presentation values: any option but `msg`, `phase` included, so
160
+ * an animated avatar can be moved out of step with another of the same agent while it runs.
111
161
  * @param {Partial<AvatarOptions>} values New values.
112
162
  * @returns {this}
113
163
  */
114
164
  set(values = {}) {
115
165
  if (!values || typeof values !== 'object') return this;
116
- for (const key of ['src', 'name', 'initials', 'label', 'size', 'shape', 'tone', 'status', 'statusLabel']) {
117
- if (Object.hasOwn(values, key)) this._state[key] = values[key];
166
+ for (const key of SETTABLE) {
167
+ if (Object.hasOwn(values, key)) this._state[key] = key === 'animate' ? Boolean(values[key]) : values[key];
118
168
  }
119
169
  this._sync();
120
170
  return this;
@@ -129,14 +179,36 @@ export class Avatar extends Component {
129
179
  return this;
130
180
  }
131
181
 
182
+ /**
183
+ * Sets what an agent is doing and, optionally, the word for it. `null` clears the activity, and
184
+ * a person's `status` shows again if one is set.
185
+ * @param {AgentActivity|null} activity
186
+ * @param {string|null} [label=null] The word, when the default is not the one to show.
187
+ * @returns {this}
188
+ */
189
+ setActivity(activity, label = null) {
190
+ this._state.activity = activity;
191
+ this._state.activityLabel = label;
192
+ this._syncLabel();
193
+ this._syncStatus();
194
+ return this;
195
+ }
196
+
197
+ /** @returns {AgentActivity|null} What the agent is doing, or null. */
198
+ getActivity() {
199
+ return normalizeActivity(this._state.activity);
200
+ }
201
+
132
202
  /** Returns whether the image is currently visible. @returns {boolean} */
133
203
  hasImage() {
134
- return !this.refs.image.hidden;
204
+ return !(/** @type {HTMLElement} */ (this.refs.image)).hidden;
135
205
  }
136
206
 
137
207
  /** Restores an enhanced target or removes an owned root. @returns {void} */
138
208
  destroy() {
139
209
  const original = this._original;
210
+ this._presence?.untrack();
211
+ this._presence = null;
140
212
  super.destroy();
141
213
  if (!this._createdRoot && original) {
142
214
  for (const attribute of Array.from(this.el.attributes)) this.el.removeAttribute(attribute.name);
@@ -147,13 +219,14 @@ export class Avatar extends Component {
147
219
 
148
220
  /** @returns {void} */
149
221
  _sync() {
150
- const { size, shape, label } = this._state;
151
- this.el.dataset.size = typeof size === 'string' ? size : 'custom';
152
- this.el.dataset.shape = ['circle', 'rounded', 'square'].includes(shape) ? shape : 'circle';
222
+ const root = /** @type {HTMLElement} */ (this.el);
223
+ const { size, shape } = this._state;
224
+ root.dataset.size = typeof size === 'string' ? size : 'custom';
225
+ root.dataset.shape = ['circle', 'rounded', 'square'].includes(shape) ? shape : 'circle';
153
226
  if (typeof size === 'number' && Number.isFinite(size)) {
154
- this.el.style.setProperty('--zx-avatar-size', `${Math.max(1, size)}px`);
227
+ root.style.setProperty('--zx-avatar-size', `${Math.max(1, size)}px`);
155
228
  } else {
156
- this.el.style.removeProperty('--zx-avatar-size');
229
+ root.style.removeProperty('--zx-avatar-size');
157
230
  }
158
231
  this._syncLabel();
159
232
  const name = String(this._state.name ?? '');
@@ -164,7 +237,7 @@ export class Avatar extends Component {
164
237
  const tone = AVATAR_TONES.includes(this._state.tone)
165
238
  ? this._state.tone
166
239
  : avatarTone(name.trim() ? name : this._state.initials);
167
- this.el.dataset.tone = tone;
240
+ root.dataset.tone = tone;
168
241
  const src = this._state.src == null ? '' : String(this._state.src).trim();
169
242
  if (src) {
170
243
  this.refs.image.setAttribute('src', src);
@@ -182,7 +255,8 @@ export class Avatar extends Component {
182
255
  _syncLabel() {
183
256
  const { label, status, statusLabel } = this._state;
184
257
  if (label) {
185
- const presence = ['online', 'away', 'busy', 'offline'].includes(status) ? statusLabel : null;
258
+ const word = this._activityWord();
259
+ const presence = word ?? (PRESENCE.includes(status) ? statusLabel : null);
186
260
  this.el.setAttribute('role', 'img');
187
261
  this.el.setAttribute('aria-label', [label, presence].filter(Boolean).join(', '));
188
262
  this.el.removeAttribute('aria-hidden');
@@ -195,9 +269,9 @@ export class Avatar extends Component {
195
269
 
196
270
  /** @param {boolean} visible @returns {void} */
197
271
  _showImage(visible) {
198
- this.refs.image.hidden = !visible;
199
- this.refs.fallback.hidden = visible;
200
- this.el.dataset.fallback = String(!visible);
272
+ (/** @type {HTMLElement} */ (this.refs.image)).hidden = !visible;
273
+ (/** @type {HTMLElement} */ (this.refs.fallback)).hidden = visible;
274
+ (/** @type {HTMLElement} */ (this.el)).dataset.fallback = String(!visible);
201
275
  }
202
276
 
203
277
  /** Ignores a late load/error from a source that has already been replaced. @returns {boolean} */
@@ -212,20 +286,68 @@ export class Avatar extends Component {
212
286
  }
213
287
  }
214
288
 
289
+ /** The word for the current activity, or null without one. @returns {string|null} */
290
+ _activityWord() {
291
+ const activity = normalizeActivity(this._state.activity);
292
+ if (!activity) return null;
293
+ return this._state.activityLabel ? String(this._state.activityLabel) : this.msg(ACTIVITY[activity].key);
294
+ }
295
+
215
296
  /** @returns {void} */
216
297
  _syncStatus() {
217
- const allowed = ['online', 'away', 'busy', 'offline'];
218
- const status = allowed.includes(this._state.status) ? this._state.status : null;
219
- this.refs.status.hidden = status === null;
220
- if (status) this.refs.status.dataset.status = status;
221
- else delete this.refs.status.dataset.status;
298
+ const root = /** @type {HTMLElement} */ (this.el);
299
+ const activity = normalizeActivity(this._state.activity);
300
+ const dot = /** @type {HTMLElement} */ (this.refs.activity);
301
+ dot.hidden = activity === null;
302
+ if (activity) {
303
+ root.dataset.activity = activity;
304
+ dot.setAttribute('title', String(this._activityWord()));
305
+ } else {
306
+ delete root.dataset.activity;
307
+ dot.removeAttribute('title');
308
+ }
309
+ this._syncMotion(activity);
310
+ const status = !activity && PRESENCE.includes(this._state.status) ? this._state.status : null;
311
+ const presence = /** @type {HTMLElement} */ (this.refs.status);
312
+ presence.hidden = status === null;
313
+ if (status) presence.dataset.status = status;
314
+ else delete presence.dataset.status;
222
315
  const label = this._state.statusLabel;
223
316
  if (label) {
224
- this.refs.status.setAttribute('title', String(label));
317
+ presence.setAttribute('title', String(label));
225
318
  } else {
226
- this.refs.status.removeAttribute('title');
319
+ presence.removeAttribute('title');
227
320
  }
228
321
  }
322
+
323
+ /**
324
+ * Joins, follows, or leaves the shared presence loop.
325
+ * @param {AgentActivity|null} activity
326
+ * @returns {void}
327
+ */
328
+ _syncMotion(activity) {
329
+ const root = /** @type {HTMLElement} */ (this.el);
330
+ const animate = Boolean(this._state.animate) && activity !== null;
331
+ if (animate) root.dataset.animate = '';
332
+ else delete root.dataset.animate;
333
+ if (!animate) {
334
+ this._presence?.untrack();
335
+ this._presence = null;
336
+ } else if (this._presence) {
337
+ this._presence.set(activity, { phase: this._phase() });
338
+ } else {
339
+ this._presence = trackPresence(root, activity, { phase: this._phase() });
340
+ }
341
+ }
342
+
343
+ /**
344
+ * The phase the avatar moves at: the `phase` option, or one derived from the name or initials.
345
+ * @returns {number} A fraction of the cycle.
346
+ */
347
+ _phase() {
348
+ const key = String(this._state.name ?? '') || String(this._state.initials ?? '');
349
+ return normalizePhase(this._state.phase) ?? presencePhase(key);
350
+ }
229
351
  }
230
352
 
231
353
  /**
@@ -1,23 +1,32 @@
1
1
  /*
2
+ * One chip, two shapes. A status — how something is doing — is a pill; a tag — what something is,
3
+ * a `tone` — is a small rectangle (below). Both are one fill and no line, 12px at weight 500 at
4
+ * either size, and as tall as the row they sit in allows: five ninths of `--zx-row-height` (20px
5
+ * in the default 36px row), never below a line of their own text and never above two, so a chip
6
+ * follows the row height setting without making a row taller.
7
+ *
2
8
  * The neutral soft fill is a wash of the text colour rather than an opaque step of the surface
3
9
  * scale: it darkens whatever it sits on by the same amount. In the dark theme the muted step is
4
10
  * the raised one, so an opaque muted badge vanished on a raised card, a menu, or a dialog.
5
11
  */
6
12
  .zx-badge {
13
+ --zx-badge-height: clamp(calc(var(--zx-text-xs) * 1.4), calc(var(--zx-row-height) * 5 / 9), calc(var(--zx-text-xs) * 2));
7
14
  display: inline-flex;
8
15
  align-items: center;
9
16
  gap: var(--zx-space-1);
17
+ box-sizing: border-box;
10
18
  max-inline-size: 100%;
19
+ block-size: var(--zx-badge-height);
11
20
  border: 1px solid transparent;
12
21
  border-radius: var(--zx-radius-full);
13
22
  background: color-mix(in srgb, var(--zx-color-text) 7%, transparent);
14
23
  color: var(--zx-color-text-muted);
15
- padding-block: 2px;
24
+ padding-block: 0;
16
25
  padding-inline: var(--zx-space-2);
17
26
  font-size: var(--zx-text-xs);
18
27
  font-weight: var(--zx-weight-medium);
19
28
  font-variant-numeric: tabular-nums;
20
- line-height: 1.35;
29
+ line-height: 1.25;
21
30
  white-space: nowrap;
22
31
  vertical-align: middle;
23
32
  }
@@ -136,10 +145,12 @@
136
145
  * Tone — categorical colour from the tone palette, for what a badge *is* (a project, a label, a
137
146
  * module) rather than how it is doing. Declared after every `kind` rule so a tone wins at equal
138
147
  * specificity: a badge has one colour, and a tone is the more specific request. Soft by default,
139
- * borderless; solid fills with the tone's foreground; outline draws it.
148
+ * borderless; solid fills with the tone's foreground; outline draws it. A toned badge is a tag, so
149
+ * it takes the tag's small corners in every variant.
140
150
  */
141
151
  .zx-badge[data-tone] {
142
152
  border-color: transparent;
153
+ border-radius: var(--zx-radius-md);
143
154
  background: var(--zx-badge-tone-bg);
144
155
  color: var(--zx-badge-tone-fg);
145
156
  }
@@ -165,30 +176,32 @@
165
176
  color: var(--zx-badge-tone-fg);
166
177
  }
167
178
 
179
+ /* Small is shorter and tighter, never smaller type: 12px is the floor for anything read as a word.
180
+ Half the row's height — 18px in the default row. */
168
181
  .zx-badge[data-size="sm"] {
169
- gap: calc(var(--zx-space-1) / 2);
170
- padding-block: 1px;
171
- padding-inline: var(--zx-space-1);
172
- font-size: calc(var(--zx-text-xs) - 1px);
182
+ --zx-badge-height: clamp(calc(var(--zx-text-xs) * 1.4), calc(var(--zx-row-height) / 2), calc(var(--zx-text-xs) * 1.75));
183
+ padding-inline: calc(var(--zx-space-1) * 1.5);
173
184
  }
174
185
 
175
- .zx-badge[data-size="sm"] .zx-badge__dot {
176
- inline-size: 5px;
177
- block-size: 5px;
186
+ /* A status dot sits at the centre of the pill's round end, whatever the height, with a full step
187
+ to the label. */
188
+ .zx-badge:has(> .zx-badge__dot) {
189
+ padding-inline-start: calc(var(--zx-badge-height) / 2 - 4px);
178
190
  }
179
191
 
180
- /* A small badge with a dot keeps the medium badge's text size and a full step between dot and
181
- label: at 11px with a 2px gap the dot ran into the first letter. The label's end gets a little
182
- more room than the dot's start, which the pill's round end would otherwise crowd. */
183
- .zx-badge[data-size="sm"]:has(> .zx-badge__dot) {
184
- gap: var(--zx-space-1);
185
- padding-inline: var(--zx-space-1) calc(var(--zx-space-1) * 1.5);
186
- font-size: var(--zx-text-xs);
192
+ /* Someone who asked for more contrast, or whose colours are forced, gets the chip's edge back:
193
+ a fill alone may not separate it from the surface any more. */
194
+ @media (prefers-contrast: more) {
195
+ .zx-badge:not([data-variant="solid"], [data-variant="outline"]) {
196
+ border-color: var(--zx-color-border-strong);
197
+ }
187
198
  }
188
199
 
189
- .zx-badge[data-size="sm"]:has(> .zx-badge__dot) .zx-badge__dot {
190
- inline-size: 6px;
191
- block-size: 6px;
200
+ @media (forced-colors: active) {
201
+ .zx-badge,
202
+ .zx-badge[data-tone] {
203
+ border-color: CanvasText;
204
+ }
192
205
  }
193
206
 
194
207
  .zx-badge-group {
@@ -13,8 +13,8 @@ import { icon as createIcon } from '../../core/icons.js';
13
13
  * @property {'neutral'|'accent'|'success'|'warning'|'danger'|'info'} [kind='neutral'] Semantic intent.
14
14
  * @property {BadgeTone|null} [tone=null] Categorical colour — a project, a label, a module — from
15
15
  * the tone palette rather than the status set, so a tag never reads as a warning. When set it
16
- * decides the colour and `kind` is ignored for it; `variant` still applies. Unknown names are
17
- * ignored.
16
+ * decides the colour and the shape — a tag's small corners instead of a status pill — and `kind`
17
+ * is ignored for it; `variant` still applies. Unknown names are ignored.
18
18
  * @property {'soft'|'solid'|'outline'} [variant='soft'] Fill treatment.
19
19
  * @property {'md'|'sm'} [size='md'] Badge size.
20
20
  * @property {boolean} [dot=false] Renders a small leading status dot instead of an icon.
@@ -45,8 +45,9 @@ const defaults = Object.freeze({
45
45
  });
46
46
 
47
47
  /**
48
- * Creates a status pill: a small, non-interactive label carrying a semantic colour — or, with
49
- * `tone`, a categorical one.
48
+ * Creates a chip: a small, non-interactive label carrying a semantic colour as a status pill — or,
49
+ * with `tone`, a categorical one as a tag. `TagPicker` builds its tags with it, so a label has one
50
+ * construction wherever it appears.
50
51
  *
51
52
  * The badge is plain text content, so it needs no ARIA of its own. A badge without a label but
52
53
  * with a `title` is named for assistive technology through `role="img"`.