@codecademy/gamut 68.1.5-alpha.fbf911.0 → 68.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/Alert/Alert.d.ts +1 -0
- package/dist/Alert/elements.d.ts +18 -17
- package/dist/Alert/variants.d.ts +2 -1
- package/dist/Anchor/index.d.ts +15 -15
- package/dist/Animation/ExpandInCollapseOut.d.ts +1 -0
- package/dist/AppWrapper/index.d.ts +3 -2
- package/dist/Badge/index.d.ts +3 -2
- package/dist/BarChart/BarChartProvider.d.ts +19 -0
- package/dist/BarChart/BarChartProvider.js +27 -0
- package/dist/BarChart/BarRow/ValueLabelsContent.d.ts +7 -0
- package/dist/BarChart/BarRow/ValueLabelsContent.js +34 -0
- package/dist/BarChart/BarRow/elements.d.ts +959 -0
- package/dist/BarChart/BarRow/elements.js +110 -0
- package/dist/BarChart/BarRow/index.d.ts +6 -0
- package/dist/BarChart/BarRow/index.js +231 -0
- package/dist/BarChart/SortSelect/index.d.ts +15 -0
- package/dist/BarChart/SortSelect/index.js +18 -0
- package/dist/BarChart/index.d.ts +4 -0
- package/dist/BarChart/index.js +136 -0
- package/dist/BarChart/layout/GridLines.d.ts +3 -0
- package/dist/BarChart/layout/GridLines.js +69 -0
- package/dist/BarChart/layout/LabelSpacer.d.ts +6 -0
- package/dist/BarChart/layout/LabelSpacer.js +56 -0
- package/dist/BarChart/layout/ScaleChartHeader.d.ts +3 -0
- package/dist/BarChart/layout/ScaleChartHeader.js +87 -0
- package/dist/BarChart/shared/elements.d.ts +7 -0
- package/dist/BarChart/shared/elements.js +12 -0
- package/dist/BarChart/shared/styles.d.ts +4 -0
- package/dist/BarChart/shared/styles.js +4 -0
- package/dist/BarChart/shared/translations.d.ts +69 -0
- package/dist/BarChart/shared/translations.js +57 -0
- package/dist/BarChart/shared/types.d.ts +100 -0
- package/dist/BarChart/shared/types.js +1 -0
- package/dist/BarChart/utils/hooks.d.ts +89 -0
- package/dist/BarChart/utils/hooks.js +281 -0
- package/dist/BarChart/utils/index.d.ts +56 -0
- package/dist/BarChart/utils/index.js +122 -0
- package/dist/Box/Box.d.ts +3 -2
- package/dist/Box/FlexBox.d.ts +3 -2
- package/dist/Box/GridBox.d.ts +3 -2
- package/dist/Box/props.d.ts +3 -3
- package/dist/Button/CTAButton.d.ts +9 -8
- package/dist/Button/FillButton.d.ts +18 -17
- package/dist/Button/IconButton.d.ts +19 -19
- package/dist/Button/StrokeButton.d.ts +18 -17
- package/dist/Button/TextButton.d.ts +18 -17
- package/dist/Button/shared/InlineIconButton.d.ts +13 -12
- package/dist/Button/shared/styles.d.ts +15 -10
- package/dist/Button/shared/variants.d.ts +6 -6
- package/dist/ButtonBase/ButtonBase.d.ts +9 -7
- package/dist/Card/elements.d.ts +4 -2
- package/dist/Card/styles.d.ts +2 -2
- package/dist/ConnectedForm/ConnectedInputs/ConnectedNestedCheckboxes/utils.d.ts +1 -0
- package/dist/ConnectedForm/utils.d.ts +6 -6
- package/dist/ContentContainer/index.d.ts +4 -3
- package/dist/DataList/Tables/Rows/elements.d.ts +2 -1
- package/dist/DataList/hooks/useListControls.d.ts +2 -1
- package/dist/DataList/hooks/useListState.d.ts +1 -0
- package/dist/Disclosure/elements.d.ts +58 -57
- package/dist/Disclosure/helpers.d.ts +4 -4
- package/dist/Disclosure/types.d.ts +1 -0
- package/dist/Drawer/index.d.ts +1 -0
- package/dist/FeatureShimmer/index.d.ts +1 -0
- package/dist/Form/SelectDropdown/elements/constants.d.ts +1 -0
- package/dist/Form/SelectDropdown/elements/containers.d.ts +1 -0
- package/dist/Form/SelectDropdown/styles.d.ts +2 -2
- package/dist/Form/SelectDropdown/utils.d.ts +2 -2
- package/dist/Form/__fixtures__/utils.d.ts +1 -0
- package/dist/Form/elements/Form.d.ts +4 -4
- package/dist/Form/elements/FormError.d.ts +1 -1
- package/dist/Form/elements/FormGroup.d.ts +4 -4
- package/dist/Form/elements/FormGroupDescription.d.ts +4 -3
- package/dist/Form/elements/FormGroupLabel.d.ts +2 -2
- package/dist/Form/elements/FormGroupLabel.js +2 -2
- package/dist/Form/inputs/Input.d.ts +8 -4
- package/dist/Form/inputs/Radio.d.ts +8 -8
- package/dist/Form/inputs/Select.d.ts +2 -2
- package/dist/Form/inputs/Select.js +6 -5
- package/dist/Form/inputs/TextArea.d.ts +2 -2
- package/dist/Form/styles/Checkbox-styles.d.ts +16 -8
- package/dist/Form/styles/Radio-styles.d.ts +8 -4
- package/dist/Form/styles/shared-system-props.d.ts +12 -7
- package/dist/GridForm/GridFormButtons/index.d.ts +18 -18
- package/dist/GridForm/GridFormInputGroup/__fixtures__/assertions.d.ts +2 -2
- package/dist/GridForm/GridFormSections/GridFormSectionBreak.d.ts +2 -2
- package/dist/HiddenText/index.d.ts +3 -2
- package/dist/InternalFloatingCard/InternalFloatingCard.d.ts +3 -3
- package/dist/Layout/Column.d.ts +4 -3
- package/dist/Layout/LayoutGrid.d.ts +3 -2
- package/dist/List/ListProvider.d.ts +1 -0
- package/dist/List/elements.d.ts +40 -28
- package/dist/List/hooks.d.ts +1 -0
- package/dist/Menu/Menu.d.ts +3 -2
- package/dist/Menu/MenuContext.d.ts +1 -0
- package/dist/Menu/elements.d.ts +11 -11
- package/dist/Modals/elements.d.ts +4 -3
- package/dist/Pagination/AnimatedPaginationButtons.d.ts +37 -3
- package/dist/Pagination/EllipsisButton.d.ts +52 -19
- package/dist/Pagination/PaginationButton.d.ts +30 -30
- package/dist/Pagination/styles.d.ts +4 -4
- package/dist/Pagination/utils.d.ts +5 -5
- package/dist/Popover/Popover.d.ts +1 -0
- package/dist/Popover/elements.d.ts +17 -16
- package/dist/Popover/styles/base.d.ts +2 -2
- package/dist/Popover/styles/beak.d.ts +1 -1
- package/dist/Popover/styles/variants.d.ts +6 -6
- package/dist/Popover/utils.d.ts +1 -1
- package/dist/PopoverContainer/hooks.d.ts +2 -2
- package/dist/PopoverContainer/utils.d.ts +1 -1
- package/dist/SkipToContent/index.d.ts +2 -2
- package/dist/Tabs/TabButton.d.ts +10 -9
- package/dist/Tabs/TabNav.d.ts +3 -2
- package/dist/Tabs/TabNavLink.d.ts +8 -8
- package/dist/Tabs/TabPanels.d.ts +3 -2
- package/dist/Tabs/TabProvider.d.ts +1 -0
- package/dist/Tabs/styles.d.ts +2 -2
- package/dist/Tag/elements.d.ts +42 -41
- package/dist/Tag/styles.d.ts +22 -12
- package/dist/Tip/InfoTip/InfoTipButton.d.ts +20 -20
- package/dist/Tip/InfoTip/index.d.ts +1 -0
- package/dist/Tip/InfoTip/styles.d.ts +11 -8
- package/dist/Tip/PreviewTip/elements.d.ts +17 -16
- package/dist/Tip/PreviewTip/utils.d.ts +1 -1
- package/dist/Tip/ToolTip/elements.d.ts +4 -3
- package/dist/Tip/ToolTip/index.d.ts +1 -0
- package/dist/Tip/__tests__/helpers.d.ts +4 -4
- package/dist/Tip/shared/InlineTip.d.ts +1 -0
- package/dist/Tip/shared/elements.d.ts +20 -19
- package/dist/Tip/shared/styles/composeVariantsUtils.d.ts +2 -2
- package/dist/Tip/shared/styles/styles.d.ts +4 -4
- package/dist/Tip/shared/utils.d.ts +1 -0
- package/dist/Toggle/elements.d.ts +12 -11
- package/dist/Toggle/utils.d.ts +1 -1
- package/dist/Typography/Text.d.ts +9 -8
- package/dist/Video/lib/ReactPlayer.d.ts +3 -2
- package/dist/Video/lib/VideoLayout.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/types.d.ts +1 -0
- package/package.json +8 -7
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _styled from "@emotion/styled/base";
|
|
2
|
+
import { css } from '@codecademy/gamut-styles';
|
|
3
|
+
import { Box } from '../../Box';
|
|
4
|
+
import { barListItemPadding } from '../shared/styles';
|
|
5
|
+
import { useBarChartContext } from '../utils/hooks';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const SpacerContainer = /*#__PURE__*/_styled(Box, {
|
|
8
|
+
target: "e9z677g1",
|
|
9
|
+
label: "SpacerContainer"
|
|
10
|
+
})(css({
|
|
11
|
+
display: 'flex',
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: '100%',
|
|
14
|
+
gap: 0
|
|
15
|
+
}), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9CYXJDaGFydC9sYXlvdXQvTGFiZWxTcGFjZXIudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVF3QiIsImZpbGUiOiIuLi8uLi8uLi9zcmMvQmFyQ2hhcnQvbGF5b3V0L0xhYmVsU3BhY2VyLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0Bjb2RlY2FkZW15L2dhbXV0LXN0eWxlcyc7XG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgeyBSZWFjdE5vZGUgfSBmcm9tICdyZWFjdCc7XG5cbmltcG9ydCB7IEJveCB9IGZyb20gJy4uLy4uL0JveCc7XG5pbXBvcnQgeyBiYXJMaXN0SXRlbVBhZGRpbmcgfSBmcm9tICcuLi9zaGFyZWQvc3R5bGVzJztcbmltcG9ydCB7IHVzZUJhckNoYXJ0Q29udGV4dCB9IGZyb20gJy4uL3V0aWxzL2hvb2tzJztcblxuY29uc3QgU3BhY2VyQ29udGFpbmVyID0gc3R5bGVkKEJveCkoXG4gIGNzcyh7XG4gICAgZGlzcGxheTogJ2ZsZXgnLFxuICAgIHdpZHRoOiAnMTAwJScsXG4gICAgaGVpZ2h0OiAnMTAwJScsXG4gICAgZ2FwOiAwLFxuICB9KVxuKTtcblxuY29uc3QgQ29udGVudEFyZWEgPSBzdHlsZWQoQm94KShcbiAgY3NzKHtcbiAgICBmbGV4OiAxLFxuICAgI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0gKHtcbiAgY2hpbGRyZW4sXG4gIGNsYXNzTmFtZSxcbn0pID0+IHtcbiAgcmV0dXJuIChcbiAgICA8U3BhY2VyQ29udGFpbmVyIGNsYXNzTmFtZT17Y2xhc3NOYW1lfT5cbiAgICAgIDxQcmVMYWJlbFNwYWNlciAvPlxuICAgICAgPENvbnRlbnRBcmVhPntjaGlsZHJlbn08L0NvbnRlbnRBcmVhPlxuICAgICAgPFBvc3RMYWJlbFNwYWNlciAvPlxuICAgIDwvU3BhY2VyQ29udGFpbmVyPlxuICApO1xufTtcbiJdfQ== */");
|
|
16
|
+
const ContentArea = /*#__PURE__*/_styled(Box, {
|
|
17
|
+
target: "e9z677g0",
|
|
18
|
+
label: "ContentArea"
|
|
19
|
+
})(css({
|
|
20
|
+
flex: 1,
|
|
21
|
+
position: 'relative',
|
|
22
|
+
height: '100%'
|
|
23
|
+
}), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9CYXJDaGFydC9sYXlvdXQvTGFiZWxTcGFjZXIudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWlCb0IiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL0JhckNoYXJ0L2xheW91dC9MYWJlbFNwYWNlci50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBjc3MgfSBmcm9tICdAY29kZWNhZGVteS9nYW11dC1zdHlsZXMnO1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgUmVhY3ROb2RlIH0gZnJvbSAncmVhY3QnO1xuXG5pbXBvcnQgeyBCb3ggfSBmcm9tICcuLi8uLi9Cb3gnO1xuaW1wb3J0IHsgYmFyTGlzdEl0ZW1QYWRkaW5nIH0gZnJvbSAnLi4vc2hhcmVkL3N0eWxlcyc7XG5pbXBvcnQgey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4gICAgd2lkZXN0VG90YWxWYWx1ZUxhYmVsV2lkdGggPT09IG51bGxcbiAgICAgID8gJ21pbi1jb250ZW50J1xuICAgICAgOiB3aWRlc3RUb3RhbFZhbHVlTGFiZWxXaWR0aDtcblxuICByZXR1cm4gPEJveCBmbGV4U2hyaW5rPXswfSBtaW5XaWR0aD17d2lkdGh9IG1yPXtiYXJMaXN0SXRlbVBhZGRpbmd9IC8+O1xufTtcblxuZXhwb3J0IGNvbnN0IExhYmVsU3BhY2VyOiBSZWFjdC5GQzxMYWJlbFNwYWNlclByb3BzPiA9ICh7XG4gIGNoaWxkcmVuLFxuICBjbGFzc05hbWUsXG59KSA9PiB7XG4gIHJldHVybiAoXG4gICAgPFNwYWNlckNvbnRhaW5lciBjbGFzc05hbWU9e2NsYXNzTmFtZX0+XG4gICAgICA8UHJlTGFiZWxTcGFjZXIgLz5cbiAgICAgIDxDb250ZW50QXJlYT57Y2hpbGRyZW59PC9Db250ZW50QXJlYT5cbiAgICAgIDxQb3N0TGFiZWxTcGFjZXIgLz5cbiAgICA8L1NwYWNlckNvbnRhaW5lcj5cbiAgKTtcbn07XG4iXX0= */");
|
|
24
|
+
const PreLabelSpacer = () => {
|
|
25
|
+
const {
|
|
26
|
+
widestCategoryLabelWidth
|
|
27
|
+
} = useBarChartContext();
|
|
28
|
+
const width = widestCategoryLabelWidth === null ? 'min-content' : widestCategoryLabelWidth;
|
|
29
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
30
|
+
flexShrink: 0,
|
|
31
|
+
minWidth: width,
|
|
32
|
+
ml: barListItemPadding
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const PostLabelSpacer = () => {
|
|
36
|
+
const {
|
|
37
|
+
widestTotalValueLabelWidth
|
|
38
|
+
} = useBarChartContext();
|
|
39
|
+
const width = widestTotalValueLabelWidth === null ? 'min-content' : widestTotalValueLabelWidth;
|
|
40
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
41
|
+
flexShrink: 0,
|
|
42
|
+
minWidth: width,
|
|
43
|
+
mr: barListItemPadding
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export const LabelSpacer = ({
|
|
47
|
+
children,
|
|
48
|
+
className
|
|
49
|
+
}) => {
|
|
50
|
+
return /*#__PURE__*/_jsxs(SpacerContainer, {
|
|
51
|
+
className: className,
|
|
52
|
+
children: [/*#__PURE__*/_jsx(PreLabelSpacer, {}), /*#__PURE__*/_jsx(ContentArea, {
|
|
53
|
+
children: children
|
|
54
|
+
}), /*#__PURE__*/_jsx(PostLabelSpacer, {})]
|
|
55
|
+
});
|
|
56
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _styled from "@emotion/styled/base";
|
|
2
|
+
import { css } from '@codecademy/gamut-styles';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { Box, FlexBox } from '../../Box';
|
|
5
|
+
import { Text } from '../../Typography';
|
|
6
|
+
import { formatNumberUnitCompact } from '../utils';
|
|
7
|
+
import { useBarChartContext, useLabelPositions } from '../utils/hooks';
|
|
8
|
+
import { LabelSpacer } from './LabelSpacer';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const StyledLabelText = /*#__PURE__*/_styled(Text, {
|
|
11
|
+
target: "e1ssd1i12",
|
|
12
|
+
label: "StyledLabelText"
|
|
13
|
+
})(css({
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
whiteSpace: 'nowrap',
|
|
16
|
+
m: 0,
|
|
17
|
+
p: 0
|
|
18
|
+
}), ({
|
|
19
|
+
positionPercent,
|
|
20
|
+
textAlign
|
|
21
|
+
}) => {
|
|
22
|
+
let transform = '';
|
|
23
|
+
if (textAlign === 'left') {
|
|
24
|
+
transform = 'translateX(0)';
|
|
25
|
+
} else if (textAlign === 'right') {
|
|
26
|
+
transform = 'translateX(-100%)';
|
|
27
|
+
} else {
|
|
28
|
+
transform = 'translateX(-50%)';
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
left: `${positionPercent}%`,
|
|
32
|
+
transform
|
|
33
|
+
};
|
|
34
|
+
}, process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9CYXJDaGFydC9sYXlvdXQvU2NhbGVDaGFydEhlYWRlci50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBV3dCIiwiZmlsZSI6Ii4uLy4uLy4uL3NyYy9CYXJDaGFydC9sYXlvdXQvU2NhbGVDaGFydEhlYWRlci50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBjc3MgfSBmcm9tICdAY29kZWNhZGVteS9nYW11dC1zdHlsZXMnO1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IFJlYWN0LCB7IHVzZU1lbW8gfSBmcm9tICdyZWFjdCc7XG5cbmltcG9ydCB7IEJveCwgRmxleEJveCB9IGZyb20gJy4uLy4uL0JveCc7XG5pbXBvcnQgeyBUZXh0IH0gZnJvbSAnLi4vLi4vVHlwb2dyYXBoeSc7XG5pbXBvcnQgeyBTY2FsZUF4aXNMYXlvdXRQcm9wcyB9IGZyb20gJy4uL3NoYXJlZC90eXBlcyc7XG5pbXBvcnQgeyBmb3JtYXROdW1iZXJVbml0Q29tcGFjdCB9IGZyb20gJy4uL3V0aWxzJztcbmltcG9ydCB7IHVzZUJhckNoYXJ0Q29udGV4dCwgdXNlTGFiZWxQb3NpdGlvbnMgfSBmcm9tICcuLi91dGlscy9ob29rcyc7XG5pbXBvcnQgeyBMYWJlbFNwYWNlciB9IGZyb20gJy4vTGFiZWxTcGFjZXInO1xuXG5jb25zdCBTdHlsZWRMYWJlbFRleHQgPSBzdHlsZWQoVGV4dCk8e1xuICBwb3NpdGlvblBlcmNlbnQ6IG51bWJlcjtcbiAgdGV4dEFsaWduOiAnbGVmd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sQXJlYT57c2NhbGVMYWJlbHN9PC9IZWFkZXJMYWJlbEFyZWE+XG4gICAgICAgIDwvTGFiZWxTcGFjZXI+XG4gICAgICA8L1N0eWxlZEhlYWRlckNvbnRhaW5lcj5cbiAgICA8L0JveD5cbiAgKTtcbn07XG4iXX0= */");
|
|
35
|
+
const StyledHeaderContainer = /*#__PURE__*/_styled(FlexBox, {
|
|
36
|
+
target: "e1ssd1i11",
|
|
37
|
+
label: "StyledHeaderContainer"
|
|
38
|
+
})(css({
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
position: 'relative'
|
|
41
|
+
}), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9CYXJDaGFydC9sYXlvdXQvU2NhbGVDaGFydEhlYWRlci50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBcUM4QiIsImZpbGUiOiIuLi8uLi8uLi9zcmMvQmFyQ2hhcnQvbGF5b3V0L1NjYWxlQ2hhcnRIZWFkZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGNvZGVjYWRlbXkvZ2FtdXQtc3R5bGVzJztcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9ydCBSZWFjdCwgeyB1c2VNZW1vIH0gZnJvbSAncmVhY3QnO1xuXG5pbXBvcnQgeyBCb3gsIEZsZXhCb3ggfSBmcm9tICcuLi8uLi9Cb3gnO1xuaW1wb3J0IHsgVGV4dCB9IGZyb20gJy4uLy4uL1R5cG9ncmFwaHknO1xuaW1wb3J0IHsgU2NhbGVBeGlzTGF5b3V0UHJvcHMgfSBmcm9tICcuLi9zaGFyZWQvdHlwZXMnO1xuaW1wb3J0IHsgZm9ybWF0TnVtYmVyVW5pdENvbXBhY3QgfSBmcm9tICcuLi91dGlscyc7X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MubG9jYWxlXVxuICApO1xuXG4gIHJldHVybiAoXG4gICAgPEJveCBtYj17MTJ9IHdpZHRoPXsxfT5cbiAgICAgIDxTdHlsZWRIZWFkZXJDb250YWluZXJcbiAgICAgICAgYXJpYS1oaWRkZW49XCJ0cnVlXCJcbiAgICAgICAgZGlzcGxheT17eyBfOiAnbm9uZScsIGNfeHM6ICdibG9jaycgfX1cbiAgICAgID5cbiAgICAgICAgPExhYmVsU3BhY2VyPlxuICAgICAgICAgIDxIZWFkZXJMYWJlbEFyZWE+e3NjYWxlTGFiZWxzfTwvSGVhZGVyTGFiZWxBcmVhPlxuICAgICAgICA8L0xhYmVsU3BhY2VyPlxuICAgICAgPC9TdHlsZWRIZWFkZXJDb250YWluZXI+XG4gICAgPC9Cb3g+XG4gICk7XG59O1xuIl19 */");
|
|
42
|
+
const HeaderLabelArea = /*#__PURE__*/_styled(Box, {
|
|
43
|
+
target: "e1ssd1i10",
|
|
44
|
+
label: "HeaderLabelArea"
|
|
45
|
+
})(css({
|
|
46
|
+
minHeight: '24px'
|
|
47
|
+
}), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9CYXJDaGFydC9sYXlvdXQvU2NhbGVDaGFydEhlYWRlci50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBNEN3QiIsImZpbGUiOiIuLi8uLi8uLi9zcmMvQmFyQ2hhcnQvbGF5b3V0L1NjYWxlQ2hhcnRIZWFkZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGNvZGVjYWRlbXkvZ2FtdXQtc3R5bGVzJztcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9ydCBSZWFjdCwgeyB1c2VNZW1vIH0gZnJvbSAncmVhY3QnO1xuXG5pbXBvcnQge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AgICAgICA+XG4gICAgICAgICAge2Zvcm1hdE51bWJlclVuaXRDb21wYWN0KHtcbiAgICAgICAgICAgIG51bTogdmFsdWUsXG4gICAgICAgICAgICBsb2NhbGU6IHRyYW5zbGF0aW9ucy5sb2NhbGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgIDwvU3R5bGVkTGFiZWxUZXh0PlxuICAgICAgKSksXG4gICAgW2xhYmVsUG9zaXRpb25zLCB0cmFuc2xhdGlvbnMubG9jYWxlXVxuICApO1xuXG4gIHJldHVybiAoXG4gICAgPEJveCBtYj17MTJ9IHdpZHRoPXsxfT5cbiAgICAgIDxTdHlsZWRIZWFkZXJDb250YWluZXJcbiAgICAgICAgYXJpYS1oaWRkZW49XCJ0cnVlXCJcbiAgICAgICAgZGlzcGxheT17eyBfOiAnbm9uZScsIGNfeHM6ICdibG9jaycgfX1cbiAgICAgID5cbiAgICAgICAgPExhYmVsU3BhY2VyPlxuICAgICAgICAgIDxIZWFkZXJMYWJlbEFyZWE+e3NjYWxlTGFiZWxzfTwvSGVhZGVyTGFiZWxBcmVhPlxuICAgICAgICA8L0xhYmVsU3BhY2VyPlxuICAgICAgPC9TdHlsZWRIZWFkZXJDb250YWluZXI+XG4gICAgPC9Cb3g+XG4gICk7XG59O1xuIl19 */");
|
|
48
|
+
export const ScaleChartHeader = ({
|
|
49
|
+
maxScaleValue,
|
|
50
|
+
tickCount
|
|
51
|
+
}) => {
|
|
52
|
+
const {
|
|
53
|
+
translations
|
|
54
|
+
} = useBarChartContext();
|
|
55
|
+
const labelPositions = useLabelPositions({
|
|
56
|
+
maxScaleValue,
|
|
57
|
+
tickCount
|
|
58
|
+
});
|
|
59
|
+
const scaleLabels = useMemo(() => labelPositions.map(({
|
|
60
|
+
value,
|
|
61
|
+
positionPercent
|
|
62
|
+
}) => /*#__PURE__*/_jsx(StyledLabelText, {
|
|
63
|
+
positionPercent: positionPercent,
|
|
64
|
+
textAlign: "center",
|
|
65
|
+
variant: "p-small",
|
|
66
|
+
children: formatNumberUnitCompact({
|
|
67
|
+
num: value,
|
|
68
|
+
locale: translations.locale
|
|
69
|
+
})
|
|
70
|
+
}, `label-${value}-${positionPercent}`)), [labelPositions, translations.locale]);
|
|
71
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
72
|
+
mb: 12,
|
|
73
|
+
width: 1,
|
|
74
|
+
children: /*#__PURE__*/_jsx(StyledHeaderContainer, {
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
display: {
|
|
77
|
+
_: 'none',
|
|
78
|
+
c_xs: 'block'
|
|
79
|
+
},
|
|
80
|
+
children: /*#__PURE__*/_jsx(LabelSpacer, {
|
|
81
|
+
children: /*#__PURE__*/_jsx(HeaderLabelArea, {
|
|
82
|
+
children: scaleLabels
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const BarsList: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
7
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _styled from "@emotion/styled/base";
|
|
2
|
+
import { css } from '@codecademy/gamut-styles';
|
|
3
|
+
export const BarsList = /*#__PURE__*/_styled('ul', {
|
|
4
|
+
target: "ey0wy1t0",
|
|
5
|
+
label: "BarsList"
|
|
6
|
+
})(css({
|
|
7
|
+
p: 0,
|
|
8
|
+
listStyle: 'none',
|
|
9
|
+
'& li:nth-of-type(even)': {
|
|
10
|
+
bg: 'background-selected'
|
|
11
|
+
}
|
|
12
|
+
}), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9CYXJDaGFydC9zaGFyZWQvZWxlbWVudHMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUd3QiIsImZpbGUiOiIuLi8uLi8uLi9zcmMvQmFyQ2hhcnQvc2hhcmVkL2VsZW1lbnRzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0Bjb2RlY2FkZW15L2dhbXV0LXN0eWxlcyc7XG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5cbmV4cG9ydCBjb25zdCBCYXJzTGlzdCA9IHN0eWxlZCgndWwnKShcbiAgY3NzKHtcbiAgICBwOiAwLFxuICAgIGxpc3RTdHlsZTogJ25vbmUnLFxuICAgICcmIGxpOm50aC1vZi10eXBlKGV2ZW4pJzoge1xuICAgICAgYmc6ICdiYWNrZ3JvdW5kLXNlbGVjdGVkJyxcbiAgICB9LFxuICB9KVxuKTtcbiJdfQ== */");
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Shared context fields for accessibility summary functions. */
|
|
2
|
+
type BarChartSummaryContextBase = {
|
|
3
|
+
unit: string;
|
|
4
|
+
locale: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Context passed to the stacked-bar summary function (stackedBarSummary).
|
|
8
|
+
* Used for rows that have seriesTwoValue (two values per row).
|
|
9
|
+
*/
|
|
10
|
+
export type BarChartStackedSummaryContext = BarChartSummaryContextBase & {
|
|
11
|
+
categoryLabel: string;
|
|
12
|
+
seriesOneValue: number;
|
|
13
|
+
seriesTwoValue: number;
|
|
14
|
+
/** Precomputed: seriesTwoValue - seriesOneValue. Use in the summary string (e.g. "50 XP gained - now at 150 XP"). */
|
|
15
|
+
gained: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Context passed to the single-value bar summary function (singleValueBarSummary).
|
|
19
|
+
* Used for all single-bar rows (no seriesTwoValue). The component uses the returned string as aria-label (when row is link/button) or screenreader-only text (when row is a div).
|
|
20
|
+
*/
|
|
21
|
+
export type BarChartSingleValueBarSummaryContext = BarChartSummaryContextBase & {
|
|
22
|
+
categoryLabel: string;
|
|
23
|
+
value: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* BarChart translation configuration for internationalization.
|
|
27
|
+
*
|
|
28
|
+
* **accessibility** is function-only. Two optional summary functions; when omitted, default English summaries are used.
|
|
29
|
+
* - **stackedBarSummary**: Used for stacked (two-value) rows. Context includes `gained` (seriesTwoValue - seriesOneValue).
|
|
30
|
+
* - **singleValueBarSummary**: Used for all single-value rows. Return value is placed as aria-label (when row is link/button) or screenreader-only text (when not).
|
|
31
|
+
*
|
|
32
|
+
* **sortLabel**, **sortOptions**, and **locale** are always strings.
|
|
33
|
+
*/
|
|
34
|
+
export type BarChartTranslations = {
|
|
35
|
+
sortLabel: string;
|
|
36
|
+
sortOptions: {
|
|
37
|
+
none: string;
|
|
38
|
+
labelAsc: string;
|
|
39
|
+
labelDesc: string;
|
|
40
|
+
valueAsc: string;
|
|
41
|
+
valueDesc: string;
|
|
42
|
+
};
|
|
43
|
+
accessibility: {
|
|
44
|
+
/** Used for stacked (two-value) rows. Context includes `gained` for the numeric difference. */
|
|
45
|
+
stackedBarSummary?: (ctx: BarChartStackedSummaryContext) => string;
|
|
46
|
+
/** Used for all single-value rows. Same return value is placed as aria-label (when row is link/button) or screenreader-only text (when not). */
|
|
47
|
+
singleValueBarSummary?: (ctx: BarChartSingleValueBarSummaryContext) => string;
|
|
48
|
+
};
|
|
49
|
+
/** For Intl.NumberFormat (e.g. 'en', 'es', 'fr'). */
|
|
50
|
+
locale: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Partial translations for BarChart. Nested `accessibility` and `sortOptions` may
|
|
54
|
+
* override individual keys; they are merged with defaults at runtime.
|
|
55
|
+
*/
|
|
56
|
+
export type PartialBarChartTranslations = Partial<Omit<BarChartTranslations, 'accessibility' | 'sortOptions'>> & {
|
|
57
|
+
sortOptions?: Partial<BarChartTranslations['sortOptions']>;
|
|
58
|
+
accessibility?: Partial<BarChartTranslations['accessibility']>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Default stacked-bar summary (English).
|
|
62
|
+
*/
|
|
63
|
+
export declare const getDefaultStackedBarSummary: (ctx: BarChartStackedSummaryContext) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Default single-value bar summary (English).
|
|
66
|
+
*/
|
|
67
|
+
export declare const getDefaultSingleValueBarSummary: (ctx: BarChartSingleValueBarSummaryContext) => string;
|
|
68
|
+
export declare const defaultBarChartTranslations: BarChartTranslations;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Shared context fields for accessibility summary functions. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Context passed to the stacked-bar summary function (stackedBarSummary).
|
|
5
|
+
* Used for rows that have seriesTwoValue (two values per row).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Context passed to the single-value bar summary function (singleValueBarSummary).
|
|
10
|
+
* Used for all single-bar rows (no seriesTwoValue). The component uses the returned string as aria-label (when row is link/button) or screenreader-only text (when row is a div).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* BarChart translation configuration for internationalization.
|
|
15
|
+
*
|
|
16
|
+
* **accessibility** is function-only. Two optional summary functions; when omitted, default English summaries are used.
|
|
17
|
+
* - **stackedBarSummary**: Used for stacked (two-value) rows. Context includes `gained` (seriesTwoValue - seriesOneValue).
|
|
18
|
+
* - **singleValueBarSummary**: Used for all single-value rows. Return value is placed as aria-label (when row is link/button) or screenreader-only text (when not).
|
|
19
|
+
*
|
|
20
|
+
* **sortLabel**, **sortOptions**, and **locale** are always strings.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Partial translations for BarChart. Nested `accessibility` and `sortOptions` may
|
|
25
|
+
* override individual keys; they are merged with defaults at runtime.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Default stacked-bar summary (English).
|
|
30
|
+
*/
|
|
31
|
+
export const getDefaultStackedBarSummary = ctx => {
|
|
32
|
+
const unitText = ctx.unit ? ` ${ctx.unit}` : '';
|
|
33
|
+
return `Starting value - ${ctx.seriesOneValue}${unitText}. ${ctx.gained}${unitText} gained - now at ${ctx.seriesTwoValue}${unitText} in ${ctx.categoryLabel}`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Default single-value bar summary (English).
|
|
38
|
+
*/
|
|
39
|
+
export const getDefaultSingleValueBarSummary = ctx => {
|
|
40
|
+
const unitText = ctx.unit ? ` ${ctx.unit}` : '';
|
|
41
|
+
return `${ctx.value}${unitText} in ${ctx.categoryLabel}`;
|
|
42
|
+
};
|
|
43
|
+
export const defaultBarChartTranslations = {
|
|
44
|
+
sortLabel: 'Order by:',
|
|
45
|
+
sortOptions: {
|
|
46
|
+
none: 'None',
|
|
47
|
+
labelAsc: 'Label (A-Z)',
|
|
48
|
+
labelDesc: 'Label (Z-A)',
|
|
49
|
+
valueAsc: 'Value (Low-High)',
|
|
50
|
+
valueDesc: 'Value (High-Low)'
|
|
51
|
+
},
|
|
52
|
+
accessibility: {
|
|
53
|
+
stackedBarSummary: getDefaultStackedBarSummary,
|
|
54
|
+
singleValueBarSummary: getDefaultSingleValueBarSummary
|
|
55
|
+
},
|
|
56
|
+
locale: 'en'
|
|
57
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { GamutIconProps } from '@codecademy/gamut-icons';
|
|
2
|
+
import { ColorAlias } from '@codecademy/gamut-styles';
|
|
3
|
+
import { ComponentProps, HTMLProps } from 'react';
|
|
4
|
+
import { ButtonProps } from '../../Button';
|
|
5
|
+
import { Text } from '../../Typography/Text';
|
|
6
|
+
import { HeadingTags } from '../../Typography/types';
|
|
7
|
+
import { CustomSortOption } from '../utils/hooks';
|
|
8
|
+
import { PartialBarChartTranslations } from './translations';
|
|
9
|
+
type titleType = string | {
|
|
10
|
+
as?: HeadingTags;
|
|
11
|
+
title: string;
|
|
12
|
+
variant?: ComponentProps<typeof Text>['variant'];
|
|
13
|
+
};
|
|
14
|
+
type BarChartAriaLabel = {
|
|
15
|
+
title: titleType;
|
|
16
|
+
'aria-labelledby'?: never;
|
|
17
|
+
hideTitle?: boolean;
|
|
18
|
+
};
|
|
19
|
+
type BarChartAriaLabelledBy = {
|
|
20
|
+
'aria-labelledby': string;
|
|
21
|
+
hideTitle?: true;
|
|
22
|
+
title?: never;
|
|
23
|
+
};
|
|
24
|
+
type BarChartLabel = BarChartAriaLabel | BarChartAriaLabelledBy;
|
|
25
|
+
/** Props for components that lay out the scale axis (header labels or grid lines) */
|
|
26
|
+
export type ScaleAxisLayoutProps = {
|
|
27
|
+
maxScaleValue: number;
|
|
28
|
+
tickCount: number;
|
|
29
|
+
};
|
|
30
|
+
/** Maximum value for the value scale (min is always 0) */
|
|
31
|
+
export type MaxScaleValue = ScaleAxisLayoutProps['maxScaleValue'];
|
|
32
|
+
/** Number of labels/ticks on the scale axis. Must be at least 1. */
|
|
33
|
+
export type ScaleTickCount = ScaleAxisLayoutProps['tickCount'];
|
|
34
|
+
export type BarChartStyles = {
|
|
35
|
+
/** Color for text labels. Defaults to 'text' */
|
|
36
|
+
textColor?: ColorAlias;
|
|
37
|
+
/** Color for the series one bar (seriesOneValue: overlay in stacked charts, only bar in simple charts). Defaults to 'text' */
|
|
38
|
+
seriesOneBarColor?: ColorAlias;
|
|
39
|
+
/** Color for the series two bar (seriesTwoValue: full bar in stacked charts; unused in simple). Defaults to 'primary' */
|
|
40
|
+
seriesTwoBarColor?: ColorAlias;
|
|
41
|
+
/** Color for the series one label (first total value label when stacked, or displayValue when not stacked). Defaults to 'text-secondary' */
|
|
42
|
+
seriesOneLabel?: ColorAlias;
|
|
43
|
+
/** Color for the series two label (displayValue when stacked). Defaults to 'primary' */
|
|
44
|
+
seriesTwoLabel?: ColorAlias;
|
|
45
|
+
};
|
|
46
|
+
type BarPropsBase = {
|
|
47
|
+
/** Label displayed for this category (e.g. on the y-axis) */
|
|
48
|
+
categoryLabel: string;
|
|
49
|
+
/** The foreground/progress bar value (always shown) */
|
|
50
|
+
seriesOneValue: number;
|
|
51
|
+
/** The background/total bar value (optional - creates stacked effect when provided) */
|
|
52
|
+
seriesTwoValue?: number;
|
|
53
|
+
/** Optional gamut-icon to display next to the label */
|
|
54
|
+
icon?: React.ComponentType<GamutIconProps>;
|
|
55
|
+
};
|
|
56
|
+
type BarPropsWithoutInteraction = BarPropsBase & {
|
|
57
|
+
onClick?: never;
|
|
58
|
+
href?: never;
|
|
59
|
+
};
|
|
60
|
+
type BarPropsWithInteraction = BarPropsBase & {
|
|
61
|
+
onClick?: ButtonProps['onClick'];
|
|
62
|
+
href?: HTMLProps<HTMLAnchorElement>['href'];
|
|
63
|
+
};
|
|
64
|
+
export type BarProps = BarPropsWithoutInteraction | BarPropsWithInteraction;
|
|
65
|
+
/**
|
|
66
|
+
* Helper type that extracts the element type from an array of bars.
|
|
67
|
+
* Handles both mutable and readonly arrays.
|
|
68
|
+
*/
|
|
69
|
+
export type InferBarType<T> = T extends readonly (infer U)[] ? U extends BarProps ? U : BarProps : T extends (infer U)[] ? U extends BarProps ? U : BarProps : BarProps;
|
|
70
|
+
export type BarChartProps<TBarValues extends BarProps[] | readonly BarProps[] = BarProps[]> = BarChartLabel & {
|
|
71
|
+
/** Whether to animate bars on mount */
|
|
72
|
+
animate?: boolean;
|
|
73
|
+
/** Array of bar data to render */
|
|
74
|
+
barValues: TBarValues;
|
|
75
|
+
/** Figure caption for the BarChart. This should be a summary of the information or the overall takeaway of the information in the chart */
|
|
76
|
+
description: string;
|
|
77
|
+
/** Hides the visual figcaption */
|
|
78
|
+
hideDescription?: boolean;
|
|
79
|
+
/** Hides the visual title for the chart UL */
|
|
80
|
+
hideTitle?: boolean;
|
|
81
|
+
/** Maximum value for the value scale */
|
|
82
|
+
maxScaleValue: MaxScaleValue;
|
|
83
|
+
/** Unit label to display (e.g., "XP") */
|
|
84
|
+
unit?: string;
|
|
85
|
+
/** Style configuration for colors */
|
|
86
|
+
styleConfig?: BarChartStyles;
|
|
87
|
+
/** Interval for the value scale markers */
|
|
88
|
+
scaleInterval?: number;
|
|
89
|
+
/** Array of sort options to display in the dropdown. Can include string literals ('alphabetically', 'numerically', 'none') or custom sort functions. If not provided, the Select dropdown will not render. */
|
|
90
|
+
sortFns?: ('alphabetically' | 'numerically' | 'none' | CustomSortOption<InferBarType<TBarValues>>)[];
|
|
91
|
+
/**
|
|
92
|
+
* Translations for internationalization. Partial translations are merged with defaults.
|
|
93
|
+
* Accessibility is function-only. Two optional keys: stackedBarSummary, singleValueBarSummary.
|
|
94
|
+
* stackedBarSummary: used for stacked (two-value) rows; context includes gained (seriesTwoValue - seriesOneValue).
|
|
95
|
+
* singleValueBarSummary: used for all single-value rows; the returned string is set as aria-label on the row's link/button when interactive, or rendered in screenreader-only text when not.
|
|
96
|
+
*/
|
|
97
|
+
translations?: PartialBarChartTranslations;
|
|
98
|
+
};
|
|
99
|
+
export type BarChartUnit = Pick<BarChartProps, 'unit'>;
|
|
100
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Colors } from '@codecademy/gamut-styles';
|
|
3
|
+
import { SelectOptions } from '../../Form/inputs/Select';
|
|
4
|
+
import { BarChartContextProps } from '../BarChartProvider';
|
|
5
|
+
import { BarChartTranslations } from '../shared/translations';
|
|
6
|
+
import { BarChartStyles, BarProps, InferBarType, MaxScaleValue, ScaleTickCount } from '../shared/types';
|
|
7
|
+
export interface LabelPosition {
|
|
8
|
+
value: number;
|
|
9
|
+
positionPercent: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook that calculates label positions for a given maxScaleValue and tickCount (scale min is always 0).
|
|
13
|
+
* Returns an array of { value, positionPercent } objects.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useLabelPositions: ({ maxScaleValue, tickCount, }: {
|
|
16
|
+
maxScaleValue: MaxScaleValue;
|
|
17
|
+
tickCount: ScaleTickCount;
|
|
18
|
+
}) => LabelPosition[];
|
|
19
|
+
export declare const useBarChartContext: () => BarChartContextProps;
|
|
20
|
+
export interface UseBarChartOptions {
|
|
21
|
+
maxScaleValue: MaxScaleValue;
|
|
22
|
+
scaleInterval?: number;
|
|
23
|
+
unit?: string;
|
|
24
|
+
styleConfig?: BarChartStyles;
|
|
25
|
+
animate?: boolean;
|
|
26
|
+
barCount?: number;
|
|
27
|
+
translations: BarChartTranslations;
|
|
28
|
+
}
|
|
29
|
+
export declare const useBarChart: ({ maxScaleValue, scaleInterval, unit, styleConfig, animate, barCount, translations, }: UseBarChartOptions) => {
|
|
30
|
+
maxScaleValue: number;
|
|
31
|
+
scaleInterval: number;
|
|
32
|
+
unit: string;
|
|
33
|
+
styleConfig: {
|
|
34
|
+
textColor: "text" | "background" | "primary" | "secondary" | "danger" | "interface" | "text-secondary" | "text-accent" | "text-disabled" | "feedback-error" | "feedback-success" | "feedback-warning" | "background-primary" | "background-disabled" | "background-error" | "background-success" | "background-warning" | "background-contrast" | "background-current" | "background-selected" | "background-hover" | "shadow-primary" | "shadow-secondary" | "primary-hover" | "primary-inverse" | "secondary-hover" | "danger-hover" | "interface-hover" | "border-primary" | "border-secondary" | "border-disabled" | "border-tertiary";
|
|
35
|
+
seriesOneBarColor: "text" | "background" | "primary" | "secondary" | "danger" | "interface" | "text-secondary" | "text-accent" | "text-disabled" | "feedback-error" | "feedback-success" | "feedback-warning" | "background-primary" | "background-disabled" | "background-error" | "background-success" | "background-warning" | "background-contrast" | "background-current" | "background-selected" | "background-hover" | "shadow-primary" | "shadow-secondary" | "primary-hover" | "primary-inverse" | "secondary-hover" | "danger-hover" | "interface-hover" | "border-primary" | "border-secondary" | "border-disabled" | "border-tertiary";
|
|
36
|
+
seriesTwoBarColor: "text" | "background" | "primary" | "secondary" | "danger" | "interface" | "text-secondary" | "text-accent" | "text-disabled" | "feedback-error" | "feedback-success" | "feedback-warning" | "background-primary" | "background-disabled" | "background-error" | "background-success" | "background-warning" | "background-contrast" | "background-current" | "background-selected" | "background-hover" | "shadow-primary" | "shadow-secondary" | "primary-hover" | "primary-inverse" | "secondary-hover" | "danger-hover" | "interface-hover" | "border-primary" | "border-secondary" | "border-disabled" | "border-tertiary";
|
|
37
|
+
seriesOneLabel: "text" | "background" | "primary" | "secondary" | "danger" | "interface" | "text-secondary" | "text-accent" | "text-disabled" | "feedback-error" | "feedback-success" | "feedback-warning" | "background-primary" | "background-disabled" | "background-error" | "background-success" | "background-warning" | "background-contrast" | "background-current" | "background-selected" | "background-hover" | "shadow-primary" | "shadow-secondary" | "primary-hover" | "primary-inverse" | "secondary-hover" | "danger-hover" | "interface-hover" | "border-primary" | "border-secondary" | "border-disabled" | "border-tertiary";
|
|
38
|
+
seriesTwoLabel: "text" | "background" | "primary" | "secondary" | "danger" | "interface" | "text-secondary" | "text-accent" | "text-disabled" | "feedback-error" | "feedback-success" | "feedback-warning" | "background-primary" | "background-disabled" | "background-error" | "background-success" | "background-warning" | "background-contrast" | "background-current" | "background-selected" | "background-hover" | "shadow-primary" | "shadow-secondary" | "primary-hover" | "primary-inverse" | "secondary-hover" | "danger-hover" | "interface-hover" | "border-primary" | "border-secondary" | "border-disabled" | "border-tertiary";
|
|
39
|
+
};
|
|
40
|
+
animate: boolean;
|
|
41
|
+
widestCategoryLabelWidth: number | null;
|
|
42
|
+
setWidestCategoryLabelWidth: (width: number) => void;
|
|
43
|
+
widestTotalValueLabelWidth: number | null;
|
|
44
|
+
setWidestTotalValueLabelWidth: (width: number) => void;
|
|
45
|
+
isMeasuring: boolean;
|
|
46
|
+
translations: BarChartTranslations;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Hook that returns a function to get the highest contrast border color
|
|
50
|
+
* (white or navy-900) for a given background color.
|
|
51
|
+
*
|
|
52
|
+
* Similar to the Background component, this resolves color aliases and
|
|
53
|
+
* compares contrast ratios to determine the best border color.
|
|
54
|
+
*
|
|
55
|
+
* @returns A function that takes a background color and returns either 'white' or 'navy-900'
|
|
56
|
+
*/
|
|
57
|
+
export declare const useBarBorderColor: () => (bg: Colors) => 'white' | 'navy-900';
|
|
58
|
+
export declare const useMeasureCategoryLabelWidth: ({ ref, }: {
|
|
59
|
+
ref: React.RefObject<HTMLElement>;
|
|
60
|
+
}) => void;
|
|
61
|
+
export declare const useMeasureTotalValueLabelWidth: ({ ref, }: {
|
|
62
|
+
ref: React.RefObject<HTMLElement>;
|
|
63
|
+
}) => void;
|
|
64
|
+
export interface CustomSortOption<TBar extends BarProps = BarProps> {
|
|
65
|
+
label: string;
|
|
66
|
+
value: string;
|
|
67
|
+
sortFn: (bars: TBar[]) => TBar[];
|
|
68
|
+
}
|
|
69
|
+
export interface UseBarChartSortOptions<TBarValues extends BarProps[] | readonly BarProps[] = BarProps[]> {
|
|
70
|
+
bars: TBarValues;
|
|
71
|
+
sortFns?: ('alphabetically' | 'numerically' | 'none' | CustomSortOption<InferBarType<TBarValues>>)[];
|
|
72
|
+
translations: BarChartTranslations;
|
|
73
|
+
}
|
|
74
|
+
export interface UseBarChartSortReturn<TBarValues extends BarProps[] | readonly BarProps[] = BarProps[]> {
|
|
75
|
+
sortedBars: TBarValues;
|
|
76
|
+
sortValue: string;
|
|
77
|
+
onSortChange: (value: string) => void;
|
|
78
|
+
selectProps: {
|
|
79
|
+
options: SelectOptions;
|
|
80
|
+
value: string;
|
|
81
|
+
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
82
|
+
} | null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Hook that manages bar sorting state and provides memoized sorted bars.
|
|
86
|
+
* Supports predefined sort options (via string literals) and custom sort functions.
|
|
87
|
+
* Only returns selectProps if sortFns is provided.
|
|
88
|
+
*/
|
|
89
|
+
export declare const useBarChartSort: <TBarValues extends BarProps[] | readonly BarProps[] = BarProps[]>({ bars, sortFns, translations, }: UseBarChartSortOptions<TBarValues>) => UseBarChartSortReturn<TBarValues>;
|