@telus-uds/components-base 3.29.1 → 3.30.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 -1
- package/lib/cjs/Carousel/Carousel.js +6 -1
- package/lib/cjs/Carousel/CarouselThumbnail.js +123 -31
- package/lib/cjs/Carousel/CarouselThumbnailNavigation.js +8 -1
- package/lib/cjs/Footnote/FootnoteLink.js +18 -17
- package/lib/cjs/Progress/Progress.js +30 -5
- package/lib/cjs/Scroll/Scroll.js +466 -0
- package/lib/cjs/Scroll/ScrollContext.js +55 -0
- package/lib/cjs/Scroll/ScrollItem.js +103 -0
- package/lib/cjs/Scroll/ScrollProgress.js +99 -0
- package/lib/cjs/Scroll/dictionary.js +18 -0
- package/lib/cjs/Scroll/index.js +29 -0
- package/lib/cjs/index.js +15 -0
- package/lib/cjs/utils/animation/index.js +7 -0
- package/lib/cjs/utils/animation/useAnimatedValue.js +46 -0
- package/lib/cjs/utils/children.js +2 -1
- package/lib/esm/Carousel/Carousel.js +6 -1
- package/lib/esm/Carousel/CarouselThumbnail.js +124 -32
- package/lib/esm/Carousel/CarouselThumbnailNavigation.js +8 -1
- package/lib/esm/Footnote/FootnoteLink.js +18 -17
- package/lib/esm/Progress/Progress.js +30 -5
- package/lib/esm/Scroll/Scroll.js +459 -0
- package/lib/esm/Scroll/ScrollContext.js +47 -0
- package/lib/esm/Scroll/ScrollItem.js +96 -0
- package/lib/esm/Scroll/ScrollProgress.js +92 -0
- package/lib/esm/Scroll/dictionary.js +12 -0
- package/lib/esm/Scroll/index.js +4 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/utils/animation/index.js +1 -1
- package/lib/esm/utils/animation/useAnimatedValue.js +39 -0
- package/lib/esm/utils/children.js +2 -1
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Carousel/Carousel.jsx +6 -1
- package/src/Carousel/CarouselThumbnail.jsx +153 -64
- package/src/Carousel/CarouselThumbnailNavigation.jsx +8 -2
- package/src/Footnote/FootnoteLink.jsx +17 -12
- package/src/Progress/Progress.jsx +22 -3
- package/src/Scroll/Scroll.jsx +488 -0
- package/src/Scroll/ScrollContext.jsx +41 -0
- package/src/Scroll/ScrollItem.jsx +89 -0
- package/src/Scroll/ScrollProgress.jsx +75 -0
- package/src/Scroll/dictionary.js +12 -0
- package/src/Scroll/index.js +5 -0
- package/src/index.js +1 -0
- package/src/utils/animation/index.js +1 -1
- package/src/utils/animation/useAnimatedValue.js +37 -0
- package/src/utils/children.jsx +4 -1
- package/types/Scroll.d.ts +66 -0
- package/types/index.d.ts +9 -0
package/src/index.js
CHANGED
|
@@ -49,6 +49,7 @@ export { default as QuickLinksFeature } from './QuickLinksFeature'
|
|
|
49
49
|
export { default as Radio, RadioGroup } from './Radio'
|
|
50
50
|
export { default as RadioCard, RadioCardGroup } from './RadioCard'
|
|
51
51
|
export { default as Responsive } from './Responsive'
|
|
52
|
+
export { default as Scroll, ScrollItem } from './Scroll'
|
|
52
53
|
export { default as Search } from './Search'
|
|
53
54
|
export { default as Select } from './Select'
|
|
54
55
|
export { default as Shortcuts, ShortcutsItem } from './Shortcuts'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { default as useAnimatedValue } from './useAnimatedValue'
|
|
2
2
|
export { default as useVerticalExpandAnimation } from './useVerticalExpandAnimation'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Animated, Easing } from 'react-native'
|
|
3
|
+
|
|
4
|
+
const ANIMATION_DURATION = 200
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Smoothly animates a numeric value to a new target using a quadratic ease-in-out
|
|
8
|
+
* curve. Returns the current interpolated value as a plain number so
|
|
9
|
+
* consumers can use it in non-Animated style props.
|
|
10
|
+
*
|
|
11
|
+
* @param {number} targetValue - The value to animate towards.
|
|
12
|
+
* @param {number} [duration=ANIMATION_DURATION] - Animation duration in ms.
|
|
13
|
+
*/
|
|
14
|
+
const useAnimatedValue = (targetValue, duration = ANIMATION_DURATION) => {
|
|
15
|
+
const [currentValue, setCurrentValue] = React.useState(targetValue)
|
|
16
|
+
const animatedValue = React.useRef(new Animated.Value(targetValue)).current
|
|
17
|
+
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
const id = animatedValue.addListener(({ value }) => setCurrentValue(value))
|
|
20
|
+
return () => animatedValue.removeListener(id)
|
|
21
|
+
}, [animatedValue])
|
|
22
|
+
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
const animation = Animated.timing(animatedValue, {
|
|
25
|
+
toValue: targetValue,
|
|
26
|
+
duration,
|
|
27
|
+
easing: Easing.inOut(Easing.quad),
|
|
28
|
+
useNativeDriver: false
|
|
29
|
+
})
|
|
30
|
+
animation.start()
|
|
31
|
+
return () => animation.stop()
|
|
32
|
+
}, [targetValue, animatedValue, duration])
|
|
33
|
+
|
|
34
|
+
return currentValue
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default useAnimatedValue
|
package/src/utils/children.jsx
CHANGED
|
@@ -47,8 +47,11 @@ export const unpackFragment = (child) => {
|
|
|
47
47
|
|
|
48
48
|
const isStringOrNumber = (child) => typeof child === 'string' || typeof child === 'number'
|
|
49
49
|
// Wrap an A11yText with neighouring text strings so it doesn't split them into multiple <Text>s
|
|
50
|
+
// Check displayName first as it is explicitly set and reliable regardless of export style (named vs default)
|
|
50
51
|
const isWrapable = (child) =>
|
|
51
|
-
isStringOrNumber(child) ||
|
|
52
|
+
isStringOrNumber(child) ||
|
|
53
|
+
child.type === A11yText ||
|
|
54
|
+
child.type?.__UDS_COMPONENT_NAME__ === 'FootnoteLink'
|
|
52
55
|
const combineKeys = (childrenArray) =>
|
|
53
56
|
childrenArray.reduce((newKey, child) => `${newKey}${child.key || ''}`, '')
|
|
54
57
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { SemanticTag } from './Common'
|
|
3
|
+
|
|
4
|
+
export interface ScrollDictionary {
|
|
5
|
+
accessibilityLabel: string
|
|
6
|
+
instructionText: string
|
|
7
|
+
progressBarLabel: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ScrollProps {
|
|
11
|
+
/**
|
|
12
|
+
* Scroll items to display. Should be `ScrollItem` components.
|
|
13
|
+
*/
|
|
14
|
+
children: ReactNode
|
|
15
|
+
/**
|
|
16
|
+
* Theme tokens for customizing the Scroll appearance.
|
|
17
|
+
*/
|
|
18
|
+
tokens?: ScrollTokens
|
|
19
|
+
/**
|
|
20
|
+
* Variant for the Scroll component.
|
|
21
|
+
*/
|
|
22
|
+
variant?: ScrollVariant
|
|
23
|
+
/**
|
|
24
|
+
* Select English or French copy for accessible labels.
|
|
25
|
+
*/
|
|
26
|
+
copy?: 'en' | 'fr'
|
|
27
|
+
/**
|
|
28
|
+
* Override the default dictionary by passing the complete dictionary object for `en` and `fr`.
|
|
29
|
+
*/
|
|
30
|
+
dictionary?: {
|
|
31
|
+
en: ScrollDictionary
|
|
32
|
+
fr: ScrollDictionary
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Accessibility label for the scrollable region.
|
|
36
|
+
*/
|
|
37
|
+
accessibilityLabel?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type ScrollVariant = {}
|
|
41
|
+
|
|
42
|
+
export interface ScrollTokens {
|
|
43
|
+
itemGap?: number
|
|
44
|
+
progressBarColor?: string
|
|
45
|
+
progressBarHeight?: number
|
|
46
|
+
progressHitAreaHeight?: number
|
|
47
|
+
progressSpacing?: number
|
|
48
|
+
progressTrackColor?: string
|
|
49
|
+
progressTrackHeight?: number
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ScrollItemProps {
|
|
53
|
+
/**
|
|
54
|
+
* Content of the scroll item.
|
|
55
|
+
*/
|
|
56
|
+
children: ReactNode
|
|
57
|
+
/**
|
|
58
|
+
* Sets the HTML tag of the outer container. Defaults to `'li'`.
|
|
59
|
+
*/
|
|
60
|
+
tag?: SemanticTag
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare const Scroll: ComponentType<ScrollProps>
|
|
64
|
+
export declare const ScrollItem: ComponentType<ScrollItemProps>
|
|
65
|
+
|
|
66
|
+
export default Scroll
|
package/types/index.d.ts
CHANGED
|
@@ -45,6 +45,15 @@ export { LinkProps, LinkSize, LinkAndTextButtonVariants, LinkTokens } from './Li
|
|
|
45
45
|
export { default as List } from './List'
|
|
46
46
|
export { ListVariants, ListTokens, ListProps, ListItemProps, ListItemTokens } from './List'
|
|
47
47
|
|
|
48
|
+
export { default as Scroll, ScrollItem } from './Scroll'
|
|
49
|
+
export type {
|
|
50
|
+
ScrollProps,
|
|
51
|
+
ScrollTokens,
|
|
52
|
+
ScrollVariant,
|
|
53
|
+
ScrollItemProps,
|
|
54
|
+
ScrollDictionary
|
|
55
|
+
} from './Scroll'
|
|
56
|
+
|
|
48
57
|
export { default as Search } from './Search'
|
|
49
58
|
export { SearchTokens, SearchProps } from './Search'
|
|
50
59
|
|