@giddaa-housing/ui 0.1.0 → 1.1.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 +18 -6
- package/css/base.css +37 -0
- package/css/components.css +135 -0
- package/css/generated/shared.css +1 -0
- package/css/giddaa.css +402 -0
- package/css/preset.css +77 -0
- package/css/styles.css +2 -0
- package/css/theme.css +255 -0
- package/dist/accordion.d.ts +9 -10
- package/dist/accordion.js +41 -117
- package/dist/activity-timeline.d.ts +29 -0
- package/dist/activity-timeline.js +97 -0
- package/dist/alert.d.ts +8 -9
- package/dist/alert.js +53 -141
- package/dist/auth-layout.d.ts +23 -0
- package/dist/auth-layout.js +153 -0
- package/dist/avatar.d.ts +6 -6
- package/dist/avatar.js +40 -142
- package/dist/badge.d.ts +12 -13
- package/dist/badge.js +66 -114
- package/dist/bar-chart.d.ts +136 -114
- package/dist/bar-chart.js +244 -297
- package/dist/breadcrumb.d.ts +5 -5
- package/dist/breadcrumb.js +56 -148
- package/dist/bullet-chart.d.ts +33 -33
- package/dist/bullet-chart.js +123 -183
- package/dist/button-BZIeyUw6.d.ts +17 -0
- package/dist/button-group.d.ts +13 -16
- package/dist/button-group.js +38 -163
- package/dist/button.d.ts +2 -19
- package/dist/button.js +90 -142
- package/dist/calendar.d.ts +6 -6
- package/dist/calendar.js +134 -288
- package/dist/card.d.ts +14 -16
- package/dist/card.js +58 -174
- package/dist/carousel.d.ts +34 -35
- package/dist/carousel.js +319 -378
- package/dist/chart.d.ts +58 -59
- package/dist/chart.js +350 -466
- package/dist/checkbox.d.ts +10 -12
- package/dist/checkbox.js +84 -84
- package/dist/cn-BI_4DMBf.js +23 -0
- package/dist/collapsible.d.ts +7 -8
- package/dist/collapsible.js +23 -77
- package/dist/combobox.d.ts +10 -10
- package/dist/combobox.js +220 -696
- package/dist/cta.d.ts +64 -0
- package/dist/cta.js +192 -0
- package/dist/currency-selector.d.ts +41 -0
- package/dist/currency-selector.js +114 -0
- package/dist/data-table.d.ts +164 -0
- package/dist/data-table.js +673 -0
- package/dist/date-picker.d.ts +27 -20
- package/dist/date-picker.js +122 -520
- package/dist/details-card.d.ts +19 -0
- package/dist/details-card.js +118 -0
- package/dist/dialog.d.ts +13 -14
- package/dist/dialog.js +117 -320
- package/dist/dropdown-menu.d.ts +14 -14
- package/dist/dropdown-menu.js +170 -365
- package/dist/dropzone.d.ts +55 -55
- package/dist/dropzone.js +328 -467
- package/dist/editorial-card.d.ts +27 -0
- package/dist/editorial-card.js +144 -0
- package/dist/empty-state.d.ts +8 -9
- package/dist/empty-state.js +48 -135
- package/dist/field.d.ts +23 -25
- package/dist/field.js +111 -327
- package/dist/filter.d.ts +118 -0
- package/dist/filter.js +775 -0
- package/dist/footer.d.ts +40 -0
- package/dist/footer.js +227 -0
- package/dist/funnel-chart.d.ts +38 -41
- package/dist/funnel-chart.js +168 -563
- package/dist/gallery-indicator.d.ts +17 -0
- package/dist/gallery-indicator.js +75 -0
- package/dist/heatmap-chart.d.ts +95 -0
- package/dist/heatmap-chart.js +197 -0
- package/dist/infotip.d.ts +10 -0
- package/dist/infotip.js +40 -0
- package/dist/input-CfoEJ8A6.d.ts +12 -0
- package/dist/input-group.d.ts +16 -19
- package/dist/input-group.js +92 -372
- package/dist/input-size-context-C-SFx9sx.d.ts +10 -0
- package/dist/input-size-context.d.ts +2 -11
- package/dist/input-size-context.js +14 -20
- package/dist/input.d.ts +2 -13
- package/dist/input.js +23 -79
- package/dist/item.d.ts +7 -8
- package/dist/item.js +22 -89
- package/dist/kpi-card.d.ts +18 -20
- package/dist/kpi-card.js +84 -232
- package/dist/label.d.ts +6 -6
- package/dist/label.js +39 -66
- package/dist/line-chart.d.ts +88 -89
- package/dist/line-chart.js +143 -262
- package/dist/logo.d.ts +4 -4
- package/dist/logo.js +87 -141
- package/dist/map-indicator.d.ts +13 -0
- package/dist/map-indicator.js +83 -0
- package/dist/match.d.ts +15 -0
- package/dist/match.js +68 -0
- package/dist/media-gallery-hero.d.ts +58 -0
- package/dist/media-gallery-hero.js +201 -0
- package/dist/media-player.d.ts +60 -0
- package/dist/media-player.js +919 -0
- package/dist/multi-step-form.d.ts +56 -0
- package/dist/multi-step-form.js +342 -0
- package/dist/number-input.d.ts +34 -34
- package/dist/number-input.js +62 -413
- package/dist/page-header.d.ts +10 -11
- package/dist/page-header.js +34 -107
- package/dist/pagination.d.ts +17 -20
- package/dist/pagination.js +132 -341
- package/dist/password-input.d.ts +5 -12
- package/dist/password-input.js +32 -354
- package/dist/phone-input.d.ts +19 -19
- package/dist/phone-input.js +232 -561
- package/dist/photo-gallery.d.ts +20 -20
- package/dist/photo-gallery.js +314 -746
- package/dist/picker-lzgmsNfG.js +32 -0
- package/dist/pie-chart.d.ts +60 -60
- package/dist/pie-chart.js +141 -184
- package/dist/popover.d.ts +9 -9
- package/dist/popover.js +60 -156
- package/dist/price-tag.d.ts +34 -0
- package/dist/price-tag.js +118 -0
- package/dist/progress.d.ts +18 -16
- package/dist/progress.js +156 -300
- package/dist/property-listing-card.d.ts +29 -0
- package/dist/property-listing-card.js +117 -0
- package/dist/radar-chart.d.ts +108 -0
- package/dist/radar-chart.js +172 -0
- package/dist/radio-group.d.ts +11 -13
- package/dist/radio-group.js +47 -96
- package/dist/review-block.d.ts +18 -0
- package/dist/review-block.js +154 -0
- package/dist/rich-text-editor.d.ts +30 -14
- package/dist/rich-text-editor.js +594 -979
- package/dist/scatter-chart.d.ts +140 -0
- package/dist/scatter-chart.js +248 -0
- package/dist/search-input.d.ts +8 -15
- package/dist/search-input.js +58 -408
- package/dist/select.d.ts +8 -8
- package/dist/select.js +131 -291
- package/dist/separator.d.ts +8 -9
- package/dist/separator.js +31 -70
- package/dist/sheet.d.ts +11 -11
- package/dist/sheet.js +84 -262
- package/dist/sidebar.d.ts +32 -37
- package/dist/sidebar.js +380 -1055
- package/dist/size-context-D4mYvcg8.d.ts +10 -0
- package/dist/size-context.d.ts +2 -11
- package/dist/size-context.js +14 -18
- package/dist/skeleton.d.ts +4 -5
- package/dist/skeleton.js +9 -45
- package/dist/slider.d.ts +27 -0
- package/dist/slider.js +81 -0
- package/dist/sparkline.d.ts +43 -46
- package/dist/sparkline.js +223 -561
- package/dist/stepper.d.ts +23 -24
- package/dist/stepper.js +149 -276
- package/dist/styles.css +9995 -2
- package/dist/switch.d.ts +10 -12
- package/dist/switch.js +49 -106
- package/dist/table-card.d.ts +35 -0
- package/dist/table-card.js +125 -0
- package/dist/table.d.ts +18 -14
- package/dist/table.js +114 -182
- package/dist/tabs.d.ts +23 -15
- package/dist/tabs.js +62 -149
- package/dist/tag.d.ts +22 -23
- package/dist/tag.js +104 -156
- package/dist/testimonial-block.d.ts +33 -0
- package/dist/testimonial-block.js +208 -0
- package/dist/textarea-IS_D8pXf.d.ts +11 -0
- package/dist/textarea.d.ts +2 -12
- package/dist/textarea.js +20 -74
- package/dist/time-picker.d.ts +11 -11
- package/dist/time-picker.js +247 -464
- package/dist/toast.d.ts +16 -18
- package/dist/toast.js +154 -310
- package/dist/tooltip.d.ts +9 -10
- package/dist/tooltip.js +33 -91
- package/dist/tree-map.d.ts +54 -57
- package/dist/tree-map.js +231 -646
- package/dist/use-uncontrolled-CLfM1XbB.js +21 -0
- package/dist/waterfall-chart.d.ts +126 -0
- package/dist/waterfall-chart.js +480 -0
- package/package.json +123 -34
- package/dist/accordion.js.map +0 -1
- package/dist/alert.js.map +0 -1
- package/dist/avatar.js.map +0 -1
- package/dist/badge.js.map +0 -1
- package/dist/bar-chart.js.map +0 -1
- package/dist/base.css +0 -32
- package/dist/breadcrumb.js.map +0 -1
- package/dist/bullet-chart.js.map +0 -1
- package/dist/button-group.js.map +0 -1
- package/dist/button.js.map +0 -1
- package/dist/calendar.js.map +0 -1
- package/dist/card.js.map +0 -1
- package/dist/carousel.js.map +0 -1
- package/dist/chart.js.map +0 -1
- package/dist/checkbox.js.map +0 -1
- package/dist/collapsible.js.map +0 -1
- package/dist/combobox.js.map +0 -1
- package/dist/date-picker.js.map +0 -1
- package/dist/dialog.js.map +0 -1
- package/dist/dropdown-menu.js.map +0 -1
- package/dist/dropzone.js.map +0 -1
- package/dist/empty-state.js.map +0 -1
- package/dist/field.js.map +0 -1
- package/dist/files/red-hat-display-latin-300-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-300-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-300-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-300-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-400-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-400-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-400-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-400-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-500-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-500-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-500-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-500-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-600-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-600-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-600-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-600-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-700-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-700-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-700-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-700-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-800-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-800-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-800-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-800-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-900-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-900-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-900-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-900-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-300-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-300-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-300-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-300-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-400-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-400-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-400-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-500-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-500-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-500-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-500-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-600-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-600-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-600-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-700-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-700-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-700-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-800-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-800-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-800-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-800-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-900-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-900-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-900-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-900-normal.woff2 +0 -0
- package/dist/funnel-chart.js.map +0 -1
- package/dist/index.d.ts +0 -87
- package/dist/index.js +0 -10448
- package/dist/index.js.map +0 -1
- package/dist/input-group.js.map +0 -1
- package/dist/input-size-context.js.map +0 -1
- package/dist/input.js.map +0 -1
- package/dist/item.js.map +0 -1
- package/dist/kpi-card.js.map +0 -1
- package/dist/label.js.map +0 -1
- package/dist/line-chart.js.map +0 -1
- package/dist/logo.js.map +0 -1
- package/dist/number-input.js.map +0 -1
- package/dist/page-header.js.map +0 -1
- package/dist/pagination.js.map +0 -1
- package/dist/password-input.js.map +0 -1
- package/dist/phone-input.js.map +0 -1
- package/dist/photo-gallery.js.map +0 -1
- package/dist/pie-chart.js.map +0 -1
- package/dist/popover.js.map +0 -1
- package/dist/progress.js.map +0 -1
- package/dist/radio-group.js.map +0 -1
- package/dist/red-hat-display.css +0 -2
- package/dist/rich-text-editor.js.map +0 -1
- package/dist/search-input.js.map +0 -1
- package/dist/select.js.map +0 -1
- package/dist/separator.js.map +0 -1
- package/dist/sheet.js.map +0 -1
- package/dist/sidebar.js.map +0 -1
- package/dist/size-context.js.map +0 -1
- package/dist/skeleton.js.map +0 -1
- package/dist/sparkline.js.map +0 -1
- package/dist/stepper.js.map +0 -1
- package/dist/switch.js.map +0 -1
- package/dist/tab-list.d.ts +0 -38
- package/dist/tab-list.js +0 -394
- package/dist/tab-list.js.map +0 -1
- package/dist/table.js.map +0 -1
- package/dist/tabs.js.map +0 -1
- package/dist/tag.js.map +0 -1
- package/dist/textarea.js.map +0 -1
- package/dist/theme/giddaa.css +0 -2
- package/dist/time-picker.js.map +0 -1
- package/dist/toast.js.map +0 -1
- package/dist/tooltip.js.map +0 -1
- package/dist/tree-map.js.map +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
//#region src/lib/use-uncontrolled.ts
|
|
3
|
+
function useUncontrolled({ value, defaultValue, finalValue, onChange = () => {} }) {
|
|
4
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue !== void 0 ? defaultValue : finalValue);
|
|
5
|
+
const handleUncontrolledChange = (nextValue, ...payload) => {
|
|
6
|
+
setUncontrolledValue(nextValue);
|
|
7
|
+
onChange?.(nextValue, ...payload);
|
|
8
|
+
};
|
|
9
|
+
if (value !== void 0) return [
|
|
10
|
+
value,
|
|
11
|
+
onChange,
|
|
12
|
+
true
|
|
13
|
+
];
|
|
14
|
+
return [
|
|
15
|
+
uncontrolledValue,
|
|
16
|
+
handleUncontrolledChange,
|
|
17
|
+
false
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useUncontrolled as t };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { t as ComponentSize } from "./size-context-D4mYvcg8.js";
|
|
2
|
+
import { ChartCard, ChartValueType } from "./chart.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
//#region src/waterfall-chart.d.ts
|
|
5
|
+
type WaterfallChartOrientation = "vertical" | "horizontal";
|
|
6
|
+
type WaterfallChartLegendPlacement = "right" | "bottom";
|
|
7
|
+
type WaterfallChartStepType = "auto" | "increase" | "decrease" | "total";
|
|
8
|
+
type WaterfallChartDatum = {
|
|
9
|
+
/** Step label shown on the category axis, legend/tooltip context, and value label context. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Absolute subtotal for `type="total"`; delta amount for increase/decrease steps. */
|
|
12
|
+
value: number;
|
|
13
|
+
/** Defaults to `total` for the first/last datum and `auto` for middle data. */
|
|
14
|
+
type?: WaterfallChartStepType;
|
|
15
|
+
/** Optional fill override for this step. Defaults to semantic status tokens. */
|
|
16
|
+
fill?: string;
|
|
17
|
+
};
|
|
18
|
+
type ResolvedWaterfallStep = {
|
|
19
|
+
label: string;
|
|
20
|
+
value: number;
|
|
21
|
+
start: number;
|
|
22
|
+
end: number;
|
|
23
|
+
range: [number, number];
|
|
24
|
+
type: Exclude<WaterfallChartStepType, "auto">;
|
|
25
|
+
fill: string;
|
|
26
|
+
};
|
|
27
|
+
type WaterfallChartLayout = {
|
|
28
|
+
height: number;
|
|
29
|
+
horizontalHeight: number;
|
|
30
|
+
margin: {
|
|
31
|
+
top: number;
|
|
32
|
+
right: number;
|
|
33
|
+
bottom: number;
|
|
34
|
+
left: number;
|
|
35
|
+
};
|
|
36
|
+
horizontalMargin: {
|
|
37
|
+
top: number;
|
|
38
|
+
right: number;
|
|
39
|
+
bottom: number;
|
|
40
|
+
left: number;
|
|
41
|
+
};
|
|
42
|
+
barSize: number;
|
|
43
|
+
barRadius: number;
|
|
44
|
+
connectorWidth: number;
|
|
45
|
+
valueGap: number;
|
|
46
|
+
tickFontSize: number;
|
|
47
|
+
yAxisWidth: number;
|
|
48
|
+
xAxisHeight: number;
|
|
49
|
+
};
|
|
50
|
+
type WaterfallChartFormatContext = {
|
|
51
|
+
datum: WaterfallChartDatum;
|
|
52
|
+
step: ResolvedWaterfallStep;
|
|
53
|
+
index: number;
|
|
54
|
+
};
|
|
55
|
+
type WaterfallChartPlotProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
56
|
+
data: WaterfallChartDatum[];
|
|
57
|
+
size?: ComponentSize;
|
|
58
|
+
orientation?: WaterfallChartOrientation;
|
|
59
|
+
legend?: WaterfallChartLegendPlacement | false;
|
|
60
|
+
showValues?: boolean;
|
|
61
|
+
showTooltip?: boolean;
|
|
62
|
+
valueType?: ChartValueType;
|
|
63
|
+
valueFormatter?: (value: number, context: WaterfallChartFormatContext) => React.ReactNode;
|
|
64
|
+
categoryFormatter?: (label: string, datum: WaterfallChartDatum) => string;
|
|
65
|
+
domain?: [number, number] | [number, "auto"];
|
|
66
|
+
ariaLabel?: string;
|
|
67
|
+
};
|
|
68
|
+
type WaterfallChartLegendProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
69
|
+
size?: ComponentSize;
|
|
70
|
+
placement?: WaterfallChartLegendPlacement;
|
|
71
|
+
items?: WaterfallChartLegendItem[];
|
|
72
|
+
};
|
|
73
|
+
type WaterfallChartLegendItem = {
|
|
74
|
+
label: string;
|
|
75
|
+
color: string;
|
|
76
|
+
};
|
|
77
|
+
type WaterfallChartProps = Omit<React.ComponentProps<typeof ChartCard>, "children" | "size"> & WaterfallChartPlotProps & {
|
|
78
|
+
title?: React.ReactNode;
|
|
79
|
+
description?: React.ReactNode;
|
|
80
|
+
};
|
|
81
|
+
declare const WATERFALL_CHART_COLORS: {
|
|
82
|
+
readonly total: "var(--color-status-info)";
|
|
83
|
+
readonly increase: "var(--color-status-success)";
|
|
84
|
+
readonly decrease: "var(--color-status-danger)";
|
|
85
|
+
readonly connector: "var(--color-line-strong)";
|
|
86
|
+
readonly baseline: "var(--color-line)";
|
|
87
|
+
};
|
|
88
|
+
declare const WATERFALL_CHART_LEGEND_ITEMS: WaterfallChartLegendItem[];
|
|
89
|
+
declare const WATERFALL_CHART_CONFIG: {
|
|
90
|
+
increase: {
|
|
91
|
+
label: string;
|
|
92
|
+
color: "var(--color-status-success)";
|
|
93
|
+
};
|
|
94
|
+
decrease: {
|
|
95
|
+
label: string;
|
|
96
|
+
color: "var(--color-status-danger)";
|
|
97
|
+
};
|
|
98
|
+
total: {
|
|
99
|
+
label: string;
|
|
100
|
+
color: "var(--color-status-info)";
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
declare const WATERFALL_CHART_LAYOUT: Record<ComponentSize, WaterfallChartLayout>;
|
|
104
|
+
declare function resolveWaterfallData(data: WaterfallChartDatum[]): ({
|
|
105
|
+
label: string;
|
|
106
|
+
value: number;
|
|
107
|
+
start: number;
|
|
108
|
+
end: number;
|
|
109
|
+
range: [number, number];
|
|
110
|
+
type: "total";
|
|
111
|
+
fill: string;
|
|
112
|
+
} | {
|
|
113
|
+
label: string;
|
|
114
|
+
value: number;
|
|
115
|
+
start: number;
|
|
116
|
+
end: number;
|
|
117
|
+
range: [number, number];
|
|
118
|
+
type: "decrease" | "increase";
|
|
119
|
+
fill: string;
|
|
120
|
+
})[];
|
|
121
|
+
declare function WaterfallChartLegend({ className, size, placement, items, ...props }: WaterfallChartLegendProps): React.JSX.Element;
|
|
122
|
+
declare function WaterfallChartPlot({ data, size, orientation, legend, showValues, showTooltip, valueType, valueFormatter, categoryFormatter, domain, ariaLabel, className, ...props }: WaterfallChartPlotProps): React.JSX.Element | null;
|
|
123
|
+
declare function WaterfallChart({ data, size, orientation, title, description, legend, showValues, showTooltip, valueType, valueFormatter, categoryFormatter, domain, ariaLabel, className, ...props }: WaterfallChartProps): React.JSX.Element;
|
|
124
|
+
declare const WaterfallChartCard: typeof WaterfallChart;
|
|
125
|
+
//#endregion
|
|
126
|
+
export { type ResolvedWaterfallStep, WATERFALL_CHART_COLORS, WATERFALL_CHART_CONFIG, WATERFALL_CHART_LAYOUT, WATERFALL_CHART_LEGEND_ITEMS, WaterfallChart, WaterfallChartCard, type WaterfallChartDatum, type WaterfallChartFormatContext, type WaterfallChartLayout, WaterfallChartLegend, type WaterfallChartLegendItem, type WaterfallChartLegendPlacement, type WaterfallChartOrientation, WaterfallChartPlot, type WaterfallChartPlotProps, type WaterfallChartProps, type WaterfallChartStepType, resolveWaterfallData };
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
3
|
+
import { SizeProvider, useComponentSize } from "./size-context.js";
|
|
4
|
+
import { ChartCard, ChartContainer, ChartDescription, ChartHeader, ChartTitle, ChartTooltip, ChartTooltipContent } from "./chart.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { Bar, BarChart, LabelList, ReferenceLine, XAxis, YAxis } from "recharts";
|
|
8
|
+
//#region src/waterfall-chart.tsx
|
|
9
|
+
const WATERFALL_CHART_COLORS = {
|
|
10
|
+
total: "var(--color-status-info)",
|
|
11
|
+
increase: "var(--color-status-success)",
|
|
12
|
+
decrease: "var(--color-status-danger)",
|
|
13
|
+
connector: "var(--color-line-strong)",
|
|
14
|
+
baseline: "var(--color-line)"
|
|
15
|
+
};
|
|
16
|
+
const WATERFALL_CHART_LEGEND_ITEMS = [
|
|
17
|
+
{
|
|
18
|
+
label: "Increase",
|
|
19
|
+
color: WATERFALL_CHART_COLORS.increase
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Decrease",
|
|
23
|
+
color: WATERFALL_CHART_COLORS.decrease
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: "Total",
|
|
27
|
+
color: WATERFALL_CHART_COLORS.total
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
const WATERFALL_CHART_CONFIG = {
|
|
31
|
+
increase: {
|
|
32
|
+
label: "Increase",
|
|
33
|
+
color: WATERFALL_CHART_COLORS.increase
|
|
34
|
+
},
|
|
35
|
+
decrease: {
|
|
36
|
+
label: "Decrease",
|
|
37
|
+
color: WATERFALL_CHART_COLORS.decrease
|
|
38
|
+
},
|
|
39
|
+
total: {
|
|
40
|
+
label: "Total",
|
|
41
|
+
color: WATERFALL_CHART_COLORS.total
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const WATERFALL_CHART_LAYOUT = {
|
|
45
|
+
sm: {
|
|
46
|
+
height: 150,
|
|
47
|
+
horizontalHeight: 170,
|
|
48
|
+
margin: {
|
|
49
|
+
top: 18,
|
|
50
|
+
right: 8,
|
|
51
|
+
bottom: 0,
|
|
52
|
+
left: 0
|
|
53
|
+
},
|
|
54
|
+
horizontalMargin: {
|
|
55
|
+
top: 6,
|
|
56
|
+
right: 36,
|
|
57
|
+
bottom: 0,
|
|
58
|
+
left: 0
|
|
59
|
+
},
|
|
60
|
+
barSize: 18,
|
|
61
|
+
barRadius: 3,
|
|
62
|
+
connectorWidth: 1.25,
|
|
63
|
+
valueGap: 4,
|
|
64
|
+
tickFontSize: 10,
|
|
65
|
+
yAxisWidth: 56,
|
|
66
|
+
xAxisHeight: 20
|
|
67
|
+
},
|
|
68
|
+
md: {
|
|
69
|
+
height: 190,
|
|
70
|
+
horizontalHeight: 220,
|
|
71
|
+
margin: {
|
|
72
|
+
top: 22,
|
|
73
|
+
right: 10,
|
|
74
|
+
bottom: 0,
|
|
75
|
+
left: 0
|
|
76
|
+
},
|
|
77
|
+
horizontalMargin: {
|
|
78
|
+
top: 8,
|
|
79
|
+
right: 44,
|
|
80
|
+
bottom: 0,
|
|
81
|
+
left: 0
|
|
82
|
+
},
|
|
83
|
+
barSize: 24,
|
|
84
|
+
barRadius: 4,
|
|
85
|
+
connectorWidth: 1.5,
|
|
86
|
+
valueGap: 5,
|
|
87
|
+
tickFontSize: 11,
|
|
88
|
+
yAxisWidth: 72,
|
|
89
|
+
xAxisHeight: 24
|
|
90
|
+
},
|
|
91
|
+
lg: {
|
|
92
|
+
height: 250,
|
|
93
|
+
horizontalHeight: 280,
|
|
94
|
+
margin: {
|
|
95
|
+
top: 28,
|
|
96
|
+
right: 12,
|
|
97
|
+
bottom: 0,
|
|
98
|
+
left: 0
|
|
99
|
+
},
|
|
100
|
+
horizontalMargin: {
|
|
101
|
+
top: 10,
|
|
102
|
+
right: 56,
|
|
103
|
+
bottom: 0,
|
|
104
|
+
left: 0
|
|
105
|
+
},
|
|
106
|
+
barSize: 32,
|
|
107
|
+
barRadius: 5,
|
|
108
|
+
connectorWidth: 1.5,
|
|
109
|
+
valueGap: 6,
|
|
110
|
+
tickFontSize: 12,
|
|
111
|
+
yAxisWidth: 88,
|
|
112
|
+
xAxisHeight: 28
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const waterfallLegendVariants = cva("flex min-w-0", {
|
|
116
|
+
variants: {
|
|
117
|
+
placement: {
|
|
118
|
+
right: "flex-col items-start",
|
|
119
|
+
bottom: "flex-row flex-wrap items-center"
|
|
120
|
+
},
|
|
121
|
+
size: {
|
|
122
|
+
sm: "text-gdt-xs",
|
|
123
|
+
md: "text-gdt-xs",
|
|
124
|
+
lg: "text-gdt-sm"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
compoundVariants: [
|
|
128
|
+
{
|
|
129
|
+
placement: "right",
|
|
130
|
+
size: "sm",
|
|
131
|
+
className: "gap-2"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
placement: "right",
|
|
135
|
+
size: "md",
|
|
136
|
+
className: "gap-2.5"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
placement: "right",
|
|
140
|
+
size: "lg",
|
|
141
|
+
className: "gap-3"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
placement: "bottom",
|
|
145
|
+
className: "gap-x-4 gap-y-2"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
defaultVariants: {
|
|
149
|
+
placement: "right",
|
|
150
|
+
size: "md"
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
function defaultValueFormatter(value, { step }) {
|
|
154
|
+
if (step.type === "total") return value.toLocaleString("en-NG");
|
|
155
|
+
return `${value > 0 ? "+" : ""}${value.toLocaleString("en-NG")}`;
|
|
156
|
+
}
|
|
157
|
+
function resolveWaterfallData(data) {
|
|
158
|
+
let running = 0;
|
|
159
|
+
return data.map((datum, index) => {
|
|
160
|
+
const isEdge = index === 0 || index === data.length - 1;
|
|
161
|
+
const requestedType = datum.type ?? (isEdge ? "total" : "auto");
|
|
162
|
+
const type = requestedType === "auto" ? datum.value >= 0 ? "increase" : "decrease" : requestedType;
|
|
163
|
+
if (type === "total") {
|
|
164
|
+
running = datum.value;
|
|
165
|
+
return {
|
|
166
|
+
label: datum.label,
|
|
167
|
+
value: datum.value,
|
|
168
|
+
start: 0,
|
|
169
|
+
end: datum.value,
|
|
170
|
+
range: [0, datum.value].sort((a, b) => a - b),
|
|
171
|
+
type,
|
|
172
|
+
fill: datum.fill ?? WATERFALL_CHART_COLORS.total
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const start = running;
|
|
176
|
+
const end = running + datum.value;
|
|
177
|
+
running = end;
|
|
178
|
+
return {
|
|
179
|
+
label: datum.label,
|
|
180
|
+
value: datum.value,
|
|
181
|
+
start,
|
|
182
|
+
end,
|
|
183
|
+
range: [start, end].sort((a, b) => a - b),
|
|
184
|
+
type,
|
|
185
|
+
fill: datum.fill ?? (type === "increase" ? WATERFALL_CHART_COLORS.increase : WATERFALL_CHART_COLORS.decrease)
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function getWaterfallDomain(steps, domain) {
|
|
190
|
+
if (domain) return domain;
|
|
191
|
+
const values = steps.flatMap((step) => [
|
|
192
|
+
step.start,
|
|
193
|
+
step.end,
|
|
194
|
+
0
|
|
195
|
+
]);
|
|
196
|
+
const min = Math.min(...values);
|
|
197
|
+
const max = Math.max(...values);
|
|
198
|
+
const pad = Math.max(max - min, 1) * .08;
|
|
199
|
+
return [Math.min(0, min - pad), Math.max(0, max + pad)];
|
|
200
|
+
}
|
|
201
|
+
function getPayloadStep(payload) {
|
|
202
|
+
if (typeof payload !== "object" || payload === null) return void 0;
|
|
203
|
+
if (!("payload" in payload)) return void 0;
|
|
204
|
+
const row = payload.payload;
|
|
205
|
+
if (typeof row !== "object" || row === null) return void 0;
|
|
206
|
+
if (!("step" in row)) return void 0;
|
|
207
|
+
return row.step;
|
|
208
|
+
}
|
|
209
|
+
function findDatumByLabel(data, label) {
|
|
210
|
+
const stringLabel = String(label);
|
|
211
|
+
return data.find((datum) => datum.label === stringLabel) ?? {
|
|
212
|
+
label: stringLabel,
|
|
213
|
+
value: 0
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function formatTooltipValue(valueFormatter, data) {
|
|
217
|
+
return (_value, _name, item, index) => {
|
|
218
|
+
const step = getPayloadStep(item);
|
|
219
|
+
if (!step) return "";
|
|
220
|
+
const datumIndex = Math.max(index, 0);
|
|
221
|
+
return valueFormatter(step.value, {
|
|
222
|
+
datum: data[datumIndex] ?? {
|
|
223
|
+
label: step.label,
|
|
224
|
+
value: step.value,
|
|
225
|
+
type: step.type
|
|
226
|
+
},
|
|
227
|
+
step,
|
|
228
|
+
index: datumIndex
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function WaterfallChartLegend({ className, size, placement = "right", items = WATERFALL_CHART_LEGEND_ITEMS, ...props }) {
|
|
233
|
+
const resolvedSize = useComponentSize(size);
|
|
234
|
+
const markerClassName = resolvedSize === "sm" ? "size-2" : resolvedSize === "lg" ? "size-3" : "size-2.5";
|
|
235
|
+
return /* @__PURE__ */ jsx("div", {
|
|
236
|
+
className: cn(waterfallLegendVariants({
|
|
237
|
+
placement,
|
|
238
|
+
size: resolvedSize
|
|
239
|
+
}), className),
|
|
240
|
+
...props,
|
|
241
|
+
children: items.map((item) => /* @__PURE__ */ jsxs("div", {
|
|
242
|
+
className: "inline-flex items-center gap-2",
|
|
243
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
244
|
+
"aria-hidden": "true",
|
|
245
|
+
className: cn("shrink-0 rounded-[2px]", markerClassName),
|
|
246
|
+
style: { backgroundColor: item.color }
|
|
247
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
248
|
+
className: "font-medium text-fg-secondary",
|
|
249
|
+
children: item.label
|
|
250
|
+
})]
|
|
251
|
+
}, item.label))
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function WaterfallBarShape(props) {
|
|
255
|
+
const x = Number(props.x ?? 0);
|
|
256
|
+
const y = Number(props.y ?? 0);
|
|
257
|
+
const width = Number(props.width ?? 0);
|
|
258
|
+
const height = Number(props.height ?? 0);
|
|
259
|
+
const payload = props.payload;
|
|
260
|
+
const radius = Number(props.radius ?? 0);
|
|
261
|
+
const rectX = width < 0 ? x + width : x;
|
|
262
|
+
const rectY = height < 0 ? y + height : y;
|
|
263
|
+
const rectWidth = Math.abs(width);
|
|
264
|
+
const rectHeight = Math.abs(height);
|
|
265
|
+
if (rectWidth <= 0 || rectHeight <= 0) return null;
|
|
266
|
+
return /* @__PURE__ */ jsx("rect", {
|
|
267
|
+
x: rectX,
|
|
268
|
+
y: rectY,
|
|
269
|
+
width: rectWidth,
|
|
270
|
+
height: rectHeight,
|
|
271
|
+
rx: radius,
|
|
272
|
+
fill: payload?.step?.fill ?? payload?.fill ?? WATERFALL_CHART_COLORS.total
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function WaterfallValueLabel({ x, y, width, height, value, payload, orientation = "vertical", layout, valueFormatter = defaultValueFormatter, data, index }) {
|
|
276
|
+
const step = payload?.step ?? payload;
|
|
277
|
+
if (!step || x == null || y == null || width == null || height == null) return null;
|
|
278
|
+
const resolvedIndex = index ?? data.findIndex((datum) => datum.label === step.label);
|
|
279
|
+
const context = {
|
|
280
|
+
datum: data[resolvedIndex] ?? {
|
|
281
|
+
label: step.label,
|
|
282
|
+
value: step.value,
|
|
283
|
+
type: step.type
|
|
284
|
+
},
|
|
285
|
+
step,
|
|
286
|
+
index: Math.max(resolvedIndex, 0)
|
|
287
|
+
};
|
|
288
|
+
const fallbackLabel = Array.isArray(value) ? value.join(", ") : value == null ? "" : String(value);
|
|
289
|
+
const label = valueFormatter(step.value, context) ?? fallbackLabel;
|
|
290
|
+
const numX = Number(x);
|
|
291
|
+
const numY = Number(y);
|
|
292
|
+
const numWidth = Number(width);
|
|
293
|
+
const numHeight = Number(height);
|
|
294
|
+
const rectX = numWidth < 0 ? numX + numWidth : numX;
|
|
295
|
+
const rectY = numHeight < 0 ? numY + numHeight : numY;
|
|
296
|
+
const rectWidth = Math.abs(numWidth);
|
|
297
|
+
const rectHeight = Math.abs(numHeight);
|
|
298
|
+
if (orientation === "horizontal") return /* @__PURE__ */ jsx("text", {
|
|
299
|
+
x: rectX + rectWidth + layout.valueGap,
|
|
300
|
+
y: rectY + rectHeight / 2,
|
|
301
|
+
dominantBaseline: "central",
|
|
302
|
+
className: "fill-fg-primary text-gdt-xs font-semibold tabular-nums",
|
|
303
|
+
children: label
|
|
304
|
+
});
|
|
305
|
+
return /* @__PURE__ */ jsx("text", {
|
|
306
|
+
x: rectX + rectWidth / 2,
|
|
307
|
+
y: Math.max(10, rectY - layout.valueGap),
|
|
308
|
+
textAnchor: "middle",
|
|
309
|
+
className: "fill-fg-primary text-gdt-xs font-semibold tabular-nums",
|
|
310
|
+
children: label
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function WaterfallChartPlot({ data, size, orientation = "vertical", legend = false, showValues = true, showTooltip = false, valueType = "number", valueFormatter = defaultValueFormatter, categoryFormatter = (label) => label, domain, ariaLabel, className, ...props }) {
|
|
314
|
+
const resolvedSize = useComponentSize(size);
|
|
315
|
+
const layout = WATERFALL_CHART_LAYOUT[resolvedSize];
|
|
316
|
+
const steps = resolveWaterfallData(data);
|
|
317
|
+
if (!steps.length) return null;
|
|
318
|
+
const isHorizontal = orientation === "horizontal";
|
|
319
|
+
const resolvedDomain = getWaterfallDomain(steps, domain);
|
|
320
|
+
const chartHeight = isHorizontal ? layout.horizontalHeight : layout.height;
|
|
321
|
+
const chartMargin = isHorizontal ? layout.horizontalMargin : layout.margin;
|
|
322
|
+
const chartData = steps.map((step) => ({
|
|
323
|
+
...step,
|
|
324
|
+
range: step.range,
|
|
325
|
+
step
|
|
326
|
+
}));
|
|
327
|
+
const summary = ariaLabel ?? `Waterfall chart from ${steps[0]?.label ?? "start"} to ${steps.at(-1)?.label ?? "end"}`;
|
|
328
|
+
return /* @__PURE__ */ jsx("div", {
|
|
329
|
+
className: cn("w-full min-w-0", className),
|
|
330
|
+
"data-slot": "waterfall-chart-plot",
|
|
331
|
+
role: "img",
|
|
332
|
+
"aria-label": summary,
|
|
333
|
+
...props,
|
|
334
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
335
|
+
className: cn("flex min-w-0 gap-5", legend === "bottom" ? "flex-col" : "items-center justify-between max-sm:flex-col"),
|
|
336
|
+
children: [/* @__PURE__ */ jsx(ChartContainer, {
|
|
337
|
+
config: WATERFALL_CHART_CONFIG,
|
|
338
|
+
className: "aspect-auto w-full min-w-0 flex-1",
|
|
339
|
+
style: { height: chartHeight },
|
|
340
|
+
initialDimension: {
|
|
341
|
+
width: 420,
|
|
342
|
+
height: chartHeight
|
|
343
|
+
},
|
|
344
|
+
children: /* @__PURE__ */ jsxs(BarChart, {
|
|
345
|
+
accessibilityLayer: true,
|
|
346
|
+
data: chartData,
|
|
347
|
+
layout: isHorizontal ? "vertical" : "horizontal",
|
|
348
|
+
margin: chartMargin,
|
|
349
|
+
children: [
|
|
350
|
+
isHorizontal ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
351
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
352
|
+
type: "number",
|
|
353
|
+
domain: resolvedDomain,
|
|
354
|
+
axisLine: false,
|
|
355
|
+
tickLine: false,
|
|
356
|
+
tick: false
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
359
|
+
type: "category",
|
|
360
|
+
dataKey: "label",
|
|
361
|
+
width: layout.yAxisWidth,
|
|
362
|
+
axisLine: false,
|
|
363
|
+
tickLine: false,
|
|
364
|
+
tickMargin: 8,
|
|
365
|
+
tick: { fontSize: layout.tickFontSize },
|
|
366
|
+
tickFormatter: (label) => categoryFormatter(String(label), findDatumByLabel(data, label))
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ jsx(ReferenceLine, {
|
|
369
|
+
x: 0,
|
|
370
|
+
stroke: WATERFALL_CHART_COLORS.baseline,
|
|
371
|
+
strokeWidth: layout.connectorWidth
|
|
372
|
+
}),
|
|
373
|
+
steps.slice(0, -1).map((step, index) => /* @__PURE__ */ jsx(ReferenceLine, {
|
|
374
|
+
segment: [{
|
|
375
|
+
x: step.end,
|
|
376
|
+
y: steps[index].label
|
|
377
|
+
}, {
|
|
378
|
+
x: step.end,
|
|
379
|
+
y: steps[index + 1].label
|
|
380
|
+
}],
|
|
381
|
+
stroke: WATERFALL_CHART_COLORS.connector,
|
|
382
|
+
strokeWidth: layout.connectorWidth
|
|
383
|
+
}, `${step.label}-connector`))
|
|
384
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
385
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
386
|
+
dataKey: "label",
|
|
387
|
+
height: layout.xAxisHeight,
|
|
388
|
+
axisLine: false,
|
|
389
|
+
tickLine: false,
|
|
390
|
+
tickMargin: 8,
|
|
391
|
+
tick: { fontSize: layout.tickFontSize },
|
|
392
|
+
tickFormatter: (label) => categoryFormatter(String(label), findDatumByLabel(data, label))
|
|
393
|
+
}),
|
|
394
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
395
|
+
type: "number",
|
|
396
|
+
domain: resolvedDomain,
|
|
397
|
+
width: layout.yAxisWidth,
|
|
398
|
+
axisLine: false,
|
|
399
|
+
tickLine: false,
|
|
400
|
+
tick: false
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ jsx(ReferenceLine, {
|
|
403
|
+
y: 0,
|
|
404
|
+
stroke: WATERFALL_CHART_COLORS.baseline,
|
|
405
|
+
strokeWidth: layout.connectorWidth
|
|
406
|
+
}),
|
|
407
|
+
steps.slice(0, -1).map((step, index) => /* @__PURE__ */ jsx(ReferenceLine, {
|
|
408
|
+
segment: [{
|
|
409
|
+
x: steps[index].label,
|
|
410
|
+
y: step.end
|
|
411
|
+
}, {
|
|
412
|
+
x: steps[index + 1].label,
|
|
413
|
+
y: step.end
|
|
414
|
+
}],
|
|
415
|
+
stroke: WATERFALL_CHART_COLORS.connector,
|
|
416
|
+
strokeWidth: layout.connectorWidth
|
|
417
|
+
}, `${step.label}-connector`))
|
|
418
|
+
] }),
|
|
419
|
+
showTooltip ? /* @__PURE__ */ jsx(ChartTooltip, {
|
|
420
|
+
cursor: false,
|
|
421
|
+
content: /* @__PURE__ */ jsx(ChartTooltipContent, {
|
|
422
|
+
nameKey: "type",
|
|
423
|
+
valueType,
|
|
424
|
+
formatter: formatTooltipValue(valueFormatter, data)
|
|
425
|
+
})
|
|
426
|
+
}) : null,
|
|
427
|
+
/* @__PURE__ */ jsx(Bar, {
|
|
428
|
+
dataKey: "range",
|
|
429
|
+
name: "Change",
|
|
430
|
+
barSize: layout.barSize,
|
|
431
|
+
isAnimationActive: false,
|
|
432
|
+
shape: /* @__PURE__ */ jsx(WaterfallBarShape, { radius: layout.barRadius }),
|
|
433
|
+
children: showValues ? /* @__PURE__ */ jsx(LabelList, {
|
|
434
|
+
dataKey: "range",
|
|
435
|
+
content: /* @__PURE__ */ jsx(WaterfallValueLabel, {
|
|
436
|
+
orientation,
|
|
437
|
+
layout,
|
|
438
|
+
valueFormatter,
|
|
439
|
+
data
|
|
440
|
+
})
|
|
441
|
+
}) : null
|
|
442
|
+
})
|
|
443
|
+
]
|
|
444
|
+
})
|
|
445
|
+
}), legend ? /* @__PURE__ */ jsx(WaterfallChartLegend, {
|
|
446
|
+
size: resolvedSize,
|
|
447
|
+
placement: legend,
|
|
448
|
+
className: legend === "bottom" ? "justify-center" : "shrink-0"
|
|
449
|
+
}) : null]
|
|
450
|
+
})
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
function WaterfallChart({ data, size, orientation = "vertical", title, description, legend = "right", showValues = true, showTooltip = false, valueType = "number", valueFormatter, categoryFormatter, domain, ariaLabel, className, ...props }) {
|
|
454
|
+
const resolvedSize = useComponentSize(size);
|
|
455
|
+
const showHeader = title != null || description != null;
|
|
456
|
+
return /* @__PURE__ */ jsx(ChartCard, {
|
|
457
|
+
size: resolvedSize,
|
|
458
|
+
className,
|
|
459
|
+
...props,
|
|
460
|
+
children: /* @__PURE__ */ jsxs(SizeProvider, {
|
|
461
|
+
size: resolvedSize,
|
|
462
|
+
children: [showHeader ? /* @__PURE__ */ jsxs(ChartHeader, { children: [title != null ? /* @__PURE__ */ jsx(ChartTitle, { children: title }) : null, description != null ? /* @__PURE__ */ jsx(ChartDescription, { children: description }) : null] }) : null, /* @__PURE__ */ jsx(WaterfallChartPlot, {
|
|
463
|
+
data,
|
|
464
|
+
size: resolvedSize,
|
|
465
|
+
orientation,
|
|
466
|
+
legend,
|
|
467
|
+
showValues,
|
|
468
|
+
showTooltip,
|
|
469
|
+
valueType,
|
|
470
|
+
valueFormatter,
|
|
471
|
+
categoryFormatter,
|
|
472
|
+
domain,
|
|
473
|
+
ariaLabel
|
|
474
|
+
})]
|
|
475
|
+
})
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
const WaterfallChartCard = WaterfallChart;
|
|
479
|
+
//#endregion
|
|
480
|
+
export { WATERFALL_CHART_COLORS, WATERFALL_CHART_CONFIG, WATERFALL_CHART_LAYOUT, WATERFALL_CHART_LEGEND_ITEMS, WaterfallChart, WaterfallChartCard, WaterfallChartLegend, WaterfallChartPlot, resolveWaterfallData };
|