snice 4.8.0 → 4.9.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/adapters/react/camera-annotate.d.ts +27 -0
- package/adapters/react/camera-annotate.d.ts.map +1 -0
- package/adapters/react/camera-annotate.js +24 -0
- package/adapters/react/camera-annotate.js.map +1 -0
- package/adapters/react/camera-annotate.tsx +35 -0
- package/adapters/react/candlestick.d.ts +34 -0
- package/adapters/react/candlestick.d.ts.map +1 -0
- package/adapters/react/candlestick.js +24 -0
- package/adapters/react/candlestick.js.map +1 -0
- package/adapters/react/candlestick.tsx +42 -0
- package/adapters/react/components.d.ts +14 -0
- package/adapters/react/components.d.ts.map +1 -1
- package/adapters/react/components.js +7 -0
- package/adapters/react/components.js.map +1 -1
- package/adapters/react/components.ts +14 -0
- package/adapters/react/funnel.d.ts +31 -0
- package/adapters/react/funnel.d.ts.map +1 -0
- package/adapters/react/funnel.js +24 -0
- package/adapters/react/funnel.js.map +1 -0
- package/adapters/react/funnel.tsx +39 -0
- package/adapters/react/network-graph.d.ts +32 -0
- package/adapters/react/network-graph.d.ts.map +1 -0
- package/adapters/react/network-graph.js +24 -0
- package/adapters/react/network-graph.js.map +1 -0
- package/adapters/react/network-graph.tsx +40 -0
- package/adapters/react/sankey.d.ts +31 -0
- package/adapters/react/sankey.d.ts.map +1 -0
- package/adapters/react/sankey.js +24 -0
- package/adapters/react/sankey.js.map +1 -0
- package/adapters/react/sankey.tsx +39 -0
- package/adapters/react/time-range-picker.d.ts +33 -0
- package/adapters/react/time-range-picker.d.ts.map +1 -0
- package/adapters/react/time-range-picker.js +24 -0
- package/adapters/react/time-range-picker.js.map +1 -0
- package/adapters/react/time-range-picker.tsx +41 -0
- package/adapters/react/treemap.d.ts +30 -0
- package/adapters/react/treemap.d.ts.map +1 -0
- package/adapters/react/treemap.js +24 -0
- package/adapters/react/treemap.js.map +1 -0
- package/adapters/react/treemap.tsx +38 -0
- package/adapters/react/virtual-scroller.d.ts +1 -0
- package/adapters/react/virtual-scroller.d.ts.map +1 -1
- package/adapters/react/virtual-scroller.js +1 -1
- package/adapters/react/virtual-scroller.js.map +1 -1
- package/adapters/react/virtual-scroller.tsx +2 -1
- package/dist/cdn/accordion/snice-accordion.js +1 -1
- package/dist/cdn/accordion/snice-accordion.min.js +1 -1
- package/dist/cdn/alert/snice-alert.js +1 -1
- package/dist/cdn/alert/snice-alert.min.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.min.js +1 -1
- package/dist/cdn/avatar/snice-avatar.js +1 -1
- package/dist/cdn/avatar/snice-avatar.min.js +1 -1
- package/dist/cdn/badge/snice-badge.js +1 -1
- package/dist/cdn/badge/snice-badge.min.js +1 -1
- package/dist/cdn/banner/snice-banner.js +1 -1
- package/dist/cdn/banner/snice-banner.min.js +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +2 -2
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js.map +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.min.js +13 -13
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.min.js.map +1 -1
- package/dist/cdn/button/snice-button.js +1 -1
- package/dist/cdn/button/snice-button.min.js +1 -1
- package/dist/cdn/calendar/snice-calendar.js +1 -1
- package/dist/cdn/calendar/snice-calendar.min.js +1 -1
- package/dist/cdn/camera/snice-camera.js +1 -1
- package/dist/cdn/camera/snice-camera.min.js +1 -1
- package/dist/cdn/camera-annotate/README.md +27 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.js +730 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.js.map +1 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.min.js +144 -0
- package/dist/cdn/camera-annotate/snice-camera-annotate.min.js.map +1 -0
- package/dist/cdn/candlestick/README.md +27 -0
- package/dist/cdn/candlestick/snice-candlestick.js +717 -0
- package/dist/cdn/candlestick/snice-candlestick.js.map +1 -0
- package/dist/cdn/candlestick/snice-candlestick.min.js +22 -0
- package/dist/cdn/candlestick/snice-candlestick.min.js.map +1 -0
- package/dist/cdn/card/snice-card.js +1 -1
- package/dist/cdn/card/snice-card.min.js +1 -1
- package/dist/cdn/carousel/snice-carousel.js +1 -1
- package/dist/cdn/carousel/snice-carousel.min.js +1 -1
- package/dist/cdn/chart/snice-chart.js +1 -1
- package/dist/cdn/chart/snice-chart.min.js +1 -1
- package/dist/cdn/chat/snice-chat.js +1 -1
- package/dist/cdn/chat/snice-chat.min.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.min.js +1 -1
- package/dist/cdn/chip/snice-chip.js +1 -1
- package/dist/cdn/chip/snice-chip.min.js +1 -1
- package/dist/cdn/code-block/snice-code-block.js +1 -1
- package/dist/cdn/code-block/snice-code-block.min.js +1 -1
- package/dist/cdn/color-display/snice-color-display.js +1 -1
- package/dist/cdn/color-display/snice-color-display.min.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.min.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.min.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.min.js +1 -1
- package/dist/cdn/divider/snice-divider.js +1 -1
- package/dist/cdn/divider/snice-divider.min.js +1 -1
- package/dist/cdn/doc/snice-doc.js +1 -1
- package/dist/cdn/doc/snice-doc.min.js +1 -1
- package/dist/cdn/draw/snice-draw.js +1 -1
- package/dist/cdn/draw/snice-draw.min.js +1 -1
- package/dist/cdn/drawer/snice-drawer.js +1 -1
- package/dist/cdn/drawer/snice-drawer.min.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.min.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.min.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.min.js +1 -1
- package/dist/cdn/funnel/README.md +27 -0
- package/dist/cdn/funnel/snice-funnel.js +424 -0
- package/dist/cdn/funnel/snice-funnel.js.map +1 -0
- package/dist/cdn/funnel/snice-funnel.min.js +20 -0
- package/dist/cdn/funnel/snice-funnel.min.js.map +1 -0
- package/dist/cdn/gauge/snice-gauge.js +1 -1
- package/dist/cdn/gauge/snice-gauge.min.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.min.js +1 -1
- package/dist/cdn/image/snice-image.js +1 -1
- package/dist/cdn/image/snice-image.min.js +1 -1
- package/dist/cdn/input/snice-input.js +1 -1
- package/dist/cdn/input/snice-input.min.js +1 -1
- package/dist/cdn/kanban/snice-kanban.js +1 -1
- package/dist/cdn/kanban/snice-kanban.min.js +1 -1
- package/dist/cdn/kpi/snice-kpi.js +1 -1
- package/dist/cdn/kpi/snice-kpi.min.js +1 -1
- package/dist/cdn/layout/README.md +2 -2
- package/dist/cdn/layout/snice-layout.js +23 -6
- package/dist/cdn/layout/snice-layout.js.map +1 -1
- package/dist/cdn/layout/snice-layout.min.js +2 -2
- package/dist/cdn/layout/snice-layout.min.js.map +1 -1
- package/dist/cdn/link/snice-link.js +1 -1
- package/dist/cdn/link/snice-link.min.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.min.js +1 -1
- package/dist/cdn/list/README.md +6 -2
- package/dist/cdn/list/snice-list.js +87 -10
- package/dist/cdn/list/snice-list.js.map +1 -1
- package/dist/cdn/list/snice-list.min.js +20 -6
- package/dist/cdn/list/snice-list.min.js.map +1 -1
- package/dist/cdn/location/snice-location.js +1 -1
- package/dist/cdn/location/snice-location.min.js +1 -1
- package/dist/cdn/login/snice-login.js +1 -1
- package/dist/cdn/login/snice-login.min.js +1 -1
- package/dist/cdn/masonry/snice-masonry.js +1 -1
- package/dist/cdn/masonry/snice-masonry.min.js +1 -1
- package/dist/cdn/menu/snice-menu.js +1 -1
- package/dist/cdn/menu/snice-menu.min.js +1 -1
- package/dist/cdn/modal/snice-modal.js +1 -1
- package/dist/cdn/modal/snice-modal.min.js +1 -1
- package/dist/cdn/music-player/snice-music-player.js +1 -1
- package/dist/cdn/music-player/snice-music-player.min.js +1 -1
- package/dist/cdn/nav/README.md +2 -2
- package/dist/cdn/nav/snice-nav.js +23 -6
- package/dist/cdn/nav/snice-nav.js.map +1 -1
- package/dist/cdn/nav/snice-nav.min.js +2 -2
- package/dist/cdn/nav/snice-nav.min.js.map +1 -1
- package/dist/cdn/network-graph/README.md +27 -0
- package/dist/cdn/network-graph/snice-network-graph.js +788 -0
- package/dist/cdn/network-graph/snice-network-graph.js.map +1 -0
- package/dist/cdn/network-graph/snice-network-graph.min.js +13 -0
- package/dist/cdn/network-graph/snice-network-graph.min.js.map +1 -0
- package/dist/cdn/pagination/README.md +2 -2
- package/dist/cdn/pagination/snice-pagination.js +13 -13
- package/dist/cdn/pagination/snice-pagination.js.map +1 -1
- package/dist/cdn/pagination/snice-pagination.min.js +14 -14
- package/dist/cdn/pagination/snice-pagination.min.js.map +1 -1
- package/dist/cdn/paint/snice-paint.js +1 -1
- package/dist/cdn/paint/snice-paint.min.js +1 -1
- package/dist/cdn/progress/snice-progress.js +1 -1
- package/dist/cdn/progress/snice-progress.min.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.min.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.min.js +1 -1
- package/dist/cdn/radio/snice-radio.js +1 -1
- package/dist/cdn/radio/snice-radio.min.js +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.js +3 -3
- package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js +3 -3
- package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.js +3 -3
- package/dist/cdn/runtime/snice-runtime.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js +3 -3
- package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
- package/dist/cdn/sankey/README.md +27 -0
- package/dist/cdn/sankey/snice-sankey.js +679 -0
- package/dist/cdn/sankey/snice-sankey.js.map +1 -0
- package/dist/cdn/sankey/snice-sankey.min.js +21 -0
- package/dist/cdn/sankey/snice-sankey.min.js.map +1 -0
- package/dist/cdn/select/snice-select.js +1 -1
- package/dist/cdn/select/snice-select.min.js +1 -1
- package/dist/cdn/skeleton/snice-skeleton.js +1 -1
- package/dist/cdn/skeleton/snice-skeleton.min.js +1 -1
- package/dist/cdn/slider/snice-slider.js +1 -1
- package/dist/cdn/slider/snice-slider.min.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.min.js +1 -1
- package/dist/cdn/spinner/snice-spinner.js +1 -1
- package/dist/cdn/spinner/snice-spinner.min.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.min.js +1 -1
- package/dist/cdn/stepper/README.md +6 -2
- package/dist/cdn/stepper/snice-stepper.js +77 -10
- package/dist/cdn/stepper/snice-stepper.js.map +1 -1
- package/dist/cdn/stepper/snice-stepper.min.js +13 -9
- package/dist/cdn/stepper/snice-stepper.min.js.map +1 -1
- package/dist/cdn/switch/snice-switch.js +1 -1
- package/dist/cdn/switch/snice-switch.min.js +1 -1
- package/dist/cdn/table/snice-table.js +1 -1
- package/dist/cdn/table/snice-table.min.js +1 -1
- package/dist/cdn/tabs/snice-tabs.js +1 -1
- package/dist/cdn/tabs/snice-tabs.min.js +1 -1
- package/dist/cdn/terminal/snice-terminal.js +1 -1
- package/dist/cdn/terminal/snice-terminal.min.js +1 -1
- package/dist/cdn/textarea/snice-textarea.js +1 -1
- package/dist/cdn/textarea/snice-textarea.min.js +1 -1
- package/dist/cdn/time-range-picker/README.md +27 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.js +635 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.js.map +1 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.min.js +34 -0
- package/dist/cdn/time-range-picker/snice-time-range-picker.min.js.map +1 -0
- package/dist/cdn/timeline/snice-timeline.js +1 -1
- package/dist/cdn/timeline/snice-timeline.min.js +1 -1
- package/dist/cdn/timer/snice-timer.js +1 -1
- package/dist/cdn/timer/snice-timer.min.js +1 -1
- package/dist/cdn/toast/snice-toast.js +1 -1
- package/dist/cdn/toast/snice-toast.min.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.min.js +1 -1
- package/dist/cdn/tree/README.md +5 -1
- package/dist/cdn/tree/snice-tree.js +4 -8
- package/dist/cdn/tree/snice-tree.js.map +1 -1
- package/dist/cdn/tree/snice-tree.min.js +5 -5
- package/dist/cdn/tree/snice-tree.min.js.map +1 -1
- package/dist/cdn/treemap/README.md +27 -0
- package/dist/cdn/treemap/snice-treemap.js +522 -0
- package/dist/cdn/treemap/snice-treemap.js.map +1 -0
- package/dist/cdn/treemap/snice-treemap.min.js +14 -0
- package/dist/cdn/treemap/snice-treemap.min.js.map +1 -0
- package/dist/cdn/virtual-scroller/README.md +2 -2
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +47 -16
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js.map +1 -1
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.min.js +9 -9
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.min.js.map +1 -1
- package/dist/components/breadcrumbs/snice-breadcrumbs.js +1 -1
- package/dist/components/breadcrumbs/snice-breadcrumbs.js.map +1 -1
- package/dist/components/camera-annotate/snice-camera-annotate.d.ts +68 -0
- package/dist/components/camera-annotate/snice-camera-annotate.js +663 -0
- package/dist/components/camera-annotate/snice-camera-annotate.js.map +1 -0
- package/dist/components/camera-annotate/snice-camera-annotate.types.d.ts +50 -0
- package/dist/components/candlestick/snice-candlestick.d.ts +78 -0
- package/dist/components/candlestick/snice-candlestick.js +650 -0
- package/dist/components/candlestick/snice-candlestick.js.map +1 -0
- package/dist/components/candlestick/snice-candlestick.types.d.ts +40 -0
- package/dist/components/funnel/snice-funnel.d.ts +37 -0
- package/dist/components/funnel/snice-funnel.js +357 -0
- package/dist/components/funnel/snice-funnel.js.map +1 -0
- package/dist/components/funnel/snice-funnel.types.d.ts +28 -0
- package/dist/components/list/snice-list-item.d.ts +2 -0
- package/dist/components/list/snice-list-item.js +20 -2
- package/dist/components/list/snice-list-item.js.map +1 -1
- package/dist/components/nav/snice-nav.js +22 -5
- package/dist/components/nav/snice-nav.js.map +1 -1
- package/dist/components/network-graph/snice-network-graph.d.ts +80 -0
- package/dist/components/network-graph/snice-network-graph.js +721 -0
- package/dist/components/network-graph/snice-network-graph.js.map +1 -0
- package/dist/components/network-graph/snice-network-graph.types.d.ts +49 -0
- package/dist/components/pagination/snice-pagination.js +12 -12
- package/dist/components/sankey/snice-sankey.d.ts +46 -0
- package/dist/components/sankey/snice-sankey.js +612 -0
- package/dist/components/sankey/snice-sankey.js.map +1 -0
- package/dist/components/sankey/snice-sankey.types.d.ts +59 -0
- package/dist/components/stepper/snice-stepper.js +9 -3
- package/dist/components/stepper/snice-stepper.js.map +1 -1
- package/dist/components/time-range-picker/snice-time-range-picker.d.ts +67 -0
- package/dist/components/time-range-picker/snice-time-range-picker.js +568 -0
- package/dist/components/time-range-picker/snice-time-range-picker.js.map +1 -0
- package/dist/components/time-range-picker/snice-time-range-picker.types.d.ts +39 -0
- package/dist/components/treemap/snice-treemap.d.ts +49 -0
- package/dist/components/treemap/snice-treemap.js +455 -0
- package/dist/components/treemap/snice-treemap.js.map +1 -0
- package/dist/components/treemap/snice-treemap.types.d.ts +42 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.d.ts +5 -0
- package/dist/components/virtual-scroller/snice-virtual-scroller.js +47 -16
- package/dist/components/virtual-scroller/snice-virtual-scroller.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/docs/ai/components/camera-annotate.md +82 -0
- package/docs/ai/components/candlestick.md +79 -0
- package/docs/ai/components/funnel.md +86 -0
- package/docs/ai/components/network-graph.md +87 -0
- package/docs/ai/components/sankey.md +63 -0
- package/docs/ai/components/time-range-picker.md +78 -0
- package/docs/ai/components/treemap.md +78 -0
- package/docs/components/camera-annotate.md +186 -0
- package/docs/components/candlestick.md +196 -0
- package/docs/components/funnel.md +191 -0
- package/docs/components/network-graph.md +215 -0
- package/docs/components/sankey.md +201 -0
- package/docs/components/time-range-picker.md +213 -0
- package/docs/components/treemap.md +198 -0
- package/package.json +1 -1
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* snice v4.8.0
|
|
3
|
+
* Imperative TypeScript framework for building vanilla web components with decorators, differential rendering, routing, and controllers. No virtual DOM, no build complexity.
|
|
4
|
+
* (c) 2024
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
if(typeof globalThis.Snice==="undefined"){console.warn("[snice] snice-runtime.min.js must be loaded before snice-sankey.min.js");}
|
|
8
|
+
var SniceSankey = (function (exports, snice) {
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
/******************************************************************************
|
|
12
|
+
Copyright (c) Microsoft Corporation.
|
|
13
|
+
|
|
14
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
15
|
+
purpose with or without fee is hereby granted.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
18
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
19
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
20
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
21
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
22
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
24
|
+
***************************************************************************** */
|
|
25
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
29
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
30
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
31
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
32
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
33
|
+
var _, done = false;
|
|
34
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
35
|
+
var context = {};
|
|
36
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
37
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
38
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
39
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
40
|
+
if (kind === "accessor") {
|
|
41
|
+
if (result === void 0) continue;
|
|
42
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
43
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
44
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
45
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
46
|
+
}
|
|
47
|
+
else if (_ = accept(result)) {
|
|
48
|
+
if (kind === "field") initializers.unshift(_);
|
|
49
|
+
else descriptor[key] = _;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
53
|
+
done = true;
|
|
54
|
+
}
|
|
55
|
+
function __runInitializers(thisArg, initializers, value) {
|
|
56
|
+
var useValue = arguments.length > 2;
|
|
57
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
58
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
59
|
+
}
|
|
60
|
+
return useValue ? value : void 0;
|
|
61
|
+
}
|
|
62
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
63
|
+
var e = new Error(message);
|
|
64
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var cssContent = ":host{display:block;font-family:var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);contain:layout style paint;width:100%}.sankey{position:relative;width:100%;min-height:12.5rem}.sankey__svg{display:block;width:100%;height:100%}.sankey__node{cursor:pointer;transition:opacity var(--snice-transition-fast, 150ms) ease}.sankey__node rect{stroke:var(--snice-color-background,rgb(255 255 255));stroke-width:1px}.sankey__node:hover rect{filter:brightness(1.1)}.sankey__link{cursor:pointer;transition:opacity var(--snice-transition-fast, 150ms) ease}.sankey__link path{fill:none;stroke-opacity:0.35;transition:stroke-opacity var(--snice-transition-fast, 150ms) ease}.sankey__link:hover path{stroke-opacity:0.6}.sankey--dimmed .sankey__node:not(.sankey__node--highlighted){opacity:.2}.sankey--dimmed .sankey__link:not(.sankey__link--highlighted) path{stroke-opacity:0.08}.sankey__label{font-size:var(--snice-font-size-sm, .75rem);fill:var(--snice-color-text,rgb(23 23 23));pointer-events:none;dominant-baseline:central}.sankey__value{font-size:var(--snice-font-size-xs, .625rem);fill:var(--snice-color-text-secondary,rgb(82 82 82));pointer-events:none;dominant-baseline:central}.sankey__tooltip{position:absolute;pointer-events:none;background:var(--snice-color-background,rgb(255 255 255));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:4px;padding:var(--snice-spacing-xs,.5rem) var(--snice-spacing-sm,.75rem);font-size:var(--snice-font-size-sm, .75rem);color:var(--snice-color-text,rgb(23 23 23));box-shadow:var(--snice-shadow-md,0 4px 6px -1px rgb(0 0 0 / .1),0 2px 4px -2px rgb(0 0 0 / .1));white-space:nowrap;z-index:10;opacity:0;transition:opacity var(--snice-transition-fast, 150ms) ease}.sankey__tooltip--visible{opacity:1}.sankey__tooltip-label{font-weight:var(--snice-font-weight-semibold,600)}.sankey__tooltip-value{color:var(--snice-color-text-secondary,rgb(82 82 82));margin-top:var(--snice-spacing-3xs,.125rem)}@keyframes sankey-fade-in{from{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}:host([animation]) .sankey__node{animation:sankey-fade-in var(--snice-transition-medium,250ms) ease both}:host([animation]) .sankey__link path{stroke-dasharray:1000;stroke-dashoffset:1000;animation:.8s forwards sankey-link-draw}@keyframes sankey-link-draw{to{stroke-dashoffset:0}}";
|
|
68
|
+
|
|
69
|
+
const DEFAULT_COLORS = [
|
|
70
|
+
'#2196f3', '#4caf50', '#ff9800', '#f44336', '#9c27b0',
|
|
71
|
+
'#00bcd4', '#8bc34a', '#ffc107', '#e91e63', '#673ab7'
|
|
72
|
+
];
|
|
73
|
+
function escapeHTML(str) {
|
|
74
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
75
|
+
}
|
|
76
|
+
let SniceSankey = (() => {
|
|
77
|
+
let _classDecorators = [snice.element('snice-sankey')];
|
|
78
|
+
let _classDescriptor;
|
|
79
|
+
let _classExtraInitializers = [];
|
|
80
|
+
let _classThis;
|
|
81
|
+
let _classSuper = HTMLElement;
|
|
82
|
+
let _instanceExtraInitializers = [];
|
|
83
|
+
let _data_decorators;
|
|
84
|
+
let _data_initializers = [];
|
|
85
|
+
let _data_extraInitializers = [];
|
|
86
|
+
let _nodeWidth_decorators;
|
|
87
|
+
let _nodeWidth_initializers = [];
|
|
88
|
+
let _nodeWidth_extraInitializers = [];
|
|
89
|
+
let _nodePadding_decorators;
|
|
90
|
+
let _nodePadding_initializers = [];
|
|
91
|
+
let _nodePadding_extraInitializers = [];
|
|
92
|
+
let _alignment_decorators;
|
|
93
|
+
let _alignment_initializers = [];
|
|
94
|
+
let _alignment_extraInitializers = [];
|
|
95
|
+
let _showLabels_decorators;
|
|
96
|
+
let _showLabels_initializers = [];
|
|
97
|
+
let _showLabels_extraInitializers = [];
|
|
98
|
+
let _showValues_decorators;
|
|
99
|
+
let _showValues_initializers = [];
|
|
100
|
+
let _showValues_extraInitializers = [];
|
|
101
|
+
let _animation_decorators;
|
|
102
|
+
let _animation_initializers = [];
|
|
103
|
+
let _animation_extraInitializers = [];
|
|
104
|
+
let _chartEl_decorators;
|
|
105
|
+
let _chartEl_initializers = [];
|
|
106
|
+
let _chartEl_extraInitializers = [];
|
|
107
|
+
let _tooltipEl_decorators;
|
|
108
|
+
let _tooltipEl_initializers = [];
|
|
109
|
+
let _tooltipEl_extraInitializers = [];
|
|
110
|
+
let _emitNodeClick_decorators;
|
|
111
|
+
let _emitLinkClick_decorators;
|
|
112
|
+
let _emitHover_decorators;
|
|
113
|
+
let _init_decorators;
|
|
114
|
+
let _onDataChange_decorators;
|
|
115
|
+
let _onDisplayChange_decorators;
|
|
116
|
+
let _renderContent_decorators;
|
|
117
|
+
let _componentStyles_decorators;
|
|
118
|
+
let _cleanup_decorators;
|
|
119
|
+
(class extends _classSuper {
|
|
120
|
+
static { _classThis = this; }
|
|
121
|
+
constructor() {
|
|
122
|
+
super(...arguments);
|
|
123
|
+
this.data = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _data_initializers, { nodes: [], links: [] }));
|
|
124
|
+
this.nodeWidth = (__runInitializers(this, _data_extraInitializers), __runInitializers(this, _nodeWidth_initializers, 20));
|
|
125
|
+
this.nodePadding = (__runInitializers(this, _nodeWidth_extraInitializers), __runInitializers(this, _nodePadding_initializers, 10));
|
|
126
|
+
this.alignment = (__runInitializers(this, _nodePadding_extraInitializers), __runInitializers(this, _alignment_initializers, 'justify'));
|
|
127
|
+
this.showLabels = (__runInitializers(this, _alignment_extraInitializers), __runInitializers(this, _showLabels_initializers, true));
|
|
128
|
+
this.showValues = (__runInitializers(this, _showLabels_extraInitializers), __runInitializers(this, _showValues_initializers, true));
|
|
129
|
+
this.animation = (__runInitializers(this, _showValues_extraInitializers), __runInitializers(this, _animation_initializers, false));
|
|
130
|
+
this.chartEl = (__runInitializers(this, _animation_extraInitializers), __runInitializers(this, _chartEl_initializers, void 0));
|
|
131
|
+
this.tooltipEl = (__runInitializers(this, _chartEl_extraInitializers), __runInitializers(this, _tooltipEl_initializers, void 0));
|
|
132
|
+
this.cachedData = (__runInitializers(this, _tooltipEl_extraInitializers), { nodes: [], links: [] });
|
|
133
|
+
this.layoutNodes = [];
|
|
134
|
+
this.layoutLinks = [];
|
|
135
|
+
this.hoveredNodeId = null;
|
|
136
|
+
this.hoveredLinkIndex = null;
|
|
137
|
+
this.chartWidth = 600;
|
|
138
|
+
this.chartHeight = 400;
|
|
139
|
+
this.resizeObserver = null;
|
|
140
|
+
}
|
|
141
|
+
static {
|
|
142
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
143
|
+
_data_decorators = [snice.property({ type: Object, attribute: false })];
|
|
144
|
+
_nodeWidth_decorators = [snice.property({ type: Number, attribute: 'node-width' })];
|
|
145
|
+
_nodePadding_decorators = [snice.property({ type: Number, attribute: 'node-padding' })];
|
|
146
|
+
_alignment_decorators = [snice.property()];
|
|
147
|
+
_showLabels_decorators = [snice.property({ type: Boolean, attribute: 'show-labels' })];
|
|
148
|
+
_showValues_decorators = [snice.property({ type: Boolean, attribute: 'show-values' })];
|
|
149
|
+
_animation_decorators = [snice.property({ type: Boolean })];
|
|
150
|
+
_chartEl_decorators = [snice.query('.sankey__chart')];
|
|
151
|
+
_tooltipEl_decorators = [snice.query('.sankey__tooltip')];
|
|
152
|
+
_emitNodeClick_decorators = [snice.dispatch('sankey-node-click', { bubbles: true, composed: true })];
|
|
153
|
+
_emitLinkClick_decorators = [snice.dispatch('sankey-link-click', { bubbles: true, composed: true })];
|
|
154
|
+
_emitHover_decorators = [snice.dispatch('sankey-hover', { bubbles: true, composed: true })];
|
|
155
|
+
_init_decorators = [snice.ready()];
|
|
156
|
+
_onDataChange_decorators = [snice.watch('data')];
|
|
157
|
+
_onDisplayChange_decorators = [snice.watch('showLabels', 'showValues', 'animation', 'alignment')];
|
|
158
|
+
_renderContent_decorators = [snice.render({ once: true })];
|
|
159
|
+
_componentStyles_decorators = [snice.styles()];
|
|
160
|
+
_cleanup_decorators = [snice.dispose()];
|
|
161
|
+
__esDecorate(this, null, _emitNodeClick_decorators, { kind: "method", name: "emitNodeClick", static: false, private: false, access: { has: obj => "emitNodeClick" in obj, get: obj => obj.emitNodeClick }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
162
|
+
__esDecorate(this, null, _emitLinkClick_decorators, { kind: "method", name: "emitLinkClick", static: false, private: false, access: { has: obj => "emitLinkClick" in obj, get: obj => obj.emitLinkClick }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
163
|
+
__esDecorate(this, null, _emitHover_decorators, { kind: "method", name: "emitHover", static: false, private: false, access: { has: obj => "emitHover" in obj, get: obj => obj.emitHover }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
164
|
+
__esDecorate(this, null, _init_decorators, { kind: "method", name: "init", static: false, private: false, access: { has: obj => "init" in obj, get: obj => obj.init }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
165
|
+
__esDecorate(this, null, _onDataChange_decorators, { kind: "method", name: "onDataChange", static: false, private: false, access: { has: obj => "onDataChange" in obj, get: obj => obj.onDataChange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
166
|
+
__esDecorate(this, null, _onDisplayChange_decorators, { kind: "method", name: "onDisplayChange", static: false, private: false, access: { has: obj => "onDisplayChange" in obj, get: obj => obj.onDisplayChange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
167
|
+
__esDecorate(this, null, _renderContent_decorators, { kind: "method", name: "renderContent", static: false, private: false, access: { has: obj => "renderContent" in obj, get: obj => obj.renderContent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
168
|
+
__esDecorate(this, null, _componentStyles_decorators, { kind: "method", name: "componentStyles", static: false, private: false, access: { has: obj => "componentStyles" in obj, get: obj => obj.componentStyles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
169
|
+
__esDecorate(this, null, _cleanup_decorators, { kind: "method", name: "cleanup", static: false, private: false, access: { has: obj => "cleanup" in obj, get: obj => obj.cleanup }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
170
|
+
__esDecorate(null, null, _data_decorators, { kind: "field", name: "data", static: false, private: false, access: { has: obj => "data" in obj, get: obj => obj.data, set: (obj, value) => { obj.data = value; } }, metadata: _metadata }, _data_initializers, _data_extraInitializers);
|
|
171
|
+
__esDecorate(null, null, _nodeWidth_decorators, { kind: "field", name: "nodeWidth", static: false, private: false, access: { has: obj => "nodeWidth" in obj, get: obj => obj.nodeWidth, set: (obj, value) => { obj.nodeWidth = value; } }, metadata: _metadata }, _nodeWidth_initializers, _nodeWidth_extraInitializers);
|
|
172
|
+
__esDecorate(null, null, _nodePadding_decorators, { kind: "field", name: "nodePadding", static: false, private: false, access: { has: obj => "nodePadding" in obj, get: obj => obj.nodePadding, set: (obj, value) => { obj.nodePadding = value; } }, metadata: _metadata }, _nodePadding_initializers, _nodePadding_extraInitializers);
|
|
173
|
+
__esDecorate(null, null, _alignment_decorators, { kind: "field", name: "alignment", static: false, private: false, access: { has: obj => "alignment" in obj, get: obj => obj.alignment, set: (obj, value) => { obj.alignment = value; } }, metadata: _metadata }, _alignment_initializers, _alignment_extraInitializers);
|
|
174
|
+
__esDecorate(null, null, _showLabels_decorators, { kind: "field", name: "showLabels", static: false, private: false, access: { has: obj => "showLabels" in obj, get: obj => obj.showLabels, set: (obj, value) => { obj.showLabels = value; } }, metadata: _metadata }, _showLabels_initializers, _showLabels_extraInitializers);
|
|
175
|
+
__esDecorate(null, null, _showValues_decorators, { kind: "field", name: "showValues", static: false, private: false, access: { has: obj => "showValues" in obj, get: obj => obj.showValues, set: (obj, value) => { obj.showValues = value; } }, metadata: _metadata }, _showValues_initializers, _showValues_extraInitializers);
|
|
176
|
+
__esDecorate(null, null, _animation_decorators, { kind: "field", name: "animation", static: false, private: false, access: { has: obj => "animation" in obj, get: obj => obj.animation, set: (obj, value) => { obj.animation = value; } }, metadata: _metadata }, _animation_initializers, _animation_extraInitializers);
|
|
177
|
+
__esDecorate(null, null, _chartEl_decorators, { kind: "field", name: "chartEl", static: false, private: false, access: { has: obj => "chartEl" in obj, get: obj => obj.chartEl, set: (obj, value) => { obj.chartEl = value; } }, metadata: _metadata }, _chartEl_initializers, _chartEl_extraInitializers);
|
|
178
|
+
__esDecorate(null, null, _tooltipEl_decorators, { kind: "field", name: "tooltipEl", static: false, private: false, access: { has: obj => "tooltipEl" in obj, get: obj => obj.tooltipEl, set: (obj, value) => { obj.tooltipEl = value; } }, metadata: _metadata }, _tooltipEl_initializers, _tooltipEl_extraInitializers);
|
|
179
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
180
|
+
_classThis = _classDescriptor.value;
|
|
181
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
182
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
183
|
+
}
|
|
184
|
+
emitNodeClick(node) {
|
|
185
|
+
return { node };
|
|
186
|
+
}
|
|
187
|
+
emitLinkClick(link) {
|
|
188
|
+
return { link };
|
|
189
|
+
}
|
|
190
|
+
emitHover(detail) {
|
|
191
|
+
return detail;
|
|
192
|
+
}
|
|
193
|
+
init() {
|
|
194
|
+
const rect = this.getBoundingClientRect();
|
|
195
|
+
if (rect.width > 0)
|
|
196
|
+
this.chartWidth = rect.width;
|
|
197
|
+
if (rect.height > 0)
|
|
198
|
+
this.chartHeight = rect.height;
|
|
199
|
+
if (this.cachedData.nodes.length === 0 && this.data.nodes.length > 0) {
|
|
200
|
+
this.cachedData = this.data;
|
|
201
|
+
}
|
|
202
|
+
this.computeLayout();
|
|
203
|
+
this.rebuildChart();
|
|
204
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
205
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
206
|
+
const entry = entries[0];
|
|
207
|
+
if (entry) {
|
|
208
|
+
const { width, height } = entry.contentRect;
|
|
209
|
+
if (width > 0 && height > 0) {
|
|
210
|
+
this.chartWidth = width;
|
|
211
|
+
this.chartHeight = height;
|
|
212
|
+
this.computeLayout();
|
|
213
|
+
this.rebuildChart();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
this.resizeObserver.observe(this);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
onDataChange() {
|
|
221
|
+
this.cachedData = this.data;
|
|
222
|
+
this.computeLayout();
|
|
223
|
+
this.rebuildChart();
|
|
224
|
+
}
|
|
225
|
+
onDisplayChange() {
|
|
226
|
+
this.computeLayout();
|
|
227
|
+
this.rebuildChart();
|
|
228
|
+
}
|
|
229
|
+
computeLayout() {
|
|
230
|
+
const data = this.cachedData;
|
|
231
|
+
if (!data || !data.nodes.length || !data.links.length) {
|
|
232
|
+
this.layoutNodes = [];
|
|
233
|
+
this.layoutLinks = [];
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const padding = 40;
|
|
237
|
+
const labelSpace = this.showLabels ? 80 : 0;
|
|
238
|
+
const width = this.chartWidth - labelSpace * 2;
|
|
239
|
+
const height = this.chartHeight - padding * 2;
|
|
240
|
+
if (width <= 0 || height <= 0)
|
|
241
|
+
return;
|
|
242
|
+
// Build node map
|
|
243
|
+
const nodeMap = new Map();
|
|
244
|
+
data.nodes.forEach((n, i) => {
|
|
245
|
+
nodeMap.set(n.id, {
|
|
246
|
+
id: n.id,
|
|
247
|
+
label: n.label || n.id,
|
|
248
|
+
color: n.color || DEFAULT_COLORS[i % DEFAULT_COLORS.length],
|
|
249
|
+
x: 0, y: 0,
|
|
250
|
+
width: this.nodeWidth,
|
|
251
|
+
height: 0,
|
|
252
|
+
value: 0,
|
|
253
|
+
depth: 0,
|
|
254
|
+
sourceLinks: [],
|
|
255
|
+
targetLinks: []
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
// Build links
|
|
259
|
+
const links = data.links.map(l => ({
|
|
260
|
+
source: nodeMap.get(l.source),
|
|
261
|
+
target: nodeMap.get(l.target),
|
|
262
|
+
value: l.value,
|
|
263
|
+
color: l.color || nodeMap.get(l.source)?.color || DEFAULT_COLORS[0],
|
|
264
|
+
width: 0,
|
|
265
|
+
sy: 0,
|
|
266
|
+
ty: 0
|
|
267
|
+
})).filter(l => l.source && l.target);
|
|
268
|
+
// Assign links to nodes
|
|
269
|
+
links.forEach(link => {
|
|
270
|
+
link.source.sourceLinks.push(link);
|
|
271
|
+
link.target.targetLinks.push(link);
|
|
272
|
+
});
|
|
273
|
+
// Calculate node values
|
|
274
|
+
nodeMap.forEach(node => {
|
|
275
|
+
const sourceTotal = node.sourceLinks.reduce((s, l) => s + l.value, 0);
|
|
276
|
+
const targetTotal = node.targetLinks.reduce((s, l) => s + l.value, 0);
|
|
277
|
+
node.value = Math.max(sourceTotal, targetTotal);
|
|
278
|
+
});
|
|
279
|
+
// Compute depths using BFS
|
|
280
|
+
this.computeDepths(nodeMap);
|
|
281
|
+
const nodes = Array.from(nodeMap.values());
|
|
282
|
+
const maxDepth = Math.max(...nodes.map(n => n.depth));
|
|
283
|
+
// X positions
|
|
284
|
+
const xScale = maxDepth > 0 ? (width - this.nodeWidth) / maxDepth : 0;
|
|
285
|
+
nodes.forEach(node => {
|
|
286
|
+
node.x = labelSpace + node.depth * xScale;
|
|
287
|
+
});
|
|
288
|
+
// Apply alignment
|
|
289
|
+
this.applyAlignment(nodes, maxDepth, width, labelSpace);
|
|
290
|
+
// Y positions - compute node heights and stack within each column
|
|
291
|
+
const columns = this.getColumns(nodes);
|
|
292
|
+
columns.forEach(column => {
|
|
293
|
+
const colTotalValue = column.reduce((s, n) => s + n.value, 0);
|
|
294
|
+
const availableHeight = height - (column.length - 1) * this.nodePadding;
|
|
295
|
+
const scale = colTotalValue > 0 ? availableHeight / colTotalValue : 0;
|
|
296
|
+
let y = padding;
|
|
297
|
+
column.forEach(node => {
|
|
298
|
+
node.y = y;
|
|
299
|
+
node.height = Math.max(node.value * scale, 2);
|
|
300
|
+
y += node.height + this.nodePadding;
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
// Iterative relaxation for better node positioning
|
|
304
|
+
for (let i = 0; i < 32; i++) {
|
|
305
|
+
this.relaxColumns(columns, height, padding);
|
|
306
|
+
}
|
|
307
|
+
// Compute link positions
|
|
308
|
+
links.forEach(link => {
|
|
309
|
+
link.width = Math.max(1, (link.value / link.source.value) * link.source.height);
|
|
310
|
+
});
|
|
311
|
+
// Sort and position source links
|
|
312
|
+
nodes.forEach(node => {
|
|
313
|
+
node.sourceLinks.sort((a, b) => a.target.y - b.target.y);
|
|
314
|
+
let sy = 0;
|
|
315
|
+
node.sourceLinks.forEach(link => {
|
|
316
|
+
link.sy = node.y + sy;
|
|
317
|
+
sy += link.width;
|
|
318
|
+
});
|
|
319
|
+
node.targetLinks.sort((a, b) => a.source.y - b.source.y);
|
|
320
|
+
let ty = 0;
|
|
321
|
+
node.targetLinks.forEach(link => {
|
|
322
|
+
link.width = Math.max(1, (link.value / link.target.value) * link.target.height);
|
|
323
|
+
link.ty = node.y + ty;
|
|
324
|
+
ty += link.width;
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
this.layoutNodes = nodes;
|
|
328
|
+
this.layoutLinks = links;
|
|
329
|
+
}
|
|
330
|
+
computeDepths(nodeMap) {
|
|
331
|
+
const remaining = new Set(nodeMap.values());
|
|
332
|
+
let depth = 0;
|
|
333
|
+
while (remaining.size > 0) {
|
|
334
|
+
const nextLevel = [];
|
|
335
|
+
remaining.forEach(node => {
|
|
336
|
+
if (node.targetLinks.every(l => !remaining.has(l.source))) {
|
|
337
|
+
node.depth = depth;
|
|
338
|
+
nextLevel.push(node);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
if (nextLevel.length === 0) {
|
|
342
|
+
// Break cycles - assign remaining to current depth
|
|
343
|
+
remaining.forEach(node => {
|
|
344
|
+
node.depth = depth;
|
|
345
|
+
});
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
nextLevel.forEach(n => remaining.delete(n));
|
|
349
|
+
depth++;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
getColumns(nodes) {
|
|
353
|
+
const maxDepth = Math.max(...nodes.map(n => n.depth), 0);
|
|
354
|
+
const columns = [];
|
|
355
|
+
for (let i = 0; i <= maxDepth; i++) {
|
|
356
|
+
columns.push(nodes.filter(n => n.depth === i));
|
|
357
|
+
}
|
|
358
|
+
return columns;
|
|
359
|
+
}
|
|
360
|
+
applyAlignment(nodes, maxDepth, width, labelSpace) {
|
|
361
|
+
if (this.alignment === 'right') {
|
|
362
|
+
nodes.forEach(node => {
|
|
363
|
+
if (node.sourceLinks.length === 0) {
|
|
364
|
+
node.depth = maxDepth;
|
|
365
|
+
node.x = labelSpace + maxDepth * ((width - this.nodeWidth) / Math.max(maxDepth, 1));
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
else if (this.alignment === 'center') {
|
|
370
|
+
nodes.forEach(node => {
|
|
371
|
+
if (node.targetLinks.length === 0 && node.sourceLinks.length === 0) {
|
|
372
|
+
node.depth = Math.floor(maxDepth / 2);
|
|
373
|
+
node.x = labelSpace + node.depth * ((width - this.nodeWidth) / Math.max(maxDepth, 1));
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
else if (this.alignment === 'justify') {
|
|
378
|
+
nodes.forEach(node => {
|
|
379
|
+
if (node.sourceLinks.length === 0 && maxDepth > 0) {
|
|
380
|
+
node.depth = maxDepth;
|
|
381
|
+
node.x = labelSpace + maxDepth * ((width - this.nodeWidth) / maxDepth);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
relaxColumns(columns, height, padding) {
|
|
387
|
+
// Forward pass - push nodes based on sources
|
|
388
|
+
columns.forEach(column => {
|
|
389
|
+
column.forEach(node => {
|
|
390
|
+
if (node.targetLinks.length > 0) {
|
|
391
|
+
const avg = node.targetLinks.reduce((s, l) => s + l.source.y, 0) / node.targetLinks.length;
|
|
392
|
+
const delta = (avg - node.y) * 0.5;
|
|
393
|
+
node.y += delta;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
this.resolveOverlaps(column, height, padding);
|
|
397
|
+
});
|
|
398
|
+
// Backward pass - push nodes based on targets
|
|
399
|
+
for (let i = columns.length - 1; i >= 0; i--) {
|
|
400
|
+
columns[i].forEach(node => {
|
|
401
|
+
if (node.sourceLinks.length > 0) {
|
|
402
|
+
const avg = node.sourceLinks.reduce((s, l) => s + l.target.y, 0) / node.sourceLinks.length;
|
|
403
|
+
const delta = (avg - node.y) * 0.5;
|
|
404
|
+
node.y += delta;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
this.resolveOverlaps(columns[i], height, padding);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
resolveOverlaps(column, height, padding) {
|
|
411
|
+
column.sort((a, b) => a.y - b.y);
|
|
412
|
+
let y0 = padding;
|
|
413
|
+
column.forEach(node => {
|
|
414
|
+
if (node.y < y0) {
|
|
415
|
+
node.y = y0;
|
|
416
|
+
}
|
|
417
|
+
y0 = node.y + node.height + this.nodePadding;
|
|
418
|
+
});
|
|
419
|
+
// Push up if exceeding bottom
|
|
420
|
+
const lastNode = column[column.length - 1];
|
|
421
|
+
if (lastNode) {
|
|
422
|
+
const overflow = lastNode.y + lastNode.height - (height + padding);
|
|
423
|
+
if (overflow > 0) {
|
|
424
|
+
lastNode.y -= overflow;
|
|
425
|
+
for (let i = column.length - 2; i >= 0; i--) {
|
|
426
|
+
const maxY = column[i + 1].y - column[i].height - this.nodePadding;
|
|
427
|
+
if (column[i].y > maxY) {
|
|
428
|
+
column[i].y = maxY;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
getLinkPath(link) {
|
|
435
|
+
const x0 = link.source.x + link.source.width;
|
|
436
|
+
const x1 = link.target.x;
|
|
437
|
+
const xi = (x0 + x1) / 2;
|
|
438
|
+
const y0 = link.sy + link.width / 2;
|
|
439
|
+
const y1 = link.ty + link.width / 2;
|
|
440
|
+
return `M${x0},${y0} C${xi},${y0} ${xi},${y1} ${x1},${y1}`;
|
|
441
|
+
}
|
|
442
|
+
handleSvgClick(e) {
|
|
443
|
+
const target = e.target;
|
|
444
|
+
const el = target.closest('[data-node-id]');
|
|
445
|
+
const linkEl = target.closest('[data-link-index]');
|
|
446
|
+
if (el) {
|
|
447
|
+
const nodeId = el.dataset.nodeId;
|
|
448
|
+
const originalNode = this.cachedData.nodes.find(n => n.id === nodeId);
|
|
449
|
+
if (originalNode)
|
|
450
|
+
this.emitNodeClick(originalNode);
|
|
451
|
+
}
|
|
452
|
+
else if (linkEl) {
|
|
453
|
+
const index = parseInt(linkEl.dataset.linkIndex, 10);
|
|
454
|
+
const originalLink = this.cachedData.links[index];
|
|
455
|
+
if (originalLink)
|
|
456
|
+
this.emitLinkClick(originalLink);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
handleSvgMouseMove(e) {
|
|
460
|
+
const target = e.target;
|
|
461
|
+
const nodeEl = target.closest('[data-node-id]');
|
|
462
|
+
const linkEl = target.closest('[data-link-index]');
|
|
463
|
+
const tooltip = this.tooltipEl;
|
|
464
|
+
this.chartEl;
|
|
465
|
+
if (nodeEl) {
|
|
466
|
+
const nodeId = nodeEl.dataset.nodeId;
|
|
467
|
+
const node = this.layoutNodes.find(n => n.id === nodeId);
|
|
468
|
+
if (!node)
|
|
469
|
+
return;
|
|
470
|
+
// Update hover highlight
|
|
471
|
+
if (this.hoveredNodeId !== nodeId || this.hoveredLinkIndex !== null) {
|
|
472
|
+
this.hoveredNodeId = nodeId;
|
|
473
|
+
this.hoveredLinkIndex = null;
|
|
474
|
+
this.applyHoverClasses();
|
|
475
|
+
}
|
|
476
|
+
// Update tooltip
|
|
477
|
+
if (tooltip) {
|
|
478
|
+
tooltip.querySelector('.sankey__tooltip-label').textContent = node.label;
|
|
479
|
+
tooltip.querySelector('.sankey__tooltip-value').textContent = `Value: ${node.value.toLocaleString()}`;
|
|
480
|
+
this.positionTooltip(e);
|
|
481
|
+
tooltip.classList.add('sankey__tooltip--visible');
|
|
482
|
+
}
|
|
483
|
+
const originalNode = this.cachedData.nodes.find(n => n.id === nodeId);
|
|
484
|
+
if (originalNode)
|
|
485
|
+
this.emitHover({ type: 'node', item: originalNode });
|
|
486
|
+
}
|
|
487
|
+
else if (linkEl) {
|
|
488
|
+
const index = parseInt(linkEl.dataset.linkIndex, 10);
|
|
489
|
+
const link = this.layoutLinks[index];
|
|
490
|
+
if (!link)
|
|
491
|
+
return;
|
|
492
|
+
// Update hover highlight
|
|
493
|
+
if (this.hoveredLinkIndex !== index || this.hoveredNodeId !== null) {
|
|
494
|
+
this.hoveredLinkIndex = index;
|
|
495
|
+
this.hoveredNodeId = null;
|
|
496
|
+
this.applyHoverClasses();
|
|
497
|
+
}
|
|
498
|
+
// Update tooltip
|
|
499
|
+
if (tooltip) {
|
|
500
|
+
tooltip.querySelector('.sankey__tooltip-label').textContent = `${link.source.label} \u2192 ${link.target.label}`;
|
|
501
|
+
tooltip.querySelector('.sankey__tooltip-value').textContent = `Value: ${link.value.toLocaleString()}`;
|
|
502
|
+
this.positionTooltip(e);
|
|
503
|
+
tooltip.classList.add('sankey__tooltip--visible');
|
|
504
|
+
}
|
|
505
|
+
const originalLink = this.cachedData.links[index];
|
|
506
|
+
if (originalLink)
|
|
507
|
+
this.emitHover({ type: 'link', item: originalLink });
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
this.clearHover();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
handleSvgMouseLeave() {
|
|
514
|
+
this.clearHover();
|
|
515
|
+
}
|
|
516
|
+
clearHover() {
|
|
517
|
+
if (this.hoveredNodeId !== null || this.hoveredLinkIndex !== null) {
|
|
518
|
+
this.hoveredNodeId = null;
|
|
519
|
+
this.hoveredLinkIndex = null;
|
|
520
|
+
this.applyHoverClasses();
|
|
521
|
+
this.emitHover(null);
|
|
522
|
+
}
|
|
523
|
+
const tooltip = this.tooltipEl;
|
|
524
|
+
if (tooltip)
|
|
525
|
+
tooltip.classList.remove('sankey__tooltip--visible');
|
|
526
|
+
}
|
|
527
|
+
positionTooltip(e) {
|
|
528
|
+
const tooltip = this.tooltipEl;
|
|
529
|
+
if (!tooltip)
|
|
530
|
+
return;
|
|
531
|
+
const rect = this.getBoundingClientRect();
|
|
532
|
+
tooltip.style.left = `${e.clientX - rect.left + 10}px`;
|
|
533
|
+
tooltip.style.top = `${e.clientY - rect.top - 10}px`;
|
|
534
|
+
}
|
|
535
|
+
applyHoverClasses() {
|
|
536
|
+
const chart = this.chartEl;
|
|
537
|
+
if (!chart)
|
|
538
|
+
return;
|
|
539
|
+
const svg = chart.querySelector('svg');
|
|
540
|
+
if (!svg)
|
|
541
|
+
return;
|
|
542
|
+
const isDimmed = this.hoveredNodeId !== null || this.hoveredLinkIndex !== null;
|
|
543
|
+
const container = svg.closest('.sankey');
|
|
544
|
+
if (container) {
|
|
545
|
+
container.classList.toggle('sankey--dimmed', isDimmed);
|
|
546
|
+
}
|
|
547
|
+
// Update node highlights
|
|
548
|
+
const nodeGroups = svg.querySelectorAll('[data-node-id]');
|
|
549
|
+
nodeGroups.forEach(g => {
|
|
550
|
+
const nodeId = g.dataset.nodeId;
|
|
551
|
+
const highlighted = this.isNodeHighlighted(nodeId);
|
|
552
|
+
g.classList.toggle('sankey__node--highlighted', highlighted);
|
|
553
|
+
});
|
|
554
|
+
// Update link highlights
|
|
555
|
+
const linkGroups = svg.querySelectorAll('[data-link-index]');
|
|
556
|
+
linkGroups.forEach(g => {
|
|
557
|
+
const index = parseInt(g.dataset.linkIndex, 10);
|
|
558
|
+
const highlighted = this.isLinkHighlighted(index);
|
|
559
|
+
g.classList.toggle('sankey__link--highlighted', highlighted);
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
isNodeHighlighted(nodeId) {
|
|
563
|
+
if (this.hoveredNodeId === null && this.hoveredLinkIndex === null)
|
|
564
|
+
return false;
|
|
565
|
+
if (this.hoveredNodeId === nodeId)
|
|
566
|
+
return true;
|
|
567
|
+
if (this.hoveredLinkIndex !== null) {
|
|
568
|
+
const link = this.layoutLinks[this.hoveredLinkIndex];
|
|
569
|
+
return link?.source.id === nodeId || link?.target.id === nodeId;
|
|
570
|
+
}
|
|
571
|
+
if (this.hoveredNodeId) {
|
|
572
|
+
return this.layoutLinks.some(l => (l.source.id === this.hoveredNodeId && l.target.id === nodeId) ||
|
|
573
|
+
(l.target.id === this.hoveredNodeId && l.source.id === nodeId));
|
|
574
|
+
}
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
isLinkHighlighted(index) {
|
|
578
|
+
if (this.hoveredNodeId === null && this.hoveredLinkIndex === null)
|
|
579
|
+
return false;
|
|
580
|
+
if (this.hoveredLinkIndex === index)
|
|
581
|
+
return true;
|
|
582
|
+
if (this.hoveredNodeId) {
|
|
583
|
+
const link = this.layoutLinks[index];
|
|
584
|
+
return link?.source.id === this.hoveredNodeId || link?.target.id === this.hoveredNodeId;
|
|
585
|
+
}
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
rebuildChart() {
|
|
589
|
+
const chart = this.chartEl;
|
|
590
|
+
if (!chart) {
|
|
591
|
+
requestAnimationFrame(() => this.rebuildChart());
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const hasData = this.layoutNodes.length > 0;
|
|
595
|
+
if (!hasData) {
|
|
596
|
+
chart.innerHTML = '';
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
chart.innerHTML = this.buildSVG();
|
|
600
|
+
}
|
|
601
|
+
buildSVG() {
|
|
602
|
+
const nodes = this.layoutNodes;
|
|
603
|
+
const links = this.layoutLinks;
|
|
604
|
+
let svg = `<svg class="sankey__svg" viewBox="0 0 ${this.chartWidth} ${this.chartHeight}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="Sankey diagram">`;
|
|
605
|
+
// Links
|
|
606
|
+
svg += `<g class="sankey__links">`;
|
|
607
|
+
for (let i = 0; i < links.length; i++) {
|
|
608
|
+
const link = links[i];
|
|
609
|
+
const path = escapeHTML(this.getLinkPath(link));
|
|
610
|
+
const color = escapeHTML(link.color);
|
|
611
|
+
svg += `<g class="sankey__link" data-link-index="${i}">`;
|
|
612
|
+
svg += `<path d="${path}" stroke="${color}" stroke-width="${Math.max(1, link.width)}"/>`;
|
|
613
|
+
svg += `</g>`;
|
|
614
|
+
}
|
|
615
|
+
svg += `</g>`;
|
|
616
|
+
// Nodes
|
|
617
|
+
svg += `<g class="sankey__nodes">`;
|
|
618
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
619
|
+
const node = nodes[i];
|
|
620
|
+
const color = escapeHTML(node.color);
|
|
621
|
+
const nodeId = escapeHTML(node.id);
|
|
622
|
+
svg += `<g class="sankey__node" data-node-id="${nodeId}">`;
|
|
623
|
+
svg += `<rect x="${node.x}" y="${node.y}" width="${node.width}" height="${Math.max(node.height, 2)}" fill="${color}"/>`;
|
|
624
|
+
if (this.showLabels) {
|
|
625
|
+
const label = escapeHTML(node.label);
|
|
626
|
+
if (node.depth === 0) {
|
|
627
|
+
svg += `<text class="sankey__label" x="${node.x - 6}" y="${node.y + node.height / 2}" text-anchor="end">${label}</text>`;
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
svg += `<text class="sankey__label" x="${node.x + node.width + 6}" y="${node.y + node.height / 2}" text-anchor="start">${label}</text>`;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
if (this.showValues && node.height > 12) {
|
|
634
|
+
const value = escapeHTML(node.value.toLocaleString());
|
|
635
|
+
if (node.depth === 0) {
|
|
636
|
+
svg += `<text class="sankey__value" x="${node.x - 6}" y="${node.y + node.height / 2 + 12}" text-anchor="end">${value}</text>`;
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
svg += `<text class="sankey__value" x="${node.x + node.width + 6}" y="${node.y + node.height / 2 + 12}" text-anchor="start">${value}</text>`;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
svg += `</g>`;
|
|
643
|
+
}
|
|
644
|
+
svg += `</g>`;
|
|
645
|
+
svg += `</svg>`;
|
|
646
|
+
return svg;
|
|
647
|
+
}
|
|
648
|
+
renderContent() {
|
|
649
|
+
return snice.html /*html*/ `
|
|
650
|
+
<div class="sankey"
|
|
651
|
+
role="img"
|
|
652
|
+
aria-label="Sankey diagram"
|
|
653
|
+
@click=${(e) => this.handleSvgClick(e)}
|
|
654
|
+
@mousemove=${(e) => this.handleSvgMouseMove(e)}
|
|
655
|
+
@mouseleave=${() => this.handleSvgMouseLeave()}>
|
|
656
|
+
<div class="sankey__chart"></div>
|
|
657
|
+
<div class="sankey__tooltip">
|
|
658
|
+
<div class="sankey__tooltip-label"></div>
|
|
659
|
+
<div class="sankey__tooltip-value"></div>
|
|
660
|
+
</div>
|
|
661
|
+
</div>
|
|
662
|
+
`;
|
|
663
|
+
}
|
|
664
|
+
componentStyles() {
|
|
665
|
+
return snice.css /*css*/ `${cssContent}`;
|
|
666
|
+
}
|
|
667
|
+
cleanup() {
|
|
668
|
+
this.resizeObserver?.disconnect();
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
return _classThis;
|
|
672
|
+
})();
|
|
673
|
+
|
|
674
|
+
exports.SniceSankey = SniceSankey;
|
|
675
|
+
|
|
676
|
+
return exports;
|
|
677
|
+
|
|
678
|
+
})({}, Snice);
|
|
679
|
+
//# sourceMappingURL=snice-sankey.js.map
|