@candor-ui/react 2.2.0 → 2.3.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 (57) hide show
  1. package/dist/adapters/use-ag-ui.d.ts +1 -1
  2. package/dist/adapters/use-candor-chat.d.ts +1 -1
  3. package/dist/adapters/use-claude-agent.d.ts +1 -1
  4. package/dist/blocks/copy-field.js +4 -1
  5. package/dist/blocks/degraded-panel.js +3 -1
  6. package/dist/blocks/locked.js +5 -1
  7. package/dist/blocks/status-dot.d.ts +14 -3
  8. package/dist/blocks/status-dot.js +17 -22
  9. package/dist/blocks/step-list.d.ts +2 -1
  10. package/dist/blocks/step-list.js +19 -27
  11. package/dist/blocks/streaming-text.js +3 -1
  12. package/dist/blocks/surface.d.ts +1 -1
  13. package/dist/chat/attachment-preview.js +5 -2
  14. package/dist/chat/card-registry.js +3 -1
  15. package/dist/chat/citation.js +2 -2
  16. package/dist/chat/composer.js +19 -53
  17. package/dist/chat/context-meter.js +4 -1
  18. package/dist/chat/entity-chip.js +1 -1
  19. package/dist/chat/folded-turns.js +3 -1
  20. package/dist/chat/message-actions.js +5 -2
  21. package/dist/chat/message.js +9 -5
  22. package/dist/chat/payload.js +1 -1
  23. package/dist/chat/permission-prompt.js +6 -1
  24. package/dist/chat/prompt-suggestions.js +4 -1
  25. package/dist/chat/reasoning.js +6 -1
  26. package/dist/chat/thread.js +19 -8
  27. package/dist/chat/tool-call.js +6 -2
  28. package/dist/index.d.ts +8 -0
  29. package/dist/index.js +8 -0
  30. package/dist/lib/motion.d.ts +451 -0
  31. package/dist/lib/motion.js +350 -0
  32. package/dist/styles.css +543 -44
  33. package/dist/ui/accordion.d.ts +23 -0
  34. package/dist/ui/accordion.js +45 -0
  35. package/dist/ui/alert.d.ts +20 -0
  36. package/dist/ui/alert.js +51 -0
  37. package/dist/ui/button.d.ts +1 -1
  38. package/dist/ui/button.js +5 -3
  39. package/dist/ui/checkbox.d.ts +14 -0
  40. package/dist/ui/checkbox.js +32 -0
  41. package/dist/ui/collapsible.d.ts +3 -2
  42. package/dist/ui/collapsible.js +6 -3
  43. package/dist/ui/label.d.ts +10 -0
  44. package/dist/ui/label.js +16 -0
  45. package/dist/ui/popover.d.ts +1 -1
  46. package/dist/ui/popover.js +4 -2
  47. package/dist/ui/progress.d.ts +29 -0
  48. package/dist/ui/progress.js +27 -0
  49. package/dist/ui/skeleton.d.ts +1 -1
  50. package/dist/ui/skeleton.js +5 -2
  51. package/dist/ui/slider.d.ts +28 -0
  52. package/dist/ui/slider.js +41 -0
  53. package/dist/ui/switch.d.ts +14 -0
  54. package/dist/ui/switch.js +23 -0
  55. package/dist/ui/tooltip.d.ts +1 -1
  56. package/dist/ui/tooltip.js +4 -2
  57. package/package.json +1 -1
@@ -0,0 +1,451 @@
1
+ import * as React from "react";
2
+ import type { RunStatus } from "./status.js";
3
+ /**
4
+ * Candor's motion layer, the part that runs in components. Motion is organised by fourteen families, one per kind of
5
+ * change; each component moment (copy-field's tick, the dialog opening) belongs to one family and can be tuned on its
6
+ * own by a brand file. The rule the layer keeps: **a theme tunes how a change looks, never when it happens**. The
7
+ * trigger stays in the component (a class added at an honest moment); this file only builds the chain of CSS
8
+ * variables the family utility in `candor.css` reads, and the two hooks that decide "seen settling" and "arrived after
9
+ * the first draw".
10
+ *
11
+ * Precedence, highest first: the OS's reduced-motion setting (the calm level), then the app's `data-motion`
12
+ * (`none`, `calm`, `subtle`, `expressive`), then the brand file's `--cd-motion-*` values, then the defaults below.
13
+ *
14
+ * `motion()` is pure and safe to call at module level, so server components can use it; the hooks need a client
15
+ * component.
16
+ */
17
+ /** The fourteen families: one per kind of change a person can see. */
18
+ export type MotionFamily = "reveal" | "arrive" | "pop" | "mark" | "fill" | "value" | "move" | "overlay" | "press" | "tint" | "refuse" | "attention" | "live" | "clock";
19
+ /** A motion level: 0 off (the end state appears, events still fire), 1 subtle, 2 expressive. */
20
+ export type MotionLevel = 0 | 1 | 2;
21
+ /** The easings a family may allow. Spring overshoots, so only spatial families accept it. */
22
+ export type MotionEase = "standard" | "inout" | "spring" | "linear";
23
+ /** The CSS each easing name stands for, as a brand file writes it. */
24
+ export declare const motionEases: Readonly<Record<MotionEase, string>>;
25
+ /** A family's amplitude: what its expressive level moves by. */
26
+ export type MotionAmplitude = {
27
+ /** The token suffix: `--cd-motion-<family>-<name>`. */
28
+ readonly name: "distance" | "scale" | "count";
29
+ /** The value at the expressive level, as CSS. */
30
+ readonly default: string;
31
+ /** The lowest value `theme check` accepts. */
32
+ readonly min: number;
33
+ /** The highest value `theme check` accepts. */
34
+ readonly max: number;
35
+ /** The unit `min` and `max` are in ("" for a plain number). */
36
+ readonly unit: "px" | "" | "%";
37
+ /** How much of the amplitude the subtle level uses: 0 none, 1 all of it. */
38
+ readonly subtle: number;
39
+ };
40
+ /** A duration with the range `theme check` accepts, in milliseconds. */
41
+ export type MotionDuration = {
42
+ readonly default: number;
43
+ readonly min: number;
44
+ readonly max: number;
45
+ };
46
+ /** Everything Candor knows about one family. `check:motion` checks `candor.css` against these. */
47
+ export type MotionFamilySpec = {
48
+ /** What the family reports, in words, for the docs and the theme builder. */
49
+ readonly reports: string;
50
+ /** Moves things in space (scale, translate, size). Spring easing is accepted only here. */
51
+ readonly spatial: boolean;
52
+ /** The information itself (a hold, a deadline): a brand can't turn it below subtle. */
53
+ readonly essential: boolean;
54
+ /** How long one play takes; `null` when the clock decides. */
55
+ readonly dur: MotionDuration | null;
56
+ /** How long leaving takes, for families with an out moment (`-out-dur`). */
57
+ readonly outDur: MotionDuration | null;
58
+ /** The easing used when nothing sets one. */
59
+ readonly ease: MotionEase;
60
+ /** The easings a brand may choose. */
61
+ readonly eases: readonly MotionEase[];
62
+ /** The amplitude token, when the family has one. */
63
+ readonly amp: MotionAmplitude | null;
64
+ /** The closed set of variants: how the change is drawn, never when. The first is the default. */
65
+ readonly variants: readonly [string, ...string[]];
66
+ /** What the calm level (reduced motion) does with it, in words. */
67
+ readonly calm: string;
68
+ };
69
+ /** The family defaults. Durations, easings and amplitudes are 2.2's, so an app with no brand file looks the same. */
70
+ export declare const motionFamilies: {
71
+ readonly reveal: {
72
+ readonly reports: "Content opened or closed to its measured size; a chevron turns.";
73
+ readonly spatial: true;
74
+ readonly essential: false;
75
+ readonly dur: {
76
+ readonly default: 200;
77
+ readonly min: 150;
78
+ readonly max: 300;
79
+ };
80
+ readonly outDur: null;
81
+ readonly ease: "standard";
82
+ readonly eases: readonly ["standard", "inout"];
83
+ readonly amp: null;
84
+ readonly variants: readonly ["size", "fade"];
85
+ readonly calm: "Snaps to its measured size.";
86
+ };
87
+ readonly arrive: {
88
+ readonly reports: "Something new, added after the first draw.";
89
+ readonly spatial: true;
90
+ readonly essential: false;
91
+ readonly dur: {
92
+ readonly default: 240;
93
+ readonly min: 150;
94
+ readonly max: 300;
95
+ };
96
+ readonly outDur: null;
97
+ readonly ease: "standard";
98
+ readonly eases: readonly ["standard", "spring"];
99
+ readonly amp: {
100
+ readonly name: "distance";
101
+ readonly default: "8px";
102
+ readonly min: 0;
103
+ readonly max: 16;
104
+ readonly unit: "px";
105
+ readonly subtle: 0.5;
106
+ };
107
+ readonly variants: readonly ["rise", "fade", "pop"];
108
+ readonly calm: "Fades in, up to 150 ms.";
109
+ };
110
+ readonly pop: {
111
+ readonly reports: "Added, removed, or a small mark appearing.";
112
+ readonly spatial: true;
113
+ readonly essential: false;
114
+ readonly dur: {
115
+ readonly default: 200;
116
+ readonly min: 100;
117
+ readonly max: 300;
118
+ };
119
+ readonly outDur: {
120
+ readonly default: 120;
121
+ readonly min: 80;
122
+ readonly max: 300;
123
+ };
124
+ readonly ease: "standard";
125
+ readonly eases: readonly ["standard", "spring"];
126
+ readonly amp: {
127
+ readonly name: "scale";
128
+ readonly default: "0.85";
129
+ readonly min: 0.8;
130
+ readonly max: 1;
131
+ readonly unit: "";
132
+ readonly subtle: 0;
133
+ };
134
+ readonly variants: readonly ["scale", "fade"];
135
+ readonly calm: "Fades, up to 150 ms.";
136
+ };
137
+ readonly mark: {
138
+ readonly reports: "A tick or cross drawn when a result settles.";
139
+ readonly spatial: true;
140
+ readonly essential: false;
141
+ readonly dur: {
142
+ readonly default: 360;
143
+ readonly min: 200;
144
+ readonly max: 500;
145
+ };
146
+ readonly outDur: null;
147
+ readonly ease: "standard";
148
+ readonly eases: readonly ["standard"];
149
+ readonly amp: null;
150
+ readonly variants: readonly ["draw", "pop", "drop"];
151
+ readonly calm: "The finished mark fades in, up to 150 ms.";
152
+ };
153
+ readonly fill: {
154
+ readonly reports: "A bar or ring moving between measured values.";
155
+ readonly spatial: true;
156
+ readonly essential: false;
157
+ readonly dur: {
158
+ readonly default: 360;
159
+ readonly min: 200;
160
+ readonly max: 600;
161
+ };
162
+ readonly outDur: null;
163
+ readonly ease: "standard";
164
+ readonly eases: readonly ["standard", "inout"];
165
+ readonly amp: null;
166
+ readonly variants: readonly ["grow"];
167
+ readonly calm: "Snaps to the new value; its colour may fade.";
168
+ };
169
+ readonly value: {
170
+ readonly reports: "A number or word changed in place.";
171
+ readonly spatial: false;
172
+ readonly essential: false;
173
+ readonly dur: {
174
+ readonly default: 120;
175
+ readonly min: 80;
176
+ readonly max: 200;
177
+ };
178
+ readonly outDur: null;
179
+ readonly ease: "standard";
180
+ readonly eases: readonly ["standard"];
181
+ readonly amp: {
182
+ readonly name: "distance";
183
+ readonly default: "2px";
184
+ readonly min: 0;
185
+ readonly max: 4;
186
+ readonly unit: "px";
187
+ readonly subtle: 0;
188
+ };
189
+ readonly variants: readonly ["fade", "slide"];
190
+ readonly calm: "Crossfades, up to 150 ms.";
191
+ };
192
+ readonly move: {
193
+ readonly reports: "A thing changed place: a reorder, a tab indicator, a toast restacking, a scroll.";
194
+ readonly spatial: true;
195
+ readonly essential: false;
196
+ readonly dur: {
197
+ readonly default: 200;
198
+ readonly min: 150;
199
+ readonly max: 300;
200
+ };
201
+ readonly outDur: null;
202
+ readonly ease: "standard";
203
+ readonly eases: readonly ["standard", "spring"];
204
+ readonly amp: null;
205
+ readonly variants: readonly ["slide"];
206
+ readonly calm: "Jumps to its new place.";
207
+ };
208
+ readonly overlay: {
209
+ readonly reports: "A dialog, sheet, popover, menu or tooltip opened or closed.";
210
+ readonly spatial: true;
211
+ readonly essential: false;
212
+ readonly dur: {
213
+ readonly default: 150;
214
+ readonly min: 100;
215
+ readonly max: 500;
216
+ };
217
+ readonly outDur: {
218
+ readonly default: 150;
219
+ readonly min: 80;
220
+ readonly max: 300;
221
+ };
222
+ readonly ease: "standard";
223
+ readonly eases: readonly ["standard", "inout", "spring"];
224
+ readonly amp: {
225
+ readonly name: "scale";
226
+ readonly default: "0.95";
227
+ readonly min: 0.9;
228
+ readonly max: 1;
229
+ readonly unit: "";
230
+ readonly subtle: 1;
231
+ };
232
+ readonly variants: readonly ["scale", "slide", "fade"];
233
+ readonly calm: "Fades, up to 150 ms.";
234
+ };
235
+ readonly press: {
236
+ readonly reports: "A press registered.";
237
+ readonly spatial: true;
238
+ readonly essential: false;
239
+ readonly dur: {
240
+ readonly default: 150;
241
+ readonly min: 80;
242
+ readonly max: 200;
243
+ };
244
+ readonly outDur: null;
245
+ readonly ease: "standard";
246
+ readonly eases: readonly ["standard"];
247
+ readonly amp: {
248
+ readonly name: "scale";
249
+ readonly default: "0.96";
250
+ readonly min: 0.9;
251
+ readonly max: 1;
252
+ readonly unit: "";
253
+ readonly subtle: 0.5;
254
+ };
255
+ readonly variants: readonly ["scale"];
256
+ readonly calm: "Doesn't scale; the colour still answers.";
257
+ };
258
+ readonly tint: {
259
+ readonly reports: "Hover, focus, selected, a drop target: a colour or opacity change.";
260
+ readonly spatial: false;
261
+ readonly essential: false;
262
+ readonly dur: {
263
+ readonly default: 150;
264
+ readonly min: 0;
265
+ readonly max: 200;
266
+ };
267
+ readonly outDur: null;
268
+ readonly ease: "standard";
269
+ readonly eases: readonly ["standard", "inout"];
270
+ readonly amp: null;
271
+ readonly variants: readonly ["fade"];
272
+ readonly calm: "Colour and opacity only, up to 150 ms.";
273
+ };
274
+ readonly refuse: {
275
+ readonly reports: "A locked control was pressed: the reason is shown, and under expressive it shakes.";
276
+ readonly spatial: true;
277
+ readonly essential: false;
278
+ readonly dur: {
279
+ readonly default: 360;
280
+ readonly min: 200;
281
+ readonly max: 500;
282
+ };
283
+ readonly outDur: null;
284
+ readonly ease: "standard";
285
+ readonly eases: readonly ["standard"];
286
+ readonly amp: {
287
+ readonly name: "distance";
288
+ readonly default: "3px";
289
+ readonly min: 0;
290
+ readonly max: 6;
291
+ readonly unit: "px";
292
+ readonly subtle: 0;
293
+ };
294
+ readonly variants: readonly ["shake"];
295
+ readonly calm: "No shake; the reason's colour still changes.";
296
+ };
297
+ readonly attention: {
298
+ readonly reports: "Something new waits on the person: a ring that grows and fades.";
299
+ readonly spatial: false;
300
+ readonly essential: false;
301
+ readonly dur: {
302
+ readonly default: 900;
303
+ readonly min: 600;
304
+ readonly max: 1600;
305
+ };
306
+ readonly outDur: null;
307
+ readonly ease: "standard";
308
+ readonly eases: readonly ["standard"];
309
+ readonly amp: {
310
+ readonly name: "count";
311
+ readonly default: "1";
312
+ readonly min: 1;
313
+ readonly max: 3;
314
+ readonly unit: "";
315
+ readonly subtle: 1;
316
+ };
317
+ readonly variants: readonly ["ring"];
318
+ readonly calm: "One ring that fades without growing, up to 150 ms.";
319
+ };
320
+ readonly live: {
321
+ readonly reports: "Work that is being heard from: a dot's pulse, a caret, a spinner, a shimmer, a skeleton.";
322
+ readonly spatial: false;
323
+ readonly essential: false;
324
+ readonly dur: {
325
+ readonly default: 1600;
326
+ readonly min: 1000;
327
+ readonly max: 3000;
328
+ };
329
+ readonly outDur: null;
330
+ readonly ease: "standard";
331
+ readonly eases: readonly ["standard", "inout", "linear"];
332
+ readonly amp: null;
333
+ readonly variants: readonly ["pulse"];
334
+ readonly calm: "Still, with its word.";
335
+ };
336
+ readonly clock: {
337
+ readonly reports: "Real time passing: a hold, a deadline, a replay. Painted from the clock.";
338
+ readonly spatial: true;
339
+ readonly essential: true;
340
+ readonly dur: null;
341
+ readonly outDur: null;
342
+ readonly ease: "linear";
343
+ readonly eases: readonly ["linear"];
344
+ readonly amp: null;
345
+ readonly variants: readonly ["glide"];
346
+ readonly calm: "Steps instead of gliding; never off.";
347
+ };
348
+ };
349
+ /** The family names, in the order the docs and the theme builder list them. */
350
+ export declare const motionFamilyNames: MotionFamily[];
351
+ /** A family's variants, by name: `MotionVariant<"mark">` is `"draw" | "pop" | "drop"`. */
352
+ export type MotionVariant<F extends MotionFamily> = (typeof motionFamilies)[F]["variants"][number];
353
+ /**
354
+ * The CSS value a variant is written as. CSS can only choose a drawing by keyframe name, so a variant's value is its
355
+ * keyframe's: the word with Candor's prefix, which keeps an app's own `@keyframes rise` from taking over.
356
+ */
357
+ export declare const motionVariantValue: (variant: string) => string;
358
+ /** What a moment may set as its own default, where it differs from its family's. */
359
+ export type MomentDefaults<F extends MotionFamily> = {
360
+ /** The moment's duration, in milliseconds, within its family's range. */
361
+ dur?: number | undefined;
362
+ /** How long leaving takes, for families with an out moment. */
363
+ outDur?: number | undefined;
364
+ /** The moment's easing, from its family's allowed set. */
365
+ ease?: (typeof motionFamilies)[F]["eases"][number] | undefined;
366
+ /** The amplitude at the expressive level, as CSS (`"0.9"`, `"0.25rem"`, `"3"`). */
367
+ amp?: string | undefined;
368
+ /** The moment's variant, from its family's set. */
369
+ variant?: MotionVariant<F> | undefined;
370
+ };
371
+ /** The moment a chain belongs to, kept on the style object (not enumerable, so it never reaches the DOM). */
372
+ export type MotionMoment = {
373
+ readonly item: string;
374
+ readonly moment: string;
375
+ readonly family: MotionFamily;
376
+ };
377
+ declare const momentKey: unique symbol;
378
+ /**
379
+ * A moment's chain: CSS variables to spread into the moving element's `style`. Each resolves the moment's own token,
380
+ * then its family's, then the default, on that element, so a `data-motion` container anywhere above it still applies.
381
+ */
382
+ export type MotionStyle = React.CSSProperties & {
383
+ readonly [momentKey]?: MotionMoment | undefined;
384
+ };
385
+ /**
386
+ * Builds a moment's chain. Call it once at module level and spread the result into the element's `style`, beside the
387
+ * family utility that the component adds at the honest moment:
388
+ *
389
+ * ```tsx
390
+ * const tick = motion("copy-field", "tick", "pop")
391
+ * <Check style={tick} className={cn(copied && "cd-pop")} />
392
+ * ```
393
+ *
394
+ * The brand reaches the moment with `--cd-motion-copy-field-tick` (its level), `-dur`, `-ease`, the family's amplitude
395
+ * suffix and `-variant`; anything it doesn't set falls back to the family (`--cd-motion-pop-*`), then to `defaults`,
396
+ * then to Candor's. Two families on one element compose: `style={{ ...press, ...tint }}`.
397
+ */
398
+ export declare function motion<F extends MotionFamily>(item: string, moment: string, family: F, defaults?: MomentDefaults<F>): MotionStyle;
399
+ /** The moment a chain was built for, or `undefined` for a plain style object. */
400
+ export declare const motionMomentOf: (style: MotionStyle | undefined) => MotionMoment | undefined;
401
+ /** How `useSettled` tells a finished value from an unfinished one; Candor's run statuses when left out. */
402
+ export type SettledTest<T> = {
403
+ /** Reached an outcome worth showing settling (done or failed). */
404
+ settled: (value: T) => boolean;
405
+ /** Over in any way, including ones that don't animate (cancelled, skipped); `settled` when left out. */
406
+ over?: ((value: T) => boolean) | undefined;
407
+ };
408
+ /**
409
+ * How many times `value` reached a settled outcome from an unfinished one while the component was on screen. Zero
410
+ * for something that mounted already settled, so its mark is drawn still: motion reports a change that was seen,
411
+ * never one that happened before the reader arrived. Key the moving element on the count to replay it.
412
+ */
413
+ export declare function useSettled(value: RunStatus): number;
414
+ export declare function useSettled<T>(value: T, test: SettledTest<T>): number;
415
+ /**
416
+ * Which keys were added after the component first drew. Keys present at the first render answer false, so a list
417
+ * that loads with fifty entries draws them still; a key added later answers true until it leaves (and true again if
418
+ * it comes back).
419
+ */
420
+ export declare function useArrived(keys: readonly string[]): (key: string) => boolean;
421
+ /**
422
+ * Items that just left, kept as inert ghosts for the length of their out moment. Each ghost goes when `left(item)` is
423
+ * called (from its `onAnimationEnd`), or after `fallbackMs` when nothing animated. An item that comes back while its
424
+ * ghost is still leaving takes the ghost's place.
425
+ */
426
+ export declare function useLeaving<T>(items: readonly T[], keyOf: (item: T) => string, fallbackMs?: number): {
427
+ leaving: readonly T[];
428
+ left: (item: T) => void;
429
+ };
430
+ /** What the person allows here: everything, the calm level (reduced motion), or nothing. */
431
+ export type MotionMode = "full" | "calm" | "none";
432
+ /**
433
+ * The person's setting where `el` is: `none` under `data-motion="none"`, `calm` under the OS's reduced-motion setting
434
+ * or `data-motion="calm"`, else `full`. `none` or `calm` anywhere above wins (the same reach as the CSS variants), the
435
+ * OS setting can't be raised by the app, and values that aren't Candor's (Radix writes its own `data-motion` on menu
436
+ * panels) are ignored.
437
+ */
438
+ export declare function motionMode(el: Element | null | undefined): MotionMode;
439
+ /**
440
+ * The level a moment resolves to on `el`, read from its computed style: the moment's token, its family's, the preset,
441
+ * then capped by `data-motion`. A page without Candor's CSS reads as subtle.
442
+ */
443
+ export declare function motionLevel(el: Element | null | undefined, moment: MotionMoment | MotionFamily): MotionLevel;
444
+ /**
445
+ * For motion that CSS can't stop (smooth scrolling, the Web Animations API, a bar painted from the clock): a stable
446
+ * function that answers, at the moment of the motion, whether it may play on `ref`'s element. False under
447
+ * `data-motion="none"`, under the calm level (reduced motion), and when the moment's resolved level is 0. Pass the
448
+ * moment's chain from `motion()`, or a family name for the family's level.
449
+ */
450
+ export declare function useMotionAllowed(ref: React.RefObject<Element | null>, moment: MotionStyle | MotionFamily): () => boolean;
451
+ export {};