@telus-uds/components-web 2.13.0 → 2.15.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 +32 -2
- package/component-docs.json +46 -19
- package/lib/Badge/Badge.js +10 -1
- package/lib/Card/CardContent.js +6 -5
- package/lib/DatePicker/DatePicker.js +12 -11
- package/lib/QuantitySelector/QuantitySelector.js +67 -66
- package/lib/QuantitySelector/SideButton.js +93 -0
- package/lib/QuantitySelector/styles.js +4 -20
- package/lib/TermsAndConditions/TermsAndConditions.js +21 -4
- package/lib/Testimonial/Testimonial.js +48 -12
- package/lib/Toast/Toast.js +19 -7
- package/lib-module/Badge/Badge.js +10 -1
- package/lib-module/Card/CardContent.js +6 -5
- package/lib-module/DatePicker/DatePicker.js +11 -11
- package/lib-module/QuantitySelector/QuantitySelector.js +68 -67
- package/lib-module/QuantitySelector/SideButton.js +80 -0
- package/lib-module/QuantitySelector/styles.js +3 -15
- package/lib-module/TermsAndConditions/TermsAndConditions.js +20 -4
- package/lib-module/Testimonial/Testimonial.js +49 -13
- package/lib-module/Toast/Toast.js +19 -7
- package/package.json +4 -4
- package/src/Badge/Badge.jsx +14 -2
- package/src/Card/CardContent.jsx +6 -5
- package/src/DatePicker/DatePicker.jsx +11 -13
- package/src/QuantitySelector/QuantitySelector.jsx +60 -76
- package/src/QuantitySelector/SideButton.jsx +74 -0
- package/src/QuantitySelector/styles.js +4 -70
- package/src/TermsAndConditions/TermsAndConditions.jsx +30 -4
- package/src/Testimonial/Testimonial.jsx +73 -11
- package/src/Toast/Toast.jsx +5 -1
|
@@ -133,10 +133,11 @@ const TermsAndConditions = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
133
133
|
nonIndexedContent,
|
|
134
134
|
tokens,
|
|
135
135
|
variant = {},
|
|
136
|
+
dictionary = _dictionary.default,
|
|
136
137
|
...rest
|
|
137
138
|
} = _ref6;
|
|
138
139
|
const getCopy = (0, _componentsBase.useCopy)({
|
|
139
|
-
dictionary
|
|
140
|
+
dictionary,
|
|
140
141
|
copy
|
|
141
142
|
});
|
|
142
143
|
const hasIndexedContent = indexedContent.length > 0;
|
|
@@ -199,7 +200,14 @@ const TermsAndConditions = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
199
200
|
})]
|
|
200
201
|
});
|
|
201
202
|
});
|
|
202
|
-
TermsAndConditions.displayName = 'TermsAndConditions';
|
|
203
|
+
TermsAndConditions.displayName = 'TermsAndConditions'; // If a language dictionary entry is provided, it must contain every key
|
|
204
|
+
|
|
205
|
+
const dictionaryContentShape = _propTypes.default.shape({
|
|
206
|
+
headingHide: _propTypes.default.string.isRequired,
|
|
207
|
+
headingView: _propTypes.default.string.isRequired,
|
|
208
|
+
nonIndexedTitle: _propTypes.default.string.isRequired
|
|
209
|
+
});
|
|
210
|
+
|
|
203
211
|
TermsAndConditions.propTypes = { ...selectedSystemPropTypes,
|
|
204
212
|
|
|
205
213
|
/**
|
|
@@ -225,12 +233,21 @@ TermsAndConditions.propTypes = { ...selectedSystemPropTypes,
|
|
|
225
233
|
*
|
|
226
234
|
* nonIndexedContent do not have a corresponding superscript and instead apply to the page as a whole.
|
|
227
235
|
*/
|
|
228
|
-
nonIndexedContent: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]))
|
|
236
|
+
nonIndexedContent: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string])),
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Custom dictionary containing the labels to use for `TermsAndConditions`
|
|
240
|
+
*/
|
|
241
|
+
dictionary: _propTypes.default.shape({
|
|
242
|
+
en: dictionaryContentShape,
|
|
243
|
+
fr: dictionaryContentShape
|
|
244
|
+
})
|
|
229
245
|
};
|
|
230
246
|
TermsAndConditions.defaultProps = {
|
|
231
247
|
copy: 'en',
|
|
232
248
|
indexedContent: [],
|
|
233
|
-
nonIndexedContent: []
|
|
249
|
+
nonIndexedContent: [],
|
|
250
|
+
dictionary: _dictionary.default
|
|
234
251
|
};
|
|
235
252
|
var _default = TermsAndConditions;
|
|
236
253
|
exports.default = _default;
|
|
@@ -104,11 +104,13 @@ const Testimonial = _ref5 => {
|
|
|
104
104
|
imageSrc,
|
|
105
105
|
image = imageSrc,
|
|
106
106
|
additionalInfo,
|
|
107
|
-
testimonialStyle = '
|
|
107
|
+
testimonialStyle = 'large',
|
|
108
108
|
tokens,
|
|
109
|
+
copy = 'en',
|
|
109
110
|
variant = {},
|
|
110
111
|
...rest
|
|
111
112
|
} = _ref5;
|
|
113
|
+
const viewport = (0, _componentsBase.useViewport)();
|
|
112
114
|
const {
|
|
113
115
|
testimonialContainerGap,
|
|
114
116
|
quoteContainerGap,
|
|
@@ -117,9 +119,34 @@ const Testimonial = _ref5 => {
|
|
|
117
119
|
figcaptionGap,
|
|
118
120
|
textColor,
|
|
119
121
|
icon,
|
|
122
|
+
iconFr,
|
|
120
123
|
iconColor,
|
|
121
|
-
imageSize
|
|
122
|
-
|
|
124
|
+
imageSize,
|
|
125
|
+
testimonialFontSizeLarge,
|
|
126
|
+
testimonialLineHeightLarge,
|
|
127
|
+
testimonialFontWeightLarge,
|
|
128
|
+
testimonialFontSizeHeading,
|
|
129
|
+
testimonialLineHeightHeading,
|
|
130
|
+
testimonialFontNameHeading,
|
|
131
|
+
testimonialFontWeightHeading,
|
|
132
|
+
authorFontSize,
|
|
133
|
+
authorLineHeight,
|
|
134
|
+
authorFontName,
|
|
135
|
+
authorFontWeight,
|
|
136
|
+
additionalFontSize,
|
|
137
|
+
additionalLineHeight,
|
|
138
|
+
additionalFontName,
|
|
139
|
+
additionalFontWeight
|
|
140
|
+
} = (0, _componentsBase.useThemeTokens)('Testimonial', tokens, variant, {
|
|
141
|
+
viewport
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const getQuoteTestimonial = open => {
|
|
145
|
+
let quote = '';
|
|
146
|
+
if (copy === 'en') quote = open ? '\u201C' : '\u201D';else quote = open ? '\u00AB ' : ' \u00BB';
|
|
147
|
+
return quote;
|
|
148
|
+
};
|
|
149
|
+
|
|
123
150
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(TestimonialContainer, {
|
|
124
151
|
testimonialContainerGap: testimonialContainerGap,
|
|
125
152
|
...selectProps(rest),
|
|
@@ -132,7 +159,7 @@ const Testimonial = _ref5 => {
|
|
|
132
159
|
variant: {
|
|
133
160
|
size: 'micro'
|
|
134
161
|
},
|
|
135
|
-
icon: icon
|
|
162
|
+
icon: copy === 'en' ? icon : iconFr
|
|
136
163
|
}), showDivider && /*#__PURE__*/(0, _jsxRuntime.jsx)(Divider, {
|
|
137
164
|
dividerBackgroundColor: dividerBackgroundColor,
|
|
138
165
|
dividerBorder: dividerBorder,
|
|
@@ -145,9 +172,12 @@ const Testimonial = _ref5 => {
|
|
|
145
172
|
},
|
|
146
173
|
tokens: {
|
|
147
174
|
color: textColor,
|
|
148
|
-
|
|
175
|
+
fontSize: testimonialStyle === 'heading' ? testimonialFontSizeHeading : testimonialFontSizeLarge,
|
|
176
|
+
lineHeight: testimonialStyle === 'heading' ? testimonialLineHeightHeading : testimonialLineHeightLarge,
|
|
177
|
+
fontName: testimonialFontNameHeading,
|
|
178
|
+
fontWeight: testimonialStyle === 'heading' ? testimonialFontWeightHeading : testimonialFontWeightLarge
|
|
149
179
|
},
|
|
150
|
-
children:
|
|
180
|
+
children: `${getQuoteTestimonial(true)}${testimonial}${getQuoteTestimonial()}`
|
|
151
181
|
})
|
|
152
182
|
}), (image || title || additionalInfo) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(Figcaption, {
|
|
153
183
|
figcaptionGap: figcaptionGap,
|
|
@@ -160,20 +190,26 @@ const Testimonial = _ref5 => {
|
|
|
160
190
|
}) : image), (title || additionalInfo) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(AuthorInfoContainer, {
|
|
161
191
|
children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
162
192
|
variant: {
|
|
163
|
-
size: 'small'
|
|
164
|
-
colour: 'secondary'
|
|
193
|
+
size: 'small'
|
|
165
194
|
},
|
|
166
195
|
tokens: {
|
|
167
|
-
|
|
196
|
+
color: textColor,
|
|
197
|
+
fontSize: authorFontSize,
|
|
198
|
+
lineHeight: authorLineHeight,
|
|
199
|
+
fontName: authorFontName,
|
|
200
|
+
fontWeight: authorFontWeight
|
|
168
201
|
},
|
|
169
202
|
children: title
|
|
170
203
|
}), additionalInfo && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
171
204
|
variant: {
|
|
172
|
-
size: '
|
|
173
|
-
colour: 'secondary'
|
|
205
|
+
size: 'small'
|
|
174
206
|
},
|
|
175
207
|
tokens: {
|
|
176
|
-
|
|
208
|
+
color: textColor,
|
|
209
|
+
fontSize: additionalFontSize,
|
|
210
|
+
lineHeight: additionalLineHeight,
|
|
211
|
+
fontName: additionalFontName,
|
|
212
|
+
fontWeight: additionalFontWeight
|
|
177
213
|
},
|
|
178
214
|
children: additionalInfo
|
|
179
215
|
})]
|
package/lib/Toast/Toast.js
CHANGED
|
@@ -39,19 +39,29 @@ const animation = props => (0, _styledComponents.css)(["", " 1s ease-in-out 2s f
|
|
|
39
39
|
const ToastContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
40
40
|
displayName: "Toast__ToastContainer",
|
|
41
41
|
componentId: "components-web__sc-p78jdh-0"
|
|
42
|
-
})(["display:flex;justify-content:center;align-items:center;flex-wrap:wrap;background:", ";gap:", ";height:0;overflow:hidden;animation:", ";"], _ref => {
|
|
42
|
+
})(["display:flex;justify-content:center;align-items:center;flex-wrap:wrap;padding-left:", "px;padding-right:", "px;background:", ";gap:", ";height:0;overflow:hidden;animation:", ";"], _ref => {
|
|
43
43
|
let {
|
|
44
|
-
|
|
44
|
+
padding
|
|
45
45
|
} = _ref;
|
|
46
|
-
return
|
|
46
|
+
return padding;
|
|
47
47
|
}, _ref2 => {
|
|
48
48
|
let {
|
|
49
|
-
|
|
49
|
+
padding
|
|
50
50
|
} = _ref2;
|
|
51
|
+
return padding;
|
|
52
|
+
}, _ref3 => {
|
|
53
|
+
let {
|
|
54
|
+
containerBackgroundColor
|
|
55
|
+
} = _ref3;
|
|
56
|
+
return containerBackgroundColor;
|
|
57
|
+
}, _ref4 => {
|
|
58
|
+
let {
|
|
59
|
+
containerGap
|
|
60
|
+
} = _ref4;
|
|
51
61
|
return containerGap;
|
|
52
62
|
}, animation);
|
|
53
63
|
|
|
54
|
-
const Toast =
|
|
64
|
+
const Toast = _ref5 => {
|
|
55
65
|
let {
|
|
56
66
|
toast,
|
|
57
67
|
copy,
|
|
@@ -60,7 +70,7 @@ const Toast = _ref3 => {
|
|
|
60
70
|
tokens,
|
|
61
71
|
variant = {},
|
|
62
72
|
...rest
|
|
63
|
-
} =
|
|
73
|
+
} = _ref5;
|
|
64
74
|
// viewport hook added to work adjust the padding to different sizes
|
|
65
75
|
const viewport = (0, _componentsBase.useViewport)();
|
|
66
76
|
const {
|
|
@@ -76,7 +86,8 @@ const Toast = _ref3 => {
|
|
|
76
86
|
animationBackgroundColorAfter,
|
|
77
87
|
animationColorBefore,
|
|
78
88
|
animationColorAfter,
|
|
79
|
-
chevronlinkFontWeight
|
|
89
|
+
chevronlinkFontWeight,
|
|
90
|
+
...extraTokens
|
|
80
91
|
} = (0, _componentsBase.useThemeTokens)('Toast', tokens, variant, {
|
|
81
92
|
viewport
|
|
82
93
|
}); // inherit ChevronLink tokens for animation colors
|
|
@@ -109,6 +120,7 @@ const Toast = _ref3 => {
|
|
|
109
120
|
animationColorAfter: animationColorAfter,
|
|
110
121
|
animationFillColorBefore: chevronInverseColor,
|
|
111
122
|
animationFillColorAfter: chevronDefaultColor,
|
|
123
|
+
...extraTokens,
|
|
112
124
|
...selectProps(rest),
|
|
113
125
|
children: [headline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
114
126
|
variant: {
|
|
@@ -61,7 +61,8 @@ const Badge = _ref6 => {
|
|
|
61
61
|
paddingTop,
|
|
62
62
|
paddingBottom,
|
|
63
63
|
fontName,
|
|
64
|
-
fontWeight
|
|
64
|
+
fontWeight,
|
|
65
|
+
fontSize
|
|
65
66
|
} = useThemeTokens('Badge', tokens, variant);
|
|
66
67
|
const semanticGradient = gradient && transformGradient(gradient);
|
|
67
68
|
const {
|
|
@@ -78,6 +79,11 @@ const Badge = _ref6 => {
|
|
|
78
79
|
background = semanticGradient;
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
const fontSizeMapping = {
|
|
83
|
+
12: 'micro',
|
|
84
|
+
14: 'small',
|
|
85
|
+
16: 'h6'
|
|
86
|
+
};
|
|
81
87
|
return /*#__PURE__*/_jsx(BadgeContainer, {
|
|
82
88
|
isOutlineOffer: isOutlineOffer,
|
|
83
89
|
isAlternative: alternative,
|
|
@@ -95,6 +101,9 @@ const Badge = _ref6 => {
|
|
|
95
101
|
fontWeight,
|
|
96
102
|
color
|
|
97
103
|
},
|
|
104
|
+
variant: {
|
|
105
|
+
size: fontSizeMapping[fontSize]
|
|
106
|
+
},
|
|
98
107
|
children: children
|
|
99
108
|
})
|
|
100
109
|
});
|
|
@@ -19,7 +19,8 @@ const CardContentContainer = /*#__PURE__*/styled.div.withConfig({
|
|
|
19
19
|
contentAlignItems: alignItems,
|
|
20
20
|
contentFlexGrow: flexGrow,
|
|
21
21
|
contentFlexShrink: flexShrink,
|
|
22
|
-
contentJustifyContent: justifyContent
|
|
22
|
+
contentJustifyContent: justifyContent,
|
|
23
|
+
borderWidth
|
|
23
24
|
} = _ref;
|
|
24
25
|
return {
|
|
25
26
|
// We need to make sure to have sharp corners on the bottom
|
|
@@ -28,10 +29,10 @@ const CardContentContainer = /*#__PURE__*/styled.div.withConfig({
|
|
|
28
29
|
borderBottomRightRadius: withFooter ? 0 : borderRadius,
|
|
29
30
|
borderTopLeftRadius: borderRadius,
|
|
30
31
|
borderTopRightRadius: borderRadius,
|
|
31
|
-
paddingBottom,
|
|
32
|
-
paddingLeft,
|
|
33
|
-
paddingRight,
|
|
34
|
-
paddingTop,
|
|
32
|
+
paddingBottom: paddingBottom - borderWidth,
|
|
33
|
+
paddingLeft: paddingLeft - borderWidth,
|
|
34
|
+
paddingRight: paddingRight - borderWidth,
|
|
35
|
+
paddingTop: paddingTop - borderWidth,
|
|
35
36
|
display: 'flex',
|
|
36
37
|
flexDirection: 'column',
|
|
37
38
|
alignItems,
|
|
@@ -7,6 +7,7 @@ import SingleDatePicker from 'react-dates/lib/components/SingleDatePicker';
|
|
|
7
7
|
import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
|
|
8
8
|
import { IconButton, TextInput, selectSystemProps, useCopy, useViewport, useThemeTokens, applyTextStyles } from '@telus-uds/components-base';
|
|
9
9
|
import moment from 'moment';
|
|
10
|
+
import { isUndefined } from 'lodash';
|
|
10
11
|
import CalendarContainer from './CalendarContainer';
|
|
11
12
|
import dictionary from './dictionary';
|
|
12
13
|
import { htmlAttrs } from '../utils';
|
|
@@ -20,29 +21,23 @@ const dateFormatWithoutSpaces = 'DD/MM/YYYY';
|
|
|
20
21
|
const getResponsiveDaySize = function () {
|
|
21
22
|
let inline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
22
23
|
let viewport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'md';
|
|
23
|
-
let responsiveDaySize;
|
|
24
24
|
|
|
25
25
|
if (viewport === 'xs') {
|
|
26
|
-
|
|
27
|
-
} else {
|
|
28
|
-
responsiveDaySize = inline ? 60 : 44;
|
|
26
|
+
return inline ? undefined : 36;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
return
|
|
29
|
+
return inline ? 60 : 44;
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
const getResponsiveCircleSize = function () {
|
|
35
33
|
let inline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
36
34
|
let viewport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'md';
|
|
37
|
-
let responsiveCircleSize;
|
|
38
35
|
|
|
39
36
|
if (viewport === 'xs') {
|
|
40
|
-
|
|
41
|
-
} else {
|
|
42
|
-
responsiveCircleSize = inline ? 44 : 26;
|
|
37
|
+
return 26;
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
return
|
|
40
|
+
return inline ? 44 : 26;
|
|
46
41
|
};
|
|
47
42
|
|
|
48
43
|
const MonthCenterContainer = /*#__PURE__*/styled.div.withConfig({
|
|
@@ -111,7 +106,11 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
111
106
|
copy
|
|
112
107
|
});
|
|
113
108
|
useEffect(() => {
|
|
114
|
-
|
|
109
|
+
/**
|
|
110
|
+
* `date` could be passed as `null` to reset the value so explicitly
|
|
111
|
+
* checking for not being `undefined`
|
|
112
|
+
*/
|
|
113
|
+
if (!isUndefined(date) && !moment(date).isSame(inputDate)) {
|
|
115
114
|
setInputDate(date);
|
|
116
115
|
setInputText(date instanceof moment ? date.format(dateFormat) : '');
|
|
117
116
|
}
|
|
@@ -153,6 +152,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
153
152
|
const onChange = value => {
|
|
154
153
|
setInputDate(value);
|
|
155
154
|
setInputText(value.format(dateFormat));
|
|
155
|
+
setIsFocused(false);
|
|
156
156
|
if (onDateChange) onDateChange(value);
|
|
157
157
|
};
|
|
158
158
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { InputField, InputWrapper, LeftButtonWrapper, RightButtonWrapper } from './styles';
|
|
3
|
+
import { Box, TextInput, Spacer, Feedback, InputLabel, useInputValue, useCopy, useThemeTokensCallback } from '@telus-uds/components-base';
|
|
4
|
+
import { InputField, InputWrapper } from './styles';
|
|
6
5
|
import defaultDictionary from './dictionary';
|
|
6
|
+
import SideButton from './SideButton';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
const {
|
|
@@ -20,6 +20,7 @@ const QuantitySelector = _ref => {
|
|
|
20
20
|
minNumber,
|
|
21
21
|
maxNumber,
|
|
22
22
|
defaultValue,
|
|
23
|
+
value,
|
|
23
24
|
label,
|
|
24
25
|
hint,
|
|
25
26
|
hintPosition,
|
|
@@ -33,19 +34,9 @@ const QuantitySelector = _ref => {
|
|
|
33
34
|
testID
|
|
34
35
|
} = _ref;
|
|
35
36
|
const {
|
|
36
|
-
|
|
37
|
-
QuantitySelector: componentTheme
|
|
38
|
-
}
|
|
39
|
-
} = useTheme();
|
|
40
|
-
const {
|
|
41
|
-
leftIcon,
|
|
42
|
-
rightIcon,
|
|
43
|
-
padding
|
|
44
|
-
} = useThemeTokens('QuantitySelector', tokens, variant);
|
|
45
|
-
const [error, setError] = useState('');
|
|
46
|
-
const {
|
|
47
|
-
alternative
|
|
37
|
+
disabled
|
|
48
38
|
} = variant;
|
|
39
|
+
const [error, setError] = useState('');
|
|
49
40
|
const getCopy = useCopy({
|
|
50
41
|
dictionary,
|
|
51
42
|
copy
|
|
@@ -58,17 +49,16 @@ const QuantitySelector = _ref => {
|
|
|
58
49
|
return numberToEvaluate;
|
|
59
50
|
};
|
|
60
51
|
|
|
61
|
-
const initialValue = getValidatedNumber(defaultValue);
|
|
62
52
|
const {
|
|
63
53
|
currentValue: number,
|
|
64
54
|
setValue: setNumber
|
|
65
55
|
} = useInputValue({
|
|
66
|
-
value:
|
|
67
|
-
initialValue,
|
|
56
|
+
value: getValidatedNumber(value),
|
|
57
|
+
initialValue: getValidatedNumber(defaultValue),
|
|
68
58
|
onChange
|
|
69
59
|
});
|
|
70
|
-
const isDecreaseEnabled = !isNumber(minNumber) || number > minNumber;
|
|
71
|
-
const isIncreaseEnabled = !isNumber(maxNumber) || number < maxNumber;
|
|
60
|
+
const isDecreaseEnabled = !disabled && !isNumber(minNumber) || number > minNumber;
|
|
61
|
+
const isIncreaseEnabled = !disabled && !isNumber(maxNumber) || number < maxNumber;
|
|
72
62
|
const inputValue = isNumber(number) ? number.toString() : '';
|
|
73
63
|
|
|
74
64
|
const updateNumber = (newNumber, originalInputEvent) => {
|
|
@@ -100,20 +90,31 @@ const QuantitySelector = _ref => {
|
|
|
100
90
|
tooltip: tooltip
|
|
101
91
|
}) : null;
|
|
102
92
|
|
|
93
|
+
const getTokens = useThemeTokensCallback('QuantitySelector', tokens, variant);
|
|
94
|
+
|
|
103
95
|
const renderTextInput = () => /*#__PURE__*/_jsx(TextInput, {
|
|
104
96
|
nativeID: id,
|
|
105
97
|
value: inputValue,
|
|
98
|
+
defaultValue: defaultValue,
|
|
106
99
|
tokens: textInputState => {
|
|
107
100
|
const {
|
|
101
|
+
inputWidth,
|
|
102
|
+
inputBorderWidth,
|
|
108
103
|
inputBorderColor,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
textColor,
|
|
105
|
+
inputBackgroundColor,
|
|
106
|
+
...rest
|
|
107
|
+
} = getTokens({ ...textInputState
|
|
108
|
+
});
|
|
109
|
+
return { ...rest,
|
|
110
|
+
order: 1,
|
|
111
|
+
borderWidth: inputBorderWidth,
|
|
112
|
+
backgroundColor: inputBackgroundColor,
|
|
113
|
+
color: textColor,
|
|
114
|
+
width: inputWidth,
|
|
115
115
|
borderColor: inputBorderColor,
|
|
116
|
-
|
|
116
|
+
borderRadius: 0,
|
|
117
|
+
outerBorderWidth: 0
|
|
117
118
|
};
|
|
118
119
|
},
|
|
119
120
|
onChange: inputChangeHandler // Using title as an accessibility workaround
|
|
@@ -127,38 +128,6 @@ const QuantitySelector = _ref => {
|
|
|
127
128
|
accessibilityValueNow: number
|
|
128
129
|
});
|
|
129
130
|
|
|
130
|
-
const getButtonTokens = isEnabled => buttonState => {
|
|
131
|
-
const disabled = !isEnabled;
|
|
132
|
-
const { ...buttonTokens
|
|
133
|
-
} = getThemeTokens(componentTheme, tokens, variant, { ...buttonState,
|
|
134
|
-
disabled
|
|
135
|
-
});
|
|
136
|
-
return { ...buttonTokens,
|
|
137
|
-
outerBorderGap: 0,
|
|
138
|
-
padding
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const renderLeftButton = () => {
|
|
143
|
-
return /*#__PURE__*/_jsx(IconButton, {
|
|
144
|
-
icon: leftIcon,
|
|
145
|
-
tokens: getButtonTokens(isDecreaseEnabled),
|
|
146
|
-
onPress: event => updateNumber(number - 1, event),
|
|
147
|
-
onDoubleClick: event => updateNumber(number - 1, event),
|
|
148
|
-
accessibilityLabel: getCopy('accessibility').decreaseButton,
|
|
149
|
-
accessibilityDisabled: !isDecreaseEnabled
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const renderRightButton = () => /*#__PURE__*/_jsx(IconButton, {
|
|
154
|
-
icon: rightIcon,
|
|
155
|
-
tokens: getButtonTokens(isIncreaseEnabled),
|
|
156
|
-
onPress: () => updateNumber(number + 1),
|
|
157
|
-
onDoubleClick: () => updateNumber(number + 1),
|
|
158
|
-
accessibilityLabel: getCopy('accessibility').increaseButton,
|
|
159
|
-
accessibilityDisabled: !isIncreaseEnabled
|
|
160
|
-
});
|
|
161
|
-
|
|
162
131
|
return /*#__PURE__*/_jsxs(Box, {
|
|
163
132
|
space: 2,
|
|
164
133
|
testID: testID,
|
|
@@ -166,14 +135,39 @@ const QuantitySelector = _ref => {
|
|
|
166
135
|
space: 2
|
|
167
136
|
}), /*#__PURE__*/_jsxs(InputWrapper, {
|
|
168
137
|
children: [/*#__PURE__*/_jsx(InputField, {
|
|
169
|
-
className: `${alternative ? 'alternative' : ''}`,
|
|
170
138
|
children: renderTextInput()
|
|
171
|
-
}), /*#__PURE__*/_jsx(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
139
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
140
|
+
style: {
|
|
141
|
+
order: 0
|
|
142
|
+
},
|
|
143
|
+
children: /*#__PURE__*/_jsx(SideButton, {
|
|
144
|
+
isEnabled: isDecreaseEnabled,
|
|
145
|
+
onPress: () => updateNumber(number - 1),
|
|
146
|
+
onDoubleClick: () => updateNumber(number - 1),
|
|
147
|
+
tokens: tokens,
|
|
148
|
+
variant: {
|
|
149
|
+
decrease: true,
|
|
150
|
+
...variant
|
|
151
|
+
},
|
|
152
|
+
accessibilityLabel: getCopy('accessibility').decreaseButton,
|
|
153
|
+
accessibilityDisabled: !isDecreaseEnabled
|
|
154
|
+
})
|
|
155
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
156
|
+
style: {
|
|
157
|
+
order: 2
|
|
158
|
+
},
|
|
159
|
+
children: /*#__PURE__*/_jsx(SideButton, {
|
|
160
|
+
isEnabled: isIncreaseEnabled,
|
|
161
|
+
onPress: () => updateNumber(number + 1),
|
|
162
|
+
onDoubleClick: () => updateNumber(number + 1),
|
|
163
|
+
accessibilityLabel: getCopy('accessibility').increaseButton,
|
|
164
|
+
accessibilityDisabled: !isIncreaseEnabled,
|
|
165
|
+
tokens: tokens,
|
|
166
|
+
variant: {
|
|
167
|
+
increase: true,
|
|
168
|
+
...variant
|
|
169
|
+
}
|
|
170
|
+
})
|
|
177
171
|
})]
|
|
178
172
|
}), error ? /*#__PURE__*/_jsx(Box, {
|
|
179
173
|
vertical: 2,
|
|
@@ -224,6 +218,12 @@ QuantitySelector.propTypes = {
|
|
|
224
218
|
*/
|
|
225
219
|
defaultValue: PropTypes.number,
|
|
226
220
|
|
|
221
|
+
/**
|
|
222
|
+
* If the input's state is to be controlled by a parent component, use this prop
|
|
223
|
+
* together with the `onChange` to pass down and update the lifted state.
|
|
224
|
+
*/
|
|
225
|
+
value: PropTypes.number,
|
|
226
|
+
|
|
227
227
|
/**
|
|
228
228
|
* The label of the input field
|
|
229
229
|
*/
|
|
@@ -262,7 +262,8 @@ QuantitySelector.propTypes = {
|
|
|
262
262
|
*/
|
|
263
263
|
copy: PropTypes.oneOfType([PropTypes.oneOf(['en', 'fr'])]),
|
|
264
264
|
variant: PropTypes.exact({
|
|
265
|
-
alternative: PropTypes.bool
|
|
265
|
+
alternative: PropTypes.bool,
|
|
266
|
+
disabled: PropTypes.bool
|
|
266
267
|
}),
|
|
267
268
|
tokens: PropTypes.oneOf([PropTypes.object, PropTypes.func]),
|
|
268
269
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { IconButton, useThemeTokensCallback } from '@telus-uds/components-base';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
const SideButton = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
isEnabled,
|
|
9
|
+
onPress,
|
|
10
|
+
onDoubleClick,
|
|
11
|
+
accessibilityLabel,
|
|
12
|
+
accessibilityDisabled,
|
|
13
|
+
tokens,
|
|
14
|
+
variant
|
|
15
|
+
} = _ref;
|
|
16
|
+
const getTokens = useThemeTokensCallback('QuantitySelectorSideButton', tokens, variant);
|
|
17
|
+
|
|
18
|
+
const getButtonTokens = _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
buttonState,
|
|
21
|
+
disabled
|
|
22
|
+
} = _ref2;
|
|
23
|
+
const {
|
|
24
|
+
borderRadius,
|
|
25
|
+
borderTopLeftRadius,
|
|
26
|
+
borderTopRightRadius,
|
|
27
|
+
borderBottomLeftRadius,
|
|
28
|
+
borderBottomRightRadius,
|
|
29
|
+
...rest
|
|
30
|
+
} = getTokens({ ...buttonState,
|
|
31
|
+
disabled
|
|
32
|
+
});
|
|
33
|
+
return { ...rest,
|
|
34
|
+
borderRadius,
|
|
35
|
+
borderTopLeftRadius,
|
|
36
|
+
borderTopRightRadius,
|
|
37
|
+
borderBottomLeftRadius,
|
|
38
|
+
borderBottomRightRadius,
|
|
39
|
+
outerBorderRadius: borderRadius,
|
|
40
|
+
outerBorderTopLeftRadius: borderTopLeftRadius,
|
|
41
|
+
outerBorderTopRightRadius: borderTopRightRadius,
|
|
42
|
+
outerBorderBottomLeftRadius: borderBottomLeftRadius,
|
|
43
|
+
outerBorderBottomRightRadius: borderBottomRightRadius,
|
|
44
|
+
outerBorderGap: 0,
|
|
45
|
+
outerBorderWidth: 0
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/_jsx(IconButton, {
|
|
50
|
+
tokens: buttonState => getButtonTokens({
|
|
51
|
+
disabled: !isEnabled,
|
|
52
|
+
buttonState
|
|
53
|
+
}),
|
|
54
|
+
onPress: onPress,
|
|
55
|
+
onDoubleClick: onDoubleClick,
|
|
56
|
+
accessibilityLabel: accessibilityLabel,
|
|
57
|
+
accessibilityDisabled: accessibilityDisabled
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
SideButton.displayName = 'QuantitySelectorSideButton';
|
|
62
|
+
SideButton.defaultProps = {
|
|
63
|
+
isEnabled: true,
|
|
64
|
+
onPress: () => {},
|
|
65
|
+
onDoubleClick: () => {},
|
|
66
|
+
accessibilityLabel: '',
|
|
67
|
+
accessibilityDisabled: false,
|
|
68
|
+
tokens: {},
|
|
69
|
+
variant: {}
|
|
70
|
+
};
|
|
71
|
+
SideButton.propTypes = {
|
|
72
|
+
isEnabled: PropTypes.bool,
|
|
73
|
+
onPress: PropTypes.func,
|
|
74
|
+
onDoubleClick: PropTypes.func,
|
|
75
|
+
accessibilityLabel: PropTypes.string,
|
|
76
|
+
accessibilityDisabled: PropTypes.bool,
|
|
77
|
+
tokens: PropTypes.object,
|
|
78
|
+
variant: PropTypes.object
|
|
79
|
+
};
|
|
80
|
+
export default SideButton;
|
|
@@ -2,20 +2,8 @@ import styled from 'styled-components';
|
|
|
2
2
|
export const InputField = /*#__PURE__*/styled.div.withConfig({
|
|
3
3
|
displayName: "styles__InputField",
|
|
4
4
|
componentId: "components-web__sc-1lrz1xk-0"
|
|
5
|
-
})(["order:
|
|
6
|
-
const ButtonWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
7
|
-
displayName: "styles__ButtonWrapper",
|
|
8
|
-
componentId: "components-web__sc-1lrz1xk-1"
|
|
9
|
-
})(["&.alternative{div[role='button']{height:42px;> div{height:40px;> div{padding:12px 16px;}}}}"]);
|
|
10
|
-
export const LeftButtonWrapper = /*#__PURE__*/styled(ButtonWrapper).withConfig({
|
|
11
|
-
displayName: "styles__LeftButtonWrapper",
|
|
12
|
-
componentId: "components-web__sc-1lrz1xk-2"
|
|
13
|
-
})(["order:0;div[role='button']{border-radius:4px 0px 0px 4px !important;> div{border-right:none;border-radius:4px 0px 0px 4px !important;}}&.alternative{div[role='button']{border-radius:36px 0px 0px 36px !important;> div{border-radius:24px 0px 0px 24px !important;}}}"]);
|
|
14
|
-
export const RightButtonWrapper = /*#__PURE__*/styled(ButtonWrapper).withConfig({
|
|
15
|
-
displayName: "styles__RightButtonWrapper",
|
|
16
|
-
componentId: "components-web__sc-1lrz1xk-3"
|
|
17
|
-
})(["order:3;div[role='button']{border-radius:0px 4px 4px 0px !important;> div{border-left:none;border-radius:0px 4px 4px 0px !important;}}&.alternative{div[role='button']{border-radius:0px 36px 36px 0px !important;> div{border-radius:0px 36px 36px 0px !important;}}}"]);
|
|
5
|
+
})(["order:1;text-align:center;z-index:10;input{text-align:center;}"]);
|
|
18
6
|
export const InputWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
19
7
|
displayName: "styles__InputWrapper",
|
|
20
|
-
componentId: "components-web__sc-1lrz1xk-
|
|
21
|
-
})(["
|
|
8
|
+
componentId: "components-web__sc-1lrz1xk-1"
|
|
9
|
+
})(["text-align:start;display:flex;flex-direction:row;flex-wrap:nowrap;"]);
|