@telus-uds/components-base 1.14.3 → 1.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 +15 -2
- package/__tests17__/A11yText/A11yText.test.jsx +34 -0
- package/__tests17__/ActivityIndicator/ActivityIndicator.test.jsx +68 -0
- package/__tests17__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +299 -0
- package/__tests17__/Box/Box.test.jsx +111 -0
- package/__tests17__/Button/Button.test.jsx +86 -0
- package/__tests17__/Button/ButtonBase.test.jsx +82 -0
- package/__tests17__/Button/ButtonGroup.test.jsx +347 -0
- package/__tests17__/Button/ButtonLink.test.jsx +61 -0
- package/__tests17__/Card/Card.test.jsx +63 -0
- package/__tests17__/Carousel/Carousel.test.jsx +128 -0
- package/__tests17__/Carousel/CarouselTabs.test.jsx +142 -0
- package/__tests17__/Checkbox/Checkbox.test.jsx +94 -0
- package/__tests17__/Checkbox/CheckboxGroup.test.jsx +246 -0
- package/__tests17__/Divider/Divider.test.jsx +91 -0
- package/__tests17__/ExpandCollapse/ExpandCollapse.test.jsx +109 -0
- package/__tests17__/Feedback/Feedback.test.jsx +42 -0
- package/__tests17__/FlexGrid/Col.test.jsx +261 -0
- package/__tests17__/FlexGrid/FlexGrid.test.jsx +136 -0
- package/__tests17__/FlexGrid/Row.test.jsx +273 -0
- package/__tests17__/HorizontalScroll/HorizontalScroll.test.jsx +165 -0
- package/__tests17__/Icon/Icon.test.jsx +61 -0
- package/__tests17__/IconButton/IconButton.test.jsx +52 -0
- package/__tests17__/InputLabel/InputLabel.test.jsx +28 -0
- package/__tests17__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +3 -0
- package/__tests17__/InputSupports/InputSupports.test.jsx +60 -0
- package/__tests17__/Link/Link.test.jsx +63 -0
- package/__tests17__/Link/TextButton.test.jsx +35 -0
- package/__tests17__/List/List.test.jsx +82 -0
- package/__tests17__/Modal/Modal.test.jsx +47 -0
- package/__tests17__/Notification/Notification.test.jsx +20 -0
- package/__tests17__/Pagination/Pagination.test.jsx +160 -0
- package/__tests17__/Progress/Progress.test.jsx +79 -0
- package/__tests17__/Radio/Radio.test.jsx +87 -0
- package/__tests17__/Radio/RadioGroup.test.jsx +220 -0
- package/__tests17__/RadioCard/RadioCard.test.jsx +87 -0
- package/__tests17__/RadioCard/RadioCardGroup.test.jsx +246 -0
- package/__tests17__/Search/Search.test.jsx +87 -0
- package/__tests17__/Select/Select.test.jsx +94 -0
- package/__tests17__/SideNav/SideNav.test.jsx +110 -0
- package/__tests17__/Skeleton/Skeleton.test.jsx +61 -0
- package/__tests17__/SkipLink/SkipLink.test.jsx +61 -0
- package/__tests17__/Spacer/Spacer.test.jsx +63 -0
- package/__tests17__/StackView/StackView.test.jsx +211 -0
- package/__tests17__/StackView/StackWrap.test.jsx +47 -0
- package/__tests17__/StackView/getStackedContent.test.jsx +295 -0
- package/__tests17__/StepTracker/StepTracker.test.jsx +108 -0
- package/__tests17__/Tabs/Tabs.test.jsx +49 -0
- package/__tests17__/Tags/Tags.test.jsx +327 -0
- package/__tests17__/TextInput/TextArea.test.jsx +35 -0
- package/__tests17__/TextInput/TextInputBase.test.jsx +125 -0
- package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +80 -0
- package/__tests17__/ThemeProvider/useThemeTokens.test.jsx +514 -0
- package/__tests17__/ThemeProvider/utils/theme-tokens.test.js +41 -0
- package/__tests17__/ToggleSwitch/ToggleSwitch.test.jsx +82 -0
- package/__tests17__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
- package/__tests17__/Tooltip/Tooltip.test.jsx +65 -0
- package/__tests17__/Tooltip/getTooltipPosition.test.js +79 -0
- package/__tests17__/Typography/typography.test.jsx +90 -0
- package/__tests17__/utils/children.test.jsx +128 -0
- package/__tests17__/utils/containUniqueFields.test.js +25 -0
- package/__tests17__/utils/input.test.js +375 -0
- package/__tests17__/utils/props.test.js +36 -0
- package/__tests17__/utils/semantics.test.jsx +34 -0
- package/__tests17__/utils/useCopy.test.js +42 -0
- package/__tests17__/utils/useResponsiveProp.test.jsx +202 -0
- package/__tests17__/utils/useSpacingScale.test.jsx +273 -0
- package/__tests17__/utils/useUniqueId.test.js +31 -0
- package/component-docs.json +85 -438
- package/lib/A11yInfoProvider/index.js +14 -5
- package/lib/Button/ButtonGroup.js +3 -2
- package/lib/Checkbox/Checkbox.js +9 -6
- package/lib/ExpandCollapse/Control.js +6 -5
- package/lib/ExpandCollapse/Panel.js +5 -4
- package/lib/List/ListItem.js +10 -236
- package/lib/List/ListItemBase.js +162 -0
- package/lib/List/ListItemContent.js +85 -0
- package/lib/List/ListItemMark.js +158 -0
- package/lib/List/PressableListItemBase.js +147 -0
- package/lib/Notification/Notification.js +2 -1
- package/lib/Pagination/Pagination.js +4 -3
- package/lib/Radio/Radio.js +9 -6
- package/lib/RadioCard/RadioCard.js +9 -6
- package/lib/Tabs/Tabs.js +12 -3
- package/lib/Tags/Tags.js +3 -3
- package/lib/TextInput/TextInput.js +5 -4
- package/lib/ViewportProvider/useViewportListener.js +11 -5
- package/lib/utils/hasOwnProperty.js +18 -0
- package/lib/utils/props/a11yProps.js +212 -45
- package/lib/utils/props/getPropSelector.js +47 -5
- package/lib/utils/useResponsiveProp.js +5 -3
- package/lib/utils/withLinkRouter.js +3 -5
- package/lib-module/A11yInfoProvider/index.js +14 -4
- package/lib-module/Button/ButtonGroup.js +3 -2
- package/lib-module/Checkbox/Checkbox.js +9 -6
- package/lib-module/ExpandCollapse/Control.js +6 -5
- package/lib-module/ExpandCollapse/Panel.js +5 -4
- package/lib-module/List/ListItem.js +13 -235
- package/lib-module/List/ListItemBase.js +139 -0
- package/lib-module/List/ListItemContent.js +66 -0
- package/lib-module/List/ListItemMark.js +143 -0
- package/lib-module/List/PressableListItemBase.js +117 -0
- package/lib-module/Notification/Notification.js +2 -1
- package/lib-module/Pagination/Pagination.js +5 -3
- package/lib-module/Radio/Radio.js +9 -6
- package/lib-module/RadioCard/RadioCard.js +9 -6
- package/lib-module/Tabs/Tabs.js +13 -4
- package/lib-module/Tags/Tags.js +3 -3
- package/lib-module/TextInput/TextInput.js +5 -4
- package/lib-module/ViewportProvider/useViewportListener.js +10 -4
- package/lib-module/utils/hasOwnProperty.js +11 -0
- package/lib-module/utils/props/a11yProps.js +210 -45
- package/lib-module/utils/props/getPropSelector.js +44 -5
- package/lib-module/utils/useResponsiveProp.js +3 -4
- package/lib-module/utils/withLinkRouter.js +3 -5
- package/package.json +11 -16
- package/src/A11yInfoProvider/index.jsx +20 -4
- package/src/Button/ButtonGroup.jsx +4 -2
- package/src/Checkbox/Checkbox.jsx +7 -3
- package/src/ExpandCollapse/Control.jsx +8 -5
- package/src/ExpandCollapse/Panel.jsx +7 -5
- package/src/List/ListItem.jsx +12 -191
- package/src/List/ListItemBase.jsx +118 -0
- package/src/List/ListItemContent.jsx +52 -0
- package/src/List/ListItemMark.jsx +99 -0
- package/src/List/PressableListItemBase.jsx +102 -0
- package/src/Notification/Notification.jsx +1 -1
- package/src/Pagination/Pagination.jsx +6 -1
- package/src/Radio/Radio.jsx +7 -3
- package/src/RadioCard/RadioCard.jsx +7 -3
- package/src/Tabs/Tabs.jsx +19 -2
- package/src/Tags/Tags.jsx +3 -3
- package/src/TextInput/TextInput.jsx +4 -4
- package/src/ViewportProvider/useViewportListener.js +10 -5
- package/src/utils/hasOwnProperty.js +11 -0
- package/src/utils/props/a11yProps.js +168 -55
- package/src/utils/props/getPropSelector.js +45 -4
- package/src/utils/useResponsiveProp.js +3 -3
- package/src/utils/withLinkRouter.jsx +1 -3
|
@@ -48,53 +48,213 @@ const nativeA11yPropTypes = {
|
|
|
48
48
|
onAccessibilityEscape: _propTypes.default.func,
|
|
49
49
|
onAccessibilityTap: _propTypes.default.func
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
const a11yPropTypes = _Platform.default.select({
|
|
52
53
|
// React Native Web adds many a11y props that alias aria-* attributes
|
|
53
54
|
// Types based on https://necolas.github.io/react-native-web/docs/accessibility/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
55
|
+
web: { ...nativeA11yPropTypes,
|
|
56
|
+
accessibilityActiveDescendant: _propTypes.default.string,
|
|
57
|
+
accessibilityAtomic: _propTypes.default.bool,
|
|
58
|
+
accessibilityAutoComplete: _propTypes.default.string,
|
|
59
|
+
accessibilityBusy: _propTypes.default.bool,
|
|
60
|
+
accessibilityChecked: _propTypes.default.oneOf([true, false, 'mixed']),
|
|
61
|
+
accessibilityColumnCount: _propTypes.default.number,
|
|
62
|
+
accessibilityColumnIndex: _propTypes.default.number,
|
|
63
|
+
accessibilityColumnSpan: _propTypes.default.number,
|
|
64
|
+
accessibilityControls: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
65
|
+
accessibilityCurrent: _propTypes.default.oneOf([true, false, 'page', 'step', 'location', 'date', 'time']),
|
|
66
|
+
accessibilityDescribedBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
67
|
+
accessibilityDetails: _propTypes.default.string,
|
|
68
|
+
accessibilityDisabled: _propTypes.default.bool,
|
|
69
|
+
accessibilityErrorMessage: _propTypes.default.string,
|
|
70
|
+
accessibilityExpanded: _propTypes.default.bool,
|
|
71
|
+
accessibilityFlowTo: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
72
|
+
accessibilityHasPopup: _propTypes.default.string,
|
|
73
|
+
accessibilityHidden: _propTypes.default.bool,
|
|
74
|
+
accessibilityInvalid: _propTypes.default.bool,
|
|
75
|
+
accessibilityKeyShortcuts: _propTypes.default.string,
|
|
76
|
+
accessibilityLabelledBy: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
77
|
+
accessibilityLevel: _propTypes.default.number,
|
|
78
|
+
accessibilityModal: _propTypes.default.bool,
|
|
79
|
+
accessibilityMultiline: _propTypes.default.bool,
|
|
80
|
+
accessibilityMultiSelectable: _propTypes.default.bool,
|
|
81
|
+
accessibilityOrientation: _propTypes.default.oneOf(['horizontal', 'vertical']),
|
|
82
|
+
accessibilityOwns: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
83
|
+
accessibilityPlaceholder: _propTypes.default.string,
|
|
84
|
+
accessibilityPosInSet: _propTypes.default.number,
|
|
85
|
+
accessibilityPressed: _propTypes.default.bool,
|
|
86
|
+
accessibilityReadOnly: _propTypes.default.bool,
|
|
87
|
+
accessibilityRequired: _propTypes.default.bool,
|
|
88
|
+
accessibilityRoleDescription: _propTypes.default.string,
|
|
89
|
+
accessibilityRowCount: _propTypes.default.number,
|
|
90
|
+
accessibilityRowIndex: _propTypes.default.number,
|
|
91
|
+
accessibilityRowSpan: _propTypes.default.number,
|
|
92
|
+
accessibilitySelected: _propTypes.default.bool,
|
|
93
|
+
accessibilitySetSize: _propTypes.default.number,
|
|
94
|
+
accessibilitySort: _propTypes.default.oneOf(['ascending', 'descending', 'none', 'other']),
|
|
95
|
+
accessibilityValueMax: _propTypes.default.number,
|
|
96
|
+
accessibilityValueMin: _propTypes.default.number,
|
|
97
|
+
accessibilityValueNow: _propTypes.default.number,
|
|
98
|
+
accessibilityValueText: _propTypes.default.string
|
|
99
|
+
},
|
|
100
|
+
// Ignore web-only props in native builds
|
|
101
|
+
default: nativeA11yPropTypes
|
|
102
|
+
}); // These RNW-only props only exist in RNW >=0.18. Catch them and map them according to platform
|
|
103
|
+
// so all props work on RN, RNW >=0.18 and RNW <=0.18, regardless of which they were written for:
|
|
104
|
+
// - On native, bundle them into objects, like `accessibilityValue: { max: 100 }`
|
|
105
|
+
// - On web, split them into both of:
|
|
106
|
+
// - The appropriate aria-* attr, like `aria-valuenow`, which will work regardless of RNW version
|
|
107
|
+
// - The corresponding RNW >=0.18 prop, like `accessibilityValueNow`, which in some cases does more
|
|
108
|
+
// than just add the aria-* (e.g. `accessibilityDisabled` adds `disabled` if element supports it,
|
|
109
|
+
// and future releases might add more features here).
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
const rwnPropMappings = {
|
|
113
|
+
// Former accessibilityValue props.
|
|
114
|
+
accessibilityValueMax: value => _Platform.default.select({
|
|
115
|
+
web: {
|
|
116
|
+
'aria-valuemax': value,
|
|
117
|
+
accessibilityValueMax: value
|
|
118
|
+
},
|
|
119
|
+
default: {
|
|
120
|
+
accessibilityValue: {
|
|
121
|
+
max: value
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
accessibilityValueMin: value => _Platform.default.select({
|
|
126
|
+
web: {
|
|
127
|
+
'aria-valuemin': value,
|
|
128
|
+
accessibilityValueMin: value
|
|
129
|
+
},
|
|
130
|
+
default: {
|
|
131
|
+
accessibilityValue: {
|
|
132
|
+
min: value
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
accessibilityValueNow: value => _Platform.default.select({
|
|
137
|
+
web: {
|
|
138
|
+
'aria-valuenow': value,
|
|
139
|
+
accessibilityValueNow: value
|
|
140
|
+
},
|
|
141
|
+
default: {
|
|
142
|
+
accessibilityValue: {
|
|
143
|
+
now: value
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
accessibilityValueText: value => _Platform.default.select({
|
|
148
|
+
web: {
|
|
149
|
+
'aria-valuetext': value,
|
|
150
|
+
accessibilityValueText: value
|
|
151
|
+
},
|
|
152
|
+
default: {
|
|
153
|
+
accessibilityValue: {
|
|
154
|
+
text: value
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
// Former accessibilityState props
|
|
159
|
+
accessibilityBusy: value => _Platform.default.select({
|
|
160
|
+
web: {
|
|
161
|
+
'aria-busy': value,
|
|
162
|
+
accessibilityBusy: value
|
|
163
|
+
},
|
|
164
|
+
default: {
|
|
165
|
+
accessibilityState: {
|
|
166
|
+
busy: value
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}),
|
|
170
|
+
accessibilityChecked: value => _Platform.default.select({
|
|
171
|
+
web: {
|
|
172
|
+
'aria-checked': value,
|
|
173
|
+
accessibilityChecked: value
|
|
174
|
+
},
|
|
175
|
+
default: {
|
|
176
|
+
accessibilityState: {
|
|
177
|
+
checked: value
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
accessibilityDisabled: value => _Platform.default.select({
|
|
182
|
+
web: {
|
|
183
|
+
'aria-disabled': value,
|
|
184
|
+
// RNW >= 0.18 maps `accessibilityDisabled` to `disabled` attr if element supports it
|
|
185
|
+
accessibilityDisabled: value,
|
|
186
|
+
// As of RNW 0.18.9, Pressable doesn't support `accessibilityDisabled`, only `disabled`,
|
|
187
|
+
// but everything else supports `accessibilityDisabled` but not `disabled`.
|
|
188
|
+
disabled: value
|
|
189
|
+
},
|
|
190
|
+
default: {
|
|
191
|
+
accessibilityState: {
|
|
192
|
+
disabled: value
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
accessibilityExpanded: value => _Platform.default.select({
|
|
197
|
+
web: {
|
|
198
|
+
'aria-expanded': value,
|
|
199
|
+
accessibilityExpanded: value
|
|
200
|
+
},
|
|
201
|
+
default: {
|
|
202
|
+
accessibilityState: {
|
|
203
|
+
expanded: value
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}),
|
|
207
|
+
accessibilitySelected: value => _Platform.default.select({
|
|
208
|
+
web: {
|
|
209
|
+
'aria-selected': value,
|
|
210
|
+
accessibilitySelected: value
|
|
211
|
+
},
|
|
212
|
+
default: {
|
|
213
|
+
accessibilityState: {
|
|
214
|
+
selected: value
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
})
|
|
97
218
|
};
|
|
219
|
+
|
|
220
|
+
if (_Platform.default.OS === 'web') {
|
|
221
|
+
const mapIfDefined = (value, fn) => value === undefined ? undefined : fn(value); // On Web only, these React Native object props need manual mapping in RNW >=0.18
|
|
222
|
+
// which dropped support for the React Native shape of these props.
|
|
223
|
+
// Re-use our RNW 0.18 prop mappings to support both RNW <0.18 (aria-*) and
|
|
224
|
+
// new features added in >=0.18 (e.g. for accessibilityDisabled).
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
rwnPropMappings.accessibilityValue = function () {
|
|
228
|
+
let {
|
|
229
|
+
max,
|
|
230
|
+
min,
|
|
231
|
+
now,
|
|
232
|
+
text
|
|
233
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
234
|
+
return { ...mapIfDefined(max, rwnPropMappings.accessibilityValueMax),
|
|
235
|
+
...mapIfDefined(min, rwnPropMappings.accessibilityValueMin),
|
|
236
|
+
...mapIfDefined(now, rwnPropMappings.accessibilityValueNow),
|
|
237
|
+
...mapIfDefined(text, rwnPropMappings.accessibilityValueText)
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
rwnPropMappings.accessibilityState = function () {
|
|
242
|
+
let {
|
|
243
|
+
busy,
|
|
244
|
+
checked,
|
|
245
|
+
disabled,
|
|
246
|
+
expanded,
|
|
247
|
+
selected
|
|
248
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
249
|
+
return { ...mapIfDefined(busy, rwnPropMappings.accessibilityBusy),
|
|
250
|
+
...mapIfDefined(checked, rwnPropMappings.accessibilityChecked),
|
|
251
|
+
...mapIfDefined(disabled, rwnPropMappings.accessibilityDisabled),
|
|
252
|
+
...mapIfDefined(expanded, rwnPropMappings.accessibilityExpanded),
|
|
253
|
+
...mapIfDefined(selected, rwnPropMappings.accessibilitySelected)
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
98
258
|
var _default = {
|
|
99
259
|
/**
|
|
100
260
|
* Proptypes for recognised React Native accessiblity (a11y) props.
|
|
@@ -108,7 +268,14 @@ var _default = {
|
|
|
108
268
|
* Where components accept React Native a11y props, pass { ...rest } from its props to this,
|
|
109
269
|
* then spread the returned object into the component's props (usually its outer container).
|
|
110
270
|
*/
|
|
111
|
-
select: (0, _getPropSelector.default)(
|
|
271
|
+
select: (0, _getPropSelector.default)( // Allow all React Native accessibility props
|
|
272
|
+
a11yPropTypes, // Allow any `aria-*` attribute on web; ignore them on native
|
|
273
|
+
_Platform.default.OS === 'web' && /^aria-/, // For the props added and deprecated in React Native Web 0.18, convert them to
|
|
274
|
+
// a form that is platform-appropriate and RNW-version safe
|
|
275
|
+
(key, value) => {
|
|
276
|
+
const rnwPropMapper = rwnPropMappings[key];
|
|
277
|
+
return rnwPropMapper ? rnwPropMapper(value) : undefined;
|
|
278
|
+
}),
|
|
112
279
|
|
|
113
280
|
/**
|
|
114
281
|
* Use this to disable focus for elements which are visually hidden but still rendered.
|
|
@@ -5,12 +5,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getPropSelector;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.merge"));
|
|
9
|
+
|
|
10
|
+
var _hasOwnProperty = _interopRequireDefault(require("../hasOwnProperty"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @callback PropSelectorCallback - a callback called for each prop passed to a component
|
|
16
|
+
* @param {string} key - the key for the prop to be tested
|
|
17
|
+
* @param {*} value - the value of the prop being passed in to the component
|
|
18
|
+
* @returns {object|undefined}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {PropSelectorCallback} callback
|
|
23
|
+
* @param {object} items
|
|
24
|
+
* @param {string} key
|
|
25
|
+
* @param {*} value
|
|
26
|
+
* @returns {object|undefined}
|
|
27
|
+
*/
|
|
28
|
+
const applyCallback = (callback, items, key, value) => {
|
|
29
|
+
// If there's no callback, continue and look up keys as normal
|
|
30
|
+
if (typeof callback !== 'function') return undefined;
|
|
31
|
+
const newItems = callback(key, value); // If the callback doesn't return anything, continue and look up keys as normal
|
|
32
|
+
|
|
33
|
+
if (!newItems) return undefined; // If the callback returns items, merge them in, deep merging props that are objects
|
|
34
|
+
|
|
35
|
+
return (0, _lodash.default)({}, items, newItems);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Generates a function to filter an object of props down to a subset of allowed props, with
|
|
39
|
+
* optional prop alteration and re-mapping via an optional callback.
|
|
40
|
+
*
|
|
41
|
+
* @param {object} propTypes - an object where every defined key is a valid prop
|
|
42
|
+
* @param {*} [regexp] - an optional regular expression where any match is a valid prop
|
|
43
|
+
* @param {PropSelectorCallback} callback - optional function taking `(key, value)` returning either undefined or an object of new props to merge in
|
|
44
|
+
* @returns {object} - valid props for this component
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
function getPropSelector(propTypes, regexp, callback) {
|
|
10
49
|
return props => Object.entries(props).reduce((items, _ref) => {
|
|
11
50
|
let [key, value] = _ref;
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
51
|
+
return (// If there's a callback and it matches something, applyCallback merges it in; return that
|
|
52
|
+
applyCallback(callback, items, key, value) || ( // If there's no callback match, check if this prop is valid and merge it in if it is
|
|
53
|
+
(0, _hasOwnProperty.default)(propTypes, key) || regexp && regexp.test(key) ? { ...items,
|
|
54
|
+
[key]: value
|
|
55
|
+
} : items)
|
|
56
|
+
);
|
|
15
57
|
}, {});
|
|
16
58
|
}
|
|
@@ -9,9 +9,11 @@ var _systemConstants = require("@telus-uds/system-constants");
|
|
|
9
9
|
|
|
10
10
|
var _ViewportProvider = require("../ViewportProvider");
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
var _hasOwnProperty = _interopRequireDefault(require("./hasOwnProperty"));
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const hasResponsiveProperties = objectProp => _systemConstants.viewports.keys.some(key => (0, _hasOwnProperty.default)(objectProp, key));
|
|
15
17
|
/**
|
|
16
18
|
* Resolves a prop which may be a responsive object with keys for viewports.
|
|
17
19
|
*
|
|
@@ -29,7 +31,7 @@ const resolveResponsiveProp = (prop, viewport, defaultValue) => {
|
|
|
29
31
|
if (!prop || typeof prop !== 'object' || !hasResponsiveProperties(prop)) return prop;
|
|
30
32
|
const value = _systemConstants.viewports.keys.includes(viewport) ? // If there's a current viewport, return the closest match at or below it
|
|
31
33
|
_systemConstants.viewports.inherit(prop)[viewport] : // If no current viewport is available, default to smallest viewport
|
|
32
|
-
prop[_systemConstants.viewports.keys.find(key =>
|
|
34
|
+
prop[_systemConstants.viewports.keys.find(key => (0, _hasOwnProperty.default)(prop, key))];
|
|
33
35
|
return value === undefined ? defaultValue : value;
|
|
34
36
|
};
|
|
35
37
|
/**
|
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _hasOwnProperty = _interopRequireDefault(require("./hasOwnProperty"));
|
|
13
|
+
|
|
12
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -17,8 +19,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
19
|
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
21
|
|
|
20
|
-
// Prototype-safe alternative to (linter-forbidden) someObject.hasOwnProperty()
|
|
21
|
-
const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop);
|
|
22
22
|
/**
|
|
23
23
|
* Higher-order component that has no effect unless an additional prop `LinkRouter` is passed.
|
|
24
24
|
* This may be used to provide custom wrappers for integrations with third party libraries.
|
|
@@ -47,8 +47,6 @@ const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(ob
|
|
|
47
47
|
* <IconButton icon={SomeIcon} LinkRouter={LinkLinkRouter} linkRouterProps={{ to, options }} ref={iconRef} />
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
50
|
const withLinkRouter = Component => {
|
|
53
51
|
const wrappedComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
54
52
|
let {
|
|
@@ -84,7 +82,7 @@ const withLinkRouter = Component => {
|
|
|
84
82
|
|
|
85
83
|
Object.keys(otherProperties).forEach(key => {
|
|
86
84
|
// Skip internal React properties from wrappedComponent's forwardRef (render, $$typeof, etc)
|
|
87
|
-
if (
|
|
85
|
+
if ((0, _hasOwnProperty.default)(Component, key) && !(0, _hasOwnProperty.default)(wrappedComponent, key)) {
|
|
88
86
|
wrappedComponent[key] = Component[key];
|
|
89
87
|
}
|
|
90
88
|
});
|
|
@@ -19,8 +19,8 @@ const A11yInfoProvider = _ref => {
|
|
|
19
19
|
return () => {};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
AccessibilityInfo.addEventListener('reduceMotionChanged', setReduceMotionEnabled);
|
|
23
|
-
AccessibilityInfo.addEventListener('screenReaderChanged', setScreenReaderEnabled);
|
|
22
|
+
const motionSubscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduceMotionEnabled);
|
|
23
|
+
const screenReaderSubscription = AccessibilityInfo.addEventListener('screenReaderChanged', setScreenReaderEnabled);
|
|
24
24
|
|
|
25
25
|
const setInitialA11yInfo = async () => {
|
|
26
26
|
const [initialReduceMotionEnabled, initialScreenReaderEnabled] = await Promise.all([AccessibilityInfo.isReduceMotionEnabled(), AccessibilityInfo.isScreenReaderEnabled()]); // Browsers can't detect screen readers; in RNW isScreenReaderEnabled() is always `true`
|
|
@@ -36,8 +36,18 @@ const A11yInfoProvider = _ref => {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
return () => {
|
|
39
|
-
AccessibilityInfo.removeEventListener
|
|
40
|
-
|
|
39
|
+
// From react-native 0.65, AccessibilityInfo.removeEventListener is deprecated for `remove` on addEventListener return value
|
|
40
|
+
if (typeof (motionSubscription === null || motionSubscription === void 0 ? void 0 : motionSubscription.remove) === 'function') {
|
|
41
|
+
motionSubscription === null || motionSubscription === void 0 ? void 0 : motionSubscription.remove();
|
|
42
|
+
} else if (typeof AccessibilityInfo.removeEventListener === 'function') {
|
|
43
|
+
AccessibilityInfo.removeEventListener('reduceMotionChanged', setReduceMotionEnabled);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (typeof (screenReaderSubscription === null || screenReaderSubscription === void 0 ? void 0 : screenReaderSubscription.remove) === 'function') {
|
|
47
|
+
screenReaderSubscription === null || screenReaderSubscription === void 0 ? void 0 : screenReaderSubscription.remove();
|
|
48
|
+
} else if (typeof AccessibilityInfo.removeEventListener === 'function') {
|
|
49
|
+
AccessibilityInfo.removeEventListener('screenReaderChanged', setScreenReaderEnabled);
|
|
50
|
+
}
|
|
41
51
|
};
|
|
42
52
|
}, []);
|
|
43
53
|
return /*#__PURE__*/_jsx(ReducedMotionContext.Provider, {
|
|
@@ -130,8 +130,9 @@ const ButtonGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
130
130
|
tokens: getButtonTokens,
|
|
131
131
|
selected: isSelected,
|
|
132
132
|
inactive: inactive,
|
|
133
|
-
...
|
|
134
|
-
|
|
133
|
+
...selectItemProps({ ...itemRest,
|
|
134
|
+
...itemA11y
|
|
135
|
+
}),
|
|
135
136
|
children: label
|
|
136
137
|
}, id);
|
|
137
138
|
})
|
|
@@ -191,6 +191,14 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
191
191
|
const {
|
|
192
192
|
themeOptions
|
|
193
193
|
} = useTheme();
|
|
194
|
+
const selectedProps = selectProps({
|
|
195
|
+
accessibilityRole: 'checkbox',
|
|
196
|
+
accessibilityState: {
|
|
197
|
+
checked: isChecked,
|
|
198
|
+
disabled: inactive
|
|
199
|
+
},
|
|
200
|
+
...rest
|
|
201
|
+
});
|
|
194
202
|
return /*#__PURE__*/_jsx(View, {
|
|
195
203
|
style: staticStyles.wrapper,
|
|
196
204
|
ref: ref,
|
|
@@ -201,12 +209,7 @@ const Checkbox = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
201
209
|
disabled: inactive,
|
|
202
210
|
onKeyDown: handleKeyDown,
|
|
203
211
|
onPress: handleChange,
|
|
204
|
-
|
|
205
|
-
accessibilityState: {
|
|
206
|
-
checked: isChecked,
|
|
207
|
-
disabled: inactive
|
|
208
|
-
},
|
|
209
|
-
...selectProps(rest),
|
|
212
|
+
...selectedProps,
|
|
210
213
|
children: _ref6 => {
|
|
211
214
|
let {
|
|
212
215
|
focused: focus,
|
|
@@ -67,12 +67,13 @@ const ExpandCollapseControl = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
67
67
|
...rest
|
|
68
68
|
} = _ref3;
|
|
69
69
|
const getTokens = useThemeTokensCallback('ExpandCollapseControl', tokens, variant);
|
|
70
|
-
const selectedProps = selectProps({
|
|
71
|
-
accessibilityRole
|
|
70
|
+
const selectedProps = selectProps({
|
|
71
|
+
accessibilityRole,
|
|
72
|
+
...rest,
|
|
73
|
+
accessibilityState: { ...(rest.accessibilityState || {}),
|
|
74
|
+
expanded: isExpanded
|
|
75
|
+
}
|
|
72
76
|
});
|
|
73
|
-
selectedProps.accessibilityState = { ...(selectedProps.accessibilityState || {}),
|
|
74
|
-
expanded: isExpanded
|
|
75
|
-
};
|
|
76
77
|
|
|
77
78
|
const getControlState = _ref4 => {
|
|
78
79
|
let {
|
|
@@ -55,10 +55,11 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
55
55
|
} = _ref2;
|
|
56
56
|
const [containerHeight, setContainerHeight] = useState(null);
|
|
57
57
|
const isExpanded = openIds.includes(panelId);
|
|
58
|
-
const selectedProps = selectProps(rest
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const selectedProps = selectProps({ ...rest,
|
|
59
|
+
accessibilityState: { ...(rest.accessibilityState || {}),
|
|
60
|
+
expanded: isExpanded
|
|
61
|
+
}
|
|
62
|
+
});
|
|
62
63
|
const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
|
|
63
64
|
expanded: isExpanded
|
|
64
65
|
});
|