@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.
Files changed (50) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/lib/cjs/Carousel/Carousel.js +6 -1
  3. package/lib/cjs/Carousel/CarouselThumbnail.js +123 -31
  4. package/lib/cjs/Carousel/CarouselThumbnailNavigation.js +8 -1
  5. package/lib/cjs/Footnote/FootnoteLink.js +18 -17
  6. package/lib/cjs/Progress/Progress.js +30 -5
  7. package/lib/cjs/Scroll/Scroll.js +466 -0
  8. package/lib/cjs/Scroll/ScrollContext.js +55 -0
  9. package/lib/cjs/Scroll/ScrollItem.js +103 -0
  10. package/lib/cjs/Scroll/ScrollProgress.js +99 -0
  11. package/lib/cjs/Scroll/dictionary.js +18 -0
  12. package/lib/cjs/Scroll/index.js +29 -0
  13. package/lib/cjs/index.js +15 -0
  14. package/lib/cjs/utils/animation/index.js +7 -0
  15. package/lib/cjs/utils/animation/useAnimatedValue.js +46 -0
  16. package/lib/cjs/utils/children.js +2 -1
  17. package/lib/esm/Carousel/Carousel.js +6 -1
  18. package/lib/esm/Carousel/CarouselThumbnail.js +124 -32
  19. package/lib/esm/Carousel/CarouselThumbnailNavigation.js +8 -1
  20. package/lib/esm/Footnote/FootnoteLink.js +18 -17
  21. package/lib/esm/Progress/Progress.js +30 -5
  22. package/lib/esm/Scroll/Scroll.js +459 -0
  23. package/lib/esm/Scroll/ScrollContext.js +47 -0
  24. package/lib/esm/Scroll/ScrollItem.js +96 -0
  25. package/lib/esm/Scroll/ScrollProgress.js +92 -0
  26. package/lib/esm/Scroll/dictionary.js +12 -0
  27. package/lib/esm/Scroll/index.js +4 -0
  28. package/lib/esm/index.js +1 -0
  29. package/lib/esm/utils/animation/index.js +1 -1
  30. package/lib/esm/utils/animation/useAnimatedValue.js +39 -0
  31. package/lib/esm/utils/children.js +2 -1
  32. package/lib/package.json +2 -2
  33. package/package.json +2 -2
  34. package/src/Carousel/Carousel.jsx +6 -1
  35. package/src/Carousel/CarouselThumbnail.jsx +153 -64
  36. package/src/Carousel/CarouselThumbnailNavigation.jsx +8 -2
  37. package/src/Footnote/FootnoteLink.jsx +17 -12
  38. package/src/Progress/Progress.jsx +22 -3
  39. package/src/Scroll/Scroll.jsx +488 -0
  40. package/src/Scroll/ScrollContext.jsx +41 -0
  41. package/src/Scroll/ScrollItem.jsx +89 -0
  42. package/src/Scroll/ScrollProgress.jsx +75 -0
  43. package/src/Scroll/dictionary.js +12 -0
  44. package/src/Scroll/index.js +5 -0
  45. package/src/index.js +1 -0
  46. package/src/utils/animation/index.js +1 -1
  47. package/src/utils/animation/useAnimatedValue.js +37 -0
  48. package/src/utils/children.jsx +4 -1
  49. package/types/Scroll.d.ts +66 -0
  50. package/types/index.d.ts +9 -0
@@ -0,0 +1,5 @@
1
+ import Scroll from './Scroll'
2
+
3
+ export default Scroll
4
+ export { default as ScrollItem } from './ScrollItem'
5
+ export { ScrollProvider, useScroll } from './ScrollContext'
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
- /* eslint-disable import/prefer-default-export */
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
@@ -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) || child.type === A11yText || child.type?.name === 'FootnoteLink'
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