@fusion.dev/helix-headless 0.241.3 → 0.243.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 (89) hide show
  1. package/api.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/chat/composer/chat-composer.d.ts +8 -1
  4. package/dist/chat/composer/chat-composer.js +15 -1
  5. package/dist/chat/message/chat-message.d.ts +12 -0
  6. package/dist/chat/message/chat-message.js +8 -0
  7. package/dist/chat/root/chat-root.d.ts +9 -0
  8. package/dist/chat/root/chat-root.js +13 -1
  9. package/dist/code-editor/root/code-editor-root.d.ts +1 -0
  10. package/dist/code-editor/root/code-editor-root.js +1 -1
  11. package/dist/column-manager/root/column-manager-root.d.ts +30 -2
  12. package/dist/column-manager/root/column-manager-root.js +73 -9
  13. package/dist/combobox/root/combobox-root.d.ts +8 -1
  14. package/dist/combobox/root/combobox-root.js +19 -2
  15. package/dist/data-table/root/data-table-root.d.ts +34 -6
  16. package/dist/data-table/root/data-table-root.js +42 -7
  17. package/dist/date-input/root/date-input-root.d.ts +8 -1
  18. package/dist/date-input/root/date-input-root.js +19 -2
  19. package/dist/date-picker/root/date-picker-root.d.ts +5 -0
  20. package/dist/date-picker/root/date-picker-root.js +3 -0
  21. package/dist/editor/root/editor-root.d.ts +1 -0
  22. package/dist/editor/root/editor-root.js +1 -1
  23. package/dist/element-events.generated.js +2 -0
  24. package/dist/file-input/root/file-input-root.d.ts +8 -1
  25. package/dist/file-input/root/file-input-root.js +19 -2
  26. package/dist/filter-input/root/filter-input-root.d.ts +8 -1
  27. package/dist/filter-input/root/filter-input-root.js +13 -1
  28. package/dist/find/root/find-root.d.ts +1 -0
  29. package/dist/find/root/find-root.js +4 -4
  30. package/dist/hover-card/index.d.ts +1 -0
  31. package/dist/hover-card/index.js +1 -0
  32. package/dist/hover-card/root/hover-card-root.d.ts +122 -0
  33. package/dist/hover-card/root/hover-card-root.js +185 -0
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.js +2 -0
  36. package/dist/line-chart/root/line-chart-root.d.ts +7 -1
  37. package/dist/line-chart/root/line-chart-root.js +6 -0
  38. package/dist/list/root/list-root.d.ts +12 -1
  39. package/dist/list/root/list-root.js +11 -1
  40. package/dist/log/line/log-line.d.ts +11 -0
  41. package/dist/log/line/log-line.js +8 -0
  42. package/dist/log/root/log-root.d.ts +9 -0
  43. package/dist/log/root/log-root.js +13 -1
  44. package/dist/meter/root/meter-root.d.ts +12 -1
  45. package/dist/meter/root/meter-root.js +31 -2
  46. package/dist/navigation/root/navigation-root.d.ts +5 -1
  47. package/dist/navigation/root/navigation-root.js +13 -1
  48. package/dist/notifications/root/notifications-root.d.ts +10 -1
  49. package/dist/notifications/root/notifications-root.js +12 -1
  50. package/dist/object-inspector/root/object-inspector-root.js +6 -6
  51. package/dist/pagination/root/pagination-root.d.ts +16 -1
  52. package/dist/pagination/root/pagination-root.js +19 -1
  53. package/dist/popover/root/popover-root.d.ts +6 -0
  54. package/dist/popover/root/popover-root.js +2 -0
  55. package/dist/progress/root/progress-root.d.ts +11 -1
  56. package/dist/progress/root/progress-root.js +29 -2
  57. package/dist/sparkline/root/sparkline-root.d.ts +3 -1
  58. package/dist/sparkline/root/sparkline-root.js +8 -1
  59. package/dist/stat/root/stat-root.d.ts +22 -1
  60. package/dist/stat/root/stat-root.js +27 -4
  61. package/dist/table/root/table-root.d.ts +22 -5
  62. package/dist/table/root/table-root.js +13 -1
  63. package/dist/tabs/root/tabs-root.d.ts +6 -1
  64. package/dist/tabs/root/tabs-root.js +12 -1
  65. package/dist/tag/group/tag-group.d.ts +13 -1
  66. package/dist/tag/group/tag-group.js +12 -1
  67. package/dist/terminal/root/terminal-root.d.ts +1 -0
  68. package/dist/terminal/root/terminal-root.js +1 -1
  69. package/dist/theme-toggle/index.d.ts +1 -0
  70. package/dist/theme-toggle/index.js +1 -0
  71. package/dist/theme-toggle/root/theme-toggle-root.d.ts +98 -0
  72. package/dist/theme-toggle/root/theme-toggle-root.js +68 -0
  73. package/dist/time-input/root/time-input-root.d.ts +8 -1
  74. package/dist/time-input/root/time-input-root.js +19 -2
  75. package/dist/timeline/root/timeline-root.d.ts +10 -1
  76. package/dist/timeline/root/timeline-root.js +11 -1
  77. package/dist/toggle/group/toggle-group.d.ts +5 -1
  78. package/dist/toggle/group/toggle-group.js +12 -2
  79. package/dist/tree/root/tree-root.d.ts +13 -1
  80. package/dist/tree/root/tree-root.js +11 -1
  81. package/dist/trend/root/trend-root.d.ts +14 -1
  82. package/dist/trend/root/trend-root.js +20 -2
  83. package/examples.json +1 -1
  84. package/lint.json +1 -1
  85. package/package.json +5 -5
  86. package/types/jsx.d.ts +425 -10
  87. package/types/svelte.d.ts +2 -0
  88. package/types/vue.d.ts +249 -8
  89. package/types/words.d.ts +8 -0
@@ -0,0 +1,68 @@
1
+ import { __decorate } from "tslib";
2
+ import { colorMode, customElement, drawIcon, HelixElement, onColorModeChange, setColorMode, words, } from '@fusion.dev/helix-core';
3
+ import { moon, sun } from '@fusion.dev/helix-icons';
4
+ import { html } from 'lit';
5
+ import { property, state } from 'lit/decorators.js';
6
+ let HelixHeadlessThemeToggle = class HelixHeadlessThemeToggle extends HelixElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.fallbackLabel = 'Dark mode';
10
+ this.label = '';
11
+ this.mode = 'light';
12
+ this.toggle = async () => {
13
+ const box = this.partNamed('button')?.getBoundingClientRect();
14
+ const next = colorMode() === 'dark' ? 'light' : 'dark';
15
+ await setColorMode(next, {
16
+ ...(box ? { from: { x: box.left + box.width / 2, y: box.top + box.height / 2 } } : {}),
17
+ transition: this.transition ?? 'circle',
18
+ });
19
+ this.mode = colorMode();
20
+ this.dispatchEvent(new Event('change', { bubbles: true }));
21
+ };
22
+ }
23
+ static { this.words = 'helix-theme-toggle'; }
24
+ connectedCallback() {
25
+ super.connectedCallback();
26
+ this.mode = colorMode();
27
+ this.unheard ??= onColorModeChange((mode) => {
28
+ this.mode = mode;
29
+ });
30
+ }
31
+ disconnectedCallback() {
32
+ super.disconnectedCallback();
33
+ this.unheard?.();
34
+ this.unheard = undefined;
35
+ }
36
+ updated() {
37
+ this.toggleState('dark', this.mode === 'dark');
38
+ }
39
+ render() {
40
+ return html `<button
41
+ aria-label=${this.label || this.fallbackLabel}
42
+ aria-pressed=${this.mode === 'dark' ? 'true' : 'false'}
43
+ part="button"
44
+ type="button"
45
+ @click=${this.toggle}
46
+ ><span part="icon">${this.renderIcon()}</span><slot></slot></button>`;
47
+ }
48
+ renderIcon() {
49
+ return html `<slot name="icon">${drawIcon(this.mode === 'dark' ? sun : moon)}</slot>`;
50
+ }
51
+ };
52
+ __decorate([
53
+ words,
54
+ property({ attribute: 'fallback-label' })
55
+ ], HelixHeadlessThemeToggle.prototype, "fallbackLabel", void 0);
56
+ __decorate([
57
+ property()
58
+ ], HelixHeadlessThemeToggle.prototype, "label", void 0);
59
+ __decorate([
60
+ property()
61
+ ], HelixHeadlessThemeToggle.prototype, "transition", void 0);
62
+ __decorate([
63
+ state()
64
+ ], HelixHeadlessThemeToggle.prototype, "mode", void 0);
65
+ HelixHeadlessThemeToggle = __decorate([
66
+ customElement('helix-headless-theme-toggle')
67
+ ], HelixHeadlessThemeToggle);
68
+ export { HelixHeadlessThemeToggle };
@@ -1,4 +1,4 @@
1
- import { AriaForwardController, HelixFormElement, type HourCycle } from '@fusion.dev/helix-core';
1
+ import { AriaForwardController, HelixFormElement, type HourCycle, LayoutMotionController } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  import '../../tag/root/index.js';
4
4
  import '../../time-picker/index.js';
@@ -169,6 +169,13 @@ export declare class HelixHeadlessTimeInput extends HelixHeadlessTimeInput_base
169
169
  * `registerWords('de', { 'helix-time-input': { triggerLabel: 'Uhrzeit auswählen' } })`.
170
170
  */
171
171
  static words: string;
172
+ /**
173
+ * Sliding the times chosen to their new places as they come and go: one arriving
174
+ * fades in, one leaving fades where it was, and the rest close up. Timed by
175
+ * `--time-input-move-duration` and `--time-input-move-easing`, which this tier never
176
+ * sets, so it moves nothing until a stylesheet does.
177
+ */
178
+ protected readonly motion: LayoutMotionController;
172
179
  protected readonly aria: AriaForwardController;
173
180
  /**
174
181
  * What the browser may autofill here, as one of the platform's own tokens.
@@ -1,8 +1,9 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, valueAsTime as asTime, clockLocale, customElement, drawIcon, formatWords, timeAsValue as fromTime, HelixClearEvent, HelixFormElement, handedLocale, hostWords, isClockValue, MixinControllerOpen, MixinControllerValue, MixinField, MixinPickerEditing, MixinPickerField, MixinSegmentedField, MixinTokens, numberConverter, readWrittenTime, slottedWords, timeFault, words, wordsLocale, writeClock, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, valueAsTime as asTime, clockLocale, customElement, drawIcon, formatWords, timeAsValue as fromTime, HelixClearEvent, HelixFormElement, handedLocale, hostWords, isClockValue, LayoutMotionController, MixinControllerOpen, MixinControllerValue, MixinField, MixinPickerEditing, MixinPickerField, MixinSegmentedField, MixinTokens, numberConverter, readWrittenTime, slottedWords, timeFault, words, wordsLocale, writeClock, } from '@fusion.dev/helix-core';
3
3
  import { clock, x } from '@fusion.dev/helix-icons';
4
4
  import { nothing } from 'lit';
5
5
  import { property, state } from 'lit/decorators.js';
6
+ import { repeat } from 'lit/directives/repeat.js';
6
7
  import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
7
8
  import { html } from 'lit/static-html.js';
8
9
  import '../../tag/root/index.js';
@@ -10,6 +11,22 @@ import '../../time-picker/index.js';
10
11
  let HelixHeadlessTimeInput = class HelixHeadlessTimeInput extends MixinSegmentedField(MixinPickerEditing(MixinPickerField(MixinControllerOpen(MixinTokens(MixinControllerValue(MixinField(HelixFormElement))))))) {
11
12
  constructor() {
12
13
  super(...arguments);
14
+ this.motion = new LayoutMotionController(this, {
15
+ arriveIntoEmpty: true,
16
+ items: () => [
17
+ ...(this.renderRoot?.querySelectorAll('[part~="time"]:not([data-leaving])') ??
18
+ []),
19
+ ],
20
+ leaving: () => this.partNamed('field'),
21
+ timing: () => {
22
+ const style = getComputedStyle(this);
23
+ return {
24
+ duration: style.getPropertyValue('--time-input-move-duration'),
25
+ easing: style.getPropertyValue('--time-input-move-easing'),
26
+ };
27
+ },
28
+ watch: 'updates',
29
+ });
13
30
  this.aria = new AriaForwardController(this, {
14
31
  target: () => this.partNamed('control') ?? this.segmentGroup,
15
32
  });
@@ -320,7 +337,7 @@ let HelixHeadlessTimeInput = class HelixHeadlessTimeInput extends MixinSegmented
320
337
  <div part="field" @keydown=${this.handleKeydown}>
321
338
  <slot name="start"></slot>
322
339
  ${this.mode === 'multiple'
323
- ? this.renderTokenRow(this.shownTimes.map((at) => this.renderTag(at)), this.restCount)
340
+ ? this.renderTokenRow(repeat(this.shownTimes, (at) => at, (at) => this.renderTag(at)), this.restCount)
324
341
  : nothing}
325
342
  ${this.segmentsShown ? this.renderSegments() : this.renderControl()}
326
343
  <slot name="end"></slot>
@@ -1,4 +1,4 @@
1
- import { HelixElement } from '@fusion.dev/helix-core';
1
+ import { HelixElement, LayoutMotionController } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  /**
4
4
  * @summary A list of events, in the order they happened.
@@ -43,6 +43,9 @@ import { type PropertyValues, type TemplateResult } from 'lit';
43
43
  *
44
44
  * @csspart loading - The entry after the last while `loading` is set.
45
45
  *
46
+ * @cssproperty --timeline-move-duration - How long an entry or a group takes to slide to its new place when one before it arrives or goes, or to fade in. Unset, nothing moves.
47
+ * @cssproperty --timeline-move-easing - The curve an entry slides and fades in along.
48
+ *
46
49
  * @cssstate loading - While `loading` is set.
47
50
  */
48
51
  export declare class HelixHeadlessTimeline extends HelixElement {
@@ -66,6 +69,12 @@ export declare class HelixHeadlessTimeline extends HelixElement {
66
69
  * @deprecated Use `loading-text`. Removed in the next release.
67
70
  */
68
71
  loadingLabel?: string;
72
+ /**
73
+ * Slides the entries and groups to their places when one arrives or goes,
74
+ * and fades in one that arrives, as `List` does, timed from
75
+ * `--timeline-move-duration` and `--timeline-move-easing`.
76
+ */
77
+ protected readonly motion: LayoutMotionController;
69
78
  /** The text of the entry drawn while `loading` is set, where the `loading` slot is empty. */
70
79
  loadingText: string;
71
80
  protected render(): TemplateResult;
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { customElement, HelixElement, hostAria, internalsOf, words } from '@fusion.dev/helix-core';
2
+ import { customElement, HelixElement, hostAria, internalsOf, LayoutMotionController, words, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing } from 'lit';
4
4
  import { property } from 'lit/decorators.js';
5
5
  let HelixHeadlessTimeline = class HelixHeadlessTimeline extends HelixElement {
@@ -7,6 +7,16 @@ let HelixHeadlessTimeline = class HelixHeadlessTimeline extends HelixElement {
7
7
  super(...arguments);
8
8
  this.label = '';
9
9
  this.loading = false;
10
+ this.motion = new LayoutMotionController(this, {
11
+ items: () => [...this.children].filter((child) => child instanceof HTMLElement && child.getAttribute('slot') !== 'loading'),
12
+ timing: () => {
13
+ const style = getComputedStyle(this);
14
+ return {
15
+ duration: style.getPropertyValue('--timeline-move-duration'),
16
+ easing: style.getPropertyValue('--timeline-move-easing'),
17
+ };
18
+ },
19
+ });
10
20
  this.loadingText = 'Loading';
11
21
  }
12
22
  static { this.words = 'helix-timeline'; }
@@ -1,4 +1,4 @@
1
- import { DisabledCascadeController, HelixFormElement, KeyboardNavigationController, UpgradeController } from '@fusion.dev/helix-core';
1
+ import { DisabledCascadeController, HelixFormElement, HoverMarkController, KeyboardNavigationController, UpgradeController } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  declare const HelixHeadlessToggleGroup_base: (new (...args: any[]) => import("@fusion.dev/helix-core").MixinControllerValueInterface) & (new (...args: any[]) => import("@fusion.dev/helix-core").MixinFieldInterface) & typeof HelixFormElement;
4
4
  /**
@@ -63,6 +63,7 @@ declare const HelixHeadlessToggleGroup_base: (new (...args: any[]) => import("@f
63
63
  * @event {Event} input - Fired after the value changes.
64
64
  *
65
65
  * @csspart feedback - The error message under the row.
66
+ * @csspart highlight - The wash under the pointer, which glides from item to item while a mouse or pen moves along them. It carries the item's place and size as the indicator does, `data-placed` while it is over one, and `data-gliding` from the frame after it arrives. Hidden until a stylesheet shows it, so the headless tier lays out as it did without it.
66
67
  * @csspart hint - The help text under the row, shown while there is no error.
67
68
  * @csspart indicator - The moving marker behind the selected item.
68
69
  * @csspart label - The label above the row.
@@ -72,6 +73,7 @@ declare const HelixHeadlessToggleGroup_base: (new (...args: any[]) => import("@f
72
73
  * ships no CSS, so it renders no separate element for the line, which would add
73
74
  * an empty child to your layout.
74
75
  *
76
+ * @cssstate gliding - While a mouse or pen is over an item, so the highlight draws the hover wash in place of each item's own.
75
77
  * @cssstate invalid - The group has an error to show, from the browser's validation or from your `feedback`.
76
78
  */
77
79
  export declare class HelixHeadlessToggleGroup extends HelixHeadlessToggleGroup_base {
@@ -194,6 +196,8 @@ export declare class HelixHeadlessToggleGroup extends HelixHeadlessToggleGroup_b
194
196
  */
195
197
  protected get focusTarget(): HTMLElement | null;
196
198
  private readonly indicator;
199
+ /** Moves the hover wash to whichever item is under the pointer, as segmented `Tabs` does. A disabled item takes none. */
200
+ protected readonly highlight: HoverMarkController;
197
201
  protected readonly keys: KeyboardNavigationController;
198
202
  protected readonly cascade: DisabledCascadeController;
199
203
  /**
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { commaList, customElement, DisabledCascadeController, HelixFormElement, hostAria, IndicatorController, internalsOf, KeyboardNavigationController, MixinControllerValue, MixinField, reportValues, rovingStop, toggleValue, toolbarAround, UpgradeController, } from '@fusion.dev/helix-core';
2
+ import { commaList, customElement, DisabledCascadeController, HelixFormElement, HoverMarkController, hostAria, IndicatorController, internalsOf, KeyboardNavigationController, MixinControllerValue, MixinField, reportValues, rovingStop, toggleValue, toolbarAround, UpgradeController, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing } from 'lit';
4
4
  import { property } from 'lit/decorators.js';
5
5
  import { HelixHeadlessToggle } from '../root/toggle-root.js';
@@ -23,6 +23,16 @@ let HelixHeadlessToggleGroup = class HelixHeadlessToggleGroup extends MixinContr
23
23
  observe: () => this.items,
24
24
  surface: () => this.partNamed('track'),
25
25
  });
26
+ this.highlight = new HoverMarkController(this, {
27
+ gliding: (on) => this.toggleState('gliding', on),
28
+ item: (under) => {
29
+ const items = this.items;
30
+ return under.find((one) => one instanceof HelixHeadlessToggle && items.includes(one) && !one.disabled);
31
+ },
32
+ mark: () => this.partNamed('highlight'),
33
+ observe: () => this.items,
34
+ surface: () => this.partNamed('track'),
35
+ });
26
36
  this.keys = new KeyboardNavigationController(this, {
27
37
  items: () => this.items,
28
38
  selects: () => !this.multiple,
@@ -190,7 +200,7 @@ let HelixHeadlessToggleGroup = class HelixHeadlessToggleGroup extends MixinContr
190
200
  render() {
191
201
  const inside = this.labelPlacement === 'start';
192
202
  const label = this.renderGroupLabel();
193
- return html `${inside ? nothing : label}<div part="row"><slot name="start"></slot><div part="track">${inside ? label : nothing}<div part="indicator" aria-hidden="true"></div><slot @slotchange=${this.handleItems}></slot></div><slot name="end"></slot></div>${this.renderHint()}${this.renderFeedback()}`;
203
+ return html `${inside ? nothing : label}<div part="row"><slot name="start"></slot><div part="track">${inside ? label : nothing}<span part="highlight" aria-hidden="true" hidden></span><div part="indicator" aria-hidden="true"></div><slot @slotchange=${this.handleItems}></slot></div><slot name="end"></slot></div>${this.renderHint()}${this.renderFeedback()}`;
194
204
  }
195
205
  };
196
206
  __decorate([
@@ -1,4 +1,4 @@
1
- import { AriaForwardController, HelixElement, UpgradeController } from '@fusion.dev/helix-core';
1
+ import { AriaForwardController, HelixElement, LayoutMotionController, UpgradeController } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  declare const HelixHeadlessTree_base: (new (...args: any[]) => import("@fusion.dev/helix-core").CollectionElement) & (new (...args: any[]) => import("@fusion.dev/helix-core").MixinControllerActiveInterface) & typeof HelixElement;
4
4
  /**
@@ -71,6 +71,13 @@ declare const HelixHeadlessTree_base: (new (...args: any[]) => import("@fusion.d
71
71
  * holding that branch's items in their new order. The tree says the move with
72
72
  * `moved-into-label`.
73
73
  *
74
+ * **Items slide to their places.** When you move, add, remove or hide items,
75
+ * each one moves from where it was drawn to where it is now, a branch carrying
76
+ * its rows with it, and an item you add fades in. The tree times it from
77
+ * `--tree-move-duration` and `--tree-move-easing`, which the styled tier sets
78
+ * from the duration and easing tokens. Here neither is set, so nothing moves
79
+ * until you set them. Under reduced motion nothing moves, whatever they say.
80
+ *
74
81
  * @since 0.1.0
75
82
  * @status stable
76
83
  * @category navigation
@@ -90,6 +97,9 @@ declare const HelixHeadlessTree_base: (new (...args: any[]) => import("@fusion.d
90
97
  * @csspart live - A copy of the empty and loading messages, and each step of a move in a `reorderable` tree, in a live region that announces them when they change. Visually hidden in the styled tier.
91
98
  * @csspart loading - Shown while the rows load.
92
99
  * @csspart tree - The tree container.
100
+ *
101
+ * @cssproperty --tree-move-duration - How long an item takes to slide to its new place, or to fade in. Unset, nothing moves.
102
+ * @cssproperty --tree-move-easing - The curve an item slides and fades in along.
93
103
  */
94
104
  export declare class HelixHeadlessTree extends HelixHeadlessTree_base {
95
105
  /**
@@ -132,6 +142,8 @@ export declare class HelixHeadlessTree extends HelixHeadlessTree_base {
132
142
  protected readonly aria: AriaForwardController;
133
143
  /** The letters typed so far, for moving to an item by its name. */
134
144
  private readonly typeahead;
145
+ /** Sliding each item to its new place when the page moves, adds, removes or hides items. */
146
+ protected readonly motion: LayoutMotionController;
135
147
  /**
136
148
  * Moving items among their siblings, in a `reorderable` tree. The items are
137
149
  * the page's, so a drop asks the page to move them.
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, auditName, closestInstance, commaList, customElement, deepActiveElement, formatWords, HelixElement, inlineStep, keyClaimed, MixinCollection, MixinControllerActive, ReorderController, requestReorder, scrollItemIntoView, selectsAll, slottedWords, Typeahead, treeArrow, typesCharacter, UpgradeController, whenHydrated, words, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, auditName, closestInstance, commaList, customElement, deepActiveElement, formatWords, HelixElement, inlineStep, keyClaimed, LayoutMotionController, MixinCollection, MixinControllerActive, ReorderController, requestReorder, scrollItemIntoView, selectsAll, slottedWords, Typeahead, treeArrow, typesCharacter, UpgradeController, whenHydrated, words, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing } from 'lit';
4
4
  import { property } from 'lit/decorators.js';
5
5
  import { fromGrip } from '../grip.js';
@@ -28,6 +28,16 @@ let HelixHeadlessTree = class HelixHeadlessTree extends MixinCollection(MixinCon
28
28
  target: () => this.partNamed('tree'),
29
29
  });
30
30
  this.typeahead = new Typeahead();
31
+ this.motion = new LayoutMotionController(this, {
32
+ items: () => this.items,
33
+ timing: () => {
34
+ const style = getComputedStyle(this);
35
+ return {
36
+ duration: style.getPropertyValue('--tree-move-duration'),
37
+ easing: style.getPropertyValue('--tree-move-easing'),
38
+ };
39
+ },
40
+ });
31
41
  this.reorder = new ReorderController(this, {
32
42
  axis: 'block',
33
43
  box: (key) => this.itemFor(key)?.getBoundingClientRect(),
@@ -1,4 +1,4 @@
1
- import { HelixElement } from '@fusion.dev/helix-core';
1
+ import { CountController, HelixElement } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  /**
4
4
  * @summary An indicator that shows which way a measurement moved, and whether the change is good.
@@ -27,6 +27,13 @@ import { type PropertyValues, type TemplateResult } from 'lit';
27
27
  * such as `{"style":"percent"}` for `12%`. `movement` still wins when it is
28
28
  * written. Without `value` the metric is what the page slots.
29
29
  *
30
+ * **A new `value` counts to the new change** from the one before, as Stat's
31
+ * figure does, and a screen reader reads only the new change. The trend times
32
+ * the count from `--trend-count-duration` and `--trend-count-easing`, which
33
+ * the styled tier sets from the duration and easing tokens. Here neither is
34
+ * set, so the change shows at once until you set them, and under reduced
35
+ * motion it always does.
36
+ *
30
37
  * Slot one glyph per movement into `up-icon`, `down-icon` and `neutral-icon`,
31
38
  * and the trend shows the one that matches; a glyph in `icon` stands in for
32
39
  * all three. Inside a `Stat`, put the trend in the stat's `trend` slot so it is
@@ -53,12 +60,18 @@ import { type PropertyValues, type TemplateResult } from 'lit';
53
60
  * @csspart icon - The arrow.
54
61
  * @csspart value - The change written from `value`, hidden while `value` is no number.
55
62
  *
63
+ * @cssproperty --trend-count-duration - How long a new `value` takes to count from the one before. Unset, the change shows at once.
64
+ * @cssproperty --trend-count-easing - The curve a new `value` counts along.
65
+ *
56
66
  * @cssstate better - The trend moved the way `good` names.
57
67
  * @cssstate down - The trend moved down, as `movement`, the old `direction`, or the sign of `value` says.
58
68
  * @cssstate up - The trend moved up, as `movement`, the old `direction`, or the sign of `value` says.
59
69
  * @cssstate worse - The trend moved against the way `good` names.
60
70
  */
61
71
  export declare class HelixHeadlessTrend extends HelixElement {
72
+ protected static markRules: string[];
73
+ /** Counting a new `value` from the one before. */
74
+ protected readonly count: CountController;
62
75
  /**
63
76
  * The key this family's words are registered under, its styled tag:
64
77
  * `registerWords('de', { 'helix-trend': { upLabel: 'Gestiegen' } })`.
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { customElement, formatWords, HelixElement, numberConverter, reportRuntime, words, wordsLocale, } from '@fusion.dev/helix-core';
2
+ import { CountController, customElement, formatWords, HelixElement, numberConverter, reportRuntime, SPOKEN_RULE, words, wordsLocale, } from '@fusion.dev/helix-core';
3
3
  import { arrowDown, arrowUp, minus } from '@fusion.dev/helix-icons';
4
4
  import { html } from 'lit';
5
5
  import { property } from 'lit/decorators.js';
@@ -14,6 +14,15 @@ const readDirection = (value) => DIRECTIONS[value] ?? DIRECTIONS.neutral;
14
14
  let HelixHeadlessTrend = class HelixHeadlessTrend extends HelixElement {
15
15
  constructor() {
16
16
  super(...arguments);
17
+ this.count = new CountController(this, {
18
+ timing: () => {
19
+ const style = getComputedStyle(this);
20
+ return {
21
+ duration: style.getPropertyValue('--trend-count-duration'),
22
+ easing: style.getPropertyValue('--trend-count-easing'),
23
+ };
24
+ },
25
+ });
17
26
  this.betterLabel = 'better';
18
27
  this.downLabel = 'Down';
19
28
  this.judgmentLabel = '{judgment, select, better {{direction}, {betterLabel}} worse {{direction}, {worseLabel}} other {{direction}}}';
@@ -22,6 +31,7 @@ let HelixHeadlessTrend = class HelixHeadlessTrend extends HelixElement {
22
31
  this.upLabel = 'Up';
23
32
  this.worseLabel = 'worse';
24
33
  }
34
+ static { this.markRules = [SPOKEN_RULE]; }
25
35
  static { this.words = 'helix-trend'; }
26
36
  renderIcon(icon) {
27
37
  return html `<slot aria-hidden="true" name="icon"
@@ -59,6 +69,10 @@ let HelixHeadlessTrend = class HelixHeadlessTrend extends HelixElement {
59
69
  }
60
70
  willUpdate(changed) {
61
71
  super.willUpdate(changed);
72
+ const was = changed.get('value');
73
+ if (changed.has('value') && this.hasUpdated && was !== undefined) {
74
+ this.count.start(was, this.value);
75
+ }
62
76
  const judged = this.judged;
63
77
  this.toggleState('better', judged === 'better');
64
78
  this.toggleState('worse', judged === 'worse');
@@ -85,9 +99,13 @@ let HelixHeadlessTrend = class HelixHeadlessTrend extends HelixElement {
85
99
  const figure = value === undefined || !Number.isFinite(value)
86
100
  ? ''
87
101
  : figureOf(value, wordsLocale(this), this.formatOptions);
102
+ const counting = this.count.counting;
103
+ const shown = counting === undefined
104
+ ? figure
105
+ : html `<span aria-hidden="true">${figureOf(counting, wordsLocale(this), this.formatOptions)}</span><span data-spoken>${figure}</span>`;
88
106
  return html `${glyph}
89
107
  <span part="direction">${said}</span>
90
- <span part="value" ?hidden=${figure === ''}>${figure}</span><slot></slot>
108
+ <span part="value" ?hidden=${figure === ''}>${shown}</span><slot></slot>
91
109
  <slot name="label"></slot>`;
92
110
  }
93
111
  };