@techsio/ui-kit 0.57.0 → 0.58.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/README.md +128 -133
- package/dist/atoms/action-icon.js +9 -8
- package/dist/atoms/button.js +78 -18
- package/dist/atoms/checkbox.js +77 -17
- package/dist/atoms/hotkeys.js +26 -7
- package/dist/atoms/icon.js +5 -5
- package/dist/atoms/image.js +107 -2
- package/dist/atoms/input.js +57 -9
- package/dist/atoms/label.js +13 -4
- package/dist/atoms/link-button.js +14 -12
- package/dist/atoms/link.js +18 -4
- package/dist/atoms/numeric-input.js +293 -76
- package/dist/atoms/rating.js +306 -73
- package/dist/atoms/skeleton.js +18 -14
- package/dist/atoms/status-text.js +31 -18
- package/dist/atoms/textarea.js +59 -12
- package/dist/atoms/tooltip.js +64 -43
- package/dist/hotkeys.js +1 -0
- package/dist/internal/choice-control.js +173 -0
- package/dist/internal/combobox-query-sync.js +11 -0
- package/dist/internal/date-picker-coordinator.js +56 -40
- package/dist/internal/date-picker-dom.js +44 -0
- package/dist/internal/date-picker-input.js +30 -0
- package/dist/internal/described-by.js +23 -18
- package/dist/internal/form-control-lifecycle.js +122 -0
- package/dist/internal/molecules/command.context.js +1 -0
- package/dist/internal/molecules/drawer.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.styles.js +9 -2
- package/dist/internal/numeric-input-editing.js +87 -0
- package/dist/internal/organisms/sidebar.context.js +1 -0
- package/dist/internal/organisms/sidebar.focus.js +1 -0
- package/dist/internal/overlay-portal.js +72 -0
- package/dist/internal/reduced-motion.js +1 -0
- package/dist/internal/use-effective-disabled.js +8 -0
- package/dist/molecules/accordion.js +44 -30
- package/dist/molecules/availability-status.js +1 -0
- package/dist/molecules/breadcrumb.js +11 -11
- package/dist/molecules/carousel.js +279 -97
- package/dist/molecules/cascade-select.js +327 -81
- package/dist/molecules/chart.js +276 -38
- package/dist/molecules/color-select.js +181 -62
- package/dist/molecules/combobox.js +535 -182
- package/dist/molecules/command.js +2 -1
- package/dist/molecules/date-picker.js +571 -119
- package/dist/molecules/dialog.js +81 -47
- package/dist/molecules/drawer.js +54 -5
- package/dist/molecules/file-upload.js +373 -37
- package/dist/molecules/form-checkbox.js +65 -22
- package/dist/molecules/form-error-summary.js +29 -5
- package/dist/molecules/form-input.js +26 -30
- package/dist/molecules/form-numeric-input.js +11 -9
- package/dist/molecules/form-textarea.js +26 -23
- package/dist/molecules/menu.js +170 -47
- package/dist/molecules/pagination.js +100 -28
- package/dist/molecules/phone-input.js +172 -37
- package/dist/molecules/popover.js +53 -26
- package/dist/molecules/price-block.js +1 -0
- package/dist/molecules/product-card.js +23 -18
- package/dist/molecules/quantity-field.js +4 -2
- package/dist/molecules/radio-card.js +102 -30
- package/dist/molecules/radio-group.js +108 -31
- package/dist/molecules/search-form.js +116 -13
- package/dist/molecules/select.js +226 -81
- package/dist/molecules/slider.js +141 -30
- package/dist/molecules/steps.js +181 -50
- package/dist/molecules/switch.js +85 -20
- package/dist/molecules/tabs.js +227 -31
- package/dist/molecules/toast.js +146 -51
- package/dist/molecules/totals-summary.js +2 -1
- package/dist/molecules/tour.js +9 -5
- package/dist/molecules/tree-view.js +255 -109
- package/dist/molecules/vertical-navigation.js +8 -4
- package/dist/organisms/data-table.fields.js +25 -5
- package/dist/organisms/data-table.helpers.js +6 -2
- package/dist/organisms/data-table.js +580 -151
- package/dist/organisms/footer.js +18 -11
- package/dist/organisms/gallery.js +61 -24
- package/dist/organisms/header.js +106 -32
- package/dist/organisms/line-item.js +1 -0
- package/dist/organisms/sidebar.js +1 -0
- package/dist/organisms/table.js +22 -7
- package/dist/src/atoms/action-icon.d.ts +10 -10
- package/dist/src/atoms/action-icon.d.ts.map +1 -1
- package/dist/src/atoms/badge.d.ts +3 -3
- package/dist/src/atoms/badge.d.ts.map +1 -1
- package/dist/src/atoms/button.d.ts +35 -24
- package/dist/src/atoms/button.d.ts.map +1 -1
- package/dist/src/atoms/checkbox.d.ts +6 -5
- package/dist/src/atoms/checkbox.d.ts.map +1 -1
- package/dist/src/atoms/hotkeys.d.ts +3 -2
- package/dist/src/atoms/hotkeys.d.ts.map +1 -1
- package/dist/src/atoms/icon.d.ts +18 -17
- package/dist/src/atoms/icon.d.ts.map +1 -1
- package/dist/src/atoms/image.d.ts +14 -6
- package/dist/src/atoms/image.d.ts.map +1 -1
- package/dist/src/atoms/input.d.ts +23 -14
- package/dist/src/atoms/input.d.ts.map +1 -1
- package/dist/src/atoms/label.d.ts +4 -4
- package/dist/src/atoms/label.d.ts.map +1 -1
- package/dist/src/atoms/link-button.d.ts +54 -31
- package/dist/src/atoms/link-button.d.ts.map +1 -1
- package/dist/src/atoms/link.d.ts +30 -9
- package/dist/src/atoms/link.d.ts.map +1 -1
- package/dist/src/atoms/numeric-input.d.ts +23 -19
- package/dist/src/atoms/numeric-input.d.ts.map +1 -1
- package/dist/src/atoms/rating.d.ts +54 -26
- package/dist/src/atoms/rating.d.ts.map +1 -1
- package/dist/src/atoms/skeleton.d.ts +9 -9
- package/dist/src/atoms/skeleton.d.ts.map +1 -1
- package/dist/src/atoms/status-text.d.ts +21 -13
- package/dist/src/atoms/status-text.d.ts.map +1 -1
- package/dist/src/atoms/textarea.d.ts +22 -20
- package/dist/src/atoms/textarea.d.ts.map +1 -1
- package/dist/src/atoms/tooltip.d.ts +5 -5
- package/dist/src/atoms/tooltip.d.ts.map +1 -1
- package/dist/src/hotkeys.d.ts +1 -1
- package/dist/src/hotkeys.d.ts.map +1 -1
- package/dist/src/internal/choice-control.d.ts +18 -0
- package/dist/src/internal/choice-control.d.ts.map +1 -0
- package/dist/src/internal/combobox-query-sync.d.ts +4 -0
- package/dist/src/internal/combobox-query-sync.d.ts.map +1 -0
- package/dist/src/internal/date-picker-coordinator.d.ts +7 -1
- package/dist/src/internal/date-picker-coordinator.d.ts.map +1 -1
- package/dist/src/internal/date-picker-dom.d.ts +10 -0
- package/dist/src/internal/date-picker-dom.d.ts.map +1 -0
- package/dist/src/internal/date-picker-input.d.ts +7 -0
- package/dist/src/internal/date-picker-input.d.ts.map +1 -0
- package/dist/src/internal/described-by.d.ts +7 -1
- package/dist/src/internal/described-by.d.ts.map +1 -1
- package/dist/src/internal/form-control-lifecycle.d.ts +22 -0
- package/dist/src/internal/form-control-lifecycle.d.ts.map +1 -0
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts +1 -1
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts.map +1 -1
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts +21 -0
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts.map +1 -1
- package/dist/src/internal/numeric-input-editing.d.ts +13 -0
- package/dist/src/internal/numeric-input-editing.d.ts.map +1 -0
- package/dist/src/internal/overlay-portal.d.ts +18 -0
- package/dist/src/internal/overlay-portal.d.ts.map +1 -0
- package/dist/src/internal/use-effective-disabled.d.ts +4 -0
- package/dist/src/internal/use-effective-disabled.d.ts.map +1 -0
- package/dist/src/molecules/accordion.d.ts +25 -19
- package/dist/src/molecules/accordion.d.ts.map +1 -1
- package/dist/src/molecules/availability-status.d.ts +4 -1
- package/dist/src/molecules/availability-status.d.ts.map +1 -1
- package/dist/src/molecules/breadcrumb.d.ts +2 -2
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
- package/dist/src/molecules/carousel.d.ts +51 -52
- package/dist/src/molecules/carousel.d.ts.map +1 -1
- package/dist/src/molecules/cascade-select.d.ts +23 -8
- package/dist/src/molecules/cascade-select.d.ts.map +1 -1
- package/dist/src/molecules/chart.d.ts +7 -1
- package/dist/src/molecules/chart.d.ts.map +1 -1
- package/dist/src/molecules/color-select.d.ts +19 -3
- package/dist/src/molecules/color-select.d.ts.map +1 -1
- package/dist/src/molecules/combobox.d.ts +23 -5
- package/dist/src/molecules/combobox.d.ts.map +1 -1
- package/dist/src/molecules/command.d.ts +1 -1
- package/dist/src/molecules/date-picker.d.ts +7 -3
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +7 -3
- package/dist/src/molecules/dialog.d.ts.map +1 -1
- package/dist/src/molecules/drawer.d.ts +4 -4
- package/dist/src/molecules/drawer.d.ts.map +1 -1
- package/dist/src/molecules/file-upload.d.ts +11 -6
- package/dist/src/molecules/file-upload.d.ts.map +1 -1
- package/dist/src/molecules/form-checkbox.d.ts +7 -2
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
- package/dist/src/molecules/form-error-summary.d.ts +4 -3
- package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
- package/dist/src/molecules/form-input.d.ts +5 -6
- package/dist/src/molecules/form-input.d.ts.map +1 -1
- package/dist/src/molecules/form-numeric-input.d.ts +5 -5
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
- package/dist/src/molecules/form-textarea.d.ts +5 -6
- package/dist/src/molecules/form-textarea.d.ts.map +1 -1
- package/dist/src/molecules/menu.d.ts +17 -3
- package/dist/src/molecules/menu.d.ts.map +1 -1
- package/dist/src/molecules/pagination.d.ts +1 -1
- package/dist/src/molecules/pagination.d.ts.map +1 -1
- package/dist/src/molecules/phone-input.d.ts +4 -1
- package/dist/src/molecules/phone-input.d.ts.map +1 -1
- package/dist/src/molecules/popover.d.ts +7 -1
- package/dist/src/molecules/popover.d.ts.map +1 -1
- package/dist/src/molecules/price-block.d.ts +1 -1
- package/dist/src/molecules/price-block.d.ts.map +1 -1
- package/dist/src/molecules/product-card.d.ts +20 -25
- package/dist/src/molecules/product-card.d.ts.map +1 -1
- package/dist/src/molecules/quantity-field.d.ts +1 -1
- package/dist/src/molecules/quantity-field.d.ts.map +1 -1
- package/dist/src/molecules/radio-card.d.ts +10 -3
- package/dist/src/molecules/radio-card.d.ts.map +1 -1
- package/dist/src/molecules/radio-group.d.ts +15 -6
- package/dist/src/molecules/radio-group.d.ts.map +1 -1
- package/dist/src/molecules/search-form.d.ts +37 -12
- package/dist/src/molecules/search-form.d.ts.map +1 -1
- package/dist/src/molecules/select.d.ts +34 -29
- package/dist/src/molecules/select.d.ts.map +1 -1
- package/dist/src/molecules/slider.d.ts +23 -2
- package/dist/src/molecules/slider.d.ts.map +1 -1
- package/dist/src/molecules/steps.d.ts +30 -10
- package/dist/src/molecules/steps.d.ts.map +1 -1
- package/dist/src/molecules/switch.d.ts +54 -33
- package/dist/src/molecules/switch.d.ts.map +1 -1
- package/dist/src/molecules/tabs.d.ts +11 -11
- package/dist/src/molecules/tabs.d.ts.map +1 -1
- package/dist/src/molecules/toast.d.ts +25 -13
- package/dist/src/molecules/toast.d.ts.map +1 -1
- package/dist/src/molecules/totals-summary.d.ts +1 -1
- package/dist/src/molecules/totals-summary.d.ts.map +1 -1
- package/dist/src/molecules/tour.d.ts +1 -1
- package/dist/src/molecules/tour.d.ts.map +1 -1
- package/dist/src/molecules/tree-view.d.ts +16 -20
- package/dist/src/molecules/tree-view.d.ts.map +1 -1
- package/dist/src/molecules/vertical-navigation.d.ts +2 -2
- package/dist/src/molecules/vertical-navigation.d.ts.map +1 -1
- package/dist/src/organisms/data-table.d.ts +24 -3
- package/dist/src/organisms/data-table.d.ts.map +1 -1
- package/dist/src/organisms/data-table.fields.d.ts +4 -1
- package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
- package/dist/src/organisms/data-table.helpers.d.ts +5 -12
- package/dist/src/organisms/data-table.helpers.d.ts.map +1 -1
- package/dist/src/organisms/footer.d.ts +5 -5
- package/dist/src/organisms/footer.d.ts.map +1 -1
- package/dist/src/organisms/gallery.d.ts +11 -9
- package/dist/src/organisms/gallery.d.ts.map +1 -1
- package/dist/src/organisms/header.d.ts +24 -22
- package/dist/src/organisms/header.d.ts.map +1 -1
- package/dist/src/organisms/table.d.ts +14 -14
- package/dist/src/organisms/table.d.ts.map +1 -1
- package/dist/src/templates/accordion.d.ts +8 -6
- package/dist/src/templates/accordion.d.ts.map +1 -1
- package/dist/src/templates/breadcrumb.d.ts +1 -1
- package/dist/src/templates/breadcrumb.d.ts.map +1 -1
- package/dist/src/templates/carousel.d.ts +3 -3
- package/dist/src/templates/carousel.d.ts.map +1 -1
- package/dist/src/templates/facet-filter-panel.d.ts +9 -3
- package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
- package/dist/src/templates/gallery.d.ts +2 -2
- package/dist/src/templates/gallery.d.ts.map +1 -1
- package/dist/src/templates/numeric-input.d.ts +1 -1
- package/dist/src/templates/numeric-input.d.ts.map +1 -1
- package/dist/src/templates/popover.d.ts +4 -2
- package/dist/src/templates/popover.d.ts.map +1 -1
- package/dist/src/templates/product-card.d.ts +12 -4
- package/dist/src/templates/product-card.d.ts.map +1 -1
- package/dist/src/templates/search-suggestions.d.ts +1 -1
- package/dist/src/templates/select.d.ts +7 -2
- package/dist/src/templates/select.d.ts.map +1 -1
- package/dist/src/templates/tabs.d.ts +8 -7
- package/dist/src/templates/tabs.d.ts.map +1 -1
- package/dist/src/theme/theme-config.d.ts +9 -16
- package/dist/src/theme/theme-config.d.ts.map +1 -1
- package/dist/src/theme/theme-provider.d.ts +16 -21
- package/dist/src/theme/theme-provider.d.ts.map +1 -1
- package/dist/src/theme/theme-toggle.d.ts.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/templates/accordion.js +3 -1
- package/dist/templates/breadcrumb.js +11 -4
- package/dist/templates/carousel.js +3 -6
- package/dist/templates/facet-filter-panel.js +121 -52
- package/dist/templates/gallery.js +6 -2
- package/dist/templates/numeric-input.js +6 -1
- package/dist/templates/popover.js +6 -1
- package/dist/templates/product-card.js +52 -26
- package/dist/templates/select.js +6 -1
- package/dist/templates/tabs.js +4 -2
- package/dist/theme/theme-config.js +8 -16
- package/dist/theme/theme-provider.js +89 -63
- package/dist/theme/theme-toggle.js +17 -9
- package/dist/utils.js +11 -1
- package/package.json +9 -5
- package/src/tokens/_base.css +4 -3
- package/src/tokens/_business-atoms.css +103 -0
- package/src/tokens/_foundation-overrides.css +251 -0
- package/src/tokens/_reset.css +10 -10
- package/src/tokens/_scheme-scopes.css +4144 -0
- package/src/tokens/_semantic.css +1 -23
- package/src/tokens/_tokens-base.css +36 -32
- package/src/tokens/_typography.css +2 -1
- package/src/tokens/components/_form-control.css +149 -6
- package/src/tokens/components/_popup-surface.css +15 -29
- package/src/tokens/components/atoms/_action-icon.css +49 -0
- package/src/tokens/components/atoms/_button.css +67 -0
- package/src/tokens/components/atoms/_checkbox.css +47 -4
- package/src/tokens/components/atoms/_hotkeys.css +2 -0
- package/src/tokens/components/atoms/_icon.css +60 -7
- package/src/tokens/components/atoms/_image.css +18 -0
- package/src/tokens/components/atoms/_input.css +20 -0
- package/src/tokens/components/atoms/_label.css +3 -7
- package/src/tokens/components/atoms/_link.css +47 -5
- package/src/tokens/components/atoms/_numeric-input.css +111 -2
- package/src/tokens/components/atoms/_rating.css +55 -6
- package/src/tokens/components/atoms/_skeleton.css +12 -2
- package/src/tokens/components/atoms/_status-text.css +35 -5
- package/src/tokens/components/atoms/_textarea.css +32 -3
- package/src/tokens/components/atoms/_tooltip.css +25 -0
- package/src/tokens/components/molecules/_accordion.css +46 -5
- package/src/tokens/components/molecules/_breadcrumb.css +15 -4
- package/src/tokens/components/molecules/_carousel.css +67 -0
- package/src/tokens/components/molecules/_cascade-select.css +104 -0
- package/src/tokens/components/molecules/_chart.css +12 -14
- package/src/tokens/components/molecules/_color-select.css +21 -0
- package/src/tokens/components/molecules/_combobox.css +81 -0
- package/src/tokens/components/molecules/_command.css +1 -0
- package/src/tokens/components/molecules/_date-picker.css +66 -10
- package/src/tokens/components/molecules/_dialog.css +36 -4
- package/src/tokens/components/molecules/_drawer.css +39 -3
- package/src/tokens/components/molecules/_file-upload.css +16 -1
- package/src/tokens/components/molecules/_menu.css +17 -0
- package/src/tokens/components/molecules/_pagination.css +19 -0
- package/src/tokens/components/molecules/_phone-input.css +20 -5
- package/src/tokens/components/molecules/_popover.css +34 -0
- package/src/tokens/components/molecules/_product-card.css +49 -0
- package/src/tokens/components/molecules/_radio-card.css +35 -0
- package/src/tokens/components/molecules/_radio-group.css +8 -0
- package/src/tokens/components/molecules/_select.css +33 -0
- package/src/tokens/components/molecules/_slider.css +5 -0
- package/src/tokens/components/molecules/_steps.css +52 -0
- package/src/tokens/components/molecules/_switch.css +59 -10
- package/src/tokens/components/molecules/_tabs.css +61 -3
- package/src/tokens/components/molecules/_toast.css +60 -0
- package/src/tokens/components/molecules/_totals-summary.css +22 -22
- package/src/tokens/components/molecules/_tour.css +16 -1
- package/src/tokens/components/molecules/_tree-view.css +27 -3
- package/src/tokens/components/molecules/_vertical-navigation.css +21 -3
- package/src/tokens/components/organisms/_data-table.css +97 -0
- package/src/tokens/components/organisms/_footer.css +9 -0
- package/src/tokens/components/organisms/_gallery.css +11 -0
- package/src/tokens/components/organisms/_header.css +22 -0
- package/src/tokens/components/organisms/_sidebar.css +1 -1
- package/src/tokens/components/organisms/_table.css +31 -0
- package/src/tokens/components/templates/_facet-filter-panel.css +11 -1
- package/src/tokens/figma/akros/variables.css +6 -6
- package/src/tokens/figma/brand-overrides.css +162 -57
- package/src/tokens/figma/business/variables.css +6 -6
- package/src/tokens/figma/cyber/variables.css +115 -38
- package/src/tokens/figma/cyber-dark/variables.css +115 -38
- package/src/tokens/figma/dark/variables.css +4 -4
- package/src/tokens/figma/light/variables.css +43 -40
- package/src/tokens/figma/{neo → n1}/variables.css +114 -114
- package/src/tokens/figma/variables.css +639 -240
- package/src/tokens/theme.css +24 -4
- package/src/tokens/_colors.css +0 -5
- package/src/tokens/figma/neo-dark/variables.css +0 -457
package/dist/molecules/chart.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { areaY, barX, barY, colorLegend, colorLegendItems, d3Curve, dot, group, lineY, stack } from "@tanstack/charts";
|
|
3
4
|
import { polar, radialArc } from "@tanstack/charts/polar";
|
|
4
5
|
import { Chart } from "@tanstack/charts/react";
|
|
5
6
|
import { scaleBand } from "@tanstack/charts/scales/band";
|
|
@@ -9,13 +10,19 @@ import { renderChartSvg } from "@tanstack/charts/svg";
|
|
|
9
10
|
import { tooltip as tooltip_tooltip } from "@tanstack/charts/tooltip";
|
|
10
11
|
import { scaleUtc } from "d3-scale";
|
|
11
12
|
import { curveMonotoneX, pie } from "d3-shape";
|
|
12
|
-
import { useMemo } from "react";
|
|
13
|
+
import { useMemo, useRef, useState } from "react";
|
|
13
14
|
import { usePrefersReducedMotion } from "../internal/reduced-motion.js";
|
|
14
15
|
import { tv } from "../utils.js";
|
|
15
16
|
const chartVariants = tv({
|
|
16
17
|
slots: {
|
|
17
18
|
root: "chart-base block w-full text-chart-fg",
|
|
18
|
-
tooltip: "chart-tooltip"
|
|
19
|
+
tooltip: "chart-tooltip popup-layer!",
|
|
20
|
+
alternative: "overflow-auto text-chart-data text-chart-fg",
|
|
21
|
+
summary: "cursor-pointer rounded-chart-tooltip focus-visible:outline-chart-fg",
|
|
22
|
+
cell: "border-chart-tooltip-border border-b p-chart-tooltip text-start",
|
|
23
|
+
legend: "flex flex-wrap gap-chart-legend text-chart-data text-chart-fg",
|
|
24
|
+
legendItem: "inline-flex items-center gap-chart-item",
|
|
25
|
+
fallback: "p-chart-tooltip text-chart-data text-chart-fg"
|
|
19
26
|
}
|
|
20
27
|
});
|
|
21
28
|
const SERIES_1_PAINT = "var(--color-chart-series-1)";
|
|
@@ -26,27 +33,42 @@ function toAccessor(accessor) {
|
|
|
26
33
|
if ("function" == typeof accessor) return accessor;
|
|
27
34
|
return (datum)=>datum[accessor];
|
|
28
35
|
}
|
|
36
|
+
const READABLE_TICK_LABELS = {
|
|
37
|
+
fontSize: 14,
|
|
38
|
+
opacity: 1
|
|
39
|
+
};
|
|
29
40
|
const MAX_SERIES = 6;
|
|
41
|
+
const LINE_DASHES = [
|
|
42
|
+
"",
|
|
43
|
+
"8 4",
|
|
44
|
+
"2 4",
|
|
45
|
+
"8 4 2 4",
|
|
46
|
+
"12 4",
|
|
47
|
+
"4 4"
|
|
48
|
+
];
|
|
30
49
|
function resolveXAxis(data, getX, xLabel) {
|
|
31
50
|
const values = data.map(getX);
|
|
32
51
|
if (values.length > 0 && values.every((value)=>value instanceof Date)) return {
|
|
33
52
|
scale: ()=>scaleUtc(),
|
|
34
53
|
nice: true,
|
|
35
54
|
axis: {
|
|
36
|
-
label: xLabel
|
|
55
|
+
label: xLabel,
|
|
56
|
+
tickLabels: READABLE_TICK_LABELS
|
|
37
57
|
}
|
|
38
58
|
};
|
|
39
59
|
if (values.length > 0 && values.every((value)=>"number" == typeof value)) return {
|
|
40
60
|
scale: scaleLinear,
|
|
41
61
|
nice: true,
|
|
42
62
|
axis: {
|
|
43
|
-
label: xLabel
|
|
63
|
+
label: xLabel,
|
|
64
|
+
tickLabels: READABLE_TICK_LABELS
|
|
44
65
|
}
|
|
45
66
|
};
|
|
46
67
|
return {
|
|
47
68
|
scale: ()=>scalePoint().padding(0.1),
|
|
48
69
|
axis: {
|
|
49
|
-
label: xLabel
|
|
70
|
+
label: xLabel,
|
|
71
|
+
tickLabels: READABLE_TICK_LABELS
|
|
50
72
|
}
|
|
51
73
|
};
|
|
52
74
|
}
|
|
@@ -57,9 +79,9 @@ function resolveBuild(config) {
|
|
|
57
79
|
const isPolar = "pie" === config.type || "donut" === config.type;
|
|
58
80
|
const showLegend = config.legend ?? (null != config.series || isPolar);
|
|
59
81
|
const { formatValue } = config;
|
|
60
|
-
const valueTicks =
|
|
82
|
+
const valueTicks = {
|
|
61
83
|
format: formatValue
|
|
62
|
-
}
|
|
84
|
+
};
|
|
63
85
|
warnOnSeriesOverflow(config.data, isPolar ? getX : getSeries);
|
|
64
86
|
const tooltipBase = {
|
|
65
87
|
use: tooltip_tooltip,
|
|
@@ -122,7 +144,8 @@ function resolveBuild(config) {
|
|
|
122
144
|
grid: config.grid,
|
|
123
145
|
axis: {
|
|
124
146
|
label: config.yLabel,
|
|
125
|
-
ticks: valueTicks
|
|
147
|
+
ticks: valueTicks,
|
|
148
|
+
tickLabels: READABLE_TICK_LABELS
|
|
126
149
|
}
|
|
127
150
|
};
|
|
128
151
|
const xAxis = resolveXAxis(config.data, getX, config.xLabel);
|
|
@@ -131,6 +154,7 @@ function resolveBuild(config) {
|
|
|
131
154
|
getX,
|
|
132
155
|
getY,
|
|
133
156
|
getSeries,
|
|
157
|
+
seriesDomain: config.seriesDomain,
|
|
134
158
|
stacked: config.stacked,
|
|
135
159
|
points: config.points,
|
|
136
160
|
curve: config.smooth ? d3Curve(curveMonotoneX) : void 0,
|
|
@@ -143,17 +167,25 @@ function resolveBuild(config) {
|
|
|
143
167
|
bandAxis: {
|
|
144
168
|
scale: ()=>scaleBand().padding(0.3),
|
|
145
169
|
axis: {
|
|
146
|
-
label: config.xLabel
|
|
170
|
+
label: config.xLabel,
|
|
171
|
+
tickLabels: READABLE_TICK_LABELS
|
|
147
172
|
}
|
|
148
173
|
},
|
|
149
174
|
tooltipFor,
|
|
150
175
|
polarTooltip,
|
|
151
176
|
shared: {
|
|
152
|
-
color:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
177
|
+
color: {
|
|
178
|
+
domain: config.seriesDomain,
|
|
179
|
+
legend: showLegend && "line" !== config.type ? colorLegend({
|
|
180
|
+
label: config.legendLabel,
|
|
181
|
+
items: colorLegendItems({
|
|
182
|
+
label: {
|
|
183
|
+
fontSize: 14,
|
|
184
|
+
fillOpacity: 1
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
}) : void 0
|
|
188
|
+
},
|
|
157
189
|
svgAnimation: config.animate
|
|
158
190
|
}
|
|
159
191
|
};
|
|
@@ -166,18 +198,26 @@ function warnOnSeriesOverflow(data, getColorIdentity) {
|
|
|
166
198
|
}
|
|
167
199
|
function buildLine(build) {
|
|
168
200
|
const { data, getX, getY, getSeries } = build;
|
|
201
|
+
const identities = getSeries ? [
|
|
202
|
+
...new Set(data.map(getSeries))
|
|
203
|
+
] : [
|
|
204
|
+
void 0
|
|
205
|
+
];
|
|
169
206
|
return {
|
|
170
|
-
marks:
|
|
171
|
-
|
|
207
|
+
marks: identities.map((identity)=>{
|
|
208
|
+
const rows = getSeries ? data.filter((row)=>getSeries(row) === identity) : data;
|
|
209
|
+
const index = null == identity ? 0 : build.seriesDomain?.indexOf(identity) ?? 0;
|
|
210
|
+
return lineY(rows, {
|
|
172
211
|
x: getX,
|
|
173
212
|
y: getY,
|
|
174
213
|
z: getSeries,
|
|
175
214
|
color: getSeries,
|
|
176
|
-
points: build.points,
|
|
215
|
+
points: build.points || 1 === rows.length,
|
|
177
216
|
curve: build.curve,
|
|
217
|
+
strokeDasharray: LINE_DASHES[index % LINE_DASHES.length],
|
|
178
218
|
stroke: null == getSeries ? SERIES_1_PAINT : void 0
|
|
179
|
-
})
|
|
180
|
-
|
|
219
|
+
});
|
|
220
|
+
}),
|
|
181
221
|
scales: {
|
|
182
222
|
x: build.xAxis,
|
|
183
223
|
y: build.valueAxis
|
|
@@ -247,7 +287,8 @@ function buildBars(build, horizontal) {
|
|
|
247
287
|
grid: build.grid,
|
|
248
288
|
axis: {
|
|
249
289
|
label: build.yLabel,
|
|
250
|
-
ticks: build.valueTicks
|
|
290
|
+
ticks: build.valueTicks,
|
|
291
|
+
tickLabels: READABLE_TICK_LABELS
|
|
251
292
|
}
|
|
252
293
|
},
|
|
253
294
|
y: build.bandAxis
|
|
@@ -385,22 +426,176 @@ function renderCartesianChartSvg(scene, options) {
|
|
|
385
426
|
children
|
|
386
427
|
};
|
|
387
428
|
});
|
|
388
|
-
return
|
|
429
|
+
return renderReadableChartSvg({
|
|
389
430
|
...scene,
|
|
390
431
|
nodes
|
|
391
432
|
}, options);
|
|
392
433
|
}
|
|
393
|
-
function
|
|
394
|
-
const
|
|
434
|
+
function renderReadableChartSvg(scene, options) {
|
|
435
|
+
const readable = (node)=>{
|
|
436
|
+
if ("group" === node.kind) return {
|
|
437
|
+
...node,
|
|
438
|
+
children: node.children.map(readable)
|
|
439
|
+
};
|
|
440
|
+
if ("label" === node.kind) return {
|
|
441
|
+
...node,
|
|
442
|
+
fontSize: Math.max(READABLE_TICK_LABELS.fontSize, node.fontSize ?? 0),
|
|
443
|
+
style: {
|
|
444
|
+
...node.style,
|
|
445
|
+
fillOpacity: 1,
|
|
446
|
+
opacity: 1
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
return node;
|
|
450
|
+
};
|
|
451
|
+
return renderChartSvg({
|
|
452
|
+
...scene,
|
|
453
|
+
nodes: scene.nodes.map(readable)
|
|
454
|
+
}, options);
|
|
455
|
+
}
|
|
456
|
+
function useStableSeriesDomain(data, getIdentity, domain) {
|
|
457
|
+
const seenIdentities = useRef([]);
|
|
458
|
+
for (const datum of data){
|
|
459
|
+
const identity = getIdentity?.(datum);
|
|
460
|
+
if (null != identity && !seenIdentities.current.includes(identity)) seenIdentities.current.push(identity);
|
|
461
|
+
}
|
|
462
|
+
return domain ?? seenIdentities.current;
|
|
463
|
+
}
|
|
464
|
+
function filterChartData(data, x, y) {
|
|
465
|
+
const getX = toAccessor(x);
|
|
466
|
+
const getY = toAccessor(y);
|
|
467
|
+
return data.filter((datum)=>{
|
|
468
|
+
const category = getX(datum);
|
|
469
|
+
return Number.isFinite(getY(datum)) && ("number" != typeof category || Number.isFinite(category)) && (!(category instanceof Date) || Number.isFinite(category.getTime()));
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function invalidPolarData(data, validData, getY) {
|
|
473
|
+
const total = validData.reduce((sum, datum)=>sum + getY(datum), 0);
|
|
474
|
+
return validData.length !== data.length || validData.some((datum)=>getY(datum) < 0) || validData.length > 0 && (!Number.isFinite(total) || total <= 0);
|
|
475
|
+
}
|
|
476
|
+
function ChartDataAlternative({ data, x, y, series, xLabel, yLabel, legendLabel, formatValue, ariaLabel, dataTableLabel }) {
|
|
477
|
+
const { alternative, summary, cell } = chartVariants();
|
|
478
|
+
const getX = toAccessor(x);
|
|
479
|
+
const getY = toAccessor(y);
|
|
480
|
+
const getSeries = null == series ? void 0 : toAccessor(series);
|
|
481
|
+
const occurrences = new Map();
|
|
482
|
+
return /*#__PURE__*/ jsxs("details", {
|
|
483
|
+
className: alternative(),
|
|
484
|
+
children: [
|
|
485
|
+
/*#__PURE__*/ jsx("summary", {
|
|
486
|
+
className: summary(),
|
|
487
|
+
children: dataTableLabel
|
|
488
|
+
}),
|
|
489
|
+
/*#__PURE__*/ jsxs("table", {
|
|
490
|
+
children: [
|
|
491
|
+
/*#__PURE__*/ jsx("caption", {
|
|
492
|
+
children: ariaLabel
|
|
493
|
+
}),
|
|
494
|
+
/*#__PURE__*/ jsx("thead", {
|
|
495
|
+
children: /*#__PURE__*/ jsxs("tr", {
|
|
496
|
+
children: [
|
|
497
|
+
getSeries && /*#__PURE__*/ jsx("th", {
|
|
498
|
+
className: cell(),
|
|
499
|
+
scope: "col",
|
|
500
|
+
children: legendLabel ?? ("string" == typeof series ? series : "Series")
|
|
501
|
+
}),
|
|
502
|
+
/*#__PURE__*/ jsx("th", {
|
|
503
|
+
className: cell(),
|
|
504
|
+
scope: "col",
|
|
505
|
+
children: xLabel ?? ("string" == typeof x ? x : "Category")
|
|
506
|
+
}),
|
|
507
|
+
/*#__PURE__*/ jsx("th", {
|
|
508
|
+
className: cell(),
|
|
509
|
+
scope: "col",
|
|
510
|
+
children: yLabel ?? ("string" == typeof y ? y : "Value")
|
|
511
|
+
})
|
|
512
|
+
]
|
|
513
|
+
})
|
|
514
|
+
}),
|
|
515
|
+
/*#__PURE__*/ jsx("tbody", {
|
|
516
|
+
children: data.map((datum)=>{
|
|
517
|
+
const identity = `${String(getX(datum))}:${getSeries?.(datum) ?? ""}`;
|
|
518
|
+
const occurrence = occurrences.get(identity) ?? 0;
|
|
519
|
+
occurrences.set(identity, occurrence + 1);
|
|
520
|
+
return /*#__PURE__*/ jsxs("tr", {
|
|
521
|
+
children: [
|
|
522
|
+
getSeries && /*#__PURE__*/ jsx("td", {
|
|
523
|
+
className: cell(),
|
|
524
|
+
children: getSeries(datum)
|
|
525
|
+
}),
|
|
526
|
+
/*#__PURE__*/ jsx("td", {
|
|
527
|
+
className: cell(),
|
|
528
|
+
children: String(getX(datum))
|
|
529
|
+
}),
|
|
530
|
+
/*#__PURE__*/ jsx("td", {
|
|
531
|
+
className: cell(),
|
|
532
|
+
children: formatValue ? formatValue(getY(datum)) : String(getY(datum))
|
|
533
|
+
})
|
|
534
|
+
]
|
|
535
|
+
}, `${identity}:${occurrence}`);
|
|
536
|
+
})
|
|
537
|
+
})
|
|
538
|
+
]
|
|
539
|
+
})
|
|
540
|
+
]
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function ChartLineLegend({ identities, domain, label }) {
|
|
544
|
+
const { legend, legendItem } = chartVariants();
|
|
545
|
+
return /*#__PURE__*/ jsx("ul", {
|
|
546
|
+
"aria-label": label,
|
|
547
|
+
className: legend(),
|
|
548
|
+
children: identities.map((identity)=>{
|
|
549
|
+
const index = Math.max(0, domain.indexOf(identity));
|
|
550
|
+
return /*#__PURE__*/ jsxs("li", {
|
|
551
|
+
className: legendItem(),
|
|
552
|
+
children: [
|
|
553
|
+
/*#__PURE__*/ jsx("svg", {
|
|
554
|
+
"aria-hidden": "true",
|
|
555
|
+
height: "12",
|
|
556
|
+
viewBox: "0 0 32 12",
|
|
557
|
+
width: "32",
|
|
558
|
+
children: /*#__PURE__*/ jsx("line", {
|
|
559
|
+
stroke: `var(--color-chart-series-${index % MAX_SERIES + 1})`,
|
|
560
|
+
strokeDasharray: LINE_DASHES[index % LINE_DASHES.length],
|
|
561
|
+
strokeWidth: "2",
|
|
562
|
+
x1: "0",
|
|
563
|
+
x2: "32",
|
|
564
|
+
y1: "6",
|
|
565
|
+
y2: "6"
|
|
566
|
+
})
|
|
567
|
+
}),
|
|
568
|
+
identity
|
|
569
|
+
]
|
|
570
|
+
}, identity);
|
|
571
|
+
})
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function chart_Chart({ type = "line", data, x, y, series, seriesDomain, stacked, points = false, smooth = false, grid = true, legend, legendLabel, xLabel, yLabel, formatValue, height, aspectRatio, initialWidth = 640, animate, tooltip = true, ariaLabel, ariaDescription, className, dataTableLabel = "View chart data", emptyLabel = "No data to display.", invalidLabel = "Pie and donut values must be finite, non-negative numbers with a positive total.", onSelect }) {
|
|
575
|
+
const { root, tooltip: tooltipSlot, fallback } = chartVariants();
|
|
395
576
|
const tooltipClassName = tooltipSlot();
|
|
396
577
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
397
578
|
const shouldAnimate = animate ?? !prefersReducedMotion;
|
|
579
|
+
const [dismissed, setDismissed] = useState(false);
|
|
580
|
+
const getX = toAccessor(x);
|
|
581
|
+
const getY = toAccessor(y);
|
|
582
|
+
const getSeries = null == series ? void 0 : toAccessor(series);
|
|
583
|
+
const isPolar = "pie" === type || "donut" === type;
|
|
584
|
+
const validData = useMemo(()=>filterChartData(data, x, y), [
|
|
585
|
+
data,
|
|
586
|
+
x,
|
|
587
|
+
y
|
|
588
|
+
]);
|
|
589
|
+
const invalidPolar = isPolar && invalidPolarData(data, validData, getY);
|
|
590
|
+
const stableDomain = useStableSeriesDomain(validData, isPolar ? (datum)=>String(getX(datum)) : getSeries, isPolar ? seriesDomain?.map(String) : seriesDomain);
|
|
591
|
+
const domainKey = JSON.stringify(stableDomain);
|
|
398
592
|
const definition = useMemo(()=>buildChartDefinition({
|
|
399
593
|
type,
|
|
400
|
-
data,
|
|
594
|
+
data: invalidPolar ? [] : validData,
|
|
401
595
|
x,
|
|
402
596
|
y,
|
|
403
597
|
series,
|
|
598
|
+
seriesDomain: JSON.parse(domainKey),
|
|
404
599
|
stacked,
|
|
405
600
|
points,
|
|
406
601
|
smooth,
|
|
@@ -411,11 +606,14 @@ function chart_Chart({ type = "line", data, x, y, series, stacked, points = fals
|
|
|
411
606
|
yLabel,
|
|
412
607
|
formatValue,
|
|
413
608
|
animate: shouldAnimate,
|
|
414
|
-
showTooltip: tooltip,
|
|
609
|
+
showTooltip: tooltip && !dismissed,
|
|
415
610
|
tooltipClassName
|
|
416
611
|
}), [
|
|
417
612
|
type,
|
|
418
|
-
|
|
613
|
+
validData,
|
|
614
|
+
invalidPolar,
|
|
615
|
+
domainKey,
|
|
616
|
+
dismissed,
|
|
419
617
|
x,
|
|
420
618
|
y,
|
|
421
619
|
series,
|
|
@@ -432,23 +630,63 @@ function chart_Chart({ type = "line", data, x, y, series, stacked, points = fals
|
|
|
432
630
|
tooltip,
|
|
433
631
|
tooltipClassName
|
|
434
632
|
]);
|
|
435
|
-
const isPolar = "pie" === type || "donut" === type;
|
|
436
633
|
const handleSelect = onSelect ? (point)=>{
|
|
437
634
|
if (null == point) return void onSelect(null);
|
|
438
635
|
onSelect(isPolar ? point.datum.data : point.datum);
|
|
439
636
|
} : void 0;
|
|
440
|
-
return /*#__PURE__*/
|
|
441
|
-
ariaDescription: ariaDescription,
|
|
442
|
-
ariaLabel: ariaLabel,
|
|
443
|
-
aspectRatio: null == height ? aspectRatio ?? 16 / 9 : void 0,
|
|
637
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
444
638
|
className: root({
|
|
445
639
|
className
|
|
446
640
|
}),
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
641
|
+
onKeyDownCapture: (event)=>{
|
|
642
|
+
if ("Escape" === event.key) setDismissed(true);
|
|
643
|
+
else if ([
|
|
644
|
+
"ArrowLeft",
|
|
645
|
+
"ArrowRight",
|
|
646
|
+
"ArrowUp",
|
|
647
|
+
"ArrowDown",
|
|
648
|
+
"Home",
|
|
649
|
+
"End"
|
|
650
|
+
].includes(event.key)) setDismissed(false);
|
|
651
|
+
},
|
|
652
|
+
onPointerMoveCapture: ()=>{
|
|
653
|
+
if (dismissed) setDismissed(false);
|
|
654
|
+
},
|
|
655
|
+
children: [
|
|
656
|
+
invalidPolar || 0 === validData.length ? /*#__PURE__*/ jsx("p", {
|
|
657
|
+
className: fallback(),
|
|
658
|
+
role: "status",
|
|
659
|
+
children: invalidPolar ? invalidLabel : emptyLabel
|
|
660
|
+
}) : /*#__PURE__*/ jsx(Chart, {
|
|
661
|
+
ariaDescription: ariaDescription,
|
|
662
|
+
ariaLabel: ariaLabel,
|
|
663
|
+
aspectRatio: null == height ? aspectRatio ?? 16 / 9 : void 0,
|
|
664
|
+
definition: definition,
|
|
665
|
+
height: height,
|
|
666
|
+
initialWidth: initialWidth,
|
|
667
|
+
onSelect: handleSelect,
|
|
668
|
+
renderSvg: isPolar ? renderReadableChartSvg : renderCartesianChartSvg
|
|
669
|
+
}),
|
|
670
|
+
"line" === type && getSeries && false !== legend && !invalidPolar && /*#__PURE__*/ jsx(ChartLineLegend, {
|
|
671
|
+
domain: stableDomain,
|
|
672
|
+
identities: [
|
|
673
|
+
...new Set(validData.map(getSeries))
|
|
674
|
+
],
|
|
675
|
+
label: legendLabel
|
|
676
|
+
}),
|
|
677
|
+
validData.length > 0 && !invalidPolar && /*#__PURE__*/ jsx(ChartDataAlternative, {
|
|
678
|
+
ariaLabel: ariaLabel,
|
|
679
|
+
data: validData,
|
|
680
|
+
dataTableLabel: dataTableLabel,
|
|
681
|
+
formatValue: formatValue,
|
|
682
|
+
legendLabel: legendLabel,
|
|
683
|
+
series: series,
|
|
684
|
+
x: x,
|
|
685
|
+
xLabel: xLabel,
|
|
686
|
+
y: y,
|
|
687
|
+
yLabel: yLabel
|
|
688
|
+
})
|
|
689
|
+
]
|
|
452
690
|
});
|
|
453
691
|
}
|
|
454
692
|
export { chart_Chart as Chart };
|