@fusion.dev/helix-headless 0.236.0 → 0.237.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 (119) hide show
  1. package/api.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/app-header/root/app-header-root.d.ts +9 -0
  4. package/dist/app-header/root/app-header-root.js +21 -0
  5. package/dist/area-chart/root/area-chart-root.d.ts +29 -15
  6. package/dist/area-chart/root/area-chart-root.js +10 -7
  7. package/dist/bar-chart/root/bar-chart-root.d.ts +41 -23
  8. package/dist/bar-chart/root/bar-chart-root.js +15 -10
  9. package/dist/button/root/button-root.js +1 -1
  10. package/dist/canvas/root/canvas-root.d.ts +10 -3
  11. package/dist/canvas/root/canvas-root.js +31 -14
  12. package/dist/color-input/root/color-input-root.d.ts +4 -2
  13. package/dist/color-input/root/color-input-root.js +1 -1
  14. package/dist/combobox/root/combobox-root.d.ts +8 -7
  15. package/dist/combobox/root/combobox-root.js +7 -3
  16. package/dist/command/root/command-root.d.ts +22 -2
  17. package/dist/command/root/command-root.js +39 -5
  18. package/dist/data-table/root/data-table-root.d.ts +10 -7
  19. package/dist/data-table/root/data-table-root.js +6 -1
  20. package/dist/date-picker/root/date-picker-root.d.ts +1 -1
  21. package/dist/date-picker/root/date-picker-root.js +9 -2
  22. package/dist/dialog/root/dialog-root.d.ts +13 -3
  23. package/dist/dialog/root/dialog-root.js +33 -2
  24. package/dist/donut-chart/root/donut-chart-root.d.ts +23 -1
  25. package/dist/donut-chart/root/donut-chart-root.js +41 -13
  26. package/dist/drawer/root/drawer-root.d.ts +10 -2
  27. package/dist/drawer/root/drawer-root.js +34 -1
  28. package/dist/filter-input/chip/filter-chip.js +2 -2
  29. package/dist/find/root/find-root.d.ts +11 -1
  30. package/dist/find/root/find-root.js +11 -0
  31. package/dist/heatmap/root/heatmap-root.d.ts +11 -8
  32. package/dist/heatmap/root/heatmap-root.js +27 -2
  33. package/dist/kbd/root/kbd-root.d.ts +4 -0
  34. package/dist/kbd/root/kbd-root.js +2 -1
  35. package/dist/lightbox/root/lightbox-root.js +3 -2
  36. package/dist/line-chart/root/line-chart-root.d.ts +36 -23
  37. package/dist/line-chart/root/line-chart-root.js +20 -13
  38. package/dist/list/item/list-item.d.ts +2 -1
  39. package/dist/list/item/list-item.js +4 -1
  40. package/dist/list/root/list-root.d.ts +33 -8
  41. package/dist/list/root/list-root.js +17 -3
  42. package/dist/listbox/root/listbox-root.d.ts +48 -15
  43. package/dist/listbox/root/listbox-root.js +65 -6
  44. package/dist/map/root/map-root.js +7 -7
  45. package/dist/markdown/tree.d.ts +6 -1
  46. package/dist/markdown/tree.js +1 -1
  47. package/dist/megamenu/root/megamenu-root.d.ts +19 -0
  48. package/dist/megamenu/root/megamenu-root.js +24 -0
  49. package/dist/menu/filter/menu-filter.js +3 -1
  50. package/dist/menu/item/menu-item.d.ts +12 -0
  51. package/dist/menu/item/menu-item.js +3 -0
  52. package/dist/menu/root/menu-root.d.ts +7 -1
  53. package/dist/menu/root/menu-root.js +6 -3
  54. package/dist/motion-toggle/root/motion-toggle-root.js +2 -2
  55. package/dist/notifications/notification/notification.d.ts +1 -0
  56. package/dist/notifications/notification/notification.js +1 -0
  57. package/dist/notifications/root/notifications-root.d.ts +7 -5
  58. package/dist/notifications/root/notifications-root.js +1 -1
  59. package/dist/number-input/root/number-input-root.d.ts +6 -0
  60. package/dist/number-input/root/number-input-root.js +14 -4
  61. package/dist/object-inspector/root/object-inspector-root.d.ts +6 -5
  62. package/dist/object-inspector/root/object-inspector-root.js +9 -3
  63. package/dist/option/root/option-root.d.ts +14 -0
  64. package/dist/option/root/option-root.js +3 -0
  65. package/dist/pagination/root/pagination-root.d.ts +36 -0
  66. package/dist/pagination/root/pagination-root.js +55 -2
  67. package/dist/pin-input/code.js +1 -1
  68. package/dist/qr-code/root/qr-code-root.d.ts +1 -0
  69. package/dist/qr-code/root/qr-code-root.js +1 -0
  70. package/dist/rating/root/rating-root.d.ts +1 -0
  71. package/dist/rating/root/rating-root.js +1 -0
  72. package/dist/scatter-chart/root/scatter-chart-root.d.ts +6 -0
  73. package/dist/select/root/select-root.d.ts +27 -1
  74. package/dist/select/root/select-root.js +34 -3
  75. package/dist/shortcut-overlay/root/shortcut-overlay-root.d.ts +5 -0
  76. package/dist/shortcut-overlay/root/shortcut-overlay-root.js +15 -1
  77. package/dist/skeleton/root/skeleton-root.d.ts +1 -0
  78. package/dist/skeleton/root/skeleton-root.js +3 -0
  79. package/dist/sparkline/root/sparkline-root.d.ts +53 -0
  80. package/dist/sparkline/root/sparkline-root.js +37 -1
  81. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.d.ts +4 -1
  82. package/dist/spatial-bar-chart/root/spatial-bar-chart-root.js +2 -2
  83. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.d.ts +3 -0
  84. package/dist/spatial-ribbon-chart/root/spatial-ribbon-chart-root.js +2 -2
  85. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.d.ts +3 -0
  86. package/dist/spatial-scatter-chart/root/spatial-scatter-chart-root.js +2 -2
  87. package/dist/spatial-scatter-chart/view.d.ts +17 -8
  88. package/dist/spatial-scatter-chart/view.js +7 -6
  89. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.d.ts +3 -0
  90. package/dist/spatial-surface-chart/root/spatial-surface-chart-root.js +2 -2
  91. package/dist/spatial-treemap/root/spatial-treemap-root.d.ts +3 -0
  92. package/dist/spatial-treemap/root/spatial-treemap-root.js +2 -2
  93. package/dist/splitter/root/splitter-root.js +3 -1
  94. package/dist/stat/group/stat-group.d.ts +13 -0
  95. package/dist/stat/group/stat-group.js +22 -1
  96. package/dist/stat/root/stat-root.d.ts +62 -1
  97. package/dist/stat/root/stat-root.js +146 -4
  98. package/dist/table/cell/table-cell.d.ts +1 -0
  99. package/dist/table/cell/table-cell.js +4 -0
  100. package/dist/table/root/table-root.d.ts +7 -6
  101. package/dist/table/root/table-root.js +1 -1
  102. package/dist/tabs/tab/tab.js +2 -2
  103. package/dist/tag/root/tag-root.js +2 -2
  104. package/dist/timeline/root/timeline-root.d.ts +2 -2
  105. package/dist/timeline/root/timeline-root.js +1 -1
  106. package/dist/toast/root/toast-root.d.ts +53 -6
  107. package/dist/toast/root/toast-root.js +158 -1
  108. package/dist/toggle/root/toggle-root.d.ts +1 -0
  109. package/dist/toggle/root/toggle-root.js +1 -1
  110. package/dist/video-playlist/root/video-playlist-root.d.ts +1 -0
  111. package/dist/video-playlist/root/video-playlist-root.js +2 -0
  112. package/dist/virtual-list/root/virtual-list-root.d.ts +2 -2
  113. package/dist/virtual-list/root/virtual-list-root.js +1 -1
  114. package/examples.json +1 -1
  115. package/lint.json +1 -1
  116. package/package.json +5 -5
  117. package/types/jsx.d.ts +633 -168
  118. package/types/vue.d.ts +379 -95
  119. package/types/words.d.ts +51 -12
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { animationsFinished, ariaChord, chordParts, customElement, DelayController, deepActiveElement, deepContains, FocusScopeController, focusableElements, formatWords, HelixElement, hostAria, internalsOf, keyClaimed, keyNames, matchesChord, numberConverter, onApple, registerShortcut, scrollHolders, words, } from '@fusion.dev/helix-core';
2
+ import { animationsFinished, animationsSettled, ariaChord, chordParts, customElement, DelayController, deepActiveElement, deepContains, FocusScopeController, focusableElements, formatWords, HelixElement, hostAria, internalsOf, keepAbove, keyClaimed, keyNames, matchesChord, numberConverter, onApple, registerShortcut, scrollHolders, words, } from '@fusion.dev/helix-core';
3
3
  import { html } from 'lit';
4
4
  import { property, state } from 'lit/decorators.js';
5
5
  import '../../button/index.js';
@@ -77,6 +77,26 @@ let HelixHeadlessToast = class HelixHeadlessToast extends HelixElement {
77
77
  this.inform();
78
78
  };
79
79
  this.held = new WeakSet();
80
+ this.handleCoveredPress = (event) => {
81
+ const point = 'changedTouches' in event ? event.changedTouches[0] : event;
82
+ if (!point || !('clientX' in point)) {
83
+ return;
84
+ }
85
+ const target = event.composedPath()[0];
86
+ if (target instanceof Node && deepContains(this, target)) {
87
+ return;
88
+ }
89
+ if (!this.raised.covers(point.clientX, point.clientY) || !this.blocked()) {
90
+ return;
91
+ }
92
+ event.stopImmediatePropagation();
93
+ if (event.cancelable) {
94
+ event.preventDefault();
95
+ }
96
+ };
97
+ this.handleResize = () => {
98
+ this.clear();
99
+ };
80
100
  this.handleFocusIn = (event) => {
81
101
  const from = event.relatedTarget;
82
102
  if (from instanceof HTMLElement && !deepContains(this, from)) {
@@ -124,6 +144,24 @@ let HelixHeadlessToast = class HelixHeadlessToast extends HelixElement {
124
144
  }
125
145
  });
126
146
  };
147
+ this.raised = {
148
+ covers: (x, y) => this.region?.style.visibility !== 'hidden' &&
149
+ this.showing.some((one) => {
150
+ const box = one.getBoundingClientRect();
151
+ return x >= box.left && x <= box.right && y >= box.top && y <= box.bottom;
152
+ }),
153
+ raise: () => {
154
+ const region = this.region;
155
+ if (region && popoverOpen(region) && this.showing.length > 0) {
156
+ region.hidePopover();
157
+ region.showPopover();
158
+ }
159
+ this.clearWhenStill();
160
+ },
161
+ release: () => {
162
+ this.clear();
163
+ },
164
+ };
127
165
  }
128
166
  static { this.words = 'helix-toast'; }
129
167
  willUpdate(changed) {
@@ -365,6 +403,100 @@ let HelixHeadlessToast = class HelixHeadlessToast extends HelixElement {
365
403
  if (!open || blocked) {
366
404
  region.showPopover();
367
405
  }
406
+ this.clear();
407
+ }
408
+ clear() {
409
+ const region = this.region;
410
+ if (!region) {
411
+ return;
412
+ }
413
+ const style = region.style;
414
+ const surfaces = this.showing.length > 0 && popoverOpen(region) ? this.modalSurfaces() : [];
415
+ if (surfaces.length === 0) {
416
+ style.removeProperty('translate');
417
+ style.removeProperty('visibility');
418
+ return;
419
+ }
420
+ const [movedX = 0, movedY = 0] = getComputedStyle(region)
421
+ .translate.split(' ')
422
+ .map((one) => Number.parseFloat(one) || 0);
423
+ const frame = region.getBoundingClientRect();
424
+ const messages = this.showing.map((one) => one.getBoundingClientRect());
425
+ const rest = {
426
+ bottom: frame.bottom - movedY,
427
+ left: Math.min(...messages.map((one) => one.left)) - movedX,
428
+ right: Math.max(...messages.map((one) => one.right)) - movedX,
429
+ top: frame.top - movedY,
430
+ };
431
+ const width = window.innerWidth;
432
+ const height = window.innerHeight;
433
+ const inlineGap = frame.left - movedX;
434
+ const blockGap = this.placement?.startsWith('top') ? rest.top : height - rest.bottom;
435
+ const meets = (box, other) => box.left < other.right &&
436
+ box.right > other.left &&
437
+ box.top < other.bottom &&
438
+ box.bottom > other.top;
439
+ const moved = (x, y) => ({
440
+ bottom: rest.bottom + y,
441
+ left: rest.left + x,
442
+ right: rest.right + x,
443
+ top: rest.top + y,
444
+ });
445
+ if (!surfaces.some((one) => meets(rest, one))) {
446
+ style.removeProperty('translate');
447
+ style.removeProperty('visibility');
448
+ return;
449
+ }
450
+ const moves = surfaces.flatMap((one) => [
451
+ [0, one.top - blockGap - rest.bottom],
452
+ [0, one.bottom + blockGap - rest.top],
453
+ [one.left - inlineGap - rest.right, 0],
454
+ [one.right + inlineGap - rest.left, 0],
455
+ ]);
456
+ const fits = moves
457
+ .filter(([x, y]) => {
458
+ const box = moved(x, y);
459
+ return (box.top >= blockGap &&
460
+ box.bottom <= height - blockGap &&
461
+ box.left >= inlineGap &&
462
+ box.right <= width - inlineGap &&
463
+ !surfaces.some((one) => meets(box, one)));
464
+ })
465
+ .sort((one, other) => Math.abs(one[0] + one[1]) - Math.abs(other[0] + other[1]));
466
+ const [move] = fits;
467
+ if (move) {
468
+ style.setProperty('translate', `${Math.round(move[0])}px ${Math.round(move[1])}px`);
469
+ style.removeProperty('visibility');
470
+ }
471
+ else {
472
+ style.removeProperty('translate');
473
+ style.setProperty('visibility', 'hidden');
474
+ }
475
+ }
476
+ modalSurfaces() {
477
+ const surfaces = [];
478
+ for (const holder of scrollHolders()) {
479
+ const surface = holder instanceof HTMLDialogElement ? holder : holder.shadowRoot?.querySelector('dialog');
480
+ if (surface && !deepContains(holder, this)) {
481
+ surfaces.push(surface);
482
+ }
483
+ }
484
+ try {
485
+ const native = document.querySelector('dialog:modal');
486
+ if (native && !deepContains(native, this)) {
487
+ surfaces.push(native);
488
+ }
489
+ }
490
+ catch {
491
+ }
492
+ return surfaces
493
+ .map((one) => one.getBoundingClientRect())
494
+ .filter((one) => one.width > 0 && one.height > 0);
495
+ }
496
+ clearWhenStill() {
497
+ this.clear();
498
+ const surfaces = scrollHolders().map((holder) => holder.shadowRoot?.querySelector('dialog'));
499
+ void Promise.all(surfaces.map((one) => animationsSettled(one))).then(() => this.clear());
368
500
  }
369
501
  lowerWhenStill(region) {
370
502
  void animationsFinished(this).then(() => {
@@ -407,6 +539,14 @@ let HelixHeadlessToast = class HelixHeadlessToast extends HelixElement {
407
539
  document.addEventListener('keydown', this.handleHotkey);
408
540
  document.addEventListener('keydown', this.handleUndo);
409
541
  window.addEventListener('pagehide', this.handlePageHide);
542
+ window.addEventListener('resize', this.handleResize);
543
+ for (const press of PRESSES) {
544
+ window.addEventListener(press, this.handleCoveredPress, {
545
+ capture: true,
546
+ passive: press === 'touchstart',
547
+ });
548
+ }
549
+ this.lower = keepAbove(this.raised);
410
550
  this.unregister = registerShortcut({
411
551
  keys: () => this.hotkey,
412
552
  label: () => this.hotkeyLabel,
@@ -433,6 +573,11 @@ let HelixHeadlessToast = class HelixHeadlessToast extends HelixElement {
433
573
  disconnectedCallback() {
434
574
  super.disconnectedCallback();
435
575
  this.unregister?.();
576
+ this.lower?.();
577
+ window.removeEventListener('resize', this.handleResize);
578
+ for (const press of PRESSES) {
579
+ window.removeEventListener(press, this.handleCoveredPress, { capture: true });
580
+ }
436
581
  this.keepAll();
437
582
  document.removeEventListener('keydown', this.handleUndo);
438
583
  window.removeEventListener('pagehide', this.handlePageHide);
@@ -511,6 +656,18 @@ HelixHeadlessToast = __decorate([
511
656
  customElement('helix-headless-toast')
512
657
  ], HelixHeadlessToast);
513
658
  export { HelixHeadlessToast };
659
+ const PRESSES = [
660
+ 'auxclick',
661
+ 'click',
662
+ 'contextmenu',
663
+ 'dblclick',
664
+ 'mousedown',
665
+ 'mouseup',
666
+ 'pointerdown',
667
+ 'pointerup',
668
+ 'touchend',
669
+ 'touchstart',
670
+ ];
514
671
  const isDanger = (item) => (item.tone ?? item.getAttribute('tone')) === 'danger';
515
672
  const popoverOpen = (region) => {
516
673
  try {
@@ -32,6 +32,7 @@ declare const HelixHeadlessToggle_base: (new (...args: any[]) => import("@fusion
32
32
  * @event {HelixBeforeSelectEvent} helix-before-select - Fired when the item is chosen. Cancelable: call `preventDefault()` to keep the current choice.
33
33
  *
34
34
  * @csspart item - The button: a radio in a group where one is chosen, and a button with `aria-pressed` on its own or in a group where several can be.
35
+ * @csspart label - The words, between the `start` and `end` slots.
35
36
  *
36
37
  * @cssstate pressed - The item is pressed, on its own or in a group where several can be.
37
38
  * @cssstate selected - The item is chosen.
@@ -55,7 +55,7 @@ let HelixHeadlessToggle = class HelixHeadlessToggle extends MixinSelectableItem(
55
55
  ?disabled=${this.disabled}
56
56
  tabindex=${alone || (this.focusable ?? this.selected) || !this.childrenKnown ? '0' : '-1'}
57
57
  @click=${() => this.select()}
58
- ><slot name="start"></slot><slot></slot><slot name="end"></slot></button>`;
58
+ ><slot name="start"></slot><span part="label"><slot></slot></span><slot name="end"></slot></button>`;
59
59
  }
60
60
  };
61
61
  __decorate([
@@ -103,6 +103,7 @@ declare const HelixHeadlessVideoPlaylist_base: (new (...args: any[]) => import("
103
103
  * @csspart player - The region that holds the player.
104
104
  *
105
105
  * @cssstate ended - The last entry finished and the playlist stopped there, until an entry plays again.
106
+ * @cssstate no-thumbnails - No entry has a thumbnail, from a `poster` or a slotted `media`, so the entries draw no thumbnail column.
106
107
  */
107
108
  export declare class HelixHeadlessVideoPlaylist extends HelixHeadlessVideoPlaylist_base {
108
109
  /**
@@ -293,6 +293,8 @@ let HelixHeadlessVideoPlaylist = class HelixHeadlessVideoPlaylist extends MixinC
293
293
  item.current = item === current;
294
294
  }
295
295
  this.known = { current: current?.value, values: items.map((one) => one.value) };
296
+ this.toggleState('no-thumbnails', items.length > 0 &&
297
+ !items.some((one) => one.poster !== '' || one.querySelector(':scope > [slot="media"]')));
296
298
  this.placeStop(items);
297
299
  const player = this.player;
298
300
  if (!player || !current) {
@@ -159,8 +159,8 @@ export interface VirtualListRange {
159
159
  * and `range` holds them. `helix-load-more` fires once a reader is within one
160
160
  * screen of the end, once for each length of the set: add to `items` and it can
161
161
  * fire again. While you fetch, set `loading`: the list is busy, and a row after
162
- * the last item says "Loading more" (`loading-text`, or your own content in
163
- * the `loading` slot). `scrollToIndex` takes a reader to an item.
162
+ * the last item says "Loading", the word every collection uses (`loading-text`,
163
+ * or your own content in the `loading` slot). `scrollToIndex` takes a reader to an item.
164
164
  *
165
165
  * **Moving items** is a separate import, `@fusion.dev/helix/virtual-list/reorder`,
166
166
  * as React Aria's drag and drop is. With it imported, `reorderable` lets a
@@ -28,7 +28,7 @@ let HelixHeadlessVirtualList = class HelixHeadlessVirtualList extends HelixEleme
28
28
  this.label = '';
29
29
  this.layout = 'grid';
30
30
  this.loading = false;
31
- this.loadingText = 'Loading more';
31
+ this.loadingText = 'Loading';
32
32
  this.measured = false;
33
33
  this.minColumnWidth = 0;
34
34
  this.orientation = 'vertical';