@telus-uds/components-base 1.8.3 → 1.9.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/CHANGELOG.md +37 -2
- package/component-docs.json +17 -1
- package/lib/ActivityIndicator/Spinner.js +7 -7
- package/lib/ActivityIndicator/Spinner.native.js +2 -2
- package/lib/Button/ButtonBase.js +2 -2
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Card/Card.js +9 -4
- package/lib/Checkbox/Checkbox.js +5 -3
- package/lib/Checkbox/CheckboxGroup.js +2 -2
- package/lib/Divider/Divider.js +2 -2
- package/lib/ExpandCollapse/Panel.js +12 -18
- package/lib/FlexGrid/Col/Col.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/Link/InlinePressable.js +5 -1
- package/lib/Link/LinkBase.js +5 -2
- package/lib/List/List.js +8 -2
- package/lib/Pagination/PageButton.js +2 -2
- package/lib/Pagination/Pagination.js +5 -3
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/ProgressBar.js +3 -3
- package/lib/Progress/ProgressBarBackground.js +3 -3
- package/lib/Radio/Radio.js +2 -2
- package/lib/Radio/RadioGroup.js +2 -2
- package/lib/RadioCard/RadioCard.js +1 -1
- package/lib/RadioCard/RadioCardGroup.js +2 -2
- package/lib/Search/Search.js +1 -1
- package/lib/SideNav/SideNav.js +2 -2
- package/lib/Skeleton/Skeleton.js +1 -1
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/StackView/StackWrap.js +3 -1
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/Tabs/Tabs.js +28 -3
- package/lib/Tabs/TabsItem.js +5 -6
- package/lib/Tags/Tags.js +1 -1
- package/lib/TextInput/TextInput.js +0 -11
- package/lib/TextInput/TextInputBase.js +9 -0
- package/lib/TextInput/propTypes.js +3 -8
- package/lib/ThemeProvider/utils/styles.js +2 -2
- package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
- package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib/Tooltip/Backdrop.js +2 -10
- package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
- package/lib/utils/children.js +2 -2
- package/lib/utils/input.js +6 -12
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/textInputProps.js +8 -1
- package/lib/utils/props/tokens.js +2 -2
- package/lib/utils/useSpacingScale.js +3 -1
- package/lib/utils/useUniqueId.js +1 -1
- package/lib-module/A11yInfoProvider/index.js +63 -0
- package/lib-module/A11yText/index.js +56 -0
- package/lib-module/ActivityIndicator/Spinner.js +77 -0
- package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
- package/lib-module/ActivityIndicator/index.js +41 -0
- package/lib-module/ActivityIndicator/shared.js +12 -0
- package/lib-module/BaseProvider/index.js +29 -0
- package/lib-module/Box/Box.js +244 -0
- package/lib-module/Box/index.js +2 -0
- package/lib-module/Button/Button.js +26 -0
- package/lib-module/Button/ButtonBase.js +271 -0
- package/lib-module/Button/ButtonGroup.js +247 -0
- package/lib-module/Button/ButtonLink.js +40 -0
- package/lib-module/Button/index.js +4 -0
- package/lib-module/Button/propTypes.js +36 -0
- package/lib-module/Card/Card.js +85 -0
- package/lib-module/Card/CardBase.js +66 -0
- package/lib-module/Card/PressableCardBase.js +114 -0
- package/lib-module/Card/index.js +4 -0
- package/lib-module/Checkbox/Checkbox.js +348 -0
- package/lib-module/Checkbox/CheckboxGroup.js +233 -0
- package/lib-module/Checkbox/CheckboxInput.js +60 -0
- package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
- package/lib-module/Checkbox/index.js +3 -0
- package/lib-module/Divider/Divider.js +124 -0
- package/lib-module/Divider/index.js +2 -0
- package/lib-module/ExpandCollapse/Accordion.js +15 -0
- package/lib-module/ExpandCollapse/Control.js +136 -0
- package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
- package/lib-module/ExpandCollapse/Panel.js +159 -0
- package/lib-module/ExpandCollapse/index.js +7 -0
- package/lib-module/Feedback/Feedback.js +157 -0
- package/lib-module/Feedback/index.js +2 -0
- package/lib-module/Fieldset/Fieldset.js +153 -0
- package/lib-module/Fieldset/FieldsetContainer.js +32 -0
- package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
- package/lib-module/Fieldset/Legend.js +24 -0
- package/lib-module/Fieldset/Legend.native.js +31 -0
- package/lib-module/Fieldset/cssReset.js +14 -0
- package/lib-module/Fieldset/index.js +2 -0
- package/lib-module/FlexGrid/Col/Col.js +276 -0
- package/lib-module/FlexGrid/Col/index.js +2 -0
- package/lib-module/FlexGrid/FlexGrid.js +148 -0
- package/lib-module/FlexGrid/Row/Row.js +184 -0
- package/lib-module/FlexGrid/Row/index.js +2 -0
- package/lib-module/FlexGrid/helpers/index.js +18 -0
- package/lib-module/FlexGrid/index.js +2 -0
- package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
- package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
- package/lib-module/HorizontalScroll/dictionary.js +11 -0
- package/lib-module/HorizontalScroll/index.js +11 -0
- package/lib-module/HorizontalScroll/itemPositions.js +112 -0
- package/lib-module/Icon/Icon.js +62 -0
- package/lib-module/Icon/IconText.js +83 -0
- package/lib-module/Icon/index.js +4 -0
- package/lib-module/IconButton/IconButton.js +122 -0
- package/lib-module/IconButton/index.js +2 -0
- package/lib-module/InputLabel/InputLabel.js +148 -0
- package/lib-module/InputLabel/LabelContent.js +27 -0
- package/lib-module/InputLabel/LabelContent.native.js +19 -0
- package/lib-module/InputLabel/index.js +2 -0
- package/lib-module/InputSupports/InputSupports.js +96 -0
- package/lib-module/InputSupports/index.js +2 -0
- package/lib-module/InputSupports/useInputSupports.js +32 -0
- package/lib-module/Link/ChevronLink.js +52 -0
- package/lib-module/Link/InlinePressable.js +44 -0
- package/lib-module/Link/InlinePressable.native.js +89 -0
- package/lib-module/Link/Link.js +28 -0
- package/lib-module/Link/LinkBase.js +243 -0
- package/lib-module/Link/TextButton.js +35 -0
- package/lib-module/Link/index.js +5 -0
- package/lib-module/List/List.js +62 -0
- package/lib-module/List/ListItem.js +248 -0
- package/lib-module/List/index.js +5 -0
- package/lib-module/Modal/Modal.js +222 -0
- package/lib-module/Modal/dictionary.js +9 -0
- package/lib-module/Modal/index.js +2 -0
- package/lib-module/Notification/Notification.js +209 -0
- package/lib-module/Notification/dictionary.js +8 -0
- package/lib-module/Notification/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +66 -0
- package/lib-module/Pagination/Pagination.js +153 -0
- package/lib-module/Pagination/SideButton.js +106 -0
- package/lib-module/Pagination/dictionary.js +18 -0
- package/lib-module/Pagination/index.js +2 -0
- package/lib-module/Pagination/usePagination.js +73 -0
- package/lib-module/Progress/Progress.js +89 -0
- package/lib-module/Progress/ProgressBar.js +138 -0
- package/lib-module/Progress/ProgressBarBackground.js +42 -0
- package/lib-module/Progress/index.js +4 -0
- package/lib-module/Radio/Radio.js +285 -0
- package/lib-module/Radio/RadioButton.js +138 -0
- package/lib-module/Radio/RadioGroup.js +243 -0
- package/lib-module/Radio/RadioInput.js +62 -0
- package/lib-module/Radio/RadioInput.native.js +6 -0
- package/lib-module/Radio/index.js +3 -0
- package/lib-module/RadioCard/RadioCard.js +219 -0
- package/lib-module/RadioCard/RadioCardGroup.js +250 -0
- package/lib-module/RadioCard/index.js +3 -0
- package/lib-module/Search/Search.js +261 -0
- package/lib-module/Search/dictionary.js +12 -0
- package/lib-module/Search/index.js +2 -0
- package/lib-module/Select/Group.js +21 -0
- package/lib-module/Select/Group.native.js +15 -0
- package/lib-module/Select/Item.js +20 -0
- package/lib-module/Select/Item.native.js +3 -0
- package/lib-module/Select/Picker.js +68 -0
- package/lib-module/Select/Picker.native.js +120 -0
- package/lib-module/Select/Select.js +337 -0
- package/lib-module/Select/index.js +6 -0
- package/lib-module/SideNav/Item.js +145 -0
- package/lib-module/SideNav/ItemContent.js +48 -0
- package/lib-module/SideNav/ItemsGroup.js +117 -0
- package/lib-module/SideNav/SideNav.js +136 -0
- package/lib-module/SideNav/index.js +1 -0
- package/lib-module/Skeleton/Skeleton.js +179 -0
- package/lib-module/Skeleton/index.js +2 -0
- package/lib-module/Skeleton/skeleton.constant.js +3 -0
- package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
- package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
- package/lib-module/Spacer/Spacer.js +98 -0
- package/lib-module/Spacer/index.js +2 -0
- package/lib-module/StackView/StackView.js +125 -0
- package/lib-module/StackView/StackWrap.js +50 -0
- package/lib-module/StackView/StackWrap.native.js +3 -0
- package/lib-module/StackView/StackWrapBox.js +115 -0
- package/lib-module/StackView/StackWrapGap.js +59 -0
- package/lib-module/StackView/common.js +35 -0
- package/lib-module/StackView/getStackedContent.js +124 -0
- package/lib-module/StackView/index.js +5 -0
- package/lib-module/StepTracker/Step.js +248 -0
- package/lib-module/StepTracker/StepTracker.js +185 -0
- package/lib-module/StepTracker/dictionary.js +10 -0
- package/lib-module/StepTracker/index.js +2 -0
- package/lib-module/Tabs/Tabs.js +143 -0
- package/lib-module/Tabs/TabsItem.js +224 -0
- package/lib-module/Tabs/index.js +2 -0
- package/lib-module/Tags/Tags.js +251 -0
- package/lib-module/Tags/index.js +2 -0
- package/lib-module/TextInput/TextArea.js +94 -0
- package/lib-module/TextInput/TextInput.js +64 -0
- package/lib-module/TextInput/TextInputBase.js +254 -0
- package/lib-module/TextInput/index.js +3 -0
- package/lib-module/TextInput/propTypes.js +33 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
- package/lib-module/ThemeProvider/index.js +6 -0
- package/lib-module/ThemeProvider/useSetTheme.js +25 -0
- package/lib-module/ThemeProvider/useTheme.js +14 -0
- package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
- package/lib-module/ThemeProvider/utils/index.js +2 -0
- package/lib-module/ThemeProvider/utils/styles.js +181 -0
- package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
- package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
- package/lib-module/ToggleSwitch/index.js +3 -0
- package/lib-module/Tooltip/Backdrop.js +45 -0
- package/lib-module/Tooltip/Backdrop.native.js +44 -0
- package/lib-module/Tooltip/Tooltip.js +348 -0
- package/lib-module/Tooltip/dictionary.js +8 -0
- package/lib-module/Tooltip/getTooltipPosition.js +175 -0
- package/lib-module/Tooltip/index.js +2 -0
- package/lib-module/TooltipButton/TooltipButton.js +78 -0
- package/lib-module/TooltipButton/index.js +2 -0
- package/lib-module/Typography/Typography.js +124 -0
- package/lib-module/Typography/index.js +2 -0
- package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
- package/lib-module/ViewportProvider/index.js +3 -0
- package/lib-module/ViewportProvider/useViewport.js +3 -0
- package/lib-module/ViewportProvider/useViewportListener.js +46 -0
- package/lib-module/index.js +48 -0
- package/lib-module/utils/a11y/index.js +2 -0
- package/lib-module/utils/a11y/semantics.js +157 -0
- package/lib-module/utils/a11y/textSize.js +36 -0
- package/lib-module/utils/animation/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
- package/lib-module/utils/children.js +119 -0
- package/lib-module/utils/containUniqueFields.js +26 -0
- package/lib-module/utils/index.js +16 -0
- package/lib-module/utils/info/index.js +7 -0
- package/lib-module/utils/info/platform/index.js +11 -0
- package/lib-module/utils/info/platform/platform.android.js +1 -0
- package/lib-module/utils/info/platform/platform.ios.js +1 -0
- package/lib-module/utils/info/platform/platform.js +1 -0
- package/lib-module/utils/info/platform/platform.native.js +4 -0
- package/lib-module/utils/info/versions.js +5 -0
- package/lib-module/utils/input.js +179 -0
- package/lib-module/utils/pressability.js +111 -0
- package/lib-module/utils/props/a11yProps.js +140 -0
- package/lib-module/utils/props/clickProps.js +26 -0
- package/lib-module/utils/props/componentPropType.js +63 -0
- package/lib-module/utils/props/copyPropTypes.js +2 -0
- package/lib-module/utils/props/getPropSelector.js +9 -0
- package/lib-module/utils/props/handlerProps.js +65 -0
- package/lib-module/utils/props/hrefAttrsProp.js +33 -0
- package/lib-module/utils/props/index.js +19 -0
- package/lib-module/utils/props/inputSupportsProps.js +62 -0
- package/lib-module/utils/props/linkProps.js +44 -0
- package/lib-module/utils/props/paddingProp.js +9 -0
- package/lib-module/utils/props/pressProps.js +42 -0
- package/lib-module/utils/props/rectProp.js +9 -0
- package/lib-module/utils/props/responsiveProps.js +30 -0
- package/lib-module/utils/props/selectSystemProps.js +24 -0
- package/lib-module/utils/props/spacingProps.js +56 -0
- package/lib-module/utils/props/textInputProps.js +201 -0
- package/lib-module/utils/props/textProps.js +59 -0
- package/lib-module/utils/props/tokens.js +133 -0
- package/lib-module/utils/props/variantProp.js +18 -0
- package/lib-module/utils/props/viewProps.js +22 -0
- package/lib-module/utils/ssr.js +38 -0
- package/lib-module/utils/useCopy.js +44 -0
- package/lib-module/utils/useHash.js +45 -0
- package/lib-module/utils/useHash.native.js +7 -0
- package/lib-module/utils/useResponsiveProp.js +47 -0
- package/lib-module/utils/useSpacingScale.js +125 -0
- package/lib-module/utils/useUniqueId.js +13 -0
- package/lib-module/utils/withLinkRouter.js +83 -0
- package/package.json +3 -3
- package/src/Card/Card.jsx +6 -4
- package/src/Checkbox/Checkbox.jsx +3 -1
- package/src/ExpandCollapse/Panel.jsx +10 -20
- package/src/Link/InlinePressable.jsx +5 -2
- package/src/Link/LinkBase.jsx +4 -1
- package/src/List/List.jsx +6 -2
- package/src/Tabs/Tabs.jsx +24 -2
- package/src/Tabs/TabsItem.jsx +6 -5
- package/src/TextInput/TextInput.jsx +1 -8
- package/src/TextInput/TextInputBase.jsx +11 -1
- package/src/TextInput/propTypes.js +3 -7
- package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
- package/src/utils/props/textInputProps.js +7 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
5
|
+
import View from "react-native-web/dist/exports/View";
|
|
6
|
+
import StackView from '../StackView';
|
|
7
|
+
import { applyTextStyles, useThemeTokens } from '../ThemeProvider';
|
|
8
|
+
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
9
|
+
import { useViewport } from '../ViewportProvider';
|
|
10
|
+
import useCopy from '../utils/useCopy';
|
|
11
|
+
import Step from './Step';
|
|
12
|
+
import defaultDictionary from './dictionary';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
16
|
+
|
|
17
|
+
const selectContainerStyles = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
containerPaddingBottom,
|
|
20
|
+
containerPaddingLeft,
|
|
21
|
+
containerPaddingRight,
|
|
22
|
+
containerPaddingTop
|
|
23
|
+
} = _ref;
|
|
24
|
+
return {
|
|
25
|
+
paddingBottom: containerPaddingBottom,
|
|
26
|
+
paddingLeft: containerPaddingLeft,
|
|
27
|
+
paddingRight: containerPaddingRight,
|
|
28
|
+
paddingTop: containerPaddingTop
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const selectStepTrackerLabelContainerStyles = _ref2 => {
|
|
33
|
+
let {
|
|
34
|
+
labelMarginTop
|
|
35
|
+
} = _ref2;
|
|
36
|
+
return {
|
|
37
|
+
marginTop: labelMarginTop
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const selectStepTrackerLabelStyles = _ref3 => {
|
|
42
|
+
let {
|
|
43
|
+
labelColor,
|
|
44
|
+
labelFontSize,
|
|
45
|
+
labelFontWeight,
|
|
46
|
+
labelFontName,
|
|
47
|
+
labelLineHeight
|
|
48
|
+
} = _ref3;
|
|
49
|
+
return applyTextStyles({
|
|
50
|
+
color: labelColor,
|
|
51
|
+
fontSize: labelFontSize,
|
|
52
|
+
lineHeight: labelLineHeight,
|
|
53
|
+
fontWeight: labelFontWeight,
|
|
54
|
+
fontName: labelFontName
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* StepTracker component shows the current position in a sequence of steps.
|
|
59
|
+
*
|
|
60
|
+
* ## Component API
|
|
61
|
+
*
|
|
62
|
+
* - `current` prop allows to control the current step, 0-based number;
|
|
63
|
+
* - use `copy` and `dictionary` props to internationalize the labels;
|
|
64
|
+
* - `steps` is and array of strings defining step titles;
|
|
65
|
+
* - tokens and variant props define the appearance of the `StepTracker`:
|
|
66
|
+
*
|
|
67
|
+
* ## Usability and A11y guidelines
|
|
68
|
+
*
|
|
69
|
+
* Keep in mind that in its current implementation this is not an interactive
|
|
70
|
+
* component and can’t be used to navigate between steps. The application
|
|
71
|
+
* must provide its own navigation mechanism and state control. That is the
|
|
72
|
+
* main reason the component assumes the `progressbar` role in terms of
|
|
73
|
+
* accessibility. This also makes it extremely important to make sure you
|
|
74
|
+
* set a11y on controls used to modify the state of the step tracker.
|
|
75
|
+
*
|
|
76
|
+
* You can pass standard a11y props to the `StepTracker` component, including
|
|
77
|
+
* the ones that are specific to the `progressbar` role. By default the
|
|
78
|
+
* following props are used:
|
|
79
|
+
*
|
|
80
|
+
* - `accessibilityRole` (`role`): `progressbar`,
|
|
81
|
+
* - `accessibilityLabel` (`aria-label`): `Step I of N: <Current Step Label>`,
|
|
82
|
+
* - `accessibilityLevel` (`aria-level`): 1,
|
|
83
|
+
* - `accessibilityValue.min` (`aria-valuemin`): `0`,
|
|
84
|
+
* - `accessibilityValue.max` (`aria-valuemax`): `steps.length - 1`,
|
|
85
|
+
* - `accessibilityValue.now` (`aria-valuenow`): `current`,
|
|
86
|
+
* - `accessibilityValue.text` (`aria-valuetext`): `<Current Step Label>`,
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
const StepTracker = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
92
|
+
let {
|
|
93
|
+
current = 0,
|
|
94
|
+
copy = 'en',
|
|
95
|
+
dictionary = defaultDictionary,
|
|
96
|
+
steps = [],
|
|
97
|
+
tokens,
|
|
98
|
+
variant,
|
|
99
|
+
...rest
|
|
100
|
+
} = _ref4;
|
|
101
|
+
const viewport = useViewport();
|
|
102
|
+
const {
|
|
103
|
+
showStepTrackerLabel,
|
|
104
|
+
...themeTokens
|
|
105
|
+
} = useThemeTokens('StepTracker', tokens, variant, {
|
|
106
|
+
viewport
|
|
107
|
+
});
|
|
108
|
+
const getCopy = useCopy({
|
|
109
|
+
dictionary,
|
|
110
|
+
copy
|
|
111
|
+
});
|
|
112
|
+
const stepTrackerLabel = getCopy('stepTrackerLabel').replace('%{stepNumber}', current < steps.length ? current + 1 : steps.length).replace('%{stepCount}', steps.length).replace('%{stepLabel}', current < steps.length ? steps[current] : steps[steps.length - 1]);
|
|
113
|
+
if (!steps.length) return null;
|
|
114
|
+
const selectedProps = selectProps({
|
|
115
|
+
accessibilityLabel: stepTrackerLabel,
|
|
116
|
+
accessibilityLevel: 1,
|
|
117
|
+
accessibilityRole: 'progressbar',
|
|
118
|
+
accessibilityValue: {
|
|
119
|
+
min: 0,
|
|
120
|
+
max: steps.length - 1,
|
|
121
|
+
now: current,
|
|
122
|
+
text: steps[current]
|
|
123
|
+
},
|
|
124
|
+
...rest
|
|
125
|
+
});
|
|
126
|
+
return /*#__PURE__*/_jsx(View, {
|
|
127
|
+
ref: ref,
|
|
128
|
+
style: selectContainerStyles(themeTokens),
|
|
129
|
+
...selectedProps,
|
|
130
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
131
|
+
space: 0,
|
|
132
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
133
|
+
style: staticStyles.stepsContainer,
|
|
134
|
+
children: steps.map((label, index) => {
|
|
135
|
+
return /*#__PURE__*/_jsx(Step, {
|
|
136
|
+
status: current,
|
|
137
|
+
label: label,
|
|
138
|
+
name: getCopy('stepLabel').replace('%{stepNumber}', index + 1),
|
|
139
|
+
stepIndex: index,
|
|
140
|
+
stepCount: steps.length,
|
|
141
|
+
tokens: themeTokens
|
|
142
|
+
}, label);
|
|
143
|
+
})
|
|
144
|
+
}), showStepTrackerLabel && /*#__PURE__*/_jsx(View, {
|
|
145
|
+
style: [staticStyles.stepTrackerLabelContainer, selectStepTrackerLabelContainerStyles(themeTokens)],
|
|
146
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
147
|
+
style: selectStepTrackerLabelStyles(themeTokens),
|
|
148
|
+
children: stepTrackerLabel
|
|
149
|
+
})
|
|
150
|
+
})]
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
StepTracker.displayName = 'StepTracker';
|
|
155
|
+
StepTracker.propTypes = { ...selectedSystemPropTypes,
|
|
156
|
+
current: PropTypes.number,
|
|
157
|
+
copy: PropTypes.oneOf(['en', 'fr']),
|
|
158
|
+
dictionary: PropTypes.shape({
|
|
159
|
+
en: PropTypes.shape({
|
|
160
|
+
stepLabel: PropTypes.string,
|
|
161
|
+
stepTrackerLabel: PropTypes.string
|
|
162
|
+
}),
|
|
163
|
+
fr: PropTypes.shape({
|
|
164
|
+
stepLabel: PropTypes.string,
|
|
165
|
+
stepTrackerLabel: PropTypes.string
|
|
166
|
+
})
|
|
167
|
+
}),
|
|
168
|
+
steps: PropTypes.arrayOf(PropTypes.string),
|
|
169
|
+
tokens: getTokensPropType('StepTracker'),
|
|
170
|
+
variant: variantProp.propType
|
|
171
|
+
};
|
|
172
|
+
export default StepTracker;
|
|
173
|
+
const staticStyles = StyleSheet.create({
|
|
174
|
+
stepsContainer: {
|
|
175
|
+
alignItems: 'flex-start',
|
|
176
|
+
flexDirection: 'row',
|
|
177
|
+
justifyContent: 'space-evenly',
|
|
178
|
+
flexGrow: 1
|
|
179
|
+
},
|
|
180
|
+
stepTrackerLabelContainer: {
|
|
181
|
+
textAlign: 'center',
|
|
182
|
+
flexDirection: 'row',
|
|
183
|
+
justifyContent: 'center'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
en: {
|
|
3
|
+
stepLabel: 'Step %{stepNumber}',
|
|
4
|
+
stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
|
|
5
|
+
},
|
|
6
|
+
fr: {
|
|
7
|
+
stepLabel: 'Étape %{stepNumber}',
|
|
8
|
+
stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ABBPropTypes from 'airbnb-prop-types';
|
|
4
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
5
|
+
import StackView from '../StackView';
|
|
6
|
+
import { a11yProps, getTokensPropType, selectSystemProps, useHash, useInputValue, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
7
|
+
import HorizontalScroll, { horizontalScrollUtils, HorizontalScrollButton } from '../HorizontalScroll';
|
|
8
|
+
import TabsItem from './TabsItem';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
11
|
+
const {
|
|
12
|
+
selectHorizontalScrollTokens,
|
|
13
|
+
useItemPositions
|
|
14
|
+
} = horizontalScrollUtils;
|
|
15
|
+
|
|
16
|
+
const getDefaultTabItemAccessibilityRole = parentRole => {
|
|
17
|
+
switch (parentRole) {
|
|
18
|
+
case 'tablist':
|
|
19
|
+
return 'tab';
|
|
20
|
+
|
|
21
|
+
case 'navigation':
|
|
22
|
+
return 'link';
|
|
23
|
+
|
|
24
|
+
default:
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Tabs renders a horizontally-scrolling menu of selectable buttons which may link
|
|
30
|
+
* to a page or control what content is displayed on this page.
|
|
31
|
+
*
|
|
32
|
+
* If you are using Tabs to navigate to a new page (web-only) you should pass
|
|
33
|
+
* `navigation`as the `accessibilityRole` to te Tabs component, this will cause
|
|
34
|
+
* TabItems to default to a role of link and obtain aria-current behaviour.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const Tabs = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
39
|
+
var _restProps$accessibil;
|
|
40
|
+
|
|
41
|
+
let {
|
|
42
|
+
tokens,
|
|
43
|
+
itemTokens,
|
|
44
|
+
scrollButtonTokens,
|
|
45
|
+
variant,
|
|
46
|
+
value,
|
|
47
|
+
initialValue,
|
|
48
|
+
onChange,
|
|
49
|
+
items = [],
|
|
50
|
+
LinkRouter,
|
|
51
|
+
linkRouterProps,
|
|
52
|
+
...rest
|
|
53
|
+
} = _ref;
|
|
54
|
+
const {
|
|
55
|
+
space,
|
|
56
|
+
...themeTokens
|
|
57
|
+
} = useThemeTokens('Tabs', tokens, variant);
|
|
58
|
+
const {
|
|
59
|
+
currentValue,
|
|
60
|
+
setValue
|
|
61
|
+
} = useInputValue({
|
|
62
|
+
value,
|
|
63
|
+
initialValue,
|
|
64
|
+
onChange
|
|
65
|
+
});
|
|
66
|
+
const [itemPositions, isPositioningReady] = useItemPositions();
|
|
67
|
+
useHash(useCallback((hash, event) => {
|
|
68
|
+
const hashItem = hash && items.find(_ref2 => {
|
|
69
|
+
let {
|
|
70
|
+
href
|
|
71
|
+
} = _ref2;
|
|
72
|
+
return hash === href;
|
|
73
|
+
});
|
|
74
|
+
const hashId = hashItem && (hashItem.id || hashItem.label);
|
|
75
|
+
if (hashId) setTimeout(setValue(hashId, event), 500);
|
|
76
|
+
}, [items, setValue]), isPositioningReady);
|
|
77
|
+
const restProps = selectProps(rest);
|
|
78
|
+
const parentAccessibilityRole = (_restProps$accessibil = restProps.accessibilityRole) !== null && _restProps$accessibil !== void 0 ? _restProps$accessibil : 'tablist';
|
|
79
|
+
const defaultTabItemAccessibiltyRole = getDefaultTabItemAccessibilityRole(parentAccessibilityRole);
|
|
80
|
+
return /*#__PURE__*/_jsx(HorizontalScroll, {
|
|
81
|
+
ref: ref,
|
|
82
|
+
ScrollButton: HorizontalScrollButton,
|
|
83
|
+
itemPositions: itemPositions,
|
|
84
|
+
tokens: selectHorizontalScrollTokens(themeTokens),
|
|
85
|
+
scrollButtonTokens: scrollButtonTokens,
|
|
86
|
+
accessibilityRole: parentAccessibilityRole,
|
|
87
|
+
...restProps,
|
|
88
|
+
children: /*#__PURE__*/_jsx(StackView, {
|
|
89
|
+
space: space,
|
|
90
|
+
direction: "row",
|
|
91
|
+
children: items.map((_ref3, index) => {
|
|
92
|
+
let {
|
|
93
|
+
href,
|
|
94
|
+
label,
|
|
95
|
+
id,
|
|
96
|
+
accessibilityRole = defaultTabItemAccessibiltyRole,
|
|
97
|
+
ref: itemRef,
|
|
98
|
+
LinkRouter: ItemLinkRouter = LinkRouter,
|
|
99
|
+
linkRouterProps: itemLinkRouterProps
|
|
100
|
+
} = _ref3;
|
|
101
|
+
const itemId = id !== null && id !== void 0 ? id : label;
|
|
102
|
+
const isSelected = Boolean(currentValue && currentValue === itemId);
|
|
103
|
+
|
|
104
|
+
const handlePress = event => setValue(itemId, event);
|
|
105
|
+
|
|
106
|
+
return /*#__PURE__*/_jsx(TabsItem, {
|
|
107
|
+
ref: itemRef,
|
|
108
|
+
href: href,
|
|
109
|
+
variant: variant,
|
|
110
|
+
tokens: itemTokens,
|
|
111
|
+
onPress: handlePress,
|
|
112
|
+
selected: isSelected,
|
|
113
|
+
itemPositions: itemPositions,
|
|
114
|
+
index: index,
|
|
115
|
+
accessibilityRole: accessibilityRole,
|
|
116
|
+
LinkRouter: ItemLinkRouter,
|
|
117
|
+
linkRouterProps: { ...linkRouterProps,
|
|
118
|
+
...itemLinkRouterProps
|
|
119
|
+
},
|
|
120
|
+
children: label
|
|
121
|
+
}, itemId);
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
Tabs.displayName = 'Tabs';
|
|
127
|
+
Tabs.propTypes = { ...selectedSystemPropTypes,
|
|
128
|
+
...withLinkRouter.PropTypes,
|
|
129
|
+
items: PropTypes.arrayOf(PropTypes.shape({ ...withLinkRouter.PropTypes,
|
|
130
|
+
href: PropTypes.string,
|
|
131
|
+
label: PropTypes.string,
|
|
132
|
+
id: PropTypes.string,
|
|
133
|
+
ref: ABBPropTypes.ref()
|
|
134
|
+
})),
|
|
135
|
+
value: PropTypes.string,
|
|
136
|
+
initialValue: PropTypes.string,
|
|
137
|
+
onChange: PropTypes.func,
|
|
138
|
+
tokens: getTokensPropType('Tabs'),
|
|
139
|
+
itemTokens: getTokensPropType('TabsItem'),
|
|
140
|
+
scrollButtonTokens: getTokensPropType('HorizontalScrollButton'),
|
|
141
|
+
variant: variantProp.propType
|
|
142
|
+
};
|
|
143
|
+
export default Tabs;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
5
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
6
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
7
|
+
import View from "react-native-web/dist/exports/View";
|
|
8
|
+
import { applyTextStyles, useThemeTokensCallback } from '../ThemeProvider';
|
|
9
|
+
import { a11yProps, clickProps, getTokensPropType, linkProps, resolvePressableTokens, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
10
|
+
import Spacer from '../Spacer';
|
|
11
|
+
import { horizontalScrollUtils } from '../HorizontalScroll';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
15
|
+
const {
|
|
16
|
+
itemPositionsPropType,
|
|
17
|
+
getItemPositionLayoutHandler
|
|
18
|
+
} = horizontalScrollUtils;
|
|
19
|
+
|
|
20
|
+
const selectHighlightBarStyles = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
highlightColor,
|
|
23
|
+
highlightBarBorderRadius = 0,
|
|
24
|
+
highlightBarBorderWidth = 0,
|
|
25
|
+
highlightBarHeight = 0
|
|
26
|
+
} = _ref;
|
|
27
|
+
return {
|
|
28
|
+
backgroundColor: highlightColor,
|
|
29
|
+
borderColor: highlightColor,
|
|
30
|
+
height: highlightBarHeight + highlightBarBorderWidth * 2,
|
|
31
|
+
borderRadius: highlightBarBorderRadius,
|
|
32
|
+
borderWidth: highlightBarBorderWidth,
|
|
33
|
+
bottom: -1 * (highlightBarHeight + highlightBarBorderWidth),
|
|
34
|
+
left: -1 * highlightBarBorderWidth,
|
|
35
|
+
right: -1 * highlightBarBorderWidth,
|
|
36
|
+
zIndex: 1 + highlightBarBorderWidth
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const selectHighlightTriangleStyles = _ref2 => {
|
|
41
|
+
let {
|
|
42
|
+
highlightColor,
|
|
43
|
+
highlightTriangleSize
|
|
44
|
+
} = _ref2;
|
|
45
|
+
return {
|
|
46
|
+
container: {
|
|
47
|
+
bottom: 0 - highlightTriangleSize * 2
|
|
48
|
+
},
|
|
49
|
+
triangle: {
|
|
50
|
+
height: 0,
|
|
51
|
+
width: 0,
|
|
52
|
+
borderWidth: highlightTriangleSize,
|
|
53
|
+
borderTopColor: highlightColor,
|
|
54
|
+
borderBottomColor: 'transparent',
|
|
55
|
+
borderLeftColor: 'transparent',
|
|
56
|
+
borderRightColor: 'transparent'
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const selectContainerStyles = _ref3 => {
|
|
62
|
+
let {
|
|
63
|
+
backgroundColor,
|
|
64
|
+
borderColor,
|
|
65
|
+
borderWidth = 0,
|
|
66
|
+
borderRadius,
|
|
67
|
+
paddingHorizontal = 0,
|
|
68
|
+
paddingVertical = 0
|
|
69
|
+
} = _ref3;
|
|
70
|
+
return {
|
|
71
|
+
backgroundColor,
|
|
72
|
+
borderColor,
|
|
73
|
+
borderWidth,
|
|
74
|
+
borderRadius,
|
|
75
|
+
paddingHorizontal: paddingHorizontal - borderWidth,
|
|
76
|
+
paddingVertical: paddingVertical - borderWidth
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Item within a Tabs component representing one tab of content. May be rendered as a link
|
|
81
|
+
* or as a "menuitem" button depending on whether 'href' is passed.
|
|
82
|
+
*
|
|
83
|
+
* This is rendered automatically by `Tabs` and isn't intended be used directly.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const TabsItem = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
88
|
+
let {
|
|
89
|
+
href,
|
|
90
|
+
variant,
|
|
91
|
+
tokens,
|
|
92
|
+
selected,
|
|
93
|
+
itemPositions,
|
|
94
|
+
index,
|
|
95
|
+
children,
|
|
96
|
+
accessibilityRole,
|
|
97
|
+
accessibilityCurrent = Platform.OS === 'web' && accessibilityRole === 'link' && selected ? 'page' : undefined,
|
|
98
|
+
accessibilityState = accessibilityRole === 'tab' ? {
|
|
99
|
+
selected
|
|
100
|
+
} : undefined,
|
|
101
|
+
...rawRest
|
|
102
|
+
} = _ref4;
|
|
103
|
+
// Convert onClick etc to onPress etc if used in an integration
|
|
104
|
+
const {
|
|
105
|
+
onPress,
|
|
106
|
+
...rest
|
|
107
|
+
} = clickProps.toPressProps(rawRest);
|
|
108
|
+
const getTokens = useThemeTokensCallback('TabsItem', tokens, variant);
|
|
109
|
+
|
|
110
|
+
const resolveTokens = pressableState => resolvePressableTokens(getTokens, pressableState, {
|
|
111
|
+
selected
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const getPressableStyle = pressableState => {
|
|
115
|
+
const {
|
|
116
|
+
maxWidth
|
|
117
|
+
} = resolveTokens(pressableState);
|
|
118
|
+
return [{
|
|
119
|
+
maxWidth
|
|
120
|
+
}, Platform.OS === 'web' && {
|
|
121
|
+
outline: 'none'
|
|
122
|
+
}];
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const handleLayout = getItemPositionLayoutHandler(itemPositions.positions, index); // On press, update the selection, call any press handler, and open any href in platform-appropriate way
|
|
126
|
+
|
|
127
|
+
const openHref = href && linkProps.handleHref({
|
|
128
|
+
href
|
|
129
|
+
});
|
|
130
|
+
const handlePress = onPress || openHref ? function () {
|
|
131
|
+
if (onPress) onPress(...arguments);
|
|
132
|
+
if (openHref) openHref(...arguments);
|
|
133
|
+
} : undefined;
|
|
134
|
+
const selectedProps = selectProps({
|
|
135
|
+
accessibilityRole,
|
|
136
|
+
accessibilityCurrent,
|
|
137
|
+
accessibilityState,
|
|
138
|
+
...rest
|
|
139
|
+
});
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
// If this is selected while off-screen, scroll it into view
|
|
142
|
+
if (selected) {
|
|
143
|
+
const position = itemPositions.positions[index];
|
|
144
|
+
const scrollEnd = itemPositions.scrollOffset + itemPositions.containerWidth;
|
|
145
|
+
|
|
146
|
+
if ( // is off the right edge, or
|
|
147
|
+
scrollEnd && (position === null || position === void 0 ? void 0 : position.end) > scrollEnd || // is off the left edge
|
|
148
|
+
typeof (position === null || position === void 0 ? void 0 : position.start) === 'number' && position.start < itemPositions.scrollOffset) {
|
|
149
|
+
itemPositions.scrollTo(position.start);
|
|
150
|
+
}
|
|
151
|
+
} // itemPositions is a ref object so this should only re-run when `selected` (or `index`) change
|
|
152
|
+
|
|
153
|
+
}, [selected, index, itemPositions]);
|
|
154
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
155
|
+
ref: ref,
|
|
156
|
+
onPress: handlePress,
|
|
157
|
+
href: href,
|
|
158
|
+
style: getPressableStyle,
|
|
159
|
+
onLayout: handleLayout,
|
|
160
|
+
...selectedProps,
|
|
161
|
+
children: pressableState => {
|
|
162
|
+
const {
|
|
163
|
+
space,
|
|
164
|
+
textAlign,
|
|
165
|
+
...themeTokens
|
|
166
|
+
} = resolveTokens(pressableState);
|
|
167
|
+
const hasHighlightBar = Boolean(themeTokens.highlightBarHeight);
|
|
168
|
+
const highlightBarStyle = hasHighlightBar && selectHighlightBarStyles(themeTokens);
|
|
169
|
+
const hasHighlightTriangle = Boolean(themeTokens.highlightTriangleSize);
|
|
170
|
+
const highlightTriangleStyle = hasHighlightTriangle && selectHighlightTriangleStyles(themeTokens);
|
|
171
|
+
const containerStyles = selectContainerStyles(themeTokens);
|
|
172
|
+
const textStyles = applyTextStyles({ ...selectTokens('Typography', themeTokens),
|
|
173
|
+
textAlign
|
|
174
|
+
});
|
|
175
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
176
|
+
style: staticStyles.container,
|
|
177
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
178
|
+
style: containerStyles,
|
|
179
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
180
|
+
style: textStyles,
|
|
181
|
+
children: children
|
|
182
|
+
})
|
|
183
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
184
|
+
space: space
|
|
185
|
+
}), hasHighlightBar && /*#__PURE__*/_jsx(View, {
|
|
186
|
+
style: [staticStyles.absolute, highlightBarStyle]
|
|
187
|
+
}), hasHighlightTriangle && /*#__PURE__*/_jsx(View, {
|
|
188
|
+
style: [staticStyles.absolute, highlightTriangleStyle.container],
|
|
189
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
190
|
+
style: highlightTriangleStyle.triangle
|
|
191
|
+
})
|
|
192
|
+
})]
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
TabsItem.displayName = 'TabsItem';
|
|
198
|
+
TabsItem.propTypes = { ...selectedSystemPropTypes,
|
|
199
|
+
tokens: getTokensPropType('TabsItem'),
|
|
200
|
+
variant: variantProp.propType,
|
|
201
|
+
onPress: PropTypes.func,
|
|
202
|
+
href: PropTypes.string,
|
|
203
|
+
index: PropTypes.number,
|
|
204
|
+
selected: PropTypes.bool,
|
|
205
|
+
itemPositions: itemPositionsPropType,
|
|
206
|
+
children: PropTypes.string
|
|
207
|
+
};
|
|
208
|
+
const staticStyles = StyleSheet.create({
|
|
209
|
+
center: {
|
|
210
|
+
alignItems: 'center'
|
|
211
|
+
},
|
|
212
|
+
absolute: {
|
|
213
|
+
position: 'absolute',
|
|
214
|
+
alignItems: 'center',
|
|
215
|
+
left: 0,
|
|
216
|
+
right: 0
|
|
217
|
+
},
|
|
218
|
+
container: {
|
|
219
|
+
flexGrow: 1,
|
|
220
|
+
alignItems: 'center',
|
|
221
|
+
justifyContent: 'center'
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
export default withLinkRouter(TabsItem);
|