@telus-uds/components-web 2.33.2 → 2.34.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 +29 -3
- package/lib/Badge/Badge.js +4 -2
- package/lib/BlockQuote/BlockQuote.js +4 -2
- package/lib/Breadcrumbs/Breadcrumbs.js +7 -5
- package/lib/Breadcrumbs/Item/Item.js +2 -13
- package/lib/Callout/Callout.js +4 -2
- package/lib/Card/Card.js +3 -5
- package/lib/Card/CardContent.js +4 -2
- package/lib/Countdown/Countdown.js +2 -6
- package/lib/Countdown/Segment.js +4 -2
- package/lib/DatePicker/CalendarContainer.js +2 -2
- package/lib/DatePicker/DatePicker.js +21 -35
- package/lib/Disclaimer/Disclaimer.js +4 -2
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +5 -11
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +4 -2
- package/lib/Footnote/Footnote.js +32 -37
- package/lib/Footnote/FootnoteLink.js +9 -6
- package/lib/IconButton/IconButton.js +4 -11
- package/lib/Image/Image.js +5 -3
- package/lib/List/ListItem.js +2 -7
- package/lib/NavigationBar/NavigationBar.js +8 -18
- package/lib/NavigationBar/NavigationItem.js +4 -9
- package/lib/NavigationBar/NavigationSubMenu.js +8 -7
- package/lib/NavigationBar/index.js +2 -0
- package/lib/OptimizeImage/OptimizeImage.js +8 -8
- package/lib/OrderedList/Item.js +3 -9
- package/lib/OrderedList/OrderedList.js +5 -13
- package/lib/OrderedList/OrderedListBase.js +3 -8
- package/lib/Paragraph/Paragraph.js +5 -3
- package/lib/PreviewCard/PreviewCard.js +3 -5
- package/lib/PriceLockup/PriceLockup.js +4 -2
- package/lib/Progress/ProgressBar.js +4 -2
- package/lib/QuantitySelector/QuantitySelector.js +21 -24
- package/lib/QuantitySelector/SideButton.js +12 -20
- package/lib/ResponsiveImage/ResponsiveImage.js +4 -2
- package/lib/Ribbon/Ribbon.js +4 -2
- package/lib/SkeletonProvider/SkeletonImage.js +5 -3
- package/lib/SkeletonProvider/SkeletonProvider.js +3 -5
- package/lib/SkeletonProvider/SkeletonTypography.js +5 -3
- package/lib/Span/Span.js +5 -3
- package/lib/Spinner/Spinner.js +4 -2
- package/lib/Spinner/SpinnerContent.js +4 -2
- package/lib/StoryCard/StoryCard.js +3 -5
- package/lib/Table/Body.js +4 -2
- package/lib/Table/Cell.js +5 -3
- package/lib/Table/Header.js +6 -6
- package/lib/Table/Row.js +6 -6
- package/lib/Table/SubHeading.js +6 -6
- package/lib/Table/Table.js +6 -8
- package/lib/TermsAndConditions/ExpandCollapse.js +2 -7
- package/lib/TermsAndConditions/TermsAndConditions.js +5 -14
- package/lib/Testimonial/Testimonial.js +4 -2
- package/lib/Toast/Toast.js +4 -2
- package/lib/Video/Video.js +19 -55
- package/lib/VideoPicker/VideoPicker.js +38 -9
- package/lib/VideoPicker/VideoPickerPlayer.js +4 -2
- package/lib/VideoPicker/VideoPickerThumbnail.js +4 -2
- package/lib/VideoPicker/VideoSlider.js +7 -7
- package/lib/WaffleGrid/WaffleGrid.js +4 -2
- package/lib/WebVideo/WebVideo.js +51 -13
- package/lib/WebVideo/utils/index.js +58 -0
- package/lib/baseExports.js +6 -0
- package/lib/utils/theming/with-client-theme.js +1 -1
- package/lib/utils/theming/with-server-theme.js +1 -1
- package/lib-module/Badge/Badge.js +4 -2
- package/lib-module/BlockQuote/BlockQuote.js +4 -2
- package/lib-module/Breadcrumbs/Breadcrumbs.js +7 -5
- package/lib-module/Breadcrumbs/Item/Item.js +2 -11
- package/lib-module/Callout/Callout.js +4 -2
- package/lib-module/Card/Card.js +2 -3
- package/lib-module/Card/CardContent.js +4 -2
- package/lib-module/Countdown/Countdown.js +2 -3
- package/lib-module/Countdown/Segment.js +4 -2
- package/lib-module/DatePicker/CalendarContainer.js +2 -2
- package/lib-module/DatePicker/DatePicker.js +21 -33
- package/lib-module/Disclaimer/Disclaimer.js +4 -2
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +5 -9
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +4 -2
- package/lib-module/Footnote/Footnote.js +31 -36
- package/lib-module/Footnote/FootnoteLink.js +9 -7
- package/lib-module/IconButton/IconButton.js +4 -9
- package/lib-module/Image/Image.js +5 -3
- package/lib-module/List/ListItem.js +2 -5
- package/lib-module/NavigationBar/NavigationBar.js +9 -17
- package/lib-module/NavigationBar/NavigationItem.js +5 -8
- package/lib-module/NavigationBar/NavigationSubMenu.js +9 -6
- package/lib-module/NavigationBar/index.js +2 -0
- package/lib-module/OptimizeImage/OptimizeImage.js +8 -6
- package/lib-module/OrderedList/Item.js +3 -7
- package/lib-module/OrderedList/OrderedList.js +6 -12
- package/lib-module/OrderedList/OrderedListBase.js +3 -6
- package/lib-module/Paragraph/Paragraph.js +6 -4
- package/lib-module/PreviewCard/PreviewCard.js +2 -3
- package/lib-module/PriceLockup/PriceLockup.js +4 -2
- package/lib-module/Progress/ProgressBar.js +4 -2
- package/lib-module/QuantitySelector/QuantitySelector.js +22 -23
- package/lib-module/QuantitySelector/SideButton.js +13 -21
- package/lib-module/ResponsiveImage/ResponsiveImage.js +4 -2
- package/lib-module/Ribbon/Ribbon.js +4 -2
- package/lib-module/SkeletonProvider/SkeletonImage.js +5 -3
- package/lib-module/SkeletonProvider/SkeletonProvider.js +3 -3
- package/lib-module/SkeletonProvider/SkeletonTypography.js +5 -3
- package/lib-module/Span/Span.js +6 -4
- package/lib-module/Spinner/Spinner.js +4 -2
- package/lib-module/Spinner/SpinnerContent.js +4 -2
- package/lib-module/StoryCard/StoryCard.js +2 -3
- package/lib-module/Table/Body.js +4 -2
- package/lib-module/Table/Cell.js +5 -3
- package/lib-module/Table/Header.js +6 -4
- package/lib-module/Table/Row.js +6 -4
- package/lib-module/Table/SubHeading.js +6 -4
- package/lib-module/Table/Table.js +6 -6
- package/lib-module/TermsAndConditions/ExpandCollapse.js +2 -5
- package/lib-module/TermsAndConditions/TermsAndConditions.js +5 -12
- package/lib-module/Testimonial/Testimonial.js +4 -2
- package/lib-module/Toast/Toast.js +4 -2
- package/lib-module/Video/Video.js +19 -53
- package/lib-module/VideoPicker/VideoPicker.js +37 -8
- package/lib-module/VideoPicker/VideoPickerPlayer.js +4 -2
- package/lib-module/VideoPicker/VideoPickerThumbnail.js +4 -2
- package/lib-module/VideoPicker/VideoSlider.js +7 -5
- package/lib-module/WaffleGrid/WaffleGrid.js +4 -2
- package/lib-module/WebVideo/WebVideo.js +51 -11
- package/lib-module/WebVideo/utils/index.js +50 -0
- package/lib-module/baseExports.js +1 -1
- package/lib-module/utils/theming/with-client-theme.js +2 -2
- package/lib-module/utils/theming/with-server-theme.js +2 -2
- package/package.json +3 -3
- package/src/Badge/Badge.jsx +5 -2
- package/src/BlockQuote/BlockQuote.jsx +120 -112
- package/src/Breadcrumbs/Breadcrumbs.jsx +84 -77
- package/src/Breadcrumbs/Item/Item.jsx +2 -9
- package/src/Callout/Callout.jsx +37 -40
- package/src/Card/Card.jsx +2 -3
- package/src/Card/CardContent.jsx +19 -14
- package/src/Countdown/Countdown.jsx +72 -71
- package/src/Countdown/Segment.jsx +40 -28
- package/src/DatePicker/CalendarContainer.jsx +2 -2
- package/src/DatePicker/DatePicker.jsx +21 -34
- package/src/Disclaimer/Disclaimer.jsx +5 -3
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +37 -40
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +52 -44
- package/src/Footnote/Footnote.jsx +32 -38
- package/src/Footnote/FootnoteLink.jsx +45 -49
- package/src/IconButton/IconButton.jsx +19 -20
- package/src/Image/Image.jsx +40 -43
- package/src/List/ListItem.jsx +3 -5
- package/src/NavigationBar/NavigationBar.jsx +9 -18
- package/src/NavigationBar/NavigationItem.jsx +6 -5
- package/src/NavigationBar/NavigationSubMenu.jsx +104 -88
- package/src/NavigationBar/index.js +3 -0
- package/src/OptimizeImage/OptimizeImage.jsx +48 -41
- package/src/OrderedList/Item.jsx +34 -35
- package/src/OrderedList/OrderedList.jsx +4 -6
- package/src/OrderedList/OrderedListBase.jsx +2 -3
- package/src/Paragraph/Paragraph.jsx +21 -16
- package/src/PreviewCard/PreviewCard.jsx +2 -3
- package/src/PriceLockup/PriceLockup.jsx +143 -136
- package/src/Progress/ProgressBar.jsx +11 -3
- package/src/QuantitySelector/QuantitySelector.jsx +162 -154
- package/src/QuantitySelector/SideButton.jsx +52 -56
- package/src/ResponsiveImage/ResponsiveImage.jsx +16 -22
- package/src/Ribbon/Ribbon.jsx +85 -83
- package/src/SkeletonProvider/SkeletonImage.jsx +24 -15
- package/src/SkeletonProvider/SkeletonProvider.jsx +3 -3
- package/src/SkeletonProvider/SkeletonTypography.jsx +18 -13
- package/src/Span/Span.jsx +7 -5
- package/src/Spinner/Spinner.jsx +86 -79
- package/src/Spinner/SpinnerContent.jsx +31 -33
- package/src/StoryCard/StoryCard.jsx +2 -3
- package/src/Table/Body.jsx +5 -3
- package/src/Table/Cell.jsx +77 -67
- package/src/Table/Header.jsx +7 -5
- package/src/Table/Row.jsx +7 -5
- package/src/Table/SubHeading.jsx +7 -5
- package/src/Table/Table.jsx +6 -6
- package/src/TermsAndConditions/ExpandCollapse.jsx +2 -6
- package/src/TermsAndConditions/TermsAndConditions.jsx +5 -13
- package/src/Testimonial/Testimonial.jsx +148 -137
- package/src/Toast/Toast.jsx +68 -63
- package/src/Video/Video.jsx +25 -45
- package/src/VideoPicker/VideoPicker.jsx +114 -75
- package/src/VideoPicker/VideoPickerPlayer.jsx +13 -9
- package/src/VideoPicker/VideoPickerThumbnail.jsx +102 -94
- package/src/VideoPicker/VideoSlider.jsx +8 -6
- package/src/WaffleGrid/WaffleGrid.jsx +36 -40
- package/src/WebVideo/WebVideo.jsx +114 -60
- package/src/WebVideo/utils/index.js +56 -0
- package/src/baseExports.js +1 -0
- package/src/utils/theming/with-client-theme.jsx +2 -2
- package/src/utils/theming/with-server-theme.jsx +2 -2
- package/types/WebVideo.d.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import {
|
|
4
4
|
Box,
|
|
@@ -8,8 +8,12 @@ import {
|
|
|
8
8
|
InputLabel,
|
|
9
9
|
useInputValue,
|
|
10
10
|
useCopy,
|
|
11
|
-
useThemeTokensCallback
|
|
11
|
+
useThemeTokensCallback,
|
|
12
|
+
getTokensPropType,
|
|
13
|
+
selectSystemProps,
|
|
14
|
+
a11yProps
|
|
12
15
|
} from '@telus-uds/components-base'
|
|
16
|
+
import { htmlAttrs } from '../utils'
|
|
13
17
|
|
|
14
18
|
import { InputField, InputWrapper } from './styles'
|
|
15
19
|
import defaultDictionary from './dictionary'
|
|
@@ -21,159 +25,169 @@ const isNumber = (value) => {
|
|
|
21
25
|
return typeof value === 'number' && !isNaN(value)
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
const
|
|
25
|
-
id,
|
|
26
|
-
minNumber,
|
|
27
|
-
maxNumber,
|
|
28
|
-
defaultValue,
|
|
29
|
-
value,
|
|
30
|
-
label,
|
|
31
|
-
hint,
|
|
32
|
-
hintPosition,
|
|
33
|
-
tooltip,
|
|
34
|
-
onChange,
|
|
35
|
-
dictionary = defaultDictionary,
|
|
36
|
-
accessibilityLabel,
|
|
37
|
-
copy,
|
|
38
|
-
variant,
|
|
39
|
-
tokens,
|
|
40
|
-
testID
|
|
41
|
-
}) => {
|
|
42
|
-
const { disabled } = variant
|
|
43
|
-
const [error, setError] = useState('')
|
|
44
|
-
const getCopy = useCopy({ dictionary, copy })
|
|
28
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, htmlAttrs])
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
30
|
+
const QuantitySelector = React.forwardRef(
|
|
31
|
+
(
|
|
32
|
+
{
|
|
33
|
+
id = 'quantity-selector',
|
|
34
|
+
minNumber,
|
|
35
|
+
maxNumber,
|
|
36
|
+
defaultValue,
|
|
37
|
+
value,
|
|
38
|
+
label,
|
|
39
|
+
hint,
|
|
40
|
+
hintPosition = 'inline',
|
|
41
|
+
tooltip,
|
|
42
|
+
onChange,
|
|
43
|
+
dictionary = defaultDictionary,
|
|
44
|
+
accessibilityLabel,
|
|
45
|
+
copy = 'en',
|
|
46
|
+
variant = {
|
|
47
|
+
alternative: false
|
|
48
|
+
},
|
|
49
|
+
tokens,
|
|
50
|
+
testID = 'quantity-selector-testid',
|
|
51
|
+
...rest
|
|
52
|
+
},
|
|
53
|
+
ref
|
|
54
|
+
) => {
|
|
55
|
+
const { disabled } = variant
|
|
56
|
+
const [error, setError] = React.useState('')
|
|
57
|
+
const getCopy = useCopy({ dictionary, copy })
|
|
58
|
+
|
|
59
|
+
const getValidatedNumber = (numberToEvaluate) => {
|
|
60
|
+
if (isNaN(numberToEvaluate)) return null
|
|
61
|
+
if (isNumber(minNumber) && numberToEvaluate < minNumber)
|
|
62
|
+
throw getCopy('errors').numberIsTooSmall(minNumber)
|
|
63
|
+
if (isNumber(maxNumber) && numberToEvaluate > maxNumber)
|
|
64
|
+
throw getCopy('errors').numberIsTooBig(maxNumber)
|
|
65
|
+
return numberToEvaluate
|
|
66
|
+
}
|
|
54
67
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
const { currentValue: number, setValue: setNumber } = useInputValue({
|
|
69
|
+
value: getValidatedNumber(value),
|
|
70
|
+
initialValue: getValidatedNumber(defaultValue),
|
|
71
|
+
onChange
|
|
72
|
+
})
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
const isDecreaseEnabled = (!disabled && !isNumber(minNumber)) || number > minNumber
|
|
75
|
+
const isIncreaseEnabled = (!disabled && !isNumber(maxNumber)) || number < maxNumber
|
|
76
|
+
const inputValue = isNumber(number) ? number.toString() : ''
|
|
64
77
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
const updateNumber = (newNumber, originalInputEvent) => {
|
|
79
|
+
try {
|
|
80
|
+
const validatedNumber = getValidatedNumber(newNumber)
|
|
81
|
+
setNumber(validatedNumber, originalInputEvent)
|
|
82
|
+
setError('')
|
|
83
|
+
} catch (e) {
|
|
84
|
+
setError(e)
|
|
85
|
+
}
|
|
72
86
|
}
|
|
73
|
-
}
|
|
74
87
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
const inputChangeHandler = (textInputValue, event) => {
|
|
89
|
+
if (textInputValue === '') setNumber(null)
|
|
90
|
+
const numberFromTextInput = Number(textInputValue)
|
|
91
|
+
if (isNumber(numberFromTextInput)) {
|
|
92
|
+
updateNumber(numberFromTextInput, event)
|
|
93
|
+
} else {
|
|
94
|
+
setError(getCopy('errors').invalidCharacters)
|
|
95
|
+
}
|
|
82
96
|
}
|
|
83
|
-
}
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
const renderLabel = () =>
|
|
99
|
+
label ? (
|
|
100
|
+
<InputLabel
|
|
101
|
+
forId={id}
|
|
102
|
+
label={label}
|
|
103
|
+
hint={hint}
|
|
104
|
+
hintPosition={hintPosition}
|
|
105
|
+
tooltip={tooltip}
|
|
106
|
+
/>
|
|
107
|
+
) : null
|
|
95
108
|
|
|
96
|
-
|
|
109
|
+
const getTokens = useThemeTokensCallback('QuantitySelector', tokens, variant)
|
|
97
110
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
111
|
+
const renderTextInput = () => (
|
|
112
|
+
<TextInput
|
|
113
|
+
nativeID={id}
|
|
114
|
+
value={inputValue}
|
|
115
|
+
defaultValue={defaultValue}
|
|
116
|
+
tokens={(textInputState) => {
|
|
117
|
+
const {
|
|
118
|
+
inputWidth,
|
|
119
|
+
inputBorderWidth,
|
|
120
|
+
inputBorderColor,
|
|
121
|
+
textColor,
|
|
122
|
+
inputBackgroundColor,
|
|
123
|
+
...restOfTokens
|
|
124
|
+
} = getTokens({
|
|
125
|
+
...textInputState
|
|
126
|
+
})
|
|
127
|
+
return {
|
|
128
|
+
...restOfTokens,
|
|
129
|
+
order: 1,
|
|
130
|
+
borderWidth: inputBorderWidth,
|
|
131
|
+
backgroundColor: inputBackgroundColor,
|
|
132
|
+
color: textColor,
|
|
133
|
+
width: inputWidth,
|
|
134
|
+
borderColor: inputBorderColor,
|
|
135
|
+
borderRadius: 0,
|
|
136
|
+
outerBorderWidth: 0
|
|
137
|
+
}
|
|
138
|
+
}}
|
|
139
|
+
onChange={inputChangeHandler}
|
|
140
|
+
// Using title as an accessibility workaround
|
|
141
|
+
// given that accessibilityLabel is not available
|
|
142
|
+
keyboardType="numeric"
|
|
143
|
+
accessibilityLabel={accessibilityLabel ?? getCopy('accessibility').a11yLabel}
|
|
144
|
+
accessibilityRole="spinbutton"
|
|
145
|
+
accessibilityValueMax={maxNumber}
|
|
146
|
+
accessibilityValueMin={minNumber}
|
|
147
|
+
accessibilityValueNow={number}
|
|
148
|
+
/>
|
|
149
|
+
)
|
|
137
150
|
|
|
138
|
-
|
|
151
|
+
const flexOrder = (order) => ({ order })
|
|
139
152
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
153
|
+
return (
|
|
154
|
+
<Box testID={testID} ref={ref} {...selectProps(rest)}>
|
|
155
|
+
{renderLabel()}
|
|
156
|
+
<Spacer space={2} />
|
|
157
|
+
<InputWrapper>
|
|
158
|
+
<InputField>{renderTextInput()}</InputField>
|
|
159
|
+
<div style={flexOrder(0)}>
|
|
160
|
+
<SideButton
|
|
161
|
+
isEnabled={isDecreaseEnabled}
|
|
162
|
+
onPress={() => updateNumber(number - 1)}
|
|
163
|
+
onDoubleClick={() => updateNumber(number - 1)}
|
|
164
|
+
tokens={tokens}
|
|
165
|
+
variant={{ decrease: true, ...variant }}
|
|
166
|
+
accessibilityLabel={getCopy('accessibility').decreaseButton}
|
|
167
|
+
accessibilityDisabled={!isDecreaseEnabled}
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
<div style={flexOrder(2)}>
|
|
171
|
+
<SideButton
|
|
172
|
+
isEnabled={isIncreaseEnabled}
|
|
173
|
+
onPress={() => updateNumber(number + 1)}
|
|
174
|
+
onDoubleClick={() => updateNumber(number + 1)}
|
|
175
|
+
accessibilityLabel={getCopy('accessibility').increaseButton}
|
|
176
|
+
accessibilityDisabled={!isIncreaseEnabled}
|
|
177
|
+
tokens={tokens}
|
|
178
|
+
variant={{ increase: true, ...variant }}
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
</InputWrapper>
|
|
182
|
+
{error ? (
|
|
183
|
+
<Box vertical={2}>
|
|
184
|
+
<Feedback validation="error">{error}</Feedback>
|
|
185
|
+
</Box>
|
|
186
|
+
) : null}
|
|
187
|
+
</Box>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
)
|
|
177
191
|
|
|
178
192
|
// If a language dictionary entry is provided, it must contain every key
|
|
179
193
|
const dictionaryContentShape = PropTypes.shape({
|
|
@@ -189,7 +203,10 @@ const dictionaryContentShape = PropTypes.shape({
|
|
|
189
203
|
}).isRequired
|
|
190
204
|
})
|
|
191
205
|
|
|
206
|
+
QuantitySelector.displayName = 'QuantitySelector'
|
|
207
|
+
|
|
192
208
|
QuantitySelector.propTypes = {
|
|
209
|
+
...selectedSystemPropTypes,
|
|
193
210
|
/**
|
|
194
211
|
* The id of the input field
|
|
195
212
|
*/
|
|
@@ -250,21 +267,12 @@ QuantitySelector.propTypes = {
|
|
|
250
267
|
alternative: PropTypes.bool,
|
|
251
268
|
disabled: PropTypes.bool
|
|
252
269
|
}),
|
|
253
|
-
|
|
270
|
+
|
|
271
|
+
tokens: getTokensPropType('QuantitySelector'),
|
|
254
272
|
/**
|
|
255
273
|
* Sets `data-testid` attribute on the input field for testing purposes.
|
|
256
274
|
*/
|
|
257
275
|
testID: PropTypes.string
|
|
258
276
|
}
|
|
259
277
|
|
|
260
|
-
QuantitySelector.defaultProps = {
|
|
261
|
-
id: 'quantity-selector',
|
|
262
|
-
hintPosition: 'inline',
|
|
263
|
-
copy: 'en',
|
|
264
|
-
variant: {
|
|
265
|
-
alternative: false
|
|
266
|
-
},
|
|
267
|
-
testID: 'quantity-selector-testid'
|
|
268
|
-
}
|
|
269
|
-
|
|
270
278
|
export default QuantitySelector
|
|
@@ -1,74 +1,70 @@
|
|
|
1
|
-
import { IconButton, useThemeTokensCallback } from '@telus-uds/components-base'
|
|
1
|
+
import { IconButton, getTokensPropType, useThemeTokensCallback } from '@telus-uds/components-base'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
|
|
5
|
-
const SideButton = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
const SideButton = React.forwardRef(
|
|
6
|
+
(
|
|
7
|
+
{
|
|
8
|
+
isEnabled = true,
|
|
9
|
+
onPress = () => {},
|
|
10
|
+
onDoubleClick = () => {},
|
|
11
|
+
accessibilityLabel = '',
|
|
12
|
+
accessibilityDisabled = false,
|
|
13
|
+
tokens = {},
|
|
14
|
+
variant = {}
|
|
15
|
+
},
|
|
16
|
+
ref
|
|
17
|
+
) => {
|
|
18
|
+
const getTokens = useThemeTokensCallback('QuantitySelectorSideButton', tokens, variant)
|
|
19
|
+
const getButtonTokens = ({ buttonState, disabled }) => {
|
|
20
|
+
const {
|
|
21
|
+
borderRadius,
|
|
22
|
+
borderTopLeftRadius,
|
|
23
|
+
borderTopRightRadius,
|
|
24
|
+
borderBottomLeftRadius,
|
|
25
|
+
borderBottomRightRadius,
|
|
26
|
+
...rest
|
|
27
|
+
} = getTokens({ ...buttonState, disabled })
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
return {
|
|
30
|
+
...rest,
|
|
31
|
+
borderRadius,
|
|
32
|
+
borderTopLeftRadius,
|
|
33
|
+
borderTopRightRadius,
|
|
34
|
+
borderBottomLeftRadius,
|
|
35
|
+
borderBottomRightRadius,
|
|
36
|
+
outerBorderRadius: borderRadius,
|
|
37
|
+
outerBorderTopLeftRadius: borderTopLeftRadius,
|
|
38
|
+
outerBorderTopRightRadius: borderTopRightRadius,
|
|
39
|
+
outerBorderBottomLeftRadius: borderBottomLeftRadius,
|
|
40
|
+
outerBorderBottomRightRadius: borderBottomRightRadius,
|
|
41
|
+
outerBorderGap: 0,
|
|
42
|
+
outerBorderWidth: 0
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
|
-
}
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
return (
|
|
47
|
+
<IconButton
|
|
48
|
+
tokens={(buttonState) => getButtonTokens({ disabled: !isEnabled, buttonState })}
|
|
49
|
+
onPress={onPress}
|
|
50
|
+
onDoubleClick={onDoubleClick}
|
|
51
|
+
accessibilityLabel={accessibilityLabel}
|
|
52
|
+
accessibilityDisabled={accessibilityDisabled}
|
|
53
|
+
ref={ref}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
)
|
|
52
58
|
|
|
53
59
|
SideButton.displayName = 'QuantitySelectorSideButton'
|
|
54
60
|
|
|
55
|
-
SideButton.defaultProps = {
|
|
56
|
-
isEnabled: true,
|
|
57
|
-
onPress: () => {},
|
|
58
|
-
onDoubleClick: () => {},
|
|
59
|
-
accessibilityLabel: '',
|
|
60
|
-
accessibilityDisabled: false,
|
|
61
|
-
tokens: {},
|
|
62
|
-
variant: {}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
61
|
SideButton.propTypes = {
|
|
66
62
|
isEnabled: PropTypes.bool,
|
|
67
63
|
onPress: PropTypes.func,
|
|
68
64
|
onDoubleClick: PropTypes.func,
|
|
69
65
|
accessibilityLabel: PropTypes.string,
|
|
70
66
|
accessibilityDisabled: PropTypes.bool,
|
|
71
|
-
tokens:
|
|
67
|
+
tokens: getTokensPropType('QuantitySelectorSideButton'),
|
|
72
68
|
variant: PropTypes.object
|
|
73
69
|
}
|
|
74
70
|
export default SideButton
|
|
@@ -13,28 +13,22 @@ const staticStyles = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Provide different image sources for different screen sizes.
|
|
15
15
|
*/
|
|
16
|
-
const ResponsiveImage = (
|
|
17
|
-
xsSrc,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<source srcSet={smSrc} media={`(min-width: ${viewports.map.get(viewports.sm)}px)`} />
|
|
33
|
-
<source srcSet={xsSrc} media={`(max-width: ${viewports.map.get(viewports.sm) - 1}px)`} />
|
|
34
|
-
<img src={fallbackSrc} alt={alt} style={staticStyles.image} loading={loading} />
|
|
35
|
-
</picture>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
16
|
+
const ResponsiveImage = React.forwardRef(
|
|
17
|
+
({ xsSrc, smSrc, mdSrc, lgSrc, xlSrc, fallbackSrc, alt, loading = 'eager', ...rest }, ref) => {
|
|
18
|
+
return (
|
|
19
|
+
<picture {...selectProps(rest)} ref={ref}>
|
|
20
|
+
<source srcSet={xlSrc} media={`(min-width: ${viewports.map.get(viewports.xl)}px)`} />
|
|
21
|
+
<source srcSet={lgSrc} media={`(min-width: ${viewports.map.get(viewports.lg)}px)`} />
|
|
22
|
+
<source srcSet={mdSrc} media={`(min-width: ${viewports.map.get(viewports.md)}px)`} />
|
|
23
|
+
<source srcSet={smSrc} media={`(min-width: ${viewports.map.get(viewports.sm)}px)`} />
|
|
24
|
+
<source srcSet={xsSrc} media={`(max-width: ${viewports.map.get(viewports.sm) - 1}px)`} />
|
|
25
|
+
<img src={fallbackSrc} alt={alt} style={staticStyles.image} loading={loading} />
|
|
26
|
+
</picture>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
ResponsiveImage.displayName = 'ResponsiveImage'
|
|
38
32
|
|
|
39
33
|
ResponsiveImage.propTypes = {
|
|
40
34
|
...selectedSystemPropTypes,
|