@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.
- package/CHANGELOG.md +28 -2
- package/component-docs.json +94 -81
- package/lib/BlockQuote/BlockQuote.js +53 -5
- package/lib/Callout/Callout.js +12 -0
- package/lib/DatePicker/CalendarContainer.js +24 -0
- package/lib/DatePicker/DatePicker.js +26 -9
- package/lib/Disclaimer/Disclaimer.js +0 -4
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
- package/lib/IconButton/IconButton.js +8 -0
- package/lib/Listbox/GroupControl.js +44 -28
- package/lib/Listbox/Listbox.js +62 -47
- package/lib/Listbox/ListboxGroup.js +36 -20
- package/lib/Listbox/ListboxItem.js +14 -51
- package/lib/Listbox/ListboxOverlay.js +1 -1
- package/lib/NavigationBar/NavigationBar.js +4 -0
- package/lib/OrderedList/Item.js +4 -0
- package/lib/Paragraph/Paragraph.js +4 -0
- package/lib/PreviewCard/AuthorDate.js +7 -0
- package/lib/PriceLockup/PriceLockup.js +48 -0
- package/lib/QuantitySelector/QuantitySelector.js +51 -0
- package/lib/Span/Span.js +4 -0
- package/lib/Table/Table.js +4 -0
- package/lib/Toast/Toast.js +16 -0
- package/lib/Video/ControlBar/ControlBar.js +13 -10
- package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
- package/lib/VideoPicker/VideoPicker.js +1 -1
- package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
- package/lib/utils/index.js +3 -3
- package/lib-module/BlockQuote/BlockQuote.js +54 -6
- package/lib-module/Callout/Callout.js +12 -0
- package/lib-module/DatePicker/CalendarContainer.js +24 -0
- package/lib-module/DatePicker/DatePicker.js +26 -9
- package/lib-module/Disclaimer/Disclaimer.js +0 -4
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
- package/lib-module/IconButton/IconButton.js +8 -0
- package/lib-module/Listbox/GroupControl.js +45 -29
- package/lib-module/Listbox/Listbox.js +62 -46
- package/lib-module/Listbox/ListboxGroup.js +37 -21
- package/lib-module/Listbox/ListboxItem.js +15 -51
- package/lib-module/Listbox/ListboxOverlay.js +1 -1
- package/lib-module/NavigationBar/NavigationBar.js +4 -0
- package/lib-module/OrderedList/Item.js +4 -0
- package/lib-module/Paragraph/Paragraph.js +4 -0
- package/lib-module/PreviewCard/AuthorDate.js +7 -0
- package/lib-module/PriceLockup/PriceLockup.js +48 -0
- package/lib-module/QuantitySelector/QuantitySelector.js +51 -0
- package/lib-module/Span/Span.js +4 -0
- package/lib-module/Table/Table.js +4 -0
- package/lib-module/Toast/Toast.js +16 -0
- package/lib-module/Video/ControlBar/ControlBar.js +14 -11
- package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
- package/lib-module/VideoPicker/VideoPicker.js +1 -1
- package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
- package/lib-module/utils/index.js +1 -1
- package/package.json +3 -3
- package/src/BlockQuote/BlockQuote.jsx +66 -7
- package/src/Callout/Callout.jsx +9 -0
- package/src/DatePicker/CalendarContainer.jsx +24 -0
- package/src/DatePicker/DatePicker.jsx +25 -9
- package/src/Disclaimer/Disclaimer.jsx +0 -3
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +3 -0
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +12 -0
- package/src/IconButton/IconButton.jsx +6 -0
- package/src/Listbox/GroupControl.jsx +50 -33
- package/src/Listbox/Listbox.jsx +65 -50
- package/src/Listbox/ListboxGroup.jsx +34 -19
- package/src/Listbox/ListboxItem.jsx +26 -48
- package/src/Listbox/ListboxOverlay.jsx +1 -1
- package/src/NavigationBar/NavigationBar.jsx +3 -0
- package/src/OrderedList/Item.jsx +3 -0
- package/src/Paragraph/Paragraph.jsx +3 -0
- package/src/PreviewCard/AuthorDate.jsx +6 -0
- package/src/PriceLockup/PriceLockup.jsx +37 -0
- package/src/QuantitySelector/QuantitySelector.jsx +39 -0
- package/src/Span/Span.jsx +3 -0
- package/src/Table/Table.jsx +3 -0
- package/src/Toast/Toast.jsx +12 -0
- package/src/Video/ControlBar/ControlBar.jsx +17 -13
- package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +2 -1
- package/src/VideoPicker/VideoPicker.jsx +1 -1
- package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +8 -1
- package/src/utils/index.js +1 -1
- package/lib/Listbox/PressableItem.js +0 -149
- package/lib/utils/htmlAttrs.js +0 -33
- package/lib-module/Listbox/PressableItem.js +0 -128
- package/lib-module/utils/htmlAttrs.js +0 -22
- package/src/Listbox/PressableItem.jsx +0 -121
- 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(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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,
|
|
45
|
+
const GroupControl = ({ expanded, pressed, hover, focus, label, id }) => {
|
|
46
|
+
const { selectedId, setSelectedId } = useListboxContext()
|
|
34
47
|
const tokens = useThemeTokens(
|
|
35
|
-
'
|
|
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 {
|
|
61
|
+
<StyledControlWrapper onClick={() => setSelectedId(id)} {...tokens}>
|
|
49
62
|
{label}
|
|
50
63
|
<Spacer space={1} direction="row" />
|
|
51
|
-
<Icon
|
|
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
|
|
package/src/Listbox/Listbox.jsx
CHANGED
|
@@ -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 {
|
|
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,
|
|
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
|
-
<
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
</
|
|
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
|
-
|
|
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) =>
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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 {
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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('
|
|
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
|
package/src/OrderedList/Item.jsx
CHANGED
|
@@ -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.
|
|
@@ -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.
|
package/src/Table/Table.jsx
CHANGED