@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
|
@@ -1,14 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import merge from 'lodash.merge'
|
|
2
|
+
import hasOwnProperty from '../hasOwnProperty'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @callback PropSelectorCallback - a callback called for each prop passed to a component
|
|
6
|
+
* @param {string} key - the key for the prop to be tested
|
|
7
|
+
* @param {*} value - the value of the prop being passed in to the component
|
|
8
|
+
* @returns {object|undefined}
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {PropSelectorCallback} callback
|
|
13
|
+
* @param {object} items
|
|
14
|
+
* @param {string} key
|
|
15
|
+
* @param {*} value
|
|
16
|
+
* @returns {object|undefined}
|
|
17
|
+
*/
|
|
18
|
+
const applyCallback = (callback, items, key, value) => {
|
|
19
|
+
// If there's no callback, continue and look up keys as normal
|
|
20
|
+
if (typeof callback !== 'function') return undefined
|
|
21
|
+
|
|
22
|
+
const newItems = callback(key, value)
|
|
23
|
+
|
|
24
|
+
// If the callback doesn't return anything, continue and look up keys as normal
|
|
25
|
+
if (!newItems) return undefined
|
|
26
|
+
|
|
27
|
+
// If the callback returns items, merge them in, deep merging props that are objects
|
|
28
|
+
return merge({}, items, newItems)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generates a function to filter an object of props down to a subset of allowed props, with
|
|
33
|
+
* optional prop alteration and re-mapping via an optional callback.
|
|
34
|
+
*
|
|
35
|
+
* @param {object} propTypes - an object where every defined key is a valid prop
|
|
36
|
+
* @param {*} [regexp] - an optional regular expression where any match is a valid prop
|
|
37
|
+
* @param {PropSelectorCallback} callback - optional function taking `(key, value)` returning either undefined or an object of new props to merge in
|
|
38
|
+
* @returns {object} - valid props for this component
|
|
39
|
+
*/
|
|
40
|
+
export default function getPropSelector(propTypes, regexp, callback) {
|
|
3
41
|
return (props) =>
|
|
4
42
|
Object.entries(props).reduce(
|
|
5
43
|
(items, [key, value]) =>
|
|
6
|
-
|
|
44
|
+
// If there's a callback and it matches something, applyCallback merges it in; return that
|
|
45
|
+
applyCallback(callback, items, key, value) ||
|
|
46
|
+
// If there's no callback match, check if this prop is valid and merge it in if it is
|
|
47
|
+
(hasOwnProperty(propTypes, key) || (regexp && regexp.test(key))
|
|
7
48
|
? {
|
|
8
49
|
...items,
|
|
9
50
|
[key]: value
|
|
10
51
|
}
|
|
11
|
-
: items,
|
|
52
|
+
: items),
|
|
12
53
|
{}
|
|
13
54
|
)
|
|
14
55
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { viewports } from '@telus-uds/system-constants'
|
|
2
2
|
import { useViewport } from '../ViewportProvider'
|
|
3
|
+
import hasOwnProperty from './hasOwnProperty'
|
|
3
4
|
|
|
4
|
-
const hasOwn = (objectProp, key) => Object.prototype.hasOwnProperty.call(objectProp, key)
|
|
5
5
|
const hasResponsiveProperties = (objectProp) =>
|
|
6
|
-
viewports.keys.some((key) =>
|
|
6
|
+
viewports.keys.some((key) => hasOwnProperty(objectProp, key))
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Resolves a prop which may be a responsive object with keys for viewports.
|
|
@@ -23,7 +23,7 @@ export const resolveResponsiveProp = (prop, viewport, defaultValue) => {
|
|
|
23
23
|
? // If there's a current viewport, return the closest match at or below it
|
|
24
24
|
viewports.inherit(prop)[viewport]
|
|
25
25
|
: // If no current viewport is available, default to smallest viewport
|
|
26
|
-
prop[viewports.keys.find((key) =>
|
|
26
|
+
prop[viewports.keys.find((key) => hasOwnProperty(prop, key))]
|
|
27
27
|
|
|
28
28
|
return value === undefined ? defaultValue : value
|
|
29
29
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
|
|
4
|
-
// Prototype-safe alternative to (linter-forbidden) someObject.hasOwnProperty()
|
|
5
|
-
const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop)
|
|
3
|
+
import hasOwnProperty from './hasOwnProperty'
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Higher-order component that has no effect unless an additional prop `LinkRouter` is passed.
|