@telus-uds/components-base 1.12.0 → 1.14.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 +41 -2
- package/component-docs.json +933 -55
- package/lib/BaseProvider/index.js +7 -2
- package/lib/Button/ButtonBase.js +52 -19
- package/lib/Button/ButtonGroup.js +7 -0
- package/lib/Button/propTypes.js +18 -0
- package/lib/Carousel/Carousel.js +83 -58
- package/lib/Carousel/CarouselContext.js +22 -8
- package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +73 -0
- package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +56 -0
- package/lib/Carousel/CarouselStepTracker/index.js +13 -0
- package/lib/Carousel/CarouselTabs/CarouselTabs.js +70 -0
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +95 -0
- package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +148 -0
- package/lib/Carousel/CarouselTabs/index.js +13 -0
- package/lib/Carousel/CarouselThumbnail.js +99 -0
- package/lib/Carousel/CarouselThumbnailNavigation.js +87 -0
- package/lib/Carousel/dictionary.js +4 -2
- package/lib/Carousel/index.js +10 -1
- package/lib/Checkbox/Checkbox.js +7 -3
- package/lib/Checkbox/CheckboxGroup.js +8 -1
- package/lib/Feedback/Feedback.js +18 -10
- package/lib/Icon/IconText.js +6 -1
- package/lib/InputLabel/InputLabel.js +11 -5
- package/lib/Link/InlinePressable.js +1 -8
- package/lib/Link/LinkBase.js +13 -10
- package/lib/List/ListItem.js +8 -4
- package/lib/Notification/Notification.js +44 -24
- package/lib/Pagination/Pagination.js +7 -3
- package/lib/Radio/RadioGroup.js +8 -0
- package/lib/RadioCard/RadioCard.js +6 -1
- package/lib/RadioCard/RadioCardGroup.js +7 -0
- package/lib/Select/Select.js +7 -3
- package/lib/SkipLink/SkipLink.js +216 -0
- package/lib/SkipLink/index.js +13 -0
- package/lib/StepTracker/Step.js +8 -4
- package/lib/StepTracker/StepTracker.js +7 -3
- package/lib/Tabs/TabsItem.js +4 -0
- package/lib/TextInput/TextInputBase.js +7 -3
- package/lib/ThemeProvider/ThemeProvider.js +25 -3
- package/lib/ThemeProvider/utils/styles.js +8 -1
- package/lib/ThemeProvider/utils/theme-tokens.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +7 -0
- package/lib/Typography/Typography.js +6 -2
- package/lib/index.js +9 -0
- package/lib-module/BaseProvider/index.js +7 -2
- package/lib-module/Button/ButtonBase.js +41 -9
- package/lib-module/Button/ButtonGroup.js +7 -0
- package/lib-module/Button/propTypes.js +17 -0
- package/lib-module/Carousel/Carousel.js +80 -57
- package/lib-module/Carousel/CarouselContext.js +21 -8
- package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +51 -0
- package/lib-module/Carousel/CarouselStepTracker/CarouselStepTracker.js +42 -0
- package/lib-module/Carousel/CarouselStepTracker/index.js +2 -0
- package/lib-module/Carousel/CarouselTabs/CarouselTabs.js +50 -0
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +76 -0
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanelItem.js +126 -0
- package/lib-module/Carousel/CarouselTabs/index.js +2 -0
- package/lib-module/Carousel/CarouselThumbnail.js +85 -0
- package/lib-module/Carousel/CarouselThumbnailNavigation.js +66 -0
- package/lib-module/Carousel/dictionary.js +4 -2
- package/lib-module/Carousel/index.js +2 -1
- package/lib-module/Checkbox/Checkbox.js +8 -4
- package/lib-module/Checkbox/CheckboxGroup.js +8 -1
- package/lib-module/Feedback/Feedback.js +19 -11
- package/lib-module/Icon/IconText.js +6 -1
- package/lib-module/InputLabel/InputLabel.js +12 -6
- package/lib-module/Link/InlinePressable.js +1 -8
- package/lib-module/Link/LinkBase.js +14 -11
- package/lib-module/List/ListItem.js +9 -5
- package/lib-module/Notification/Notification.js +46 -26
- package/lib-module/Pagination/Pagination.js +8 -4
- package/lib-module/Radio/RadioGroup.js +8 -0
- package/lib-module/RadioCard/RadioCard.js +7 -2
- package/lib-module/RadioCard/RadioCardGroup.js +7 -0
- package/lib-module/Select/Select.js +8 -4
- package/lib-module/SkipLink/SkipLink.js +188 -0
- package/lib-module/SkipLink/index.js +2 -0
- package/lib-module/StepTracker/Step.js +9 -5
- package/lib-module/StepTracker/StepTracker.js +8 -4
- package/lib-module/Tabs/TabsItem.js +5 -1
- package/lib-module/TextInput/TextInputBase.js +8 -4
- package/lib-module/ThemeProvider/ThemeProvider.js +24 -3
- package/lib-module/ThemeProvider/utils/styles.js +8 -1
- package/lib-module/ThemeProvider/utils/theme-tokens.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +7 -0
- package/lib-module/Typography/Typography.js +7 -3
- package/lib-module/index.js +1 -0
- package/package.json +46 -47
- package/src/BaseProvider/index.jsx +6 -3
- package/src/Button/ButtonBase.jsx +36 -12
- package/src/Button/ButtonGroup.jsx +6 -0
- package/src/Button/propTypes.js +14 -0
- package/src/Carousel/Carousel.jsx +91 -64
- package/src/Carousel/CarouselContext.jsx +29 -5
- package/src/Carousel/CarouselFirstFocus/CarouselFirstFocus.jsx +49 -0
- package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +36 -0
- package/src/Carousel/CarouselStepTracker/index.js +3 -0
- package/src/Carousel/CarouselTabs/CarouselTabs.jsx +37 -0
- package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +69 -0
- package/src/Carousel/CarouselTabs/CarouselTabsPanelItem.jsx +119 -0
- package/src/Carousel/CarouselTabs/index.js +3 -0
- package/src/Carousel/CarouselThumbnail.jsx +77 -0
- package/src/Carousel/CarouselThumbnailNavigation.jsx +53 -0
- package/src/Carousel/dictionary.js +4 -2
- package/src/Carousel/index.js +1 -0
- package/src/Checkbox/Checkbox.jsx +14 -11
- package/src/Checkbox/CheckboxGroup.jsx +8 -1
- package/src/Feedback/Feedback.jsx +14 -7
- package/src/Icon/IconText.jsx +3 -1
- package/src/InputLabel/InputLabel.jsx +13 -12
- package/src/Link/InlinePressable.jsx +2 -8
- package/src/Link/LinkBase.jsx +18 -21
- package/src/List/ListItem.jsx +10 -5
- package/src/Notification/Notification.jsx +40 -23
- package/src/Pagination/Pagination.jsx +6 -4
- package/src/Radio/RadioGroup.jsx +7 -0
- package/src/RadioCard/RadioCard.jsx +3 -2
- package/src/RadioCard/RadioCardGroup.jsx +6 -0
- package/src/Select/Select.jsx +12 -3
- package/src/SkipLink/SkipLink.jsx +179 -0
- package/src/SkipLink/index.js +3 -0
- package/src/StepTracker/Step.jsx +12 -4
- package/src/StepTracker/StepTracker.jsx +11 -10
- package/src/Tabs/TabsItem.jsx +3 -2
- package/src/TextInput/TextInputBase.jsx +11 -3
- package/src/ThemeProvider/ThemeProvider.jsx +22 -3
- package/src/ThemeProvider/utils/styles.js +9 -1
- package/src/ThemeProvider/utils/theme-tokens.js +1 -1
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +6 -0
- package/src/Typography/Typography.jsx +11 -12
- package/src/index.js +1 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
4
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
5
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
6
|
+
import { applyTextStyles, useThemeTokensCallback } from '../../ThemeProvider';
|
|
7
|
+
import { selectSystemProps, a11yProps, pressProps, viewProps, textProps, getTokensPropType, variantProp, resolvePressableState } from '../../utils';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const [selectPressProps, pressPropTypes] = selectSystemProps([a11yProps, pressProps, viewProps]);
|
|
10
|
+
const [selectTextProps, textPropTypes] = selectSystemProps([textProps]);
|
|
11
|
+
|
|
12
|
+
const selectContainerStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
paddingLeft,
|
|
15
|
+
paddingRight,
|
|
16
|
+
paddingTop,
|
|
17
|
+
paddingBottom = 0,
|
|
18
|
+
borderBottomColor,
|
|
19
|
+
borderBottomWidth = 0,
|
|
20
|
+
borderBottomStyle,
|
|
21
|
+
flex,
|
|
22
|
+
alignItems,
|
|
23
|
+
justifyContent
|
|
24
|
+
} = _ref;
|
|
25
|
+
return {
|
|
26
|
+
paddingLeft,
|
|
27
|
+
paddingRight,
|
|
28
|
+
paddingTop,
|
|
29
|
+
paddingBottom: paddingBottom - borderBottomWidth,
|
|
30
|
+
borderBottomColor,
|
|
31
|
+
borderBottomWidth,
|
|
32
|
+
borderBottomStyle,
|
|
33
|
+
flex,
|
|
34
|
+
alignItems,
|
|
35
|
+
justifyContent,
|
|
36
|
+
...Platform.select({
|
|
37
|
+
// Removes the default browser :focus outline
|
|
38
|
+
web: {
|
|
39
|
+
outline: 'none'
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const selectTextStyles = _ref2 => {
|
|
46
|
+
let {
|
|
47
|
+
fontSize,
|
|
48
|
+
fontScaleCap,
|
|
49
|
+
lineHeight,
|
|
50
|
+
letterSpacing,
|
|
51
|
+
fontWeight,
|
|
52
|
+
fontName,
|
|
53
|
+
color
|
|
54
|
+
} = _ref2;
|
|
55
|
+
return applyTextStyles({
|
|
56
|
+
fontSize,
|
|
57
|
+
fontScaleCap,
|
|
58
|
+
lineHeight,
|
|
59
|
+
letterSpacing,
|
|
60
|
+
fontWeight,
|
|
61
|
+
fontName,
|
|
62
|
+
color
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const CarouselTabsPanelItem = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
67
|
+
let {
|
|
68
|
+
title,
|
|
69
|
+
selected,
|
|
70
|
+
inactive,
|
|
71
|
+
variant,
|
|
72
|
+
tokens,
|
|
73
|
+
accessibilityRole = 'tab',
|
|
74
|
+
...rest
|
|
75
|
+
} = _ref3;
|
|
76
|
+
// Workaround for React Native Web https://github.com/necolas/react-native-web/issues/2357
|
|
77
|
+
// Don't allow disabled to be set while focus is true else focus state gets locked `true`
|
|
78
|
+
// (must refocus _after_ calling `goTo`, else focus target content is not up to date)
|
|
79
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
80
|
+
const disabled = (inactive || selected) && !isFocused;
|
|
81
|
+
const getTokens = useThemeTokensCallback('CarouselTabsPanelItem', tokens, variant);
|
|
82
|
+
|
|
83
|
+
const resolveTokens = pressState => getTokens(resolvePressableState(pressState, {
|
|
84
|
+
selected
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
const getContainerStyle = pressState => selectContainerStyles(resolveTokens(pressState));
|
|
88
|
+
|
|
89
|
+
const getTextStyle = pressState => selectTextStyles(resolveTokens(pressState));
|
|
90
|
+
|
|
91
|
+
const {
|
|
92
|
+
onPress,
|
|
93
|
+
...selectedPressProps
|
|
94
|
+
} = selectPressProps(rest);
|
|
95
|
+
|
|
96
|
+
const handleKeyDown = event => {
|
|
97
|
+
// Allow using the spacebar for navigation
|
|
98
|
+
if ((event === null || event === void 0 ? void 0 : event.key) === ' ') onPress(event);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
102
|
+
onPress: onPress,
|
|
103
|
+
style: getContainerStyle,
|
|
104
|
+
accessibilityRole: accessibilityRole,
|
|
105
|
+
ref: ref,
|
|
106
|
+
onKeyDown: handleKeyDown,
|
|
107
|
+
onFocus: () => setIsFocused(true),
|
|
108
|
+
onBlur: () => setIsFocused(false),
|
|
109
|
+
disabled: disabled,
|
|
110
|
+
...selectedPressProps,
|
|
111
|
+
children: pressState => /*#__PURE__*/_jsx(Text, {
|
|
112
|
+
style: getTextStyle(pressState),
|
|
113
|
+
...selectTextProps(rest),
|
|
114
|
+
children: title
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
CarouselTabsPanelItem.displayName = 'CarouselTabsPanelItem';
|
|
119
|
+
CarouselTabsPanelItem.propTypes = { ...pressPropTypes,
|
|
120
|
+
...textPropTypes,
|
|
121
|
+
title: PropTypes.string.isRequired,
|
|
122
|
+
selected: PropTypes.bool,
|
|
123
|
+
tokens: getTokensPropType('CarouselTabsPanelItem'),
|
|
124
|
+
variant: variantProp.propType
|
|
125
|
+
};
|
|
126
|
+
export default CarouselTabsPanelItem;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
4
|
+
import Image from "react-native-web/dist/exports/Image";
|
|
5
|
+
import { useCarousel } from './CarouselContext';
|
|
6
|
+
/**
|
|
7
|
+
* `Carousel.Thumbnail` is used to wrap the content of an individual slide and is suppsoed to be the
|
|
8
|
+
* only top-level component passed to the `Carousel`
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
const CarouselThumbnail = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
accessibilityLabel,
|
|
16
|
+
alt,
|
|
17
|
+
index,
|
|
18
|
+
src
|
|
19
|
+
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
activeIndex,
|
|
22
|
+
itemLabel,
|
|
23
|
+
totalItems,
|
|
24
|
+
getCopyWithPlaceholders,
|
|
25
|
+
goTo,
|
|
26
|
+
themeTokens
|
|
27
|
+
} = useCarousel();
|
|
28
|
+
const thumbnailTitle = alt !== null && alt !== void 0 ? alt : getCopyWithPlaceholders('stepTrackerLabel').replace(/%\{itemLabel\}/g, itemLabel).replace(/%\{stepNumber\}/g, index).replace(/%\{stepCount\}/g, totalItems);
|
|
29
|
+
|
|
30
|
+
const handlePress = () => goTo(index);
|
|
31
|
+
|
|
32
|
+
const handleKeyDown = event => {
|
|
33
|
+
// Allow using the spacebar for navigation
|
|
34
|
+
if ((event === null || event === void 0 ? void 0 : event.key) === ' ') goTo(index);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
thumbnailBorderColor,
|
|
39
|
+
thumbnailBorderRadius,
|
|
40
|
+
thumbnailBorderWidth,
|
|
41
|
+
thumbnailMargin,
|
|
42
|
+
thumbnailPadding,
|
|
43
|
+
thumbnailSelectedBorderColor,
|
|
44
|
+
thumbnailSelectedBorderWidth,
|
|
45
|
+
thumbnailSize
|
|
46
|
+
} = themeTokens;
|
|
47
|
+
const styles = {
|
|
48
|
+
pressable: {
|
|
49
|
+
borderColor: thumbnailBorderColor,
|
|
50
|
+
borderRadius: thumbnailBorderRadius,
|
|
51
|
+
borderWidth: thumbnailBorderWidth,
|
|
52
|
+
margin: thumbnailMargin,
|
|
53
|
+
padding: thumbnailPadding
|
|
54
|
+
},
|
|
55
|
+
image: {
|
|
56
|
+
height: thumbnailSize,
|
|
57
|
+
width: thumbnailSize
|
|
58
|
+
},
|
|
59
|
+
selected: {
|
|
60
|
+
borderColor: thumbnailSelectedBorderColor,
|
|
61
|
+
borderWidth: thumbnailSelectedBorderWidth,
|
|
62
|
+
padding: thumbnailPadding - thumbnailSelectedBorderWidth + thumbnailBorderWidth
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
66
|
+
onKeyDown: handleKeyDown,
|
|
67
|
+
onPress: handlePress,
|
|
68
|
+
style: [styles.pressable, index === activeIndex && styles.selected],
|
|
69
|
+
children: /*#__PURE__*/_jsx(Image, {
|
|
70
|
+
accessibilityIgnoresInvertColors: true,
|
|
71
|
+
accessibilityLabel: accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : alt,
|
|
72
|
+
source: src,
|
|
73
|
+
style: styles.image,
|
|
74
|
+
title: thumbnailTitle
|
|
75
|
+
})
|
|
76
|
+
}, src);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
CarouselThumbnail.propTypes = {
|
|
80
|
+
accessibilityLabel: PropTypes.string,
|
|
81
|
+
alt: PropTypes.string,
|
|
82
|
+
index: PropTypes.number,
|
|
83
|
+
src: PropTypes.string
|
|
84
|
+
};
|
|
85
|
+
export default CarouselThumbnail;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import { useCarousel } from './CarouselContext';
|
|
5
|
+
import CarouselThumbnail from './CarouselThumbnail';
|
|
6
|
+
import { StackWrap } from '../StackView';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const CarouselThumbnailNavigation = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
9
|
+
let {
|
|
10
|
+
thumbnails = []
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
totalItems,
|
|
14
|
+
themeTokens
|
|
15
|
+
} = useCarousel();
|
|
16
|
+
|
|
17
|
+
if (thumbnails.length !== totalItems) {
|
|
18
|
+
throw new Error('Thumbnail set provided does not match the number of slides in the carousel');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
thumbnailContainerPaddingTop,
|
|
23
|
+
thumbnailMargin
|
|
24
|
+
} = themeTokens;
|
|
25
|
+
const stackWrapTokens = {
|
|
26
|
+
justifyContent: 'flex-start'
|
|
27
|
+
};
|
|
28
|
+
const containerStyles = {
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
paddingTop: thumbnailContainerPaddingTop - thumbnailMargin
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/_jsx(View, {
|
|
34
|
+
style: containerStyles,
|
|
35
|
+
children: /*#__PURE__*/_jsx(StackWrap, {
|
|
36
|
+
direction: "row",
|
|
37
|
+
tokens: stackWrapTokens,
|
|
38
|
+
ref: ref,
|
|
39
|
+
children: thumbnails.map((_ref2, index) => {
|
|
40
|
+
let {
|
|
41
|
+
accessibilityLabel,
|
|
42
|
+
alt,
|
|
43
|
+
src
|
|
44
|
+
} = _ref2;
|
|
45
|
+
return /*#__PURE__*/_jsx(CarouselThumbnail, {
|
|
46
|
+
accessibilityLabel: accessibilityLabel,
|
|
47
|
+
alt: alt,
|
|
48
|
+
index: index,
|
|
49
|
+
src: src
|
|
50
|
+
}, src);
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
CarouselThumbnailNavigation.displayName = 'CarouselThumbnailNavigation';
|
|
56
|
+
CarouselThumbnailNavigation.propTypes = {
|
|
57
|
+
/**
|
|
58
|
+
* An array of objects containing information on the thumbnail images.
|
|
59
|
+
*/
|
|
60
|
+
thumbnails: PropTypes.arrayOf(PropTypes.shape({
|
|
61
|
+
accessibilityLabel: PropTypes.string,
|
|
62
|
+
alt: PropTypes.string,
|
|
63
|
+
src: PropTypes.string
|
|
64
|
+
})).isRequired
|
|
65
|
+
};
|
|
66
|
+
export default CarouselThumbnailNavigation;
|
|
@@ -4,13 +4,15 @@ export default {
|
|
|
4
4
|
carouselLabel: '%{stepCount} items',
|
|
5
5
|
iconButtonLabel: 'Show %{itemLabel} %{targetStep} of %{stepCount}',
|
|
6
6
|
stepLabel: '%{itemLabel} %{stepNumber}',
|
|
7
|
-
stepTrackerLabel: '%{itemLabel} %{stepNumber} of %{stepCount}'
|
|
7
|
+
stepTrackerLabel: '%{itemLabel} %{stepNumber} of %{stepCount}',
|
|
8
|
+
skipLink: 'Skip %{title}'
|
|
8
9
|
},
|
|
9
10
|
fr: {
|
|
10
11
|
// TODO: French translations here
|
|
11
12
|
carouselLabel: '(fr) %{stepCount} items',
|
|
12
13
|
iconButtonLabel: '(fr) Show %{itemLabel} %{targetStep} of %{stepCount}',
|
|
13
14
|
stepLabel: '(fr) %{itemLabel} %{stepNumber}',
|
|
14
|
-
stepTrackerLabel: '(fr) %{itemLabel} %{stepNumber} of %{stepCount}'
|
|
15
|
+
stepTrackerLabel: '(fr) %{itemLabel} %{stepNumber} of %{stepCount}',
|
|
16
|
+
skipLink: '(fr) Skip %{title}'
|
|
15
17
|
}
|
|
16
18
|
};
|
|
@@ -9,7 +9,7 @@ import CheckboxInput from './CheckboxInput';
|
|
|
9
9
|
import CheckboxLabel from '../InputLabel/LabelContent';
|
|
10
10
|
import Feedback from '../Feedback';
|
|
11
11
|
import StackView from '../StackView';
|
|
12
|
-
import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider';
|
|
12
|
+
import { applyShadowToken, applyTextStyles, useTheme, useThemeTokensCallback } from '../ThemeProvider';
|
|
13
13
|
import { a11yProps, focusHandlerProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
|
|
14
14
|
import useUniqueId from '../utils/useUniqueId';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -47,7 +47,7 @@ const selectInputStyles = (_ref, isChecked) => {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
const selectLabelStyles = _ref2 => {
|
|
50
|
+
const selectLabelStyles = (_ref2, themeOptions) => {
|
|
51
51
|
let {
|
|
52
52
|
labelColor,
|
|
53
53
|
labelFontName,
|
|
@@ -63,7 +63,8 @@ const selectLabelStyles = _ref2 => {
|
|
|
63
63
|
fontName: labelFontName,
|
|
64
64
|
fontWeight: labelFontWeight,
|
|
65
65
|
fontSize: labelFontSize,
|
|
66
|
-
lineHeight: labelLineHeight
|
|
66
|
+
lineHeight: labelLineHeight,
|
|
67
|
+
themeOptions
|
|
67
68
|
})
|
|
68
69
|
};
|
|
69
70
|
};
|
|
@@ -187,6 +188,9 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
187
188
|
|
|
188
189
|
const uniqueId = useUniqueId('checkbox');
|
|
189
190
|
const inputId = id !== null && id !== void 0 ? id : uniqueId;
|
|
191
|
+
const {
|
|
192
|
+
themeOptions
|
|
193
|
+
} = useTheme();
|
|
190
194
|
return /*#__PURE__*/_jsx(View, {
|
|
191
195
|
style: staticStyles.wrapper,
|
|
192
196
|
ref: ref,
|
|
@@ -218,7 +222,7 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
218
222
|
pressed
|
|
219
223
|
});
|
|
220
224
|
const iconTokens = selectIconTokens(stateTokens);
|
|
221
|
-
const labelStyles = selectLabelStyles(stateTokens);
|
|
225
|
+
const labelStyles = selectLabelStyles(stateTokens, themeOptions);
|
|
222
226
|
const alignWithLabel = label ? [staticStyles.alignWithLabel, {
|
|
223
227
|
height: labelStyles.lineHeight
|
|
224
228
|
}] : null;
|
|
@@ -46,7 +46,7 @@ const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, f
|
|
|
46
46
|
* @example
|
|
47
47
|
* ```jsx
|
|
48
48
|
* <CheckboxGroup
|
|
49
|
-
*
|
|
49
|
+
* initialCheckedIds="check1"
|
|
50
50
|
* items={[
|
|
51
51
|
* { label: 'Checkbox 1', id: 'check1' },
|
|
52
52
|
* { label: 'Checkbox 2', id: 'check2' },
|
|
@@ -67,6 +67,7 @@ const CheckboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
67
67
|
legend,
|
|
68
68
|
tooltip,
|
|
69
69
|
hint,
|
|
70
|
+
hintPosition = 'inline',
|
|
70
71
|
validation,
|
|
71
72
|
feedback,
|
|
72
73
|
initialCheckedIds,
|
|
@@ -133,6 +134,7 @@ const CheckboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
133
134
|
legend: legend,
|
|
134
135
|
tooltip: tooltip,
|
|
135
136
|
hint: hint,
|
|
137
|
+
hintPosition: hintPosition,
|
|
136
138
|
space: fieldSpace,
|
|
137
139
|
feedback: feedback,
|
|
138
140
|
inactive: inactive,
|
|
@@ -182,6 +184,11 @@ CheckboxGroup.propTypes = { ...selectedSystemPropTypes,
|
|
|
182
184
|
*/
|
|
183
185
|
hint: PropTypes.string,
|
|
184
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Position of the hint relative to label. Use `below` to display a larger hint below the label.
|
|
189
|
+
*/
|
|
190
|
+
hintPosition: PropTypes.oneOf(['inline', 'below']),
|
|
191
|
+
|
|
185
192
|
/**
|
|
186
193
|
* Optional tooltip text content to include alongside the legend and hint.
|
|
187
194
|
*/
|
|
@@ -3,7 +3,7 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
|
3
3
|
import Text from "react-native-web/dist/exports/Text";
|
|
4
4
|
import View from "react-native-web/dist/exports/View";
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { applyTextStyles, useThemeTokens } from '../ThemeProvider';
|
|
6
|
+
import { applyTextStyles, useTheme, useThemeTokens } from '../ThemeProvider';
|
|
7
7
|
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils';
|
|
8
8
|
import StackView from '../StackView';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -12,24 +12,29 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
12
12
|
|
|
13
13
|
const selectStyles = tokens => selectTokens('Feedback', tokens);
|
|
14
14
|
|
|
15
|
-
const selectTitleTextStyles = _ref => {
|
|
15
|
+
const selectTitleTextStyles = (_ref, themeOptions) => {
|
|
16
16
|
let {
|
|
17
17
|
titleFontSize,
|
|
18
18
|
...tokens
|
|
19
19
|
} = _ref;
|
|
20
|
-
return applyTextStyles(selectTokens('Typography', { ...tokens,
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
return applyTextStyles({ ...selectTokens('Typography', { ...tokens,
|
|
21
|
+
fontSize: titleFontSize,
|
|
22
|
+
themeOptions
|
|
23
|
+
}),
|
|
24
|
+
themeOptions
|
|
25
|
+
});
|
|
23
26
|
};
|
|
24
27
|
|
|
25
|
-
const selectContentTextStyles = _ref2 => {
|
|
28
|
+
const selectContentTextStyles = (_ref2, themeOptions) => {
|
|
26
29
|
let {
|
|
27
30
|
contentFontSize,
|
|
28
31
|
...tokens
|
|
29
32
|
} = _ref2;
|
|
30
|
-
return applyTextStyles(selectTokens('Typography', { ...tokens,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
return applyTextStyles({ ...selectTokens('Typography', { ...tokens,
|
|
34
|
+
fontSize: contentFontSize
|
|
35
|
+
}),
|
|
36
|
+
themeOptions
|
|
37
|
+
});
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
const selectIconTokens = _ref3 => {
|
|
@@ -90,8 +95,11 @@ const Feedback = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
90
95
|
const {
|
|
91
96
|
icon: IconComponent
|
|
92
97
|
} = themeTokens;
|
|
93
|
-
const
|
|
94
|
-
|
|
98
|
+
const {
|
|
99
|
+
themeOptions
|
|
100
|
+
} = useTheme();
|
|
101
|
+
const titleTextStyles = selectTitleTextStyles(themeTokens, themeOptions);
|
|
102
|
+
const contentTextStyles = selectContentTextStyles(themeTokens, themeOptions);
|
|
95
103
|
const content = typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
96
104
|
style: contentTextStyles,
|
|
97
105
|
children: children
|
|
@@ -51,6 +51,9 @@ const IconText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
51
51
|
});
|
|
52
52
|
IconText.displayName = 'IconText';
|
|
53
53
|
IconText.propTypes = {
|
|
54
|
+
/* eslint-disable react/no-unused-prop-types */
|
|
55
|
+
// eslint is having hard time seeing these props through forwardRef
|
|
56
|
+
|
|
54
57
|
/**
|
|
55
58
|
* Amount of space to separate the text content and icon. Uses the themes's spacing scale
|
|
56
59
|
* (see useSpacingScale for more info).
|
|
@@ -65,7 +68,7 @@ IconText.propTypes = {
|
|
|
65
68
|
/**
|
|
66
69
|
* A valid UDS icon component imported from a UDS palette.
|
|
67
70
|
*/
|
|
68
|
-
icon: PropTypes.
|
|
71
|
+
icon: PropTypes.elementType,
|
|
69
72
|
|
|
70
73
|
/**
|
|
71
74
|
* Props that will be passed to the icon component. By default the icon's `scalesWithText`
|
|
@@ -79,5 +82,7 @@ IconText.propTypes = {
|
|
|
79
82
|
* `<Typography>` component, or a component that renders `<Text>`.
|
|
80
83
|
*/
|
|
81
84
|
children: PropTypes.node
|
|
85
|
+
/* eslint-enable react/no-unused-prop-types */
|
|
86
|
+
|
|
82
87
|
};
|
|
83
88
|
export default IconText;
|
|
@@ -3,7 +3,7 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
|
3
3
|
import Text from "react-native-web/dist/exports/Text";
|
|
4
4
|
import View from "react-native-web/dist/exports/View";
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { applyTextStyles, useThemeTokens } from '../ThemeProvider';
|
|
6
|
+
import { applyTextStyles, useTheme, useThemeTokens } from '../ThemeProvider';
|
|
7
7
|
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils';
|
|
8
8
|
import LabelContent from './LabelContent';
|
|
9
9
|
import Tooltip from '../Tooltip';
|
|
@@ -12,9 +12,11 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
14
14
|
|
|
15
|
-
const selectLabelStyles = tokens => applyTextStyles(selectTokens('Typography', tokens)
|
|
15
|
+
const selectLabelStyles = (tokens, themeOptions) => applyTextStyles({ ...selectTokens('Typography', tokens),
|
|
16
|
+
themeOptions
|
|
17
|
+
});
|
|
16
18
|
|
|
17
|
-
const selectHintStyles = _ref => {
|
|
19
|
+
const selectHintStyles = (_ref, themeOptions) => {
|
|
18
20
|
let {
|
|
19
21
|
hintColor,
|
|
20
22
|
hintFontName,
|
|
@@ -27,7 +29,8 @@ const selectHintStyles = _ref => {
|
|
|
27
29
|
fontName: hintFontName,
|
|
28
30
|
fontSize: hintFontSize,
|
|
29
31
|
fontWeight: hintFontWeight,
|
|
30
|
-
lineHeight: hintLineHeight
|
|
32
|
+
lineHeight: hintLineHeight,
|
|
33
|
+
themeOptions
|
|
31
34
|
});
|
|
32
35
|
};
|
|
33
36
|
|
|
@@ -56,19 +59,22 @@ const InputLabel = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
56
59
|
const themeTokens = useThemeTokens('InputLabel', tokens, variant);
|
|
57
60
|
const hasTooltip = tooltip !== undefined;
|
|
58
61
|
const isHintInline = hintPosition === 'inline';
|
|
62
|
+
const {
|
|
63
|
+
themeOptions
|
|
64
|
+
} = useTheme();
|
|
59
65
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
60
66
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
61
67
|
ref: ref,
|
|
62
68
|
style: staticStyles.container,
|
|
63
69
|
...selectProps(rest),
|
|
64
70
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
65
|
-
style: [selectLabelStyles(themeTokens), selectGapStyles(themeTokens), staticStyles.label],
|
|
71
|
+
style: [selectLabelStyles(themeTokens, themeOptions), selectGapStyles(themeTokens), staticStyles.label],
|
|
66
72
|
children: /*#__PURE__*/_jsx(LabelContent, {
|
|
67
73
|
forId: forId,
|
|
68
74
|
children: label
|
|
69
75
|
})
|
|
70
76
|
}), hint && isHintInline && /*#__PURE__*/_jsx(Text, {
|
|
71
|
-
style: [selectHintStyles(themeTokens), hasTooltip && selectGapStyles(themeTokens), staticStyles.label],
|
|
77
|
+
style: [selectHintStyles(themeTokens, themeOptions), hasTooltip && selectGapStyles(themeTokens), staticStyles.label],
|
|
72
78
|
nativeID: hintId,
|
|
73
79
|
children: hint
|
|
74
80
|
}), hasTooltip && /*#__PURE__*/_jsx(View, {
|
|
@@ -9,8 +9,6 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
|
9
9
|
* InlinePressable is an alternative to React Native's Pressable that works better when nested
|
|
10
10
|
* inline inside Text. It accepts the same props as React Native's Pressable.
|
|
11
11
|
*
|
|
12
|
-
* On Web it simply passes its props to Pressable and defaults to `inline-flex` instead of `flex`.
|
|
13
|
-
*
|
|
14
12
|
* @param {PressableProps} PressableProps
|
|
15
13
|
*/
|
|
16
14
|
// React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
|
|
@@ -21,12 +19,11 @@ const InlinePressable = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
21
19
|
let {
|
|
22
20
|
children,
|
|
23
21
|
style,
|
|
24
|
-
inline = false,
|
|
25
22
|
...props
|
|
26
23
|
} = _ref;
|
|
27
24
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
28
25
|
ref: ref,
|
|
29
|
-
style: pressState => [staticStyles
|
|
26
|
+
style: pressState => [staticStyles.inline, typeof style === 'function' ? style(pressState) : style],
|
|
30
27
|
...props,
|
|
31
28
|
children: pressState => typeof children === 'function' ? children(pressState) : children
|
|
32
29
|
});
|
|
@@ -34,11 +31,7 @@ const InlinePressable = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
34
31
|
InlinePressable.displayName = 'InlinePressable';
|
|
35
32
|
const staticStyles = StyleSheet.create({
|
|
36
33
|
inline: {
|
|
37
|
-
// Stop Pressable defaulting to (block) flex
|
|
38
34
|
display: 'inline'
|
|
39
|
-
},
|
|
40
|
-
inlineFlex: {
|
|
41
|
-
display: 'inline-flex'
|
|
42
35
|
}
|
|
43
36
|
});
|
|
44
37
|
export default InlinePressable;
|
|
@@ -7,12 +7,12 @@ import { a11yProps, clickProps, getTokensPropType, hrefAttrsProp, linkProps, sel
|
|
|
7
7
|
import { resolvePressableTokens } from '../utils/pressability';
|
|
8
8
|
import { withLinkRouter } from '../utils';
|
|
9
9
|
import InlinePressable from './InlinePressable';
|
|
10
|
-
import { applyTextStyles, applyOuterBorder } from '../ThemeProvider';
|
|
10
|
+
import { applyTextStyles, applyOuterBorder, useTheme } from '../ThemeProvider';
|
|
11
11
|
import { IconText, iconComponentPropTypes } from '../Icon';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps]);
|
|
14
14
|
|
|
15
|
-
const selectOuterBorderStyles = _ref => {
|
|
15
|
+
const selectOuterBorderStyles = (_ref, hasIcon) => {
|
|
16
16
|
let {
|
|
17
17
|
outerBorderColor,
|
|
18
18
|
outerBorderWidth,
|
|
@@ -33,7 +33,8 @@ const selectOuterBorderStyles = _ref => {
|
|
|
33
33
|
}),
|
|
34
34
|
// Stops focus ring stretching horizontally if parent has display: block
|
|
35
35
|
// width: fit-content isn't supported on Firefox; can't cascade props like CSS `width: fit-content; width: --moz-fit-content;`
|
|
36
|
-
display: 'inline-flex'
|
|
36
|
+
display: hasIcon ? 'inline-flex' : 'inline' // Stop Pressable defaulting to (block) flex
|
|
37
|
+
|
|
37
38
|
} : {}
|
|
38
39
|
);
|
|
39
40
|
};
|
|
@@ -53,7 +54,7 @@ const selectTextStyles = _ref2 => {
|
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
const selectBlockStyles = _ref3 => {
|
|
57
|
+
const selectBlockStyles = (_ref3, themeOptions) => {
|
|
57
58
|
let {
|
|
58
59
|
blockFontWeight,
|
|
59
60
|
blockFontSize,
|
|
@@ -64,7 +65,8 @@ const selectBlockStyles = _ref3 => {
|
|
|
64
65
|
fontWeight: blockFontWeight,
|
|
65
66
|
fontSize: blockFontSize,
|
|
66
67
|
lineHeight: blockLineHeight,
|
|
67
|
-
fontName: blockFontName
|
|
68
|
+
fontName: blockFontName,
|
|
69
|
+
themeOptions
|
|
68
70
|
});
|
|
69
71
|
};
|
|
70
72
|
|
|
@@ -164,15 +166,16 @@ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
|
164
166
|
const hasIcon = Boolean(icon || defaultThemeTokens.icon); // On web, this makes focus rings wrap only the link, not the entire block
|
|
165
167
|
|
|
166
168
|
const blockLeftStyle = Platform.OS === 'web' && staticStyles.blockLeft;
|
|
169
|
+
const {
|
|
170
|
+
themeOptions
|
|
171
|
+
} = useTheme();
|
|
167
172
|
return /*#__PURE__*/_jsx(InlinePressable, { ...selectedProps,
|
|
168
|
-
inline: hasIcon // assuming links without icons should be inline (even if they are long)
|
|
169
|
-
,
|
|
170
173
|
ref: ref,
|
|
171
174
|
style: linkState => {
|
|
172
175
|
const themeTokens = resolveLinkTokens(linkState);
|
|
173
|
-
const outerBorderStyles = selectOuterBorderStyles(themeTokens);
|
|
176
|
+
const outerBorderStyles = selectOuterBorderStyles(themeTokens, hasIcon);
|
|
174
177
|
const decorationStyles = selectDecorationStyles(themeTokens);
|
|
175
|
-
return [outerBorderStyles, blockLeftStyle, decorationStyles,
|
|
178
|
+
return [outerBorderStyles, blockLeftStyle, decorationStyles, staticStyles.rowContainer];
|
|
176
179
|
},
|
|
177
180
|
children: linkState => {
|
|
178
181
|
const themeTokens = resolveLinkTokens(linkState);
|
|
@@ -180,7 +183,7 @@ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
|
180
183
|
const iconTokens = selectIconTokens(themeTokens); // TODO: may need to apply some smarter text inheritance here if inline to avoid native
|
|
181
184
|
// issues like double-application of line heights breaking align-items: baseline
|
|
182
185
|
|
|
183
|
-
const blockTextStyles = selectBlockStyles(themeTokens);
|
|
186
|
+
const blockTextStyles = selectBlockStyles(themeTokens, themeOptions);
|
|
184
187
|
const IconComponent = icon || themeTokens.icon;
|
|
185
188
|
const {
|
|
186
189
|
iconSpace
|
|
@@ -214,7 +217,7 @@ LinkBase.propTypes = { ...selectedSystemPropTypes,
|
|
|
214
217
|
* A function component for an SVG icon to render inside the link. Inherits size and color from
|
|
215
218
|
* the link and any Typography the link is nested inside.
|
|
216
219
|
*/
|
|
217
|
-
icon: PropTypes.
|
|
220
|
+
icon: PropTypes.elementType,
|
|
218
221
|
|
|
219
222
|
/**
|
|
220
223
|
* When `icon` is provided, use `iconPosition` to place the Icon to the left or right side of Link.
|