@telus-uds/components-base 1.52.0 → 1.54.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 +34 -2
- package/component-docs.json +172 -21
- package/lib/Button/ButtonBase.js +17 -5
- package/lib/Card/CardBase.js +11 -2
- package/lib/Carousel/Carousel.js +15 -6
- package/lib/ExpandCollapse/Panel.js +65 -8
- package/lib/Modal/Modal.js +9 -3
- package/lib/SkipLink/SkipLink.js +19 -15
- package/lib/ToggleSwitch/ToggleSwitch.js +60 -22
- package/lib/TooltipButton/TooltipButton.js +3 -1
- package/lib/Typography/Typography.js +11 -2
- package/lib-module/Button/ButtonBase.js +17 -5
- package/lib-module/Card/CardBase.js +10 -2
- package/lib-module/Carousel/Carousel.js +15 -6
- package/lib-module/ExpandCollapse/Panel.js +64 -8
- package/lib-module/Modal/Modal.js +8 -3
- package/lib-module/SkipLink/SkipLink.js +19 -15
- package/lib-module/ToggleSwitch/ToggleSwitch.js +60 -22
- package/lib-module/TooltipButton/TooltipButton.js +3 -1
- package/lib-module/Typography/Typography.js +10 -2
- package/package.json +3 -3
- package/src/Button/ButtonBase.jsx +11 -1
- package/src/Card/CardBase.jsx +26 -15
- package/src/Carousel/Carousel.jsx +13 -6
- package/src/ExpandCollapse/Panel.jsx +55 -8
- package/src/Modal/Modal.jsx +8 -3
- package/src/SkipLink/SkipLink.jsx +12 -12
- package/src/ToggleSwitch/ToggleSwitch.jsx +26 -9
- package/src/TooltipButton/TooltipButton.jsx +9 -1
- package/src/Typography/Typography.jsx +7 -2
|
@@ -13,6 +13,8 @@ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/export
|
|
|
13
13
|
|
|
14
14
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
15
15
|
|
|
16
|
+
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
17
|
+
|
|
16
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
19
|
|
|
18
20
|
var _airbnbPropTypes = _interopRequireDefault(require("airbnb-prop-types"));
|
|
@@ -44,7 +46,50 @@ const selectContainerStyles = _ref => {
|
|
|
44
46
|
paddingLeft: contentPaddingLeft,
|
|
45
47
|
paddingRight: contentPaddingRight,
|
|
46
48
|
paddingTop: contentPaddingTop,
|
|
47
|
-
paddingBottom: contentPaddingBottom
|
|
49
|
+
paddingBottom: contentPaddingBottom,
|
|
50
|
+
flex: 1
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const selectTextStyles = _ref2 => {
|
|
55
|
+
let {
|
|
56
|
+
contentPanelFontSize,
|
|
57
|
+
contentPanelFontName,
|
|
58
|
+
contentPanelFontColor,
|
|
59
|
+
contentPanelFontWeight,
|
|
60
|
+
contentPanelLineHeight
|
|
61
|
+
} = _ref2;
|
|
62
|
+
return {
|
|
63
|
+
fontSize: contentPanelFontSize,
|
|
64
|
+
fontFamily: `${contentPanelFontName}${contentPanelFontWeight}normal`,
|
|
65
|
+
lineHeight: contentPanelFontSize * contentPanelLineHeight,
|
|
66
|
+
color: contentPanelFontColor
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const selectContentPanelStyles = _ref3 => {
|
|
71
|
+
let {
|
|
72
|
+
contentPanelBackgroundColor,
|
|
73
|
+
contentPanelPaddingTop,
|
|
74
|
+
contentPanelPaddingBottom,
|
|
75
|
+
contentPanelPaddingLeft,
|
|
76
|
+
contentPanelPaddingRight,
|
|
77
|
+
contentPanelBorderWidth,
|
|
78
|
+
contentPanelBorderColor,
|
|
79
|
+
borderRadius,
|
|
80
|
+
marginBottom
|
|
81
|
+
} = _ref3;
|
|
82
|
+
return {
|
|
83
|
+
backgroundColor: contentPanelBackgroundColor,
|
|
84
|
+
paddingTop: contentPanelPaddingTop,
|
|
85
|
+
paddingBottom: contentPanelPaddingBottom,
|
|
86
|
+
paddingLeft: contentPanelPaddingLeft,
|
|
87
|
+
paddingRight: contentPanelPaddingRight,
|
|
88
|
+
borderWidth: contentPanelBorderWidth,
|
|
89
|
+
borderColor: contentPanelBorderColor,
|
|
90
|
+
borderStyle: 'solid',
|
|
91
|
+
borderRadius,
|
|
92
|
+
marginBottom
|
|
48
93
|
};
|
|
49
94
|
};
|
|
50
95
|
/**
|
|
@@ -59,7 +104,7 @@ const selectContainerStyles = _ref => {
|
|
|
59
104
|
*/
|
|
60
105
|
|
|
61
106
|
|
|
62
|
-
const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((
|
|
107
|
+
const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
63
108
|
let {
|
|
64
109
|
openIds = [],
|
|
65
110
|
panelId,
|
|
@@ -71,8 +116,9 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
71
116
|
tokens,
|
|
72
117
|
variant,
|
|
73
118
|
controlRef,
|
|
119
|
+
content,
|
|
74
120
|
...rest
|
|
75
|
-
} =
|
|
121
|
+
} = _ref4;
|
|
76
122
|
const [containerHeight, setContainerHeight] = (0, _react.useState)(null);
|
|
77
123
|
const isExpanded = openIds.includes(panelId);
|
|
78
124
|
const selectedProps = selectProps({ ...rest,
|
|
@@ -107,7 +153,13 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
107
153
|
tokens: themeTokens
|
|
108
154
|
});
|
|
109
155
|
const focusabilityProps = isExpanded ? {} : _utils.a11yProps.nonFocusableProps;
|
|
110
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
156
|
+
return content ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
157
|
+
style: selectContentPanelStyles(themeTokens),
|
|
158
|
+
children: typeof children === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
159
|
+
style: selectTextStyles(themeTokens),
|
|
160
|
+
children: children
|
|
161
|
+
}) : children
|
|
162
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
111
163
|
ref: ref,
|
|
112
164
|
style: themeTokens,
|
|
113
165
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Control.default, { ...selectedProps,
|
|
@@ -157,7 +209,7 @@ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
|
|
|
157
209
|
* Function to call on pressing the panel's control, which should open or close the panel.
|
|
158
210
|
* If Panel is a direct child of `ExpandCollapse`, this prop will be provided by the ExpandCollapse parent.
|
|
159
211
|
*/
|
|
160
|
-
onToggle: _propTypes.default.func
|
|
212
|
+
onToggle: _propTypes.default.func,
|
|
161
213
|
|
|
162
214
|
/**
|
|
163
215
|
* Optional function to call on pressing the panel's control, in addition to opening or closing the panel.
|
|
@@ -171,9 +223,9 @@ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
|
|
|
171
223
|
children: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
172
224
|
|
|
173
225
|
/**
|
|
174
|
-
* The content inside the
|
|
226
|
+
* The content inside the control element that opens and closes the ExpandCollapse when pressed.
|
|
175
227
|
*/
|
|
176
|
-
control: _Control.default.propTypes.children
|
|
228
|
+
control: _Control.default.propTypes.children,
|
|
177
229
|
|
|
178
230
|
/**
|
|
179
231
|
* Optional theme token overrides that may be passed to the ExpandCollapseControl element.
|
|
@@ -183,7 +235,12 @@ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
|
|
|
183
235
|
/**
|
|
184
236
|
* An optional ref to be attached to the control
|
|
185
237
|
*/
|
|
186
|
-
controlRef: _airbnbPropTypes.default.ref()
|
|
238
|
+
controlRef: _airbnbPropTypes.default.ref(),
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* A boolean prop to determine if the panel is a content panel or not. If true, the panel will not have a control
|
|
242
|
+
*/
|
|
243
|
+
content: _propTypes.default.bool
|
|
187
244
|
};
|
|
188
245
|
var _default = ExpandCollapsePanel;
|
|
189
246
|
exports.default = _default;
|
package/lib/Modal/Modal.js
CHANGED
|
@@ -13,6 +13,8 @@ var _TouchableWithoutFeedback = _interopRequireDefault(require("react-native-web
|
|
|
13
13
|
|
|
14
14
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
15
15
|
|
|
16
|
+
var _ScrollView = _interopRequireDefault(require("react-native-web/dist/cjs/exports/ScrollView"));
|
|
17
|
+
|
|
16
18
|
var _Modal = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Modal"));
|
|
17
19
|
|
|
18
20
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
@@ -166,8 +168,8 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
166
168
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.default, {
|
|
167
169
|
transparent: true,
|
|
168
170
|
...selectProps(rest),
|
|
169
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
170
|
-
|
|
171
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ScrollView.default, {
|
|
172
|
+
contentContainerStyle: [staticStyles.positioningContainer],
|
|
171
173
|
ref: modalRef,
|
|
172
174
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
173
175
|
style: [staticStyles.sizingContainer, selectContainerStyles(themeTokens)],
|
|
@@ -258,7 +260,11 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
258
260
|
modal: {
|
|
259
261
|
maxHeight: '100%',
|
|
260
262
|
// so that the modal can expand vertically up to the sizing container's height (exclusive of its vertical padding)
|
|
261
|
-
|
|
263
|
+
..._Platform.default.select({
|
|
264
|
+
web: {
|
|
265
|
+
overflow: 'auto'
|
|
266
|
+
}
|
|
267
|
+
})
|
|
262
268
|
},
|
|
263
269
|
closeButtonContainer: {
|
|
264
270
|
position: 'absolute',
|
package/lib/SkipLink/SkipLink.js
CHANGED
|
@@ -56,10 +56,19 @@ const selectStyles = _ref => {
|
|
|
56
56
|
|
|
57
57
|
const selectTextStyles = _ref2 => {
|
|
58
58
|
let {
|
|
59
|
-
color
|
|
59
|
+
color,
|
|
60
|
+
textLine,
|
|
61
|
+
fontName,
|
|
62
|
+
fontSize,
|
|
63
|
+
fontWeight,
|
|
64
|
+
lineHeight
|
|
60
65
|
} = _ref2;
|
|
61
66
|
return {
|
|
62
|
-
color
|
|
67
|
+
color,
|
|
68
|
+
textDecorationLine: textLine,
|
|
69
|
+
fontFamily: `${fontName}${fontWeight}normal`,
|
|
70
|
+
lineHeight: fontSize * lineHeight,
|
|
71
|
+
fontSize
|
|
63
72
|
};
|
|
64
73
|
};
|
|
65
74
|
/**
|
|
@@ -134,9 +143,6 @@ const SkipLink = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
134
143
|
} = _utils.clickProps.toPressProps(rawRest);
|
|
135
144
|
|
|
136
145
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('SkipLink', tokens, variant);
|
|
137
|
-
const defaultTokens = getTokens();
|
|
138
|
-
|
|
139
|
-
const resolveLinkTokens = pressState => (0, _utils.resolvePressableTokens)(defaultTokens, pressState);
|
|
140
146
|
|
|
141
147
|
const handlePress = event => {
|
|
142
148
|
if (typeof onPress === 'function') onPress(event); // TODO - support native apps with something based on refs and/or setAccessibilityFocus
|
|
@@ -147,19 +153,17 @@ const SkipLink = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
147
153
|
accessibilityRole: "link",
|
|
148
154
|
onPress: handlePress,
|
|
149
155
|
href: href,
|
|
150
|
-
style:
|
|
151
|
-
|
|
152
|
-
focused: focus
|
|
153
|
-
} = _ref4;
|
|
154
|
-
const themeTokens = getTokens({
|
|
155
|
-
focus
|
|
156
|
-
});
|
|
156
|
+
style: pressableState => {
|
|
157
|
+
const themeTokens = (0, _utils.resolvePressableTokens)(getTokens, pressableState);
|
|
157
158
|
const skipLinkStyle = selectStyles(themeTokens);
|
|
158
|
-
|
|
159
|
+
const {
|
|
160
|
+
focused
|
|
161
|
+
} = pressableState;
|
|
162
|
+
return [staticStyles.absolute, skipLinkStyle, !focused && staticStyles.hidden];
|
|
159
163
|
},
|
|
160
164
|
...selectProps(rest),
|
|
161
|
-
children:
|
|
162
|
-
const themeTokens =
|
|
165
|
+
children: pressableState => {
|
|
166
|
+
const themeTokens = (0, _utils.resolvePressableTokens)(getTokens, pressableState);
|
|
163
167
|
const textStyles = selectTextStyles(themeTokens);
|
|
164
168
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
165
169
|
style: [textStyles, staticStyles.baseline],
|
|
@@ -38,36 +38,54 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
38
38
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.pressProps, _utils.viewProps]); // We need to drop the icon before passing it to the `ButtonBase`, because it's
|
|
39
39
|
// being handled separately in this case
|
|
40
40
|
|
|
41
|
-
const selectButtonTokens = _ref => {
|
|
41
|
+
const selectButtonTokens = (_ref, _ref2) => {
|
|
42
42
|
let {
|
|
43
43
|
icon: _,
|
|
44
44
|
...tokens
|
|
45
45
|
} = _ref;
|
|
46
|
+
let {
|
|
47
|
+
trackHeight,
|
|
48
|
+
outerBorderGapButton
|
|
49
|
+
} = _ref2;
|
|
46
50
|
return (0, _utils.selectTokens)('Button', { ...tokens,
|
|
47
51
|
// Width tokens are applied to our inner track. Disable Button width token so it wraps our track width.
|
|
52
|
+
outerBorderGap: outerBorderGapButton,
|
|
53
|
+
height: trackHeight,
|
|
48
54
|
width: null
|
|
49
55
|
});
|
|
50
56
|
}; // Map and rename icon-specific tokens to name used within Icon
|
|
51
57
|
|
|
52
58
|
|
|
53
|
-
const selectIconTokens =
|
|
59
|
+
const selectIconTokens = _ref3 => {
|
|
54
60
|
let {
|
|
55
61
|
iconSize,
|
|
56
62
|
iconColor
|
|
57
|
-
} =
|
|
63
|
+
} = _ref3;
|
|
58
64
|
return {
|
|
59
65
|
size: iconSize,
|
|
60
66
|
color: iconColor
|
|
61
67
|
};
|
|
62
68
|
};
|
|
63
69
|
|
|
64
|
-
const
|
|
70
|
+
const selectTrackSwitchStyles = _ref4 => {
|
|
71
|
+
let {
|
|
72
|
+
switchSize,
|
|
73
|
+
width,
|
|
74
|
+
trackHeight
|
|
75
|
+
} = _ref4;
|
|
76
|
+
return {
|
|
77
|
+
width,
|
|
78
|
+
height: Math.max(switchSize, trackHeight)
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const selectTrackStyles = _ref5 => {
|
|
65
83
|
let {
|
|
66
84
|
trackBorderWidth,
|
|
67
85
|
trackBorderColor,
|
|
68
86
|
trackBorderRadius,
|
|
69
87
|
width
|
|
70
|
-
} =
|
|
88
|
+
} = _ref5;
|
|
71
89
|
return {
|
|
72
90
|
borderWidth: trackBorderWidth,
|
|
73
91
|
borderColor: trackBorderColor,
|
|
@@ -76,7 +94,7 @@ const selectTrackStyles = _ref3 => {
|
|
|
76
94
|
};
|
|
77
95
|
};
|
|
78
96
|
|
|
79
|
-
const selectSwitchStyles =
|
|
97
|
+
const selectSwitchStyles = _ref6 => {
|
|
80
98
|
let {
|
|
81
99
|
switchSize,
|
|
82
100
|
switchColor,
|
|
@@ -84,8 +102,9 @@ const selectSwitchStyles = _ref4 => {
|
|
|
84
102
|
switchBorderColor,
|
|
85
103
|
switchBorderRadius,
|
|
86
104
|
switchShadow
|
|
87
|
-
} =
|
|
105
|
+
} = _ref6;
|
|
88
106
|
return {
|
|
107
|
+
position: 'absolute',
|
|
89
108
|
width: switchSize,
|
|
90
109
|
height: switchSize,
|
|
91
110
|
backgroundColor: switchColor,
|
|
@@ -102,23 +121,23 @@ const selectSwitchStyles = _ref4 => {
|
|
|
102
121
|
};
|
|
103
122
|
};
|
|
104
123
|
|
|
105
|
-
const selectLabelStyles =
|
|
124
|
+
const selectLabelStyles = _ref7 => {
|
|
106
125
|
let {
|
|
107
126
|
labelMarginLeft
|
|
108
|
-
} =
|
|
127
|
+
} = _ref7;
|
|
109
128
|
return {
|
|
110
129
|
marginLeft: labelMarginLeft
|
|
111
130
|
};
|
|
112
131
|
};
|
|
113
132
|
|
|
114
|
-
const selectLabelTokens =
|
|
133
|
+
const selectLabelTokens = _ref8 => {
|
|
115
134
|
let {
|
|
116
135
|
labelColor,
|
|
117
136
|
labelFontName,
|
|
118
137
|
labelFontSize,
|
|
119
138
|
labelFontWeight,
|
|
120
139
|
labelLineHeight
|
|
121
|
-
} =
|
|
140
|
+
} = _ref8;
|
|
122
141
|
return {
|
|
123
142
|
color: labelColor,
|
|
124
143
|
fontName: labelFontName,
|
|
@@ -128,7 +147,7 @@ const selectLabelTokens = _ref6 => {
|
|
|
128
147
|
};
|
|
129
148
|
};
|
|
130
149
|
|
|
131
|
-
const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)((
|
|
150
|
+
const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)((_ref9, ref) => {
|
|
132
151
|
let {
|
|
133
152
|
copy = 'en',
|
|
134
153
|
value,
|
|
@@ -143,7 +162,7 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)((_ref7, ref) => {
|
|
|
143
162
|
accessibilityRole = 'switch',
|
|
144
163
|
accessibilityLabel = label,
|
|
145
164
|
...rest
|
|
146
|
-
} =
|
|
165
|
+
} = _ref9;
|
|
147
166
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ToggleSwitch', tokens, variant);
|
|
148
167
|
const themeTokens = getTokens();
|
|
149
168
|
const {
|
|
@@ -157,13 +176,16 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)((_ref7, ref) => {
|
|
|
157
176
|
|
|
158
177
|
const handlePress = event => setValue(!currentValue, event);
|
|
159
178
|
|
|
160
|
-
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
|
|
179
|
+
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState), getTokens(themeTokens));
|
|
161
180
|
|
|
162
181
|
const uniqueId = (0, _utils.useUniqueId)('toggleSwitch');
|
|
163
182
|
const inputId = id ?? uniqueId;
|
|
164
183
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
165
|
-
space:
|
|
184
|
+
space: themeTokens.space,
|
|
166
185
|
direction: "row",
|
|
186
|
+
tokens: {
|
|
187
|
+
alignItems: 'center'
|
|
188
|
+
},
|
|
167
189
|
children: [Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
168
190
|
style: [selectLabelStyles(themeTokens), staticStyles.containText],
|
|
169
191
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, {
|
|
@@ -191,24 +213,36 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)((_ref7, ref) => {
|
|
|
191
213
|
const IconComponent = stateTokens.icon;
|
|
192
214
|
const switchStyles = selectSwitchStyles(stateTokens);
|
|
193
215
|
const trackStyles = selectTrackStyles(stateTokens);
|
|
194
|
-
const iconTokens = selectIconTokens(stateTokens);
|
|
216
|
+
const iconTokens = selectIconTokens(stateTokens);
|
|
217
|
+
const trackSwitchStyles = selectTrackSwitchStyles(stateTokens);
|
|
218
|
+
const {
|
|
219
|
+
switchSize,
|
|
220
|
+
trackHeight,
|
|
221
|
+
width,
|
|
222
|
+
trackBorderWidth
|
|
223
|
+
} = stateTokens; // If drag-slide support is needed, use a PanResponder and apply these to an Animated value.
|
|
195
224
|
// Use translate transforms for smoothest non-thread-blocking animations and to allow drag.
|
|
225
|
+
// Two different translates depending on the switchSize and trackSize relationship.
|
|
196
226
|
|
|
197
|
-
const
|
|
198
|
-
const
|
|
227
|
+
const isSwitchTallerThanTrack = switchSize >= trackHeight;
|
|
228
|
+
const slideStart = isSwitchTallerThanTrack ? 0 : trackBorderWidth;
|
|
229
|
+
const slideEnd = isSwitchTallerThanTrack ? width - switchSize : width - switchSize - trackBorderWidth;
|
|
199
230
|
const switchOffset = buttonState.selected ? slideEnd : slideStart;
|
|
200
231
|
const switchPositionStyle = {
|
|
201
232
|
transform: [{
|
|
202
233
|
translateX: switchOffset
|
|
203
234
|
}]
|
|
204
235
|
};
|
|
205
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
206
|
-
|
|
207
|
-
|
|
236
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
237
|
+
nativeID: "trackSwitch",
|
|
238
|
+
style: [trackSwitchStyles, staticStyles.trackSwitch],
|
|
239
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
240
|
+
style: [staticStyles.track, trackStyles]
|
|
241
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
208
242
|
style: [staticStyles.switch, switchStyles, switchPositionStyle],
|
|
209
243
|
children: IconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, { ...iconTokens
|
|
210
244
|
})
|
|
211
|
-
})
|
|
245
|
+
})]
|
|
212
246
|
});
|
|
213
247
|
}
|
|
214
248
|
})]
|
|
@@ -275,6 +309,10 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
275
309
|
},
|
|
276
310
|
containText: {
|
|
277
311
|
flexShrink: 1
|
|
312
|
+
},
|
|
313
|
+
trackSwitch: {
|
|
314
|
+
flexDirection: 'row',
|
|
315
|
+
alignItems: 'center'
|
|
278
316
|
}
|
|
279
317
|
});
|
|
280
318
|
|
|
@@ -65,7 +65,9 @@ const TooltipButton = _ref3 => {
|
|
|
65
65
|
icon: IconComponent
|
|
66
66
|
} = themeTokens;
|
|
67
67
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
68
|
-
style: (0, _ThemeProvider.applyOuterBorder)(themeTokens),
|
|
68
|
+
style: [(0, _ThemeProvider.applyOuterBorder)(themeTokens), themeTokens.outerBorderWidth && {
|
|
69
|
+
margin: -themeTokens.outerBorderWidth
|
|
70
|
+
}],
|
|
69
71
|
...selectProps(rest),
|
|
70
72
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
71
73
|
style: selectInnerContainerStyles(themeTokens),
|
|
@@ -75,7 +75,10 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
75
75
|
...rest
|
|
76
76
|
} = _ref2;
|
|
77
77
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
78
|
-
const
|
|
78
|
+
const {
|
|
79
|
+
superScriptFontSize,
|
|
80
|
+
...themeTokens
|
|
81
|
+
} = (0, _ThemeProvider.useThemeTokens)('Typography', tokens, variant, {
|
|
79
82
|
viewport
|
|
80
83
|
});
|
|
81
84
|
const {
|
|
@@ -98,8 +101,14 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
98
101
|
if (typeof child === 'object' && ((child === null || child === void 0 ? void 0 : child.type) === 'sub' || (child === null || child === void 0 ? void 0 : child.type) === 'sup')) {
|
|
99
102
|
var _child$props;
|
|
100
103
|
|
|
104
|
+
const childStyles = (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.style) || {};
|
|
105
|
+
const supFontSize = childStyles.fontSize ?? superScriptFontSize;
|
|
106
|
+
|
|
101
107
|
const sanitizedChild = /*#__PURE__*/_react.default.cloneElement(child, {
|
|
102
|
-
style: { ...
|
|
108
|
+
style: { ...childStyles,
|
|
109
|
+
...(supFontSize ? {
|
|
110
|
+
fontSize: supFontSize
|
|
111
|
+
} : {}),
|
|
103
112
|
lineHeight: 0
|
|
104
113
|
}
|
|
105
114
|
});
|
|
@@ -208,19 +208,29 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref8) => {
|
|
|
208
208
|
});
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
-
const
|
|
211
|
+
const selectButtonStyles = _ref9 => {
|
|
212
|
+
let {
|
|
213
|
+
textAlign
|
|
214
|
+
} = _ref9;
|
|
215
|
+
return {
|
|
216
|
+
flexDirection: 'row',
|
|
217
|
+
justifyContent: textAlign
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const selectItemIconTokens = _ref10 => {
|
|
212
222
|
let {
|
|
213
223
|
color,
|
|
214
224
|
iconColor,
|
|
215
225
|
iconSize
|
|
216
|
-
} =
|
|
226
|
+
} = _ref10;
|
|
217
227
|
return {
|
|
218
228
|
size: iconSize,
|
|
219
229
|
color: iconColor || color
|
|
220
230
|
};
|
|
221
231
|
};
|
|
222
232
|
|
|
223
|
-
const ButtonBase = /*#__PURE__*/forwardRef((
|
|
233
|
+
const ButtonBase = /*#__PURE__*/forwardRef((_ref11, ref) => {
|
|
224
234
|
let {
|
|
225
235
|
id,
|
|
226
236
|
href,
|
|
@@ -235,7 +245,7 @@ const ButtonBase = /*#__PURE__*/forwardRef((_ref10, ref) => {
|
|
|
235
245
|
iconPosition = icon ? 'left' : undefined,
|
|
236
246
|
iconProps,
|
|
237
247
|
...rawRest
|
|
238
|
-
} =
|
|
248
|
+
} = _ref11;
|
|
239
249
|
const {
|
|
240
250
|
onPress,
|
|
241
251
|
...rest
|
|
@@ -282,6 +292,7 @@ const ButtonBase = /*#__PURE__*/forwardRef((_ref10, ref) => {
|
|
|
282
292
|
|
|
283
293
|
const stretchStyles = themeTokens.width ? staticStyles.stretch : staticStyles.align;
|
|
284
294
|
const IconComponent = icon || themeTokens.icon;
|
|
295
|
+
const rowStyles = selectButtonStyles(themeTokens);
|
|
285
296
|
return /*#__PURE__*/_jsx(View, {
|
|
286
297
|
id: id,
|
|
287
298
|
style: [containerStyles, borderStyles, stretchStyles, staticStyles.row, Platform.select({
|
|
@@ -289,7 +300,8 @@ const ButtonBase = /*#__PURE__*/forwardRef((_ref10, ref) => {
|
|
|
289
300
|
maxWidth: '100%',
|
|
290
301
|
// ensure overflowing content wraps
|
|
291
302
|
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
292
|
-
transition: 'background-color 200ms, border-color 200ms'
|
|
303
|
+
transition: 'background-color 200ms, border-color 200ms',
|
|
304
|
+
...rowStyles
|
|
293
305
|
}
|
|
294
306
|
})],
|
|
295
307
|
children: /*#__PURE__*/_jsx(IconText, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
5
|
import { applyShadowToken } from '../ThemeProvider';
|
|
5
6
|
import { getTokensPropType } from '../utils';
|
|
6
7
|
import { a11yProps, viewProps, selectSystemProps } from '../utils/props';
|
|
@@ -19,7 +20,8 @@ const selectStyles = _ref => {
|
|
|
19
20
|
paddingRight,
|
|
20
21
|
paddingTop,
|
|
21
22
|
minWidth,
|
|
22
|
-
shadow
|
|
23
|
+
shadow,
|
|
24
|
+
gradient
|
|
23
25
|
} = _ref;
|
|
24
26
|
return {
|
|
25
27
|
flex,
|
|
@@ -32,7 +34,13 @@ const selectStyles = _ref => {
|
|
|
32
34
|
paddingRight,
|
|
33
35
|
paddingTop,
|
|
34
36
|
minWidth,
|
|
35
|
-
...applyShadowToken(shadow)
|
|
37
|
+
...applyShadowToken(shadow),
|
|
38
|
+
...(gradient && Platform.OS === 'web' ? {
|
|
39
|
+
backgroundImage: `linear-gradient(${gradient.angle}deg, ${gradient.stops[0].color}, ${gradient.stops[1].color})`,
|
|
40
|
+
backgroundOrigin: `border-box`,
|
|
41
|
+
boxShadow: `inset 0 1000px white`,
|
|
42
|
+
border: `${borderWidth}px solid transparent`
|
|
43
|
+
} : {})
|
|
36
44
|
};
|
|
37
45
|
};
|
|
38
46
|
/**
|
|
@@ -185,7 +185,12 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
185
185
|
dictionary,
|
|
186
186
|
copy
|
|
187
187
|
});
|
|
188
|
-
|
|
188
|
+
let childrenArray = unpackFragment(children); // if `Carousel` only has one `Carousel.Item`, convert this to a single-item array
|
|
189
|
+
|
|
190
|
+
if (!Array.isArray(childrenArray)) {
|
|
191
|
+
childrenArray = [childrenArray];
|
|
192
|
+
}
|
|
193
|
+
|
|
189
194
|
const systemProps = selectProps({ ...rest,
|
|
190
195
|
accessibilityRole,
|
|
191
196
|
accessibilityLabel,
|
|
@@ -316,12 +321,16 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
316
321
|
fixOffsetAndGo(toPrev ? -1 : 1);
|
|
317
322
|
}, [fixOffsetAndGo]);
|
|
318
323
|
const isSwipeAllowed = React.useCallback(() => {
|
|
324
|
+
if (childrenArray.length === 1) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
|
|
319
328
|
if (Platform.OS === 'web') {
|
|
320
329
|
return !!(viewport === 'xs' || viewport === 'sm');
|
|
321
330
|
}
|
|
322
331
|
|
|
323
332
|
return true;
|
|
324
|
-
}, [viewport]);
|
|
333
|
+
}, [viewport, childrenArray.length]);
|
|
325
334
|
const panResponder = React.useMemo(() => PanResponder.create({
|
|
326
335
|
onPanResponderTerminationRequest: () => false,
|
|
327
336
|
onMoveShouldSetResponderCapture: () => true,
|
|
@@ -449,7 +458,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
449
458
|
ref: ref,
|
|
450
459
|
...systemProps,
|
|
451
460
|
...containerProps,
|
|
452
|
-
children: [showPreviousNextNavigation && /*#__PURE__*/_jsx(View, {
|
|
461
|
+
children: [showPreviousNextNavigation && childrenArray.length > 1 ? /*#__PURE__*/_jsx(View, {
|
|
453
462
|
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true),
|
|
454
463
|
testID: "previous-button-container",
|
|
455
464
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
@@ -459,7 +468,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
459
468
|
variant: previousNextIconButtonVariants,
|
|
460
469
|
accessibilityLabel: getCopyWithPlaceholders('iconButtonLabel').replace('%{targetStep}', activeIndex)
|
|
461
470
|
})
|
|
462
|
-
}), Boolean(skipLinkHref) && /*#__PURE__*/_jsx(SkipLink, {
|
|
471
|
+
}) : null, Boolean(skipLinkHref) && /*#__PURE__*/_jsx(SkipLink, {
|
|
463
472
|
ref: firstFocusRef,
|
|
464
473
|
href: skipLinkHref,
|
|
465
474
|
children: getCopyWithPlaceholders('skipLink')
|
|
@@ -494,7 +503,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
494
503
|
}, index.toFixed(2));
|
|
495
504
|
})
|
|
496
505
|
})
|
|
497
|
-
}), showPreviousNextNavigation && /*#__PURE__*/_jsx(View, {
|
|
506
|
+
}), showPreviousNextNavigation && childrenArray.length > 1 ? /*#__PURE__*/_jsx(View, {
|
|
498
507
|
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false),
|
|
499
508
|
testID: "next-button-container",
|
|
500
509
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
@@ -504,7 +513,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
504
513
|
variant: previousNextIconButtonVariants,
|
|
505
514
|
accessibilityLabel: getCopyWithPlaceholders('iconButtonLabel').replace('%{targetStep}', activeIndex + 2)
|
|
506
515
|
})
|
|
507
|
-
})]
|
|
516
|
+
}) : null]
|
|
508
517
|
}), showPanelNavigation ? activePanelNavigation : null]
|
|
509
518
|
});
|
|
510
519
|
});
|