@telus-uds/components-base 1.50.0 → 1.51.1
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 +160 -46
- package/lib/A11yText/index.js +8 -0
- package/lib/Divider/Divider.js +4 -0
- package/lib/IconButton/IconButton.js +16 -0
- package/lib/Link/ChevronLink.js +4 -0
- package/lib/Link/LinkBase.js +1 -1
- package/lib/Modal/Modal.js +16 -0
- package/lib/MultiSelectFilter/ModalOverlay.js +24 -8
- package/lib/MultiSelectFilter/MultiSelectFilter.js +154 -21
- package/lib/Pagination/PageButton.js +12 -0
- package/lib/Pagination/Pagination.js +12 -0
- package/lib/QuickLinks/QuickLinks.js +12 -0
- package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +62 -41
- package/lib/Responsive/Responsive.js +7 -0
- package/lib/Select/Group.js +4 -0
- package/lib/Select/Group.native.js +4 -0
- package/lib/Select/Item.js +4 -0
- package/lib/SideNav/ItemsGroup.js +4 -0
- package/lib/SideNav/SideNav.js +8 -0
- package/lib/StepTracker/Step.js +35 -14
- package/lib/StepTracker/StepTracker.js +21 -2
- package/lib/StepTracker/dictionary.js +24 -4
- package/lib/Tabs/Tabs.js +20 -0
- package/lib-module/A11yText/index.js +8 -0
- package/lib-module/Divider/Divider.js +4 -0
- package/lib-module/IconButton/IconButton.js +16 -0
- package/lib-module/Link/ChevronLink.js +4 -0
- package/lib-module/Link/LinkBase.js +1 -1
- package/lib-module/Modal/Modal.js +16 -0
- package/lib-module/MultiSelectFilter/ModalOverlay.js +25 -9
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +154 -23
- package/lib-module/Pagination/PageButton.js +12 -0
- package/lib-module/Pagination/Pagination.js +12 -0
- package/lib-module/QuickLinks/QuickLinks.js +12 -0
- package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +64 -43
- package/lib-module/Responsive/Responsive.js +7 -0
- package/lib-module/Select/Group.js +4 -0
- package/lib-module/Select/Group.native.js +4 -0
- package/lib-module/Select/Item.js +4 -0
- package/lib-module/SideNav/ItemsGroup.js +4 -0
- package/lib-module/SideNav/SideNav.js +8 -0
- package/lib-module/StepTracker/Step.js +35 -14
- package/lib-module/StepTracker/StepTracker.js +21 -2
- package/lib-module/StepTracker/dictionary.js +24 -4
- package/lib-module/Tabs/Tabs.js +20 -0
- package/package.json +2 -2
- package/src/A11yText/index.jsx +6 -0
- package/src/Divider/Divider.jsx +3 -0
- package/src/IconButton/IconButton.jsx +12 -0
- package/src/Link/ChevronLink.jsx +3 -0
- package/src/Link/LinkBase.jsx +3 -1
- package/src/Modal/Modal.jsx +12 -0
- package/src/MultiSelectFilter/ModalOverlay.jsx +30 -6
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +142 -20
- package/src/Pagination/PageButton.jsx +9 -0
- package/src/Pagination/Pagination.jsx +9 -0
- package/src/QuickLinks/QuickLinks.jsx +9 -0
- package/src/QuickLinksFeature/QuickLinksFeatureItem.jsx +42 -35
- package/src/Responsive/Responsive.jsx +6 -0
- package/src/Select/Group.jsx +3 -0
- package/src/Select/Group.native.jsx +3 -0
- package/src/Select/Item.jsx +3 -0
- package/src/SideNav/ItemsGroup.jsx +3 -0
- package/src/SideNav/SideNav.jsx +6 -0
- package/src/StepTracker/Step.jsx +34 -10
- package/src/StepTracker/StepTracker.jsx +23 -2
- package/src/StepTracker/dictionary.js +24 -4
- package/src/Tabs/Tabs.jsx +15 -0
- package/src/Typography/Typography.jsx +1 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
3
|
+
import { useThemeTokens, useThemeTokensCallback, applyTextStyles } from '../ThemeProvider';
|
|
4
4
|
import { containUniqueFields, getTokensPropType, getPressHandlersWithArgs, selectTokens, useOverlaidPosition, useCopy, useMultipleInputValues, useResponsiveProp, variantProp } from '../utils';
|
|
5
5
|
import dictionary from './dictionary';
|
|
6
|
+
import { useViewport } from '../ViewportProvider';
|
|
6
7
|
import Box from '../Box';
|
|
7
8
|
import { Button, ButtonDropdown } from '../Button';
|
|
8
9
|
import { CheckboxGroup } from '../Checkbox';
|
|
@@ -13,6 +14,7 @@ import StackView from '../StackView';
|
|
|
13
14
|
import Typography from '../Typography';
|
|
14
15
|
import { TextButton } from '../Link';
|
|
15
16
|
import ModalOverlay from './ModalOverlay';
|
|
17
|
+
import Modal from '../Modal';
|
|
16
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
19
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -54,6 +56,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
54
56
|
tokens,
|
|
55
57
|
items = [],
|
|
56
58
|
values,
|
|
59
|
+
maxHeight = false,
|
|
57
60
|
initialValues,
|
|
58
61
|
maxValues,
|
|
59
62
|
onChange,
|
|
@@ -63,6 +66,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
63
66
|
rowLimit = 12,
|
|
64
67
|
...rest
|
|
65
68
|
} = _ref3;
|
|
69
|
+
const viewport = useViewport();
|
|
66
70
|
const {
|
|
67
71
|
currentValues,
|
|
68
72
|
setValues
|
|
@@ -73,6 +77,9 @@ const MultiSelectFilter = _ref3 => {
|
|
|
73
77
|
onChange,
|
|
74
78
|
readOnly
|
|
75
79
|
});
|
|
80
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
81
|
+
const [checkedIds, setCheckedIds] = useState(currentValues ?? []);
|
|
82
|
+
const [maxWidth, setMaxWidth] = useState(false);
|
|
76
83
|
const themeTokens = useThemeTokens('ButtonDropdown', tokens, variant);
|
|
77
84
|
const getItemTokens = useThemeTokensCallback('ButtonDropdown', tokens, variant);
|
|
78
85
|
|
|
@@ -82,10 +89,34 @@ const MultiSelectFilter = _ref3 => {
|
|
|
82
89
|
dictionary,
|
|
83
90
|
copy
|
|
84
91
|
});
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
92
|
+
const colSizeNotMobile = items.length > rowLimit ? 2 : 1;
|
|
93
|
+
const colSize = viewport !== 'xs' ? colSizeNotMobile : 1;
|
|
94
|
+
const itemsLengthNotMobile = items.length > 24 ? items.length / 2 : rowLimit;
|
|
88
95
|
const isSelected = currentValues.length > 0;
|
|
96
|
+
const rowLength = viewport !== 'xs' ? itemsLengthNotMobile : items.length;
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (colSize === 1) return setMaxWidth(false);
|
|
99
|
+
return colSize === 2 && setMaxWidth(true);
|
|
100
|
+
}, [colSize]);
|
|
101
|
+
const {
|
|
102
|
+
headerFontColor,
|
|
103
|
+
headerFontSize,
|
|
104
|
+
buttonDirection,
|
|
105
|
+
headerFontWeight,
|
|
106
|
+
headerLineHeight,
|
|
107
|
+
subHeaderFontWeight,
|
|
108
|
+
subHeaderFontSize,
|
|
109
|
+
maxHeightSize,
|
|
110
|
+
maxWidthSize,
|
|
111
|
+
subHeaderLineHeight,
|
|
112
|
+
minHeight,
|
|
113
|
+
minWidth
|
|
114
|
+
} = useThemeTokens('MultiSelectFilter', tokens, { ...variant,
|
|
115
|
+
maxHeight,
|
|
116
|
+
maxWidth
|
|
117
|
+
}, {
|
|
118
|
+
viewport
|
|
119
|
+
});
|
|
89
120
|
const uniqueFields = ['id', 'label'];
|
|
90
121
|
|
|
91
122
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
@@ -109,6 +140,11 @@ const MultiSelectFilter = _ref3 => {
|
|
|
109
140
|
setIsOpen(false);
|
|
110
141
|
};
|
|
111
142
|
|
|
143
|
+
const onClear = () => {
|
|
144
|
+
setCheckedIds(() => []);
|
|
145
|
+
onApply([]);
|
|
146
|
+
};
|
|
147
|
+
|
|
112
148
|
const {
|
|
113
149
|
align,
|
|
114
150
|
offsets
|
|
@@ -116,9 +152,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
116
152
|
xs: {
|
|
117
153
|
align: {
|
|
118
154
|
top: 'top',
|
|
119
|
-
left: 'left'
|
|
120
|
-
bottom: 'bottom',
|
|
121
|
-
right: 'right'
|
|
155
|
+
left: 'left'
|
|
122
156
|
}
|
|
123
157
|
},
|
|
124
158
|
sm: {
|
|
@@ -131,6 +165,16 @@ const MultiSelectFilter = _ref3 => {
|
|
|
131
165
|
}
|
|
132
166
|
}
|
|
133
167
|
});
|
|
168
|
+
const headerStyles = applyTextStyles({
|
|
169
|
+
fontSize: headerFontSize,
|
|
170
|
+
fontWeight: headerFontWeight,
|
|
171
|
+
fontColor: headerFontColor
|
|
172
|
+
});
|
|
173
|
+
const subeHeaderStyles = applyTextStyles({
|
|
174
|
+
fontSize: subHeaderFontSize,
|
|
175
|
+
fontWeight: subHeaderFontWeight,
|
|
176
|
+
fontColor: selectSubTitleTokens(themeTokens)
|
|
177
|
+
});
|
|
134
178
|
const {
|
|
135
179
|
overlaidPosition,
|
|
136
180
|
onTargetLayout,
|
|
@@ -151,20 +195,96 @@ const MultiSelectFilter = _ref3 => {
|
|
|
151
195
|
onChange: handleChange,
|
|
152
196
|
tokens: getButtonTokens,
|
|
153
197
|
inactive: inactive
|
|
154
|
-
}, id), isOpen && /*#__PURE__*/_jsxs(
|
|
198
|
+
}, id), isOpen && viewport === 'xs' && /*#__PURE__*/_jsxs(Modal, {
|
|
199
|
+
isOpen: isOpen,
|
|
200
|
+
onClose: () => setIsOpen(false),
|
|
201
|
+
children: [/*#__PURE__*/_jsx(Row, {
|
|
202
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
203
|
+
tokens: { ...headerStyles,
|
|
204
|
+
lineHeight: headerLineHeight
|
|
205
|
+
},
|
|
206
|
+
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
207
|
+
})
|
|
208
|
+
}), subtitle && /*#__PURE__*/_jsxs(_Fragment, {
|
|
209
|
+
children: [/*#__PURE__*/_jsx(Spacer, {
|
|
210
|
+
space: 5
|
|
211
|
+
}), /*#__PURE__*/_jsx(Row, {
|
|
212
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
213
|
+
tokens: { ...subeHeaderStyles,
|
|
214
|
+
lineHeight: subHeaderLineHeight
|
|
215
|
+
},
|
|
216
|
+
children: subtitle
|
|
217
|
+
})
|
|
218
|
+
})]
|
|
219
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
220
|
+
space: 4
|
|
221
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
222
|
+
scroll: true,
|
|
223
|
+
children: /*#__PURE__*/_jsx(Row, {
|
|
224
|
+
distribute: "between",
|
|
225
|
+
children: [...Array(colSize).keys()].map(i => /*#__PURE__*/_jsxs(Col, {
|
|
226
|
+
xs: 12 / colSize,
|
|
227
|
+
children: [/*#__PURE__*/_jsx(CheckboxGroup, {
|
|
228
|
+
items: items.slice(i * rowLength, (i + 1) * rowLength),
|
|
229
|
+
checkedIds: checkedIds,
|
|
230
|
+
onChange: e => setCheckedIds(e, i)
|
|
231
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
232
|
+
size: 4
|
|
233
|
+
})]
|
|
234
|
+
}, i))
|
|
235
|
+
})
|
|
236
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
|
237
|
+
variant: selectDividerToknes({ ...themeTokens,
|
|
238
|
+
width: 'full'
|
|
239
|
+
}),
|
|
240
|
+
space: 4
|
|
241
|
+
}), /*#__PURE__*/_jsx(Row, {
|
|
242
|
+
horizontalAlign: buttonDirection === 'column' ? 'center' : 'start',
|
|
243
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
244
|
+
direction: buttonDirection,
|
|
245
|
+
space: 3,
|
|
246
|
+
tokens: {
|
|
247
|
+
alignItems: 'center',
|
|
248
|
+
...(viewport === 'xs' && {
|
|
249
|
+
flexGrow: 1
|
|
250
|
+
})
|
|
251
|
+
},
|
|
252
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
253
|
+
onPress: () => onApply(checkedIds),
|
|
254
|
+
variant: {
|
|
255
|
+
size: 'small',
|
|
256
|
+
priority: 'high',
|
|
257
|
+
...(viewport === 'xs' && {
|
|
258
|
+
width: 'full'
|
|
259
|
+
})
|
|
260
|
+
},
|
|
261
|
+
children: getCopy('applyButtonLabel')
|
|
262
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
263
|
+
children: /*#__PURE__*/_jsx(TextButton, {
|
|
264
|
+
onPress: () => onClear(),
|
|
265
|
+
children: getCopy('clearButtonLabel')
|
|
266
|
+
})
|
|
267
|
+
})]
|
|
268
|
+
})
|
|
269
|
+
})]
|
|
270
|
+
}), isOpen && viewport !== 'xs' && /*#__PURE__*/_jsxs(ModalOverlay, {
|
|
155
271
|
overlaidPosition: overlaidPosition,
|
|
156
|
-
variant: {
|
|
157
|
-
width: colSize > 1 ? 'size576' : 's'
|
|
158
|
-
},
|
|
159
272
|
onClose: () => setIsOpen(false),
|
|
160
|
-
|
|
273
|
+
maxHeight: maxHeight,
|
|
274
|
+
maxHeightSize: maxHeightSize,
|
|
275
|
+
maxWidthSize: maxWidthSize,
|
|
276
|
+
minHeight: minHeight,
|
|
277
|
+
minWidth: minWidth,
|
|
278
|
+
tokens: { ...tokens,
|
|
279
|
+
maxWidth
|
|
280
|
+
},
|
|
161
281
|
copy: copy,
|
|
162
282
|
isReady: isReady,
|
|
163
283
|
onLayout: onTargetLayout,
|
|
164
284
|
children: [/*#__PURE__*/_jsx(Row, {
|
|
165
285
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
166
|
-
|
|
167
|
-
|
|
286
|
+
tokens: { ...headerStyles,
|
|
287
|
+
lineHeight: headerLineHeight
|
|
168
288
|
},
|
|
169
289
|
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
170
290
|
})
|
|
@@ -173,10 +293,9 @@ const MultiSelectFilter = _ref3 => {
|
|
|
173
293
|
space: 5
|
|
174
294
|
}), /*#__PURE__*/_jsx(Row, {
|
|
175
295
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
176
|
-
|
|
177
|
-
|
|
296
|
+
tokens: { ...subeHeaderStyles,
|
|
297
|
+
lineHeight: subHeaderLineHeight
|
|
178
298
|
},
|
|
179
|
-
tokens: selectSubTitleTokens(themeTokens),
|
|
180
299
|
children: subtitle
|
|
181
300
|
})
|
|
182
301
|
})]
|
|
@@ -189,7 +308,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
189
308
|
children: [...Array(colSize).keys()].map(i => /*#__PURE__*/_jsxs(Col, {
|
|
190
309
|
xs: 12 / colSize,
|
|
191
310
|
children: [/*#__PURE__*/_jsx(CheckboxGroup, {
|
|
192
|
-
items: items.slice(i *
|
|
311
|
+
items: items.slice(i * rowLength, (i + 1) * rowLength),
|
|
193
312
|
checkedIds: checkedIds,
|
|
194
313
|
onChange: e => setCheckedIds(e, i)
|
|
195
314
|
}), /*#__PURE__*/_jsx(Spacer, {
|
|
@@ -203,22 +322,29 @@ const MultiSelectFilter = _ref3 => {
|
|
|
203
322
|
}),
|
|
204
323
|
space: 4
|
|
205
324
|
}), /*#__PURE__*/_jsx(Row, {
|
|
325
|
+
horizontalAlign: buttonDirection === 'column' ? 'center' : 'start',
|
|
206
326
|
children: /*#__PURE__*/_jsxs(StackView, {
|
|
207
|
-
direction:
|
|
327
|
+
direction: buttonDirection,
|
|
208
328
|
space: 3,
|
|
209
329
|
tokens: {
|
|
210
|
-
alignItems: 'center'
|
|
330
|
+
alignItems: 'center',
|
|
331
|
+
...(viewport === 'xs' && {
|
|
332
|
+
flexGrow: 1
|
|
333
|
+
})
|
|
211
334
|
},
|
|
212
335
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
213
336
|
onPress: () => onApply(checkedIds),
|
|
214
337
|
variant: {
|
|
215
338
|
size: 'small',
|
|
216
|
-
priority: 'high'
|
|
339
|
+
priority: 'high',
|
|
340
|
+
...(viewport === 'xs' && {
|
|
341
|
+
width: 'full'
|
|
342
|
+
})
|
|
217
343
|
},
|
|
218
344
|
children: getCopy('applyButtonLabel')
|
|
219
345
|
}), /*#__PURE__*/_jsx(Box, {
|
|
220
346
|
children: /*#__PURE__*/_jsx(TextButton, {
|
|
221
|
-
onPress: () =>
|
|
347
|
+
onPress: () => onClear(),
|
|
222
348
|
children: getCopy('clearButtonLabel')
|
|
223
349
|
})
|
|
224
350
|
})]
|
|
@@ -292,6 +418,11 @@ MultiSelectFilter.propTypes = {
|
|
|
292
418
|
*/
|
|
293
419
|
maxValues: PropTypes.number,
|
|
294
420
|
|
|
421
|
+
/**
|
|
422
|
+
* If provided sets maxHeight to be active
|
|
423
|
+
*/
|
|
424
|
+
maxHeight: PropTypes.bool,
|
|
425
|
+
|
|
295
426
|
/**
|
|
296
427
|
* If provided, this function is called when the current selection is changed
|
|
297
428
|
* and is passed an array of the `id`s of all currently selected `items`.
|
|
@@ -57,8 +57,20 @@ const PageButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
57
57
|
});
|
|
58
58
|
PageButton.displayName = 'PageButton';
|
|
59
59
|
PageButton.propTypes = { ...linkProps.types,
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* To set custom label for the button
|
|
63
|
+
*/
|
|
60
64
|
label: PropTypes.string,
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* To set `PageButton` to active state
|
|
68
|
+
*/
|
|
61
69
|
isActive: PropTypes.bool,
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* To change the language for labels
|
|
73
|
+
*/
|
|
62
74
|
copy: copyPropTypes,
|
|
63
75
|
variant: variantProp.propType,
|
|
64
76
|
tokens: getTokensPropType('PaginationPageButton')
|
|
@@ -183,10 +183,22 @@ Pagination.PageButton = PageButton;
|
|
|
183
183
|
Pagination.propTypes = { ...selectedSystemPropTypes,
|
|
184
184
|
...withLinkRouter.propTypes,
|
|
185
185
|
children: componentPropType('PageButton'),
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* To change the language for labels
|
|
189
|
+
*/
|
|
186
190
|
copy: copyPropTypes,
|
|
187
191
|
variant: variantProp.propType,
|
|
188
192
|
tokens: getTokensPropType('Pagination'),
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* When passed as `{{ compact: true }}`, `Pagination` does not render labels along side buttons
|
|
196
|
+
*/
|
|
189
197
|
sideButtonVariant: variantProp.propType,
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Custom tokens for `PaginationSideButton`
|
|
201
|
+
*/
|
|
190
202
|
sideButtonTokens: getTokensPropType('PaginationSideButton')
|
|
191
203
|
};
|
|
192
204
|
const staticStyles = StyleSheet.create({
|
|
@@ -62,8 +62,20 @@ const QuickLinks = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
62
62
|
QuickLinks.displayName = 'QuickLinks';
|
|
63
63
|
QuickLinks.propTypes = {
|
|
64
64
|
tokens: getTokensPropType('QuickLinks'),
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Custom tokens override for `Card`
|
|
68
|
+
*/
|
|
65
69
|
cardTokens: getTokensPropType('Card'),
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Custom tokens override for `QuickLinksList`
|
|
73
|
+
*/
|
|
66
74
|
listTokens: getTokensPropType('QuickLinksList'),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The HTML tag to render the list as
|
|
78
|
+
*/
|
|
67
79
|
tag: PropTypes.string,
|
|
68
80
|
variant: variantProp.propType,
|
|
69
81
|
children: PropTypes.node
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Image from "react-native-web/dist/exports/Image";
|
|
4
4
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
@@ -6,7 +6,7 @@ import Text from "react-native-web/dist/exports/Text";
|
|
|
6
6
|
import View from "react-native-web/dist/exports/View";
|
|
7
7
|
import { getTokensPropType, variantProp, withLinkRouter, a11yProps, linkProps, selectSystemProps } from '../utils';
|
|
8
8
|
import { useViewport } from '../ViewportProvider';
|
|
9
|
-
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
9
|
+
import { applyTextStyles, useThemeTokensCallback } from '../ThemeProvider';
|
|
10
10
|
import { Link } from '../Link';
|
|
11
11
|
import { StackWrap } from '../StackView'; // pass through and type relevant system props - add more sets for interactive components
|
|
12
12
|
|
|
@@ -32,6 +32,7 @@ const selectContainerStyle = _ref => {
|
|
|
32
32
|
} = _ref;
|
|
33
33
|
return {
|
|
34
34
|
textAlign,
|
|
35
|
+
outline: 'red',
|
|
35
36
|
width: contentMaxDimension,
|
|
36
37
|
overflow: 'hidden'
|
|
37
38
|
};
|
|
@@ -43,6 +44,15 @@ const selectImageContainerStyle = contentMaxDimension => ({
|
|
|
43
44
|
justifyContent: 'center',
|
|
44
45
|
alignItems: 'center'
|
|
45
46
|
});
|
|
47
|
+
|
|
48
|
+
const selectLinkToken = _ref2 => {
|
|
49
|
+
let {
|
|
50
|
+
outerBorderColor
|
|
51
|
+
} = _ref2;
|
|
52
|
+
return {
|
|
53
|
+
outerBorderColor
|
|
54
|
+
};
|
|
55
|
+
};
|
|
46
56
|
/**
|
|
47
57
|
* Component export along with QuickLinksFeature to be used as children
|
|
48
58
|
*
|
|
@@ -50,7 +60,7 @@ const selectImageContainerStyle = contentMaxDimension => ({
|
|
|
50
60
|
*/
|
|
51
61
|
|
|
52
62
|
|
|
53
|
-
const QuickLinksFeatureItem = /*#__PURE__*/forwardRef((
|
|
63
|
+
const QuickLinksFeatureItem = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
54
64
|
let {
|
|
55
65
|
tokens,
|
|
56
66
|
variant,
|
|
@@ -58,52 +68,63 @@ const QuickLinksFeatureItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
58
68
|
imageAccessibilityLabel,
|
|
59
69
|
imageSource,
|
|
60
70
|
...rest
|
|
61
|
-
} =
|
|
71
|
+
} = _ref3;
|
|
62
72
|
const viewport = useViewport();
|
|
63
73
|
const getTokens = useThemeTokensCallback('QuickLinksFeatureItem', tokens, variant);
|
|
64
|
-
const [hover, setHover] = useState(false);
|
|
65
|
-
const {
|
|
66
|
-
contentDirection,
|
|
67
|
-
contentSpace,
|
|
68
|
-
contentAlignItems,
|
|
69
|
-
contentMaxDimension,
|
|
70
|
-
imageDimension,
|
|
71
|
-
textAlign
|
|
72
|
-
} = getTokens({
|
|
73
|
-
viewport,
|
|
74
|
-
hover
|
|
75
|
-
});
|
|
76
74
|
return /*#__PURE__*/_jsx(Link, {
|
|
77
75
|
ref: ref,
|
|
78
|
-
tokens: state => {
|
|
79
|
-
setHover(state.hover);
|
|
80
|
-
return getTokens(state);
|
|
81
|
-
},
|
|
82
76
|
...selectProps(rest),
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
tokens: state => selectLinkToken(getTokens(state)),
|
|
78
|
+
children: _ref4 => {
|
|
79
|
+
let {
|
|
80
|
+
hovered: hover,
|
|
81
|
+
pressed,
|
|
82
|
+
focused: focus
|
|
83
|
+
} = _ref4;
|
|
84
|
+
const {
|
|
85
|
+
contentDirection,
|
|
86
|
+
contentSpace,
|
|
87
|
+
contentAlignItems,
|
|
85
88
|
contentMaxDimension,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
89
|
+
imageDimension,
|
|
90
|
+
textLine,
|
|
91
|
+
gap,
|
|
92
|
+
...themeTokens
|
|
93
|
+
} = getTokens({
|
|
94
|
+
viewport,
|
|
95
|
+
hover,
|
|
96
|
+
pressed,
|
|
97
|
+
focus
|
|
98
|
+
});
|
|
99
|
+
const textStyle = { ...applyTextStyles(themeTokens),
|
|
100
|
+
textDecorationLine: textLine
|
|
101
|
+
};
|
|
102
|
+
return /*#__PURE__*/_jsx(View, {
|
|
103
|
+
style: selectContainerStyle({ ...themeTokens,
|
|
104
|
+
contentMaxDimension
|
|
105
|
+
}),
|
|
106
|
+
children: /*#__PURE__*/_jsxs(StackWrap, {
|
|
107
|
+
direction: contentDirection,
|
|
108
|
+
space: contentSpace,
|
|
109
|
+
gap: gap,
|
|
110
|
+
tokens: {
|
|
111
|
+
alignItems: contentAlignItems
|
|
112
|
+
},
|
|
113
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
114
|
+
style: selectImageContainerStyle(contentMaxDimension),
|
|
115
|
+
children: /*#__PURE__*/_jsx(Image, {
|
|
116
|
+
accessibilityIgnoresInvertColors: true,
|
|
117
|
+
imageAccessibilityLabel: imageAccessibilityLabel,
|
|
118
|
+
source: imageSource,
|
|
119
|
+
style: selectImageStyle(imageDimension)
|
|
120
|
+
})
|
|
121
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
122
|
+
style: textStyle,
|
|
123
|
+
children: children
|
|
124
|
+
})]
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
}
|
|
107
128
|
});
|
|
108
129
|
});
|
|
109
130
|
QuickLinksFeatureItem.displayName = 'QuickLinksFeatureItem';
|
|
@@ -38,7 +38,14 @@ const Responsive = _ref => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
Responsive.propTypes = {
|
|
41
|
+
/**
|
|
42
|
+
* To hide children of `Responsive` if the current viewport is smaller than `min`
|
|
43
|
+
*/
|
|
41
44
|
min: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* To hide children of `Responsive` if the current viewport is larger than `max`
|
|
48
|
+
*/
|
|
42
49
|
max: PropTypes.oneOf(['sm', 'md', 'lg', 'xl']),
|
|
43
50
|
children: PropTypes.node.isRequired
|
|
44
51
|
};
|
|
@@ -122,6 +122,10 @@ ItemsGroup.propTypes = {
|
|
|
122
122
|
isActive: PropTypes.bool,
|
|
123
123
|
variant: variantProp.propType,
|
|
124
124
|
tokens: getTokensPropType('SideNavItemsGroup'),
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Custom tokens for `SideNav.Item`
|
|
128
|
+
*/
|
|
125
129
|
itemTokens: getTokensPropType('SideNavItem')
|
|
126
130
|
};
|
|
127
131
|
export default ItemsGroup;
|
|
@@ -128,7 +128,15 @@ SideNav.propTypes = { ...selectedSystemPropTypes,
|
|
|
128
128
|
accordion: PropTypes.bool,
|
|
129
129
|
variant: variantProp.propType,
|
|
130
130
|
tokens: getTokensPropType('SideNav'),
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Custom tokens for `SideNav.Item`
|
|
134
|
+
*/
|
|
131
135
|
itemTokens: getTokensPropType('SideNavItem'),
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Custom tokens for `SideNavItemsGroup`
|
|
139
|
+
*/
|
|
132
140
|
groupTokens: getTokensPropType('SideNavItemsGroup')
|
|
133
141
|
};
|
|
134
142
|
SideNav.Item = Item;
|