@fusion.dev/helix-headless 0.145.0 → 0.147.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.
- package/custom-elements.json +12286 -4281
- package/dist/accordion/item/accordion-item.d.ts +51 -18
- package/dist/accordion/item/accordion-item.js +45 -13
- package/dist/accordion/root/accordion-root.d.ts +16 -7
- package/dist/accordion/root/accordion-root.js +3 -3
- package/dist/announcement/root/announcement-root.d.ts +16 -6
- package/dist/announcement/root/announcement-root.js +37 -7
- package/dist/app-header/root/app-header-root.d.ts +7 -2
- package/dist/app-header/root/app-header-root.js +9 -1
- package/dist/app-header/sectioning.d.ts +3 -1
- package/dist/app-header/sectioning.js +3 -2
- package/dist/area-chart/root/area-chart-root.d.ts +18 -1
- package/dist/area-chart/root/area-chart-root.js +11 -3
- package/dist/avatar/group/avatar-group.d.ts +20 -14
- package/dist/avatar/group/avatar-group.js +17 -19
- package/dist/avatar/root/avatar-root.d.ts +31 -1
- package/dist/avatar/root/avatar-root.js +11 -1
- package/dist/badge/root/badge-root.d.ts +60 -7
- package/dist/badge/root/badge-root.js +89 -6
- package/dist/bar-chart/root/bar-chart-root.d.ts +18 -1
- package/dist/bar-chart/root/bar-chart-root.js +48 -20
- package/dist/bar-chart/stack.d.ts +25 -0
- package/dist/bar-chart/stack.js +27 -0
- package/dist/breadcrumbs/breadcrumb/breadcrumb.d.ts +14 -0
- package/dist/breadcrumbs/breadcrumb/breadcrumb.js +12 -2
- package/dist/breadcrumbs/root/breadcrumbs-root.d.ts +25 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.js +51 -4
- package/dist/button/root/button-root.d.ts +50 -38
- package/dist/button/root/button-root.js +42 -53
- package/dist/button/submitter.d.ts +27 -0
- package/dist/button/submitter.js +25 -0
- package/dist/button-group/root/button-group-root.d.ts +2 -1
- package/dist/button-group/root/button-group-root.js +5 -1
- package/dist/canvas/node/canvas-node.d.ts +4 -3
- package/dist/canvas/node/canvas-node.js +3 -2
- package/dist/canvas/root/canvas-root.js +2 -2
- package/dist/card/root/card-root.d.ts +36 -4
- package/dist/card/root/card-root.js +29 -10
- package/dist/carousel/root/carousel-root.d.ts +43 -4
- package/dist/carousel/root/carousel-root.js +40 -12
- package/dist/carousel/stops.d.ts +20 -0
- package/dist/carousel/stops.js +30 -0
- package/dist/chat/message/chat-message.js +5 -4
- package/dist/chat/naming.d.ts +5 -1
- package/dist/chat/naming.js +4 -2
- package/dist/chat/root/chat-root.d.ts +40 -4
- package/dist/chat/root/chat-root.js +32 -6
- package/dist/checkbox/root/checkbox-root.d.ts +20 -0
- package/dist/checkbox/root/checkbox-root.js +18 -7
- package/dist/checkbox-group/root/checkbox-group-root.d.ts +8 -2
- package/dist/checkbox-group/root/checkbox-group-root.js +14 -11
- package/dist/checkbox-group/select-all.d.ts +21 -0
- package/dist/checkbox-group/select-all.js +7 -0
- package/dist/code-block/highlight.d.ts +15 -0
- package/dist/code-block/highlight.js +4 -0
- package/dist/code-block/root/code-block-root.d.ts +79 -10
- package/dist/code-block/root/code-block-root.js +74 -5
- package/dist/color-input/root/color-input-root.d.ts +14 -0
- package/dist/color-input/root/color-input-root.js +17 -7
- package/dist/color-picker/channels.js +1 -2
- package/dist/color-picker/root/color-picker-root.d.ts +53 -16
- package/dist/color-picker/root/color-picker-root.js +155 -46
- package/dist/color-picker/wheel.d.ts +17 -0
- package/dist/color-picker/wheel.js +6 -0
- package/dist/combobox/root/combobox-root.d.ts +56 -0
- package/dist/combobox/root/combobox-root.js +92 -15
- package/dist/command/root/command-root.d.ts +19 -2
- package/dist/command/root/command-root.js +24 -23
- package/dist/copy-button/root/copy-button-root.d.ts +21 -1
- package/dist/copy-button/root/copy-button-root.js +16 -4
- package/dist/data-table/index.d.ts +1 -1
- package/dist/data-table/index.js +1 -1
- package/dist/data-table/keys.d.ts +6 -0
- package/dist/data-table/keys.js +14 -0
- package/dist/data-table/root/data-table-root.d.ts +27 -18
- package/dist/data-table/root/data-table-root.js +31 -57
- package/dist/data-table/tree.d.ts +16 -1
- package/dist/data-table/tree.js +2 -3
- package/dist/date-input/root/date-input-root.d.ts +11 -2
- package/dist/date-input/root/date-input-root.js +26 -12
- package/dist/date-picker/root/date-picker-root.d.ts +14 -9
- package/dist/date-picker/root/date-picker-root.js +33 -22
- package/dist/description-list/item/description-list-item.d.ts +18 -4
- package/dist/description-list/item/description-list-item.js +8 -4
- package/dist/dialog/description.js +15 -1
- package/dist/dialog/root/dialog-root.d.ts +8 -2
- package/dist/dialog/root/dialog-root.js +16 -1
- package/dist/divider/root/divider-root.d.ts +3 -0
- package/dist/divider/root/divider-root.js +2 -1
- package/dist/donut-chart/root/donut-chart-root.d.ts +31 -0
- package/dist/donut-chart/root/donut-chart-root.js +55 -1
- package/dist/donut-chart/slice-label.d.ts +35 -0
- package/dist/donut-chart/slice-label.js +11 -0
- package/dist/drawer/reveal.d.ts +8 -0
- package/dist/drawer/reveal.js +1 -0
- package/dist/drawer/root/drawer-root.d.ts +63 -2
- package/dist/drawer/root/drawer-root.js +75 -4
- package/dist/drilldown/item/drilldown-item.d.ts +21 -1
- package/dist/drilldown/item/drilldown-item.js +40 -5
- package/dist/drilldown/root/drilldown-root.d.ts +21 -3
- package/dist/drilldown/root/drilldown-root.js +22 -3
- package/dist/element-events.generated.js +35 -6
- package/dist/empty/root/empty-root.d.ts +34 -2
- package/dist/empty/root/empty-root.js +26 -4
- package/dist/file-input/root/file-input-root.d.ts +99 -8
- package/dist/file-input/root/file-input-root.js +120 -22
- package/dist/file-input/screen.d.ts +2 -1
- package/dist/file-input/status.d.ts +24 -0
- package/dist/file-input/status.js +10 -0
- package/dist/filter-input/chip/filter-chip.d.ts +23 -0
- package/dist/filter-input/chip/filter-chip.js +11 -2
- package/dist/filter-input/menu/filter-menu.d.ts +2 -0
- package/dist/filter-input/menu/filter-menu.js +12 -4
- package/dist/filter-input/root/filter-input-root.d.ts +38 -6
- package/dist/filter-input/root/filter-input-root.js +18 -28
- package/dist/filter-input/suggest.d.ts +28 -3
- package/dist/filter-input/suggest.js +18 -8
- package/dist/format-date/options.d.ts +3 -4
- package/dist/format-date/options.js +2 -2
- package/dist/format-date/root/format-date-root.d.ts +27 -17
- package/dist/format-date/root/format-date-root.js +27 -48
- package/dist/heatmap/root/buckets.d.ts +21 -0
- package/dist/heatmap/root/buckets.js +34 -0
- package/dist/heatmap/root/heatmap-root.d.ts +83 -11
- package/dist/heatmap/root/heatmap-root.js +104 -12
- package/dist/icon/index.d.ts +1 -1
- package/dist/icon/index.js +1 -1
- package/dist/icon/registry.d.ts +26 -1
- package/dist/icon/registry.js +12 -1
- package/dist/icon/root/icon-root.d.ts +25 -1
- package/dist/icon/root/icon-root.js +44 -12
- package/dist/icon/root/index.d.ts +1 -1
- package/dist/icon/root/index.js +1 -1
- package/dist/icon/settle.d.ts +7 -0
- package/dist/icon/settle.js +10 -0
- package/dist/icon-button/root/icon-button-root.d.ts +2 -0
- package/dist/image/root/image-root.d.ts +14 -1
- package/dist/image/root/image-root.js +7 -2
- package/dist/input/root/input-root.d.ts +34 -3
- package/dist/input/root/input-root.js +17 -4
- package/dist/kbd/keys.d.ts +29 -0
- package/dist/kbd/keys.js +52 -0
- package/dist/kbd/root/kbd-root.d.ts +52 -1
- package/dist/kbd/root/kbd-root.js +40 -47
- package/dist/legend/hidden-series.d.ts +10 -2
- package/dist/legend/hidden-series.js +5 -2
- package/dist/legend/root/legend-root.d.ts +77 -12
- package/dist/legend/root/legend-root.js +71 -17
- package/dist/lightbox/root/lightbox-root.d.ts +98 -10
- package/dist/lightbox/root/lightbox-root.js +153 -18
- package/dist/lightbox/zoom-controller.d.ts +59 -0
- package/dist/lightbox/zoom-controller.js +128 -0
- package/dist/lightbox/zoom.d.ts +24 -0
- package/dist/lightbox/zoom.js +18 -0
- package/dist/line-chart/root/line-chart-root.d.ts +38 -1
- package/dist/line-chart/root/line-chart-root.js +31 -3
- package/dist/list/item/list-item.d.ts +2 -0
- package/dist/list/item/list-item.js +11 -2
- package/dist/list/root/list-root.d.ts +70 -13
- package/dist/list/root/list-root.js +91 -13
- package/dist/list/selection.d.ts +54 -7
- package/dist/list/selection.js +32 -7
- package/dist/listbox/root/listbox-root.d.ts +44 -4
- package/dist/listbox/root/listbox-root.js +72 -34
- package/dist/loader/busy.d.ts +10 -0
- package/dist/loader/busy.js +11 -0
- package/dist/loader/root/loader-root.d.ts +9 -2
- package/dist/loader/root/loader-root.js +23 -3
- package/dist/megamenu/hand-over.d.ts +75 -0
- package/dist/megamenu/hand-over.js +67 -0
- package/dist/megamenu/root/megamenu-root.d.ts +80 -15
- package/dist/megamenu/root/megamenu-root.js +76 -19
- package/dist/menu/item/menu-item.d.ts +51 -2
- package/dist/menu/item/menu-item.js +50 -26
- package/dist/menu/root/menu-root.d.ts +17 -0
- package/dist/menu/root/menu-root.js +2 -2
- package/dist/meter/root/meter-root.d.ts +62 -1
- package/dist/meter/root/meter-root.js +38 -16
- package/dist/navigation/root/navigation-root.d.ts +2 -1
- package/dist/navigation/root/navigation-root.js +2 -2
- package/dist/notifications/root/notifications-root.d.ts +20 -4
- package/dist/notifications/root/notifications-root.js +30 -8
- package/dist/number-input/grain.d.ts +28 -0
- package/dist/number-input/grain.js +14 -0
- package/dist/number-input/root/number-input-root.d.ts +34 -9
- package/dist/number-input/root/number-input-root.js +31 -25
- package/dist/object-inspector/root/object-inspector-root.d.ts +88 -33
- package/dist/object-inspector/root/object-inspector-root.js +134 -92
- package/dist/object-inspector/rows.d.ts +18 -0
- package/dist/object-inspector/rows.js +33 -0
- package/dist/option/index.d.ts +1 -0
- package/dist/option/index.js +1 -0
- package/dist/option/root/option-root.d.ts +5 -3
- package/dist/option/separator/option-separator.d.ts +30 -0
- package/dist/option/separator/option-separator.js +21 -0
- package/dist/outline/root/outline-root.d.ts +30 -0
- package/dist/outline/root/outline-root.js +17 -13
- package/dist/pagination/size/pagination-size.d.ts +6 -0
- package/dist/pagination/size/pagination-size.js +5 -3
- package/dist/pin-input/code.d.ts +37 -0
- package/dist/pin-input/code.js +25 -0
- package/dist/pin-input/root/pin-input-root.d.ts +116 -115
- package/dist/pin-input/root/pin-input-root.js +163 -155
- package/dist/popover/hide-outside.d.ts +14 -0
- package/dist/popover/hide-outside.js +34 -0
- package/dist/popover/root/popover-root.d.ts +64 -8
- package/dist/popover/root/popover-root.js +67 -4
- package/dist/progress/root/progress-root.d.ts +47 -0
- package/dist/progress/root/progress-root.js +34 -16
- package/dist/qr-code/export.d.ts +45 -1
- package/dist/qr-code/export.js +28 -0
- package/dist/qr-code/name.d.ts +11 -0
- package/dist/qr-code/name.js +7 -0
- package/dist/qr-code/root/qr-code-root.d.ts +36 -11
- package/dist/qr-code/root/qr-code-root.js +58 -11
- package/dist/quote/marks.d.ts +8 -0
- package/dist/quote/marks.js +5 -0
- package/dist/quote/root/quote-root.d.ts +14 -2
- package/dist/quote/root/quote-root.js +23 -1
- package/dist/radio/group/radio-group.d.ts +15 -0
- package/dist/radio/root/radio-root.d.ts +6 -2
- package/dist/radio/root/radio-root.js +7 -2
- package/dist/rating/root/rating-root.d.ts +30 -12
- package/dist/rating/root/rating-root.js +27 -27
- package/dist/scatter-chart/fit.d.ts +15 -0
- package/dist/scatter-chart/fit.js +35 -0
- package/dist/scatter-chart/root/scatter-chart-root.d.ts +51 -1
- package/dist/scatter-chart/root/scatter-chart-root.js +64 -24
- package/dist/scroll-area/root/scroll-area-root.d.ts +22 -51
- package/dist/scroll-area/root/scroll-area-root.js +57 -173
- package/dist/scroll-area/scrollbar-controller.d.ts +111 -0
- package/dist/scroll-area/scrollbar-controller.js +172 -0
- package/dist/scroll-area/scrollbar.d.ts +27 -8
- package/dist/scroll-area/scrollbar.js +10 -1
- package/dist/select/align.d.ts +47 -0
- package/dist/select/align.js +7 -0
- package/dist/select/root/select-root.d.ts +71 -0
- package/dist/select/root/select-root.js +78 -6
- package/dist/skeleton/root/skeleton-root.d.ts +3 -0
- package/dist/skeleton/root/skeleton-root.js +4 -2
- package/dist/skip-link/root/skip-link-root.js +2 -2
- package/dist/slider/root/slider-root.d.ts +59 -5
- package/dist/slider/root/slider-root.js +45 -3
- package/dist/sparkline/readings.d.ts +36 -0
- package/dist/sparkline/readings.js +36 -0
- package/dist/sparkline/root/sparkline-root.d.ts +121 -7
- package/dist/sparkline/root/sparkline-root.js +160 -26
- package/dist/speed-dial/item/speed-dial-item.d.ts +1 -1
- package/dist/speed-dial/item/speed-dial-item.js +2 -2
- package/dist/speed-dial/root/speed-dial-root.d.ts +6 -0
- package/dist/speed-dial/root/speed-dial-root.js +11 -3
- package/dist/splitter/root/splitter-root.d.ts +10 -12
- package/dist/splitter/root/splitter-root.js +211 -204
- package/dist/stat/root/stat-root.d.ts +14 -5
- package/dist/stat/root/stat-root.js +21 -5
- package/dist/steps/reach.d.ts +5 -0
- package/dist/steps/reach.js +3 -0
- package/dist/steps/root/steps-root.d.ts +56 -3
- package/dist/steps/root/steps-root.js +50 -6
- package/dist/steps/step/step.d.ts +8 -0
- package/dist/steps/step/step.js +8 -3
- package/dist/switch/root/switch-root.d.ts +10 -0
- package/dist/table/column/table-column.d.ts +6 -10
- package/dist/table/column/table-column.js +8 -20
- package/dist/table/root/table-root.d.ts +31 -10
- package/dist/table/root/table-root.js +14 -18
- package/dist/table/row/table-row.d.ts +24 -0
- package/dist/table/row/table-row.js +37 -1
- package/dist/tabs/panel/tab-panel.d.ts +16 -3
- package/dist/tabs/panel/tab-panel.js +34 -5
- package/dist/tabs/root/tabs-root.d.ts +17 -3
- package/dist/tabs/root/tabs-root.js +1 -1
- package/dist/tabs/tab/tab.d.ts +5 -0
- package/dist/tabs/tab/tab.js +5 -2
- package/dist/tag/group/tag-group.d.ts +44 -5
- package/dist/tag/group/tag-group.js +60 -9
- package/dist/tag/root/tag-root.js +9 -2
- package/dist/textarea/root/textarea-root.d.ts +41 -2
- package/dist/textarea/root/textarea-root.js +39 -1
- package/dist/time-input/root/time-input-root.d.ts +10 -2
- package/dist/time-input/root/time-input-root.js +24 -13
- package/dist/time-picker/root/time-picker-root.d.ts +28 -17
- package/dist/time-picker/root/time-picker-root.js +18 -29
- package/dist/time-picker/wheel-name.d.ts +9 -0
- package/dist/time-picker/wheel-name.js +15 -0
- package/dist/timeline/group/timeline-group.js +2 -2
- package/dist/toast/item/toast-item.d.ts +16 -3
- package/dist/toast/item/toast-item.js +22 -6
- package/dist/toast/root/toast-root.d.ts +34 -4
- package/dist/toast/root/toast-root.js +74 -13
- package/dist/toast/words.d.ts +12 -0
- package/dist/toast/words.js +25 -0
- package/dist/toggle/group/toggle-group.d.ts +52 -7
- package/dist/toggle/group/toggle-group.js +58 -44
- package/dist/toggle/root/toggle-root.js +2 -4
- package/dist/toolbar/root/toolbar-root.d.ts +21 -5
- package/dist/toolbar/root/toolbar-root.js +52 -8
- package/dist/tooltip/root/tooltip-root.d.ts +20 -3
- package/dist/tooltip/root/tooltip-root.js +18 -1
- package/dist/tour/back.d.ts +10 -0
- package/dist/tour/back.js +8 -0
- package/dist/tour/root/tour-root.d.ts +45 -2
- package/dist/tour/root/tour-root.js +53 -8
- package/dist/tour/stop/tour-stop.d.ts +3 -0
- package/dist/tour/stop/tour-stop.js +3 -3
- package/dist/tree/item/tree-item.d.ts +7 -3
- package/dist/tree/item/tree-item.js +3 -0
- package/dist/tree/root/tree-root.d.ts +24 -3
- package/dist/tree/root/tree-root.js +32 -13
- package/dist/tree/selection.js +2 -15
- package/dist/trend/figure.d.ts +16 -0
- package/dist/trend/figure.js +8 -0
- package/dist/trend/root/trend-root.d.ts +83 -19
- package/dist/trend/root/trend-root.js +59 -8
- package/dist/video/media-events.d.ts +13 -18
- package/dist/video/media-events.js +1 -5
- package/dist/video/root/extra-controls.d.ts +12 -0
- package/dist/video/root/extra-controls.js +6 -2
- package/dist/video/root/video-root.d.ts +23 -6
- package/dist/video/root/video-root.js +19 -10
- package/dist/video-playlist/menu/video-playlist-menu.d.ts +2 -0
- package/dist/video-playlist/menu/video-playlist-menu.js +2 -1
- package/dist/video-playlist/root/video-playlist-root.d.ts +17 -1
- package/dist/video-playlist/root/video-playlist-root.js +3 -0
- package/dist/virtual-list/fill.d.ts +11 -8
- package/dist/virtual-list/fill.js +10 -17
- package/dist/virtual-list/keys.d.ts +16 -7
- package/dist/virtual-list/keys.js +17 -6
- package/dist/virtual-list/plan.d.ts +65 -0
- package/dist/virtual-list/plan.js +27 -0
- package/dist/virtual-list/root/virtual-list-root.d.ts +136 -13
- package/dist/virtual-list/root/virtual-list-root.js +218 -51
- package/lint.json +1 -1
- package/package.json +8 -8
- package/types/jsx.d.ts +7441 -1458
- package/types/svelte.d.ts +1 -0
- package/types/vue.d.ts +1501 -326
- package/dist/chat/relative-clock.d.ts +0 -39
- package/dist/chat/relative-clock.js +0 -31
- package/dist/data-table/root/order.d.ts +0 -141
- package/dist/data-table/root/order.js +0 -76
- package/dist/tag/selection.d.ts +0 -10
- package/dist/tag/selection.js +0 -12
|
@@ -4,14 +4,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { byRow, CHART_PLOT, customElement, drawTooltip, extent, formatNumbers, HelixElement, linear, linePath, MixinChartSource, PLOT_HEIGHT, PLOT_WIDTH, seriesIndex, seriesNames, ticks, unbroken, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { byRow, CHART_PLOT, customElement, drawTooltip, extent, formatNumbers, HelixElement, linear, linePath, MixinChartSource, PLOT_HEIGHT, PLOT_WIDTH, seriesIndex, seriesKey, seriesNames, ticks, unbroken, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing, svg } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
|
+
import { stackEnds, stackedReadings, stackSpans } from '../stack.js';
|
|
10
11
|
import '../../tooltip/index.js';
|
|
11
12
|
let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartSource(HelixElement) {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
14
15
|
this.highestLabel = 'Highest';
|
|
16
|
+
this.stacked = false;
|
|
15
17
|
}
|
|
16
18
|
get scaled() {
|
|
17
19
|
return new Set(seriesNames(this.secondary));
|
|
@@ -36,11 +38,15 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartSource
|
|
|
36
38
|
return html `<div id=${CHART_PLOT} part="plot"></div>`;
|
|
37
39
|
}
|
|
38
40
|
const scaled = this.scaled;
|
|
39
|
-
const own = (one) => scaled.has(one.name
|
|
41
|
+
const own = (one) => scaled.has(seriesKey(one.name));
|
|
40
42
|
const shown = series.filter((one) => this.showsSeries(one.name));
|
|
41
43
|
const values = shown.flatMap((one) => one.points.map((point) => point.value));
|
|
44
|
+
const lined = this.lined;
|
|
45
|
+
const readingsOf = (group) => this.stacked
|
|
46
|
+
? stackedReadings(group, categories.length, (one) => lined.has(seriesKey(one.name)))
|
|
47
|
+
: group.flatMap((one) => one.points.map((point) => point.value));
|
|
42
48
|
const on = (which) => {
|
|
43
|
-
const found = shown.filter(which)
|
|
49
|
+
const found = readingsOf(shown.filter(which));
|
|
44
50
|
return found.length > 0 ? found : values.length > 0 ? values : [0];
|
|
45
51
|
};
|
|
46
52
|
const [low, high] = extent(scaled.size === 0 ? on(() => true) : on((one) => !own(one)));
|
|
@@ -66,7 +72,7 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartSource
|
|
|
66
72
|
const columns = this.plottedColumns;
|
|
67
73
|
const highest = series.flatMap((one, depth) => {
|
|
68
74
|
const top = one.points.reduce((best, point) => (best === undefined || point.value > best.value ? point : best), undefined);
|
|
69
|
-
if (top === undefined) {
|
|
75
|
+
if (top === undefined || !this.showsSeries(one.name)) {
|
|
70
76
|
return [];
|
|
71
77
|
}
|
|
72
78
|
const text = rows[top.at]?.cells[columns[depth] ?? -1]?.text ?? String(top.value);
|
|
@@ -80,18 +86,20 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartSource
|
|
|
80
86
|
const slot = 100 / categories.length;
|
|
81
87
|
const lined = this.lined;
|
|
82
88
|
const scaled = this.scaled;
|
|
83
|
-
const own = (one) => scaled.has(one.name
|
|
89
|
+
const own = (one) => scaled.has(seriesKey(one.name));
|
|
84
90
|
const against = (one) => z !== undefined && own(one) ? z : y;
|
|
85
91
|
const columns = series
|
|
86
92
|
.map((one, index) => ({ one, slots: byRow(one, categories.length), tone: index }))
|
|
87
|
-
.filter(({ one }) => !lined.has(one.name
|
|
88
|
-
const
|
|
89
|
-
const
|
|
93
|
+
.filter(({ one }) => !lined.has(seriesKey(one.name)) && this.showsSeries(one.name));
|
|
94
|
+
const abreast = this.stacked ? 1 : columns.length;
|
|
95
|
+
const stride = (slot * 0.72) / Math.max(abreast, 1);
|
|
96
|
+
const gap = abreast > 1 ? stride * 0.08 : 0;
|
|
90
97
|
const thickness = stride - gap;
|
|
91
|
-
const bar = (value, index, depth, tone, scale) => {
|
|
98
|
+
const bar = (value, index, depth, tone, scale, from) => {
|
|
92
99
|
const at = scale(value);
|
|
93
|
-
const
|
|
94
|
-
const
|
|
100
|
+
const base = from === undefined ? floor : scale(from);
|
|
101
|
+
const along = Math.min(base, at);
|
|
102
|
+
const size = Math.abs(base - at);
|
|
95
103
|
const across = index * slot + slot * 0.14 + depth * stride + gap / 2;
|
|
96
104
|
return sideways
|
|
97
105
|
? svg `<rect
|
|
@@ -151,20 +159,33 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartSource
|
|
|
151
159
|
data-active=${this.pointer.at === index ? '' : nothing}
|
|
152
160
|
part="group${this.pointer.at === index ? ' group-active' : ''}"
|
|
153
161
|
>
|
|
154
|
-
${
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
${this.stacked
|
|
163
|
+
? this.renderStack(columns, index, against, bar)
|
|
164
|
+
: columns.map(({ slots, one, tone }, depth) => {
|
|
165
|
+
const point = slots[index];
|
|
166
|
+
return point === undefined
|
|
167
|
+
? nothing
|
|
168
|
+
: bar(point.value, index, depth, tone, against(one));
|
|
169
|
+
})}
|
|
160
170
|
</g>`)}
|
|
161
|
-
${series.map((one) => lined.has(one.name
|
|
171
|
+
${series.map((one) => lined.has(seriesKey(one.name)) && this.showsSeries(one.name)
|
|
162
172
|
? this.renderLine(one, series.indexOf(one), slot, against(one), sideways)
|
|
163
173
|
: nothing)}
|
|
164
174
|
</svg>
|
|
165
175
|
${this.renderTooltip()}
|
|
166
176
|
</div>`;
|
|
167
177
|
}
|
|
178
|
+
renderStack(columns, index, against, bar) {
|
|
179
|
+
const scales = [...new Set(columns.map(({ one }) => against(one)))];
|
|
180
|
+
return scales.flatMap((scale) => {
|
|
181
|
+
const mine = columns.filter(({ one }) => against(one) === scale);
|
|
182
|
+
const spans = stackSpans(mine.map(({ slots }) => slots[index]?.value));
|
|
183
|
+
return mine.flatMap(({ tone }, place) => {
|
|
184
|
+
const span = spans[place];
|
|
185
|
+
return span === undefined ? [] : [bar(span[1], index, 0, tone, scale, span[0])];
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
168
189
|
renderAxis(scale, domain, which, sideways, widest, tint) {
|
|
169
190
|
const sizing = sideways ? undefined : `--bar-chart-axis: ${widest}ch`;
|
|
170
191
|
return html `<div
|
|
@@ -234,10 +255,14 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartSource
|
|
|
234
255
|
return drawTooltip(this.sourceRows, at, this.tag('tooltip'), undefined, undefined, this.pointer);
|
|
235
256
|
}
|
|
236
257
|
const shown = series.filter((one) => this.showsSeries(one.name));
|
|
237
|
-
const
|
|
258
|
+
const reached = shown
|
|
238
259
|
.map((one) => byRow(one, this.readings)[at]?.value)
|
|
239
260
|
.filter((one) => one !== undefined);
|
|
240
|
-
const
|
|
261
|
+
const values = this.stacked ? stackEnds([reached]) : reached;
|
|
262
|
+
const lined = this.lined;
|
|
263
|
+
const all = this.stacked
|
|
264
|
+
? stackedReadings(shown, this.readings, (one) => lined.has(seriesKey(one.name)))
|
|
265
|
+
: shown.flatMap((one) => one.points.map((point) => point.value));
|
|
241
266
|
const [low, high] = extent(all.length > 0 ? all : [0]);
|
|
242
267
|
const domain = [Math.min(0, low), Math.max(0, high)];
|
|
243
268
|
const sideways = this.orientation === 'horizontal';
|
|
@@ -268,6 +293,9 @@ __decorate([
|
|
|
268
293
|
__decorate([
|
|
269
294
|
property({ reflect: true })
|
|
270
295
|
], HelixHeadlessBarChart.prototype, "secondary", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
property({ reflect: true, type: Boolean })
|
|
298
|
+
], HelixHeadlessBarChart.prototype, "stacked", void 0);
|
|
271
299
|
HelixHeadlessBarChart = __decorate([
|
|
272
300
|
customElement('helix-headless-bar-chart')
|
|
273
301
|
], HelixHeadlessBarChart);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Series } from '@fusion.dev/helix-core';
|
|
2
|
+
/** Where a column starts and ends along the measure, in the data's own units. */
|
|
3
|
+
export type Span = readonly [from: number, to: number];
|
|
4
|
+
/**
|
|
5
|
+
* Each column's span in one category, in the order given: a positive reading
|
|
6
|
+
* stacks up from zero on the positives before it, and a negative one down
|
|
7
|
+
* from zero on the negatives before it, so neither hides the other. A blank
|
|
8
|
+
* has no span.
|
|
9
|
+
*/
|
|
10
|
+
export declare const stackSpans: (values: readonly (number | undefined)[]) => (Span | undefined)[];
|
|
11
|
+
/**
|
|
12
|
+
* Every end a stack reaches across the categories, which is what its scale
|
|
13
|
+
* has to hold: the top of each stack of positives and the foot of each stack
|
|
14
|
+
* of negatives. `categories` holds each category's readings, one per column.
|
|
15
|
+
*/
|
|
16
|
+
export declare const stackEnds: (categories: readonly (readonly (number | undefined)[])[]) => number[];
|
|
17
|
+
/**
|
|
18
|
+
* The readings a stacked scale has to hold, over `count` categories: every
|
|
19
|
+
* reading of a series drawn as a line, which `lined` says, and the top and
|
|
20
|
+
* foot of each category's stack of the others.
|
|
21
|
+
*
|
|
22
|
+
* The plot's scale and the tooltip's placing ask the same question, and
|
|
23
|
+
* answered apart they disagreed about the lines.
|
|
24
|
+
*/
|
|
25
|
+
export declare const stackedReadings: (group: readonly Series[], count: number, lined: (one: Series) => boolean) => number[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { byRow } from '@fusion.dev/helix-core';
|
|
2
|
+
export const stackSpans = (values) => {
|
|
3
|
+
let up = 0;
|
|
4
|
+
let down = 0;
|
|
5
|
+
return values.map((value) => {
|
|
6
|
+
if (value === undefined) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const from = value >= 0 ? up : down;
|
|
10
|
+
const to = from + value;
|
|
11
|
+
if (value >= 0) {
|
|
12
|
+
up = to;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
down = to;
|
|
16
|
+
}
|
|
17
|
+
return [from, to];
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export const stackEnds = (categories) => categories.flatMap((values) => stackSpans(values).flatMap((span) => (span === undefined ? [] : [span[1]])));
|
|
21
|
+
export const stackedReadings = (group, count, lined) => {
|
|
22
|
+
const slots = group.filter((one) => !lined(one)).map((one) => byRow(one, count));
|
|
23
|
+
return [
|
|
24
|
+
...group.filter(lined).flatMap((one) => one.points.map((point) => point.value)),
|
|
25
|
+
...stackEnds(Array.from({ length: count }, (_, at) => slots.map((one) => one[at]?.value))),
|
|
26
|
+
];
|
|
27
|
+
};
|
|
@@ -37,6 +37,9 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
37
37
|
* @csspart link - The crumb itself, which is an `<a>` where `href` is set.
|
|
38
38
|
* @csspart separator - The separator preceding the item.
|
|
39
39
|
* @csspart separator-mark - The chevron between crumbs, shown when no separator is slotted.
|
|
40
|
+
*
|
|
41
|
+
* @cssstate end - While the `end` slot holds something, so a stylesheet can join
|
|
42
|
+
* the label and what follows it into one control.
|
|
40
43
|
*/
|
|
41
44
|
export declare class HelixHeadlessBreadcrumb extends HelixElement {
|
|
42
45
|
/**
|
|
@@ -74,6 +77,17 @@ export declare class HelixHeadlessBreadcrumb extends HelixElement {
|
|
|
74
77
|
*/
|
|
75
78
|
target: string;
|
|
76
79
|
protected willUpdate(changed: PropertyValues): void;
|
|
80
|
+
protected updated(changed: PropertyValues): void;
|
|
81
|
+
/**
|
|
82
|
+
* Says whether anything sits after the label.
|
|
83
|
+
*
|
|
84
|
+
* A switcher's trigger in `end` makes the crumb a split control, and its
|
|
85
|
+
* label is drawn as the first half of it. No selector can ask a slot what was
|
|
86
|
+
* assigned to it, so this is script. Answered from a DOM, so the server
|
|
87
|
+
* writes the resting answer and the first client update corrects it.
|
|
88
|
+
*/
|
|
89
|
+
private markEnd;
|
|
90
|
+
private readonly handleEnd;
|
|
77
91
|
/**
|
|
78
92
|
* The mark between one crumb and the next.
|
|
79
93
|
*
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { customElement, HelixElement, hostAria } from '@fusion.dev/helix-core';
|
|
7
|
+
import { customElement, HelixElement, hostAria, slotFilled } from '@fusion.dev/helix-core';
|
|
8
8
|
import { caretRight } from '@fusion.dev/helix-icons';
|
|
9
9
|
import { html, nothing } from 'lit';
|
|
10
10
|
import { property } from 'lit/decorators.js';
|
|
@@ -15,12 +15,22 @@ let HelixHeadlessBreadcrumb = class HelixHeadlessBreadcrumb extends HelixElement
|
|
|
15
15
|
this.current = false;
|
|
16
16
|
this.rel = '';
|
|
17
17
|
this.target = '';
|
|
18
|
+
this.handleEnd = () => {
|
|
19
|
+
this.markEnd();
|
|
20
|
+
};
|
|
18
21
|
}
|
|
19
22
|
willUpdate(changed) {
|
|
20
23
|
super.willUpdate(changed);
|
|
21
24
|
hostAria(this.internals, { role: 'listitem' });
|
|
22
25
|
this.internals.ariaCurrent = this.current ? 'page' : null;
|
|
23
26
|
}
|
|
27
|
+
updated(changed) {
|
|
28
|
+
super.updated(changed);
|
|
29
|
+
this.markEnd();
|
|
30
|
+
}
|
|
31
|
+
markEnd() {
|
|
32
|
+
this.toggleState('end', slotFilled(this.renderRoot?.querySelector('slot[name="end"]')));
|
|
33
|
+
}
|
|
24
34
|
renderSeparator() {
|
|
25
35
|
return html `<slot name="separator"
|
|
26
36
|
><svg part="separator-mark" data-mirror fill="currentColor" viewBox=${caretRight.viewBox}>
|
|
@@ -41,7 +51,7 @@ let HelixHeadlessBreadcrumb = class HelixHeadlessBreadcrumb extends HelixElement
|
|
|
41
51
|
rel=${this.rel || nothing}
|
|
42
52
|
>${label}</a
|
|
43
53
|
>`
|
|
44
|
-
: html `<span part="link">${label}</span>`}<slot name="end"></slot>`;
|
|
54
|
+
: html `<span part="link">${label}</span>`}<slot name="end" @slotchange=${this.handleEnd}></slot>`;
|
|
45
55
|
}
|
|
46
56
|
};
|
|
47
57
|
__decorate([
|
|
@@ -35,6 +35,12 @@ export interface BreadcrumbItem {
|
|
|
35
35
|
* array of `{ label, href }`, drawn as crumbs in order, the last one as the
|
|
36
36
|
* current page. Slotted crumbs follow them. Use one way or the other in a trail.
|
|
37
37
|
*
|
|
38
|
+
* With `max-items`, a trail drawn from `items` that is longer folds its middle
|
|
39
|
+
* into one crumb: the first crumb, a button, then the last `max-items` less one.
|
|
40
|
+
* The button is named by `expand-label` and shows the whole trail, moving focus
|
|
41
|
+
* to the first crumb it brought back. A new `items` folds again. Slotted crumbs
|
|
42
|
+
* do not fold; write the folded crumb where the gap should be.
|
|
43
|
+
*
|
|
38
44
|
* @since 0.1.0
|
|
39
45
|
* @status stable
|
|
40
46
|
* @category navigation
|
|
@@ -45,13 +51,20 @@ export interface BreadcrumbItem {
|
|
|
45
51
|
* the crumb that holds the folded items where the gap should appear.
|
|
46
52
|
*
|
|
47
53
|
* @csspart crumb - Each crumb drawn from `items`.
|
|
54
|
+
* @csspart crumb-collapsed - The crumb that holds the folded middle of a trail longer than `max-items`.
|
|
48
55
|
* @csspart crumb-current - The crumb drawn from `items` for the current page.
|
|
49
56
|
* @csspart crumb-link - The link, or the current page's words, of a crumb drawn from `items`.
|
|
50
57
|
* @csspart crumb-separator - The separator before a crumb drawn from `items`.
|
|
51
58
|
* @csspart crumb-separator-mark - The chevron before a crumb drawn from `items`.
|
|
59
|
+
* @csspart expand - The button in the folded crumb that shows the whole trail.
|
|
52
60
|
* @csspart list - The ordered list.
|
|
53
61
|
*/
|
|
54
62
|
export declare class HelixHeadlessBreadcrumbs extends HelixElement {
|
|
63
|
+
/**
|
|
64
|
+
* The name of the button that shows a folded trail's hidden crumbs. `{count}`
|
|
65
|
+
* is replaced by how many it shows. Translate it with the page.
|
|
66
|
+
*/
|
|
67
|
+
expandLabel: string;
|
|
55
68
|
/**
|
|
56
69
|
* The trail as data, drawn as crumbs before any you slot. The last item is the
|
|
57
70
|
* current page.
|
|
@@ -65,7 +78,19 @@ export declare class HelixHeadlessBreadcrumbs extends HelixElement {
|
|
|
65
78
|
* wins over it.
|
|
66
79
|
*/
|
|
67
80
|
label: string;
|
|
81
|
+
/**
|
|
82
|
+
* The most crumbs a trail drawn from `items` shows before it folds its middle
|
|
83
|
+
* into one, counting the first and the last. Unset, it never folds. At least
|
|
84
|
+
* 2, so the first crumb and the current page always show.
|
|
85
|
+
*/
|
|
86
|
+
maxItems?: number;
|
|
87
|
+
/** Whether a reader has asked to see the whole of a folded trail. */
|
|
88
|
+
private expanded;
|
|
89
|
+
/** Shows the whole trail and moves focus to the first crumb it brought back. */
|
|
90
|
+
private readonly expand;
|
|
68
91
|
protected willUpdate(changed: PropertyValues): void;
|
|
92
|
+
/** How many crumbs drawn from `items` are folded away, or 0. */
|
|
93
|
+
private get folded();
|
|
69
94
|
/** The crumbs `items` describes, each a crumb of this tier. */
|
|
70
95
|
protected renderItems(): TemplateResult | typeof nothing;
|
|
71
96
|
protected render(): TemplateResult;
|
|
@@ -4,21 +4,38 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { customElement, HelixElement, hostAria } from '@fusion.dev/helix-core';
|
|
7
|
+
import { customElement, fillTemplate, HelixElement, hostAria } from '@fusion.dev/helix-core';
|
|
8
8
|
import { nothing } from 'lit';
|
|
9
|
-
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import { repeat } from 'lit/directives/repeat.js';
|
|
11
11
|
import { html } from 'lit/static-html.js';
|
|
12
12
|
import '../breadcrumb/breadcrumb.js';
|
|
13
13
|
let HelixHeadlessBreadcrumbs = class HelixHeadlessBreadcrumbs extends HelixElement {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
|
+
this.expandLabel = 'Show {count} more';
|
|
16
17
|
this.items = [];
|
|
17
18
|
this.label = 'Breadcrumb';
|
|
19
|
+
this.expanded = false;
|
|
20
|
+
this.expand = () => {
|
|
21
|
+
this.expanded = true;
|
|
22
|
+
this.updateComplete.then(() => {
|
|
23
|
+
const crumb = this.renderRoot.querySelectorAll('[part~="crumb"]')[1];
|
|
24
|
+
crumb?.shadowRoot?.querySelector('a, [part="link"]')?.focus();
|
|
25
|
+
});
|
|
26
|
+
};
|
|
18
27
|
}
|
|
19
28
|
willUpdate(changed) {
|
|
20
29
|
super.willUpdate(changed);
|
|
21
30
|
hostAria(this.internals, { label: this.label, role: 'navigation' });
|
|
31
|
+
if (changed.has('items') && changed.get('items') !== undefined) {
|
|
32
|
+
this.expanded = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
get folded() {
|
|
36
|
+
const most = this.maxItems ?? 0;
|
|
37
|
+
const count = this.items.length;
|
|
38
|
+
return !this.expanded && most >= 2 && count > most ? count - most : 0;
|
|
22
39
|
}
|
|
23
40
|
renderItems() {
|
|
24
41
|
if (this.items.length === 0) {
|
|
@@ -26,7 +43,27 @@ let HelixHeadlessBreadcrumbs = class HelixHeadlessBreadcrumbs extends HelixEleme
|
|
|
26
43
|
}
|
|
27
44
|
const crumb = this.tag('breadcrumb');
|
|
28
45
|
const last = this.items.length - 1;
|
|
29
|
-
|
|
46
|
+
const folded = this.folded;
|
|
47
|
+
const shown = this.items
|
|
48
|
+
.map((item, index) => ({ index, item }))
|
|
49
|
+
.filter(({ index }) => folded === 0 || index === 0 || index > folded);
|
|
50
|
+
const fold = folded === 0
|
|
51
|
+
? nothing
|
|
52
|
+
: html `<${crumb}
|
|
53
|
+
part="crumb crumb-collapsed"
|
|
54
|
+
exportparts="link: crumb-link, separator: crumb-separator, separator-mark: crumb-separator-mark"
|
|
55
|
+
><button
|
|
56
|
+
part="expand"
|
|
57
|
+
type="button"
|
|
58
|
+
aria-label=${fillTemplate(this.expandLabel, { count: String(folded) })}
|
|
59
|
+
@click=${this.expand}
|
|
60
|
+
>
|
|
61
|
+
…
|
|
62
|
+
</button></${crumb}
|
|
63
|
+
>`;
|
|
64
|
+
const first = shown.slice(0, 1);
|
|
65
|
+
const rest = shown.slice(1);
|
|
66
|
+
const draw = ({ index, item }) => html `<${crumb}
|
|
30
67
|
part="crumb${index === last ? ' crumb-current' : ''}"
|
|
31
68
|
exportparts="link: crumb-link, separator: crumb-separator, separator-mark: crumb-separator-mark"
|
|
32
69
|
href=${index === last ? nothing : (item.href ?? nothing)}
|
|
@@ -34,7 +71,8 @@ let HelixHeadlessBreadcrumbs = class HelixHeadlessBreadcrumbs extends HelixEleme
|
|
|
34
71
|
target=${item.target ?? nothing}
|
|
35
72
|
?current=${index === last}
|
|
36
73
|
>${item.label}</${crumb}
|
|
37
|
-
|
|
74
|
+
>`;
|
|
75
|
+
return html `${repeat(first, ({ index }) => index, draw)}${fold}${repeat(rest, ({ index }) => index, draw)}`;
|
|
38
76
|
}
|
|
39
77
|
render() {
|
|
40
78
|
return html `<ol part="list" role="list">
|
|
@@ -42,12 +80,21 @@ let HelixHeadlessBreadcrumbs = class HelixHeadlessBreadcrumbs extends HelixEleme
|
|
|
42
80
|
</ol>`;
|
|
43
81
|
}
|
|
44
82
|
};
|
|
83
|
+
__decorate([
|
|
84
|
+
property({ attribute: 'expand-label' })
|
|
85
|
+
], HelixHeadlessBreadcrumbs.prototype, "expandLabel", void 0);
|
|
45
86
|
__decorate([
|
|
46
87
|
property({ attribute: false })
|
|
47
88
|
], HelixHeadlessBreadcrumbs.prototype, "items", void 0);
|
|
48
89
|
__decorate([
|
|
49
90
|
property()
|
|
50
91
|
], HelixHeadlessBreadcrumbs.prototype, "label", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ attribute: 'max-items', type: Number })
|
|
94
|
+
], HelixHeadlessBreadcrumbs.prototype, "maxItems", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
state()
|
|
97
|
+
], HelixHeadlessBreadcrumbs.prototype, "expanded", void 0);
|
|
51
98
|
HelixHeadlessBreadcrumbs = __decorate([
|
|
52
99
|
customElement('helix-headless-breadcrumbs')
|
|
53
100
|
], HelixHeadlessBreadcrumbs);
|
|
@@ -18,13 +18,12 @@ import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
|
18
18
|
*
|
|
19
19
|
* The inner control is always `type="button"`, because a
|
|
20
20
|
* `<button type="submit">` inside a shadow root cannot submit a form outside
|
|
21
|
-
* it. To submit, the button
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* submit buttons apart.
|
|
21
|
+
* it. To submit, the button puts a hidden native submit button carrying its
|
|
22
|
+
* `name`, `value` and `form*` overrides into the form, calls
|
|
23
|
+
* `requestSubmit()` with it, which runs validation, unlike `submit()`, and
|
|
24
|
+
* takes it out again, as Shoelace and Web Awesome do. A `submit` listener
|
|
25
|
+
* reads that button as `event.submitter`, so `event.submitter.value` and
|
|
26
|
+
* `new FormData(form, event.submitter)` tell two submit buttons apart.
|
|
28
27
|
*
|
|
29
28
|
* As the first submit button in its form, it is the form's default button:
|
|
30
29
|
* Enter in a text field of the form presses it, as it presses a native one.
|
|
@@ -32,6 +31,15 @@ import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
|
32
31
|
* Set `pending` while the action a press started is still running. The button
|
|
33
32
|
* keeps focus and refuses presses, and a reader on it hears `pending-label`.
|
|
34
33
|
*
|
|
34
|
+
* Every press that acts sends `helix-press` with what pressed it in
|
|
35
|
+
* `detail.pointerType`: `mouse`, `pen`, `touch`, `keyboard`, or `virtual` for
|
|
36
|
+
* a screen reader's press or a script's `click()`, as React Aria's `onPress`
|
|
37
|
+
* does. It is sent once the press has done its own work, before `click`
|
|
38
|
+
* reaches listeners on the element, and never for a disabled or pending
|
|
39
|
+
* button.
|
|
40
|
+
*
|
|
41
|
+
* **Keyboard.** Enter and Space press the button, as on a native one.
|
|
42
|
+
*
|
|
35
43
|
* @since 0.1.0
|
|
36
44
|
* @status stable
|
|
37
45
|
* @category actions
|
|
@@ -41,8 +49,11 @@ import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
|
41
49
|
* @slot end - Content after the label.
|
|
42
50
|
* @slot start - Content before the label, usually an icon.
|
|
43
51
|
*
|
|
52
|
+
* @event {HelixPressEvent} helix-press - Fired when a press acts, with `detail.pointerType` saying what pressed the button.
|
|
53
|
+
*
|
|
44
54
|
* @csspart button - The inner control.
|
|
45
55
|
* @csspart live - The live region that says `pending-label` when the button becomes pending under focus. It is rendered from the first time the button is pending, and the styled button clips it out of view.
|
|
56
|
+
* @csspart spinner - The ring a pending button turns, an empty element the styled button draws over the words. It is rendered only while the button is pending.
|
|
46
57
|
* @csspart text - The button's words, which the styled button trims to their capitals and baseline so the letters sit at the middle in any font.
|
|
47
58
|
*
|
|
48
59
|
* @cssstate pending - The button is pending: `pending` is set.
|
|
@@ -124,18 +135,13 @@ export declare class HelixHeadlessButton extends HelixFormElement {
|
|
|
124
135
|
/**
|
|
125
136
|
* Where this button's submission goes, overriding the form's own.
|
|
126
137
|
*
|
|
127
|
-
* **The five `form*` overrides
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* The whole submit algorithm runs synchronously inside `requestSubmit()`, so
|
|
136
|
-
* the window is one call and a `finally` closes it whether or not a listener
|
|
137
|
-
* refused. What a `submit` handler observes during that window is the form a
|
|
138
|
-
* native submitter would have given it, which is the point.
|
|
138
|
+
* **The five `form*` overrides ride on a native submit button that stands in
|
|
139
|
+
* for this one**, because `requestSubmit(submitter)` refuses the inner
|
|
140
|
+
* `<button>` twice over: it is `type="button"`, and it sits in this shadow
|
|
141
|
+
* root, so its form owner is not the consumer's form. The stand-in is a
|
|
142
|
+
* hidden `<button type="submit">` in the form for the one synchronous call,
|
|
143
|
+
* so the platform applies the overrides to that submission alone and leaves
|
|
144
|
+
* the form as it was. See `submitAs`.
|
|
139
145
|
*/
|
|
140
146
|
formAction: string;
|
|
141
147
|
/**
|
|
@@ -214,7 +220,22 @@ export declare class HelixHeadlessButton extends HelixFormElement {
|
|
|
214
220
|
protected renderLive(): TemplateResult | typeof nothing;
|
|
215
221
|
/** Moves focus to the inner control, so the host is never the focus target. */
|
|
216
222
|
static shadowRootOptions: ShadowRootInit;
|
|
223
|
+
/** What the control saw before a click that the click may not carry. */
|
|
224
|
+
private recent;
|
|
225
|
+
/**
|
|
226
|
+
* @internal Records what starts a press, a pointer's kind or Enter or Space,
|
|
227
|
+
* for `helix-press`. Bound on the inner control by this render and by any
|
|
228
|
+
* subclass that draws its own.
|
|
229
|
+
*/
|
|
230
|
+
protected readonly notePress: (event: Event) => void;
|
|
231
|
+
/**
|
|
232
|
+
* @internal Sends `helix-press` for a click that acted, with what pressed it,
|
|
233
|
+
* and forgets what started it.
|
|
234
|
+
*/
|
|
235
|
+
protected announcePress(click: Event): void;
|
|
217
236
|
private readonly handleClick;
|
|
237
|
+
/** What a press does: sends the command, and submits or resets the form. */
|
|
238
|
+
private act;
|
|
218
239
|
/**
|
|
219
240
|
* What activating the button does to its form.
|
|
220
241
|
*/
|
|
@@ -223,13 +244,10 @@ export declare class HelixHeadlessButton extends HelixFormElement {
|
|
|
223
244
|
* The value this button submits under its own `name`, as a native submit
|
|
224
245
|
* button does.
|
|
225
246
|
*
|
|
226
|
-
* **
|
|
247
|
+
* **Sent with exactly the submission this button starts and not otherwise.**
|
|
227
248
|
* A native submit button contributes `name=value` only when it is the one
|
|
228
|
-
* that submitted, and every other button on the form contributes nothing
|
|
229
|
-
*
|
|
230
|
-
* every submission whoever started it, which is a different feature wearing
|
|
231
|
-
* the same name, so `submit` below sets it, submits, and clears it inside one
|
|
232
|
-
* synchronous call.
|
|
249
|
+
* that submitted, and every other button on the form contributes nothing,
|
|
250
|
+
* which is what the native button standing in for this one at submit does.
|
|
233
251
|
*
|
|
234
252
|
* `CopyButton` has a `value` of its own meaning the text to put on the
|
|
235
253
|
* clipboard, which is not this and is why it is declared there rather than
|
|
@@ -237,19 +255,8 @@ export declare class HelixHeadlessButton extends HelixFormElement {
|
|
|
237
255
|
*/
|
|
238
256
|
value: string;
|
|
239
257
|
/**
|
|
240
|
-
* Submits the form as this button,
|
|
241
|
-
*
|
|
242
|
-
* Everything a native submitter carries is written onto the form, the
|
|
243
|
-
* submission is started, and everything is put back. See `formAction` for why
|
|
244
|
-
* `requestSubmit(submitter)` is not available to a control inside a shadow
|
|
245
|
-
* root.
|
|
246
|
-
*
|
|
247
|
-
* `novalidate` is in the same list rather than reached by `form.submit()`,
|
|
248
|
-
* which looks like the shortcut and is not: `submit()` skips the `submit`
|
|
249
|
-
* event as well as the validation, so a consumer's handler would stop running
|
|
250
|
-
* the moment somebody wrote `formnovalidate`. Turning the flag on and calling
|
|
251
|
-
* `requestSubmit()` skips the validation alone, which is what the attribute
|
|
252
|
-
* means.
|
|
258
|
+
* Submits the form as this button, through a native submit button carrying
|
|
259
|
+
* its name, value and overrides. See `formAction`.
|
|
253
260
|
*/
|
|
254
261
|
private submit;
|
|
255
262
|
/**
|
|
@@ -320,6 +327,11 @@ export declare class HelixHeadlessButton extends HelixFormElement {
|
|
|
320
327
|
/** Called by the browser when the button's form changes. */
|
|
321
328
|
formAssociatedCallback(form: HTMLFormElement | null): void;
|
|
322
329
|
protected render(): TemplateResult;
|
|
330
|
+
/**
|
|
331
|
+
* The ring a pending button turns, behind a seam a tier can move: an empty
|
|
332
|
+
* element, hidden from a screen reader, which hears `pending-label` instead.
|
|
333
|
+
*/
|
|
334
|
+
protected renderSpinner(): TemplateResult | typeof nothing;
|
|
323
335
|
}
|
|
324
336
|
declare global {
|
|
325
337
|
interface HTMLElementTagNameMap {
|