@telus-uds/components-base 1.8.1 → 1.8.4
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 +35 -2
- package/component-docs.json +711 -669
- package/lib/A11yInfoProvider/index.js +4 -3
- package/lib/A11yText/index.js +6 -5
- package/lib/ActivityIndicator/Spinner.js +14 -13
- package/lib/ActivityIndicator/Spinner.native.js +10 -8
- package/lib/ActivityIndicator/index.js +6 -5
- package/lib/ActivityIndicator/shared.js +1 -1
- package/lib/BaseProvider/index.js +13 -10
- package/lib/Box/Box.js +20 -19
- package/lib/Button/Button.js +7 -6
- package/lib/Button/ButtonBase.js +97 -79
- package/lib/Button/ButtonGroup.js +34 -32
- package/lib/Button/ButtonLink.js +9 -7
- package/lib/Button/index.js +4 -4
- package/lib/Button/propTypes.js +1 -1
- package/lib/Card/Card.js +8 -7
- package/lib/Card/CardBase.js +35 -31
- package/lib/Card/PressableCardBase.js +14 -12
- package/lib/Checkbox/Checkbox.js +97 -83
- package/lib/Checkbox/CheckboxGroup.js +29 -27
- package/lib/Checkbox/CheckboxInput.js +12 -10
- package/lib/Divider/Divider.js +10 -9
- package/lib/ExpandCollapse/Control.js +42 -36
- package/lib/ExpandCollapse/ExpandCollapse.js +11 -10
- package/lib/ExpandCollapse/Panel.js +29 -40
- package/lib/Feedback/Feedback.js +48 -35
- package/lib/Fieldset/Fieldset.js +16 -15
- package/lib/Fieldset/FieldsetContainer.js +16 -13
- package/lib/Fieldset/FieldsetContainer.native.js +11 -8
- package/lib/Fieldset/Legend.js +10 -7
- package/lib/Fieldset/Legend.native.js +10 -7
- package/lib/FlexGrid/Col/Col.js +18 -17
- package/lib/FlexGrid/FlexGrid.js +15 -14
- package/lib/FlexGrid/Row/Row.js +13 -12
- package/lib/HorizontalScroll/HorizontalScroll.js +25 -20
- package/lib/HorizontalScroll/HorizontalScrollButton.js +18 -14
- package/lib/HorizontalScroll/ScrollViewEnd.js +6 -5
- package/lib/HorizontalScroll/ScrollViewEnd.native.js +12 -9
- package/lib/HorizontalScroll/itemPositions.js +19 -13
- package/lib/Icon/Icon.js +11 -10
- package/lib/Icon/IconText.js +8 -7
- package/lib/Icon/index.js +5 -5
- package/lib/IconButton/IconButton.js +50 -42
- package/lib/InputLabel/InputLabel.js +37 -30
- package/lib/InputLabel/LabelContent.js +12 -9
- package/lib/InputLabel/LabelContent.native.js +9 -6
- package/lib/InputSupports/InputSupports.js +11 -10
- package/lib/InputSupports/useInputSupports.js +7 -6
- package/lib/Link/ChevronLink.js +9 -8
- package/lib/Link/InlinePressable.js +13 -10
- package/lib/Link/InlinePressable.native.js +20 -16
- package/lib/Link/Link.js +10 -9
- package/lib/Link/LinkBase.js +96 -78
- package/lib/Link/TextButton.js +9 -8
- package/lib/List/List.js +20 -13
- package/lib/List/ListItem.js +103 -79
- package/lib/Modal/Modal.js +74 -60
- package/lib/Notification/Notification.js +46 -33
- package/lib/Pagination/PageButton.js +13 -12
- package/lib/Pagination/Pagination.js +43 -30
- package/lib/Pagination/SideButton.js +21 -18
- package/lib/Pagination/usePagination.js +7 -6
- package/lib/Progress/Progress.js +23 -19
- package/lib/Progress/ProgressBar.js +25 -21
- package/lib/Progress/ProgressBarBackground.js +7 -6
- package/lib/Radio/Radio.js +80 -69
- package/lib/Radio/RadioButton.js +63 -53
- package/lib/Radio/RadioGroup.js +30 -28
- package/lib/Radio/RadioInput.js +12 -10
- package/lib/RadioCard/RadioCard.js +16 -15
- package/lib/RadioCard/RadioCardGroup.js +30 -28
- package/lib/Search/Search.js +52 -32
- package/lib/Select/Group.js +5 -4
- package/lib/Select/Group.native.js +4 -3
- package/lib/Select/Item.js +10 -7
- package/lib/Select/Item.native.js +1 -9
- package/lib/Select/Picker.js +16 -15
- package/lib/Select/Picker.native.js +49 -38
- package/lib/Select/Select.js +134 -113
- package/lib/SideNav/Item.js +39 -33
- package/lib/SideNav/ItemContent.js +15 -12
- package/lib/SideNav/ItemsGroup.js +13 -11
- package/lib/SideNav/SideNav.js +21 -18
- package/lib/Skeleton/Skeleton.js +60 -44
- package/lib/Skeleton/skeleton.constant.js +1 -1
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/Spacer/Spacer.js +6 -5
- package/lib/StackView/StackView.js +12 -11
- package/lib/StackView/StackWrap.js +5 -3
- package/lib/StackView/StackWrapBox.js +12 -11
- package/lib/StackView/StackWrapGap.js +11 -10
- package/lib/StackView/common.js +14 -11
- package/lib/StackView/getStackedContent.js +10 -9
- package/lib/StackView/index.js +1 -1
- package/lib/StepTracker/Step.js +122 -103
- package/lib/StepTracker/StepTracker.js +48 -38
- package/lib/Tabs/Tabs.js +57 -27
- package/lib/Tabs/TabsItem.js +78 -68
- package/lib/Tags/Tags.js +68 -62
- package/lib/TextInput/TextArea.js +26 -20
- package/lib/TextInput/TextInput.js +20 -15
- package/lib/TextInput/TextInputBase.js +74 -62
- package/lib/TextInput/index.js +4 -4
- package/lib/ThemeProvider/ThemeProvider.js +6 -5
- package/lib/ThemeProvider/index.js +5 -5
- package/lib/ThemeProvider/useSetTheme.js +6 -3
- package/lib/ThemeProvider/useThemeTokens.js +7 -2
- package/lib/ThemeProvider/utils/styles.js +50 -43
- package/lib/ThemeProvider/utils/theme-tokens.js +33 -21
- package/lib/ToggleSwitch/ToggleSwitch.js +90 -74
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +37 -35
- package/lib/Tooltip/Backdrop.js +6 -13
- package/lib/Tooltip/Backdrop.native.js +5 -4
- package/lib/Tooltip/Tooltip.js +81 -65
- package/lib/Tooltip/getTooltipPosition.js +29 -18
- package/lib/TooltipButton/TooltipButton.js +28 -21
- package/lib/Typography/Typography.js +37 -33
- package/lib/ViewportProvider/ViewportProvider.js +4 -3
- package/lib/ViewportProvider/useViewportListener.js +6 -3
- package/lib/index.js +54 -54
- package/lib/utils/a11y/semantics.js +5 -2
- package/lib/utils/a11y/textSize.js +8 -6
- package/lib/utils/animation/useVerticalExpandAnimation.js +46 -19
- package/lib/utils/children.js +4 -3
- package/lib/utils/index.js +10 -10
- package/lib/utils/input.js +28 -29
- package/lib/utils/pressability.js +36 -22
- package/lib/utils/props/clickProps.js +2 -1
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/getPropSelector.js +6 -3
- package/lib/utils/props/handlerProps.js +25 -19
- package/lib/utils/props/hrefAttrsProp.js +14 -11
- package/lib/utils/props/index.js +12 -12
- package/lib/utils/props/inputSupportsProps.js +15 -12
- package/lib/utils/props/linkProps.js +7 -6
- package/lib/utils/props/pressProps.js +1 -1
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/tokens.js +29 -15
- package/lib/utils/ssr.js +6 -2
- package/lib/utils/useCopy.js +6 -4
- package/lib/utils/useHash.js +2 -1
- package/lib/utils/useResponsiveProp.js +1 -1
- package/lib/utils/useSpacingScale.js +3 -1
- package/lib/utils/useUniqueId.js +3 -2
- package/lib/utils/withLinkRouter.js +6 -5
- package/lib-module/A11yInfoProvider/index.js +4 -3
- package/lib-module/A11yText/index.js +6 -5
- package/lib-module/ActivityIndicator/Spinner.js +14 -13
- package/lib-module/ActivityIndicator/Spinner.native.js +9 -8
- package/lib-module/ActivityIndicator/index.js +6 -5
- package/lib-module/BaseProvider/index.js +13 -10
- package/lib-module/Box/Box.js +20 -19
- package/lib-module/Button/Button.js +7 -6
- package/lib-module/Button/ButtonBase.js +96 -79
- package/lib-module/Button/ButtonGroup.js +34 -32
- package/lib-module/Button/ButtonLink.js +8 -7
- package/lib-module/Card/Card.js +8 -7
- package/lib-module/Card/CardBase.js +35 -31
- package/lib-module/Card/PressableCardBase.js +12 -11
- package/lib-module/Checkbox/Checkbox.js +97 -83
- package/lib-module/Checkbox/CheckboxGroup.js +29 -27
- package/lib-module/Checkbox/CheckboxInput.js +12 -10
- package/lib-module/Divider/Divider.js +10 -9
- package/lib-module/ExpandCollapse/Control.js +42 -36
- package/lib-module/ExpandCollapse/ExpandCollapse.js +11 -10
- package/lib-module/ExpandCollapse/Panel.js +29 -37
- package/lib-module/Feedback/Feedback.js +46 -33
- package/lib-module/Fieldset/Fieldset.js +16 -15
- package/lib-module/Fieldset/FieldsetContainer.js +16 -13
- package/lib-module/Fieldset/FieldsetContainer.native.js +11 -8
- package/lib-module/Fieldset/Legend.js +10 -7
- package/lib-module/Fieldset/Legend.native.js +10 -7
- package/lib-module/FlexGrid/Col/Col.js +18 -17
- package/lib-module/FlexGrid/FlexGrid.js +15 -14
- package/lib-module/FlexGrid/Row/Row.js +13 -12
- package/lib-module/HorizontalScroll/HorizontalScroll.js +24 -19
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +18 -14
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +6 -5
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +12 -9
- package/lib-module/HorizontalScroll/itemPositions.js +18 -12
- package/lib-module/Icon/Icon.js +10 -9
- package/lib-module/Icon/IconText.js +9 -7
- package/lib-module/IconButton/IconButton.js +48 -41
- package/lib-module/InputLabel/InputLabel.js +37 -30
- package/lib-module/InputLabel/LabelContent.js +12 -9
- package/lib-module/InputLabel/LabelContent.native.js +9 -6
- package/lib-module/InputSupports/InputSupports.js +11 -10
- package/lib-module/InputSupports/useInputSupports.js +7 -6
- package/lib-module/Link/ChevronLink.js +9 -8
- package/lib-module/Link/InlinePressable.js +13 -10
- package/lib-module/Link/InlinePressable.native.js +20 -16
- package/lib-module/Link/Link.js +10 -9
- package/lib-module/Link/LinkBase.js +94 -77
- package/lib-module/Link/TextButton.js +9 -8
- package/lib-module/List/List.js +20 -13
- package/lib-module/List/ListItem.js +103 -78
- package/lib-module/Modal/Modal.js +74 -60
- package/lib-module/Notification/Notification.js +46 -33
- package/lib-module/Pagination/PageButton.js +13 -12
- package/lib-module/Pagination/Pagination.js +43 -30
- package/lib-module/Pagination/SideButton.js +21 -18
- package/lib-module/Pagination/usePagination.js +7 -6
- package/lib-module/Progress/Progress.js +23 -19
- package/lib-module/Progress/ProgressBar.js +25 -21
- package/lib-module/Progress/ProgressBarBackground.js +7 -6
- package/lib-module/Radio/Radio.js +80 -69
- package/lib-module/Radio/RadioButton.js +62 -52
- package/lib-module/Radio/RadioGroup.js +30 -28
- package/lib-module/Radio/RadioInput.js +12 -10
- package/lib-module/RadioCard/RadioCard.js +16 -15
- package/lib-module/RadioCard/RadioCardGroup.js +30 -28
- package/lib-module/Search/Search.js +52 -32
- package/lib-module/Select/Group.js +5 -4
- package/lib-module/Select/Group.native.js +4 -3
- package/lib-module/Select/Item.js +10 -7
- package/lib-module/Select/Item.native.js +1 -7
- package/lib-module/Select/Picker.js +16 -15
- package/lib-module/Select/Picker.native.js +46 -36
- package/lib-module/Select/Select.js +134 -113
- package/lib-module/SideNav/Item.js +39 -33
- package/lib-module/SideNav/ItemContent.js +14 -11
- package/lib-module/SideNav/ItemsGroup.js +13 -11
- package/lib-module/SideNav/SideNav.js +21 -18
- package/lib-module/Skeleton/Skeleton.js +60 -44
- package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib-module/Spacer/Spacer.js +6 -5
- package/lib-module/StackView/StackView.js +12 -11
- package/lib-module/StackView/StackWrap.js +5 -3
- package/lib-module/StackView/StackWrapBox.js +12 -11
- package/lib-module/StackView/StackWrapGap.js +11 -10
- package/lib-module/StackView/common.js +14 -11
- package/lib-module/StackView/getStackedContent.js +10 -9
- package/lib-module/StepTracker/Step.js +122 -103
- package/lib-module/StepTracker/StepTracker.js +48 -38
- package/lib-module/Tabs/Tabs.js +57 -27
- package/lib-module/Tabs/TabsItem.js +77 -68
- package/lib-module/Tags/Tags.js +68 -62
- package/lib-module/TextInput/TextArea.js +26 -20
- package/lib-module/TextInput/TextInput.js +19 -15
- package/lib-module/TextInput/TextInputBase.js +74 -62
- package/lib-module/ThemeProvider/ThemeProvider.js +5 -4
- package/lib-module/ThemeProvider/useSetTheme.js +6 -3
- package/lib-module/ThemeProvider/useThemeTokens.js +7 -2
- package/lib-module/ThemeProvider/utils/styles.js +48 -41
- package/lib-module/ThemeProvider/utils/theme-tokens.js +32 -20
- package/lib-module/ToggleSwitch/ToggleSwitch.js +90 -74
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +37 -35
- package/lib-module/Tooltip/Backdrop.js +6 -13
- package/lib-module/Tooltip/Backdrop.native.js +5 -4
- package/lib-module/Tooltip/Tooltip.js +81 -65
- package/lib-module/Tooltip/getTooltipPosition.js +29 -18
- package/lib-module/TooltipButton/TooltipButton.js +28 -21
- package/lib-module/Typography/Typography.js +35 -31
- package/lib-module/ViewportProvider/ViewportProvider.js +4 -3
- package/lib-module/ViewportProvider/useViewportListener.js +6 -3
- package/lib-module/utils/a11y/semantics.js +4 -1
- package/lib-module/utils/a11y/textSize.js +7 -5
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +47 -20
- package/lib-module/utils/children.js +4 -3
- package/lib-module/utils/input.js +28 -29
- package/lib-module/utils/pressability.js +35 -21
- package/lib-module/utils/props/clickProps.js +2 -1
- package/lib-module/utils/props/componentPropType.js +3 -3
- package/lib-module/utils/props/getPropSelector.js +6 -3
- package/lib-module/utils/props/handlerProps.js +24 -18
- package/lib-module/utils/props/hrefAttrsProp.js +14 -11
- package/lib-module/utils/props/inputSupportsProps.js +15 -12
- package/lib-module/utils/props/linkProps.js +7 -6
- package/lib-module/utils/props/selectSystemProps.js +2 -2
- package/lib-module/utils/props/tokens.js +27 -14
- package/lib-module/utils/ssr.js +5 -2
- package/lib-module/utils/useCopy.js +6 -4
- package/lib-module/utils/useHash.js +2 -1
- package/lib-module/utils/useSpacingScale.js +3 -1
- package/lib-module/utils/useUniqueId.js +3 -2
- package/lib-module/utils/withLinkRouter.js +6 -5
- package/package.json +13 -11
- package/src/ExpandCollapse/Panel.jsx +2 -19
- package/src/List/List.jsx +34 -19
- package/src/List/ListItem.jsx +12 -2
- package/src/Modal/Modal.jsx +2 -1
- package/src/Pagination/Pagination.jsx +3 -0
- package/src/Search/Search.jsx +11 -0
- package/src/Select/Item.native.jsx +0 -7
- package/src/Tabs/Tabs.jsx +24 -2
- package/src/Tabs/TabsItem.jsx +6 -5
- package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
6
6
|
import { fontBasePixels } from '@telus-uds/system-constants'; // Make design tokens fit React Native's text styles' specific requirements and quirks
|
|
7
7
|
|
|
8
|
-
export function applyTextStyles({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
export function applyTextStyles(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
fontSize,
|
|
11
|
+
fontScaleCap,
|
|
12
|
+
lineHeight,
|
|
13
|
+
letterSpacing,
|
|
14
|
+
fontWeight = '400',
|
|
15
|
+
fontName,
|
|
16
|
+
fontStyle = 'normal',
|
|
17
|
+
...rest
|
|
18
|
+
} = _ref;
|
|
18
19
|
const styles = { ...rest
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -36,7 +37,7 @@ export function applyTextStyles({
|
|
|
36
37
|
if (fontName) {
|
|
37
38
|
// Don't set undefined font families. May need some validation here that the font is available.
|
|
38
39
|
// Android doesn't recognise font weights natively so apply custom font weights via `fontFamily`.
|
|
39
|
-
styles.fontFamily =
|
|
40
|
+
styles.fontFamily = "".concat(fontName).concat(fontWeight).concat(fontStyle);
|
|
40
41
|
} else if (fontWeight) {
|
|
41
42
|
// If using system default font, apply the font weight directly.
|
|
42
43
|
// Font weight support in Android is limited to 'bold' or anything else === 'normal'.
|
|
@@ -72,17 +73,18 @@ export function applyShadowToken(shadowToken) {
|
|
|
72
73
|
return applyShadow();
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
function applyWebShadow({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
function applyWebShadow(_ref2) {
|
|
77
|
+
let {
|
|
78
|
+
inset,
|
|
79
|
+
color = '',
|
|
80
|
+
offsetX = 0,
|
|
81
|
+
offsetY = 0,
|
|
82
|
+
blur = 0,
|
|
83
|
+
spread = 0
|
|
84
|
+
} = _ref2;
|
|
83
85
|
const insetString = inset ? 'inset ' : '';
|
|
84
86
|
const boxShadow = {
|
|
85
|
-
boxShadow:
|
|
87
|
+
boxShadow: "".concat(insetString).concat(offsetX, "px ").concat(offsetY, "px ").concat(blur, "px ").concat(spread, "px ").concat(color)
|
|
86
88
|
};
|
|
87
89
|
return boxShadow;
|
|
88
90
|
}
|
|
@@ -111,14 +113,15 @@ function applyAndroidShadow(shadowToken) {
|
|
|
111
113
|
return {};
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
function applyIosShadow({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
function applyIosShadow(_ref3) {
|
|
117
|
+
let {
|
|
118
|
+
inset,
|
|
119
|
+
color,
|
|
120
|
+
offsetX,
|
|
121
|
+
offsetY,
|
|
122
|
+
spread,
|
|
123
|
+
blur
|
|
124
|
+
} = _ref3;
|
|
122
125
|
// React Native iOS doesn't support inset shadows.
|
|
123
126
|
// TODO: maybe use a library or workaround for inset shadows. This is a sizable task and would
|
|
124
127
|
// involve changing component implementations to use a custom view, can't be done with styles alone.
|
|
@@ -149,7 +152,8 @@ const verticalAlignToFlexRowAlign = {
|
|
|
149
152
|
middle: 'center',
|
|
150
153
|
bottom: 'flex-end'
|
|
151
154
|
};
|
|
152
|
-
export function verticalAlignRow(verticalAlign
|
|
155
|
+
export function verticalAlignRow(verticalAlign) {
|
|
156
|
+
let reverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
153
157
|
return {
|
|
154
158
|
flexDirection: reverse ? 'row-reverse' : 'row',
|
|
155
159
|
alignItems: verticalAlignToFlexRowAlign[verticalAlign]
|
|
@@ -160,15 +164,18 @@ export function verticalAlignRow(verticalAlign, reverse = false) {
|
|
|
160
164
|
* that matches the border radius of any inner border.
|
|
161
165
|
*/
|
|
162
166
|
|
|
163
|
-
export const applyOuterBorder =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
167
|
+
export const applyOuterBorder = _ref4 => {
|
|
168
|
+
let {
|
|
169
|
+
outerBorderColor,
|
|
170
|
+
outerBorderWidth = 0,
|
|
171
|
+
outerBorderGap = 0,
|
|
172
|
+
borderRadius = 0
|
|
173
|
+
} = _ref4;
|
|
174
|
+
return {
|
|
175
|
+
margin: 0 - outerBorderWidth - outerBorderGap,
|
|
176
|
+
padding: outerBorderGap,
|
|
177
|
+
borderRadius: borderRadius + outerBorderGap + outerBorderWidth,
|
|
178
|
+
borderWidth: outerBorderWidth,
|
|
179
|
+
borderColor: outerBorderColor
|
|
180
|
+
};
|
|
181
|
+
};
|
|
@@ -17,26 +17,29 @@ export const getComponentTheme = (theme, componentName) => {
|
|
|
17
17
|
// Give clear and understandable error messages for common dev errors, for example,
|
|
18
18
|
// typo in component name, missing export or accessing old version of theme
|
|
19
19
|
if (!theme) {
|
|
20
|
-
throw new Error(
|
|
20
|
+
throw new Error("Called useTheme's getStyle on \"".concat(componentName, "\" with no theme provided"));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const themeName = ((_theme$metadata = theme.metadata) === null || _theme$metadata === void 0 ? void 0 : _theme$metadata.name) || '';
|
|
24
24
|
|
|
25
25
|
if (!theme.components) {
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error("Theme \"".concat(themeName, "\" has no components defined (looking for \"").concat(componentName, "\")"));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const componentTheme = theme.components[componentName];
|
|
30
30
|
|
|
31
31
|
if (!componentTheme) {
|
|
32
|
-
throw new Error(
|
|
32
|
+
throw new Error("Theme \"".concat(themeName, "\" does not have styles for component \"").concat(componentName, "\""));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return componentTheme;
|
|
36
36
|
};
|
|
37
|
-
export const doesThemeConditionApply = (
|
|
37
|
+
export const doesThemeConditionApply = (_ref, appearances) => {
|
|
38
|
+
var _appearances$key;
|
|
39
|
+
|
|
40
|
+
let [key, value] = _ref;
|
|
38
41
|
// use null rather than undefined so we can serialise the value in themes
|
|
39
|
-
const appearanceValue = appearances[key]
|
|
42
|
+
const appearanceValue = (_appearances$key = appearances[key]) !== null && _appearances$key !== void 0 ? _appearances$key : null;
|
|
40
43
|
return Array.isArray(value) ? value.includes(appearanceValue) : value === appearanceValue;
|
|
41
44
|
};
|
|
42
45
|
export const doesThemeRuleApply = (rule, appearances) => Object.entries(rule.if).every(condition => doesThemeConditionApply(condition, appearances));
|
|
@@ -57,12 +60,18 @@ export const doesThemeRuleApply = (rule, appearances) => Object.entries(rule.if)
|
|
|
57
60
|
* @returns {TokensSet} - object containing resolved tokens with overrides applied
|
|
58
61
|
*/
|
|
59
62
|
|
|
60
|
-
export const resolveThemeTokens = (defaultTokens
|
|
63
|
+
export const resolveThemeTokens = function (defaultTokens) {
|
|
64
|
+
let appearances = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
65
|
+
let tokenOverrides = arguments.length > 2 ? arguments[2] : undefined;
|
|
66
|
+
|
|
61
67
|
const resolve = tokens => typeof tokens === 'function' ? tokens(appearances) : tokens;
|
|
62
68
|
|
|
63
69
|
if (!tokenOverrides) return resolve(defaultTokens);
|
|
64
|
-
return Object.entries(resolve(tokenOverrides)).reduce((mergedTokens,
|
|
65
|
-
[tokenName]
|
|
70
|
+
return Object.entries(resolve(tokenOverrides)).reduce((mergedTokens, _ref2) => {
|
|
71
|
+
let [tokenName, tokenValue] = _ref2;
|
|
72
|
+
return tokenValue === undefined ? mergedTokens : { ...mergedTokens,
|
|
73
|
+
[tokenName]: tokenValue
|
|
74
|
+
};
|
|
66
75
|
}, resolve(defaultTokens));
|
|
67
76
|
};
|
|
68
77
|
/**
|
|
@@ -95,9 +104,13 @@ export const validateThemeTokens = (themeTokens, validator, componentName) => {
|
|
|
95
104
|
* @returns {AppearanceSet}
|
|
96
105
|
*/
|
|
97
106
|
|
|
98
|
-
export const mergeAppearances = (
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
export const mergeAppearances = function () {
|
|
108
|
+
let variants = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
109
|
+
let states = arguments.length > 1 ? arguments[1] : undefined;
|
|
110
|
+
return states ? { ...states,
|
|
111
|
+
...variants
|
|
112
|
+
} : variants;
|
|
113
|
+
};
|
|
101
114
|
/**
|
|
102
115
|
* Get a set of theme tokens by applying a theme's component rules based on a component's variants and state.
|
|
103
116
|
*
|
|
@@ -110,10 +123,13 @@ export const mergeAppearances = (variants = {}, states) => states ? { ...states,
|
|
|
110
123
|
* @returns {object} Set of resolved theme tokens
|
|
111
124
|
*/
|
|
112
125
|
|
|
113
|
-
export const getThemeTokens = ({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
export const getThemeTokens = function (_ref3, tokensProp) {
|
|
127
|
+
let {
|
|
128
|
+
rules = [],
|
|
129
|
+
tokens: defaultThemeTokens = {}
|
|
130
|
+
} = _ref3;
|
|
131
|
+
let variants = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
132
|
+
let states = arguments.length > 3 ? arguments[3] : undefined;
|
|
117
133
|
const appearances = mergeAppearances(variants, states); // TODO: if in dev mode, validate the appearances and provided propTokens
|
|
118
134
|
// Get the theme's default tokens set and merge tokens from applicable theme rules over it
|
|
119
135
|
|
|
@@ -142,10 +158,6 @@ export const validateThemeTokensVersion = theme => {
|
|
|
142
158
|
const actualThemeTokensVersion = theme === null || theme === void 0 ? void 0 : (_theme$metadata2 = theme.metadata) === null || _theme$metadata2 === void 0 ? void 0 : _theme$metadata2.themeTokensVersion;
|
|
143
159
|
|
|
144
160
|
if (!semVerSatisfies(actualThemeTokensVersion, expectedThemeTokensVersion)) {
|
|
145
|
-
throw new Error(
|
|
146
|
-
|
|
147
|
-
The UDS base components ${pkg.name} v${pkg.version} are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ${expectedThemeTokensVersion}. The current theme was built with @telus-uds/system-theme-tokens v${actualThemeTokensVersion}.
|
|
148
|
-
|
|
149
|
-
If you see this error than most likely you have attempted to install ${pkg.name} and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/packages/docs-uds/docs/multi-brand-usage.md`);
|
|
161
|
+
throw new Error("Invalid UDS token schema version detected.\n\nThe UDS base components ".concat(pkg.name, " v").concat(pkg.version, " are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ").concat(expectedThemeTokensVersion, ". The current theme was built with @telus-uds/system-theme-tokens v").concat(actualThemeTokensVersion, ".\n\nIf you see this error than most likely you have attempted to install ").concat(pkg.name, " and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/packages/docs-uds/docs/multi-brand-usage.md"));
|
|
150
162
|
}
|
|
151
163
|
};
|
|
@@ -19,84 +19,100 @@ const selectButtonTokens = tokens => selectTokens('Button', { ...tokens,
|
|
|
19
19
|
}); // Map and rename icon-specific tokens to name used within Icon
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
const selectIconTokens =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const selectIconTokens = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
iconSize,
|
|
25
|
+
iconColor
|
|
26
|
+
} = _ref;
|
|
27
|
+
return {
|
|
28
|
+
size: iconSize,
|
|
29
|
+
color: iconColor
|
|
30
|
+
};
|
|
31
|
+
};
|
|
29
32
|
|
|
30
|
-
const selectTrackStyles =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const selectTrackStyles = _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
trackBorderWidth,
|
|
36
|
+
trackBorderColor,
|
|
37
|
+
trackBorderRadius,
|
|
38
|
+
width
|
|
39
|
+
} = _ref2;
|
|
40
|
+
return {
|
|
41
|
+
borderWidth: trackBorderWidth,
|
|
42
|
+
borderColor: trackBorderColor,
|
|
43
|
+
borderRadius: trackBorderRadius,
|
|
44
|
+
width
|
|
45
|
+
};
|
|
46
|
+
};
|
|
41
47
|
|
|
42
|
-
const selectSwitchStyles =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
48
|
+
const selectSwitchStyles = _ref3 => {
|
|
49
|
+
let {
|
|
50
|
+
switchSize,
|
|
51
|
+
switchColor,
|
|
52
|
+
switchBorderWidth,
|
|
53
|
+
switchBorderColor,
|
|
54
|
+
switchBorderRadius,
|
|
55
|
+
switchShadow
|
|
56
|
+
} = _ref3;
|
|
57
|
+
return {
|
|
58
|
+
width: switchSize,
|
|
59
|
+
height: switchSize,
|
|
60
|
+
backgroundColor: switchColor,
|
|
61
|
+
borderWidth: switchBorderWidth,
|
|
62
|
+
borderColor: switchBorderColor,
|
|
63
|
+
borderRadius: switchBorderRadius,
|
|
64
|
+
...applyShadowToken(switchShadow),
|
|
65
|
+
...Platform.select({
|
|
66
|
+
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
67
|
+
web: {
|
|
68
|
+
transition: 'transform 200ms'
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
};
|
|
64
73
|
|
|
65
|
-
const selectLabelStyles =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
const selectLabelStyles = _ref4 => {
|
|
75
|
+
let {
|
|
76
|
+
labelMarginLeft
|
|
77
|
+
} = _ref4;
|
|
78
|
+
return {
|
|
79
|
+
marginLeft: labelMarginLeft
|
|
80
|
+
};
|
|
81
|
+
};
|
|
70
82
|
|
|
71
|
-
const selectLabelTokens =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
const selectLabelTokens = _ref5 => {
|
|
84
|
+
let {
|
|
85
|
+
labelColor,
|
|
86
|
+
labelFontName,
|
|
87
|
+
labelFontSize,
|
|
88
|
+
labelFontWeight,
|
|
89
|
+
labelLineHeight
|
|
90
|
+
} = _ref5;
|
|
91
|
+
return {
|
|
92
|
+
color: labelColor,
|
|
93
|
+
fontName: labelFontName,
|
|
94
|
+
fontWeight: labelFontWeight,
|
|
95
|
+
fontSize: labelFontSize,
|
|
96
|
+
lineHeight: labelLineHeight
|
|
97
|
+
};
|
|
98
|
+
};
|
|
84
99
|
|
|
85
|
-
const ToggleSwitch = /*#__PURE__*/forwardRef(({
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
const ToggleSwitch = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
101
|
+
let {
|
|
102
|
+
copy = 'en',
|
|
103
|
+
value,
|
|
104
|
+
initialValue,
|
|
105
|
+
onChange,
|
|
106
|
+
id,
|
|
107
|
+
label,
|
|
108
|
+
inactive,
|
|
109
|
+
tokens,
|
|
110
|
+
tooltip,
|
|
111
|
+
variant,
|
|
112
|
+
accessibilityRole = 'switch',
|
|
113
|
+
accessibilityLabel = label,
|
|
114
|
+
...rest
|
|
115
|
+
} = _ref6;
|
|
100
116
|
const getTokens = useThemeTokensCallback('ToggleSwitch', tokens, variant);
|
|
101
117
|
const themeTokens = getTokens();
|
|
102
118
|
const {
|
|
@@ -113,7 +129,7 @@ const ToggleSwitch = /*#__PURE__*/forwardRef(({
|
|
|
113
129
|
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
|
|
114
130
|
|
|
115
131
|
const uniqueId = useUniqueId('toggleSwitch');
|
|
116
|
-
const inputId = id
|
|
132
|
+
const inputId = id !== null && id !== void 0 ? id : uniqueId;
|
|
117
133
|
return /*#__PURE__*/_jsxs(StackView, {
|
|
118
134
|
space: 2,
|
|
119
135
|
direction: "row",
|
|
@@ -11,31 +11,32 @@ import { a11yProps, containUniqueFields, focusHandlerProps, getTokensPropType, s
|
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
13
13
|
const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
|
|
14
|
-
const ToggleSwitchGroup = /*#__PURE__*/forwardRef(({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
const ToggleSwitchGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
15
|
+
let {
|
|
16
|
+
copy = 'en',
|
|
17
|
+
variant,
|
|
18
|
+
tokens,
|
|
19
|
+
items = [],
|
|
20
|
+
values,
|
|
21
|
+
initialValues,
|
|
22
|
+
maxValues = 1,
|
|
23
|
+
onChange,
|
|
24
|
+
readOnly = false,
|
|
25
|
+
inactive = false,
|
|
26
|
+
feedback,
|
|
27
|
+
hint,
|
|
28
|
+
tooltip,
|
|
29
|
+
legend,
|
|
30
|
+
name: inputGroupName,
|
|
31
|
+
accessibilityRole = maxValues === 1 ? 'radiogroup' // radiogroup is cross-platform; only web aria has generic groups
|
|
32
|
+
: Platform.select({
|
|
33
|
+
web: 'group',
|
|
34
|
+
default: 'none'
|
|
35
|
+
}),
|
|
36
|
+
toggleSwitchTokens,
|
|
37
|
+
validation,
|
|
38
|
+
...rest
|
|
39
|
+
} = _ref;
|
|
39
40
|
const viewport = useViewport();
|
|
40
41
|
const {
|
|
41
42
|
space,
|
|
@@ -61,18 +62,19 @@ const ToggleSwitchGroup = /*#__PURE__*/forwardRef(({
|
|
|
61
62
|
const uniqueFields = ['id', 'label'];
|
|
62
63
|
|
|
63
64
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
64
|
-
throw new Error(
|
|
65
|
+
throw new Error("ToggleSwitchGroup items must have unique ".concat(uniqueFields.join(', ')));
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
const toggleSwitches = items.map(({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
const toggleSwitches = items.map((_ref2, index) => {
|
|
69
|
+
let {
|
|
70
|
+
label,
|
|
71
|
+
id = label,
|
|
72
|
+
accessibilityLabel = label,
|
|
73
|
+
onChange: itemOnChange,
|
|
74
|
+
ref: itemRef,
|
|
75
|
+
tooltip: itemTooltip,
|
|
76
|
+
...itemRest
|
|
77
|
+
} = _ref2;
|
|
76
78
|
const isSelected = currentValues.includes(id);
|
|
77
79
|
|
|
78
80
|
const handleChange = (newCheckedState, event) => {
|
|
@@ -8,15 +8,7 @@ function createPortalNode(nodeId) {
|
|
|
8
8
|
// this way the backdrop stays in place when scrolling the window - that's why we need to
|
|
9
9
|
// position it at the scroll position when rendering
|
|
10
10
|
|
|
11
|
-
node.style.cssText =
|
|
12
|
-
position: absolute;
|
|
13
|
-
top: ${window.scrollY}px;
|
|
14
|
-
left: ${window.scrollX}px;
|
|
15
|
-
right: 0;
|
|
16
|
-
bottom: 0;
|
|
17
|
-
z-index: 9999;
|
|
18
|
-
pointer-events: none;
|
|
19
|
-
`;
|
|
11
|
+
node.style.cssText = "\n position: absolute; \n top: ".concat(window.scrollY, "px;\n left: ").concat(window.scrollX, "px; \n right: 0; \n bottom: 0; \n z-index: 9999; \n pointer-events: none;\n ");
|
|
20
12
|
document.body.appendChild(node);
|
|
21
13
|
return node;
|
|
22
14
|
}
|
|
@@ -31,12 +23,13 @@ function removePortalNode(nodeId) {
|
|
|
31
23
|
*/
|
|
32
24
|
|
|
33
25
|
|
|
34
|
-
function Backdrop({
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
function Backdrop(_ref) {
|
|
27
|
+
let {
|
|
28
|
+
children
|
|
29
|
+
} = _ref;
|
|
37
30
|
const [portalNode, setPortalNode] = useState();
|
|
38
31
|
useEffect(() => {
|
|
39
|
-
const nodeId =
|
|
32
|
+
const nodeId = "tooltip-backdrop-".concat(Date.now());
|
|
40
33
|
const node = createPortalNode(nodeId);
|
|
41
34
|
setPortalNode(node);
|
|
42
35
|
return () => {
|
|
@@ -13,10 +13,11 @@ import PropTypes from 'prop-types';
|
|
|
13
13
|
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
|
|
16
|
-
function Backdrop({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function Backdrop(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
onPress,
|
|
19
|
+
children
|
|
20
|
+
} = _ref;
|
|
20
21
|
return /*#__PURE__*/_jsx(Modal, {
|
|
21
22
|
transparent: true,
|
|
22
23
|
children: /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|