@telus-uds/components-web 2.9.0 → 2.11.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 (90) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/component-docs.json +94 -81
  3. package/lib/BlockQuote/BlockQuote.js +53 -5
  4. package/lib/Callout/Callout.js +12 -0
  5. package/lib/DatePicker/CalendarContainer.js +24 -0
  6. package/lib/DatePicker/DatePicker.js +26 -9
  7. package/lib/Disclaimer/Disclaimer.js +0 -4
  8. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
  9. package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
  10. package/lib/IconButton/IconButton.js +8 -0
  11. package/lib/Listbox/GroupControl.js +44 -28
  12. package/lib/Listbox/Listbox.js +62 -47
  13. package/lib/Listbox/ListboxGroup.js +36 -20
  14. package/lib/Listbox/ListboxItem.js +14 -51
  15. package/lib/Listbox/ListboxOverlay.js +1 -1
  16. package/lib/NavigationBar/NavigationBar.js +4 -0
  17. package/lib/OrderedList/Item.js +4 -0
  18. package/lib/Paragraph/Paragraph.js +4 -0
  19. package/lib/PreviewCard/AuthorDate.js +7 -0
  20. package/lib/PriceLockup/PriceLockup.js +48 -0
  21. package/lib/QuantitySelector/QuantitySelector.js +51 -0
  22. package/lib/Span/Span.js +4 -0
  23. package/lib/Table/Table.js +4 -0
  24. package/lib/Toast/Toast.js +16 -0
  25. package/lib/Video/ControlBar/ControlBar.js +13 -10
  26. package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  27. package/lib/VideoPicker/VideoPicker.js +1 -1
  28. package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  29. package/lib/utils/index.js +3 -3
  30. package/lib-module/BlockQuote/BlockQuote.js +54 -6
  31. package/lib-module/Callout/Callout.js +12 -0
  32. package/lib-module/DatePicker/CalendarContainer.js +24 -0
  33. package/lib-module/DatePicker/DatePicker.js +26 -9
  34. package/lib-module/Disclaimer/Disclaimer.js +0 -4
  35. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
  36. package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
  37. package/lib-module/IconButton/IconButton.js +8 -0
  38. package/lib-module/Listbox/GroupControl.js +45 -29
  39. package/lib-module/Listbox/Listbox.js +62 -46
  40. package/lib-module/Listbox/ListboxGroup.js +37 -21
  41. package/lib-module/Listbox/ListboxItem.js +15 -51
  42. package/lib-module/Listbox/ListboxOverlay.js +1 -1
  43. package/lib-module/NavigationBar/NavigationBar.js +4 -0
  44. package/lib-module/OrderedList/Item.js +4 -0
  45. package/lib-module/Paragraph/Paragraph.js +4 -0
  46. package/lib-module/PreviewCard/AuthorDate.js +7 -0
  47. package/lib-module/PriceLockup/PriceLockup.js +48 -0
  48. package/lib-module/QuantitySelector/QuantitySelector.js +51 -0
  49. package/lib-module/Span/Span.js +4 -0
  50. package/lib-module/Table/Table.js +4 -0
  51. package/lib-module/Toast/Toast.js +16 -0
  52. package/lib-module/Video/ControlBar/ControlBar.js +14 -11
  53. package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  54. package/lib-module/VideoPicker/VideoPicker.js +1 -1
  55. package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  56. package/lib-module/utils/index.js +1 -1
  57. package/package.json +3 -3
  58. package/src/BlockQuote/BlockQuote.jsx +66 -7
  59. package/src/Callout/Callout.jsx +9 -0
  60. package/src/DatePicker/CalendarContainer.jsx +24 -0
  61. package/src/DatePicker/DatePicker.jsx +25 -9
  62. package/src/Disclaimer/Disclaimer.jsx +0 -3
  63. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +3 -0
  64. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +12 -0
  65. package/src/IconButton/IconButton.jsx +6 -0
  66. package/src/Listbox/GroupControl.jsx +50 -33
  67. package/src/Listbox/Listbox.jsx +65 -50
  68. package/src/Listbox/ListboxGroup.jsx +34 -19
  69. package/src/Listbox/ListboxItem.jsx +26 -48
  70. package/src/Listbox/ListboxOverlay.jsx +1 -1
  71. package/src/NavigationBar/NavigationBar.jsx +3 -0
  72. package/src/OrderedList/Item.jsx +3 -0
  73. package/src/Paragraph/Paragraph.jsx +3 -0
  74. package/src/PreviewCard/AuthorDate.jsx +6 -0
  75. package/src/PriceLockup/PriceLockup.jsx +37 -0
  76. package/src/QuantitySelector/QuantitySelector.jsx +39 -0
  77. package/src/Span/Span.jsx +3 -0
  78. package/src/Table/Table.jsx +3 -0
  79. package/src/Toast/Toast.jsx +12 -0
  80. package/src/Video/ControlBar/ControlBar.jsx +17 -13
  81. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +2 -1
  82. package/src/VideoPicker/VideoPicker.jsx +1 -1
  83. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +8 -1
  84. package/src/utils/index.js +1 -1
  85. package/lib/Listbox/PressableItem.js +0 -149
  86. package/lib/utils/htmlAttrs.js +0 -33
  87. package/lib-module/Listbox/PressableItem.js +0 -128
  88. package/lib-module/utils/htmlAttrs.js +0 -22
  89. package/src/Listbox/PressableItem.jsx +0 -121
  90. package/src/utils/htmlAttrs.js +0 -29
@@ -1,64 +1,81 @@
1
1
  import React from 'react'
2
2
  import styled from 'styled-components'
3
3
  import PropTypes from 'prop-types'
4
- import { Icon, Spacer, useThemeTokens } from '@telus-uds/components-base'
4
+ import { Icon, Spacer, useThemeTokens, useListboxContext } from '@telus-uds/components-base'
5
5
 
6
- const StyledControlWrapper = styled.div(({ focus, tokens }) => ({
7
- fontFamily: `${tokens.groupFontName}${tokens.groupFontWeight}normal`,
8
- fontSize: tokens.groupFontSize,
9
- color: tokens.groupColor,
10
- textDecoration: tokens.itemTextDecoration,
11
- backgroundColor: tokens.groupBackgroundColor,
12
- outline: tokens.itemOutline,
13
- width: '100%',
14
- display: 'flex',
15
- justifyContent: 'space-between',
16
- ...(focus
17
- ? {
18
- border: `${tokens.groupBorderWidth} solid ${tokens.groupBorderColor}`,
19
- borderRadius: tokens.groupBorderRadius,
20
- paddingLeft: `calc(${tokens.groupPaddingLeft}px - ${tokens.groupBorderWidth}px)`,
21
- paddingRight: `calc(${tokens.groupPaddingRight}px - ${tokens.groupBorderWidth}px)`,
22
- paddingTop: `calc(${tokens.groupPaddingTop}px - ${tokens.groupBorderWidth}px)`,
23
- paddingBottom: `calc(${tokens.groupPaddingBottom}px - ${tokens.groupBorderWidth}px)`
24
- }
25
- : {
26
- paddingLeft: tokens.groupPaddingLeft,
27
- paddingRight: tokens.groupPaddingRight,
28
- paddingTop: tokens.groupPaddingTop,
29
- paddingBottom: tokens.groupPaddingBottom
30
- })
31
- }))
6
+ const StyledControlWrapper = styled.div(
7
+ ({
8
+ groupFontName,
9
+ groupFontWeight,
10
+ groupFontSize,
11
+ groupColor,
12
+ groupBackgroundColor,
13
+ groupBorderColor,
14
+ groupBorderWidth,
15
+ groupBorderRadius,
16
+ groupPaddingLeft,
17
+ groupPaddingRight,
18
+ groupPaddingTop,
19
+ groupPaddingBottom,
20
+ itemTextDecoration,
21
+ itemOutline,
22
+ groupHeight
23
+ }) => ({
24
+ fontFamily: `${groupFontName}${groupFontWeight}normal`,
25
+ fontSize: groupFontSize,
26
+ color: groupColor,
27
+ textDecoration: itemTextDecoration,
28
+ backgroundColor: groupBackgroundColor,
29
+ outline: itemOutline,
30
+ width: '100%',
31
+ height: groupHeight,
32
+ display: 'flex',
33
+ alignItems: 'center',
34
+ justifyContent: 'space-between',
35
+ boxSizing: 'border-box',
36
+ border: `${groupBorderWidth}px solid ${groupBorderColor}`,
37
+ borderRadius: groupBorderRadius,
38
+ paddingLeft: groupPaddingLeft - groupBorderWidth,
39
+ paddingRight: groupPaddingRight - groupBorderWidth,
40
+ paddingTop: groupPaddingTop - groupBorderWidth,
41
+ paddingBottom: groupPaddingBottom - groupBorderWidth
42
+ })
43
+ )
32
44
 
33
- const GroupControl = ({ expanded, pressed, hover, focus, current, label }) => {
45
+ const GroupControl = ({ expanded, pressed, hover, focus, label, id }) => {
46
+ const { selectedId, setSelectedId } = useListboxContext()
34
47
  const tokens = useThemeTokens(
35
- 'ListBox',
48
+ 'Listbox',
36
49
  {},
37
50
  {},
38
51
  {
39
52
  expanded,
40
53
  pressed,
41
54
  hover,
42
- current,
55
+ current: selectedId === id && id !== undefined,
43
56
  focus
44
57
  }
45
58
  )
46
59
 
47
60
  return (
48
- <StyledControlWrapper {...{ focus, tokens }}>
61
+ <StyledControlWrapper onClick={() => setSelectedId(id)} {...tokens}>
49
62
  {label}
50
63
  <Spacer space={1} direction="row" />
51
- <Icon icon={tokens.groupIcon} variant={{ size: 'micro' }} />
64
+ <Icon
65
+ icon={tokens.groupIcon}
66
+ tokens={{ color: tokens.groupColor }}
67
+ variant={{ size: 'micro' }}
68
+ />
52
69
  </StyledControlWrapper>
53
70
  )
54
71
  }
55
72
 
56
73
  GroupControl.propTypes = {
74
+ id: PropTypes.string,
57
75
  expanded: PropTypes.bool,
58
76
  pressed: PropTypes.bool,
59
77
  hover: PropTypes.bool,
60
78
  focus: PropTypes.bool,
61
- current: PropTypes.bool,
62
79
  label: PropTypes.string
63
80
  }
64
81
 
@@ -1,11 +1,15 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import styled from 'styled-components'
4
- import { ExpandCollapse, withLinkRouter } from '@telus-uds/components-base'
4
+ import {
5
+ ExpandCollapse,
6
+ useThemeTokens,
7
+ withLinkRouter,
8
+ ListboxContext
9
+ } from '@telus-uds/components-base'
5
10
  import ListboxGroup from './ListboxGroup'
6
11
  import ListboxItem from './ListboxItem'
7
12
  import DropdownOverlay from './ListboxOverlay'
8
- import resolveItemSelection from '../NavigationBar/resolveItemSelection'
9
13
 
10
14
  const StyledList = styled.ul({
11
15
  margin: 0,
@@ -26,12 +30,18 @@ const Listbox = ({
26
30
  items = [],
27
31
  firstItemRef = null, // focus will be moved to this one once within the menu
28
32
  parentRef = null, // to return focus to after leaving the last menu item
29
- selectedId,
33
+ selectedId: defaultSelectedId,
30
34
  LinkRouter,
31
35
  itemRouterProps,
32
- onClose
36
+ onClose,
37
+ variant,
38
+ tokens
33
39
  }) => {
34
- const initialOpen = getInitialOpen(items, selectedId)
40
+ const initialOpen = getInitialOpen(items, defaultSelectedId)
41
+
42
+ const [selectedId, setSelectedId] = useState(defaultSelectedId)
43
+
44
+ const { minHeight, minWidth } = useThemeTokens('Listbox', variant, tokens)
35
45
 
36
46
  // We need to keep track of each item's ref in order to be able to
37
47
  // focus on a specific item via keyboard navigation
@@ -78,53 +88,52 @@ const Listbox = ({
78
88
  }, [onClose, handleKeydown])
79
89
 
80
90
  return (
81
- <ExpandCollapse initialOpen={initialOpen} maxOpen={1}>
82
- {(expandProps) => (
83
- <StyledList role="listbox">
84
- {items.map((item, index) => {
85
- const { id, label, items: nestedItems } = item
86
- const { itemId, selected } = resolveItemSelection(
87
- { id, label, items: nestedItems },
88
- selectedId
89
- )
91
+ <ListboxContext.Provider value={{ selectedId, setSelectedId }}>
92
+ <ExpandCollapse initialOpen={initialOpen} maxOpen={1}>
93
+ {(expandProps) => (
94
+ <StyledList role="listbox" style={{ minHeight, minWidth }}>
95
+ {items.map((item, index) => {
96
+ const { id, label, items: nestedItems } = item
97
+ const itemId = id ?? label
90
98
 
91
- // Give `firstItemRef` to the first focusable item
92
- const itemRef =
93
- (index === 0 && !itemId !== selectedId) || (index === 1 && items[0].id === selectedId)
94
- ? firstItemRef
95
- : (ref) => {
96
- itemRefs.current[index] = ref
97
- return ref
98
- }
99
+ // Give `firstItemRef` to the first focusable item
100
+ const itemRef =
101
+ (index === 0 && !itemId !== selectedId) ||
102
+ (index === 1 && items[0].id === selectedId)
103
+ ? firstItemRef
104
+ : (ref) => {
105
+ itemRefs.current[index] = ref
106
+ return ref
107
+ }
99
108
 
100
- return nestedItems ? (
101
- <ListboxGroup
102
- {...item}
103
- selectedId={selectedId}
104
- key={itemId}
105
- expandProps={expandProps}
106
- LinkRouter={LinkRouter}
107
- itemRouterProps={itemRouterProps}
108
- prevItemRef={itemRefs.current[index - 1] ?? null}
109
- nextItemRef={itemRefs.current[index + 1] ?? null}
110
- ref={itemRef}
111
- />
112
- ) : (
113
- <ListboxItem
114
- {...item}
115
- selected={selected}
116
- key={itemId}
117
- LinkRouter={LinkRouter}
118
- itemRouterProps={itemRouterProps}
119
- prevItemRef={itemRefs.current[index - 1] ?? null}
120
- nextItemRef={itemRefs.current[index + 1] ?? null}
121
- ref={itemRef}
122
- />
123
- )
124
- })}
125
- </StyledList>
126
- )}
127
- </ExpandCollapse>
109
+ return nestedItems ? (
110
+ <ListboxGroup
111
+ {...item}
112
+ expandProps={expandProps}
113
+ LinkRouter={LinkRouter}
114
+ itemRouterProps={itemRouterProps}
115
+ prevItemRef={itemRefs.current[index - 1] ?? null}
116
+ nextItemRef={itemRefs.current[index + 1] ?? null}
117
+ ref={itemRef}
118
+ key={itemId}
119
+ />
120
+ ) : (
121
+ <ListboxItem
122
+ {...item}
123
+ key={itemId}
124
+ id={itemId}
125
+ LinkRouter={LinkRouter}
126
+ itemRouterProps={itemRouterProps}
127
+ prevItemRef={itemRefs.current[index - 1] ?? null}
128
+ nextItemRef={itemRefs.current[index + 1] ?? null}
129
+ ref={itemRef}
130
+ />
131
+ )
132
+ })}
133
+ </StyledList>
134
+ )}
135
+ </ExpandCollapse>
136
+ </ListboxContext.Provider>
128
137
  )
129
138
  }
130
139
 
@@ -139,7 +148,13 @@ Listbox.propTypes = {
139
148
  * the last menu item.
140
149
  */
141
150
  parentRef: PropTypes.object,
151
+ /**
152
+ * `Listbox` items
153
+ */
142
154
  items: PropTypes.array,
155
+ /**
156
+ * To select an item by default
157
+ */
143
158
  selectedId: PropTypes.string
144
159
  }
145
160
 
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/require-default-props */
2
2
  import React, { forwardRef } from 'react'
3
3
  import PropTypes from 'prop-types'
4
- import { ExpandCollapse, withLinkRouter } from '@telus-uds/components-base'
4
+ import { ExpandCollapse, withLinkRouter, useListboxContext } from '@telus-uds/components-base'
5
5
  import styled from 'styled-components'
6
6
  import ListboxItem from './ListboxItem'
7
7
  import GroupControl from './GroupControl'
@@ -31,7 +31,6 @@ const ListboxGroup = forwardRef(
31
31
  id,
32
32
  label,
33
33
  items,
34
- selectedId,
35
34
  LinkRouter,
36
35
  linkRouterProps,
37
36
  expandProps,
@@ -41,8 +40,9 @@ const ListboxGroup = forwardRef(
41
40
  },
42
41
  ref
43
42
  ) => {
44
- // TODO: implement keyboard navigation via refs for grouped items separately here
43
+ const { selectedId } = useListboxContext()
45
44
 
45
+ // TODO: implement keyboard navigation via refs for grouped items separately here
46
46
  return (
47
47
  <StyledGroupWrapper role="option">
48
48
  <ExpandCollapse.Panel
@@ -52,34 +52,49 @@ const ListboxGroup = forwardRef(
52
52
  paddingLeft: 'none',
53
53
  paddingRight: 'none',
54
54
  paddingTop: 'none',
55
- paddingBottom: 'none'
55
+ paddingBottom: 'none',
56
+ backgroundColor: 'transparent',
57
+ borderColor: 'transparent',
58
+ textLine: 'none',
59
+ borderWidth: 0
56
60
  }}
57
61
  // TODO refactor
58
62
  // eslint-disable-next-line react/no-unstable-nested-components
59
- control={(controlProps) => <GroupControl {...controlProps} label={label} />}
63
+ control={(controlProps) => (
64
+ <GroupControl id={id ?? label} {...controlProps} label={label} />
65
+ )}
60
66
  {...expandProps}
61
67
  tokens={{
62
68
  contentPaddingLeft: 'none',
63
69
  contentPaddingRight: 'none',
64
70
  contentPaddingTop: 'none',
65
- contentPaddingBottom: 'none'
71
+ contentPaddingBottom: 'none',
72
+ borderColor: 'transparent',
73
+ borderRadius: 0,
74
+ borderWidth: 0,
75
+ marginBottom: 0
66
76
  }}
67
77
  controlRef={ref}
68
78
  >
69
79
  <StyledList>
70
- {items.map((item, index) => (
71
- <ListboxItem
72
- key={item.label}
73
- {...item}
74
- selected={item.id === selectedId}
75
- isChild
76
- LinkRouter={LinkRouter}
77
- linkRouterProps={linkRouterProps}
78
- {...(index === 0 && { prevItemRef })}
79
- {...(index === items.length - 1 && { nextItemRef })}
80
- {...(index === items.length - 1 && { onBlur: onLastItemBlur })}
81
- />
82
- ))}
80
+ {items.map((item, index) => {
81
+ return (
82
+ <ListboxItem
83
+ key={item.label}
84
+ id={item.id ?? item.label}
85
+ {...item}
86
+ selected={
87
+ (item.id && item.id === selectedId) || (item.label && item.label === selectedId)
88
+ }
89
+ isChild
90
+ LinkRouter={LinkRouter}
91
+ linkRouterProps={linkRouterProps}
92
+ {...(index === 0 && { prevItemRef })}
93
+ {...(index === items.length - 1 && { nextItemRef })}
94
+ {...(index === items.length - 1 && { onBlur: onLastItemBlur })}
95
+ />
96
+ )
97
+ })}
83
98
  </StyledList>
84
99
  </ExpandCollapse.Panel>
85
100
  </StyledGroupWrapper>
@@ -2,9 +2,13 @@
2
2
  import React, { forwardRef } from 'react'
3
3
  import PropTypes from 'prop-types'
4
4
  import styled from 'styled-components'
5
- import { selectSystemProps, withLinkRouter, useThemeTokens } from '@telus-uds/components-base'
5
+ import {
6
+ selectSystemProps,
7
+ withLinkRouter,
8
+ useThemeTokensCallback,
9
+ PressableItem
10
+ } from '@telus-uds/components-base'
6
11
  import { htmlAttrs } from '../utils'
7
- import PressableItem from './PressableItem'
8
12
 
9
13
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
10
14
 
@@ -17,36 +21,11 @@ const StyledItemContainer = styled.li({
17
21
  }
18
22
  })
19
23
 
20
- const getSelectedItemStyles = ({ tokens }) => ({
21
- display: tokens.itemDisplay,
22
- fontFamily: `${tokens.itemFontName}${tokens.itemFontWeight}normal`,
23
- fontSize: tokens.itemFontSize,
24
- paddingTop: tokens.itemPaddingTop,
25
- paddingBottom: tokens.itemPaddingBottom,
26
- paddingLeft: tokens.itemPaddingLeft,
27
- paddingRight: tokens.itemPaddingRight,
28
- color: tokens.itemColor,
29
- textDecoration: tokens.itemTextDecoration,
30
- backgroundColor: tokens.itemBackgroundColor,
31
- outline: tokens.itemOutline,
32
- borderWidth: tokens.itemBorderWidth,
33
- width: '100%'
34
- })
35
-
36
- const SelectedItem = styled.div(({ isChild, tokens }) => ({
37
- ...getSelectedItemStyles({ tokens }),
38
- borderLeft: isChild
39
- ? `${tokens.itemBorderLeftWidth}px solid ${tokens.itemBorderLeftColor}`
40
- : 'none'
41
- }))
42
-
43
24
  const ListboxItem = forwardRef(
44
25
  (
45
26
  {
46
27
  href,
47
28
  label,
48
- onPress,
49
- selected = false,
50
29
  isChild = false,
51
30
  onBlur,
52
31
  nextItemRef,
@@ -55,32 +34,32 @@ const ListboxItem = forwardRef(
55
34
  variant = {},
56
35
  LinkRouter,
57
36
  linkRouterProps,
37
+ id,
38
+ onPress = () => {},
39
+
58
40
  ...rest
59
41
  },
60
42
  ref
61
43
  ) => {
62
- const selectedProps = selectProps(rest)
63
- const systemTokens = useThemeTokens('ListBox', tokens, variant, { isChild })
44
+ const selectedProps = selectProps({ href, ...rest })
64
45
 
46
+ const getTokens = useThemeTokensCallback('Listbox', tokens, variant, { isChild })
65
47
  return (
66
48
  <StyledItemContainer isChild={isChild} {...selectedProps} role="option">
67
- {selected ? (
68
- <SelectedItem isChild={isChild} tokens={systemTokens}>
69
- {label}
70
- </SelectedItem>
71
- ) : (
72
- <PressableItem
73
- href={href}
74
- isChild={isChild}
75
- onPress={onPress}
76
- onBlur={onBlur}
77
- nextItemRef={nextItemRef}
78
- prevItemRef={prevItemRef}
79
- ref={ref}
80
- >
81
- {label}
82
- </PressableItem>
83
- )}
49
+ <PressableItem
50
+ href={href}
51
+ isChild={isChild}
52
+ onPress={onPress}
53
+ onBlur={onBlur}
54
+ nextItemRef={nextItemRef}
55
+ prevItemRef={prevItemRef}
56
+ ref={ref}
57
+ tokens={getTokens}
58
+ selectedProps={selectedProps}
59
+ id={id}
60
+ >
61
+ {label}
62
+ </PressableItem>
84
63
  </StyledItemContainer>
85
64
  )
86
65
  }
@@ -95,8 +74,7 @@ ListboxItem.propTypes = {
95
74
  label: PropTypes.node.isRequired,
96
75
  nextItemRef: PropTypes.object,
97
76
  prevItemRef: PropTypes.object,
98
- onPress: PropTypes.func,
99
- selected: PropTypes.bool
77
+ onPress: PropTypes.func
100
78
  }
101
79
 
102
80
  export default withLinkRouter(ListboxItem)
@@ -23,7 +23,7 @@ const paddingHorizontal = 0
23
23
 
24
24
  const DropdownOverlay = forwardRef(
25
25
  ({ children, isReady = false, overlaidPosition, maxWidth, minWidth, onLayout }, ref) => {
26
- const systemTokens = useThemeTokens('ListBox', {}, {})
26
+ const systemTokens = useThemeTokens('Listbox', {}, {})
27
27
 
28
28
  return (
29
29
  <WebPortal>
@@ -198,6 +198,9 @@ NavigationBar.propTypes = {
198
198
  * Common navigation bar heading.
199
199
  */
200
200
  heading: PropTypes.string,
201
+ /**
202
+ * Sets the `headingLevel` of the `heading`
203
+ */
201
204
  headingLevel: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
202
205
  /**
203
206
  * Matches the `id` property of the item in `items` corresponding to the current page
@@ -107,6 +107,9 @@ Item.propTypes = {
107
107
  * Item content
108
108
  */
109
109
  children: PropTypes.node.isRequired,
110
+ /**
111
+ * Defines the title of the `OrderedList.Item`
112
+ */
110
113
  title: PropTypes.string,
111
114
  /**
112
115
  * Item tokens
@@ -49,6 +49,9 @@ const Paragraph = ({ children, variant, tokens, testID, align, linesBetween = 1,
49
49
  Paragraph.propTypes = {
50
50
  ...selectedSystemPropTypes,
51
51
  children: PropTypes.node.isRequired,
52
+ /**
53
+ * Adds a `data-testid` attribute to the element for testing purposes
54
+ */
52
55
  testID: PropTypes.string,
53
56
  /**
54
57
  * Sets the alignment style for the paragraph. Same options as Typography's `align` prop.
@@ -24,7 +24,13 @@ const AuthorDate = ({ author, date }) => {
24
24
  }
25
25
 
26
26
  AuthorDate.propTypes = {
27
+ /**
28
+ * Name of the author
29
+ */
27
30
  author: PropTypes.string.isRequired,
31
+ /**
32
+ * Date of the post
33
+ */
28
34
  date: PropTypes.string.isRequired
29
35
  }
30
36
 
@@ -226,16 +226,53 @@ const PriceLockup = ({
226
226
 
227
227
  PriceLockup.propTypes = {
228
228
  ...selectedSystemPropTypes,
229
+ /**
230
+ * Size of the component
231
+ *
232
+ * Small for pricing in product catalogue pages, medium for pricing in product comparison cards and large for pricing in banners and promo cards
233
+ */
229
234
  size: PropTypes.oneOf(['small', 'medium', 'large']),
235
+ /**
236
+ * If currency symbol other than `$` to be used
237
+ */
230
238
  currencySymbol: PropTypes.string,
239
+ /**
240
+ * Shows additional info above the price
241
+ */
231
242
  topText: PropTypes.string,
243
+ /**
244
+ * Monetary value (including decimals separated by ".")
245
+ */
232
246
  price: PropTypes.string.isRequired,
247
+ /**
248
+ * Shows month/year unit
249
+ */
233
250
  rateText: PropTypes.string,
251
+ /**
252
+ * Shows additional info below the price with a `Divider`
253
+ */
234
254
  bottomText: PropTypes.string,
255
+ /**
256
+ * Displays which side the currency should apperar (left, right)
257
+ */
235
258
  signDirection: PropTypes.oneOf(['right', 'left']),
259
+ /**
260
+ * Shows additional link for context
261
+ */
236
262
  footnoteLinks: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
263
+ /**
264
+ * Function to be called when a footnote link is clicked
265
+ */
237
266
  onClickFootnote: PropTypes.func,
267
+ /**
268
+ * To show price savings comparison
269
+ */
238
270
  strikeThrough: PropTypes.bool,
271
+ /**
272
+ * To provide a11y text for `PriceLockup` component
273
+ *
274
+ * **Note:** a11yText will override strikethrough price, so it must include price (ie. "was 50 dollars per month")
275
+ */
239
276
  a11yText: PropTypes.string
240
277
  }
241
278
 
@@ -210,25 +210,64 @@ const dictionaryContentShape = PropTypes.shape({
210
210
  })
211
211
 
212
212
  QuantitySelector.propTypes = {
213
+ /**
214
+ * The id of the input field
215
+ */
213
216
  id: PropTypes.string,
217
+ /**
218
+ * The minimum number allowed
219
+ */
214
220
  minNumber: PropTypes.number,
221
+ /**
222
+ * The maximum number allowed
223
+ */
215
224
  maxNumber: PropTypes.number,
225
+ /**
226
+ * The callback function that is called when the value of the input field changes
227
+ */
216
228
  onChange: PropTypes.func,
229
+ /**
230
+ * The default value of the input field
231
+ */
217
232
  defaultValue: PropTypes.number,
233
+ /**
234
+ * The label of the input field
235
+ */
218
236
  label: PropTypes.string,
237
+ /**
238
+ * The hint of the input field
239
+ */
219
240
  hint: PropTypes.string,
241
+ /**
242
+ * The position of the hint. Could be shown along side the label or below it
243
+ */
220
244
  hintPosition: PropTypes.oneOf(['inline', 'below']),
245
+ /**
246
+ * Adds a question mark which will display a tooltip when clicked
247
+ */
221
248
  tooltip: PropTypes.string,
249
+ /**
250
+ * The accessibility label of the input field
251
+ */
222
252
  accessibilityLabel: PropTypes.string,
253
+ /**
254
+ * The dictionary object containing the content for the input field
255
+ */
223
256
  dictionary: PropTypes.shape({
224
257
  en: dictionaryContentShape,
225
258
  fr: dictionaryContentShape
226
259
  }),
260
+ /**
261
+ * The language to use for the copy.
262
+ */
227
263
  copy: PropTypes.oneOfType([PropTypes.oneOf(['en', 'fr'])]),
228
264
  variant: PropTypes.exact({
229
265
  alternative: PropTypes.bool
230
266
  }),
231
267
  tokens: PropTypes.oneOf([PropTypes.object, PropTypes.func]),
268
+ /**
269
+ * Sets `data-testid` attribute on the input field for testing purposes.
270
+ */
232
271
  testID: PropTypes.string
233
272
  }
234
273
 
package/src/Span/Span.jsx CHANGED
@@ -27,6 +27,9 @@ const Span = ({ children, variant, tokens, testID, flex, ...rest }) => {
27
27
  Span.propTypes = {
28
28
  ...selectedSystemPropTypes,
29
29
  children: PropTypes.node.isRequired,
30
+ /**
31
+ * Adds `data-testid` attribute for testing
32
+ */
30
33
  testID: PropTypes.string,
31
34
  /**
32
35
  * Sets display to inline-flex so that children are laid out using the flex model.
@@ -87,6 +87,9 @@ const Table = ({ children, fullWidth = true, text = 'medium', tokens, variant, .
87
87
  Table.propTypes = {
88
88
  ...selectedSystemPropTypes,
89
89
  children: PropTypes.node,
90
+ /**
91
+ * Sets text style
92
+ */
90
93
  text: PropTypes.oneOf(['medium', 'small'])
91
94
  }
92
95