@telus-uds/components-base 1.18.1 → 1.19.1
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 +22 -2
- package/component-docs.json +111 -16
- package/jest.config-android.js +17 -0
- package/jest.config-ios.js +18 -0
- package/jest.config-web.js +31 -0
- package/lib/ActivityIndicator/Spinner.js +7 -7
- package/lib/ActivityIndicator/Spinner.native.js +2 -2
- package/lib/BaseProvider/HydrationContext.js +1 -1
- package/lib/BaseProvider/TamaguiProvider.js +30 -0
- package/lib/Button/ButtonBase.js +8 -4
- package/lib/Button/ButtonDropdown.js +207 -0
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Carousel/Carousel.js +31 -5
- package/lib/Carousel/CarouselContext.js +1 -1
- package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
- package/lib/Carousel/CarouselThumbnail.js +2 -2
- package/lib/Checkbox/Checkbox.js +1 -1
- package/lib/Checkbox/CheckboxGroup.js +2 -2
- package/lib/Divider/Divider.js +2 -2
- package/lib/FlexGrid/Col/Col.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/MultiSelectFilter/ModalOverlay.js +136 -0
- package/lib/MultiSelectFilter/MultiSelectFilter.js +314 -0
- package/lib/MultiSelectFilter/dictionary.js +19 -0
- package/lib/MultiSelectFilter/index.js +13 -0
- package/lib/Pagination/PageButton.js +2 -2
- package/lib/Pagination/Pagination.js +3 -5
- package/lib/Pagination/SideButton.js +6 -4
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/ProgressBar.js +3 -3
- package/lib/Progress/ProgressBarBackground.js +3 -3
- package/lib/QuickLinksFeature/QuickLinksFeature.js +91 -0
- package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +157 -0
- package/lib/QuickLinksFeature/index.js +16 -0
- 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/Responsive/Responsive.js +58 -0
- package/lib/Responsive/index.js +13 -0
- package/lib/Search/Search.js +30 -63
- package/lib/Select/constants.js +15 -0
- 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 +1 -3
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/Tabs/Tabs.js +2 -4
- package/lib/Tags/Tags.js +11 -5
- package/lib/TextInput/TextInputBase.js +53 -19
- package/lib/TextInput/dictionary.js +19 -0
- package/lib/ThemeProvider/utils/styles.js +3 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib/Timeline/Timeline.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib/Tooltip/Backdrop.js +10 -2
- package/lib/Tooltip/Tooltip.native.js +357 -0
- package/lib/Tooltip/shared.js +39 -0
- package/lib/Validator/Validator.js +271 -0
- package/lib/Validator/index.js +13 -0
- package/lib/index.js +9 -0
- package/lib/utils/BaseView/BaseView.js +64 -0
- package/lib/utils/BaseView/BaseView.native.js +16 -0
- package/lib/utils/BaseView/index.js +13 -0
- package/lib/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib/utils/children.js +2 -2
- package/lib/utils/floating-ui/index.js +43 -0
- package/lib/utils/floating-ui/index.native.js +43 -0
- package/lib/utils/input.js +12 -6
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/tokens.js +2 -2
- package/lib/utils/useOverlaidPosition.js +243 -0
- package/lib/utils/useSpacingScale.js +1 -3
- package/lib/utils/useUniqueId.js +1 -1
- package/lib-module/ActivityIndicator/Spinner.js +7 -7
- package/lib-module/ActivityIndicator/Spinner.native.js +2 -2
- package/lib-module/BaseProvider/HydrationContext.js +1 -1
- package/lib-module/BaseProvider/TamaguiProvider.js +22 -0
- package/lib-module/Button/ButtonBase.js +8 -4
- package/lib-module/Button/ButtonDropdown.js +181 -0
- package/lib-module/Button/ButtonGroup.js +1 -1
- package/lib-module/Carousel/Carousel.js +31 -5
- package/lib-module/Carousel/CarouselContext.js +1 -1
- package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
- package/lib-module/Carousel/CarouselThumbnail.js +2 -2
- package/lib-module/Checkbox/Checkbox.js +1 -1
- package/lib-module/Checkbox/CheckboxGroup.js +2 -2
- package/lib-module/Divider/Divider.js +2 -2
- package/lib-module/FlexGrid/Col/Col.js +1 -1
- package/lib-module/Icon/Icon.js +1 -1
- package/lib-module/MultiSelectFilter/ModalOverlay.js +112 -0
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +286 -0
- package/lib-module/MultiSelectFilter/dictionary.js +12 -0
- package/lib-module/MultiSelectFilter/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +2 -2
- package/lib-module/Pagination/Pagination.js +3 -5
- package/lib-module/Pagination/SideButton.js +6 -4
- package/lib-module/Pagination/usePagination.js +2 -2
- package/lib-module/Progress/ProgressBar.js +3 -3
- package/lib-module/Progress/ProgressBarBackground.js +3 -3
- package/lib-module/QuickLinksFeature/QuickLinksFeature.js +69 -0
- package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +130 -0
- package/lib-module/QuickLinksFeature/index.js +4 -0
- package/lib-module/Radio/Radio.js +2 -2
- package/lib-module/Radio/RadioGroup.js +2 -2
- package/lib-module/RadioCard/RadioCard.js +1 -1
- package/lib-module/RadioCard/RadioCardGroup.js +2 -2
- package/lib-module/Responsive/Responsive.js +45 -0
- package/lib-module/Responsive/index.js +2 -0
- package/lib-module/Search/Search.js +30 -61
- package/lib-module/Select/constants.js +5 -0
- package/lib-module/SideNav/SideNav.js +2 -2
- package/lib-module/Skeleton/Skeleton.js +1 -1
- package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib-module/StackView/StackWrap.js +1 -3
- package/lib-module/StackView/getStackedContent.js +2 -2
- package/lib-module/Tabs/Tabs.js +2 -4
- package/lib-module/Tags/Tags.js +11 -5
- package/lib-module/TextInput/TextInputBase.js +52 -19
- package/lib-module/TextInput/dictionary.js +12 -0
- package/lib-module/ThemeProvider/utils/styles.js +3 -3
- package/lib-module/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib-module/Timeline/Timeline.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib-module/Tooltip/Backdrop.js +10 -2
- package/lib-module/Tooltip/Tooltip.native.js +326 -0
- package/lib-module/Tooltip/shared.js +27 -0
- package/lib-module/Validator/Validator.js +245 -0
- package/lib-module/Validator/index.js +2 -0
- package/lib-module/index.js +1 -0
- package/lib-module/utils/BaseView/BaseView.js +43 -0
- package/lib-module/utils/BaseView/BaseView.native.js +6 -0
- package/lib-module/utils/BaseView/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib-module/utils/children.js +2 -2
- package/lib-module/utils/floating-ui/index.js +1 -0
- package/lib-module/utils/floating-ui/index.native.js +1 -0
- package/lib-module/utils/input.js +12 -6
- package/lib-module/utils/props/componentPropType.js +3 -3
- package/lib-module/utils/props/selectSystemProps.js +2 -2
- package/lib-module/utils/props/tokens.js +2 -2
- package/lib-module/utils/useOverlaidPosition.js +232 -0
- package/lib-module/utils/useSpacingScale.js +1 -3
- package/lib-module/utils/useUniqueId.js +1 -1
- package/package.json +7 -4
- package/src/Button/ButtonBase.jsx +4 -2
- package/src/Carousel/Carousel.jsx +42 -10
- package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +0 -10
- package/src/Pagination/SideButton.jsx +5 -5
- package/src/Responsive/Responsive.jsx +33 -0
- package/src/Responsive/index.js +3 -0
- package/src/Search/Search.jsx +17 -32
- package/src/Tags/Tags.jsx +46 -33
- package/src/TextInput/TextInputBase.jsx +46 -16
- package/src/index.js +1 -0
|
@@ -67,7 +67,7 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const direction = index ? -1 : +1;
|
|
70
|
-
return
|
|
70
|
+
return `${direction * (180 - (sa + ea)) * easing(progress) + rotation}deg`;
|
|
71
71
|
});
|
|
72
72
|
const layerStyle = {
|
|
73
73
|
width: size,
|
|
@@ -82,7 +82,7 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
82
82
|
layerStyle.transform = [{
|
|
83
83
|
rotate: timer.interpolate({
|
|
84
84
|
inputRange: [0, 1],
|
|
85
|
-
outputRange: [
|
|
85
|
+
outputRange: [`${0 + ea + sa}deg`, `${2 * 360 + ea + sa}deg`]
|
|
86
86
|
})
|
|
87
87
|
}];
|
|
88
88
|
viewportStyle.transform = [{
|
|
@@ -39,7 +39,7 @@ export const HydrationProvider = _ref => {
|
|
|
39
39
|
}, []); // If we've got a HydrationProvider inside a HydrationProvider somehow, defer to the top one
|
|
40
40
|
|
|
41
41
|
const valueFromAncestor = useHydrationContext();
|
|
42
|
-
const isHydrating = valueFromAncestor
|
|
42
|
+
const isHydrating = valueFromAncestor ?? Boolean(!hasMounted && hasWebStyleTag());
|
|
43
43
|
return /*#__PURE__*/_jsx(HydrationContext.Provider, {
|
|
44
44
|
value: isHydrating,
|
|
45
45
|
children: children
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { TamaguiProvider, config } from '@telus-uds/components-multi-platform';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const TamaguiWrapper = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
extended,
|
|
8
|
+
children
|
|
9
|
+
} = _ref;
|
|
10
|
+
console.log('extended', extended);
|
|
11
|
+
return extended ? /*#__PURE__*/_jsx(TamaguiProvider, {
|
|
12
|
+
config: config,
|
|
13
|
+
disableInjectCSS: true,
|
|
14
|
+
defaultTheme: "light",
|
|
15
|
+
children: children
|
|
16
|
+
}) : children;
|
|
17
|
+
};
|
|
18
|
+
TamaguiWrapper.propTypes = {
|
|
19
|
+
children: PropTypes.node.isRequired,
|
|
20
|
+
extended: PropTypes.bool
|
|
21
|
+
};
|
|
22
|
+
export default TamaguiWrapper;
|
|
@@ -76,7 +76,7 @@ const selectOuterWidthStyles = _ref3 => {
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
if (Platform.OS === 'web') {
|
|
79
|
-
widthStyles.width =
|
|
79
|
+
widthStyles.width = `calc(${width} + ${outerBorderOffset * 2}px)`;
|
|
80
80
|
return widthStyles;
|
|
81
81
|
} // Can't use calc() on native but (unlike on web) flexGrow fills the container width here
|
|
82
82
|
|
|
@@ -139,7 +139,9 @@ const selectTextStyles = (_ref6, themeOptions) => {
|
|
|
139
139
|
lineHeight,
|
|
140
140
|
fontName,
|
|
141
141
|
fontWeight,
|
|
142
|
-
textAlign
|
|
142
|
+
textAlign,
|
|
143
|
+
textLine,
|
|
144
|
+
textLineStyle
|
|
143
145
|
} = _ref6;
|
|
144
146
|
return applyTextStyles({
|
|
145
147
|
fontSize,
|
|
@@ -148,7 +150,9 @@ const selectTextStyles = (_ref6, themeOptions) => {
|
|
|
148
150
|
fontName,
|
|
149
151
|
fontWeight,
|
|
150
152
|
themeOptions,
|
|
151
|
-
textAlign
|
|
153
|
+
textAlign,
|
|
154
|
+
textDecorationLine: textLine,
|
|
155
|
+
textDecorationStyle: textLineStyle
|
|
152
156
|
});
|
|
153
157
|
};
|
|
154
158
|
|
|
@@ -159,7 +163,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref7) => {
|
|
|
159
163
|
return Platform.select({
|
|
160
164
|
web: {
|
|
161
165
|
// if it would overflow the container, wraps instead
|
|
162
|
-
maxWidth:
|
|
166
|
+
maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
|
|
163
167
|
outline: 'none',
|
|
164
168
|
// removes the default browser :focus outline
|
|
165
169
|
...getCursorStyle(inactive, accessibilityRole)
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
5
|
+
import View from "react-native-web/dist/exports/View";
|
|
6
|
+
import buttonPropTypes, { textAndA11yText } from './propTypes';
|
|
7
|
+
import ButtonBase from './ButtonBase';
|
|
8
|
+
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
9
|
+
import { a11yProps, focusHandlerProps, resolvePressableState, selectTokens, useInputValue } from '../utils';
|
|
10
|
+
import Icon from '../Icon';
|
|
11
|
+
import { getStackedContent } from '../StackView';
|
|
12
|
+
import { getPressHandlersWithArgs } from '../utils/pressability';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
|
|
15
|
+
const selectIconTokens = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
icon,
|
|
18
|
+
iconPosition,
|
|
19
|
+
iconSpace,
|
|
20
|
+
iconSize,
|
|
21
|
+
iconColor,
|
|
22
|
+
iconBackground,
|
|
23
|
+
iconBorderRadius,
|
|
24
|
+
iconAlignSelf,
|
|
25
|
+
iconPadding,
|
|
26
|
+
iconTranslateX,
|
|
27
|
+
iconTranslateY
|
|
28
|
+
} = _ref;
|
|
29
|
+
return {
|
|
30
|
+
icon,
|
|
31
|
+
iconPosition,
|
|
32
|
+
iconSpace,
|
|
33
|
+
iconWrapperStyle: {
|
|
34
|
+
backgroundColor: iconBackground,
|
|
35
|
+
borderRadius: iconBorderRadius,
|
|
36
|
+
alignSelf: iconAlignSelf,
|
|
37
|
+
padding: iconPadding,
|
|
38
|
+
...Platform.select({
|
|
39
|
+
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
40
|
+
web: {
|
|
41
|
+
transition: 'color 200ms, background 200ms'
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
iconTokens: {
|
|
46
|
+
size: iconSize,
|
|
47
|
+
color: iconColor,
|
|
48
|
+
translateX: iconTranslateX,
|
|
49
|
+
translateY: iconTranslateY
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const ButtonDropdown = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
55
|
+
let {
|
|
56
|
+
value,
|
|
57
|
+
initialValue,
|
|
58
|
+
onChange,
|
|
59
|
+
label,
|
|
60
|
+
tokens,
|
|
61
|
+
variant,
|
|
62
|
+
inactive = false,
|
|
63
|
+
readOnly = false,
|
|
64
|
+
children = null,
|
|
65
|
+
accessibilityRole = 'radio',
|
|
66
|
+
...props
|
|
67
|
+
} = _ref2;
|
|
68
|
+
const {
|
|
69
|
+
currentValue: isOpen,
|
|
70
|
+
setValue: setIsOpen
|
|
71
|
+
} = useInputValue({
|
|
72
|
+
value,
|
|
73
|
+
initialValue,
|
|
74
|
+
onChange,
|
|
75
|
+
readOnly
|
|
76
|
+
}, 'useButtonDropdownValues');
|
|
77
|
+
const extraState = {
|
|
78
|
+
open: isOpen,
|
|
79
|
+
inactive,
|
|
80
|
+
...variant
|
|
81
|
+
};
|
|
82
|
+
const getTokens = useThemeTokensCallback('ButtonDropdown', tokens, extraState);
|
|
83
|
+
|
|
84
|
+
const getButtonTokens = buttonState => selectTokens('Button', getTokens(buttonState)); // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const pressHandlers = getPressHandlersWithArgs(props, [{
|
|
88
|
+
label,
|
|
89
|
+
open: isOpen
|
|
90
|
+
}]);
|
|
91
|
+
|
|
92
|
+
const handlePress = event => {
|
|
93
|
+
if (!inactive) {
|
|
94
|
+
if (pressHandlers.onPress) pressHandlers === null || pressHandlers === void 0 ? void 0 : pressHandlers.onPress(event);
|
|
95
|
+
setIsOpen(!isOpen, event);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return /*#__PURE__*/_jsx(ButtonBase, {
|
|
100
|
+
ref: ref,
|
|
101
|
+
...pressHandlers,
|
|
102
|
+
onPress: handlePress,
|
|
103
|
+
tokens: getButtonTokens,
|
|
104
|
+
inactive: inactive,
|
|
105
|
+
icon: () => null,
|
|
106
|
+
accessibilityRole: accessibilityRole,
|
|
107
|
+
...props,
|
|
108
|
+
children: _ref3 => {
|
|
109
|
+
let {
|
|
110
|
+
textStyles,
|
|
111
|
+
...buttonState
|
|
112
|
+
} = _ref3;
|
|
113
|
+
// TODO: once Icon/IconButton designs are stable, see if this sort of styling around
|
|
114
|
+
// an icon should go in Icon itself, or possibly via an IconText token set. Related issues:
|
|
115
|
+
// - Icon: https://github.com/telus/universal-design-system/issues/327
|
|
116
|
+
// - IconButton: https://github.com/telus/universal-design-system/issues/281
|
|
117
|
+
// - Token sets: https://github.com/telus/universal-design-system/issues/782
|
|
118
|
+
const itemTokens = getTokens(buttonState);
|
|
119
|
+
const {
|
|
120
|
+
iconTokens,
|
|
121
|
+
iconPosition,
|
|
122
|
+
iconSpace,
|
|
123
|
+
iconWrapperStyle,
|
|
124
|
+
icon: IconComponent
|
|
125
|
+
} = selectIconTokens(itemTokens);
|
|
126
|
+
const iconContent = IconComponent ? /*#__PURE__*/_jsx(View, {
|
|
127
|
+
style: iconWrapperStyle,
|
|
128
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
129
|
+
icon: IconComponent,
|
|
130
|
+
tokens: iconTokens
|
|
131
|
+
})
|
|
132
|
+
}) : null;
|
|
133
|
+
|
|
134
|
+
const childrenContent = () => typeof children === 'function' ? children({ ...resolvePressableState(buttonState, extraState),
|
|
135
|
+
textStyles
|
|
136
|
+
}) : children;
|
|
137
|
+
|
|
138
|
+
const content = children ? childrenContent() : /*#__PURE__*/_jsx(Text, {
|
|
139
|
+
style: textStyles,
|
|
140
|
+
children: label
|
|
141
|
+
});
|
|
142
|
+
return getStackedContent(iconPosition === 'left' ? [iconContent, content] : [content, iconContent], {
|
|
143
|
+
space: iconSpace,
|
|
144
|
+
direction: 'row'
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
ButtonDropdown.displayName = 'ButtonDropdown';
|
|
150
|
+
ButtonDropdown.propTypes = { ...a11yProps.types,
|
|
151
|
+
...focusHandlerProps.types,
|
|
152
|
+
...buttonPropTypes,
|
|
153
|
+
children: textAndA11yText,
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Callback called when a controlled ButtonDropdown gets interacted with.
|
|
157
|
+
*/
|
|
158
|
+
onChange: PropTypes.func,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* `value` prop is being used to set the 'open' state of ButtonDropdown. Use it for
|
|
162
|
+
* controlled ButtonDropdown. For uncontrolled ButtonDropdown, use `initialValue`.
|
|
163
|
+
*/
|
|
164
|
+
value: PropTypes.bool,
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Use `initialValue` to provide the initial value for an uncontrolled version.
|
|
168
|
+
*/
|
|
169
|
+
initialValue: PropTypes.bool,
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The label of ButtonDropdown.
|
|
173
|
+
*/
|
|
174
|
+
label: PropTypes.string,
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* By default, `ButtonDropdown` is treated by accessibility tools as a radio button.
|
|
178
|
+
*/
|
|
179
|
+
accessibilityRole: PropTypes.string
|
|
180
|
+
};
|
|
181
|
+
export default ButtonDropdown;
|
|
@@ -67,7 +67,7 @@ const ButtonGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
67
67
|
const uniqueFields = ['id', 'label'];
|
|
68
68
|
|
|
69
69
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
70
|
-
throw new Error(
|
|
70
|
+
throw new Error(`ButtonGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
71
71
|
} // Some web screenreaders e.g. MacOS Voiceover don't handle radiogroups properly unless radio is direct child of radiogroup
|
|
72
72
|
|
|
73
73
|
|
|
@@ -150,7 +150,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
150
150
|
}) : /*#__PURE__*/_jsx(CarouselStepTracker, {}),
|
|
151
151
|
tag = 'ul',
|
|
152
152
|
accessibilityRole,
|
|
153
|
-
accessibilityLabel
|
|
153
|
+
accessibilityLabel,
|
|
154
154
|
accessibilityLiveRegion = 'polite',
|
|
155
155
|
copy,
|
|
156
156
|
...rest
|
|
@@ -391,11 +391,38 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
391
391
|
const getCopyWithPlaceholders = React.useCallback(copyKey => {
|
|
392
392
|
const copyText = getCopy(copyKey).replace(/%\{title\}/g, title).replace(/%\{itemLabel\}/g, itemLabel).replace(/%\{stepNumber\}/g, activeIndex + 1).replace(/%\{stepCount\}/g, childrenArray.length); // First word might be a lowercase placeholder: capitalize the first letter
|
|
393
393
|
|
|
394
|
-
return
|
|
394
|
+
return `${copyText[0].toUpperCase()}${copyText.slice(1)}`;
|
|
395
395
|
}, [activeIndex, childrenArray.length, itemLabel, getCopy, title]);
|
|
396
396
|
const activePanelNavigation = tabs && showPanelTabs ? /*#__PURE__*/_jsx(CarouselTabsPanel, {
|
|
397
397
|
items: tabs
|
|
398
398
|
}) : panelNavigation;
|
|
399
|
+
const isFirstFocusContainer = Boolean(refocus && !skipLinkHref);
|
|
400
|
+
|
|
401
|
+
const containerRef = element => {
|
|
402
|
+
// Apply both firstFocusRef to the container
|
|
403
|
+
firstFocusRef.current = element; // Also apply forwarded ref if there is one (which could be a function ref)
|
|
404
|
+
|
|
405
|
+
if (ref) {
|
|
406
|
+
if (typeof ref === 'object') {
|
|
407
|
+
// eslint-disable-next-line no-param-reassign
|
|
408
|
+
ref.current = element;
|
|
409
|
+
} else if (typeof ref === 'function') {
|
|
410
|
+
ref(element);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}; // If container isn't used for focus, give it a label of title if none is passed in,
|
|
414
|
+
// otherwise read the current position on focus
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
const containerAccessibilityLabel = systemProps.accessibilityLabel ?? isFirstFocusContainer ? `${title ? `${title} ` : ''}${getCopyWithPlaceholders('stepTrackerLabel')}` : title;
|
|
418
|
+
const containerProps = {
|
|
419
|
+
accessibilityLabel: containerAccessibilityLabel,
|
|
420
|
+
// If used for focus, attach the ref and draw a focus box around the whole carousel
|
|
421
|
+
...(isFirstFocusContainer && {
|
|
422
|
+
ref: containerRef,
|
|
423
|
+
focusable: true
|
|
424
|
+
})
|
|
425
|
+
};
|
|
399
426
|
return /*#__PURE__*/_jsxs(CarouselProvider, {
|
|
400
427
|
activeIndex: activeIndex,
|
|
401
428
|
goTo: goTo,
|
|
@@ -411,6 +438,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
411
438
|
onLayout: onContainerLayout,
|
|
412
439
|
ref: ref,
|
|
413
440
|
...systemProps,
|
|
441
|
+
...containerProps,
|
|
414
442
|
children: [showPreviousNextNavigation && /*#__PURE__*/_jsx(View, {
|
|
415
443
|
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true),
|
|
416
444
|
testID: "previous-button-container",
|
|
@@ -425,12 +453,10 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
425
453
|
ref: firstFocusRef,
|
|
426
454
|
href: skipLinkHref,
|
|
427
455
|
children: getCopyWithPlaceholders('skipLink')
|
|
428
|
-
}), /*#__PURE__*/_jsx(A11yText // Read the current slide position to screen readers on slide.
|
|
456
|
+
}), !isFirstFocusContainer && /*#__PURE__*/_jsx(A11yText // Read the current slide position to screen readers on slide.
|
|
429
457
|
// If it's set to refocus and doesn't have a SkipLink to focus to, focus this.
|
|
430
458
|
, {
|
|
431
|
-
ref: !skipLinkHref && refocus ? firstFocusRef : null,
|
|
432
459
|
accessibilityLiveRegion: !skipLinkHref && refocus ? undefined : 'polite',
|
|
433
|
-
focusable: !skipLinkHref && refocus,
|
|
434
460
|
text: getCopyWithPlaceholders('stepTrackerLabel')
|
|
435
461
|
}), /*#__PURE__*/_jsx(View, {
|
|
436
462
|
style: selectContainerStyles(containerLayout.width),
|
|
@@ -36,7 +36,7 @@ function useCarousel() {
|
|
|
36
36
|
const context = React.useContext(CarouselContext);
|
|
37
37
|
|
|
38
38
|
if (context === undefined) {
|
|
39
|
-
throw new Error(
|
|
39
|
+
throw new Error(`'useCarousel' must be used within a 'CarouselProvider'`);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return context;
|
|
@@ -21,7 +21,7 @@ const CarouselFirstFocus = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
21
21
|
} = useCarousel(); // TODO: integrate skip link description if behaving as skip link.
|
|
22
22
|
// Consider moving this content to aria-live area while only the skip link is focused.
|
|
23
23
|
|
|
24
|
-
const accessibilityLabel =
|
|
24
|
+
const accessibilityLabel = `${title}, ${getCopyWithPlaceholders('stepTrackerLabel')}`;
|
|
25
25
|
const accessibilityRole = Platform.select({
|
|
26
26
|
web: 'link',
|
|
27
27
|
// The focused item will ultimately be a skip link.
|
|
@@ -25,16 +25,7 @@ const CarouselTabsPanel = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
25
25
|
};
|
|
26
26
|
const lastTabSelected = activeIndex === items.length - 1;
|
|
27
27
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
28
|
-
children: [/*#__PURE__*/_jsx(
|
|
29
|
-
focusable: true,
|
|
30
|
-
accessible: true,
|
|
31
|
-
onFocus: event => {
|
|
32
|
-
// When user forward-tabs into this section, focus the next tab; if they backwards-tab
|
|
33
|
-
// (shift-tab) back into the carousel content, don't interfere.
|
|
34
|
-
const previousWebFocus = event.relatedTarget;
|
|
35
|
-
if (previousWebFocus !== firstTabRef.current) nextFocusRef.current.focus();
|
|
36
|
-
}
|
|
37
|
-
}), /*#__PURE__*/_jsx(StackView, {
|
|
28
|
+
children: [/*#__PURE__*/_jsx(StackView, {
|
|
38
29
|
direction: "row",
|
|
39
30
|
space: 3,
|
|
40
31
|
divider: {
|
|
@@ -25,7 +25,7 @@ const CarouselThumbnail = _ref => {
|
|
|
25
25
|
goTo,
|
|
26
26
|
themeTokens
|
|
27
27
|
} = useCarousel();
|
|
28
|
-
const thumbnailTitle = alt
|
|
28
|
+
const thumbnailTitle = alt ?? getCopyWithPlaceholders('stepTrackerLabel').replace(/%\{itemLabel\}/g, itemLabel).replace(/%\{stepNumber\}/g, index).replace(/%\{stepCount\}/g, totalItems);
|
|
29
29
|
|
|
30
30
|
const handlePress = () => goTo(index);
|
|
31
31
|
|
|
@@ -68,7 +68,7 @@ const CarouselThumbnail = _ref => {
|
|
|
68
68
|
style: [styles.pressable, index === activeIndex && styles.selected],
|
|
69
69
|
children: /*#__PURE__*/_jsx(Image, {
|
|
70
70
|
accessibilityIgnoresInvertColors: true,
|
|
71
|
-
accessibilityLabel: accessibilityLabel
|
|
71
|
+
accessibilityLabel: accessibilityLabel ?? alt,
|
|
72
72
|
source: src,
|
|
73
73
|
style: styles.image,
|
|
74
74
|
title: thumbnailTitle
|
|
@@ -187,7 +187,7 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
const uniqueId = useUniqueId('checkbox');
|
|
190
|
-
const inputId = id
|
|
190
|
+
const inputId = id ?? uniqueId;
|
|
191
191
|
const {
|
|
192
192
|
themeOptions
|
|
193
193
|
} = useTheme();
|
|
@@ -97,7 +97,7 @@ const CheckboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
97
97
|
const uniqueFields = ['id', 'label'];
|
|
98
98
|
|
|
99
99
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
100
|
-
throw new Error(
|
|
100
|
+
throw new Error(`CheckboxGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
const checkboxes = items.map((_ref2, index) => {
|
|
@@ -108,7 +108,7 @@ const CheckboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
108
108
|
ref: itemRef,
|
|
109
109
|
...itemRest
|
|
110
110
|
} = _ref2;
|
|
111
|
-
const checkboxId = id ||
|
|
111
|
+
const checkboxId = id || `Checkbox[${index}]`;
|
|
112
112
|
|
|
113
113
|
const handleChange = (newCheckedState, event) => {
|
|
114
114
|
if (typeof itemOnChange === 'function') itemOnChange(newCheckedState, event);
|
|
@@ -98,9 +98,9 @@ const Divider = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
98
98
|
};
|
|
99
99
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
100
100
|
children: [/*#__PURE__*/_jsx(Spacer, { ...spacerProps,
|
|
101
|
-
testID: testID ?
|
|
101
|
+
testID: testID ? `${testID}-Spacer-before` : undefined
|
|
102
102
|
}), divider, /*#__PURE__*/_jsx(Spacer, { ...spacerProps,
|
|
103
|
-
testID: testID ?
|
|
103
|
+
testID: testID ? `${testID}-Spacer-after` : undefined
|
|
104
104
|
})]
|
|
105
105
|
});
|
|
106
106
|
});
|
|
@@ -45,7 +45,7 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
45
45
|
const horizontalAlignLevel = getHorizontalAlignLevel();
|
|
46
46
|
|
|
47
47
|
const toPercent = num => {
|
|
48
|
-
return
|
|
48
|
+
return `${num / 12 * 100}%`;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const calculateWidth = value => {
|
package/lib-module/Icon/Icon.js
CHANGED
|
@@ -30,7 +30,7 @@ const Icon = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
30
30
|
// TODO: systematise animations.
|
|
31
31
|
// https://github.com/telus/universal-design-system/issues/487
|
|
32
32
|
transition: 'transform 200ms, color 200ms',
|
|
33
|
-
transform: [themeTokens.scale ?
|
|
33
|
+
transform: [themeTokens.scale ? `scale(${themeTokens.scale})` : '', themeTokens.translateX ? `translateX(${themeTokens.translateX}px)` : '', themeTokens.translateY ? `translateY(${themeTokens.translateY}px)` : ''].filter(exists => exists).join(' ')
|
|
34
34
|
},
|
|
35
35
|
dataSet: dataSet,
|
|
36
36
|
children: iconContent
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
+
import { Portal } from '@gorhom/portal';
|
|
6
|
+
import { copyPropTypes, getTokensPropType, selectTokens, useCopy, variantProp } from '../utils';
|
|
7
|
+
import { useViewport } from '../ViewportProvider';
|
|
8
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
9
|
+
import dictionary from './dictionary';
|
|
10
|
+
import Card from '../Card';
|
|
11
|
+
import IconButton from '../IconButton';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
+
const staticStyles = StyleSheet.create({
|
|
16
|
+
positioner: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
// Grow to maxWidth when possible, shrink when not possible
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
height: 330,
|
|
21
|
+
paddingTop: 5,
|
|
22
|
+
zIndex: 10000 // Position on top of all the other overlays, including backdrops and modals
|
|
23
|
+
|
|
24
|
+
},
|
|
25
|
+
closeButtonContainer: {
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
top: 0,
|
|
28
|
+
right: 0,
|
|
29
|
+
zIndex: 1
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const selectCloseButtonContainerStyles = _ref => {
|
|
34
|
+
let {
|
|
35
|
+
paddingRight,
|
|
36
|
+
paddingTop
|
|
37
|
+
} = _ref;
|
|
38
|
+
return {
|
|
39
|
+
paddingRight,
|
|
40
|
+
paddingTop
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const selectPaddingContainerStyles = _ref2 => {
|
|
45
|
+
let {
|
|
46
|
+
paddingTop,
|
|
47
|
+
paddingLeft,
|
|
48
|
+
paddingRight
|
|
49
|
+
} = _ref2;
|
|
50
|
+
return {
|
|
51
|
+
paddingBottom: 35,
|
|
52
|
+
paddingTop,
|
|
53
|
+
paddingLeft,
|
|
54
|
+
paddingRight
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
59
|
+
let {
|
|
60
|
+
children,
|
|
61
|
+
tokens,
|
|
62
|
+
variant,
|
|
63
|
+
copy,
|
|
64
|
+
onClose
|
|
65
|
+
} = _ref3;
|
|
66
|
+
const viewport = useViewport();
|
|
67
|
+
const themeTokens = useThemeTokens('Modal', tokens, variant, {
|
|
68
|
+
viewport,
|
|
69
|
+
maxWidth: false
|
|
70
|
+
});
|
|
71
|
+
const {
|
|
72
|
+
closeIcon: CloseIconComponent,
|
|
73
|
+
maxWidth
|
|
74
|
+
} = themeTokens;
|
|
75
|
+
const getCopy = useCopy({
|
|
76
|
+
dictionary,
|
|
77
|
+
copy
|
|
78
|
+
});
|
|
79
|
+
const closeLabel = getCopy('closeButton');
|
|
80
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
81
|
+
children: /*#__PURE__*/_jsx(Portal, {
|
|
82
|
+
ref: ref,
|
|
83
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
84
|
+
style: [{
|
|
85
|
+
minWidth: maxWidth
|
|
86
|
+
}, staticStyles.positioner],
|
|
87
|
+
children: /*#__PURE__*/_jsxs(Card, {
|
|
88
|
+
tokens: selectPaddingContainerStyles(themeTokens),
|
|
89
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
90
|
+
style: [staticStyles.closeButtonContainer, selectCloseButtonContainerStyles(themeTokens)],
|
|
91
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
92
|
+
onPress: onClose,
|
|
93
|
+
icon: CloseIconComponent,
|
|
94
|
+
accessibilityRole: "button",
|
|
95
|
+
accessibilityLabel: closeLabel,
|
|
96
|
+
tokens: selectTokens('IconButton', themeTokens, 'close')
|
|
97
|
+
})
|
|
98
|
+
}), children]
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
ModalOverlay.displayName = 'ModalOverlay';
|
|
105
|
+
ModalOverlay.propTypes = {
|
|
106
|
+
children: PropTypes.node.isRequired,
|
|
107
|
+
variant: variantProp.propType,
|
|
108
|
+
tokens: getTokensPropType('Modal'),
|
|
109
|
+
copy: copyPropTypes,
|
|
110
|
+
onClose: PropTypes.func
|
|
111
|
+
};
|
|
112
|
+
export default ModalOverlay;
|