@telus-uds/components-base 1.10.0 → 1.12.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 +37 -3
- package/component-docs.json +413 -62
- package/lib/BaseProvider/index.js +7 -2
- package/lib/Button/ButtonBase.js +18 -14
- package/lib/Carousel/Carousel.js +92 -71
- package/lib/Carousel/CarouselContext.js +12 -4
- package/lib/Carousel/CarouselItem/CarouselItem.js +24 -9
- package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +56 -0
- package/lib/Carousel/CarouselStepTracker/index.js +13 -0
- package/lib/Carousel/dictionary.js +23 -0
- package/lib/Checkbox/Checkbox.js +7 -3
- package/lib/Checkbox/CheckboxGroup.js +1 -1
- package/lib/Feedback/Feedback.js +18 -10
- package/lib/Icon/IconText.js +5 -0
- package/lib/InputLabel/InputLabel.js +11 -5
- package/lib/InputSupports/InputSupports.js +10 -3
- package/lib/InputSupports/useInputSupports.js +3 -2
- package/lib/Link/LinkBase.js +7 -3
- package/lib/List/ListItem.js +7 -3
- package/lib/Modal/Modal.js +4 -0
- package/lib/Notification/Notification.js +7 -2
- package/lib/Pagination/Pagination.js +7 -3
- package/lib/RadioCard/RadioCard.js +6 -1
- package/lib/Select/Select.js +7 -3
- package/lib/Skeleton/Skeleton.js +1 -0
- package/lib/StepTracker/Step.js +8 -4
- package/lib/StepTracker/StepTracker.js +17 -13
- package/lib/Tabs/TabsItem.js +4 -0
- package/lib/TextInput/TextInput.js +3 -1
- package/lib/TextInput/TextInputBase.js +7 -3
- package/lib/ThemeProvider/ThemeProvider.js +20 -3
- package/lib/ThemeProvider/utils/styles.js +8 -1
- package/lib/ThemeProvider/utils/theme-tokens.js +1 -1
- package/lib/Typography/Typography.js +6 -2
- package/lib/index.js +9 -0
- package/lib/utils/index.js +9 -0
- package/lib/utils/props/clickProps.js +2 -2
- package/lib/utils/props/handlerProps.js +77 -31
- package/lib/utils/useScrollBlocking.js +66 -0
- package/lib/utils/useScrollBlocking.native.js +11 -0
- package/lib-module/BaseProvider/index.js +7 -2
- package/lib-module/Button/ButtonBase.js +7 -3
- package/lib-module/Carousel/Carousel.js +85 -70
- package/lib-module/Carousel/CarouselContext.js +11 -4
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +25 -10
- package/lib-module/Carousel/CarouselStepTracker/CarouselStepTracker.js +42 -0
- package/lib-module/Carousel/CarouselStepTracker/index.js +2 -0
- package/lib-module/Carousel/dictionary.js +16 -0
- package/lib-module/Checkbox/Checkbox.js +8 -4
- package/lib-module/Checkbox/CheckboxGroup.js +1 -1
- package/lib-module/Feedback/Feedback.js +19 -11
- package/lib-module/Icon/IconText.js +5 -0
- package/lib-module/InputLabel/InputLabel.js +12 -6
- package/lib-module/InputSupports/InputSupports.js +10 -3
- package/lib-module/InputSupports/useInputSupports.js +3 -2
- package/lib-module/Link/LinkBase.js +8 -4
- package/lib-module/List/ListItem.js +8 -4
- package/lib-module/Modal/Modal.js +3 -0
- package/lib-module/Notification/Notification.js +8 -3
- package/lib-module/Pagination/Pagination.js +8 -4
- package/lib-module/RadioCard/RadioCard.js +7 -2
- package/lib-module/Select/Select.js +8 -4
- package/lib-module/Skeleton/Skeleton.js +1 -0
- package/lib-module/StepTracker/Step.js +9 -5
- package/lib-module/StepTracker/StepTracker.js +17 -14
- package/lib-module/Tabs/TabsItem.js +5 -1
- package/lib-module/TextInput/TextInput.js +3 -1
- package/lib-module/TextInput/TextInputBase.js +8 -4
- package/lib-module/ThemeProvider/ThemeProvider.js +20 -3
- package/lib-module/ThemeProvider/utils/styles.js +8 -1
- package/lib-module/ThemeProvider/utils/theme-tokens.js +1 -1
- package/lib-module/Typography/Typography.js +7 -3
- package/lib-module/index.js +1 -0
- package/lib-module/utils/index.js +1 -0
- package/lib-module/utils/props/clickProps.js +2 -2
- package/lib-module/utils/props/handlerProps.js +78 -31
- package/lib-module/utils/useScrollBlocking.js +58 -0
- package/lib-module/utils/useScrollBlocking.native.js +2 -0
- package/package.json +3 -3
- package/src/BaseProvider/index.jsx +6 -3
- package/src/Button/ButtonBase.jsx +8 -3
- package/src/Carousel/Carousel.jsx +106 -74
- package/src/Carousel/CarouselContext.jsx +15 -4
- package/src/Carousel/CarouselItem/CarouselItem.jsx +26 -8
- package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +36 -0
- package/src/Carousel/CarouselStepTracker/index.js +3 -0
- package/src/Carousel/dictionary.js +16 -0
- package/src/Checkbox/Checkbox.jsx +14 -11
- package/src/Checkbox/CheckboxGroup.jsx +1 -1
- package/src/Feedback/Feedback.jsx +14 -7
- package/src/Icon/IconText.jsx +2 -0
- package/src/InputLabel/InputLabel.jsx +13 -12
- package/src/InputSupports/InputSupports.jsx +18 -3
- package/src/InputSupports/useInputSupports.js +2 -2
- package/src/Link/LinkBase.jsx +10 -4
- package/src/List/ListItem.jsx +9 -4
- package/src/Modal/Modal.jsx +3 -1
- package/src/Notification/Notification.jsx +5 -3
- package/src/Pagination/Pagination.jsx +6 -4
- package/src/RadioCard/RadioCard.jsx +3 -2
- package/src/Select/Select.jsx +12 -3
- package/src/Skeleton/Skeleton.jsx +1 -0
- package/src/StepTracker/Step.jsx +12 -4
- package/src/StepTracker/StepTracker.jsx +20 -13
- package/src/Tabs/TabsItem.jsx +3 -2
- package/src/TextInput/TextInput.jsx +1 -1
- package/src/TextInput/TextInputBase.jsx +11 -3
- package/src/ThemeProvider/ThemeProvider.jsx +16 -3
- package/src/ThemeProvider/utils/styles.js +9 -1
- package/src/ThemeProvider/utils/theme-tokens.js +1 -1
- package/src/Typography/Typography.jsx +11 -12
- package/src/index.js +1 -0
- package/src/utils/index.js +1 -0
- package/src/utils/props/clickProps.js +2 -2
- package/src/utils/props/handlerProps.js +64 -16
- package/src/utils/useScrollBlocking.js +57 -0
- package/src/utils/useScrollBlocking.native.js +2 -0
|
@@ -157,7 +157,7 @@ export const validateThemeTokensVersion = (theme) => {
|
|
|
157
157
|
|
|
158
158
|
The UDS base components ${pkg.name} v${pkg.version} are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ${expectedThemeTokensVersion}. The current theme was built with @telus-uds/system-theme-tokens v${actualThemeTokensVersion}.
|
|
159
159
|
|
|
160
|
-
If you see this error than most likely you have attempted to install ${pkg.name} and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/
|
|
160
|
+
If you see this error than most likely you have attempted to install ${pkg.name} and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/docs/docs/multi-brand-usage.md`
|
|
161
161
|
)
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { Text, View } from 'react-native'
|
|
4
4
|
|
|
5
|
-
import { useThemeTokens } from '../ThemeProvider'
|
|
5
|
+
import { useTheme, useThemeTokens } from '../ThemeProvider'
|
|
6
6
|
import { useViewport } from '../ViewportProvider'
|
|
7
7
|
import { applyTextStyles } from '../ThemeProvider/utils'
|
|
8
8
|
import {
|
|
@@ -24,22 +24,17 @@ import {
|
|
|
24
24
|
const [selectContainerProps, selectedContainerPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
25
25
|
const [selectTextProps, selectedTextPropTypes] = selectSystemProps([textProps])
|
|
26
26
|
|
|
27
|
-
const selectTextStyles = (
|
|
28
|
-
fontWeight,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
lineHeight,
|
|
32
|
-
fontName,
|
|
33
|
-
textAlign,
|
|
34
|
-
textTransform,
|
|
35
|
-
letterSpacing
|
|
36
|
-
}) =>
|
|
27
|
+
const selectTextStyles = (
|
|
28
|
+
{ fontWeight, fontSize, color, lineHeight, fontName, textAlign, textTransform, letterSpacing },
|
|
29
|
+
themeOptions
|
|
30
|
+
) =>
|
|
37
31
|
applyTextStyles({
|
|
38
32
|
fontWeight,
|
|
39
33
|
fontSize,
|
|
40
34
|
color,
|
|
41
35
|
lineHeight,
|
|
42
36
|
fontName,
|
|
37
|
+
themeOptions,
|
|
43
38
|
textAlign,
|
|
44
39
|
textTransform,
|
|
45
40
|
letterSpacing
|
|
@@ -64,9 +59,13 @@ const Typography = forwardRef(
|
|
|
64
59
|
) => {
|
|
65
60
|
const viewport = useViewport()
|
|
66
61
|
const themeTokens = useThemeTokens('Typography', tokens, variant, { viewport })
|
|
62
|
+
const { themeOptions } = useTheme()
|
|
67
63
|
const resolvedTextProps = {
|
|
68
64
|
...selectTextProps(rest),
|
|
69
|
-
style: selectTextStyles(
|
|
65
|
+
style: selectTextStyles(
|
|
66
|
+
align ? { ...themeTokens, textAlign: align } : themeTokens,
|
|
67
|
+
themeOptions
|
|
68
|
+
),
|
|
70
69
|
dataSet,
|
|
71
70
|
maxFontSizeMultiplier: getMaxFontMultiplier(themeTokens)
|
|
72
71
|
}
|
package/src/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { default as Icon } from './Icon'
|
|
|
17
17
|
export * from './Icon'
|
|
18
18
|
export { default as IconButton } from './IconButton'
|
|
19
19
|
export { default as InputLabel } from './InputLabel'
|
|
20
|
+
export { default as InputSupports } from './InputSupports'
|
|
20
21
|
export * from './Link'
|
|
21
22
|
export { default as List, ListItem, ListBase } from './List'
|
|
22
23
|
export { default as Modal } from './Modal'
|
package/src/utils/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as useCopy } from './useCopy'
|
|
|
10
10
|
export { default as useHash } from './useHash'
|
|
11
11
|
export { default as useSpacingScale } from './useSpacingScale'
|
|
12
12
|
export { default as useResponsiveProp } from './useResponsiveProp'
|
|
13
|
+
export { default as useScrollBlocking } from './useScrollBlocking'
|
|
13
14
|
export * from './useResponsiveProp'
|
|
14
15
|
export { default as useUniqueId } from './useUniqueId'
|
|
15
16
|
export { default as withLinkRouter } from './withLinkRouter'
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
|
+
import { Platform } from 'react-native'
|
|
3
|
+
import getPropSelector from './getPropSelector'
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
const focusHandlerProps = {
|
|
4
6
|
types: {
|
|
5
7
|
/**
|
|
6
8
|
* onBlur handler
|
|
@@ -10,14 +12,11 @@ export const focusHandlerProps = {
|
|
|
10
12
|
* onFocus handler
|
|
11
13
|
*/
|
|
12
14
|
onFocus: PropTypes.func
|
|
13
|
-
}
|
|
14
|
-
select: ({ onBlur, onFocus }) => ({
|
|
15
|
-
onBlur,
|
|
16
|
-
onFocus
|
|
17
|
-
})
|
|
15
|
+
}
|
|
18
16
|
}
|
|
17
|
+
focusHandlerProps.select = getPropSelector(focusHandlerProps.types)
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
const textInputHandlerProps = {
|
|
21
20
|
types: {
|
|
22
21
|
/**
|
|
23
22
|
* onChange handler
|
|
@@ -34,14 +33,63 @@ export const textInputHandlerProps = {
|
|
|
34
33
|
/**
|
|
35
34
|
* onSubmitEditing handler
|
|
36
35
|
*/
|
|
37
|
-
onSubmitEditing: PropTypes.func
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
onSubmitEditing: PropTypes.func,
|
|
37
|
+
/**
|
|
38
|
+
* onContentSizeChange handler
|
|
39
|
+
*/
|
|
40
|
+
onContentSizeChange: PropTypes.func,
|
|
41
|
+
/**
|
|
42
|
+
* onEndEditing handler
|
|
43
|
+
*/
|
|
44
|
+
onEndEditing: PropTypes.func,
|
|
45
|
+
/**
|
|
46
|
+
* onScroll handler
|
|
47
|
+
*/
|
|
48
|
+
onScroll: PropTypes.func,
|
|
49
|
+
/**
|
|
50
|
+
* onSelectionChange handler
|
|
51
|
+
*/
|
|
52
|
+
onSelectionChange: PropTypes.func,
|
|
53
|
+
/**
|
|
54
|
+
* onKeyPress handler
|
|
55
|
+
*/
|
|
56
|
+
onKeyPress: PropTypes.func,
|
|
57
|
+
/**
|
|
58
|
+
* onKeyUp handler (only supported on Web)
|
|
59
|
+
*/
|
|
60
|
+
onKeyUp: PropTypes.func,
|
|
61
|
+
/**
|
|
62
|
+
* onKeyDown handler (only supported on Web)
|
|
63
|
+
*/
|
|
64
|
+
onKeyDown: PropTypes.func
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const selectTextInputHandlers = getPropSelector(textInputHandlerProps.types)
|
|
68
|
+
textInputHandlerProps.select = (props) => {
|
|
69
|
+
// Support for onKeyPress/onKeyUp/onKeyDown is inconsistent between React Native and React Native Web
|
|
70
|
+
const { onKeyPress, onKeyUp, onKeyDown, ...resolvedProps } = selectTextInputHandlers(props)
|
|
71
|
+
if (onKeyPress || onKeyUp || onKeyDown) {
|
|
72
|
+
if (Platform.OS !== 'web') {
|
|
73
|
+
// React Native only supports onKeyPress. Call any key handlers supplied in expected order.
|
|
74
|
+
resolvedProps.onKeyPress = (event) => {
|
|
75
|
+
if (typeof onKeyDown === 'function') onKeyDown(event)
|
|
76
|
+
if (typeof onKeyPress === 'function') onKeyPress(event)
|
|
77
|
+
if (typeof onKeyUp === 'function') onKeyUp(event)
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
// React Native Web supports onKeyUp the normal way.
|
|
81
|
+
if (onKeyUp) resolvedProps.onKeyUp = onKeyUp
|
|
82
|
+
// React Native Web doesn't support the `onKeyDown` prop name, but maps a supplied onKeyPress handler
|
|
83
|
+
// to the onKeyDown event and calls it with a keydown event. Make React Native Web call either or both.
|
|
84
|
+
if (onKeyPress || onKeyDown) {
|
|
85
|
+
resolvedProps.onKeyPress = (event) => {
|
|
86
|
+
if (typeof onKeyDown === 'function') onKeyDown(event)
|
|
87
|
+
if (typeof onKeyPress === 'function') onKeyPress(event)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return resolvedProps
|
|
45
93
|
}
|
|
46
94
|
|
|
47
|
-
export
|
|
95
|
+
export { focusHandlerProps, textInputHandlerProps }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
const addScrollBlocking = (preventScrolling, stopPropagation, ref) => {
|
|
4
|
+
document.body.addEventListener('touchmove', preventScrolling, { passive: false })
|
|
5
|
+
ref.current?.addEventListener('touchmove', stopPropagation)
|
|
6
|
+
document.body.style.overflow = 'hidden'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const removeScrollBlocking = (preventScrolling, stopPropagation, ref) => {
|
|
10
|
+
document.body.removeEventListener('touchmove', preventScrolling)
|
|
11
|
+
ref.current?.removeEventListener('touchmove', stopPropagation)
|
|
12
|
+
document.body.style.overflow = 'inherit'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Disables scrolling when passed `true` or an array where all items are `true`.
|
|
17
|
+
*
|
|
18
|
+
* Returns an optional callback ref. Pass this to an element if it or its children
|
|
19
|
+
* should allow touch-based scrolling within that element's bounds.
|
|
20
|
+
*
|
|
21
|
+
* @param {boolean | boolean[]} conditionProps
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
const useScrollBlocking = (conditionProps) => {
|
|
25
|
+
// useRef refs are null on first render and don't trigger a re-render when they get their
|
|
26
|
+
// element. Force re-run when ref mounts to ensure the stopPropagation listener is attached.
|
|
27
|
+
const ref = useRef()
|
|
28
|
+
const [refIsMounted, setRefIsMounted] = useState(false)
|
|
29
|
+
const callbackRef = useCallback((element) => {
|
|
30
|
+
ref.current = element
|
|
31
|
+
setRefIsMounted(Boolean(element))
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
const conditionsMet = Array.isArray(conditionProps)
|
|
35
|
+
? conditionProps.every((condition) => condition)
|
|
36
|
+
: Boolean(conditionProps)
|
|
37
|
+
|
|
38
|
+
const preventScrolling = useCallback((event) => event.preventDefault(), [])
|
|
39
|
+
const stopPropagation = useCallback((event) => event.stopPropagation(), [])
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const cleanup = () => removeScrollBlocking(preventScrolling, stopPropagation, ref)
|
|
43
|
+
|
|
44
|
+
if (conditionsMet) {
|
|
45
|
+
addScrollBlocking(preventScrolling, stopPropagation, ref)
|
|
46
|
+
} else {
|
|
47
|
+
cleanup()
|
|
48
|
+
}
|
|
49
|
+
return cleanup
|
|
50
|
+
// preventScrolling and stopPropagation are stable callbacks with no deps, so this
|
|
51
|
+
// will re-run when conditionsMet or refIsMounted flip between true and false.
|
|
52
|
+
}, [preventScrolling, conditionsMet, stopPropagation, refIsMounted])
|
|
53
|
+
|
|
54
|
+
return callbackRef
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default useScrollBlocking
|