@cdx-ui/components 0.3.5 → 0.3.6
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 +1 -1
- package/coverage.svg +1 -1
- package/docs/components/bar-chart/content.md +703 -0
- package/docs/components/content.md +9 -1
- package/docs/components/line-chart/content.md +567 -0
- package/docs/components/pie-chart/content.md +493 -0
- package/docs/components/progress-segmented/content.md +1 -1
- package/docs/components/stepper/content.md +599 -0
- package/docs/components/system-alert/content.md +533 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +2 -1
- package/docs/llms.txt +9 -0
- package/docs/patterns/content.md +1 -0
- package/docs/patterns/dashboard/content.md +423 -19
- package/docs/patterns/insights/content.md +590 -0
- package/docs/resources/release-notes/0.3.5/content.md +7 -0
- package/docs/resources/release-notes/content.md +1 -0
- package/lib/commonjs/components/BarChart/geometry.js +1130 -0
- package/lib/commonjs/components/BarChart/geometry.js.map +1 -0
- package/lib/commonjs/components/BarChart/index.js +942 -0
- package/lib/commonjs/components/BarChart/index.js.map +1 -0
- package/lib/commonjs/components/BarChart/styles.js +26 -0
- package/lib/commonjs/components/BarChart/styles.js.map +1 -0
- package/lib/commonjs/components/Button/index.js +2 -2
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/LineChart/geometry.js +698 -0
- package/lib/commonjs/components/LineChart/geometry.js.map +1 -0
- package/lib/commonjs/components/LineChart/index.js +747 -0
- package/lib/commonjs/components/LineChart/index.js.map +1 -0
- package/lib/commonjs/components/LineChart/styles.js +25 -0
- package/lib/commonjs/components/LineChart/styles.js.map +1 -0
- package/lib/commonjs/components/PieChart/geometry.js +216 -0
- package/lib/commonjs/components/PieChart/geometry.js.map +1 -0
- package/lib/commonjs/components/PieChart/index.js +476 -0
- package/lib/commonjs/components/PieChart/index.js.map +1 -0
- package/lib/commonjs/components/PieChart/styles.js +88 -0
- package/lib/commonjs/components/PieChart/styles.js.map +1 -0
- package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js +9 -31
- package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
- package/lib/commonjs/components/ProgressCircle/ProgressRing.js +52 -0
- package/lib/commonjs/components/ProgressCircle/ProgressRing.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +8 -7
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/commonjs/components/Stepper/index.js +369 -0
- package/lib/commonjs/components/Stepper/index.js.map +1 -0
- package/lib/commonjs/components/Stepper/styles.js +211 -0
- package/lib/commonjs/components/Stepper/styles.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.js +22 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js +52 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperRingColors.js +31 -0
- package/lib/commonjs/components/Stepper/useStepperRingColors.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/animation.js +218 -0
- package/lib/commonjs/components/SystemAlert/animation.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/index.js +525 -0
- package/lib/commonjs/components/SystemAlert/index.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/styles.js +178 -0
- package/lib/commonjs/components/SystemAlert/styles.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js +53 -0
- package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
- package/lib/commonjs/components/Tabs/index.js +4 -0
- package/lib/commonjs/components/Tabs/index.js.map +1 -1
- package/lib/commonjs/components/Tabs/styles.js +1 -1
- package/lib/commonjs/components/Tabs/styles.js.map +1 -1
- package/lib/commonjs/components/chart/ChartInspector.js +610 -0
- package/lib/commonjs/components/chart/ChartInspector.js.map +1 -0
- package/lib/commonjs/components/chart/format.js +93 -0
- package/lib/commonjs/components/chart/format.js.map +1 -0
- package/lib/commonjs/components/chart/index.js +2 -0
- package/lib/commonjs/components/chart/index.js.map +1 -0
- package/lib/commonjs/components/chart/motion.js +97 -0
- package/lib/commonjs/components/chart/motion.js.map +1 -0
- package/lib/commonjs/components/chart/palette.js +178 -0
- package/lib/commonjs/components/chart/palette.js.map +1 -0
- package/lib/commonjs/components/chart/size.js +34 -0
- package/lib/commonjs/components/chart/size.js.map +1 -0
- package/lib/commonjs/components/chart/ticks.js +59 -0
- package/lib/commonjs/components/chart/ticks.js.map +1 -0
- package/lib/commonjs/components/chart/types.js +6 -0
- package/lib/commonjs/components/chart/types.js.map +1 -0
- package/lib/commonjs/components/chart/useChartHostWidth.js +27 -0
- package/lib/commonjs/components/chart/useChartHostWidth.js.map +1 -0
- package/lib/commonjs/components/index.js +60 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/figma/SystemAlert.Button.figma.js +28 -0
- package/lib/commonjs/figma/SystemAlert.Button.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.Close.figma.js +22 -0
- package/lib/commonjs/figma/SystemAlert.Close.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.Description.figma.js +20 -0
- package/lib/commonjs/figma/SystemAlert.Description.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.IconButton.figma.js +31 -0
- package/lib/commonjs/figma/SystemAlert.IconButton.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.figma.js +48 -0
- package/lib/commonjs/figma/SystemAlert.figma.js.map +1 -0
- package/lib/module/components/BarChart/geometry.js +1110 -0
- package/lib/module/components/BarChart/geometry.js.map +1 -0
- package/lib/module/components/BarChart/index.js +936 -0
- package/lib/module/components/BarChart/index.js.map +1 -0
- package/lib/module/components/BarChart/styles.js +22 -0
- package/lib/module/components/BarChart/styles.js.map +1 -0
- package/lib/module/components/Button/index.js +2 -2
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/LineChart/geometry.js +685 -0
- package/lib/module/components/LineChart/geometry.js.map +1 -0
- package/lib/module/components/LineChart/index.js +741 -0
- package/lib/module/components/LineChart/index.js.map +1 -0
- package/lib/module/components/LineChart/styles.js +21 -0
- package/lib/module/components/LineChart/styles.js.map +1 -0
- package/lib/module/components/PieChart/geometry.js +209 -0
- package/lib/module/components/PieChart/geometry.js.map +1 -0
- package/lib/module/components/PieChart/index.js +471 -0
- package/lib/module/components/PieChart/index.js.map +1 -0
- package/lib/module/components/PieChart/styles.js +84 -0
- package/lib/module/components/PieChart/styles.js.map +1 -0
- package/lib/module/components/ProgressCircle/ProgressCircleRing.js +10 -32
- package/lib/module/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
- package/lib/module/components/ProgressCircle/ProgressRing.js +48 -0
- package/lib/module/components/ProgressCircle/ProgressRing.js.map +1 -0
- package/lib/module/components/ScrollShadow/useScrollShadow.js +8 -7
- package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/module/components/Stepper/index.js +360 -0
- package/lib/module/components/Stepper/index.js.map +1 -0
- package/lib/module/components/Stepper/styles.js +206 -0
- package/lib/module/components/Stepper/styles.js.map +1 -0
- package/lib/module/components/Stepper/useStepperLabelFit.js +18 -0
- package/lib/module/components/Stepper/useStepperLabelFit.js.map +1 -0
- package/lib/module/components/Stepper/useStepperLabelFit.web.js +48 -0
- package/lib/module/components/Stepper/useStepperLabelFit.web.js.map +1 -0
- package/lib/module/components/Stepper/useStepperRingColors.js +28 -0
- package/lib/module/components/Stepper/useStepperRingColors.js.map +1 -0
- package/lib/module/components/SystemAlert/animation.js +213 -0
- package/lib/module/components/SystemAlert/animation.js.map +1 -0
- package/lib/module/components/SystemAlert/index.js +515 -0
- package/lib/module/components/SystemAlert/index.js.map +1 -0
- package/lib/module/components/SystemAlert/styles.js +174 -0
- package/lib/module/components/SystemAlert/styles.js.map +1 -0
- package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js +49 -0
- package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
- package/lib/module/components/Tabs/index.js +4 -0
- package/lib/module/components/Tabs/index.js.map +1 -1
- package/lib/module/components/Tabs/styles.js +1 -1
- package/lib/module/components/Tabs/styles.js.map +1 -1
- package/lib/module/components/chart/ChartInspector.js +600 -0
- package/lib/module/components/chart/ChartInspector.js.map +1 -0
- package/lib/module/components/chart/format.js +84 -0
- package/lib/module/components/chart/format.js.map +1 -0
- package/lib/module/components/chart/index.js +2 -0
- package/lib/module/components/chart/index.js.map +1 -0
- package/lib/module/components/chart/motion.js +89 -0
- package/lib/module/components/chart/motion.js.map +1 -0
- package/lib/module/components/chart/palette.js +168 -0
- package/lib/module/components/chart/palette.js.map +1 -0
- package/lib/module/components/chart/size.js +29 -0
- package/lib/module/components/chart/size.js.map +1 -0
- package/lib/module/components/chart/ticks.js +55 -0
- package/lib/module/components/chart/ticks.js.map +1 -0
- package/lib/module/components/chart/types.js +4 -0
- package/lib/module/components/chart/types.js.map +1 -0
- package/lib/module/components/chart/useChartHostWidth.js +23 -0
- package/lib/module/components/chart/useChartHostWidth.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/figma/SystemAlert.Button.figma.js +22 -0
- package/lib/module/figma/SystemAlert.Button.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.Close.figma.js +18 -0
- package/lib/module/figma/SystemAlert.Close.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.Description.figma.js +14 -0
- package/lib/module/figma/SystemAlert.Description.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.IconButton.figma.js +25 -0
- package/lib/module/figma/SystemAlert.IconButton.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.figma.js +42 -0
- package/lib/module/figma/SystemAlert.figma.js.map +1 -0
- package/lib/typescript/components/BarChart/geometry.d.ts +236 -0
- package/lib/typescript/components/BarChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/BarChart/index.d.ts +193 -0
- package/lib/typescript/components/BarChart/index.d.ts.map +1 -0
- package/lib/typescript/components/BarChart/styles.d.ts +32 -0
- package/lib/typescript/components/BarChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/geometry.d.ts +248 -0
- package/lib/typescript/components/LineChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/index.d.ts +105 -0
- package/lib/typescript/components/LineChart/index.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/styles.d.ts +12 -0
- package/lib/typescript/components/LineChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/geometry.d.ts +43 -0
- package/lib/typescript/components/PieChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/index.d.ts +147 -0
- package/lib/typescript/components/PieChart/index.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/styles.d.ts +27 -0
- package/lib/typescript/components/PieChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/ProgressCircle/ProgressCircleRing.d.ts.map +1 -1
- package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts +17 -0
- package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
- package/lib/typescript/components/Stepper/index.d.ts +68 -0
- package/lib/typescript/components/Stepper/index.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/styles.d.ts +46 -0
- package/lib/typescript/components/Stepper/styles.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts +15 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts +10 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperRingColors.d.ts +6 -0
- package/lib/typescript/components/Stepper/useStepperRingColors.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/animation.d.ts +56 -0
- package/lib/typescript/components/SystemAlert/animation.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/index.d.ts +110 -0
- package/lib/typescript/components/SystemAlert/index.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/styles.d.ts +38 -0
- package/lib/typescript/components/SystemAlert/styles.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts +14 -0
- package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts.map +1 -0
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
- package/lib/typescript/components/chart/ChartInspector.d.ts +101 -0
- package/lib/typescript/components/chart/ChartInspector.d.ts.map +1 -0
- package/lib/typescript/components/chart/format.d.ts +16 -0
- package/lib/typescript/components/chart/format.d.ts.map +1 -0
- package/lib/typescript/components/chart/index.d.ts +3 -0
- package/lib/typescript/components/chart/index.d.ts.map +1 -0
- package/lib/typescript/components/chart/motion.d.ts +27 -0
- package/lib/typescript/components/chart/motion.d.ts.map +1 -0
- package/lib/typescript/components/chart/palette.d.ts +44 -0
- package/lib/typescript/components/chart/palette.d.ts.map +1 -0
- package/lib/typescript/components/chart/size.d.ts +25 -0
- package/lib/typescript/components/chart/size.d.ts.map +1 -0
- package/lib/typescript/components/chart/ticks.d.ts +3 -0
- package/lib/typescript/components/chart/ticks.d.ts.map +1 -0
- package/lib/typescript/components/chart/types.d.ts +163 -0
- package/lib/typescript/components/chart/types.d.ts.map +1 -0
- package/lib/typescript/components/chart/useChartHostWidth.d.ts +9 -0
- package/lib/typescript/components/chart/useChartHostWidth.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +5 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/figma/SystemAlert.Button.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.Button.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.Close.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.Close.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.Description.figma.d.ts +8 -0
- package/lib/typescript/figma/SystemAlert.Description.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.figma.d.ts +8 -0
- package/lib/typescript/figma/SystemAlert.figma.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/components/BarChart/geometry.ts +1469 -0
- package/src/components/BarChart/index.tsx +1424 -0
- package/src/components/BarChart/styles.ts +31 -0
- package/src/components/Button/index.tsx +1 -1
- package/src/components/LineChart/geometry.ts +957 -0
- package/src/components/LineChart/index.tsx +1109 -0
- package/src/components/LineChart/styles.ts +26 -0
- package/src/components/PieChart/geometry.ts +295 -0
- package/src/components/PieChart/index.tsx +715 -0
- package/src/components/PieChart/styles.ts +101 -0
- package/src/components/ProgressCircle/ProgressCircleRing.tsx +10 -39
- package/src/components/ProgressCircle/ProgressRing.tsx +60 -0
- package/src/components/ScrollShadow/useScrollShadow.ts +12 -11
- package/src/components/Stepper/index.tsx +452 -0
- package/src/components/Stepper/styles.ts +234 -0
- package/src/components/Stepper/useStepperLabelFit.ts +21 -0
- package/src/components/Stepper/useStepperLabelFit.web.ts +53 -0
- package/src/components/Stepper/useStepperRingColors.ts +29 -0
- package/src/components/SystemAlert/animation.ts +252 -0
- package/src/components/SystemAlert/index.tsx +684 -0
- package/src/components/SystemAlert/styles.ts +212 -0
- package/src/components/SystemAlert/useSystemAlertStatusBarStyle.ts +57 -0
- package/src/components/Tabs/index.tsx +4 -0
- package/src/components/Tabs/styles.ts +1 -1
- package/src/components/chart/ChartInspector.tsx +726 -0
- package/src/components/chart/format.ts +95 -0
- package/src/components/chart/index.ts +24 -0
- package/src/components/chart/motion.ts +98 -0
- package/src/components/chart/palette.tsx +247 -0
- package/src/components/chart/size.ts +21 -0
- package/src/components/chart/ticks.ts +53 -0
- package/src/components/chart/types.ts +183 -0
- package/src/components/chart/useChartHostWidth.ts +26 -0
- package/src/components/index.ts +5 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultChartLocaleText = void 0;
|
|
7
|
+
exports.defaultChartValueFormatter = defaultChartValueFormatter;
|
|
8
|
+
exports.formatChartNumber = formatChartNumber;
|
|
9
|
+
exports.formatChartPercent = formatChartPercent;
|
|
10
|
+
exports.resolveChartLocaleText = resolveChartLocaleText;
|
|
11
|
+
exports.resolveValueFormatter = resolveValueFormatter;
|
|
12
|
+
var _formatters = require("@cdx-ui/formatters");
|
|
13
|
+
function namedValue(value) {
|
|
14
|
+
return value.label.length > 0 ? `${value.label} ${value.formattedValue}` : value.formattedValue;
|
|
15
|
+
}
|
|
16
|
+
function categoryText(category) {
|
|
17
|
+
return `${category.label} ${category.values.map(namedValue).join(', ')}`;
|
|
18
|
+
}
|
|
19
|
+
const defaultChartLocaleText = exports.defaultChartLocaleText = {
|
|
20
|
+
noData: 'No data',
|
|
21
|
+
noValue: 'No value',
|
|
22
|
+
defaultSeriesLabel: 'Value',
|
|
23
|
+
waterfallIncrease: 'Increase',
|
|
24
|
+
waterfallDecrease: 'Decrease',
|
|
25
|
+
trend: ({
|
|
26
|
+
direction,
|
|
27
|
+
formattedDelta,
|
|
28
|
+
comparisonLabel
|
|
29
|
+
}) => {
|
|
30
|
+
const from = comparisonLabel.length > 0 ? ` from ${comparisonLabel}` : '';
|
|
31
|
+
return direction === 'none' ? `no change${from}` : `${direction} ${formattedDelta}${from}`;
|
|
32
|
+
},
|
|
33
|
+
barChartSummary: categories => categories.length === 0 ? 'Bar chart. No data.' : `Bar chart. ${categories.map(categoryText).join('; ')}.`,
|
|
34
|
+
lineChartSummary: latest => latest === null ? 'Line chart. No data.' : `Line chart. ${categoryText(latest)}.`,
|
|
35
|
+
pieChartSummary: slices => slices.length === 0 ? 'Pie chart. No data.' : `Pie chart. ${slices.map(namedValue).join(', ')}.`
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Consumer strings over the English defaults. `undefined` entries keep the default. */
|
|
39
|
+
function resolveChartLocaleText(localeText) {
|
|
40
|
+
if (localeText === undefined) {
|
|
41
|
+
return defaultChartLocaleText;
|
|
42
|
+
}
|
|
43
|
+
const overrides = Object.entries(localeText).filter(([, value]) => value !== undefined);
|
|
44
|
+
return {
|
|
45
|
+
...defaultChartLocaleText,
|
|
46
|
+
...Object.fromEntries(overrides)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Up to two fraction digits, without trailing zeros: `3`, `2.5`, `1,234.56`. */
|
|
51
|
+
function formatChartNumber(value, locale) {
|
|
52
|
+
if (value === null || !Number.isFinite(value)) {
|
|
53
|
+
return '';
|
|
54
|
+
}
|
|
55
|
+
const hundredths = Math.round(Math.abs(value) * 100);
|
|
56
|
+
const decimalPlaces = hundredths % 100 === 0 ? 0 : hundredths % 10 === 0 ? 1 : 2;
|
|
57
|
+
return (0, _formatters.formatNumber)(value, {
|
|
58
|
+
locale,
|
|
59
|
+
decimalPlaces
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const percentFormatters = new Map();
|
|
63
|
+
|
|
64
|
+
/** A 0–1 share as a whole percent for `locale`: `0.46` → `46%`. */
|
|
65
|
+
function formatChartPercent(share, locale) {
|
|
66
|
+
if (!Number.isFinite(share)) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
// Without a locale, match the `@cdx-ui/formatters` default that numbers use, not the device locale.
|
|
70
|
+
if (locale === undefined) {
|
|
71
|
+
return `${(0, _formatters.formatNumber)(Math.round(share * 100), {
|
|
72
|
+
decimalPlaces: 0
|
|
73
|
+
})}%`;
|
|
74
|
+
}
|
|
75
|
+
let formatter = percentFormatters.get(locale);
|
|
76
|
+
if (formatter === undefined) {
|
|
77
|
+
formatter = new Intl.NumberFormat(locale, {
|
|
78
|
+
style: 'percent',
|
|
79
|
+
maximumFractionDigits: 0
|
|
80
|
+
});
|
|
81
|
+
percentFormatters.set(locale, formatter);
|
|
82
|
+
}
|
|
83
|
+
return formatter.format(share);
|
|
84
|
+
}
|
|
85
|
+
function defaultChartValueFormatter(locale) {
|
|
86
|
+
return value => formatChartNumber(value, locale);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Series formatter, then axis formatter, then the `locale` default. */
|
|
90
|
+
function resolveValueFormatter(series, axis, locale) {
|
|
91
|
+
return series?.valueFormatter ?? axis?.valueFormatter ?? defaultChartValueFormatter(locale);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_formatters","require","namedValue","value","label","length","formattedValue","categoryText","category","values","map","join","defaultChartLocaleText","exports","noData","noValue","defaultSeriesLabel","waterfallIncrease","waterfallDecrease","trend","direction","formattedDelta","comparisonLabel","from","barChartSummary","categories","lineChartSummary","latest","pieChartSummary","slices","resolveChartLocaleText","localeText","undefined","overrides","Object","entries","filter","fromEntries","formatChartNumber","locale","Number","isFinite","hundredths","Math","round","abs","decimalPlaces","formatNumber","percentFormatters","Map","formatChartPercent","share","formatter","get","Intl","NumberFormat","style","maximumFractionDigits","set","format","defaultChartValueFormatter","resolveValueFormatter","series","axis","valueFormatter"],"sourceRoot":"../../../../src","sources":["components/chart/format.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAaA,SAASC,UAAUA,CAACC,KAAwB,EAAU;EACpD,OAAOA,KAAK,CAACC,KAAK,CAACC,MAAM,GAAG,CAAC,GAAG,GAAGF,KAAK,CAACC,KAAK,IAAID,KAAK,CAACG,cAAc,EAAE,GAAGH,KAAK,CAACG,cAAc;AACjG;AAEA,SAASC,YAAYA,CAACC,QAA8B,EAAU;EAC5D,OAAO,GAAGA,QAAQ,CAACJ,KAAK,IAAII,QAAQ,CAACC,MAAM,C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SAAS;MAAEC,qBAAqB,EAAE;IAAE,CAAC,CAAC;IACzFT,iBAAiB,CAACU,GAAG,CAACnB,MAAM,EAAEa,SAAS,CAAC;EAC1C;EACA,OAAOA,SAAS,CAACO,MAAM,CAACR,KAAK,CAAC;AAChC;AAEO,SAASS,0BAA0BA,CAACrB,MAAe,EAAuB;EAC/E,OAAQpC,KAAK,IAAKmC,iBAAiB,CAACnC,KAAK,EAAEoC,MAAM,CAAC;AACpD;;AAEA;AACO,SAASsB,qBAAqBA,CACnCC,MAA4C,EAC5CC,IAA0C,EAC1CxB,MAAe,EACM;EACrB,OAAOuB,MAAM,EAAEE,cAAc,IAAID,IAAI,EAAEC,cAAc,IAAIJ,0BAA0B,CAACrB,MAAM,CAAC;AAC7F","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/chart/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CHART_MOTION_DURATION = void 0;
|
|
7
|
+
exports.lerpVector = lerpVector;
|
|
8
|
+
exports.useChartEntrance = useChartEntrance;
|
|
9
|
+
exports.useChartMorph = useChartMorph;
|
|
10
|
+
exports.useChartMotionEnabled = useChartMotionEnabled;
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
13
|
+
var _animation = require("../../animation");
|
|
14
|
+
const CHART_MOTION_DURATION = exports.CHART_MOTION_DURATION = 600;
|
|
15
|
+
const CHART_MOTION_EASING = _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic);
|
|
16
|
+
/** Off for `'disable-all'`, an ancestor or global `disable-all`, and Reduce Motion. */
|
|
17
|
+
function useChartMotionEnabled(animation) {
|
|
18
|
+
const disabled = (0, _animation.useCombinedAnimationDisabledState)(animation);
|
|
19
|
+
const reducedMotion = (0, _reactNativeReanimated.useReducedMotion)();
|
|
20
|
+
return !disabled && !reducedMotion;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Non-finite entries mark gaps: they snap to the target instead of tweening.
|
|
25
|
+
* Vectors of different lengths cannot be paired, so the target wins outright.
|
|
26
|
+
*/
|
|
27
|
+
function lerpVector(from, to, t) {
|
|
28
|
+
'worklet';
|
|
29
|
+
|
|
30
|
+
const out = [];
|
|
31
|
+
const paired = from.length === to.length;
|
|
32
|
+
for (let index = 0; index < to.length; index += 1) {
|
|
33
|
+
const end = to[index];
|
|
34
|
+
const start = paired ? from[index] : end;
|
|
35
|
+
out.push(Number.isFinite(start) && Number.isFinite(end) ? start + (end - start) * t : end);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function parseSignature(signature) {
|
|
40
|
+
return signature.length === 0 ? [] : signature.split(',').map(Number);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Tweens a numeric geometry vector on the UI thread. Mounts at `initial` and runs to
|
|
45
|
+
* `target`; later targets start from wherever the previous tween currently is. When the
|
|
46
|
+
* vector changes length (points or slices added/removed) the entry replays from `initial`.
|
|
47
|
+
*/
|
|
48
|
+
function useChartMorph(target, initial, enabled) {
|
|
49
|
+
const from = (0, _reactNativeReanimated.useSharedValue)(enabled ? [...initial] : [...target]);
|
|
50
|
+
const to = (0, _reactNativeReanimated.useSharedValue)([...target]);
|
|
51
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(enabled ? 0 : 1);
|
|
52
|
+
const signature = target.join(',');
|
|
53
|
+
const initialSignature = initial.join(',');
|
|
54
|
+
(0, _react.useEffect)(() => {
|
|
55
|
+
const next = parseSignature(signature);
|
|
56
|
+
if (!enabled) {
|
|
57
|
+
from.set(next);
|
|
58
|
+
to.set(next);
|
|
59
|
+
progress.set(1);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const current = lerpVector(from.get(), to.get(), progress.get());
|
|
63
|
+
from.set(current.length === next.length ? current : parseSignature(initialSignature));
|
|
64
|
+
to.set(next);
|
|
65
|
+
progress.set(0);
|
|
66
|
+
progress.set((0, _reactNativeReanimated.withTiming)(1, {
|
|
67
|
+
duration: CHART_MOTION_DURATION,
|
|
68
|
+
easing: CHART_MOTION_EASING
|
|
69
|
+
}));
|
|
70
|
+
}, [signature, initialSignature, enabled, from, to, progress]);
|
|
71
|
+
return {
|
|
72
|
+
from,
|
|
73
|
+
to,
|
|
74
|
+
progress
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 0 → 1 on mount and whenever `replayKey` changes. Labels sit on animated geometry, so they
|
|
80
|
+
* stay hidden until the morph is mostly done, then fade in at the final position.
|
|
81
|
+
*/
|
|
82
|
+
function useChartEntrance(enabled, replayKey = '') {
|
|
83
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(enabled ? 0 : 1);
|
|
84
|
+
(0, _react.useEffect)(() => {
|
|
85
|
+
if (!enabled) {
|
|
86
|
+
progress.set(1);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
progress.set(0);
|
|
90
|
+
progress.set((0, _reactNativeReanimated.withTiming)(1, {
|
|
91
|
+
duration: CHART_MOTION_DURATION,
|
|
92
|
+
easing: CHART_MOTION_EASING
|
|
93
|
+
}));
|
|
94
|
+
}, [enabled, replayKey, progress]);
|
|
95
|
+
return progress;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNativeReanimated","_animation","CHART_MOTION_DURATION","exports","CHART_MOTION_EASING","Easing","out","cubic","useChartMotionEnabled","animation","disabled","useCombinedAnimationDisabledState","reducedMotion","useReducedMotion","lerpVector","from","to","t","paired","length","index","end","start","push","Number","isFinite","parseSignature","signature","split","map","useChartMorph","target","initial","enabled","useSharedValue","progress","join","initialSignature","useEffect","next","set","current","get","withTiming","duration","easing","useChartEntrance","replayKey"],"sourceRoot":"../../../../src","sources":["components/chart/motion.ts"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAOA,IAAAE,UAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,GAAG;AACxC,MAAME,mBAAmB,GAAGC,6BAAM,CAACC,GAAG,CAACD,6BAAM,CAACE,KAAK,CAAC;AAQpD;AACO,SAASC,qBAAqBA,CAACC,SAA8C,EAAW;EAC7F,MAAMC,QAAQ,GAAG,IAAAC,4CAAiC,EAACF,SAAS,CAAC;EAC7D,MAAMG,aAAa,GAAG,IAAAC,uCAAgB,EAAC,CAAC;EACxC,OAAO,CAACH,QAAQ,IAAI,CAACE,aAAa;AACpC;;AAEA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CAACC,IAAuB,EAAEC,EAAqB,EAAEC,CAAS,EAAY;EAC9F,SAAS;;EACT,MAAMX,GAAa,GAAG,EAAE;EACxB,MAAMY,MAAM,GAAGH,IAAI,CAACI,MAAM,KAAKH,EAAE,CAACG,MAAM;EACxC,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGJ,EAAE,CAACG,MAAM,EAAEC,KAAK,IAAI,CAAC,EAAE;IACjD,MAAMC,GAAG,GAAGL,EAAE,CAACI,KAAK,CAAC;IACrB,MAAME,KAAK,GAAGJ,MAAM,GAAGH,IAAI,CAACK,KAAK,CAAC,GAAGC,GAAG;IACxCf,GAAG,CAACiB,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACH,KAAK,CAAC,IAAIE,MAAM,CAACC,QAAQ,CAACJ,GAAG,CAAC,GAAGC,KAAK,GAAG,CAACD,GAAG,GAAGC,KAAK,IAAIL,CAAC,GAAGI,GAAG,CA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Gf,cAAc,CAACW,gBAAgB,CAAC,CAAC;IACrFrB,EAAE,CAACwB,GAAG,CAACD,IAAI,CAAC;IACZJ,QAAQ,CAACK,GAAG,CAAC,CAAC,CAAC;IACfL,QAAQ,CAACK,GAAG,CAAC,IAAAG,iCAAU,EAAC,CAAC,EAAE;MAAEC,QAAQ,EAAE1C,qBAAqB;MAAE2C,MAAM,EAAEzC;IAAoB,CAAC,CAAC,CAAC;EAC/F,CAAC,EAAE,CAACuB,SAAS,EAAEU,gBAAgB,EAAEJ,OAAO,EAAElB,IAAI,EAAEC,EAAE,EAAEmB,QAAQ,CAAC,CAAC;EAE9D,OAAO;IAAEpB,IAAI;IAAEC,EAAE;IAAEmB;EAAS,CAAC;AAC/B;;AAEA;AACA;AACA;AACA;AACO,SAASW,gBAAgBA,CAACb,OAAgB,EAAEc,SAAS,GAAG,EAAE,EAAuB;EACtF,MAAMZ,QAAQ,GAAG,IAAAD,qCAAc,EAACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;EAEhD,IAAAK,gBAAS,EAAC,MAAM;IACd,IAAI,CAACL,OAAO,EAAE;MACZE,QAAQ,CAACK,GAAG,CAAC,CAAC,CAAC;MACf;IACF;IACAL,QAAQ,CAACK,GAAG,CAAC,CAAC,CAAC;IACfL,QAAQ,CAACK,GAAG,CAAC,IAAAG,iCAAU,EAAC,CAAC,EAAE;MAAEC,QAAQ,EAAE1C,qBAAqB;MAAE2C,MAAM,EAAEzC;IAAoB,CAAC,CAAC,CAAC;EAC/F,CAAC,EAAE,CAAC6B,OAAO,EAAEc,SAAS,EAAEZ,QAAQ,CAAC,CAAC;EAElC,OAAOA,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChartLinearFills = ChartLinearFills;
|
|
7
|
+
exports.chartFillUrl = chartFillUrl;
|
|
8
|
+
exports.chartSeriesColor = chartSeriesColor;
|
|
9
|
+
exports.resolveChartColor = resolveChartColor;
|
|
10
|
+
exports.useChartChrome = useChartChrome;
|
|
11
|
+
exports.useChartColorPaints = useChartColorPaints;
|
|
12
|
+
exports.useChartGradientId = useChartGradientId;
|
|
13
|
+
exports.useChartPalette = useChartPalette;
|
|
14
|
+
exports.useChartSimpleColor = useChartSimpleColor;
|
|
15
|
+
var _react = require("react");
|
|
16
|
+
var _reactNativeSvg = require("react-native-svg");
|
|
17
|
+
var _uniwind = require("uniwind");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
/** Light-theme chart tokens, used when Uniwind has no CSS context (Jest). */const CHART_FALLBACKS = {
|
|
20
|
+
simple: '#5b91de',
|
|
21
|
+
simpleSecondary: '#162e49',
|
|
22
|
+
simpleTertiary: '#3b6399',
|
|
23
|
+
categorical: ['#155dfc', '#f54900', '#009689', '#e60076', '#9810fa', '#525252'],
|
|
24
|
+
danger: '#c10007',
|
|
25
|
+
warning: '#ffb900',
|
|
26
|
+
success: '#00a63e',
|
|
27
|
+
info: '#0069a8'
|
|
28
|
+
};
|
|
29
|
+
function toColor(value, fallback) {
|
|
30
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
return fallback;
|
|
34
|
+
}
|
|
35
|
+
function useChartSimpleColor() {
|
|
36
|
+
const value = (0, _uniwind.useCSSVariable)('--color-chart-simple-primary');
|
|
37
|
+
return toColor(value, CHART_FALLBACKS.simple);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A Forge color token by name: `simple-*` and `categorical-*` resolve
|
|
42
|
+
* `--color-chart-<name>`, severity names resolve `--color-surface-<name>-strong`.
|
|
43
|
+
* Overrides take a name, not a CSS color, so FI themes and dark mode recolor every chart.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
const warnedChartColors = new Set();
|
|
47
|
+
function resolveChartColor(color, paints) {
|
|
48
|
+
if (color === undefined) return undefined;
|
|
49
|
+
const paint = paints[color];
|
|
50
|
+
if (paint === undefined && __DEV__ && !warnedChartColors.has(color)) {
|
|
51
|
+
warnedChartColors.add(color);
|
|
52
|
+
console.warn(`[Chart] Unknown color "${String(color)}". Pass a ChartColor token name, not a CSS ` + 'color; the default series color is used instead.');
|
|
53
|
+
}
|
|
54
|
+
return paint;
|
|
55
|
+
}
|
|
56
|
+
function useChartColorPaints() {
|
|
57
|
+
const simple = useChartSimpleColor();
|
|
58
|
+
const secondary = toColor((0, _uniwind.useCSSVariable)('--color-chart-simple-secondary'), CHART_FALLBACKS.simpleSecondary);
|
|
59
|
+
const tertiary = toColor((0, _uniwind.useCSSVariable)('--color-chart-simple-tertiary'), CHART_FALLBACKS.simpleTertiary);
|
|
60
|
+
const danger = toColor((0, _uniwind.useCSSVariable)('--color-surface-danger-strong'), CHART_FALLBACKS.danger);
|
|
61
|
+
const warning = toColor((0, _uniwind.useCSSVariable)('--color-surface-warning-strong'), CHART_FALLBACKS.warning);
|
|
62
|
+
const success = toColor((0, _uniwind.useCSSVariable)('--color-surface-success-strong'), CHART_FALLBACKS.success);
|
|
63
|
+
const info = toColor((0, _uniwind.useCSSVariable)('--color-surface-info-strong'), CHART_FALLBACKS.info);
|
|
64
|
+
const palette = useChartPalette();
|
|
65
|
+
return {
|
|
66
|
+
danger,
|
|
67
|
+
warning,
|
|
68
|
+
success,
|
|
69
|
+
info,
|
|
70
|
+
'simple-primary': simple,
|
|
71
|
+
'simple-secondary': secondary,
|
|
72
|
+
'simple-tertiary': tertiary,
|
|
73
|
+
'categorical-1': palette[0] ?? CHART_FALLBACKS.categorical[0],
|
|
74
|
+
'categorical-2': palette[1] ?? CHART_FALLBACKS.categorical[1],
|
|
75
|
+
'categorical-3': palette[2] ?? CHART_FALLBACKS.categorical[2],
|
|
76
|
+
'categorical-4': palette[3] ?? CHART_FALLBACKS.categorical[3],
|
|
77
|
+
'categorical-5': palette[4] ?? CHART_FALLBACKS.categorical[4],
|
|
78
|
+
'categorical-6': palette[5] ?? CHART_FALLBACKS.categorical[5]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* SVG text cannot take `className`, so typography tokens are resolved here.
|
|
84
|
+
* `useResolveClassNames` converts rem to px with the consumer's rem base; web
|
|
85
|
+
* may return rem strings, which fall back to the light-theme pixel size.
|
|
86
|
+
*/
|
|
87
|
+
function toPx(value, fallbackPx) {
|
|
88
|
+
if (typeof value === 'number') {
|
|
89
|
+
return Number.isFinite(value) ? value : fallbackPx;
|
|
90
|
+
}
|
|
91
|
+
if (typeof value !== 'string') return fallbackPx;
|
|
92
|
+
const trimmed = value.trim();
|
|
93
|
+
if (!/^-?\d*\.?\d+(px)?$/.test(trimmed)) return fallbackPx;
|
|
94
|
+
return parseFloat(trimmed);
|
|
95
|
+
}
|
|
96
|
+
function useChartChrome() {
|
|
97
|
+
const grid = (0, _uniwind.useCSSVariable)('--color-stroke-secondary');
|
|
98
|
+
const label = (0, _uniwind.useCSSVariable)('--color-content-primary');
|
|
99
|
+
const surface = (0, _uniwind.useCSSVariable)('--color-surface-primary');
|
|
100
|
+
const fontFamily = (0, _uniwind.useCSSVariable)('--font-body');
|
|
101
|
+
const labelText = (0, _uniwind.useResolveClassNames)('text-xs');
|
|
102
|
+
const captionText = (0, _uniwind.useResolveClassNames)('text-2xs');
|
|
103
|
+
return {
|
|
104
|
+
grid: toColor(grid, '#e9e9e9'),
|
|
105
|
+
label: toColor(label, '#1b1c1d'),
|
|
106
|
+
surface: toColor(surface, '#ffffff'),
|
|
107
|
+
fontFamily: toColor(fontFamily, 'Inter'),
|
|
108
|
+
labelSize: toPx(labelText.fontSize, 12),
|
|
109
|
+
captionSize: toPx(captionText.fontSize, 10)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Resolved `categorical-1`…`6` paints, in slot order. Pie slices and charts past
|
|
115
|
+
* three series cycle them.
|
|
116
|
+
*/
|
|
117
|
+
function useChartPalette() {
|
|
118
|
+
const slot1 = (0, _uniwind.useCSSVariable)('--color-chart-categorical-1');
|
|
119
|
+
const slot2 = (0, _uniwind.useCSSVariable)('--color-chart-categorical-2');
|
|
120
|
+
const slot3 = (0, _uniwind.useCSSVariable)('--color-chart-categorical-3');
|
|
121
|
+
const slot4 = (0, _uniwind.useCSSVariable)('--color-chart-categorical-4');
|
|
122
|
+
const slot5 = (0, _uniwind.useCSSVariable)('--color-chart-categorical-5');
|
|
123
|
+
const slot6 = (0, _uniwind.useCSSVariable)('--color-chart-categorical-6');
|
|
124
|
+
return [toColor(slot1, CHART_FALLBACKS.categorical[0]), toColor(slot2, CHART_FALLBACKS.categorical[1]), toColor(slot3, CHART_FALLBACKS.categorical[2]), toColor(slot4, CHART_FALLBACKS.categorical[3]), toColor(slot5, CHART_FALLBACKS.categorical[4]), toColor(slot6, CHART_FALLBACKS.categorical[5])];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* `auto` keeps up to three series in the FI brand family and moves the whole chart to
|
|
129
|
+
* `categorical-1`…`6` past that, so one chart never mixes the two families.
|
|
130
|
+
* `categorical` always uses them.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Bars alternate light, dark, mid so adjacent bars don't read as a ramp. Lines step
|
|
135
|
+
* primary → tertiary → secondary so a two-line chart pairs neighboring brand steps.
|
|
136
|
+
*/
|
|
137
|
+
const SIMPLE_SERIES = {
|
|
138
|
+
bar: ['simple-primary', 'simple-secondary', 'simple-tertiary'],
|
|
139
|
+
line: ['simple-primary', 'simple-tertiary', 'simple-secondary']
|
|
140
|
+
};
|
|
141
|
+
const CATEGORICAL_SERIES = ['categorical-1', 'categorical-2', 'categorical-3', 'categorical-4', 'categorical-5', 'categorical-6'];
|
|
142
|
+
|
|
143
|
+
/** Default color for a series. A series `color` still wins. */
|
|
144
|
+
function chartSeriesColor(seriesIndex, seriesCount, palette, kind) {
|
|
145
|
+
const simple = SIMPLE_SERIES[kind];
|
|
146
|
+
const ramp = palette === 'auto' && seriesCount <= simple.length ? simple : CATEGORICAL_SERIES;
|
|
147
|
+
return ramp[seriesIndex % ramp.length] ?? 'simple-primary';
|
|
148
|
+
}
|
|
149
|
+
function useChartGradientId(prefix) {
|
|
150
|
+
return `${prefix}-${(0, _react.useId)().replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
|
151
|
+
}
|
|
152
|
+
function chartFillUrl(idPrefix, index) {
|
|
153
|
+
return `url(#${idPrefix}-${String(index)})`;
|
|
154
|
+
}
|
|
155
|
+
function ChartLinearFills({
|
|
156
|
+
idPrefix,
|
|
157
|
+
colors,
|
|
158
|
+
x2,
|
|
159
|
+
y2
|
|
160
|
+
}) {
|
|
161
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Defs, {
|
|
162
|
+
children: colors.map((color, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.LinearGradient, {
|
|
163
|
+
id: `${idPrefix}-${String(index)}`,
|
|
164
|
+
x1: "0%",
|
|
165
|
+
y1: "0%",
|
|
166
|
+
x2: x2,
|
|
167
|
+
y2: y2,
|
|
168
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
169
|
+
offset: "0%",
|
|
170
|
+
stopColor: color
|
|
171
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
172
|
+
offset: "100%",
|
|
173
|
+
stopColor: color
|
|
174
|
+
})]
|
|
175
|
+
}, `${idPrefix}-${String(index)}`))
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNativeSvg","_uniwind","_jsxRuntime","CHART_FALLBACKS","simple","simpleSecondary","simpleTertiary","categorical","danger","warning","success","info","toColor","value","fallback","length","useChartSimpleColor","useCSSVariable","warnedChartColors","Set","resolveChartColor","color","paints","undefined","paint","__DEV__","has","add","console","warn","String","useChartColorPaints","secondary","tertiary","palette","useChartPalette","toPx","fallbackPx","Number","isFinite","trimmed","trim","test","parseFloat","useChartChrome","grid","label","surface","fontFamily","labelText","useResolveClassNames","captionText","labelSize","fontSize","captionSize","slot1","slot2","slot3","slot4","slot5","slot6","SIMPLE_SERIES","bar","line","CATEGORICAL_SERIES","chartSeriesColor","seriesIndex","seriesCount","kind","ramp","useChartGradientId","prefix","useId","replace","chartFillUrl","idPrefix","index","ChartLinearFills","colors","x2","y2","jsx","Defs","children","map","jsxs","LinearGradient","id","x1","y1","Stop","offset","stopColor"],"sourceRoot":"../../../../src","sources":["components/chart/palette.tsx"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAA+D,IAAAG,WAAA,GAAAH,OAAA;AAE/D,6EACA,MAAMI,eAAe,GAAG;EACtBC,MAAM,EAAE,SAAS;EACjBC,eAAe,EAAE,SAAS;EAC1BC,cAAc,EAAE,SAAS;EACzBC,WAAW,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAU;EACxFC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE;AACR,CAAU;AAEV,SAASC,OAAOA,CAACC,KAAkC,EAAEC,QAAgB,EAAU;EAC7E,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACE,MAAM,GAAG,CAAC,EAAE;IACjD,OAAOF,KAAK;EACd;EACA,OAAOC,QAAQ;AACjB;AAEO,SAASE,mBAAmBA,CAAA,EAAW;EAC5C,MAAMH,KAAK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Module", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CHART_DIMENSIONS = void 0;
|
|
7
|
+
exports.resolveChartBox = resolveChartBox;
|
|
8
|
+
/** Plot boxes. Heights match the spacing scale (`size-40`…`size-64`). */
|
|
9
|
+
const CHART_DIMENSIONS = exports.CHART_DIMENSIONS = {
|
|
10
|
+
sm: {
|
|
11
|
+
width: 256,
|
|
12
|
+
height: 160
|
|
13
|
+
},
|
|
14
|
+
md: {
|
|
15
|
+
width: 308,
|
|
16
|
+
height: 192
|
|
17
|
+
},
|
|
18
|
+
lg: {
|
|
19
|
+
width: 360,
|
|
20
|
+
height: 224
|
|
21
|
+
},
|
|
22
|
+
xl: {
|
|
23
|
+
width: 410,
|
|
24
|
+
height: 256
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function resolveChartBox(size, width, height) {
|
|
28
|
+
const preset = CHART_DIMENSIONS[size ?? 'lg'];
|
|
29
|
+
return {
|
|
30
|
+
width: width ?? preset.width,
|
|
31
|
+
height: height ?? preset.height
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CHART_DIMENSIONS","exports","sm","width","height","md","lg","xl","resolveChartBox","size","preset"],"sourceRoot":"../../../../src","sources":["components/chart/size.ts"],"mappings":";;;;;;;AAEA;AACO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAC9BE,EAAE,EAAE;IAAEC,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAI,CAAC;EAC/BC,EAAE,EAAE;IAAEF,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAI,CAAC;EAC/BE,EAAE,EAAE;IAAEH,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAI,CAAC;EAC/BG,EAAE,EAAE;IAAEJ,KAAK,EAAE,GAAG;IAAEC,MAAM,EAAE;EAAI;AAChC,CAA2F;AAEpF,SAASI,eAAeA,CAC7BC,IAA2B,EAC3BN,KAAc,EACdC,MAAe,EACsC;EACrD,MAAMM,MAAM,GAAGV,gBAAgB,CAACS,IAAI,IAAI,IAAI,CAAC;EAC7C,OAAO;IACLN,KAAK,EAAEA,KAAK,IAAIO,MAAM,CAACP,KAAK;IAC5BC,MAAM,EAAEA,MAAM,IAAIM,MAAM,CAACN;EAC3B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.niceTicks = niceTicks;
|
|
7
|
+
/** Rounds away float drift at the step's precision, so steps below 0.01 stay distinct. */
|
|
8
|
+
function roundToStep(value, step) {
|
|
9
|
+
const decimals = Math.min(20, Math.max(2, -Math.floor(Math.log10(step)) + 1));
|
|
10
|
+
const rounded = Number(value.toFixed(decimals));
|
|
11
|
+
return Object.is(rounded, -0) ? 0 : rounded;
|
|
12
|
+
}
|
|
13
|
+
function niceNumber(span, round) {
|
|
14
|
+
if (span <= 0 || !Number.isFinite(span)) {
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
17
|
+
const exponent = Math.floor(Math.log10(span));
|
|
18
|
+
const fraction = span / 10 ** exponent;
|
|
19
|
+
let niceFraction;
|
|
20
|
+
if (round) {
|
|
21
|
+
if (fraction < 1.5) {
|
|
22
|
+
niceFraction = 1;
|
|
23
|
+
} else if (fraction < 3) {
|
|
24
|
+
niceFraction = 2;
|
|
25
|
+
} else if (fraction < 7) {
|
|
26
|
+
niceFraction = 5;
|
|
27
|
+
} else {
|
|
28
|
+
niceFraction = 10;
|
|
29
|
+
}
|
|
30
|
+
} else if (fraction <= 1) {
|
|
31
|
+
niceFraction = 1;
|
|
32
|
+
} else if (fraction <= 2) {
|
|
33
|
+
niceFraction = 2;
|
|
34
|
+
} else if (fraction <= 5) {
|
|
35
|
+
niceFraction = 5;
|
|
36
|
+
} else {
|
|
37
|
+
niceFraction = 10;
|
|
38
|
+
}
|
|
39
|
+
return niceFraction * 10 ** exponent;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Evenly spaced, readable ticks that cover `min`–`max` in about `count` steps. */
|
|
43
|
+
function niceTicks(min, max, count) {
|
|
44
|
+
if (!Number.isFinite(min) || !Number.isFinite(max)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const tickCount = Math.max(2, count);
|
|
48
|
+
const span = niceNumber(max - min, false);
|
|
49
|
+
const step = niceNumber(span / (tickCount - 1), true);
|
|
50
|
+
const niceMin = Math.floor(min / step) * step;
|
|
51
|
+
const niceMax = Math.ceil(max / step) * step;
|
|
52
|
+
const ticks = [];
|
|
53
|
+
const last = niceMax + step / 2;
|
|
54
|
+
for (let value = niceMin; value <= last; value += step) {
|
|
55
|
+
ticks.push(roundToStep(value, step));
|
|
56
|
+
}
|
|
57
|
+
return ticks;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ticks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["roundToStep","value","step","decimals","Math","min","max","floor","log10","rounded","Number","toFixed","Object","is","niceNumber","span","round","isFinite","exponent","fraction","niceFraction","niceTicks","count","tickCount","niceMin","niceMax","ceil","ticks","last","push"],"sourceRoot":"../../../../src","sources":["components/chart/ticks.ts"],"mappings":";;;;;;AAAA;AACA,SAASA,WAAWA,CAACC,KAAa,EAAEC,IAAY,EAAU;EACxD,MAAMC,QAAQ,GAAGC,IAAI,CAACC,GAAG,CAAC,EAAE,EAAED,IAAI,CAACE,GAAG,CAAC,CAAC,EAAE,CAACF,IAAI,CAACG,KAAK,CAACH,IAAI,CAACI,KAAK,CAACN,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;EAC7E,MAAMO,OAAO,GAAGC,MAAM,CAACT,KAAK,CAACU,OAAO,CAACR,QAAQ,CAA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EAAE;IAClD,OAAO,EAAE;EACX;EACA,MAAMiB,SAAS,GAAGnB,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEgB,KAAK,CAAC;EACpC,MAAMP,IAAI,GAAGD,UAAU,CAACR,GAAG,GAAGD,GAAG,EAAE,KAAK,CAAC;EACzC,MAAMH,IAAI,GAAGY,UAAU,CAACC,IAAI,IAAIQ,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC;EACrD,MAAMC,OAAO,GAAGpB,IAAI,CAACG,KAAK,CAACF,GAAG,GAAGH,IAAI,CAAC,GAAGA,IAAI;EAC7C,MAAMuB,OAAO,GAAGrB,IAAI,CAACsB,IAAI,CAACpB,GAAG,GAAGJ,IAAI,CAAC,GAAGA,IAAI;EAC5C,MAAMyB,KAAe,GAAG,EAAE;EAC1B,MAAMC,IAAI,GAAGH,OAAO,GAAGvB,IAAI,GAAG,CAAC;EAC/B,KAAK,IAAID,KAAK,GAAGuB,OAAO,EAAEvB,KAAK,IAAI2B,IAAI,EAAE3B,KAAK,IAAIC,IAAI,EAAE;IACtDyB,KAAK,CAACE,IAAI,CAAC7B,WAAW,CAACC,KAAK,EAAEC,IAAI,CAAC,CAAC;EACtC;EACA,OAAOyB,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/chart/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.composeChartLayout = composeChartLayout;
|
|
7
|
+
exports.useChartHostWidth = useChartHostWidth;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _utils = require("@cdx-ui/utils");
|
|
10
|
+
/** Runs the chart's own handler first, then the consumer's. */
|
|
11
|
+
function composeChartLayout(own, consumer) {
|
|
12
|
+
return (0, _utils.composeEventHandlers)(own, consumer);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Measured width of the chart root (`0` before the first layout) and the `onLayout` to put on
|
|
17
|
+
* it. The consumer's `onLayout` still fires.
|
|
18
|
+
*/
|
|
19
|
+
function useChartHostWidth(onLayout) {
|
|
20
|
+
const [width, setWidth] = (0, _react.useState)(0);
|
|
21
|
+
const handleLayout = composeChartLayout(event => {
|
|
22
|
+
const next = event.nativeEvent.layout.width;
|
|
23
|
+
setWidth(prev => prev === next ? prev : next);
|
|
24
|
+
}, onLayout);
|
|
25
|
+
return [width, handleLayout];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=useChartHostWidth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_utils","composeChartLayout","own","consumer","composeEventHandlers","useChartHostWidth","onLayout","width","setWidth","useState","handleLayout","event","next","nativeEvent","layout","prev"],"sourceRoot":"../../../../src","sources":["components/chart/useChartHostWidth.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA;AACO,SAASE,kBAAkBA,CAChCC,GAAuC,EACvCC,QAAiE,EAC7B;EACpC,OAAO,IAAAC,2BAAoB,EAAoBF,GAAG,EAAEC,QAAQ,CAAC;AAC/D;;AAEA;AACA;AACA;AACA;AACO,SAASE,iBAAiBA,CAC/BC,QAAiE,EACV;EACvD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAC,CAAC,CAAC;EACrC,MAAMC,YAAY,GAAGT,kBAAkB,CAAEU,KAAK,IAAK;IACjD,MAAMC,IAAI,GAAGD,KAAK,CAACE,WAAW,CAACC,MAAM,CAACP,KAAK;IAC3CC,QAAQ,CAAEO,IAAI,IAAMA,IAAI,KAAKH,IAAI,GAAGG,IAAI,GAAGH,IAAK,CAAC;EACnD,CAAC,EAAEN,QAAQ,CAAC;EACZ,OAAO,CAACC,KAAK,EAAEG,YAAY,CAAC;AAC9B","ignoreList":[]}
|
|
@@ -591,6 +591,42 @@ Object.keys(_ProgressCircle).forEach(function (key) {
|
|
|
591
591
|
}
|
|
592
592
|
});
|
|
593
593
|
});
|
|
594
|
+
var _PieChart = require("./PieChart");
|
|
595
|
+
Object.keys(_PieChart).forEach(function (key) {
|
|
596
|
+
if (key === "default" || key === "__esModule") return;
|
|
597
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
598
|
+
if (key in exports && exports[key] === _PieChart[key]) return;
|
|
599
|
+
Object.defineProperty(exports, key, {
|
|
600
|
+
enumerable: true,
|
|
601
|
+
get: function () {
|
|
602
|
+
return _PieChart[key];
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
var _BarChart = require("./BarChart");
|
|
607
|
+
Object.keys(_BarChart).forEach(function (key) {
|
|
608
|
+
if (key === "default" || key === "__esModule") return;
|
|
609
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
610
|
+
if (key in exports && exports[key] === _BarChart[key]) return;
|
|
611
|
+
Object.defineProperty(exports, key, {
|
|
612
|
+
enumerable: true,
|
|
613
|
+
get: function () {
|
|
614
|
+
return _BarChart[key];
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
var _LineChart = require("./LineChart");
|
|
619
|
+
Object.keys(_LineChart).forEach(function (key) {
|
|
620
|
+
if (key === "default" || key === "__esModule") return;
|
|
621
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
622
|
+
if (key in exports && exports[key] === _LineChart[key]) return;
|
|
623
|
+
Object.defineProperty(exports, key, {
|
|
624
|
+
enumerable: true,
|
|
625
|
+
get: function () {
|
|
626
|
+
return _LineChart[key];
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
});
|
|
594
630
|
var _Skeleton = require("./Skeleton");
|
|
595
631
|
Object.keys(_Skeleton).forEach(function (key) {
|
|
596
632
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -675,6 +711,18 @@ Object.keys(_Slider).forEach(function (key) {
|
|
|
675
711
|
}
|
|
676
712
|
});
|
|
677
713
|
});
|
|
714
|
+
var _Stepper = require("./Stepper");
|
|
715
|
+
Object.keys(_Stepper).forEach(function (key) {
|
|
716
|
+
if (key === "default" || key === "__esModule") return;
|
|
717
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
718
|
+
if (key in exports && exports[key] === _Stepper[key]) return;
|
|
719
|
+
Object.defineProperty(exports, key, {
|
|
720
|
+
enumerable: true,
|
|
721
|
+
get: function () {
|
|
722
|
+
return _Stepper[key];
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
});
|
|
678
726
|
var _VirtualizedList = require("./VirtualizedList");
|
|
679
727
|
Object.keys(_VirtualizedList).forEach(function (key) {
|
|
680
728
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -699,6 +747,18 @@ Object.keys(_Switch).forEach(function (key) {
|
|
|
699
747
|
}
|
|
700
748
|
});
|
|
701
749
|
});
|
|
750
|
+
var _SystemAlert = require("./SystemAlert");
|
|
751
|
+
Object.keys(_SystemAlert).forEach(function (key) {
|
|
752
|
+
if (key === "default" || key === "__esModule") return;
|
|
753
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
754
|
+
if (key in exports && exports[key] === _SystemAlert[key]) return;
|
|
755
|
+
Object.defineProperty(exports, key, {
|
|
756
|
+
enumerable: true,
|
|
757
|
+
get: function () {
|
|
758
|
+
return _SystemAlert[key];
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
});
|
|
702
762
|
var _Tabs = require("./Tabs");
|
|
703
763
|
Object.keys(_Tabs).forEach(function (key) {
|
|
704
764
|
if (key === "default" || key === "__esModule") return;
|