@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,10 +4,11 @@ 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 { CHART_PLOT, customElement, drawTooltip, extent, formatNumbers, HelixElement, isRtl, linear, MixinChartSource, PLOT_HEIGHT, PLOT_WIDTH, seriesIndex, ticks, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { CHART_PLOT, customElement, drawTooltip, extent, formatNumbers, HelixElement, isRtl, linear, MixinChartSource, PLOT_HEIGHT, PLOT_WIDTH, seriesIndex, seriesKey, ticks, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing, svg } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
10
|
import '../../tooltip/index.js';
|
|
11
|
+
import { correlation, leastSquares } from '../fit.js';
|
|
11
12
|
const REACH = 24;
|
|
12
13
|
const COEFFICIENTS = new Map();
|
|
13
14
|
const coefficientIn = (locale) => {
|
|
@@ -31,28 +32,13 @@ const nice = ([low, high]) => {
|
|
|
31
32
|
const round = (value) => Number(value.toPrecision(12));
|
|
32
33
|
return [round(Math.floor(low / step) * step), round(Math.ceil(high / step) * step)];
|
|
33
34
|
};
|
|
34
|
-
const correlation = (pairs) => {
|
|
35
|
-
if (pairs.length < 3) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
const mean = (values) => values.reduce((sum, one) => sum + one, 0) / values.length;
|
|
39
|
-
const across = mean(pairs.map(([x]) => x));
|
|
40
|
-
const up = mean(pairs.map(([, y]) => y));
|
|
41
|
-
let both = 0;
|
|
42
|
-
let xs = 0;
|
|
43
|
-
let ys = 0;
|
|
44
|
-
for (const [x, y] of pairs) {
|
|
45
|
-
both += (x - across) * (y - up);
|
|
46
|
-
xs += (x - across) ** 2;
|
|
47
|
-
ys += (y - up) ** 2;
|
|
48
|
-
}
|
|
49
|
-
return xs === 0 || ys === 0 ? undefined : both / Math.sqrt(xs * ys);
|
|
50
|
-
};
|
|
51
35
|
let HelixHeadlessScatterChart = class HelixHeadlessScatterChart extends MixinChartSource(HelixElement) {
|
|
52
36
|
constructor() {
|
|
53
37
|
super(...arguments);
|
|
54
38
|
this.correlationLabel = 'correlation';
|
|
55
39
|
this.pointsLabel = 'points';
|
|
40
|
+
this.sizeBy = '';
|
|
41
|
+
this.trend = false;
|
|
56
42
|
this.drawn = [];
|
|
57
43
|
this.nearest = undefined;
|
|
58
44
|
this.handleMove = (event) => {
|
|
@@ -97,8 +83,20 @@ let HelixHeadlessScatterChart = class HelixHeadlessScatterChart extends MixinCha
|
|
|
97
83
|
this.removeEventListener('pointerleave', this.handleLeave);
|
|
98
84
|
}
|
|
99
85
|
seriesOf(cell) {
|
|
100
|
-
const depth = this.
|
|
101
|
-
return depth <
|
|
86
|
+
const depth = this.measures.ups.indexOf(cell);
|
|
87
|
+
return depth < 0 ? undefined : seriesIndex(depth);
|
|
88
|
+
}
|
|
89
|
+
get measures() {
|
|
90
|
+
const rows = this.sourceRows;
|
|
91
|
+
const key = seriesKey(this.sizeBy);
|
|
92
|
+
const size = key === ''
|
|
93
|
+
? undefined
|
|
94
|
+
: this.plottedColumns.find((column) => seriesKey(rows.find((row) => row.cells[column])?.cells[column]?.name ?? '') === key);
|
|
95
|
+
const [across, ...ups] = this.plottedColumns.filter((column) => column !== size);
|
|
96
|
+
return { across, size, ups };
|
|
97
|
+
}
|
|
98
|
+
showsColumn(cell) {
|
|
99
|
+
return cell !== this.measures.size && super.showsColumn(cell);
|
|
102
100
|
}
|
|
103
101
|
get rulesX() {
|
|
104
102
|
return this.gridlines !== undefined && this.gridlines !== 'y';
|
|
@@ -108,8 +106,7 @@ let HelixHeadlessScatterChart = class HelixHeadlessScatterChart extends MixinCha
|
|
|
108
106
|
}
|
|
109
107
|
get field() {
|
|
110
108
|
const rows = this.sourceRows;
|
|
111
|
-
const
|
|
112
|
-
const [across, ...ups] = columns;
|
|
109
|
+
const { across, size, ups } = this.measures;
|
|
113
110
|
const name = (column) => column === undefined ? '' : (rows.find((row) => row.cells[column])?.cells[column]?.name ?? '');
|
|
114
111
|
const pairs = ups.map((column) => rows.flatMap((row, index) => {
|
|
115
112
|
const x = across === undefined ? undefined : row.cells[across]?.value;
|
|
@@ -122,10 +119,22 @@ let HelixHeadlessScatterChart = class HelixHeadlessScatterChart extends MixinCha
|
|
|
122
119
|
const y = nice(extent(all.length > 0 ? all.map(([, one]) => one) : [0]));
|
|
123
120
|
const along = linear(x, [0, PLOT_WIDTH]);
|
|
124
121
|
const up = linear(y, [PLOT_HEIGHT, 0]);
|
|
122
|
+
const sizes = rows.map((row) => (size === undefined ? undefined : row.cells[size]?.value));
|
|
123
|
+
const largest = Math.max(0, ...sizes.map((one) => one ?? 0));
|
|
124
|
+
const weight = (row) => {
|
|
125
|
+
const one = sizes[row];
|
|
126
|
+
return one === undefined || largest <= 0 ? undefined : Math.sqrt(Math.max(0, one) / largest);
|
|
127
|
+
};
|
|
125
128
|
return {
|
|
126
129
|
pairs: pairs.map((series) => series.map(([one, two]) => [one, two])),
|
|
127
130
|
points: pairs.flatMap((series, depth) => shown[depth]
|
|
128
|
-
? series.map(([one, two, row]) => ({
|
|
131
|
+
? series.map(([one, two, row]) => ({
|
|
132
|
+
depth,
|
|
133
|
+
row,
|
|
134
|
+
weight: weight(row),
|
|
135
|
+
x: along(one),
|
|
136
|
+
y: up(two),
|
|
137
|
+
}))
|
|
129
138
|
: []),
|
|
130
139
|
x,
|
|
131
140
|
xName: name(across),
|
|
@@ -180,6 +189,7 @@ let HelixHeadlessScatterChart = class HelixHeadlessScatterChart extends MixinCha
|
|
|
180
189
|
${this.rulesY
|
|
181
190
|
? ticks(field.y).map((level) => svg `<line part="gridline" x1="0" x2=${PLOT_WIDTH} y1=${up(level)} y2=${up(level)} />`)
|
|
182
191
|
: nothing}
|
|
192
|
+
${this.renderTrends(field, along, up)}
|
|
183
193
|
</svg>
|
|
184
194
|
${field.points.map((point) => {
|
|
185
195
|
const index = seriesIndex(point.depth);
|
|
@@ -188,12 +198,36 @@ let HelixHeadlessScatterChart = class HelixHeadlessScatterChart extends MixinCha
|
|
|
188
198
|
data-series=${index}
|
|
189
199
|
?data-active=${point.row === at}
|
|
190
200
|
part="point${point.row === at ? ' point-active' : ''}"
|
|
191
|
-
style=${`--chart-series: var(--chart-series-${index}); --chart-point-x: ${point.x}%; --chart-point-y: ${point.y}
|
|
201
|
+
style=${`--chart-series: var(--chart-series-${index}); --chart-point-x: ${point.x}%; --chart-point-y: ${point.y}%${point.weight === undefined ? '' : `; --chart-point-weight: ${point.weight}`}`}
|
|
192
202
|
></span>`;
|
|
193
203
|
})}
|
|
194
204
|
${this.renderTooltip()}
|
|
195
205
|
</div>`;
|
|
196
206
|
}
|
|
207
|
+
renderTrends(field, along, up) {
|
|
208
|
+
if (!this.trend) {
|
|
209
|
+
return nothing;
|
|
210
|
+
}
|
|
211
|
+
const [start, end] = field.x;
|
|
212
|
+
return field.yNames.flatMap((name, depth) => {
|
|
213
|
+
const fit = this.showsSeries(name) ? leastSquares(field.pairs[depth] ?? []) : undefined;
|
|
214
|
+
if (fit === undefined) {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
const index = seriesIndex(depth);
|
|
218
|
+
return [
|
|
219
|
+
svg `<line
|
|
220
|
+
data-series=${index}
|
|
221
|
+
part="trend"
|
|
222
|
+
style="--chart-series: var(--chart-series-${index})"
|
|
223
|
+
x1=${along(start)}
|
|
224
|
+
x2=${along(end)}
|
|
225
|
+
y1=${up(fit.intercept + fit.slope * start)}
|
|
226
|
+
y2=${up(fit.intercept + fit.slope * end)}
|
|
227
|
+
/>`,
|
|
228
|
+
];
|
|
229
|
+
});
|
|
230
|
+
}
|
|
197
231
|
renderSummary(field) {
|
|
198
232
|
const clauses = field.yNames.map((name, depth) => {
|
|
199
233
|
const pairs = field.pairs[depth] ?? [];
|
|
@@ -233,6 +267,12 @@ __decorate([
|
|
|
233
267
|
__decorate([
|
|
234
268
|
property({ attribute: 'points-label' })
|
|
235
269
|
], HelixHeadlessScatterChart.prototype, "pointsLabel", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
property({ attribute: 'size-by' })
|
|
272
|
+
], HelixHeadlessScatterChart.prototype, "sizeBy", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
property({ reflect: true, type: Boolean })
|
|
275
|
+
], HelixHeadlessScatterChart.prototype, "trend", void 0);
|
|
236
276
|
HelixHeadlessScatterChart = __decorate([
|
|
237
277
|
customElement('helix-headless-scatter-chart')
|
|
238
278
|
], HelixHeadlessScatterChart);
|
|
@@ -30,10 +30,20 @@ declare const EDGES: readonly ['block-start', 'block-end', 'inline-start', 'inli
|
|
|
30
30
|
* and draws the thumb from the two custom properties written on each
|
|
31
31
|
* scrollbar. An axis whose `overflow` is `hidden` gets no scrollbar.
|
|
32
32
|
*
|
|
33
|
+
* **`orientation` keeps the content to one axis.** `vertical` scrolls up and
|
|
34
|
+
* down only, and `horizontal` sideways only, so the other axis has no
|
|
35
|
+
* scrollbar, the browser's or the component's, and clips what is past it.
|
|
36
|
+
* Leave it unset to scroll both ways.
|
|
37
|
+
*
|
|
33
38
|
* The viewport's `scroll` and `scrollend` are sent again from the host, which
|
|
34
|
-
* is the element you hold.
|
|
39
|
+
* is the element you hold. A thumb dragged across the content sends one
|
|
40
|
+
* `scrollend`, once it is let go. In React, bind them with `onScroll` and
|
|
35
41
|
* `onScrollEnd`.
|
|
36
42
|
*
|
|
43
|
+
* **Keyboard.** The viewport is the tab stop while the content overflows, and
|
|
44
|
+
* the browser's scrolling keys move it: the arrow keys, Page Up and Page Down,
|
|
45
|
+
* Home and End, and Space. The scrollbars take no focus.
|
|
46
|
+
*
|
|
37
47
|
* @since 0.1.0
|
|
38
48
|
* @status stable
|
|
39
49
|
* @category layout
|
|
@@ -43,7 +53,7 @@ declare const EDGES: readonly ['block-start', 'block-end', 'inline-start', 'inli
|
|
|
43
53
|
* @slot - The content that scrolls.
|
|
44
54
|
*
|
|
45
55
|
* @event {Event} scroll - The content scrolled. Sent from the host, because the viewport's own does not leave the shadow root. Does not bubble.
|
|
46
|
-
* @event {Event} scrollend - The content stopped scrolling. Sent from the host, as `scroll` is. Does not bubble.
|
|
56
|
+
* @event {Event} scrollend - The content stopped scrolling. Sent from the host, as `scroll` is, and once for a thumb dragged across the content. Does not bubble.
|
|
47
57
|
*
|
|
48
58
|
* @csspart corner - The square where the two scrollbars meet, under `scrollbars`. Hidden unless both are drawn.
|
|
49
59
|
* @csspart edges - The layer that draws the cues on the inline start and end edges.
|
|
@@ -80,6 +90,11 @@ export declare class HelixHeadlessScrollArea extends HelixElement {
|
|
|
80
90
|
* Without one there is no region: see the note on the class.
|
|
81
91
|
*/
|
|
82
92
|
label: string;
|
|
93
|
+
/**
|
|
94
|
+
* The one axis the content scrolls along: `vertical` or `horizontal`. The
|
|
95
|
+
* other axis clips what is past it and has no scrollbar. Unset scrolls both.
|
|
96
|
+
*/
|
|
97
|
+
orientation?: 'horizontal' | 'vertical';
|
|
83
98
|
/**
|
|
84
99
|
* Draws scrollbars of the component's own in place of the browser's, and
|
|
85
100
|
* says when they show.
|
|
@@ -93,18 +108,8 @@ export declare class HelixHeadlessScrollArea extends HelixElement {
|
|
|
93
108
|
* Absent keeps the browser's scrollbars.
|
|
94
109
|
*/
|
|
95
110
|
scrollbars?: 'always' | 'auto' | 'hover' | 'scroll';
|
|
96
|
-
/**
|
|
97
|
-
private bars;
|
|
98
|
-
/** Whether the content moved, or the pointer left, within the hide delay. */
|
|
99
|
-
private active;
|
|
100
|
-
/** Whether the pointer is over the scroll area. */
|
|
101
|
-
private hovered;
|
|
102
|
-
/** Whether the pointer is over a scrollbar. */
|
|
103
|
-
private over;
|
|
104
|
-
/** The thumb being dragged, if one is. */
|
|
105
|
-
private drag;
|
|
106
|
-
/** Puts the scrollbars away once nothing has moved for the hide delay. */
|
|
107
|
-
private readonly hide;
|
|
111
|
+
/** The scrollbars drawn under `scrollbars`: what they show, when, and the drag. */
|
|
112
|
+
private readonly bars;
|
|
108
113
|
/**
|
|
109
114
|
* Which edges have content past them, measured rather than guessed.
|
|
110
115
|
*/
|
|
@@ -137,45 +142,9 @@ export declare class HelixHeadlessScrollArea extends HelixElement {
|
|
|
137
142
|
* costs.
|
|
138
143
|
*/
|
|
139
144
|
private measure;
|
|
140
|
-
/** One axis of the box, counted from its start whichever way the line runs. */
|
|
141
|
-
private extent;
|
|
142
|
-
/**
|
|
143
|
-
* Reads what each scrollbar shows off the box.
|
|
144
|
-
*
|
|
145
|
-
* An axis scrolls unless its `overflow` says it cannot. An empty reading is a
|
|
146
|
-
* harness with no layout, where the mark `core` puts on the viewport is
|
|
147
|
-
* `overflow: auto` on both axes, so it counts as one that scrolls.
|
|
148
|
-
*
|
|
149
|
-
* Written only on a change, so a scroll that moves no thumb renders nothing.
|
|
150
|
-
*/
|
|
151
|
-
private readBars;
|
|
152
|
-
/**
|
|
153
|
-
* Shows the scrollbars and starts the wait that puts them away again, under
|
|
154
|
-
* `scroll` and `hover`.
|
|
155
|
-
*/
|
|
156
|
-
private wake;
|
|
157
|
-
/** Sends the content to `offset` along an axis, counted from its start. */
|
|
158
|
-
private scrollAlong;
|
|
159
|
-
/**
|
|
160
|
-
* Takes hold of a thumb, or presses the track.
|
|
161
|
-
*
|
|
162
|
-
* A press on the track sends the thumb's middle to the press first, and the
|
|
163
|
-
* drag carries on from there, so a press and a drag are one gesture as they
|
|
164
|
-
* are on the browser's own scrollbar. `preventDefault` keeps the press from
|
|
165
|
-
* starting a text selection, and from moving focus off the viewport.
|
|
166
|
-
*/
|
|
167
|
-
private grab;
|
|
168
|
-
private readonly handleVerticalDown;
|
|
169
|
-
private readonly handleHorizontalDown;
|
|
170
|
-
/** Moves the content with a dragged thumb. Nothing while no thumb is held. */
|
|
171
|
-
private readonly handleDragMove;
|
|
172
|
-
private readonly handleDragEnd;
|
|
173
|
-
private readonly handleBarEnter;
|
|
174
|
-
private readonly handleBarLeave;
|
|
175
|
-
private readonly handleEnter;
|
|
176
|
-
private readonly handleLeave;
|
|
177
145
|
/** Measures, shows the scrollbars, and sends the event on from the host. */
|
|
178
146
|
private readonly handleScroll;
|
|
147
|
+
/** Sends the event on from the host, except the ones a thumb drag holds back. */
|
|
179
148
|
private readonly handleScrollEnd;
|
|
180
149
|
connectedCallback(): void;
|
|
181
150
|
disconnectedCallback(): void;
|
|
@@ -184,6 +153,8 @@ export declare class HelixHeadlessScrollArea extends HelixElement {
|
|
|
184
153
|
private watchContent;
|
|
185
154
|
protected updated(changed: PropertyValues): void;
|
|
186
155
|
private readonly handleSlotChange;
|
|
156
|
+
/** The axis `orientation` takes away, clipped where the content would overflow it. */
|
|
157
|
+
private get clipped();
|
|
187
158
|
protected render(): TemplateResult;
|
|
188
159
|
/**
|
|
189
160
|
* The scrollbars, the thumbs in them and the corner.
|
|
@@ -4,20 +4,22 @@ 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 {
|
|
7
|
+
import { customElement, HelixElement } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing } from 'lit';
|
|
9
9
|
import { property, state } from 'lit/decorators.js';
|
|
10
|
-
import {
|
|
10
|
+
import { ScrollbarController } from '../scrollbar-controller.js';
|
|
11
11
|
const EDGES = ['block-start', 'block-end', 'inline-start', 'inline-end'];
|
|
12
12
|
let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
15
|
this.hideDelay = 600;
|
|
16
16
|
this.label = '';
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
this.bars = new ScrollbarController(this, {
|
|
18
|
+
box: () => this.scroller,
|
|
19
|
+
hideDelay: () => this.hideDelay,
|
|
20
|
+
mode: () => this.scrollbars,
|
|
21
|
+
scrollEnd: () => this.dispatchEvent(new Event('scrollend')),
|
|
22
|
+
});
|
|
21
23
|
this.more = [];
|
|
22
24
|
this.scrolls = false;
|
|
23
25
|
this.measure = () => {
|
|
@@ -26,72 +28,39 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
30
|
const slack = 1;
|
|
31
|
+
const block = this.orientation !== 'horizontal';
|
|
32
|
+
const inline = this.orientation !== 'vertical';
|
|
29
33
|
const found = [];
|
|
30
|
-
if (box.scrollTop > slack) {
|
|
34
|
+
if (block && box.scrollTop > slack) {
|
|
31
35
|
found.push('block-start');
|
|
32
36
|
}
|
|
33
|
-
if (box.scrollTop + box.clientHeight < box.scrollHeight - slack) {
|
|
37
|
+
if (block && box.scrollTop + box.clientHeight < box.scrollHeight - slack) {
|
|
34
38
|
found.push('block-end');
|
|
35
39
|
}
|
|
36
40
|
const along = Math.abs(box.scrollLeft);
|
|
37
|
-
if (along > slack) {
|
|
41
|
+
if (inline && along > slack) {
|
|
38
42
|
found.push('inline-start');
|
|
39
43
|
}
|
|
40
|
-
if (along + box.clientWidth < box.scrollWidth - slack) {
|
|
44
|
+
if (inline && along + box.clientWidth < box.scrollWidth - slack) {
|
|
41
45
|
found.push('inline-end');
|
|
42
46
|
}
|
|
43
47
|
this.more = found;
|
|
44
|
-
this.scrolls =
|
|
48
|
+
this.scrolls =
|
|
49
|
+
(block && box.scrollHeight > box.clientHeight) ||
|
|
50
|
+
(inline && box.scrollWidth > box.clientWidth);
|
|
45
51
|
if (this.scrollbars) {
|
|
46
|
-
this.
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
this.handleVerticalDown = (event) => {
|
|
50
|
-
this.grab(event, 'vertical');
|
|
51
|
-
};
|
|
52
|
-
this.handleHorizontalDown = (event) => {
|
|
53
|
-
this.grab(event, 'horizontal');
|
|
54
|
-
};
|
|
55
|
-
this.handleDragMove = (event) => {
|
|
56
|
-
const drag = this.drag;
|
|
57
|
-
const box = this.scroller;
|
|
58
|
-
if (!drag || !box) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const pointer = drag.axis === 'vertical' ? event.clientY : event.clientX;
|
|
62
|
-
this.scrollAlong(box, drag.axis, drag.from + (pointer - drag.pointer) * drag.sign * drag.perPixel);
|
|
63
|
-
};
|
|
64
|
-
this.handleDragEnd = () => {
|
|
65
|
-
if (!this.drag) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.drag = undefined;
|
|
69
|
-
this.wake();
|
|
70
|
-
this.requestUpdate();
|
|
71
|
-
};
|
|
72
|
-
this.handleBarEnter = () => {
|
|
73
|
-
this.over = true;
|
|
74
|
-
};
|
|
75
|
-
this.handleBarLeave = () => {
|
|
76
|
-
this.over = false;
|
|
77
|
-
this.wake();
|
|
78
|
-
};
|
|
79
|
-
this.handleEnter = () => {
|
|
80
|
-
this.hovered = true;
|
|
81
|
-
};
|
|
82
|
-
this.handleLeave = () => {
|
|
83
|
-
this.hovered = false;
|
|
84
|
-
if (this.scrollbars === 'hover') {
|
|
85
|
-
this.wake();
|
|
52
|
+
this.bars.read(box);
|
|
86
53
|
}
|
|
87
54
|
};
|
|
88
55
|
this.handleScroll = (event) => {
|
|
89
56
|
this.measure();
|
|
90
|
-
this.wake();
|
|
57
|
+
this.bars.wake();
|
|
91
58
|
this.relayNativeEvent(event);
|
|
92
59
|
};
|
|
93
60
|
this.handleScrollEnd = (event) => {
|
|
94
|
-
this.
|
|
61
|
+
if (!this.bars.holdsScrollEnd()) {
|
|
62
|
+
this.relayNativeEvent(event);
|
|
63
|
+
}
|
|
95
64
|
};
|
|
96
65
|
this.handleSlotChange = (event) => {
|
|
97
66
|
const slot = event.target;
|
|
@@ -104,84 +73,8 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
104
73
|
get scroller() {
|
|
105
74
|
return this.partNamed('viewport');
|
|
106
75
|
}
|
|
107
|
-
extent(box, axis) {
|
|
108
|
-
return axis === 'vertical'
|
|
109
|
-
? { client: box.clientHeight, offset: box.scrollTop, scroll: box.scrollHeight }
|
|
110
|
-
: { client: box.clientWidth, offset: Math.abs(box.scrollLeft), scroll: box.scrollWidth };
|
|
111
|
-
}
|
|
112
|
-
readBars(box) {
|
|
113
|
-
const mode = this.scrollbars ?? 'auto';
|
|
114
|
-
const style = getComputedStyle(box);
|
|
115
|
-
const bar = (axis, overflow) => {
|
|
116
|
-
const extent = this.extent(box, axis);
|
|
117
|
-
return {
|
|
118
|
-
along: scrollFraction(extent),
|
|
119
|
-
drawn: hasScrollbar(mode, !['clip', 'hidden', 'visible'].includes(overflow), extent.offset > 1 || extent.client < extent.scroll - 1),
|
|
120
|
-
thumb: thumbFraction(extent),
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
const next = {
|
|
124
|
-
horizontal: bar('horizontal', style.overflowX),
|
|
125
|
-
vertical: bar('vertical', style.overflowY),
|
|
126
|
-
};
|
|
127
|
-
if (JSON.stringify(next) !== JSON.stringify(this.bars)) {
|
|
128
|
-
this.bars = next;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
wake() {
|
|
132
|
-
if (this.scrollbars !== 'scroll' && this.scrollbars !== 'hover') {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
this.active = true;
|
|
136
|
-
this.hide.start(this.hideDelay, () => {
|
|
137
|
-
this.active = false;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
scrollAlong(box, axis, offset) {
|
|
141
|
-
box.scrollTo(axis === 'vertical'
|
|
142
|
-
? { behavior: 'instant', top: offset }
|
|
143
|
-
: { behavior: 'instant', left: isRtl(box) ? -offset : offset });
|
|
144
|
-
}
|
|
145
|
-
grab(event, axis) {
|
|
146
|
-
const box = this.scroller;
|
|
147
|
-
const bar = event.currentTarget;
|
|
148
|
-
const thumb = bar.querySelector('[part~="thumb"]');
|
|
149
|
-
if (event.button !== 0 || !box || !thumb) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
event.preventDefault();
|
|
153
|
-
const vertical = axis === 'vertical';
|
|
154
|
-
const rtl = !vertical && isRtl(box);
|
|
155
|
-
const track = bar.getBoundingClientRect();
|
|
156
|
-
const held = thumb.getBoundingClientRect();
|
|
157
|
-
const length = vertical ? track.height : track.width;
|
|
158
|
-
const size = vertical ? held.height : held.width;
|
|
159
|
-
const extent = this.extent(box, axis);
|
|
160
|
-
const pointer = vertical ? event.clientY : event.clientX;
|
|
161
|
-
let from = extent.offset;
|
|
162
|
-
if (!thumb.contains(event.target)) {
|
|
163
|
-
const along = vertical
|
|
164
|
-
? pointer - track.top
|
|
165
|
-
: rtl
|
|
166
|
-
? track.right - pointer
|
|
167
|
-
: pointer - track.left;
|
|
168
|
-
from = offsetAt(extent, along, length, size);
|
|
169
|
-
this.scrollAlong(box, axis, from);
|
|
170
|
-
}
|
|
171
|
-
this.drag = {
|
|
172
|
-
axis,
|
|
173
|
-
from,
|
|
174
|
-
perPixel: scrollPerPixel(extent, length, size),
|
|
175
|
-
pointer,
|
|
176
|
-
sign: rtl ? -1 : 1,
|
|
177
|
-
};
|
|
178
|
-
capturePointer(bar, event.pointerId);
|
|
179
|
-
this.requestUpdate();
|
|
180
|
-
}
|
|
181
76
|
connectedCallback() {
|
|
182
77
|
super.connectedCallback();
|
|
183
|
-
this.addEventListener('pointerenter', this.handleEnter);
|
|
184
|
-
this.addEventListener('pointerleave', this.handleLeave);
|
|
185
78
|
this.watcher = new ResizeObserver(this.measure);
|
|
186
79
|
if (this.hasUpdated) {
|
|
187
80
|
this.watchContent();
|
|
@@ -189,14 +82,8 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
189
82
|
}
|
|
190
83
|
disconnectedCallback() {
|
|
191
84
|
super.disconnectedCallback();
|
|
192
|
-
this.removeEventListener('pointerenter', this.handleEnter);
|
|
193
|
-
this.removeEventListener('pointerleave', this.handleLeave);
|
|
194
85
|
this.watcher?.disconnect();
|
|
195
86
|
this.watcher = undefined;
|
|
196
|
-
this.drag = undefined;
|
|
197
|
-
this.active = false;
|
|
198
|
-
this.hovered = false;
|
|
199
|
-
this.over = false;
|
|
200
87
|
}
|
|
201
88
|
firstUpdated(changed) {
|
|
202
89
|
super.firstUpdated?.(changed);
|
|
@@ -217,10 +104,13 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
217
104
|
}
|
|
218
105
|
updated(changed) {
|
|
219
106
|
super.updated?.(changed);
|
|
220
|
-
if (changed.has('
|
|
107
|
+
if (changed.has('orientation') && this.hasUpdated) {
|
|
108
|
+
this.measure();
|
|
109
|
+
}
|
|
110
|
+
else if (changed.has('scrollbars') && this.scrollbars) {
|
|
221
111
|
const box = this.scroller;
|
|
222
112
|
if (box) {
|
|
223
|
-
this.
|
|
113
|
+
this.bars.read(box);
|
|
224
114
|
}
|
|
225
115
|
}
|
|
226
116
|
this.toggleState('scrolls', this.scrolls);
|
|
@@ -228,14 +118,21 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
228
118
|
this.toggleState('more-block-end', this.more.includes('block-end'));
|
|
229
119
|
this.toggleState('more-inline-start', this.more.includes('inline-start'));
|
|
230
120
|
this.toggleState('more-inline-end', this.more.includes('inline-end'));
|
|
231
|
-
const drawn = this.scrollbars ? this.bars : undefined;
|
|
121
|
+
const drawn = this.scrollbars ? this.bars.bars : undefined;
|
|
232
122
|
this.toggleState('scrollbar-horizontal', drawn?.horizontal.drawn === true);
|
|
233
123
|
this.toggleState('scrollbar-vertical', drawn?.vertical.drawn === true);
|
|
234
124
|
}
|
|
125
|
+
get clipped() {
|
|
126
|
+
if (this.orientation === 'vertical') {
|
|
127
|
+
return 'overflow-x: hidden';
|
|
128
|
+
}
|
|
129
|
+
return this.orientation === 'horizontal' ? 'overflow-y: hidden' : nothing;
|
|
130
|
+
}
|
|
235
131
|
render() {
|
|
236
132
|
return html `<div
|
|
237
133
|
data-scroller
|
|
238
134
|
part="viewport"
|
|
135
|
+
style=${this.clipped}
|
|
239
136
|
role=${this.label ? 'region' : nothing}
|
|
240
137
|
aria-label=${this.label || nothing}
|
|
241
138
|
tabindex=${this.scrolls ? '0' : nothing}
|
|
@@ -252,16 +149,12 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
252
149
|
<div
|
|
253
150
|
part="edges"
|
|
254
151
|
aria-hidden="true"
|
|
255
|
-
></div>${this.scrollbars ? this.renderScrollbars(
|
|
152
|
+
></div>${this.scrollbars ? this.renderScrollbars() : nothing}`;
|
|
256
153
|
}
|
|
257
|
-
renderScrollbars(
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
held: this.over || this.drag !== undefined,
|
|
262
|
-
hovered: this.hovered,
|
|
263
|
-
};
|
|
264
|
-
const shown = showsScrollbar(mode, moment);
|
|
154
|
+
renderScrollbars() {
|
|
155
|
+
const controller = this.bars;
|
|
156
|
+
const bars = controller.bars;
|
|
157
|
+
const shown = controller.shown;
|
|
265
158
|
const facts = (bar) => bar
|
|
266
159
|
? `--scroll-area-thumb-fraction: ${bar.thumb}; --scroll-area-scroll-fraction: ${bar.along}`
|
|
267
160
|
: nothing;
|
|
@@ -272,13 +165,13 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
272
165
|
aria-hidden="true"
|
|
273
166
|
?hidden=${!vertical}
|
|
274
167
|
style=${facts(bars?.vertical)}
|
|
275
|
-
@pointerdown=${
|
|
276
|
-
@pointermove=${
|
|
277
|
-
@pointerup=${
|
|
278
|
-
@pointercancel=${
|
|
279
|
-
@lostpointercapture=${
|
|
280
|
-
@pointerenter=${
|
|
281
|
-
@pointerleave=${
|
|
168
|
+
@pointerdown=${controller.handleVerticalDown}
|
|
169
|
+
@pointermove=${controller.handleDragMove}
|
|
170
|
+
@pointerup=${controller.handleDragEnd}
|
|
171
|
+
@pointercancel=${controller.handleDragEnd}
|
|
172
|
+
@lostpointercapture=${controller.handleDragEnd}
|
|
173
|
+
@pointerenter=${controller.handleBarEnter}
|
|
174
|
+
@pointerleave=${controller.handleBarLeave}
|
|
282
175
|
>
|
|
283
176
|
<div part="thumb thumb-vertical"></div>
|
|
284
177
|
</div>
|
|
@@ -287,13 +180,13 @@ let HelixHeadlessScrollArea = class HelixHeadlessScrollArea extends HelixElement
|
|
|
287
180
|
aria-hidden="true"
|
|
288
181
|
?hidden=${!horizontal}
|
|
289
182
|
style=${facts(bars?.horizontal)}
|
|
290
|
-
@pointerdown=${
|
|
291
|
-
@pointermove=${
|
|
292
|
-
@pointerup=${
|
|
293
|
-
@pointercancel=${
|
|
294
|
-
@lostpointercapture=${
|
|
295
|
-
@pointerenter=${
|
|
296
|
-
@pointerleave=${
|
|
183
|
+
@pointerdown=${controller.handleHorizontalDown}
|
|
184
|
+
@pointermove=${controller.handleDragMove}
|
|
185
|
+
@pointerup=${controller.handleDragEnd}
|
|
186
|
+
@pointercancel=${controller.handleDragEnd}
|
|
187
|
+
@lostpointercapture=${controller.handleDragEnd}
|
|
188
|
+
@pointerenter=${controller.handleBarEnter}
|
|
189
|
+
@pointerleave=${controller.handleBarLeave}
|
|
297
190
|
>
|
|
298
191
|
<div part="thumb thumb-horizontal"></div>
|
|
299
192
|
</div>
|
|
@@ -310,21 +203,12 @@ __decorate([
|
|
|
310
203
|
__decorate([
|
|
311
204
|
property()
|
|
312
205
|
], HelixHeadlessScrollArea.prototype, "label", void 0);
|
|
206
|
+
__decorate([
|
|
207
|
+
property()
|
|
208
|
+
], HelixHeadlessScrollArea.prototype, "orientation", void 0);
|
|
313
209
|
__decorate([
|
|
314
210
|
property({ reflect: true })
|
|
315
211
|
], HelixHeadlessScrollArea.prototype, "scrollbars", void 0);
|
|
316
|
-
__decorate([
|
|
317
|
-
state()
|
|
318
|
-
], HelixHeadlessScrollArea.prototype, "bars", void 0);
|
|
319
|
-
__decorate([
|
|
320
|
-
state()
|
|
321
|
-
], HelixHeadlessScrollArea.prototype, "active", void 0);
|
|
322
|
-
__decorate([
|
|
323
|
-
state()
|
|
324
|
-
], HelixHeadlessScrollArea.prototype, "hovered", void 0);
|
|
325
|
-
__decorate([
|
|
326
|
-
state()
|
|
327
|
-
], HelixHeadlessScrollArea.prototype, "over", void 0);
|
|
328
212
|
__decorate([
|
|
329
213
|
state()
|
|
330
214
|
], HelixHeadlessScrollArea.prototype, "more", void 0);
|