@fusion.dev/helix-headless 0.246.0 → 0.247.1

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 (50) hide show
  1. package/api.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/area-chart/root/area-chart-root.d.ts +18 -3
  4. package/dist/area-chart/root/area-chart-root.js +29 -11
  5. package/dist/bar-chart/root/bar-chart-root.d.ts +12 -2
  6. package/dist/bar-chart/root/bar-chart-root.js +92 -32
  7. package/dist/code-editor/root/code-editor-root.d.ts +15 -0
  8. package/dist/code-editor/root/code-editor-root.js +8 -2
  9. package/dist/data-table/changes.d.ts +39 -0
  10. package/dist/data-table/changes.js +60 -0
  11. package/dist/data-table/root/data-table-root.d.ts +33 -0
  12. package/dist/data-table/root/data-table-root.js +52 -2
  13. package/dist/drawer/root/drawer-root.d.ts +54 -14
  14. package/dist/drawer/root/drawer-root.js +102 -29
  15. package/dist/editor/root/editor-root.d.ts +5 -0
  16. package/dist/editor/root/editor-root.js +5 -5
  17. package/dist/filter-input/menu/filter-menu.d.ts +1 -0
  18. package/dist/filter-input/menu/filter-menu.js +1 -1
  19. package/dist/find/root/find-root.d.ts +1 -0
  20. package/dist/find/root/find-root.js +1 -1
  21. package/dist/line-chart/root/line-chart-root.d.ts +26 -2
  22. package/dist/line-chart/root/line-chart-root.js +76 -24
  23. package/dist/menu/root/menu-root.d.ts +23 -1
  24. package/dist/menu/root/menu-root.js +60 -1
  25. package/dist/navigation/root/navigation-root.d.ts +1 -0
  26. package/dist/navigation/root/navigation-root.js +1 -1
  27. package/dist/scatter-chart/root/scatter-chart-root.d.ts +3 -0
  28. package/dist/scatter-chart/root/scatter-chart-root.js +28 -8
  29. package/dist/skeleton/root/skeleton-root.d.ts +26 -2
  30. package/dist/skeleton/root/skeleton-root.js +19 -4
  31. package/dist/tabs/root/tabs-root.d.ts +5 -1
  32. package/dist/tabs/root/tabs-root.js +8 -1
  33. package/dist/terminal/root/terminal-root.d.ts +2 -0
  34. package/dist/terminal/root/terminal-root.js +2 -2
  35. package/dist/toast/item/toast-item.d.ts +16 -11
  36. package/dist/toast/item/toast-item.js +13 -28
  37. package/dist/toast/root/toast-root.d.ts +6 -3
  38. package/dist/toast/root/toast-root.js +2 -2
  39. package/dist/toggle/group/toggle-group.d.ts +5 -1
  40. package/dist/toggle/group/toggle-group.js +8 -2
  41. package/dist/toolbar/root/toolbar-root.d.ts +9 -1
  42. package/dist/toolbar/root/toolbar-root.js +9 -1
  43. package/dist/video/root/video-root.d.ts +2 -0
  44. package/dist/video/root/video-root.js +2 -2
  45. package/dist/video-playlist/menu/video-playlist-menu.d.ts +1 -0
  46. package/dist/video-playlist/menu/video-playlist-menu.js +1 -1
  47. package/lint.json +1 -1
  48. package/package.json +5 -5
  49. package/types/jsx.d.ts +153 -34
  50. package/types/vue.d.ts +83 -22
@@ -0,0 +1,60 @@
1
+ const DEPTH = 8;
2
+ export const sameData = (a, b, skip, depth = 0) => {
3
+ if (Object.is(a, b)) {
4
+ return true;
5
+ }
6
+ if (a instanceof Date && b instanceof Date) {
7
+ return a.getTime() === b.getTime();
8
+ }
9
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
10
+ return false;
11
+ }
12
+ if (depth >= DEPTH || Array.isArray(a) !== Array.isArray(b)) {
13
+ return false;
14
+ }
15
+ if (Array.isArray(a) && Array.isArray(b)) {
16
+ return a.length === b.length && a.every((one, at) => sameData(one, b[at], undefined, depth + 1));
17
+ }
18
+ const left = Object.keys(a).filter((name) => name !== skip);
19
+ const right = Object.keys(b).filter((name) => name !== skip);
20
+ return (left.length === right.length &&
21
+ left.every((name) => Object.hasOwn(b, name) &&
22
+ sameData(a[name], b[name], undefined, depth + 1)));
23
+ };
24
+ export const everyRow = (rows, childField) => {
25
+ if (!childField) {
26
+ return [...rows];
27
+ }
28
+ return rows.flatMap((row) => {
29
+ const children = row[childField];
30
+ return [row, ...(Array.isArray(children) ? everyRow(children, childField) : [])];
31
+ });
32
+ };
33
+ export const rowsByKey = (rows, keyOf) => {
34
+ const found = new Map();
35
+ for (const row of rows) {
36
+ const key = keyOf(row);
37
+ if (key !== undefined) {
38
+ found.set(key, row);
39
+ }
40
+ }
41
+ return found;
42
+ };
43
+ export const changedKeys = (before, now, options) => {
44
+ const changed = new Set();
45
+ let shared = false;
46
+ for (const [key, row] of now) {
47
+ const was = before.get(key);
48
+ if (was === undefined) {
49
+ if (options.arrivals) {
50
+ changed.add(key);
51
+ }
52
+ continue;
53
+ }
54
+ shared = true;
55
+ if (was !== row && !options.own?.(row) && !sameData(was, row, options.childField)) {
56
+ changed.add(key);
57
+ }
58
+ }
59
+ return shared ? changed : new Set();
60
+ };
@@ -190,6 +190,15 @@ declare const HelixHeadlessDataTable_base: (new (...args: any[]) => import("@fus
190
190
  * draws only the rows in view, so a sort that brings in other rows fades them
191
191
  * in where they land.
192
192
  *
193
+ * **`flash-changes` lights up what changed.** Set it with `row-key`, and a row
194
+ * whose values differ when you set `rows` again, or a row that arrives in it,
195
+ * takes a quiet wash that holds and fades, which core's `flashChange` draws
196
+ * over each of its cells. A row with the same values does not, even as a new
197
+ * object, and neither does a value a reader saves in a cell. A `rows` that
198
+ * shares no key with the one before is new data, and nothing lights up. The
199
+ * wash is `--data-table-flash-color`. Only the rows drawn light up, so a change
200
+ * on another page or outside the window is not shown later.
201
+ *
193
202
  * **Editable cells.** `editable` on a column lets a reader edit its cells,
194
203
  * and `rowEditable` decides row by row. The column's `type` picks the field:
195
204
  * text, a number, a date, or a select of an enum's values, and a boolean
@@ -354,6 +363,7 @@ declare const HelixHeadlessDataTable_base: (new (...args: any[]) => import("@fus
354
363
  * @csspart menu-entry-start - The leading column of a row in a column's menu, on the column.
355
364
  * @csspart menu-entry-surface - Forwarded from the row, on the column. Not shown in the table.
356
365
  * @csspart menu-header - Forwarded from the column's menu, on the column. Not shown in the table, whose menu has no submenu.
366
+ * @csspart menu-highlight - Forwarded from the menu: the wash on the row with focus, which glides from row to row.
357
367
  * @csspart menu-live - Forwarded from the column's menu, on the column. Not shown in the table, whose menu has no loading or empty text.
358
368
  * @csspart menu-loading - Forwarded from the column's menu, on the column. Not shown in the table.
359
369
  * @csspart menu-search-field - Forwarded from the column's menu, on the column. Not shown in the table.
@@ -395,6 +405,7 @@ declare const HelixHeadlessDataTable_base: (new (...args: any[]) => import("@fus
395
405
  *
396
406
  * @cssproperty --data-table-cell-align - The alignment of the cell's column: `start`, `center`, or `end`. Unset when the column sets none. The component writes it on each cell it draws, and the stylesheet reads it. `Table` sets `--table-cell-align` for the same purpose.
397
407
  * @cssproperty --data-table-cell-block-align - Where a cell's content sits from top to bottom in a row taller than it: `start`, `center` or `end`. `center` by default. Set it on the table, or on a row through `::part(row)`; a column's `vertical-align` writes it on each of that column's cells, and wins.
408
+ * @cssproperty --data-table-flash-color - The wash a row takes when it changes, with `flash-changes`, at its strongest. Unset, the info color at 14 percent in light mode and 22 in dark.
398
409
  * @cssproperty --data-table-level - How deep a row is in a tree grid, from 1. The component writes it on each row header cell, and the stylesheet indents by it.
399
410
  * @cssproperty --data-table-move-duration - How long a row takes to slide to its new place, or to fade in. Unset, nothing moves.
400
411
  * @cssproperty --data-table-move-easing - The curve a row slides and fades in along.
@@ -566,6 +577,12 @@ export declare class HelixHeadlessDataTable extends HelixHeadlessDataTable_base
566
577
  */
567
578
  get filter(): string;
568
579
  set filter(next: string);
580
+ /**
581
+ * Lights up a row whose data changes, and a row that arrives in `rows` after
582
+ * the table has drawn, so you see what live data or an agent changed. Wants
583
+ * `row-key`, which is how a row is known across the change.
584
+ */
585
+ flashChanges: boolean;
569
586
  /**
570
587
  * The built-in pagination's name for a gap in its run of pages. `{page}` is
571
588
  * replaced with the page it jumps to.
@@ -948,6 +965,22 @@ export declare class HelixHeadlessDataTable extends HelixHeadlessDataTable_base
948
965
  private lineOf;
949
966
  /** Said once, so a table that re-renders does not repeat it. */
950
967
  private warnedAboutKey;
968
+ /** Each row by its key as `rows` last held it, while `flash-changes` is on. */
969
+ private seenRows;
970
+ /** The rows the table wrote itself, with a value a reader saved, which are not news. */
971
+ private readonly ownRows;
972
+ /** Whether the table asked for more rows since `rows` last changed, so the rows that answer are not news. */
973
+ private askedForMore;
974
+ /** The keys of the rows to light up once this update has drawn them. */
975
+ private flashing;
976
+ /**
977
+ * The rows that changed since `rows` was last set, for `flash-changes`, and
978
+ * the rows as they are now kept for the next time. Nothing on the first
979
+ * render, which is the table arriving, or on the render that turns it on.
980
+ */
981
+ private rowNews;
982
+ /** Lights up each drawn row `rowNews` found, in the wash `--data-table-flash-color` holds. */
983
+ private flashRows;
951
984
  /**
952
985
  * Sliding each row it keeps to its new place when the table sorts or `rows`
953
986
  * changes. Looked for after each update, because the table draws its rows,
@@ -1,6 +1,6 @@
1
1
  var HelixHeadlessDataTable_1;
2
2
  import { __decorate } from "tslib";
3
- import { anchorAt, arranged, assignSlot, auditChildren, auditServed, commaList, countLabel, customElement, cycle, deepActiveElement, deepContains, everyState, format, formatWords, gridMove, HelixBeforeFilterEvent, HelixBeforeNavigateEvent, HelixBeforeReorderEvent, HelixBeforeSelectEvent, HelixBeforeSortEvent, HelixElement, HelixExpandEvent, HelixFilterEvent, HelixLoadMoreEvent, HelixNavigateEvent, HelixReorderEvent, HelixSelectEvent, HelixSortEvent, handedLocale, hostAria, inlineStep, inRowOrder, internalsOf, LayoutMotionController, MixinCollection, markMatches, markRegion, numberConverter, onAndroid, ordered, pageRows, parse, placeKey, ReorderController, rangeAdd, reportRuntime, requestChange, requestReorder, SCROLLER_RULE, SHUT_RULE, scrollingAncestor, scrollRoom, selectsAll, Typeahead, toggleEvery, treeArrow, typesCharacter, VIRTUAL_RULE, VirtualizeController, valueAt, whenHydrated, window_, words, wordsLocale, writtenList, } from '@fusion.dev/helix-core';
3
+ import { anchorAt, arranged, assignSlot, auditChildren, auditServed, commaList, countLabel, customElement, cycle, deepActiveElement, deepContains, everyState, flashChange, format, formatWords, gridMove, HelixBeforeFilterEvent, HelixBeforeNavigateEvent, HelixBeforeReorderEvent, HelixBeforeSelectEvent, HelixBeforeSortEvent, HelixElement, HelixExpandEvent, HelixFilterEvent, HelixLoadMoreEvent, HelixNavigateEvent, HelixReorderEvent, HelixSelectEvent, HelixSortEvent, handedLocale, hostAria, inlineStep, inRowOrder, internalsOf, LayoutMotionController, MixinCollection, markMatches, markRegion, numberConverter, onAndroid, ordered, pageRows, parse, placeKey, ReorderController, rangeAdd, reportRuntime, requestChange, requestReorder, SCROLLER_RULE, SHUT_RULE, scrollingAncestor, scrollRoom, selectsAll, Typeahead, toggleEvery, treeArrow, typesCharacter, VIRTUAL_RULE, VirtualizeController, valueAt, whenHydrated, window_, words, wordsLocale, writtenList, } from '@fusion.dev/helix-core';
4
4
  import { caretDown, dotsSixVertical } from '@fusion.dev/helix-icons';
5
5
  import { nothing } from 'lit';
6
6
  import { property, state } from 'lit/decorators.js';
@@ -21,6 +21,7 @@ import '../../option/index.js';
21
21
  import { HelixHeadlessMenu } from '../../menu/root/menu-root.js';
22
22
  import '../../pagination/index.js';
23
23
  import '../../select/index.js';
24
+ import { changedKeys, everyRow, rowsByKey } from '../changes.js';
24
25
  import { checkEdit, readEdit, withValue } from '../edit.js';
25
26
  import { HelixBeforeCellCommitEvent, HelixBeforeCellEditEvent, HelixBeforeColumnToggleEvent, HelixBeforeExportEvent, HelixBeforeFollowEvent, HelixBeforeViewChangeEvent, HelixCellCommitEvent, HelixCellEditEvent, HelixColumnToggleEvent, HelixExportEvent, HelixFollowEvent, HelixViewChangeEvent, } from '../events/index.js';
26
27
  import { EXPORT_TYPES, exportText } from '../export.js';
@@ -61,6 +62,7 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
61
62
  this.editOn = 'click';
62
63
  this.errorText = '';
63
64
  this.estimate = 32;
65
+ this.flashChanges = false;
64
66
  this.gapLabel = 'Skip to page {page}';
65
67
  this.hideColumnLabel = 'Hide column';
66
68
  this.label = '';
@@ -188,6 +190,9 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
188
190
  },
189
191
  });
190
192
  this.warnedAboutKey = false;
193
+ this.ownRows = new WeakSet();
194
+ this.askedForMore = false;
195
+ this.flashing = new Set();
191
196
  this.motion = new LayoutMotionController(this, {
192
197
  items: () => [...(this.renderRoot?.querySelectorAll('[part~="row"]') ?? [])],
193
198
  scroller: () => this.renderRoot?.querySelector('[part="table"]'),
@@ -293,7 +298,7 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
293
298
  html `${row('hide', this.hideColumnLabel, shown.length <= 1)}${this.restorable.length > 0 ? row('restore', this.showColumnsLabel) : nothing}`,
294
299
  ].filter((group) => group !== nothing);
295
300
  return html `<${menu}
296
- exportparts="back: menu-back, back-mark: menu-back-mark, empty: menu-empty, header: menu-header,
301
+ exportparts="back: menu-back, back-mark: menu-back-mark, empty: menu-empty, header: menu-header, highlight: menu-highlight,
297
302
  live: menu-live, loading: menu-loading, search-field: menu-search-field, surface: menu-surface,
298
303
  title: menu-title"
299
304
  @helix-before-check=${this.keepMenuCheck}
@@ -676,6 +681,44 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
676
681
  ? undefined
677
682
  : this.renderRoot?.querySelector?.(`[part~="row"][data-row="${index}"]`);
678
683
  }
684
+ rowNews(changed) {
685
+ if (!this.flashChanges || !this.rowKey) {
686
+ this.seenRows = undefined;
687
+ return new Set();
688
+ }
689
+ if (this.seenRows && !changed.has('rows')) {
690
+ return new Set();
691
+ }
692
+ const before = this.seenRows;
693
+ this.seenRows = rowsByKey(everyRow(this.rows, this.childField), (row) => {
694
+ const key = valueAt(row, this.rowKey);
695
+ return key === undefined || key === null ? undefined : String(key);
696
+ });
697
+ const arrivals = !this.askedForMore;
698
+ this.askedForMore = false;
699
+ if (!before || !this.hasUpdated) {
700
+ return new Set();
701
+ }
702
+ return changedKeys(before, this.seenRows, {
703
+ arrivals,
704
+ childField: this.childField || undefined,
705
+ own: (row) => this.ownRows.has(row),
706
+ });
707
+ }
708
+ flashRows() {
709
+ if (this.flashing.size === 0) {
710
+ return;
711
+ }
712
+ const keys = this.flashing;
713
+ this.flashing = new Set();
714
+ const color = getComputedStyle(this).getPropertyValue('--data-table-flash-color').trim();
715
+ for (const row of this.renderRoot.querySelectorAll('[part~="row"][data-row]')) {
716
+ const data = this.drawnPage[Number(row.dataset.row)];
717
+ if (data && keys.has(this.rowKeyOf(data, -1))) {
718
+ void flashChange(row, { color: color || undefined });
719
+ }
720
+ }
721
+ }
679
722
  drawn() {
680
723
  return [...this.renderRoot.querySelectorAll('[part~="row"][data-index]')].flatMap((row) => {
681
724
  const cell = row.firstElementChild;
@@ -1142,6 +1185,7 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
1142
1185
  return (columns.find((column) => column.rowHeader) ?? columns.find((column) => column.field !== ''));
1143
1186
  }
1144
1187
  askForMore() {
1188
+ this.askedForMore = true;
1145
1189
  this.dispatchEvent(new HelixLoadMoreEvent());
1146
1190
  }
1147
1191
  askNearEnd() {
@@ -1543,6 +1587,7 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
1543
1587
  this.fit();
1544
1588
  this.hadFocus = this.hasUpdated && this.gridHasFocus();
1545
1589
  this.announced = this.news();
1590
+ this.flashing = this.rowNews(changed);
1546
1591
  hostAria(internalsOf(this), {
1547
1592
  label: this.label || 'Table',
1548
1593
  role: this.childField ? 'treegrid' : 'grid',
@@ -1583,6 +1628,7 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
1583
1628
  this.announceSort();
1584
1629
  this.quietControls();
1585
1630
  this.placeFocus();
1631
+ this.flashRows();
1586
1632
  if (this.windowed) {
1587
1633
  this.virtualize.measure();
1588
1634
  }
@@ -2016,6 +2062,7 @@ let HelixHeadlessDataTable = class HelixHeadlessDataTable extends MixinCollectio
2016
2062
  writeEdit(row, field, value, previous) {
2017
2063
  const next = withValue(row, field, value);
2018
2064
  const key = this.editKey(row);
2065
+ this.ownRows.add(next);
2019
2066
  this.rows = this.rows.map((one) => (one === row ? next : one));
2020
2067
  this.dispatchEvent(new HelixCellCommitEvent({
2021
2068
  field,
@@ -2812,6 +2859,9 @@ __decorate([
2812
2859
  __decorate([
2813
2860
  property()
2814
2861
  ], HelixHeadlessDataTable.prototype, "filter", null);
2862
+ __decorate([
2863
+ property({ attribute: 'flash-changes', type: Boolean })
2864
+ ], HelixHeadlessDataTable.prototype, "flashChanges", void 0);
2815
2865
  __decorate([
2816
2866
  words,
2817
2867
  property({ attribute: 'gap-label' })
@@ -1,4 +1,4 @@
1
- import { AriaForwardController, CommandController, FocusScopeController, HelixElement, OpenPhaseController, SwipeController } from '@fusion.dev/helix-core';
1
+ import { AriaForwardController, CommandController, DragDismissController, FocusScopeController, HelixElement, OpenPhaseController } from '@fusion.dev/helix-core';
2
2
  import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  declare const HelixHeadlessDrawer_base: (new (...args: any[]) => import("@fusion.dev/helix-core").MixinControllerOpenInterface) & typeof HelixElement;
4
4
  /**
@@ -25,13 +25,24 @@ declare const HelixHeadlessDrawer_base: (new (...args: any[]) => import("@fusion
25
25
  * still close it. `closedby="none"` keeps it open on all three as well, and
26
26
  * `closedby="closerequest"` keeps it open on a press outside.
27
27
  *
28
- * **A touch or a pen swipes it away**, toward the edge it came from, resolved
29
- * against the writing direction. A swipe past halfway, or a quick one, closes
30
- * it through the same request as every other way out. `snap-points` lists the
31
- * fractions of the panel a reader can leave on screen, such as `0.5 1` for a
32
- * sheet that rests half open: it opens at the smallest, and a swipe settles at
33
- * the nearest. While a swipe moves the panel, the distance is written on it as
34
- * `--drawer-swipe-x` and `--drawer-swipe-y`. `swipe="false"` turns swiping off.
28
+ * **A touch or a pen drags it closed**, toward the edge it came from, resolved
29
+ * against the writing direction, from anywhere on the panel but a field or
30
+ * content that scrolls along the drag. The panel follows the finger, and past
31
+ * its open end it gives less and less. A drag past halfway, or a quick flick
32
+ * from any distance, closes it through the same request as every other way
33
+ * out, so a `helix-before-close` listener can refuse it, and then the panel
34
+ * springs back. Let go, the panel carries on at the speed it was moving: off
35
+ * the edge, or back to rest along `--drawer-release-easing`. The panel takes
36
+ * an inline `translate` only while a drag and its release run, and the host
37
+ * has `:state(dragging)` for that time. While it moves, the backdrop can fade
38
+ * with `--drawer-drag-progress`. A mouse does not drag it, since a mouse drag
39
+ * selects text, and `swipe="false"` turns dragging off.
40
+ *
41
+ * `snap-points` lists the fractions of the panel a reader can leave on screen,
42
+ * such as `0.5 1` for a sheet that rests half open: it opens at the smallest,
43
+ * and a drag settles at the nearest, or at the next one along for a flick.
44
+ * The offset of the snap point it rests at is written on the panel as
45
+ * `--drawer-swipe-x` and `--drawer-swipe-y`.
35
46
  *
36
47
  * `snap` is the snap point the panel rests at, and `:state(snapped)` is on the
37
48
  * host while that is less than the whole panel. `snapTo()` moves it to
@@ -107,15 +118,20 @@ declare const HelixHeadlessDrawer_base: (new (...args: any[]) => import("@fusion
107
118
  * @csspart header - The header region.
108
119
  * @csspart panel - The sliding panel.
109
120
  *
110
- * @cssproperty --drawer-swipe-x - How far a swipe, or a snap point, has moved the panel across, in pixels, toward the right.
111
- * @cssproperty --drawer-swipe-y - How far a swipe, or a snap point, has moved the panel down, in pixels.
121
+ * @cssproperty --drawer-drag-progress - How far a drag, and the glide after it, has taken the panel from its smallest snap point to off its edge, from `0` to `1`. Written only while the host has `:state(dragging)`.
122
+ * @cssproperty --drawer-release-duration - The longest a released panel takes to go, or to go back to rest. Unset, it lands at once.
123
+ * @cssproperty --drawer-release-easing - The curve a released panel goes back to rest along, with the speed it was let go carried in.
124
+ * @cssproperty --drawer-swipe-x - How far the snap point the panel rests at moves it across, in pixels, toward the right.
125
+ * @cssproperty --drawer-swipe-y - How far the snap point the panel rests at moves it down, in pixels.
112
126
  *
127
+ * @cssstate dragging - From the moment a finger starts dragging the panel until its release has come to rest, on screen or off it.
113
128
  * @cssstate entering - From the moment the drawer opens until its entrance has finished.
114
129
  * @cssstate exiting - From the moment the drawer closes until its exit has finished.
115
130
  * @cssstate open - While the drawer is open.
116
131
  * @cssstate snapped - While the panel rests at a snap point that shows less than the whole panel.
117
132
  */
118
133
  export declare class HelixHeadlessDrawer extends HelixHeadlessDrawer_base {
134
+ protected static markRules: string[];
119
135
  /**
120
136
  * The key this family's words are registered under, its styled tag:
121
137
  * `registerWords('de', { 'helix-drawer': { dismissLabel: 'Schließen' } })`.
@@ -235,14 +251,19 @@ export declare class HelixHeadlessDrawer extends HelixHeadlessDrawer_base {
235
251
  private get edge();
236
252
  /** The panel's size along the swipe, in pixels. */
237
253
  private get extent();
238
- protected readonly swipes: SwipeController;
254
+ /** How far toward its edge the panel rests at its smallest snap point, in pixels, on a panel `size` long. */
255
+ private floor;
256
+ protected readonly drags: DragDismissController;
239
257
  /**
240
- * Writes how far the panel sits toward its edge, as the two properties the
258
+ * Writes how far the panel rests toward its edge, as the two properties the
241
259
  * styled tier translates it by. Nothing is written at rest.
242
260
  */
243
261
  private place;
244
- /** Brings a released swipe to rest: at a snap point, or closed through the request. */
245
- private settle;
262
+ /**
263
+ * Takes the closed panel out of the top layer and puts it back at rest.
264
+ * After a drag closed it, this waits for its glide off the edge.
265
+ */
266
+ private finishClose;
246
267
  /**
247
268
  * The fraction of the panel on screen at the snap point it rests at, such as
248
269
  * `0.5`. It is `1`, the whole panel, while the drawer is closed or has no
@@ -327,6 +348,25 @@ export declare class HelixHeadlessDrawer extends HelixHeadlessDrawer_base {
327
348
  * comes first.
328
349
  */
329
350
  private describeByBody;
351
+ /** Watches the content region and what is slotted into it for a change of size. */
352
+ private contentSizes;
353
+ /**
354
+ * Marks the content region with the drag's axis while it does not scroll
355
+ * along it, and takes the mark off while it does.
356
+ *
357
+ * **The content region is a scroller, and a scroller's `touch-action` is its
358
+ * own.** Left to the styled sheet's `pan-y`, a sheet's words handed every
359
+ * downward drag to the browser, which canceled it: measured in Chromium on
360
+ * November 19, 2026, a touch drag on the text of a bottom sheet ended in
361
+ * `pointercancel` after two moves. Marked, a drag on words that do not
362
+ * scroll moves the panel, and content that scrolls along the drag keeps its
363
+ * scroll, as `startsSwipe` reads it.
364
+ */
365
+ private markContent;
366
+ /** Watches the content region, and each element slotted into it, for a change of size. */
367
+ private watchContent;
368
+ /** The body's slot changed: its description, and whether it scrolls. */
369
+ private readonly handleBodyChange;
330
370
  /** A `<form method="dialog">` slotted into the drawer closes it, as in `Dialog`. */
331
371
  private readonly handleSubmit;
332
372
  connectedCallback(): void;
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { AriaForwardController, auditName, autofocusTarget, CommandController, coversPress, customElement, drawDismiss, drawDismissGlyph, edgeOffset, FocusScopeController, focusAs, focusableElements, HelixElement, headingsIn, isRtl, lockScroll, MixinControllerOpen, nearest, OpenPhaseController, onUnlessFalse, openingFocus, parseSnapPoints, raiseAbove, reflectElements, refocusWithin, SwipeController, settleSwipe, snapTravel, swipeAxis, swipeEdge, towardEdge, unlockScroll, words, } from '@fusion.dev/helix-core';
2
+ import { AriaForwardController, auditName, autofocusTarget, CommandController, coversPress, customElement, DRAGS_RULE, DragDismissController, drawDismiss, drawDismissGlyph, edgeOffset, FocusScopeController, focusAs, focusableElements, HelixElement, headingsIn, isRtl, lockScroll, MixinControllerOpen, nearest, OpenPhaseController, onUnlessFalse, openingFocus, parseSnapPoints, raiseAbove, reflectElements, refocusWithin, settleSwipe, snapTravel, swipeAxis, swipeEdge, unlockScroll, words, } from '@fusion.dev/helix-core';
3
3
  import { html, nothing } from 'lit';
4
4
  import { property } from 'lit/decorators.js';
5
5
  import { wordsIn } from '../../dialog/description.js';
@@ -37,12 +37,48 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
37
37
  });
38
38
  this.rest = 0;
39
39
  this.shown = 1;
40
- this.swipes = new SwipeController(this, {
41
- axis: () => (this.open && this.swipe ? swipeAxis(this.edge) : undefined),
42
- end: (dx, dy, vx, vy) => this.settle(dx, dy, vx, vy),
43
- move: (dx, dy) => this.place(Math.max(0, this.rest + towardEdge(this.edge, dx, dy))),
40
+ this.drags = new DragDismissController(this, {
41
+ bounds: (size) => ({
42
+ max: this.refusesDismissal ? this.floor(size) : Number.POSITIVE_INFINITY,
43
+ min: 0,
44
+ }),
45
+ decide: ({ size, travel, velocity }) => {
46
+ const shown = settleSwipe({
47
+ points: parseSnapPoints(this.snapPoints),
48
+ size,
49
+ travel,
50
+ velocity,
51
+ });
52
+ if (shown === 0) {
53
+ return true;
54
+ }
55
+ this.restAt(shown);
56
+ return false;
57
+ },
58
+ dismiss: () => !this.refusesDismissal && this.requestOpen(false),
59
+ edge: () => (this.open && this.swipe ? this.edge : undefined),
60
+ landed: () => {
61
+ this.panel?.style.removeProperty('--drawer-drag-progress');
62
+ if (!this.open) {
63
+ this.finishClose();
64
+ }
65
+ },
66
+ mark: (on) => this.toggleState('dragging', on),
67
+ moved: (travel, size) => {
68
+ const floor = this.floor(size);
69
+ const progress = size > floor ? (travel - floor) / (size - floor) : 0;
70
+ this.panel?.style.setProperty('--drawer-drag-progress', String(Math.round(Math.min(1, Math.max(0, progress)) * 1000) / 1000));
71
+ },
72
+ rest: () => this.rest,
44
73
  start: (target, event) => startsSwipe(target, event.pointerType, swipeAxis(this.edge), this.partNamed('content')),
45
74
  surface: () => this.panel,
75
+ timing: () => {
76
+ const style = getComputedStyle(this);
77
+ return {
78
+ duration: style.getPropertyValue('--drawer-release-duration'),
79
+ easing: style.getPropertyValue('--drawer-release-easing'),
80
+ };
81
+ },
46
82
  });
47
83
  this.handleFocusIn = (event) => {
48
84
  const target = event.composedPath()[0];
@@ -110,10 +146,15 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
110
146
  };
111
147
  this.namedByHeader = false;
112
148
  this.describedByBody = false;
149
+ this.handleBodyChange = () => {
150
+ this.describeByBody();
151
+ this.watchContent();
152
+ };
113
153
  this.handleSubmit = (event) => {
114
154
  closeOnDialogSubmit(event, (value) => this.close(value));
115
155
  };
116
156
  }
157
+ static { this.markRules = [DRAGS_RULE]; }
117
158
  static { this.words = 'helix-drawer'; }
118
159
  get refusesDismissal() {
119
160
  return this.persistent || this.closedBy === 'none';
@@ -135,6 +176,9 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
135
176
  const box = this.panel?.getBoundingClientRect();
136
177
  return (swipeAxis(this.edge) === 'x' ? box?.width : box?.height) ?? 0;
137
178
  }
179
+ floor(size) {
180
+ return snapTravel(size, parseSnapPoints(this.snapPoints)[0] ?? 1);
181
+ }
138
182
  place(travel) {
139
183
  const panel = this.panel;
140
184
  if (!panel) {
@@ -145,23 +189,14 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
145
189
  panel.style.setProperty('--drawer-swipe-x', px(x));
146
190
  panel.style.setProperty('--drawer-swipe-y', px(y));
147
191
  }
148
- settle(dx, dy, vx, vy) {
149
- const edge = this.edge;
150
- const size = this.extent;
151
- const shown = settleSwipe({
152
- points: parseSnapPoints(this.snapPoints),
153
- size,
154
- travel: Math.max(0, this.rest + towardEdge(edge, dx, dy)),
155
- velocity: towardEdge(edge, vx, vy),
156
- });
157
- if (shown === 0 && !this.refusesDismissal && this.requestOpen(false)) {
158
- return;
159
- }
160
- if (shown !== 0) {
161
- this.restAt(shown);
162
- }
163
- else {
164
- this.place(this.rest);
192
+ finishClose() {
193
+ this.rest = 0;
194
+ this.shown = 1;
195
+ this.place(0);
196
+ this.markSnap();
197
+ const panel = this.panel;
198
+ if (panel?.open) {
199
+ panel.close();
165
200
  }
166
201
  }
167
202
  get snap() {
@@ -213,26 +248,61 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
213
248
  const said = this.hasAttribute('aria-describedby') ? [] : wordsIn(slot);
214
249
  this.describedByBody = reflectElements(this.panel, 'ariaDescribedByElements', said, this.describedByBody);
215
250
  }
251
+ markContent() {
252
+ const content = this.partNamed('content');
253
+ if (!content) {
254
+ return;
255
+ }
256
+ const axis = this.open && this.swipe ? swipeAxis(this.edge) : undefined;
257
+ const scrolls = axis === 'x'
258
+ ? content.scrollWidth > content.clientWidth
259
+ : content.scrollHeight > content.clientHeight;
260
+ if (axis !== undefined && !scrolls) {
261
+ content.setAttribute('data-drags', axis);
262
+ }
263
+ else {
264
+ content.removeAttribute('data-drags');
265
+ }
266
+ }
267
+ watchContent() {
268
+ if (typeof ResizeObserver === 'undefined') {
269
+ this.markContent();
270
+ return;
271
+ }
272
+ this.contentSizes ??= new ResizeObserver(() => this.markContent());
273
+ this.contentSizes.disconnect();
274
+ const content = this.partNamed('content');
275
+ if (content) {
276
+ this.contentSizes.observe(content);
277
+ }
278
+ const slot = this.renderRoot.querySelector('slot:not([name])');
279
+ for (const one of slot?.assignedElements({ flatten: true }) ?? []) {
280
+ this.contentSizes.observe(one);
281
+ }
282
+ this.markContent();
283
+ }
216
284
  connectedCallback() {
217
285
  super.connectedCallback();
218
286
  this.addEventListener('focusin', this.handleFocusIn);
219
287
  this.addEventListener('submit', this.handleSubmit);
288
+ if (this.hasUpdated) {
289
+ this.watchContent();
290
+ }
220
291
  }
221
292
  disconnectedCallback() {
222
293
  super.disconnectedCallback();
223
294
  this.removeEventListener('focusin', this.handleFocusIn);
224
295
  this.removeEventListener('submit', this.handleSubmit);
296
+ this.contentSizes?.disconnect();
297
+ this.contentSizes = undefined;
225
298
  unlockScroll(this);
226
299
  }
227
300
  updated(changed) {
228
301
  super.updated(changed);
229
302
  this.nameByHeader();
230
303
  this.describeByBody();
231
- if (changed.has('open') && !this.open) {
232
- this.rest = 0;
233
- this.shown = 1;
234
- this.place(0);
235
- this.markSnap();
304
+ if (changed.has('open') && !this.open && !this.drags.dragging) {
305
+ this.finishClose();
236
306
  }
237
307
  if (this.open && this.modal) {
238
308
  lockScroll(this);
@@ -240,6 +310,9 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
240
310
  else {
241
311
  unlockScroll(this);
242
312
  }
313
+ if (changed.has('open') || changed.has('swipe') || changed.has('placement')) {
314
+ this.watchContent();
315
+ }
243
316
  const panel = this.panel;
244
317
  if (!panel) {
245
318
  return;
@@ -279,7 +352,7 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
279
352
  });
280
353
  this.restAt(parseSnapPoints(this.snapPoints)[0] ?? 1);
281
354
  }
282
- else if (!this.open && panel.open) {
355
+ else if (!this.open && panel.open && !this.drags.dragging) {
283
356
  panel.close();
284
357
  }
285
358
  }
@@ -304,7 +377,7 @@ let HelixHeadlessDrawer = class HelixHeadlessDrawer extends MixinControllerOpen(
304
377
  @keydown=${this.handleKeydown}
305
378
  >
306
379
  <div part="header"><slot name="header" @slotchange=${this.nameByHeader}></slot></div>
307
- <div part="content"><slot @slotchange=${this.describeByBody}></slot></div>
380
+ <div part="content"><slot @slotchange=${this.handleBodyChange}></slot></div>
308
381
  <div part="footer"><slot name="footer"></slot></div>
309
382
  ${this.dismissible
310
383
  ? drawDismiss({
@@ -180,6 +180,7 @@ export interface EditorSink {
180
180
  * @csspart block-menu-back-mark - The glyph on the back control of a submenu.
181
181
  * @csspart block-menu-empty - The text shown when the menu has no items.
182
182
  * @csspart block-menu-header - The bar above a submenu, holding the way back and its name.
183
+ * @csspart block-menu-highlight - Forwarded from the menu: the wash on the row with focus, which glides from row to row.
183
184
  * @csspart block-menu-live - The block menu's live region, which repeats the empty and loading text for screen readers.
184
185
  * @csspart block-menu-loading - The text shown while the items are loading.
185
186
  * @csspart block-menu-search-field - The block menu's filter field, drawn with `filterable`.
@@ -217,6 +218,7 @@ export interface EditorSink {
217
218
  * @csspart code-spinner - The ring the Code button turns while it is pending.
218
219
  * @csspart code-text - The box the Code button's icon sits in.
219
220
  * @csspart controls - The toolbar: the tools, then your actions, one tab stop that the arrows move along.
221
+ * @csspart controls-focus - The focus ring that travels along the buttons of the toolbar as the arrow keys move focus.
220
222
  * @csspart controls-toolbar - The box inside the toolbar that lays its buttons out.
221
223
  * @csspart divider - The line between two groups of tools.
222
224
  * @csspart divider-content - The content set into a divider, which the editor sets none into.
@@ -230,6 +232,7 @@ export interface EditorSink {
230
232
  * @csspart find-close-spinner - The ring the find bar's close button turns while it is pending.
231
233
  * @csspart find-close-text - The box the find bar's close button's icon sits in.
232
234
  * @csspart find-controls - The find bar's toolbar of options and moves.
235
+ * @csspart find-controls-focus - The focus ring that travels along the buttons of the find bar's toolbar as the arrow keys move focus.
233
236
  * @csspart find-controls-toolbar - The box inside the find bar's toolbar that lays its buttons out.
234
237
  * @csspart find-count - Which match is selected, of how many.
235
238
  * @csspart find-field - The field the search is typed in.
@@ -306,6 +309,7 @@ export interface EditorSink {
306
309
  * @csspart link-close-spinner - The ring the close button turns while it is pending.
307
310
  * @csspart link-close-text - The box the close button's icon sits in.
308
311
  * @csspart link-controls - The toolbar at the end of the address bar: Apply, Remove, and Close.
312
+ * @csspart link-controls-focus - The focus ring that travels along the buttons of the address bar's toolbar as the arrow keys move focus.
309
313
  * @csspart link-controls-toolbar - The box inside the address bar's toolbar that lays its buttons out.
310
314
  * @csspart link-field - The field the address is written in.
311
315
  * @csspart link-live - The Link button's live region, which speaks while the button is pending.
@@ -336,6 +340,7 @@ export interface EditorSink {
336
340
  * @csspart overflow-divider-line - The line of that rule.
337
341
  * @csspart overflow-empty - The text shown when the menu has no items.
338
342
  * @csspart overflow-header - The bar above a submenu, holding the way back and its name.
343
+ * @csspart overflow-highlight - Forwarded from the menu: the wash on the row with focus, which glides from row to row.
339
344
  * @csspart overflow-live - The overflow menu's live region, which repeats the empty and loading text for screen readers.
340
345
  * @csspart overflow-loading - The text shown while the items are loading.
341
346
  * @csspart overflow-option - One tool in the overflow menu. A mark, a list, or the quote is checked while its format holds.