@telus-uds/components-web 2.12.0 → 2.13.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 +22 -2
- package/component-docs.json +59 -24
- package/lib/Autocomplete/Loading.js +5 -10
- package/lib/Autocomplete/dictionary.js +2 -2
- package/lib/DatePicker/DatePicker.js +6 -0
- package/lib/NavigationBar/NavigationSubMenu.js +4 -8
- package/lib/Spinner/Spinner.js +10 -1
- package/lib/Spinner/SpinnerContent.js +8 -0
- package/lib/Table/Cell.js +62 -91
- package/lib/Table/Header.js +4 -1
- package/lib/Table/SubHeading.js +4 -1
- package/lib/Table/Table.js +2 -1
- package/lib/TermsAndConditions/ExpandCollapse.js +31 -13
- package/lib/TermsAndConditions/TermsAndConditions.js +21 -6
- package/lib/VideoPicker/VideoPickerPlayer.js +4 -2
- package/lib/VideoPicker/VideoPickerThumbnail.js +103 -60
- package/lib/VideoPicker/VideoSlider.js +2 -2
- package/lib-module/Autocomplete/Loading.js +6 -12
- package/lib-module/Autocomplete/dictionary.js +2 -2
- package/lib-module/DatePicker/DatePicker.js +7 -1
- package/lib-module/NavigationBar/NavigationSubMenu.js +5 -9
- package/lib-module/Spinner/Spinner.js +10 -1
- package/lib-module/Spinner/SpinnerContent.js +8 -0
- package/lib-module/Table/Cell.js +65 -90
- package/lib-module/Table/Header.js +4 -1
- package/lib-module/Table/SubHeading.js +4 -1
- package/lib-module/Table/Table.js +2 -1
- package/lib-module/TermsAndConditions/ExpandCollapse.js +33 -15
- package/lib-module/TermsAndConditions/TermsAndConditions.js +22 -7
- package/lib-module/VideoPicker/VideoPickerPlayer.js +4 -2
- package/lib-module/VideoPicker/VideoPickerThumbnail.js +103 -61
- package/lib-module/VideoPicker/VideoSlider.js +2 -2
- package/package.json +3 -3
- package/src/Autocomplete/Loading.jsx +2 -5
- package/src/Autocomplete/dictionary.js +2 -2
- package/src/DatePicker/DatePicker.jsx +8 -1
- package/src/NavigationBar/NavigationSubMenu.jsx +3 -4
- package/src/Spinner/Spinner.jsx +9 -1
- package/src/Spinner/SpinnerContent.jsx +13 -1
- package/src/Table/Cell.jsx +58 -78
- package/src/Table/Header.jsx +6 -1
- package/src/Table/SubHeading.jsx +4 -1
- package/src/Table/Table.jsx +10 -2
- package/src/TermsAndConditions/ExpandCollapse.jsx +36 -14
- package/src/TermsAndConditions/TermsAndConditions.jsx +18 -6
- package/src/VideoPicker/VideoPickerPlayer.jsx +2 -2
- package/src/VideoPicker/VideoPickerThumbnail.jsx +51 -30
- package/src/VideoPicker/VideoSlider.jsx +2 -2
- package/types/BaseProvider.d.ts +25 -0
- package/types/index.d.ts +1 -1
|
@@ -4,7 +4,7 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { viewports } from '@telus-uds/system-constants';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
-
import { StackView, Typography, useViewport, horizontalScrollUtils,
|
|
7
|
+
import { StackView, Typography, useViewport, horizontalScrollUtils, useThemeTokensCallback } from '@telus-uds/components-base';
|
|
8
8
|
import { getTimestamp } from '../shared/VideoSplash/helpers';
|
|
9
9
|
import { VideoPropType, RefPropType } from './videoPropType';
|
|
10
10
|
import VideoSplash from '../shared/VideoSplash/VideoSplash';
|
|
@@ -42,37 +42,45 @@ const createReactNativeStyles = _ref => {
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
displayName: "
|
|
45
|
+
const ImageContainer = /*#__PURE__*/styled.div.withConfig({
|
|
46
|
+
displayName: "VideoPickerThumbnail__ImageContainer",
|
|
47
47
|
componentId: "components-web__sc-1glxurq-0"
|
|
48
|
-
})(["
|
|
48
|
+
})(["padding:", ";border:", ";border-radius:", "px;"], props => `${props.outerBorderGap}px`, props => `${props.outerBorderWidth}px solid ${props.outerBorderColor}`, _ref2 => {
|
|
49
49
|
let {
|
|
50
|
-
|
|
50
|
+
outerBorderRadius
|
|
51
51
|
} = _ref2;
|
|
52
|
-
return
|
|
53
|
-
}
|
|
52
|
+
return outerBorderRadius;
|
|
53
|
+
});
|
|
54
|
+
const VideoThumbnail = /*#__PURE__*/styled.div.withConfig({
|
|
55
|
+
displayName: "VideoPickerThumbnail__VideoThumbnail",
|
|
56
|
+
componentId: "components-web__sc-1glxurq-1"
|
|
57
|
+
})(["position:relative;width:", ";flex-shrink:0;* button{display:none;}&::before{content:'';display:block;padding-bottom:56.25%;}&::after{content:'';border:", "px solid;border-color:", ";border-radius:", "px;position:absolute;top:0;left:0;right:0;bottom:0;}& > div{border-radius:", "px;}"], props => props.layout === 'vertical' ? '100%' : '144px', _ref3 => {
|
|
54
58
|
let {
|
|
55
|
-
|
|
56
|
-
borderColor
|
|
59
|
+
borderWidth
|
|
57
60
|
} = _ref3;
|
|
58
|
-
return
|
|
61
|
+
return borderWidth;
|
|
59
62
|
}, _ref4 => {
|
|
60
63
|
let {
|
|
61
|
-
|
|
64
|
+
borderColor
|
|
62
65
|
} = _ref4;
|
|
63
|
-
return
|
|
66
|
+
return borderColor;
|
|
64
67
|
}, _ref5 => {
|
|
65
68
|
let {
|
|
66
69
|
borderRadius
|
|
67
70
|
} = _ref5;
|
|
68
71
|
return borderRadius;
|
|
72
|
+
}, _ref6 => {
|
|
73
|
+
let {
|
|
74
|
+
borderRadius
|
|
75
|
+
} = _ref6;
|
|
76
|
+
return borderRadius;
|
|
69
77
|
});
|
|
70
78
|
const ThumbnailTitleContainer = /*#__PURE__*/styled.div.withConfig({
|
|
71
79
|
displayName: "VideoPickerThumbnail__ThumbnailTitleContainer",
|
|
72
|
-
componentId: "components-web__sc-1glxurq-
|
|
80
|
+
componentId: "components-web__sc-1glxurq-2"
|
|
73
81
|
})(["display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;"]);
|
|
74
82
|
|
|
75
|
-
const VideoPickerThumbnail =
|
|
83
|
+
const VideoPickerThumbnail = _ref7 => {
|
|
76
84
|
let {
|
|
77
85
|
videoPlayerRef,
|
|
78
86
|
selectedVideoId,
|
|
@@ -83,56 +91,59 @@ const VideoPickerThumbnail = _ref6 => {
|
|
|
83
91
|
itemPositions,
|
|
84
92
|
index,
|
|
85
93
|
width = '100%'
|
|
86
|
-
} =
|
|
94
|
+
} = _ref7;
|
|
87
95
|
const viewport = useViewport();
|
|
88
|
-
const {
|
|
89
|
-
titleColor,
|
|
90
|
-
subTitleColor,
|
|
91
|
-
...themeTokens
|
|
92
|
-
} = useThemeTokens('VideoPickerThumbnail');
|
|
93
|
-
const rnStyles = createReactNativeStyles(themeTokens);
|
|
96
|
+
const getTokens = useThemeTokensCallback('VideoPickerThumbnail', {}, {});
|
|
94
97
|
const {
|
|
95
98
|
timestamp
|
|
96
99
|
} = getTimestamp(video.videoLength, video.copy);
|
|
97
100
|
const isPlaying = selectedVideoId === video.videoId;
|
|
98
101
|
|
|
99
|
-
const renderThumbnailImage =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
const renderThumbnailImage = themeTokens => {
|
|
103
|
+
return /*#__PURE__*/_jsx(VideoThumbnail, { ...themeTokens,
|
|
104
|
+
isPlaying: isPlaying,
|
|
105
|
+
layout: layout,
|
|
106
|
+
children: /*#__PURE__*/_jsx(VideoSplash, {
|
|
107
|
+
simpleMode: true,
|
|
108
|
+
poster: video.posterSrc || `https://img.youtube.com/vi/${video.videoId}/maxresdefault.jpg`,
|
|
109
|
+
videoLength: video.videoLength,
|
|
110
|
+
copy: video.copy
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
};
|
|
109
114
|
|
|
110
|
-
const renderThumbnailInfo =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const renderThumbnailInfo = _ref8 => {
|
|
116
|
+
let {
|
|
117
|
+
titleColor,
|
|
118
|
+
subTitleColor
|
|
119
|
+
} = _ref8;
|
|
120
|
+
return /*#__PURE__*/_jsxs(StackView, {
|
|
121
|
+
space: 2,
|
|
122
|
+
tokens: {
|
|
123
|
+
flexShrink: 1
|
|
124
|
+
},
|
|
125
|
+
children: [/*#__PURE__*/_jsx(ThumbnailTitleContainer, {
|
|
126
|
+
viewport: viewport,
|
|
127
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
128
|
+
variant: {
|
|
129
|
+
bold: true
|
|
130
|
+
},
|
|
131
|
+
tokens: {
|
|
132
|
+
color: titleColor
|
|
133
|
+
},
|
|
134
|
+
children: video.title
|
|
135
|
+
})
|
|
136
|
+
}), viewport !== viewports.xs && /*#__PURE__*/_jsx(Typography, {
|
|
118
137
|
variant: {
|
|
119
|
-
|
|
138
|
+
size: 'micro'
|
|
120
139
|
},
|
|
121
140
|
tokens: {
|
|
122
|
-
color:
|
|
141
|
+
color: subTitleColor
|
|
123
142
|
},
|
|
124
|
-
children:
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
size: 'micro'
|
|
129
|
-
},
|
|
130
|
-
tokens: {
|
|
131
|
-
color: subTitleColor
|
|
132
|
-
},
|
|
133
|
-
children: timestamp
|
|
134
|
-
})]
|
|
135
|
-
});
|
|
143
|
+
children: timestamp
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
};
|
|
136
147
|
|
|
137
148
|
const handleLayout = itemPositions !== undefined ? getItemPositionLayoutHandler(itemPositions.positions, index) : undefined;
|
|
138
149
|
|
|
@@ -155,14 +166,45 @@ const VideoPickerThumbnail = _ref6 => {
|
|
|
155
166
|
accessibilityState: {
|
|
156
167
|
checked: isPlaying
|
|
157
168
|
},
|
|
158
|
-
style:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
style: _ref9 => {
|
|
170
|
+
let {
|
|
171
|
+
hovered: hover,
|
|
172
|
+
focused: focus,
|
|
173
|
+
pressed
|
|
174
|
+
} = _ref9;
|
|
175
|
+
const themeTokens = getTokens({
|
|
176
|
+
hover,
|
|
177
|
+
focus,
|
|
178
|
+
pressed,
|
|
179
|
+
selected: isPlaying
|
|
180
|
+
});
|
|
181
|
+
const rnStyles = createReactNativeStyles(themeTokens);
|
|
182
|
+
return [rnStyles.container, layout === 'horizontal' && rnStyles.horizontal, isFramed && rnStyles.framed, isFramed && index > 0 && rnStyles.framedLine, {
|
|
183
|
+
width
|
|
184
|
+
}, {
|
|
185
|
+
outline: 'none'
|
|
186
|
+
}];
|
|
187
|
+
},
|
|
188
|
+
children: _ref10 => {
|
|
189
|
+
let {
|
|
190
|
+
hovered: hover,
|
|
191
|
+
focused: focus,
|
|
192
|
+
pressed
|
|
193
|
+
} = _ref10;
|
|
194
|
+
const themeTokens = getTokens({
|
|
195
|
+
hover,
|
|
196
|
+
focus,
|
|
197
|
+
pressed,
|
|
198
|
+
selected: isPlaying
|
|
199
|
+
});
|
|
200
|
+
return /*#__PURE__*/_jsxs(StackView, {
|
|
201
|
+
space: layout === 'vertical' ? 2 : 3,
|
|
202
|
+
direction: layout === 'vertical' ? 'column' : 'row',
|
|
203
|
+
children: [/*#__PURE__*/_jsx(ImageContainer, { ...themeTokens,
|
|
204
|
+
children: renderThumbnailImage(themeTokens)
|
|
205
|
+
}), renderThumbnailInfo(themeTokens)]
|
|
206
|
+
});
|
|
207
|
+
}
|
|
166
208
|
}, video.videoId);
|
|
167
209
|
};
|
|
168
210
|
|
|
@@ -30,7 +30,7 @@ const VideoSlider = _ref => {
|
|
|
30
30
|
setContainerWidth(width);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const itemsGap =
|
|
33
|
+
const itemsGap = 32; // '5' on spacing scale
|
|
34
34
|
|
|
35
35
|
const itemsCount = viewport === 'lg' || viewport === 'xl' ? 4 : 3;
|
|
36
36
|
const itemGapPortioned = (itemsCount - 1) * itemsGap / itemsCount;
|
|
@@ -40,7 +40,7 @@ const VideoSlider = _ref => {
|
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
const content = /*#__PURE__*/_jsx(StackView, {
|
|
43
|
-
space:
|
|
43
|
+
space: 5,
|
|
44
44
|
direction: "row",
|
|
45
45
|
accessibilityRole: "radiogroup",
|
|
46
46
|
tokens: {
|
package/package.json
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
],
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@gorhom/portal": "^1.0.14",
|
|
8
|
-
"@telus-uds/components-base": "1.
|
|
8
|
+
"@telus-uds/components-base": "1.54.0",
|
|
9
9
|
"@telus-uds/system-constants": "^1.2.1",
|
|
10
10
|
"fscreen": "^1.2.0",
|
|
11
11
|
"lodash.omit": "^4.5.0",
|
|
12
12
|
"react-dates": "^21.8.0",
|
|
13
13
|
"react-helmet-async": "^1.3.0",
|
|
14
14
|
"react-moment-proptypes": "^1.8.1",
|
|
15
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
15
|
+
"@telus-uds/system-theme-tokens": "^2.37.0",
|
|
16
16
|
"prop-types": "^15.7.2",
|
|
17
17
|
"lodash.throttle": "^4.1.1",
|
|
18
18
|
"react-youtube": "^10.1.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"skip": true
|
|
64
64
|
},
|
|
65
65
|
"types": "types/index.d.ts",
|
|
66
|
-
"version": "2.
|
|
66
|
+
"version": "2.13.0"
|
|
67
67
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { Box, StackView
|
|
3
|
+
import { Box, StackView } from '@telus-uds/components-base'
|
|
4
4
|
import Spinner from '../Spinner'
|
|
5
5
|
|
|
6
6
|
const Loading = ({ label }) => (
|
|
7
7
|
<Box space={3}>
|
|
8
8
|
<StackView direction="row" space={2} tokens={{ alignItems: 'center' }}>
|
|
9
|
-
<Spinner inline={true} show={true}
|
|
10
|
-
<Typography variant={{ size: 'small' }} accessibilityLiveRegion="polite">
|
|
11
|
-
{label}
|
|
12
|
-
</Typography>
|
|
9
|
+
<Spinner inline={true} show={true} label={label} labelPosition="right" />
|
|
13
10
|
</StackView>
|
|
14
11
|
</Box>
|
|
15
12
|
)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
en: {
|
|
3
3
|
hasResults: 'Some results are available',
|
|
4
|
-
loading: '
|
|
4
|
+
loading: 'Searching...',
|
|
5
5
|
noResults: 'No results found'
|
|
6
6
|
},
|
|
7
7
|
fr: {
|
|
8
8
|
hasResults: 'Quelques suggestions sont disponible',
|
|
9
|
-
loading: '
|
|
9
|
+
loading: 'Recherche...',
|
|
10
10
|
noResults: 'Aucun résultat trouvé'
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useState } from 'react'
|
|
1
|
+
import React, { forwardRef, useEffect, useState } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import momentPropTypes from 'react-moment-proptypes'
|
|
@@ -43,6 +43,7 @@ const getResponsiveCircleSize = (inline = false, viewport = 'md') => {
|
|
|
43
43
|
|
|
44
44
|
return responsiveCircleSize
|
|
45
45
|
}
|
|
46
|
+
|
|
46
47
|
const MonthCenterContainer = styled.div({
|
|
47
48
|
display: 'flex',
|
|
48
49
|
justifyContent: 'center'
|
|
@@ -104,6 +105,12 @@ const DatePicker = forwardRef(
|
|
|
104
105
|
const [isFocused, setIsFocused] = useState(false)
|
|
105
106
|
const [isClickedInside, setIsClickedInside] = useState(false)
|
|
106
107
|
const getCopy = useCopy({ dictionary, copy })
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (!moment(date).isSame(inputDate)) {
|
|
110
|
+
setInputDate(date)
|
|
111
|
+
setInputText(date instanceof moment ? date.format(dateFormat) : '')
|
|
112
|
+
}
|
|
113
|
+
}, [date, inputDate])
|
|
107
114
|
const onFocusChange = ({ focused }) => {
|
|
108
115
|
if (!isClickedInside) {
|
|
109
116
|
setIsFocused(focused)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { Icon,
|
|
3
|
+
import { Icon, useResponsiveProp, useThemeTokens } from '@telus-uds/components-base'
|
|
4
4
|
import NavigationItem from './NavigationItem'
|
|
5
5
|
import Listbox from '../Listbox'
|
|
6
6
|
import useOverlaidPosition from '../utils/useOverlaidPosition'
|
|
@@ -61,12 +61,11 @@ const NavigationSubMenu = ({
|
|
|
61
61
|
>
|
|
62
62
|
{({ textStyles }) => [
|
|
63
63
|
children,
|
|
64
|
-
<Spacer key={`${id}_spacer`} space={1} direction="row" />,
|
|
65
64
|
<Icon
|
|
66
65
|
key={`${id}_icon`}
|
|
67
66
|
icon={icoMenu}
|
|
68
|
-
variant={{ size: '
|
|
69
|
-
tokens={{ color: textStyles[0]?.color
|
|
67
|
+
variant={{ size: 'micro' }}
|
|
68
|
+
tokens={{ color: textStyles[0]?.color }}
|
|
70
69
|
/>
|
|
71
70
|
]}
|
|
72
71
|
</NavigationItem>
|
package/src/Spinner/Spinner.jsx
CHANGED
|
@@ -64,6 +64,7 @@ const Spinner = ({
|
|
|
64
64
|
fullScreen = false,
|
|
65
65
|
inline = false,
|
|
66
66
|
label,
|
|
67
|
+
labelPosition,
|
|
67
68
|
show = false,
|
|
68
69
|
isStatic = false,
|
|
69
70
|
tokens,
|
|
@@ -97,6 +98,7 @@ const Spinner = ({
|
|
|
97
98
|
>
|
|
98
99
|
<SpinnerContent
|
|
99
100
|
label={label}
|
|
101
|
+
labelPosition={labelPosition}
|
|
100
102
|
overlay={true}
|
|
101
103
|
size={size}
|
|
102
104
|
thickness={thickness}
|
|
@@ -115,6 +117,7 @@ const Spinner = ({
|
|
|
115
117
|
<SpinnerContainer inline={inline} aria-live="assertive" {...selectProps(rest)}>
|
|
116
118
|
<SpinnerContent
|
|
117
119
|
label={label}
|
|
120
|
+
labelPosition={labelPosition}
|
|
118
121
|
overlay={true}
|
|
119
122
|
size={size}
|
|
120
123
|
thickness={thickness}
|
|
@@ -141,6 +144,7 @@ const Spinner = ({
|
|
|
141
144
|
<SpinnerContainer {...selectProps(rest)}>
|
|
142
145
|
<SpinnerContent
|
|
143
146
|
label={label}
|
|
147
|
+
labelPosition={labelPosition}
|
|
144
148
|
size={size}
|
|
145
149
|
thickness={thickness}
|
|
146
150
|
sizeVariant={sizeVariant}
|
|
@@ -183,7 +187,11 @@ Spinner.propTypes = {
|
|
|
183
187
|
/**
|
|
184
188
|
* If true, it should render a static spinner
|
|
185
189
|
*/
|
|
186
|
-
isStatic: PropTypes.bool
|
|
190
|
+
isStatic: PropTypes.bool,
|
|
191
|
+
/**
|
|
192
|
+
* Determine where the label of the spinner should be placed, left, right, bottom or top.
|
|
193
|
+
*/
|
|
194
|
+
labelPosition: PropTypes.string
|
|
187
195
|
}
|
|
188
196
|
|
|
189
197
|
export default Spinner
|
|
@@ -27,6 +27,7 @@ const Container = styled.div(({ overlay }) => ({
|
|
|
27
27
|
|
|
28
28
|
const SpinnerContent = ({
|
|
29
29
|
label,
|
|
30
|
+
labelPosition,
|
|
30
31
|
overlay = false,
|
|
31
32
|
sizeVariant,
|
|
32
33
|
size,
|
|
@@ -34,9 +35,20 @@ const SpinnerContent = ({
|
|
|
34
35
|
isStatic,
|
|
35
36
|
...rest
|
|
36
37
|
}) => {
|
|
38
|
+
const labelMapping = {
|
|
39
|
+
top: 'column-reverse',
|
|
40
|
+
bottom: 'column',
|
|
41
|
+
left: 'row-reverse',
|
|
42
|
+
right: 'row'
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
return (
|
|
38
46
|
<Container overlay={overlay}>
|
|
39
|
-
<StackView
|
|
47
|
+
<StackView
|
|
48
|
+
space={3}
|
|
49
|
+
tokens={{ alignItems: 'center' }}
|
|
50
|
+
direction={labelMapping[labelPosition]}
|
|
51
|
+
>
|
|
40
52
|
<ActivityIndicator
|
|
41
53
|
label={label}
|
|
42
54
|
tokens={{ size, thickness }}
|
package/src/Table/Cell.jsx
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import styled, { css } from 'styled-components'
|
|
4
|
-
import { Typography, useThemeTokens } from '@telus-uds/components-base'
|
|
4
|
+
import { Typography, useThemeTokens, applyShadowToken } from '@telus-uds/components-base'
|
|
5
5
|
import { useTableContext } from './Table'
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const HEADER_TYPE = {
|
|
8
|
+
HEADING: 'heading',
|
|
9
|
+
SUBHEADING: 'subHeading',
|
|
10
|
+
ROWHEADING: 'rowHeading'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const stickyStyles = ({ cellStickyShadow, stickyBackgroundColor, type }) => css`
|
|
8
14
|
position: sticky;
|
|
9
15
|
left: 0; // needed for sticky to work
|
|
10
16
|
z-index: 2;
|
|
11
17
|
clip-path: inset(0 -8px 0 0); // use clip path to cut off the shadow rendered below
|
|
12
|
-
|
|
18
|
+
// Override default cell background with stickyBackgroundColor with an exception to subheading and heading
|
|
19
|
+
${type !== HEADER_TYPE.SUBHEADING && type !== HEADER_TYPE.HEADING
|
|
20
|
+
? `background-color: ${stickyBackgroundColor};`
|
|
21
|
+
: undefined}
|
|
13
22
|
&::before {
|
|
14
23
|
// use a pseudo element for the sticky shadow, since we already use shadows for inner cells border
|
|
15
24
|
content: '';
|
|
16
|
-
box-shadow: ${
|
|
25
|
+
box-shadow: ${cellStickyShadow};
|
|
17
26
|
position: absolute;
|
|
18
27
|
top: 0;
|
|
19
28
|
left: 0;
|
|
@@ -25,55 +34,43 @@ const stickyStyles = css`
|
|
|
25
34
|
const sharedStyles = css`
|
|
26
35
|
${({
|
|
27
36
|
isSticky,
|
|
28
|
-
cellBoxShadowColor,
|
|
29
37
|
align,
|
|
30
38
|
cellPaddingTop,
|
|
31
39
|
cellPaddingRight,
|
|
32
40
|
cellPaddingBottom,
|
|
33
41
|
cellPaddingLeft,
|
|
34
|
-
cellMinWidth
|
|
42
|
+
cellMinWidth,
|
|
43
|
+
cellBackground,
|
|
44
|
+
cellStickyShadow,
|
|
45
|
+
stickyBackgroundColor,
|
|
46
|
+
type
|
|
35
47
|
}) => css`
|
|
36
|
-
${isSticky ? stickyStyles : undefined};
|
|
37
|
-
box-shadow: inset 0 -1px 0 ${cellBoxShadowColor};
|
|
38
48
|
text-align: ${align};
|
|
39
49
|
min-width: ${cellMinWidth}px;
|
|
40
50
|
padding: ${cellPaddingTop}px ${cellPaddingRight}px ${cellPaddingBottom}px ${cellPaddingLeft}px;
|
|
51
|
+
background-color: ${cellBackground};
|
|
52
|
+
${isSticky && stickyStyles({ type, cellStickyShadow, stickyBackgroundColor })};
|
|
41
53
|
`}
|
|
42
54
|
`
|
|
43
|
-
const
|
|
44
|
-
${sharedStyles};
|
|
45
|
-
${({ cellHeadingBackground, cellHeadingBoxShadowColor }) => `
|
|
46
|
-
background-color: ${cellHeadingBackground};
|
|
47
|
-
box-shadow: inset 0 1px 0 ${cellHeadingBoxShadowColor}, inset 0 -1px 0 ${cellHeadingBoxShadowColor};`}
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
const StyledSubHeading = styled.th`
|
|
51
|
-
${sharedStyles};
|
|
52
|
-
background-color: ${({ cellSubheadingBackground }) => cellSubheadingBackground};
|
|
53
|
-
`
|
|
54
|
-
|
|
55
|
-
const StyledCell = styled.td`
|
|
56
|
-
${sharedStyles};
|
|
57
|
-
background-color: ${({ cellBackground }) => cellBackground};
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
const StyledRowHeading = styled.th`
|
|
55
|
+
const createStyledCell = (htmlElement) => styled[htmlElement]`
|
|
61
56
|
${sharedStyles};
|
|
62
|
-
|
|
57
|
+
box-shadow: ${({ cellBoxShadowColor, type }) => {
|
|
58
|
+
return type === HEADER_TYPE.HEADING
|
|
59
|
+
? `inset 0 1px 0 ${cellBoxShadowColor}, inset 0 -1px 0 ${cellBoxShadowColor}`
|
|
60
|
+
: `inset 0 1px 0 ${cellBoxShadowColor}`
|
|
61
|
+
}};
|
|
63
62
|
`
|
|
63
|
+
const StyledHeaderCell = createStyledCell('th')
|
|
64
|
+
const StyledDataCell = createStyledCell('td')
|
|
64
65
|
|
|
65
|
-
const Cell = ({ children,
|
|
66
|
-
const { text, isScrollable: isTableScrollable,
|
|
66
|
+
const Cell = ({ children, isFirstInRow, align = 'left', tokens: cellTokens, type }) => {
|
|
67
|
+
const { text, isScrollable: isTableScrollable, tokens: tableTokens, spacing } = useTableContext()
|
|
67
68
|
const themeTokens = { ...tableTokens, ...cellTokens }
|
|
68
69
|
|
|
69
70
|
const {
|
|
70
71
|
cellMinWidth,
|
|
71
|
-
cellHeadingBackground,
|
|
72
|
-
cellHeadingBoxShadowColor,
|
|
73
72
|
cellBoxShadowColor,
|
|
74
|
-
cellSubheadingBackground,
|
|
75
73
|
cellBackground,
|
|
76
|
-
cellRowHeadingBackground,
|
|
77
74
|
cellStickyShadow,
|
|
78
75
|
cellPaddingTop,
|
|
79
76
|
cellPaddingRight,
|
|
@@ -81,84 +78,67 @@ const Cell = ({ children, type = 'default', isFirstInRow, align = 'left', tokens
|
|
|
81
78
|
cellPaddingBottom,
|
|
82
79
|
fontName,
|
|
83
80
|
fontWeight,
|
|
84
|
-
fontSize
|
|
85
|
-
|
|
81
|
+
fontSize,
|
|
82
|
+
lineHeight,
|
|
83
|
+
stickyBackgroundColor
|
|
84
|
+
} = useThemeTokens('Table', themeTokens, { spacing, type, text })
|
|
86
85
|
|
|
87
86
|
const sharedProps = {
|
|
88
87
|
align,
|
|
89
88
|
isSticky: isTableScrollable && isFirstInRow,
|
|
89
|
+
cellBackground,
|
|
90
90
|
cellMinWidth,
|
|
91
|
-
cellStickyShadow,
|
|
91
|
+
cellStickyShadow: applyShadowToken(cellStickyShadow).boxShadow,
|
|
92
92
|
cellPaddingTop,
|
|
93
93
|
cellPaddingRight,
|
|
94
94
|
cellPaddingLeft,
|
|
95
95
|
cellPaddingBottom,
|
|
96
|
+
stickyBackgroundColor,
|
|
96
97
|
cellBoxShadowColor
|
|
97
98
|
}
|
|
98
|
-
|
|
99
99
|
const typographyTokens = {
|
|
100
100
|
fontName,
|
|
101
101
|
fontWeight,
|
|
102
|
-
fontSize
|
|
102
|
+
fontSize,
|
|
103
|
+
lineHeight
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
switch (type) {
|
|
106
|
-
case
|
|
107
|
+
case HEADER_TYPE.HEADING:
|
|
107
108
|
return (
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
cellHeadingBoxShadowColor={cellHeadingBoxShadowColor}
|
|
112
|
-
{...sharedProps}
|
|
113
|
-
>
|
|
114
|
-
<Typography tokens={typographyTokens} variant={{ size: 'h4' }}>
|
|
115
|
-
{children}
|
|
116
|
-
</Typography>
|
|
117
|
-
</StyledHeading>
|
|
109
|
+
<StyledHeaderCell scope="col" {...sharedProps} type={type}>
|
|
110
|
+
<Typography tokens={typographyTokens}>{children}</Typography>
|
|
111
|
+
</StyledHeaderCell>
|
|
118
112
|
)
|
|
119
|
-
|
|
113
|
+
|
|
114
|
+
case HEADER_TYPE.SUBHEADING:
|
|
120
115
|
return (
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{...sharedProps}
|
|
125
|
-
>
|
|
126
|
-
<Typography tokens={typographyTokens} variant={{ size: 'h5' }}>
|
|
127
|
-
{children}
|
|
128
|
-
</Typography>
|
|
129
|
-
</StyledSubHeading>
|
|
116
|
+
<StyledHeaderCell scope="col" {...sharedProps} type={type}>
|
|
117
|
+
<Typography tokens={typographyTokens}>{children}</Typography>
|
|
118
|
+
</StyledHeaderCell>
|
|
130
119
|
)
|
|
131
|
-
|
|
120
|
+
|
|
121
|
+
case HEADER_TYPE.ROWHEADING:
|
|
132
122
|
return (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
{...sharedProps}
|
|
137
|
-
>
|
|
138
|
-
<Typography tokens={typographyTokens} variant={{ size: text === 'small' ? 'h5' : 'h4' }}>
|
|
139
|
-
{children}
|
|
140
|
-
</Typography>
|
|
141
|
-
</StyledRowHeading>
|
|
123
|
+
<StyledHeaderCell scope="row" {...sharedProps} type={type}>
|
|
124
|
+
<Typography tokens={typographyTokens}>{children}</Typography>
|
|
125
|
+
</StyledHeaderCell>
|
|
142
126
|
)
|
|
143
127
|
|
|
144
128
|
default:
|
|
145
129
|
return (
|
|
146
|
-
<
|
|
147
|
-
<Typography tokens={
|
|
148
|
-
|
|
149
|
-
</Typography>
|
|
150
|
-
</StyledCell>
|
|
130
|
+
<StyledDataCell {...sharedProps}>
|
|
131
|
+
<Typography tokens={typographyTokens}>{children}</Typography>
|
|
132
|
+
</StyledDataCell>
|
|
151
133
|
)
|
|
152
134
|
}
|
|
153
135
|
}
|
|
154
136
|
|
|
155
137
|
Cell.propTypes = {
|
|
138
|
+
type: PropTypes.oneOf(['default', 'heading', 'subHeading', 'rowHeading']),
|
|
156
139
|
tokens: PropTypes.object,
|
|
157
140
|
children: PropTypes.node,
|
|
158
|
-
|
|
159
|
-
* Defines the visual styles of a cell, and whether it should be a `td` or `th` element
|
|
160
|
-
*/
|
|
161
|
-
type: PropTypes.oneOf(['default', 'heading', 'subHeading', 'rowHeading']),
|
|
141
|
+
|
|
162
142
|
/**
|
|
163
143
|
* @ignore
|
|
164
144
|
* Used internally for making the first column sticky
|
package/src/Table/Header.jsx
CHANGED
|
@@ -5,7 +5,12 @@ import Row from './Row'
|
|
|
5
5
|
const Header = ({ children }) => {
|
|
6
6
|
return (
|
|
7
7
|
<thead>
|
|
8
|
-
<Row>
|
|
8
|
+
<Row>
|
|
9
|
+
{React.Children.map(children, (child) =>
|
|
10
|
+
// TO DO: pass type as a variant instead of prop
|
|
11
|
+
cloneElement(child, { type: 'heading' })
|
|
12
|
+
)}
|
|
13
|
+
</Row>
|
|
9
14
|
</thead>
|
|
10
15
|
)
|
|
11
16
|
}
|
package/src/Table/SubHeading.jsx
CHANGED
|
@@ -5,7 +5,10 @@ import Row from './Row'
|
|
|
5
5
|
const Header = ({ children }) => {
|
|
6
6
|
return (
|
|
7
7
|
<Row>
|
|
8
|
-
{React.Children.map(children, (child) =>
|
|
8
|
+
{React.Children.map(children, (child) =>
|
|
9
|
+
// TO DO: pass type as a variant instead of prop
|
|
10
|
+
cloneElement(child, { type: 'subHeading' })
|
|
11
|
+
)}
|
|
9
12
|
</Row>
|
|
10
13
|
)
|
|
11
14
|
}
|