@cdx-ui/components 0.3.5 → 0.3.7
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 +10 -1
- package/docs/components/country-flag/content.md +232 -0
- package/docs/components/data-grid/content.md +3 -1
- package/docs/components/icon/content.md +1 -1
- package/docs/components/input/content.md +1 -0
- package/docs/components/line-chart/content.md +567 -0
- package/docs/components/pie-chart/content.md +493 -0
- package/docs/components/progress-bar/content.md +164 -3
- package/docs/components/progress-segmented/content.md +1 -1
- package/docs/components/select/content.md +1 -0
- package/docs/components/stepper/content.md +599 -0
- package/docs/components/system-alert/content.md +533 -0
- package/docs/foundations/expressions/icons/content.md +2 -1
- package/docs/foundations/styles/tokens/all-tokens/content.md +2 -1
- package/docs/getting-started/developers/content.md +1 -1
- package/docs/llms.txt +12 -0
- package/docs/patterns/content.md +1 -0
- package/docs/patterns/dashboard/content.md +423 -19
- package/docs/patterns/insights/content.md +659 -0
- package/docs/resources/content.md +1 -0
- package/docs/resources/release-notes/0.3.5/content.md +7 -0
- package/docs/resources/release-notes/0.3.6/content.md +29 -0
- package/docs/resources/release-notes/content.md +2 -0
- package/docs/resources/skills/content.md +66 -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 +935 -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/CountryFlag/index.js +56 -0
- package/lib/commonjs/components/CountryFlag/index.js.map +1 -0
- package/lib/commonjs/components/Input/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 +744 -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/ProgressBar/index.js +44 -12
- package/lib/commonjs/components/ProgressBar/index.js.map +1 -1
- package/lib/commonjs/components/ProgressBar/styles.js +31 -2
- package/lib/commonjs/components/ProgressBar/styles.js.map +1 -1
- 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/Select/index.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/hiddenSvgProps.js +23 -0
- package/lib/commonjs/components/chart/hiddenSvgProps.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 +72 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/figma/Accordion.figma.js +2 -2
- package/lib/commonjs/figma/Accordion.figma.js.map +1 -1
- package/lib/commonjs/figma/Alert.figma.js +7 -7
- package/lib/commonjs/figma/Alert.figma.js.map +1 -1
- package/lib/commonjs/figma/Badge.Indicator.figma.js +6 -5
- package/lib/commonjs/figma/Badge.Indicator.figma.js.map +1 -1
- package/lib/commonjs/figma/Badge.figma.js +22 -22
- package/lib/commonjs/figma/Badge.figma.js.map +1 -1
- package/lib/commonjs/figma/Button.figma.js +5 -2
- package/lib/commonjs/figma/Button.figma.js.map +1 -1
- package/lib/commonjs/figma/CLAUDE.md +1 -0
- package/lib/commonjs/figma/Card.Header.figma.js +8 -4
- package/lib/commonjs/figma/Card.Header.figma.js.map +1 -1
- package/lib/commonjs/figma/Card.figma.js +2 -1
- package/lib/commonjs/figma/Card.figma.js.map +1 -1
- package/lib/commonjs/figma/Chip.figma.js +2 -2
- package/lib/commonjs/figma/Chip.figma.js.map +1 -1
- package/lib/commonjs/figma/CurrencyInput.figma.js +1 -1
- package/lib/commonjs/figma/CurrencyInput.figma.js.map +1 -1
- package/lib/commonjs/figma/Dialog.figma.js +5 -2
- package/lib/commonjs/figma/Dialog.figma.js.map +1 -1
- package/lib/commonjs/figma/Divider.figma.js +1 -1
- package/lib/commonjs/figma/Divider.figma.js.map +1 -1
- package/lib/commonjs/figma/Drawer.figma.js +3 -3
- package/lib/commonjs/figma/Drawer.figma.js.map +1 -1
- package/lib/commonjs/figma/IconButton.figma.js +10 -4
- package/lib/commonjs/figma/IconButton.figma.js.map +1 -1
- package/lib/commonjs/figma/Input.figma.js +2 -1
- package/lib/commonjs/figma/Input.figma.js.map +1 -1
- package/lib/commonjs/figma/Insight.figma.js +3 -3
- package/lib/commonjs/figma/Insight.figma.js.map +1 -1
- package/lib/commonjs/figma/ProgressBar.figma.js +11 -2
- package/lib/commonjs/figma/ProgressBar.figma.js.map +1 -1
- package/lib/commonjs/figma/ProgressSegmented.figma.js +9 -1
- package/lib/commonjs/figma/ProgressSegmented.figma.js.map +1 -1
- package/lib/commonjs/figma/Select.figma.js +2 -1
- package/lib/commonjs/figma/Select.figma.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 +47 -0
- package/lib/commonjs/figma/SystemAlert.figma.js.map +1 -0
- package/lib/commonjs/styles.css +0 -1
- 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 +929 -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/CountryFlag/index.js +52 -0
- package/lib/module/components/CountryFlag/index.js.map +1 -0
- package/lib/module/components/Input/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 +738 -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/ProgressBar/index.js +47 -15
- package/lib/module/components/ProgressBar/index.js.map +1 -1
- package/lib/module/components/ProgressBar/styles.js +31 -2
- package/lib/module/components/ProgressBar/styles.js.map +1 -1
- 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/Select/index.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/hiddenSvgProps.js +20 -0
- package/lib/module/components/chart/hiddenSvgProps.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 +6 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/figma/Accordion.figma.js +2 -2
- package/lib/module/figma/Accordion.figma.js.map +1 -1
- package/lib/module/figma/Alert.figma.js +7 -7
- package/lib/module/figma/Alert.figma.js.map +1 -1
- package/lib/module/figma/Badge.Indicator.figma.js +6 -5
- package/lib/module/figma/Badge.Indicator.figma.js.map +1 -1
- package/lib/module/figma/Badge.figma.js +22 -22
- package/lib/module/figma/Badge.figma.js.map +1 -1
- package/lib/module/figma/Button.figma.js +5 -2
- package/lib/module/figma/Button.figma.js.map +1 -1
- package/lib/module/figma/CLAUDE.md +1 -0
- package/lib/module/figma/Card.Header.figma.js +8 -4
- package/lib/module/figma/Card.Header.figma.js.map +1 -1
- package/lib/module/figma/Card.figma.js +2 -1
- package/lib/module/figma/Card.figma.js.map +1 -1
- package/lib/module/figma/Chip.figma.js +2 -2
- package/lib/module/figma/Chip.figma.js.map +1 -1
- package/lib/module/figma/CurrencyInput.figma.js +1 -1
- package/lib/module/figma/CurrencyInput.figma.js.map +1 -1
- package/lib/module/figma/Dialog.figma.js +5 -2
- package/lib/module/figma/Dialog.figma.js.map +1 -1
- package/lib/module/figma/Divider.figma.js +1 -1
- package/lib/module/figma/Divider.figma.js.map +1 -1
- package/lib/module/figma/Drawer.figma.js +3 -3
- package/lib/module/figma/Drawer.figma.js.map +1 -1
- package/lib/module/figma/IconButton.figma.js +10 -4
- package/lib/module/figma/IconButton.figma.js.map +1 -1
- package/lib/module/figma/Input.figma.js +2 -1
- package/lib/module/figma/Input.figma.js.map +1 -1
- package/lib/module/figma/Insight.figma.js +3 -3
- package/lib/module/figma/Insight.figma.js.map +1 -1
- package/lib/module/figma/ProgressBar.figma.js +12 -2
- package/lib/module/figma/ProgressBar.figma.js.map +1 -1
- package/lib/module/figma/ProgressSegmented.figma.js +9 -1
- package/lib/module/figma/ProgressSegmented.figma.js.map +1 -1
- package/lib/module/figma/Select.figma.js +2 -1
- package/lib/module/figma/Select.figma.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 +41 -0
- package/lib/module/figma/SystemAlert.figma.js.map +1 -0
- package/lib/module/styles.css +0 -1
- 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/CountryFlag/index.d.ts +35 -0
- package/lib/typescript/components/CountryFlag/index.d.ts.map +1 -0
- package/lib/typescript/components/Input/index.d.ts +2 -0
- package/lib/typescript/components/Input/index.d.ts.map +1 -1
- 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/ProgressBar/index.d.ts +16 -1
- package/lib/typescript/components/ProgressBar/index.d.ts.map +1 -1
- package/lib/typescript/components/ProgressBar/styles.d.ts +7 -2
- package/lib/typescript/components/ProgressBar/styles.d.ts.map +1 -1
- 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/Select/index.d.ts +2 -0
- package/lib/typescript/components/Select/index.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/hiddenSvgProps.d.ts +17 -0
- package/lib/typescript/components/chart/hiddenSvgProps.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 +6 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/figma/Alert.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Badge.Indicator.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Badge.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Button.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Card.Header.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Card.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Dialog.figma.d.ts.map +1 -1
- package/lib/typescript/figma/IconButton.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Input.figma.d.ts.map +1 -1
- package/lib/typescript/figma/ProgressBar.figma.d.ts.map +1 -1
- package/lib/typescript/figma/ProgressSegmented.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Select.figma.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 +1417 -0
- package/src/components/BarChart/styles.ts +31 -0
- package/src/components/Button/index.tsx +1 -1
- package/src/components/CountryFlag/index.tsx +53 -0
- package/src/components/Input/index.tsx +2 -0
- package/src/components/LineChart/geometry.ts +957 -0
- package/src/components/LineChart/index.tsx +1106 -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/ProgressBar/index.tsx +66 -14
- package/src/components/ProgressBar/styles.ts +35 -4
- 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/Select/index.tsx +2 -0
- 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/hiddenSvgProps.ts +15 -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 +6 -0
- package/src/styles.css +0 -1
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* SVG `x`/`y` are paint coordinates. RN View `x`/`y` layout props are deprecated and share the name. */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
5
|
+
import { forwardRef, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { ScrollView, Text, View } from 'react-native';
|
|
7
|
+
import Animated, { useAnimatedProps } from 'react-native-reanimated';
|
|
8
|
+
import { Circle, ClipPath, Defs, G, Line, LinearGradient, Path, Rect, Stop, Svg, Text as SvgText } from 'react-native-svg';
|
|
9
|
+
import { dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives';
|
|
10
|
+
import { cn, useControllableState } from '@cdx-ui/utils';
|
|
11
|
+
import { ChartInspector, ChartTooltipLayer, chartValueText } from '../chart/ChartInspector';
|
|
12
|
+
import { resolveChartLocaleText, resolveValueFormatter } from '../chart/format';
|
|
13
|
+
import { HIDDEN_SVG_PROPS } from '../chart/hiddenSvgProps';
|
|
14
|
+
import { resolveChartBox } from '../chart/size';
|
|
15
|
+
import { useChartHostWidth } from '../chart/useChartHostWidth';
|
|
16
|
+
import { ChartLinearFills, chartFillUrl, chartSeriesColor, resolveChartColor, useChartChrome, useChartColorPaints, useChartGradientId } from '../chart/palette';
|
|
17
|
+
import { lerpVector, useChartMorph, useChartMotionEnabled } from '../chart/motion';
|
|
18
|
+
import { layoutLineChart, layoutLineChartMarkers, lineChartGutters, lineChartMarkerGutters, nearestCategoryInPlot, lineSeriesPaths, resolveLineChartContentSize, resolveLineChartData } from './geometry';
|
|
19
|
+
import { LINE_ACTIVE_DOT_RADIUS, LINE_DOT_RADIUS, LINE_STROKE_WIDTH, lineChartLegendItemVariants, lineChartLegendLabelVariants, lineChartLegendVariants, lineChartRootVariants } from './styles';
|
|
20
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
const INACTIVE_OPACITY = 0.4;
|
|
22
|
+
const DASH = '6 4';
|
|
23
|
+
/** Within this many px of a plot edge, callouts anchor inward so they are not clipped. */
|
|
24
|
+
const EDGE_LABEL_ROOM = 32;
|
|
25
|
+
/** Paint slack around the plot so dots and strokes on its edges are not cut in half. */
|
|
26
|
+
const CLIP_BLEED = LINE_ACTIVE_DOT_RADIUS + LINE_STROKE_WIDTH;
|
|
27
|
+
const AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
28
|
+
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
29
|
+
function LineChartInner({
|
|
30
|
+
dataset,
|
|
31
|
+
series: seriesProp,
|
|
32
|
+
xAxis: xAxisProp,
|
|
33
|
+
yAxis: yAxisProp,
|
|
34
|
+
size = 'lg',
|
|
35
|
+
width: widthProp,
|
|
36
|
+
height: heightProp,
|
|
37
|
+
grid,
|
|
38
|
+
palette = 'auto',
|
|
39
|
+
hideLegend = false,
|
|
40
|
+
tooltip: tooltipProp,
|
|
41
|
+
scrollable = true,
|
|
42
|
+
visiblePoints,
|
|
43
|
+
selectedItem: selectedItemProp,
|
|
44
|
+
defaultSelectedItem,
|
|
45
|
+
onSelectedItemChange,
|
|
46
|
+
referenceLines,
|
|
47
|
+
markers,
|
|
48
|
+
locale,
|
|
49
|
+
localeText: localeTextProp,
|
|
50
|
+
animation,
|
|
51
|
+
accessibilityLabel,
|
|
52
|
+
className,
|
|
53
|
+
style,
|
|
54
|
+
onLayout,
|
|
55
|
+
...props
|
|
56
|
+
}, ref) {
|
|
57
|
+
const animated = useChartMotionEnabled(animation);
|
|
58
|
+
const gradientId = useChartGradientId('line-fill');
|
|
59
|
+
const chrome = useChartChrome();
|
|
60
|
+
const paints = useChartColorPaints();
|
|
61
|
+
const localeText = useMemo(() => resolveChartLocaleText(localeTextProp), [localeTextProp]);
|
|
62
|
+
const xAxis = xAxisProp?.[0];
|
|
63
|
+
const yAxis = yAxisProp?.[0];
|
|
64
|
+
const showValueTicks = yAxis?.position !== 'none';
|
|
65
|
+
const showCategoryLabels = xAxis?.position !== 'none';
|
|
66
|
+
const resolved = useMemo(() => resolveLineChartData({
|
|
67
|
+
dataset,
|
|
68
|
+
series: seriesProp,
|
|
69
|
+
xAxis
|
|
70
|
+
}), [dataset, seriesProp, xAxis]);
|
|
71
|
+
const formatters = useMemo(() => seriesProp.map(item => resolveValueFormatter(item, yAxis, locale)), [seriesProp, yAxis, locale]);
|
|
72
|
+
const formatTick = useMemo(() => {
|
|
73
|
+
const format = resolveValueFormatter(null, yAxis, locale);
|
|
74
|
+
return value => format(value, {
|
|
75
|
+
location: 'tick'
|
|
76
|
+
});
|
|
77
|
+
}, [yAxis, locale]);
|
|
78
|
+
const box = resolveChartBox(size, widthProp, heightProp);
|
|
79
|
+
const [hostWidth, handleHostLayout] = useChartHostWidth(onLayout);
|
|
80
|
+
const viewportWidth = hostWidth > 0 ? Math.min(hostWidth, box.width) : box.width;
|
|
81
|
+
const viewportHeight = box.height;
|
|
82
|
+
const gutters = useMemo(() => lineChartMarkerGutters(dataset.length, markers, lineChartGutters({
|
|
83
|
+
showValueTicks,
|
|
84
|
+
showCategoryLabels
|
|
85
|
+
})), [dataset.length, markers, showValueTicks, showCategoryLabels]);
|
|
86
|
+
const content = useMemo(() => resolveLineChartContentSize({
|
|
87
|
+
viewportWidth,
|
|
88
|
+
viewportHeight,
|
|
89
|
+
categoryCount: dataset.length,
|
|
90
|
+
gutters,
|
|
91
|
+
scrollable,
|
|
92
|
+
visiblePoints
|
|
93
|
+
}), [viewportWidth, viewportHeight, dataset.length, gutters, scrollable, visiblePoints]);
|
|
94
|
+
const layout = useMemo(() => layoutLineChart({
|
|
95
|
+
categories: resolved.categories,
|
|
96
|
+
series: resolved.series,
|
|
97
|
+
width: content.width,
|
|
98
|
+
height: content.height,
|
|
99
|
+
referenceLines,
|
|
100
|
+
yAxis,
|
|
101
|
+
formatTick,
|
|
102
|
+
gutters
|
|
103
|
+
}), [resolved, content.width, content.height, referenceLines, yAxis, formatTick, gutters]);
|
|
104
|
+
const markerLayout = useMemo(() => layoutLineChartMarkers(markers ?? [], layout.series), [markers, layout.series]);
|
|
105
|
+
const overflowsX = content.width > viewportWidth + 0.5;
|
|
106
|
+
const morph = useChartMorph(layout.series.flatMap(item => item.points.map(point => point.y ?? Number.NaN)), layout.series.flatMap(item => item.points.map(point => point.y === null ? Number.NaN : layout.baselineY)), animated);
|
|
107
|
+
const fills = seriesProp.map((item, seriesIndex) => resolveChartColor(item.color, paints) ?? paints[chartSeriesColor(seriesIndex, seriesProp.length, palette, 'line')]);
|
|
108
|
+
const marks = seriesProp.map(item => item.showMark ?? false);
|
|
109
|
+
const summary = accessibilityLabel ?? lineSummary(layout, formatters, localeText);
|
|
110
|
+
const interactive = onSelectedItemChange !== undefined || selectedItemProp !== undefined || defaultSelectedItem !== undefined;
|
|
111
|
+
const [selectedItemState, setSelectedItem] = useControllableState({
|
|
112
|
+
prop: selectedItemProp,
|
|
113
|
+
defaultProp: defaultSelectedItem ?? null,
|
|
114
|
+
onChange: next => {
|
|
115
|
+
onSelectedItemChange?.(next ?? null);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const selectedIndex = selectedItemState?.dataIndex ?? null;
|
|
119
|
+
const showTooltip = (tooltipProp?.trigger ?? 'axis') !== 'none';
|
|
120
|
+
const inspectable = (interactive || showTooltip) && dataset.length > 0;
|
|
121
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
122
|
+
const [dismissed, setDismissed] = useState(false);
|
|
123
|
+
const [scrubbing, setScrubbing] = useState(false);
|
|
124
|
+
const scrollX = useRef(0);
|
|
125
|
+
const highlightIndex = activeIndex ?? selectedIndex;
|
|
126
|
+
const tooltipIndex = showTooltip && !dismissed && activeIndex !== null ? activeIndex : null;
|
|
127
|
+
const activate = index => {
|
|
128
|
+
setDismissed(false);
|
|
129
|
+
setActiveIndex(prev => prev === index ? prev : index);
|
|
130
|
+
};
|
|
131
|
+
const deactivate = index => {
|
|
132
|
+
setActiveIndex(prev => prev === index ? null : prev);
|
|
133
|
+
};
|
|
134
|
+
const selectIndex = index => {
|
|
135
|
+
if (selectedIndex === index) {
|
|
136
|
+
setSelectedItem(null);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const owner = layout.series.find(item => item.points[index]?.value != null) ?? layout.series[0];
|
|
140
|
+
setSelectedItem(owner === undefined ? null : {
|
|
141
|
+
seriesId: owner.key,
|
|
142
|
+
dataIndex: index
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const markerLegend = markerLayout.filter(item => item.legend !== undefined && item.legend.length > 0);
|
|
146
|
+
const showLegend = !hideLegend && (seriesProp.length > 0 || markerLegend.length > 0);
|
|
147
|
+
const plot = /*#__PURE__*/_jsx(LinePlot, {
|
|
148
|
+
layout: layout,
|
|
149
|
+
morph: morph,
|
|
150
|
+
fills: fills,
|
|
151
|
+
gradientId: gradientId,
|
|
152
|
+
chrome: chrome,
|
|
153
|
+
marks: marks,
|
|
154
|
+
showGrid: grid?.horizontal !== false,
|
|
155
|
+
highlightIndex: highlightIndex,
|
|
156
|
+
formatters: formatters,
|
|
157
|
+
markers: markerLayout,
|
|
158
|
+
paints: paints
|
|
159
|
+
});
|
|
160
|
+
const plotWidth = content.width - layout.plot.x;
|
|
161
|
+
const bleed = Math.min(CLIP_BLEED, layout.plot.x);
|
|
162
|
+
const axisWidth = layout.plot.x - bleed;
|
|
163
|
+
const targets = inspectable ? lineInspectorTargets({
|
|
164
|
+
layout,
|
|
165
|
+
width: plotWidth,
|
|
166
|
+
height: viewportHeight,
|
|
167
|
+
fills,
|
|
168
|
+
formatters,
|
|
169
|
+
localeText,
|
|
170
|
+
selectedIndex,
|
|
171
|
+
markers: markerLayout
|
|
172
|
+
}) : [];
|
|
173
|
+
const tip = tooltipIndex === null ? undefined : targets.at(tooltipIndex);
|
|
174
|
+
const ticks = showValueTicks ? /*#__PURE__*/_jsx(_Fragment, {
|
|
175
|
+
children: layout.valueTicks.map(tick => /*#__PURE__*/_jsx(SvgText, {
|
|
176
|
+
x: tick.x,
|
|
177
|
+
y: tick.y,
|
|
178
|
+
fill: chrome.label,
|
|
179
|
+
fontFamily: chrome.fontFamily,
|
|
180
|
+
fontSize: chrome.labelSize,
|
|
181
|
+
textAnchor: "end",
|
|
182
|
+
alignmentBaseline: "middle",
|
|
183
|
+
children: tick.text
|
|
184
|
+
}, `tick-${String(tick.value)}`))
|
|
185
|
+
}) : null;
|
|
186
|
+
const chart = /*#__PURE__*/_jsxs(View, {
|
|
187
|
+
className: "flex-row",
|
|
188
|
+
style: {
|
|
189
|
+
width: viewportWidth,
|
|
190
|
+
height: viewportHeight
|
|
191
|
+
},
|
|
192
|
+
...dataAttributes({
|
|
193
|
+
slot: 'line-chart-plot'
|
|
194
|
+
}),
|
|
195
|
+
children: [/*#__PURE__*/_jsx(Svg, {
|
|
196
|
+
width: axisWidth,
|
|
197
|
+
height: viewportHeight,
|
|
198
|
+
viewBox: `0 0 ${String(axisWidth)} ${String(content.height)}`,
|
|
199
|
+
...HIDDEN_SVG_PROPS,
|
|
200
|
+
children: ticks
|
|
201
|
+
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
202
|
+
horizontal: true,
|
|
203
|
+
nestedScrollEnabled: true,
|
|
204
|
+
scrollEnabled: overflowsX && !scrubbing,
|
|
205
|
+
showsHorizontalScrollIndicator: overflowsX,
|
|
206
|
+
scrollEventThrottle: 16,
|
|
207
|
+
onScroll: event => {
|
|
208
|
+
scrollX.current = event.nativeEvent.contentOffset.x;
|
|
209
|
+
if (tooltipIndex !== null) {
|
|
210
|
+
setDismissed(true);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
className: "flex-1",
|
|
214
|
+
style: {
|
|
215
|
+
height: viewportHeight
|
|
216
|
+
},
|
|
217
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
218
|
+
style: {
|
|
219
|
+
width: plotWidth + bleed,
|
|
220
|
+
height: viewportHeight
|
|
221
|
+
},
|
|
222
|
+
children: [/*#__PURE__*/_jsx(Svg, {
|
|
223
|
+
width: plotWidth + bleed,
|
|
224
|
+
height: viewportHeight,
|
|
225
|
+
viewBox: `0 0 ${String(plotWidth + bleed)} ${String(content.height)}`,
|
|
226
|
+
pointerEvents: "none",
|
|
227
|
+
...HIDDEN_SVG_PROPS,
|
|
228
|
+
children: /*#__PURE__*/_jsx(G, {
|
|
229
|
+
transform: `translate(${String(-axisWidth)}, 0)`,
|
|
230
|
+
children: plot
|
|
231
|
+
})
|
|
232
|
+
}), inspectable ? /*#__PURE__*/_jsx(View, {
|
|
233
|
+
className: "absolute top-0 bottom-0",
|
|
234
|
+
style: {
|
|
235
|
+
left: bleed,
|
|
236
|
+
width: plotWidth
|
|
237
|
+
},
|
|
238
|
+
pointerEvents: "box-none",
|
|
239
|
+
children: /*#__PURE__*/_jsx(LineInspector, {
|
|
240
|
+
layout: layout,
|
|
241
|
+
targets: targets,
|
|
242
|
+
summary: summary,
|
|
243
|
+
selectable: interactive,
|
|
244
|
+
selectedIndex: selectedIndex,
|
|
245
|
+
activeIndex: activeIndex,
|
|
246
|
+
holdToScrub: overflowsX,
|
|
247
|
+
onScrubLockChange: setScrubbing,
|
|
248
|
+
onActivate: activate,
|
|
249
|
+
onDeactivate: deactivate,
|
|
250
|
+
onDismiss: () => {
|
|
251
|
+
setDismissed(true);
|
|
252
|
+
},
|
|
253
|
+
onSelectIndex: selectIndex
|
|
254
|
+
})
|
|
255
|
+
}) : null]
|
|
256
|
+
})
|
|
257
|
+
}), tip !== undefined ? /*#__PURE__*/_jsx(ChartTooltipLayer, {
|
|
258
|
+
content: tip.tooltip,
|
|
259
|
+
noValueText: localeText.noValue,
|
|
260
|
+
slot: "line-chart",
|
|
261
|
+
anchorX: layout.plot.x + tip.anchorX - scrollX.current,
|
|
262
|
+
anchorY: tip.anchorY,
|
|
263
|
+
anchorRadius: tip.anchorRadius,
|
|
264
|
+
width: viewportWidth,
|
|
265
|
+
height: viewportHeight
|
|
266
|
+
}) : null]
|
|
267
|
+
});
|
|
268
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
269
|
+
ref: ref,
|
|
270
|
+
className: cn(lineChartRootVariants(), className),
|
|
271
|
+
style: style,
|
|
272
|
+
accessible: !inspectable && !showLegend,
|
|
273
|
+
accessibilityRole: !inspectable && !showLegend ? 'image' : undefined,
|
|
274
|
+
accessibilityLabel: !inspectable && !showLegend ? summary : undefined,
|
|
275
|
+
...props,
|
|
276
|
+
onLayout: handleHostLayout,
|
|
277
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
278
|
+
slot: 'line-chart'
|
|
279
|
+
})),
|
|
280
|
+
children: [chart, showLegend ? /*#__PURE__*/_jsxs(View, {
|
|
281
|
+
className: lineChartLegendVariants(),
|
|
282
|
+
...dataAttributes({
|
|
283
|
+
slot: 'line-chart-legend'
|
|
284
|
+
}),
|
|
285
|
+
children: [seriesProp.map((item, seriesIndex) => {
|
|
286
|
+
const selectedPoint = highlightIndex === null ? undefined : layout.series[seriesIndex]?.points.at(highlightIndex);
|
|
287
|
+
const isSelected = selectedPoint !== undefined && selectedPoint.value !== null;
|
|
288
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
289
|
+
className: lineChartLegendItemVariants(),
|
|
290
|
+
...dataAttributes({
|
|
291
|
+
slot: 'line-chart-legend-item'
|
|
292
|
+
}),
|
|
293
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
294
|
+
className: "h-0.5 w-3 rounded-full",
|
|
295
|
+
style: {
|
|
296
|
+
backgroundColor: fills[seriesIndex]
|
|
297
|
+
}
|
|
298
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
299
|
+
className: lineChartLegendLabelVariants({
|
|
300
|
+
selected: isSelected
|
|
301
|
+
}),
|
|
302
|
+
children: seriesLegendLabel(item, seriesProp.length, localeText)
|
|
303
|
+
})]
|
|
304
|
+
}, item.id);
|
|
305
|
+
}), markerLegend.map(item => /*#__PURE__*/_jsxs(View, {
|
|
306
|
+
className: lineChartLegendItemVariants(),
|
|
307
|
+
...dataAttributes({
|
|
308
|
+
slot: 'line-chart-legend-item'
|
|
309
|
+
}),
|
|
310
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
311
|
+
className: "size-2.5 rounded-full",
|
|
312
|
+
style: {
|
|
313
|
+
backgroundColor: resolveChartColor(item.color, paints) ?? fills[item.seriesIndex] ?? fills[0]
|
|
314
|
+
}
|
|
315
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
316
|
+
className: lineChartLegendLabelVariants(),
|
|
317
|
+
children: item.legend
|
|
318
|
+
})]
|
|
319
|
+
}, `legend-${item.key}`))]
|
|
320
|
+
}) : null]
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
export const LineChart = /*#__PURE__*/forwardRef(LineChartInner);
|
|
324
|
+
LineChart.displayName = 'LineChart';
|
|
325
|
+
function lineSummary(layout, formatters, localeText) {
|
|
326
|
+
const lastIndex = layout.categoryLabels.length - 1;
|
|
327
|
+
const last = layout.categoryLabels[lastIndex];
|
|
328
|
+
if (last === undefined) {
|
|
329
|
+
return localeText.lineChartSummary(null);
|
|
330
|
+
}
|
|
331
|
+
const latest = {
|
|
332
|
+
label: last.title,
|
|
333
|
+
values: layout.series.flatMap((item, seriesIndex) => {
|
|
334
|
+
const value = item.points[lastIndex]?.value;
|
|
335
|
+
if (value == null) {
|
|
336
|
+
return [];
|
|
337
|
+
}
|
|
338
|
+
const format = formatters[seriesIndex];
|
|
339
|
+
return [{
|
|
340
|
+
label: item.label,
|
|
341
|
+
formattedValue: format?.(value, {
|
|
342
|
+
location: 'a11y',
|
|
343
|
+
seriesId: item.key,
|
|
344
|
+
dataIndex: lastIndex
|
|
345
|
+
}) ?? ''
|
|
346
|
+
}];
|
|
347
|
+
})
|
|
348
|
+
};
|
|
349
|
+
return localeText.lineChartSummary(latest);
|
|
350
|
+
}
|
|
351
|
+
function showsMark(mark, index) {
|
|
352
|
+
return typeof mark === 'function' ? mark({
|
|
353
|
+
index
|
|
354
|
+
}) : mark === true;
|
|
355
|
+
}
|
|
356
|
+
function LinePlot({
|
|
357
|
+
layout,
|
|
358
|
+
morph,
|
|
359
|
+
fills,
|
|
360
|
+
gradientId,
|
|
361
|
+
chrome,
|
|
362
|
+
marks,
|
|
363
|
+
showGrid,
|
|
364
|
+
highlightIndex,
|
|
365
|
+
formatters,
|
|
366
|
+
markers,
|
|
367
|
+
paints
|
|
368
|
+
}) {
|
|
369
|
+
const xs = layout.categoryLabels.map(item => item.x);
|
|
370
|
+
const clipId = `${gradientId}-clip`;
|
|
371
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
372
|
+
children: [/*#__PURE__*/_jsx(ChartLinearFills, {
|
|
373
|
+
idPrefix: gradientId,
|
|
374
|
+
colors: fills,
|
|
375
|
+
x2: "100%",
|
|
376
|
+
y2: "0%"
|
|
377
|
+
}), /*#__PURE__*/_jsxs(Defs, {
|
|
378
|
+
children: [fills.map((color, index) => /*#__PURE__*/_jsxs(LinearGradient, {
|
|
379
|
+
id: `${gradientId}-area-${String(index)}`,
|
|
380
|
+
x1: "0%",
|
|
381
|
+
y1: "0%",
|
|
382
|
+
x2: "0%",
|
|
383
|
+
y2: "100%",
|
|
384
|
+
children: [/*#__PURE__*/_jsx(Stop, {
|
|
385
|
+
offset: "0%",
|
|
386
|
+
stopColor: color,
|
|
387
|
+
stopOpacity: 0.32
|
|
388
|
+
}), /*#__PURE__*/_jsx(Stop, {
|
|
389
|
+
offset: "100%",
|
|
390
|
+
stopColor: color,
|
|
391
|
+
stopOpacity: 0
|
|
392
|
+
})]
|
|
393
|
+
}, `area-${String(index)}`)), /*#__PURE__*/_jsx(ClipPath, {
|
|
394
|
+
id: clipId,
|
|
395
|
+
children: /*#__PURE__*/_jsx(Rect, {
|
|
396
|
+
x: layout.plot.x - CLIP_BLEED,
|
|
397
|
+
y: layout.plot.y - CLIP_BLEED,
|
|
398
|
+
width: layout.plot.width + CLIP_BLEED * 2,
|
|
399
|
+
height: layout.plot.height + CLIP_BLEED * 2
|
|
400
|
+
})
|
|
401
|
+
})]
|
|
402
|
+
}), showGrid ? layout.gridLines.map(line => /*#__PURE__*/_jsx(Line, {
|
|
403
|
+
x1: line.x1,
|
|
404
|
+
y1: line.y1,
|
|
405
|
+
x2: line.x2,
|
|
406
|
+
y2: line.y2,
|
|
407
|
+
stroke: chrome.grid,
|
|
408
|
+
strokeWidth: 1
|
|
409
|
+
}, `grid-${String(line.x1)}-${String(line.y1)}`)) : null, layout.referenceLines.map((line, index) => /*#__PURE__*/_jsxs(G, {
|
|
410
|
+
children: [/*#__PURE__*/_jsx(Line, {
|
|
411
|
+
x1: line.x1,
|
|
412
|
+
y1: line.y1,
|
|
413
|
+
x2: line.x2,
|
|
414
|
+
y2: line.y2,
|
|
415
|
+
stroke: chrome.label,
|
|
416
|
+
strokeWidth: 1,
|
|
417
|
+
strokeDasharray: DASH
|
|
418
|
+
}), line.label !== undefined && line.label.length > 0 ? /*#__PURE__*/_jsx(SvgText, {
|
|
419
|
+
x: line.x1 + 4,
|
|
420
|
+
y: line.y1 - 4,
|
|
421
|
+
fill: chrome.label,
|
|
422
|
+
fontFamily: chrome.fontFamily,
|
|
423
|
+
fontSize: chrome.captionSize,
|
|
424
|
+
textAnchor: "start",
|
|
425
|
+
children: line.label
|
|
426
|
+
}) : null]
|
|
427
|
+
}, `ref-${String(line.y1)}-${String(index)}`)), /*#__PURE__*/_jsxs(G, {
|
|
428
|
+
clipPath: `url(#${clipId})`,
|
|
429
|
+
children: [layout.series.map((item, seriesIndex) => /*#__PURE__*/_jsx(AnimatedSeries, {
|
|
430
|
+
item: item,
|
|
431
|
+
seriesIndex: seriesIndex,
|
|
432
|
+
xs: xs,
|
|
433
|
+
baselineY: layout.baselineY,
|
|
434
|
+
morph: morph,
|
|
435
|
+
areaFill: `url(#${gradientId}-area-${String(seriesIndex)})`,
|
|
436
|
+
stroke: chartFillUrl(gradientId, seriesIndex),
|
|
437
|
+
opacity: highlightIndex !== null ? INACTIVE_OPACITY + 0.35 : 1
|
|
438
|
+
}, item.key)), layout.series.flatMap((item, seriesIndex) => item.points.map(point => point.y === null || !showsMark(marks[seriesIndex], point.index) ? null : /*#__PURE__*/_jsx(AnimatedDot, {
|
|
439
|
+
cx: point.x,
|
|
440
|
+
slot: seriesIndex * xs.length + point.index,
|
|
441
|
+
morph: morph,
|
|
442
|
+
fill: chrome.surface,
|
|
443
|
+
stroke: fills[seriesIndex] ?? chrome.label
|
|
444
|
+
}, `dot-${item.key}-${String(point.index)}`)))]
|
|
445
|
+
}), highlightIndex !== null ? (() => {
|
|
446
|
+
const label = layout.categoryLabels.at(highlightIndex);
|
|
447
|
+
if (label === undefined) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
451
|
+
x1: label.x,
|
|
452
|
+
x2: label.x,
|
|
453
|
+
y1: layout.plot.y,
|
|
454
|
+
y2: layout.plot.y + layout.plot.height,
|
|
455
|
+
stroke: chrome.label,
|
|
456
|
+
strokeWidth: 1,
|
|
457
|
+
strokeDasharray: "3 4"
|
|
458
|
+
});
|
|
459
|
+
})() : null, markers.map(marker => marker.guide ? /*#__PURE__*/_jsx(Line, {
|
|
460
|
+
x1: marker.x,
|
|
461
|
+
x2: marker.x,
|
|
462
|
+
y1: layout.plot.y,
|
|
463
|
+
y2: layout.plot.y + layout.plot.height,
|
|
464
|
+
stroke: chrome.grid,
|
|
465
|
+
strokeWidth: 1,
|
|
466
|
+
strokeDasharray: "3 4",
|
|
467
|
+
opacity: highlightIndex !== null && highlightIndex !== marker.index ? INACTIVE_OPACITY : 1
|
|
468
|
+
}, `marker-guide-${marker.key}`) : null), highlightIndex !== null ? layout.series.flatMap((item, seriesIndex) => {
|
|
469
|
+
const point = item.points.at(highlightIndex);
|
|
470
|
+
if (point?.y == null) {
|
|
471
|
+
return [];
|
|
472
|
+
}
|
|
473
|
+
return [/*#__PURE__*/_jsx(Circle, {
|
|
474
|
+
cx: point.x,
|
|
475
|
+
cy: point.y,
|
|
476
|
+
r: LINE_ACTIVE_DOT_RADIUS,
|
|
477
|
+
fill: chrome.surface,
|
|
478
|
+
stroke: fills[seriesIndex],
|
|
479
|
+
strokeWidth: LINE_STROKE_WIDTH
|
|
480
|
+
}, `active-${item.key}`)];
|
|
481
|
+
}) : null, markers.map(marker => {
|
|
482
|
+
const color = resolveChartColor(marker.color, paints) ?? fills[marker.seriesIndex] ?? fills.at(0) ?? chrome.label;
|
|
483
|
+
const nearEnd = marker.x > layout.plot.x + layout.plot.width - EDGE_LABEL_ROOM;
|
|
484
|
+
const nearStart = marker.x < layout.plot.x + EDGE_LABEL_ROOM;
|
|
485
|
+
const captionAnchor = nearEnd ? 'end' : nearStart ? 'start' : 'middle';
|
|
486
|
+
const dimmed = highlightIndex !== null && highlightIndex !== marker.index;
|
|
487
|
+
const markerOpacity = dimmed ? INACTIVE_OPACITY : 1;
|
|
488
|
+
const format = formatters[marker.seriesIndex];
|
|
489
|
+
return /*#__PURE__*/_jsxs(G, {
|
|
490
|
+
children: [marker.dot ? /*#__PURE__*/_jsx(Circle, {
|
|
491
|
+
cx: marker.x,
|
|
492
|
+
cy: marker.y,
|
|
493
|
+
r: LINE_ACTIVE_DOT_RADIUS,
|
|
494
|
+
fill: color,
|
|
495
|
+
stroke: chrome.surface,
|
|
496
|
+
strokeWidth: LINE_STROKE_WIDTH,
|
|
497
|
+
opacity: markerOpacity
|
|
498
|
+
}) : null, marker.label !== undefined && marker.label.length > 0 ? /*#__PURE__*/_jsx(SvgText, {
|
|
499
|
+
x: marker.x,
|
|
500
|
+
y: marker.y - 16,
|
|
501
|
+
fill: chrome.label,
|
|
502
|
+
fontFamily: chrome.fontFamily,
|
|
503
|
+
fontSize: chrome.captionSize,
|
|
504
|
+
textAnchor: captionAnchor,
|
|
505
|
+
opacity: markerOpacity,
|
|
506
|
+
children: marker.label
|
|
507
|
+
}) : null, marker.showValue ? /*#__PURE__*/_jsx(SvgText, {
|
|
508
|
+
x: nearEnd ? marker.x - 10 : marker.x + 10,
|
|
509
|
+
y: marker.y + 4,
|
|
510
|
+
fill: chrome.label,
|
|
511
|
+
fontFamily: chrome.fontFamily,
|
|
512
|
+
fontSize: chrome.captionSize,
|
|
513
|
+
textAnchor: nearEnd ? 'end' : 'start',
|
|
514
|
+
opacity: markerOpacity,
|
|
515
|
+
children: format?.(marker.value, {
|
|
516
|
+
location: 'label',
|
|
517
|
+
seriesId: marker.seriesId,
|
|
518
|
+
dataIndex: marker.index
|
|
519
|
+
}) ?? ''
|
|
520
|
+
}) : null]
|
|
521
|
+
}, `marker-${marker.key}`);
|
|
522
|
+
}), layout.categoryLabels.map((item, index) => item.tick ? /*#__PURE__*/_jsx(SvgText, {
|
|
523
|
+
x: item.x,
|
|
524
|
+
y: item.y,
|
|
525
|
+
fill: chrome.label,
|
|
526
|
+
fontFamily: chrome.fontFamily,
|
|
527
|
+
fontSize: chrome.labelSize,
|
|
528
|
+
textAnchor: layout.categoryLabels.length < 2 ? 'middle' : index === 0 ? 'start' : index === layout.categoryLabels.length - 1 ? 'end' : 'middle',
|
|
529
|
+
alignmentBaseline: "middle",
|
|
530
|
+
children: item.label
|
|
531
|
+
}, `cat-${item.label}-${String(index)}`) : null)]
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
function categoryValues(layout, index, fills, formatters, location) {
|
|
535
|
+
return layout.series.flatMap((item, seriesIndex) => {
|
|
536
|
+
const point = item.points.at(index);
|
|
537
|
+
if (point?.value == null) {
|
|
538
|
+
return [];
|
|
539
|
+
}
|
|
540
|
+
const format = formatters[seriesIndex];
|
|
541
|
+
return [{
|
|
542
|
+
seriesId: item.key,
|
|
543
|
+
label: item.label,
|
|
544
|
+
color: fills[seriesIndex] ?? '',
|
|
545
|
+
formattedValue: format?.(point.value, {
|
|
546
|
+
location,
|
|
547
|
+
seriesId: item.key,
|
|
548
|
+
dataIndex: index
|
|
549
|
+
}) ?? ''
|
|
550
|
+
}];
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
function seriesLegendLabel(item, seriesCount, localeText) {
|
|
554
|
+
if (item.label !== undefined && item.label.length > 0) {
|
|
555
|
+
return item.label;
|
|
556
|
+
}
|
|
557
|
+
return seriesCount === 1 ? localeText.defaultSeriesLabel : item.id;
|
|
558
|
+
}
|
|
559
|
+
function categoryAnnouncement(label, values, noValue, notes = []) {
|
|
560
|
+
const parts = values.map(chartValueText);
|
|
561
|
+
const base = parts.length > 0 ? `${label}, ${parts.join(', ')}` : `${label}, ${noValue}`;
|
|
562
|
+
return notes.length > 0 ? `${base}, ${notes.join(', ')}` : base;
|
|
563
|
+
}
|
|
564
|
+
function markerNotes(markers, index) {
|
|
565
|
+
return markers.filter(marker => marker.index === index).flatMap(marker => [marker.legend, marker.label].filter(text => text !== undefined && text.length > 0));
|
|
566
|
+
}
|
|
567
|
+
function lineKeyboardNeighbor(index, key, count) {
|
|
568
|
+
if (key === 'Tab') {
|
|
569
|
+
return index + 1 < count ? index + 1 : null;
|
|
570
|
+
}
|
|
571
|
+
if (key === 'Shift+Tab') {
|
|
572
|
+
return index > 0 ? index - 1 : null;
|
|
573
|
+
}
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** Targets in scroll-content coordinates, which start at `layout.plot.x`. */
|
|
578
|
+
function lineInspectorTargets({
|
|
579
|
+
layout,
|
|
580
|
+
width,
|
|
581
|
+
height,
|
|
582
|
+
fills,
|
|
583
|
+
formatters,
|
|
584
|
+
localeText,
|
|
585
|
+
selectedIndex,
|
|
586
|
+
markers
|
|
587
|
+
}) {
|
|
588
|
+
const count = layout.categoryLabels.length;
|
|
589
|
+
const band = layout.plot.width / Math.max(count - 1, 1);
|
|
590
|
+
const offset = layout.plot.x;
|
|
591
|
+
return layout.categoryLabels.map((item, index) => {
|
|
592
|
+
const x = item.x - offset;
|
|
593
|
+
const left = index === 0 ? 0 : x - band / 2;
|
|
594
|
+
const right = index === count - 1 ? width : x + band / 2;
|
|
595
|
+
const pointYs = layout.series.flatMap(series => {
|
|
596
|
+
const y = series.points.at(index)?.y;
|
|
597
|
+
return y == null ? [] : [y];
|
|
598
|
+
});
|
|
599
|
+
return {
|
|
600
|
+
key: `hit-${String(index)}`,
|
|
601
|
+
left,
|
|
602
|
+
top: 0,
|
|
603
|
+
width: Math.max(right - left, 1),
|
|
604
|
+
height,
|
|
605
|
+
anchorX: x,
|
|
606
|
+
anchorY: pointYs.length > 0 ? Math.min(...pointYs) : layout.plot.y,
|
|
607
|
+
tooltip: {
|
|
608
|
+
title: item.title,
|
|
609
|
+
items: categoryValues(layout, index, fills, formatters, 'tooltip')
|
|
610
|
+
},
|
|
611
|
+
accessibilityLabel: categoryAnnouncement(item.title, categoryValues(layout, index, fills, formatters, 'a11y'), localeText.noValue, markerNotes(markers, index)),
|
|
612
|
+
selected: selectedIndex === index
|
|
613
|
+
};
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
function LineInspector({
|
|
617
|
+
layout,
|
|
618
|
+
targets,
|
|
619
|
+
summary,
|
|
620
|
+
selectable,
|
|
621
|
+
selectedIndex,
|
|
622
|
+
activeIndex,
|
|
623
|
+
onActivate,
|
|
624
|
+
onDeactivate,
|
|
625
|
+
onDismiss,
|
|
626
|
+
onSelectIndex,
|
|
627
|
+
holdToScrub,
|
|
628
|
+
onScrubLockChange
|
|
629
|
+
}) {
|
|
630
|
+
const count = layout.categoryLabels.length;
|
|
631
|
+
const offset = layout.plot.x;
|
|
632
|
+
return /*#__PURE__*/_jsx(ChartInspector, {
|
|
633
|
+
targets: targets,
|
|
634
|
+
summary: summary,
|
|
635
|
+
selectable: selectable,
|
|
636
|
+
activeIndex: activeIndex,
|
|
637
|
+
selectedIndex: selectedIndex,
|
|
638
|
+
slot: "line-chart",
|
|
639
|
+
holdToScrub: holdToScrub,
|
|
640
|
+
onActivate: onActivate,
|
|
641
|
+
onDeactivate: onDeactivate,
|
|
642
|
+
onDismiss: onDismiss,
|
|
643
|
+
onSelectIndex: onSelectIndex,
|
|
644
|
+
hitTest: (x, y) => nearestCategoryInPlot(layout.categoryLabels, layout.plot, x, y, offset),
|
|
645
|
+
neighborIndex: (index, key) => lineKeyboardNeighbor(index, key, count),
|
|
646
|
+
onScrubLockChange: onScrubLockChange
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
function AnimatedSeries({
|
|
650
|
+
item,
|
|
651
|
+
seriesIndex,
|
|
652
|
+
xs,
|
|
653
|
+
baselineY,
|
|
654
|
+
morph,
|
|
655
|
+
areaFill,
|
|
656
|
+
stroke,
|
|
657
|
+
opacity
|
|
658
|
+
}) {
|
|
659
|
+
const {
|
|
660
|
+
from,
|
|
661
|
+
to,
|
|
662
|
+
progress
|
|
663
|
+
} = morph;
|
|
664
|
+
const start = seriesIndex * xs.length;
|
|
665
|
+
const end = start + xs.length;
|
|
666
|
+
const dashAt = item.dashAt;
|
|
667
|
+
const curve = item.curve;
|
|
668
|
+
const lineProps = useAnimatedProps(() => {
|
|
669
|
+
const ys = lerpVector(from.get(), to.get(), progress.get()).slice(start, end);
|
|
670
|
+
return {
|
|
671
|
+
d: lineSeriesPaths(xs, ys, curve, baselineY, dashAt).path
|
|
672
|
+
};
|
|
673
|
+
}, [from, to, progress, start, end, xs, curve, baselineY, dashAt]);
|
|
674
|
+
const dashProps = useAnimatedProps(() => {
|
|
675
|
+
const ys = lerpVector(from.get(), to.get(), progress.get()).slice(start, end);
|
|
676
|
+
return {
|
|
677
|
+
d: lineSeriesPaths(xs, ys, curve, baselineY, dashAt).dashedPath
|
|
678
|
+
};
|
|
679
|
+
}, [from, to, progress, start, end, xs, curve, baselineY, dashAt]);
|
|
680
|
+
const areaProps = useAnimatedProps(() => {
|
|
681
|
+
const ys = lerpVector(from.get(), to.get(), progress.get()).slice(start, end);
|
|
682
|
+
return {
|
|
683
|
+
d: lineSeriesPaths(xs, ys, curve, baselineY, dashAt).areaPath
|
|
684
|
+
};
|
|
685
|
+
}, [from, to, progress, start, end, xs, curve, baselineY, dashAt]);
|
|
686
|
+
return /*#__PURE__*/_jsxs(G, {
|
|
687
|
+
children: [item.area && item.areaPath.length > 0 ? /*#__PURE__*/_jsx(AnimatedPath, {
|
|
688
|
+
animatedProps: areaProps,
|
|
689
|
+
fill: areaFill
|
|
690
|
+
}) : null, item.path.length > 0 ? /*#__PURE__*/_jsx(AnimatedPath, {
|
|
691
|
+
animatedProps: lineProps,
|
|
692
|
+
fill: "none",
|
|
693
|
+
stroke: stroke,
|
|
694
|
+
strokeWidth: LINE_STROKE_WIDTH,
|
|
695
|
+
strokeLinecap: "round",
|
|
696
|
+
strokeLinejoin: "round",
|
|
697
|
+
strokeDasharray: item.dashed ? DASH : undefined,
|
|
698
|
+
opacity: opacity
|
|
699
|
+
}) : null, item.dashedPath.length > 0 ? /*#__PURE__*/_jsx(AnimatedPath, {
|
|
700
|
+
animatedProps: dashProps,
|
|
701
|
+
fill: "none",
|
|
702
|
+
stroke: stroke,
|
|
703
|
+
strokeWidth: LINE_STROKE_WIDTH,
|
|
704
|
+
strokeLinecap: "round",
|
|
705
|
+
strokeLinejoin: "round",
|
|
706
|
+
strokeDasharray: DASH,
|
|
707
|
+
opacity: opacity
|
|
708
|
+
}) : null]
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
function AnimatedDot({
|
|
712
|
+
cx,
|
|
713
|
+
slot,
|
|
714
|
+
morph,
|
|
715
|
+
fill,
|
|
716
|
+
stroke
|
|
717
|
+
}) {
|
|
718
|
+
const {
|
|
719
|
+
from,
|
|
720
|
+
to,
|
|
721
|
+
progress
|
|
722
|
+
} = morph;
|
|
723
|
+
const animatedProps = useAnimatedProps(() => {
|
|
724
|
+
const ys = lerpVector(from.get(), to.get(), progress.get());
|
|
725
|
+
return {
|
|
726
|
+
cy: ys[slot] ?? 0
|
|
727
|
+
};
|
|
728
|
+
}, [from, to, progress, slot]);
|
|
729
|
+
return /*#__PURE__*/_jsx(AnimatedCircle, {
|
|
730
|
+
animatedProps: animatedProps,
|
|
731
|
+
cx: cx,
|
|
732
|
+
r: LINE_DOT_RADIUS,
|
|
733
|
+
fill: fill,
|
|
734
|
+
stroke: stroke,
|
|
735
|
+
strokeWidth: LINE_STROKE_WIDTH
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
//# sourceMappingURL=index.js.map
|