@telus-uds/components-base 1.19.0 → 1.19.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 +2 -2
- package/lib/ActivityIndicator/Spinner.js +7 -7
- package/lib/ActivityIndicator/Spinner.native.js +2 -2
- package/lib/BaseProvider/HydrationContext.js +1 -1
- package/lib/BaseProvider/TamaguiProvider.js +30 -0
- package/lib/Button/ButtonBase.js +2 -2
- package/lib/Button/ButtonDropdown.js +207 -0
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Carousel/Carousel.js +2 -4
- package/lib/Carousel/CarouselContext.js +1 -1
- package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib/Carousel/CarouselThumbnail.js +2 -2
- package/lib/Checkbox/Checkbox.js +1 -1
- package/lib/Checkbox/CheckboxGroup.js +2 -2
- package/lib/Divider/Divider.js +2 -2
- package/lib/FlexGrid/Col/Col.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/MultiSelectFilter/ModalOverlay.js +136 -0
- package/lib/MultiSelectFilter/MultiSelectFilter.js +314 -0
- package/lib/MultiSelectFilter/dictionary.js +19 -0
- package/lib/MultiSelectFilter/index.js +13 -0
- package/lib/Pagination/PageButton.js +2 -2
- package/lib/Pagination/Pagination.js +3 -5
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/ProgressBar.js +3 -3
- package/lib/Progress/ProgressBarBackground.js +3 -3
- package/lib/QuickLinksFeature/QuickLinksFeature.js +91 -0
- package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +157 -0
- package/lib/QuickLinksFeature/index.js +16 -0
- package/lib/Radio/Radio.js +2 -2
- package/lib/Radio/RadioGroup.js +2 -2
- package/lib/RadioCard/RadioCard.js +1 -1
- package/lib/RadioCard/RadioCardGroup.js +2 -2
- package/lib/Search/Search.js +1 -1
- package/lib/Select/constants.js +15 -0
- package/lib/SideNav/SideNav.js +2 -2
- package/lib/Skeleton/Skeleton.js +1 -1
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/StackView/StackWrap.js +1 -3
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/Tabs/Tabs.js +2 -4
- package/lib/Tags/Tags.js +1 -1
- package/lib/TextInput/dictionary.js +19 -0
- package/lib/ThemeProvider/utils/styles.js +3 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib/Timeline/Timeline.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib/Tooltip/Backdrop.js +10 -2
- package/lib/Tooltip/Tooltip.native.js +357 -0
- package/lib/Tooltip/shared.js +39 -0
- package/lib/Validator/Validator.js +271 -0
- package/lib/Validator/index.js +13 -0
- package/lib/utils/BaseView/BaseView.js +64 -0
- package/lib/utils/BaseView/BaseView.native.js +16 -0
- package/lib/utils/BaseView/index.js +13 -0
- package/lib/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib/utils/children.js +2 -2
- package/lib/utils/floating-ui/index.js +43 -0
- package/lib/utils/floating-ui/index.native.js +43 -0
- package/lib/utils/input.js +12 -6
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/tokens.js +2 -2
- package/lib/utils/useOverlaidPosition.js +243 -0
- package/lib/utils/useSpacingScale.js +1 -3
- package/lib/utils/useUniqueId.js +1 -1
- package/lib-module/ActivityIndicator/Spinner.js +7 -7
- package/lib-module/ActivityIndicator/Spinner.native.js +2 -2
- package/lib-module/BaseProvider/HydrationContext.js +1 -1
- package/lib-module/BaseProvider/TamaguiProvider.js +22 -0
- package/lib-module/Button/ButtonBase.js +2 -2
- package/lib-module/Button/ButtonDropdown.js +181 -0
- package/lib-module/Button/ButtonGroup.js +1 -1
- package/lib-module/Carousel/Carousel.js +2 -4
- package/lib-module/Carousel/CarouselContext.js +1 -1
- package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib-module/Carousel/CarouselThumbnail.js +2 -2
- package/lib-module/Checkbox/Checkbox.js +1 -1
- package/lib-module/Checkbox/CheckboxGroup.js +2 -2
- package/lib-module/Divider/Divider.js +2 -2
- package/lib-module/FlexGrid/Col/Col.js +1 -1
- package/lib-module/Icon/Icon.js +1 -1
- package/lib-module/MultiSelectFilter/ModalOverlay.js +112 -0
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +286 -0
- package/lib-module/MultiSelectFilter/dictionary.js +12 -0
- package/lib-module/MultiSelectFilter/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +2 -2
- package/lib-module/Pagination/Pagination.js +3 -5
- package/lib-module/Pagination/usePagination.js +2 -2
- package/lib-module/Progress/ProgressBar.js +3 -3
- package/lib-module/Progress/ProgressBarBackground.js +3 -3
- package/lib-module/QuickLinksFeature/QuickLinksFeature.js +69 -0
- package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +130 -0
- package/lib-module/QuickLinksFeature/index.js +4 -0
- package/lib-module/Radio/Radio.js +2 -2
- package/lib-module/Radio/RadioGroup.js +2 -2
- package/lib-module/RadioCard/RadioCard.js +1 -1
- package/lib-module/RadioCard/RadioCardGroup.js +2 -2
- package/lib-module/Search/Search.js +1 -1
- package/lib-module/Select/constants.js +5 -0
- package/lib-module/SideNav/SideNav.js +2 -2
- package/lib-module/Skeleton/Skeleton.js +1 -1
- package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib-module/StackView/StackWrap.js +1 -3
- package/lib-module/StackView/getStackedContent.js +2 -2
- package/lib-module/Tabs/Tabs.js +2 -4
- package/lib-module/Tags/Tags.js +1 -1
- package/lib-module/TextInput/dictionary.js +12 -0
- package/lib-module/ThemeProvider/utils/styles.js +3 -3
- package/lib-module/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib-module/Timeline/Timeline.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib-module/Tooltip/Backdrop.js +10 -2
- package/lib-module/Tooltip/Tooltip.native.js +326 -0
- package/lib-module/Tooltip/shared.js +27 -0
- package/lib-module/Validator/Validator.js +245 -0
- package/lib-module/Validator/index.js +2 -0
- package/lib-module/utils/BaseView/BaseView.js +43 -0
- package/lib-module/utils/BaseView/BaseView.native.js +6 -0
- package/lib-module/utils/BaseView/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib-module/utils/children.js +2 -2
- package/lib-module/utils/floating-ui/index.js +1 -0
- package/lib-module/utils/floating-ui/index.native.js +1 -0
- package/lib-module/utils/input.js +12 -6
- package/lib-module/utils/props/componentPropType.js +3 -3
- package/lib-module/utils/props/selectSystemProps.js +2 -2
- package/lib-module/utils/props/tokens.js +2 -2
- package/lib-module/utils/useOverlaidPosition.js +232 -0
- package/lib-module/utils/useSpacingScale.js +1 -3
- package/lib-module/utils/useUniqueId.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
4
|
+
import { containUniqueFields, getTokensPropType, getPressHandlersWithArgs, selectTokens, useCopy, useMultipleInputValues, variantProp } from '../utils';
|
|
5
|
+
import dictionary from './dictionary';
|
|
6
|
+
import Box from '../Box';
|
|
7
|
+
import { Button, ButtonDropdown } from '../Button';
|
|
8
|
+
import { CheckboxGroup } from '../Checkbox';
|
|
9
|
+
import Divider from '../Divider';
|
|
10
|
+
import FlexGrid from '../FlexGrid';
|
|
11
|
+
import Spacer from '../Spacer';
|
|
12
|
+
import StackView from '../StackView';
|
|
13
|
+
import Typography from '../Typography';
|
|
14
|
+
import { TextButton } from '../Link';
|
|
15
|
+
import ModalOverlay from './ModalOverlay';
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
const {
|
|
20
|
+
Col,
|
|
21
|
+
Row
|
|
22
|
+
} = FlexGrid;
|
|
23
|
+
|
|
24
|
+
const selectSubTitleTokens = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
subtitleColor
|
|
27
|
+
} = _ref;
|
|
28
|
+
return {
|
|
29
|
+
color: subtitleColor
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const selectDividerToknes = _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
dividerColor,
|
|
36
|
+
width,
|
|
37
|
+
decorative = true,
|
|
38
|
+
weight = 'thin'
|
|
39
|
+
} = _ref2;
|
|
40
|
+
return {
|
|
41
|
+
color: dividerColor,
|
|
42
|
+
width,
|
|
43
|
+
decorative,
|
|
44
|
+
weight
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const MultiSelectFilter = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
49
|
+
let {
|
|
50
|
+
label,
|
|
51
|
+
subtitle,
|
|
52
|
+
id = label,
|
|
53
|
+
variant,
|
|
54
|
+
tokens,
|
|
55
|
+
items = [],
|
|
56
|
+
values,
|
|
57
|
+
initialValues,
|
|
58
|
+
maxValues,
|
|
59
|
+
onChange,
|
|
60
|
+
copy = 'en',
|
|
61
|
+
readOnly = false,
|
|
62
|
+
inactive = false,
|
|
63
|
+
rowLimit = 12,
|
|
64
|
+
...rest
|
|
65
|
+
} = _ref3;
|
|
66
|
+
const {
|
|
67
|
+
currentValues,
|
|
68
|
+
setValues
|
|
69
|
+
} = useMultipleInputValues({
|
|
70
|
+
initialValues,
|
|
71
|
+
values,
|
|
72
|
+
maxValues,
|
|
73
|
+
onChange,
|
|
74
|
+
readOnly
|
|
75
|
+
});
|
|
76
|
+
const themeTokens = useThemeTokens('ButtonDropdown', tokens, variant);
|
|
77
|
+
const getItemTokens = useThemeTokensCallback('ButtonDropdown', tokens, variant);
|
|
78
|
+
|
|
79
|
+
const getButtonTokens = buttonState => selectTokens('Button', getItemTokens(buttonState));
|
|
80
|
+
|
|
81
|
+
const getCopy = useCopy({
|
|
82
|
+
dictionary,
|
|
83
|
+
copy
|
|
84
|
+
});
|
|
85
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
86
|
+
const [checkedIds, setCheckedIds] = useState(currentValues ?? []);
|
|
87
|
+
const colSize = items.length > rowLimit ? 2 : 1;
|
|
88
|
+
const isSelected = currentValues.length > 0;
|
|
89
|
+
const uniqueFields = ['id', 'label'];
|
|
90
|
+
|
|
91
|
+
if (!containUniqueFields(items, uniqueFields)) {
|
|
92
|
+
throw new Error(`MultiSelectFilter items must have unique ${uniqueFields.join(', ')}`);
|
|
93
|
+
} // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
const pressHandlers = getPressHandlersWithArgs(rest, [{
|
|
97
|
+
id,
|
|
98
|
+
label,
|
|
99
|
+
currentValues
|
|
100
|
+
}]);
|
|
101
|
+
|
|
102
|
+
const handleChange = event => {
|
|
103
|
+
if (pressHandlers.onPress) pressHandlers === null || pressHandlers === void 0 ? void 0 : pressHandlers.onPress(event);
|
|
104
|
+
setIsOpen(!isOpen);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const onApply = e => {
|
|
108
|
+
setValues(e);
|
|
109
|
+
setIsOpen(false);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
113
|
+
children: [/*#__PURE__*/_jsx(ButtonDropdown, {
|
|
114
|
+
ref: ref,
|
|
115
|
+
...pressHandlers,
|
|
116
|
+
value: isOpen,
|
|
117
|
+
selected: isSelected,
|
|
118
|
+
label: label,
|
|
119
|
+
onChange: handleChange,
|
|
120
|
+
tokens: getButtonTokens,
|
|
121
|
+
inactive: inactive
|
|
122
|
+
}, id), isOpen && /*#__PURE__*/_jsxs(ModalOverlay, {
|
|
123
|
+
variant: {
|
|
124
|
+
width: colSize > 1 ? 'size576' : 's'
|
|
125
|
+
},
|
|
126
|
+
onClose: () => setIsOpen(false),
|
|
127
|
+
children: [/*#__PURE__*/_jsx(Row, {
|
|
128
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
129
|
+
variant: {
|
|
130
|
+
size: 'h4'
|
|
131
|
+
},
|
|
132
|
+
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
133
|
+
})
|
|
134
|
+
}), subtitle && /*#__PURE__*/_jsxs(_Fragment, {
|
|
135
|
+
children: [/*#__PURE__*/_jsx(Spacer, {
|
|
136
|
+
space: 5
|
|
137
|
+
}), /*#__PURE__*/_jsx(Row, {
|
|
138
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
139
|
+
variant: {
|
|
140
|
+
size: 'h5'
|
|
141
|
+
},
|
|
142
|
+
tokens: selectSubTitleTokens(themeTokens),
|
|
143
|
+
children: subtitle
|
|
144
|
+
})
|
|
145
|
+
})]
|
|
146
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
147
|
+
space: 4
|
|
148
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
149
|
+
scroll: true,
|
|
150
|
+
children: /*#__PURE__*/_jsx(Row, {
|
|
151
|
+
distribute: "between",
|
|
152
|
+
children: [...Array(colSize).keys()].map(i => /*#__PURE__*/_jsxs(Col, {
|
|
153
|
+
xs: 12 / colSize,
|
|
154
|
+
children: [/*#__PURE__*/_jsx(CheckboxGroup, {
|
|
155
|
+
items: items.slice(i * rowLimit, (i + 1) * rowLimit),
|
|
156
|
+
checkedIds: checkedIds,
|
|
157
|
+
onChange: e => setCheckedIds(e, i)
|
|
158
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
159
|
+
size: 4
|
|
160
|
+
})]
|
|
161
|
+
}, i))
|
|
162
|
+
})
|
|
163
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
|
164
|
+
variant: selectDividerToknes({ ...themeTokens,
|
|
165
|
+
width: 'full'
|
|
166
|
+
}),
|
|
167
|
+
space: 4
|
|
168
|
+
}), /*#__PURE__*/_jsx(Row, {
|
|
169
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
170
|
+
direction: "row",
|
|
171
|
+
space: 3,
|
|
172
|
+
tokens: {
|
|
173
|
+
alignItems: 'center'
|
|
174
|
+
},
|
|
175
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
176
|
+
onPress: () => onApply(checkedIds),
|
|
177
|
+
variant: {
|
|
178
|
+
size: 'small',
|
|
179
|
+
priority: 'high'
|
|
180
|
+
},
|
|
181
|
+
children: getCopy('applyButtonLabel')
|
|
182
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
183
|
+
children: /*#__PURE__*/_jsx(TextButton, {
|
|
184
|
+
onPress: () => setCheckedIds([]),
|
|
185
|
+
children: getCopy('clearButtonLabel')
|
|
186
|
+
})
|
|
187
|
+
})]
|
|
188
|
+
})
|
|
189
|
+
})]
|
|
190
|
+
})]
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
MultiSelectFilter.displayName = 'MultiSelectFilter';
|
|
194
|
+
MultiSelectFilter.propTypes = {
|
|
195
|
+
/**
|
|
196
|
+
* The text displayed to the user in a ButtonDropdown.
|
|
197
|
+
*/
|
|
198
|
+
label: PropTypes.string.isRequired,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The text for the subtitle
|
|
202
|
+
*/
|
|
203
|
+
subtitle: PropTypes.string,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* An optional unique string may be provided to identify the ButtonDropdown.
|
|
207
|
+
* If not provided, the label is used.
|
|
208
|
+
*/
|
|
209
|
+
id: PropTypes.string,
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Sets the variant for ButtonDropdown element.
|
|
213
|
+
*/
|
|
214
|
+
variant: variantProp.propType,
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Sets the tokens for ButtonDropdown element.
|
|
218
|
+
*/
|
|
219
|
+
tokens: getTokensPropType('ButtonDropdown'),
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The options a user may select.
|
|
223
|
+
*/
|
|
224
|
+
items: PropTypes.arrayOf(PropTypes.shape({
|
|
225
|
+
/**
|
|
226
|
+
* The text displayed to the user with a checkbox, describing this option.
|
|
227
|
+
*/
|
|
228
|
+
label: PropTypes.string.isRequired,
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* An optional unique string may be provided to identify this option.
|
|
232
|
+
* If not provided, the label is used.
|
|
233
|
+
*/
|
|
234
|
+
id: PropTypes.string
|
|
235
|
+
})),
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* If the selected item(s) in the checkbox group(s) are to be controlled externally by
|
|
239
|
+
* a parent component, pass an array of strings as well as an `onChange` handler.
|
|
240
|
+
* Passing an array for "values" makes the MultiSelectFilter a "controlled" component that
|
|
241
|
+
* expects its state to be handled via `onChange` and so doesn't handle it itself.
|
|
242
|
+
*/
|
|
243
|
+
values: PropTypes.arrayOf(PropTypes.string),
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* If `values` is not passed, making the MultiSelectFilter an "uncontrolled" component
|
|
247
|
+
* managing its own selected state, a default set of selections may be provided.
|
|
248
|
+
* Changing the `initialValues` does not change the user's selections.
|
|
249
|
+
*/
|
|
250
|
+
initialValues: PropTypes.arrayOf(PropTypes.string),
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* If provided, sets a maximum number of items a user may select at once.
|
|
254
|
+
*/
|
|
255
|
+
maxValues: PropTypes.number,
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* If provided, this function is called when the current selection is changed
|
|
259
|
+
* and is passed an array of the `id`s of all currently selected `items`.
|
|
260
|
+
*/
|
|
261
|
+
onChange: PropTypes.func,
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Select English or French copy for the accessible label.
|
|
265
|
+
*/
|
|
266
|
+
copy: PropTypes.oneOf(['en', 'fr']),
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* If true, the ButtonDropdown cannot be selected by the user and simply show their current state.
|
|
270
|
+
*/
|
|
271
|
+
readOnly: PropTypes.string,
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* If true, the MultiSelectFilter cannot be interacted with, ButtonDropdown is
|
|
275
|
+
* set as `disabled` and if the theme supports `inactive` appearances rules, these
|
|
276
|
+
* are applied.
|
|
277
|
+
*/
|
|
278
|
+
inactive: PropTypes.string,
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Sets the maximum number of items in one column. If number of items are more
|
|
282
|
+
* than the `rowLimit`, they will be rendered in 2 columns.
|
|
283
|
+
*/
|
|
284
|
+
rowLimit: PropTypes.number
|
|
285
|
+
};
|
|
286
|
+
export default MultiSelectFilter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
en: {
|
|
3
|
+
filterByLabel: 'Filter by %{filterCategory}:',
|
|
4
|
+
applyButtonLabel: 'Apply',
|
|
5
|
+
clearButtonLabel: 'Clear'
|
|
6
|
+
},
|
|
7
|
+
fr: {
|
|
8
|
+
filterByLabel: 'Filtrer par %{filterCategory}:',
|
|
9
|
+
applyButtonLabel: 'Appliquer',
|
|
10
|
+
clearButtonLabel: 'Effacer'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -33,8 +33,8 @@ const PageButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
33
33
|
key: 'active-item'
|
|
34
34
|
} : {};
|
|
35
35
|
const accessibilityRole = href !== undefined ? 'link' : 'button';
|
|
36
|
-
const activeLabel = isActive ?
|
|
37
|
-
const accessibilityLabel =
|
|
36
|
+
const activeLabel = isActive ? ` ${getCopy('currentLabel')}` : '';
|
|
37
|
+
const accessibilityLabel = `${getCopy('goToLabel')} ${label}${activeLabel}`;
|
|
38
38
|
const {
|
|
39
39
|
hrefAttrs,
|
|
40
40
|
rest
|
|
@@ -84,11 +84,9 @@ const Pagination = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
84
84
|
LinkRouter: LinkRouter,
|
|
85
85
|
linkRouterProps: linkRouterProps
|
|
86
86
|
}), ...items.map((_child, itemIndex) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const buttonLabel = "".concat(itemIndex + 1);
|
|
87
|
+
const buttonLabel = `${itemIndex + 1}`;
|
|
90
88
|
const itemProps = getItemProps(itemIndex);
|
|
91
|
-
const ItemLinkRouter =
|
|
89
|
+
const ItemLinkRouter = itemProps.LinkRouter ?? LinkRouter;
|
|
92
90
|
const itemLinkRouterProps = { ...linkRouterProps,
|
|
93
91
|
...itemProps.linkRouterProps
|
|
94
92
|
};
|
|
@@ -125,7 +123,7 @@ const Pagination = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
125
123
|
ref: ref,
|
|
126
124
|
...selectProps(rest),
|
|
127
125
|
children: buttons // keep the keys in-line with the page numbers regardless of which buttons are actually rendered
|
|
128
|
-
.map((element, index) => [element,
|
|
126
|
+
.map((element, index) => [element, `page-${index + 1}`]).filter(_ref3 => {
|
|
129
127
|
let [element] = _ref3;
|
|
130
128
|
return element !== null;
|
|
131
129
|
}).map(_ref4 => {
|
|
@@ -14,7 +14,7 @@ function usePagination(_ref) {
|
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
const getItemProps = index => {
|
|
17
|
-
var _items$index
|
|
17
|
+
var _items$index;
|
|
18
18
|
|
|
19
19
|
const {
|
|
20
20
|
onPress,
|
|
@@ -22,7 +22,7 @@ function usePagination(_ref) {
|
|
|
22
22
|
hrefAttrs,
|
|
23
23
|
variant,
|
|
24
24
|
tokens
|
|
25
|
-
} = (
|
|
25
|
+
} = ((_items$index = items[index]) === null || _items$index === void 0 ? void 0 : _items$index.props) ?? {};
|
|
26
26
|
return {
|
|
27
27
|
onPress,
|
|
28
28
|
href,
|
|
@@ -21,7 +21,7 @@ const selectBarStyles = (_ref, percentage) => {
|
|
|
21
21
|
borderRadius,
|
|
22
22
|
outlineWidth,
|
|
23
23
|
outlineColor,
|
|
24
|
-
width:
|
|
24
|
+
width: `${percentage}%`
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
@@ -82,7 +82,7 @@ const ProgressBar = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
82
82
|
min: 0,
|
|
83
83
|
max: 100,
|
|
84
84
|
now: percentage,
|
|
85
|
-
text:
|
|
85
|
+
text: `${percentage}%`
|
|
86
86
|
},
|
|
87
87
|
...rest
|
|
88
88
|
});
|
|
@@ -90,7 +90,7 @@ const ProgressBar = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
90
90
|
ref: ref,
|
|
91
91
|
style: [staticStyles.bar, selectBarStyles(themeTokens, percentage)],
|
|
92
92
|
...selectedProps,
|
|
93
|
-
children: children
|
|
93
|
+
children: children ?? /*#__PURE__*/_jsx(ProgressBarBackground, {
|
|
94
94
|
variant: variant
|
|
95
95
|
})
|
|
96
96
|
}) : null;
|
|
@@ -3,8 +3,8 @@ import ImageBackground from "react-native-web/dist/exports/ImageBackground";
|
|
|
3
3
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
4
|
import { variantProp } from '../utils';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const inactiveBackground =
|
|
7
|
-
const negativeBackground =
|
|
6
|
+
const inactiveBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='DisabledProgress7' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23B2B9BF'%3E%3C/rect%3E%3Ccircle cx='4' cy='4' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23DisabledProgress7");'%3E%3C/path%3E%3C/svg%3E`;
|
|
7
|
+
const negativeBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='NegativeProgress6' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23C12335'%3E%3C/rect%3E%3Cpath d='M 0,8 l 8,-8 M -2,2 l 4,-4 M 6,10 l 4,-4' stroke-width='2' shape-rendering='auto' stroke='%23e7adb4' stroke-linecap='square'%3E%3C/path%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23NegativeProgress6");'%3E%3C/path%3E%3C/svg%3E`;
|
|
8
8
|
const ProgressBarBackground = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
9
9
|
let {
|
|
10
10
|
variant
|
|
@@ -22,7 +22,7 @@ const ProgressBarBackground = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
22
22
|
return /*#__PURE__*/_jsx(ImageBackground, {
|
|
23
23
|
ref: ref,
|
|
24
24
|
source: {
|
|
25
|
-
uri:
|
|
25
|
+
uri: `data:image/svg+xml,${source}`
|
|
26
26
|
},
|
|
27
27
|
style: staticStyles.imageBackground
|
|
28
28
|
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { forwardRef, Children, cloneElement } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { StackWrap } from '../StackView';
|
|
4
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
5
|
+
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils'; // pass through and type relevant system props - add more sets for interactive components
|
|
6
|
+
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
9
|
+
|
|
10
|
+
const isQuickListItem = element => {
|
|
11
|
+
var _element$type, _element$type2;
|
|
12
|
+
|
|
13
|
+
const elementName = (element === null || element === void 0 ? void 0 : (_element$type = element.type) === null || _element$type === void 0 ? void 0 : _element$type.displayName) || (element === null || element === void 0 ? void 0 : (_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.name);
|
|
14
|
+
return Boolean(elementName.match(/QuickLinksFeatureItem/));
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* QuickLinksFeature renders a list of interactive items.
|
|
18
|
+
* - This is the base component that is used as a wrapper and accepts a List of `QuickLinksFeature.Item`
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const QuickLinksFeature = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
23
|
+
let {
|
|
24
|
+
tokens,
|
|
25
|
+
variant,
|
|
26
|
+
tag = 'ul',
|
|
27
|
+
children,
|
|
28
|
+
...rest
|
|
29
|
+
} = _ref;
|
|
30
|
+
const {
|
|
31
|
+
stackGap,
|
|
32
|
+
stackJustify,
|
|
33
|
+
stackSpace
|
|
34
|
+
} = useThemeTokens('QuickLinksFeature', tokens, variant);
|
|
35
|
+
const items = Children.map(children, child => {
|
|
36
|
+
if (isQuickListItem(child)) {
|
|
37
|
+
return /*#__PURE__*/cloneElement(child, child.props);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
});
|
|
42
|
+
return /*#__PURE__*/_jsx(StackWrap, {
|
|
43
|
+
space: stackSpace,
|
|
44
|
+
gap: stackGap,
|
|
45
|
+
tokens: {
|
|
46
|
+
justifyContent: stackJustify
|
|
47
|
+
},
|
|
48
|
+
tag: tag,
|
|
49
|
+
ref: ref,
|
|
50
|
+
...selectProps(rest),
|
|
51
|
+
children: items
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
QuickLinksFeature.displayName = 'QuickLinksFeature';
|
|
55
|
+
QuickLinksFeature.propTypes = { ...selectedSystemPropTypes,
|
|
56
|
+
tokens: getTokensPropType('QuickLinksFeature'),
|
|
57
|
+
variant: variantProp.propType,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Default wrapper tag, by default it's "ul"
|
|
61
|
+
*/
|
|
62
|
+
tag: PropTypes.string,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* QuickLinksFeature.Item component
|
|
66
|
+
*/
|
|
67
|
+
children: PropTypes.node
|
|
68
|
+
};
|
|
69
|
+
export default QuickLinksFeature;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Image from "react-native-web/dist/exports/Image";
|
|
4
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
6
|
+
import View from "react-native-web/dist/exports/View";
|
|
7
|
+
import { getTokensPropType, variantProp, withLinkRouter, a11yProps, linkProps, selectSystemProps } from '../utils';
|
|
8
|
+
import { useViewport } from '../ViewportProvider';
|
|
9
|
+
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
10
|
+
import { Link } from '../Link';
|
|
11
|
+
import { StackWrap } from '../StackView'; // pass through and type relevant system props - add more sets for interactive components
|
|
12
|
+
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps]);
|
|
16
|
+
|
|
17
|
+
const selectImageStyle = imageDimension => ({
|
|
18
|
+
width: imageDimension,
|
|
19
|
+
height: imageDimension,
|
|
20
|
+
...Platform.select({
|
|
21
|
+
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
22
|
+
web: {
|
|
23
|
+
transition: 'width 200ms, height 200ms'
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const selectContainerStyle = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
contentMaxDimension,
|
|
31
|
+
textAlign
|
|
32
|
+
} = _ref;
|
|
33
|
+
return {
|
|
34
|
+
textAlign,
|
|
35
|
+
width: contentMaxDimension,
|
|
36
|
+
overflow: 'hidden'
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const selectImageContainerStyle = contentMaxDimension => ({
|
|
41
|
+
width: contentMaxDimension,
|
|
42
|
+
height: contentMaxDimension,
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
alignItems: 'center'
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Component export along with QuickLinksFeature to be used as children
|
|
48
|
+
*
|
|
49
|
+
* It will receive a image source and a accessibility label and will render a link accordingly with the theme tokens
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const QuickLinksFeatureItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
54
|
+
let {
|
|
55
|
+
tokens,
|
|
56
|
+
variant,
|
|
57
|
+
children,
|
|
58
|
+
imageAccessibilityLabel,
|
|
59
|
+
imageSource,
|
|
60
|
+
...rest
|
|
61
|
+
} = _ref2;
|
|
62
|
+
const viewport = useViewport();
|
|
63
|
+
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
|
+
return /*#__PURE__*/_jsx(Link, {
|
|
77
|
+
ref: ref,
|
|
78
|
+
tokens: state => {
|
|
79
|
+
setHover(state.hover);
|
|
80
|
+
return getTokens(state);
|
|
81
|
+
},
|
|
82
|
+
...selectProps(rest),
|
|
83
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
84
|
+
style: selectContainerStyle({
|
|
85
|
+
contentMaxDimension,
|
|
86
|
+
textAlign
|
|
87
|
+
}),
|
|
88
|
+
children: /*#__PURE__*/_jsxs(StackWrap, {
|
|
89
|
+
direction: contentDirection,
|
|
90
|
+
space: contentSpace,
|
|
91
|
+
tokens: {
|
|
92
|
+
alignItems: contentAlignItems
|
|
93
|
+
},
|
|
94
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
95
|
+
style: selectImageContainerStyle(contentMaxDimension),
|
|
96
|
+
children: /*#__PURE__*/_jsx(Image, {
|
|
97
|
+
accessibilityIgnoresInvertColors: true,
|
|
98
|
+
imageAccessibilityLabel: imageAccessibilityLabel,
|
|
99
|
+
source: imageSource,
|
|
100
|
+
style: selectImageStyle(imageDimension)
|
|
101
|
+
})
|
|
102
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
103
|
+
children: children
|
|
104
|
+
})]
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
QuickLinksFeatureItem.displayName = 'QuickLinksFeatureItem';
|
|
110
|
+
QuickLinksFeatureItem.propTypes = { ...withLinkRouter.propTypes,
|
|
111
|
+
...selectedSystemPropTypes,
|
|
112
|
+
tokens: getTokensPropType('QuickLinksFeatureItem'),
|
|
113
|
+
variant: variantProp.propType,
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Text which will be rendered within the Link
|
|
117
|
+
*/
|
|
118
|
+
children: PropTypes.node.isRequired,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Image accessibility label
|
|
122
|
+
*/
|
|
123
|
+
imageAccessibilityLabel: PropTypes.string.isRequired,
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Image node or Image url
|
|
127
|
+
*/
|
|
128
|
+
imageSource: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired
|
|
129
|
+
};
|
|
130
|
+
export default withLinkRouter(QuickLinksFeatureItem);
|
|
@@ -46,7 +46,7 @@ const selectDescriptionStyles = _ref2 => {
|
|
|
46
46
|
labelMarginLeft = 0
|
|
47
47
|
} = _ref2;
|
|
48
48
|
return {
|
|
49
|
-
marginLeft: descriptionMarginLeft
|
|
49
|
+
marginLeft: descriptionMarginLeft ?? containerPaddingLeft + inputSize + labelMarginLeft,
|
|
50
50
|
...applyTextStyles({
|
|
51
51
|
fontSize: descriptionFontSize,
|
|
52
52
|
lineHeight: descriptionLineHeight
|
|
@@ -150,7 +150,7 @@ const Radio = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
const uniqueId = useUniqueId('radio');
|
|
153
|
-
const inputId = id
|
|
153
|
+
const inputId = id ?? uniqueId;
|
|
154
154
|
const selectedProps = selectProps({
|
|
155
155
|
accessibilityRole: 'radio',
|
|
156
156
|
accessibilityState: {
|
|
@@ -99,7 +99,7 @@ const RadioGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
99
99
|
const uniqueFields = ['id', 'label'];
|
|
100
100
|
|
|
101
101
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
102
|
-
throw new Error(
|
|
102
|
+
throw new Error(`RadioGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const radios = items.map((_ref2, index) => {
|
|
@@ -110,7 +110,7 @@ const RadioGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
110
110
|
ref: itemRef,
|
|
111
111
|
...itemRest
|
|
112
112
|
} = _ref2;
|
|
113
|
-
const radioId = id ||
|
|
113
|
+
const radioId = id || `Radio[${index}]`;
|
|
114
114
|
const isChecked = currentValue === radioId;
|
|
115
115
|
|
|
116
116
|
const handleChange = (newCheckedState, event) => {
|
|
@@ -79,7 +79,7 @@ const RadioCard = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const uniqueId = useUniqueId('RadioCard');
|
|
82
|
-
const inputId = id
|
|
82
|
+
const inputId = id ?? uniqueId;
|
|
83
83
|
const getTokens = useThemeTokensCallback('RadioCard', tokens, variant);
|
|
84
84
|
|
|
85
85
|
const getCardTokens = cardState => selectPressableCardTokens(getTokens(cardState));
|
|
@@ -105,7 +105,7 @@ const RadioCardGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
105
105
|
const uniqueFields = ['id'];
|
|
106
106
|
|
|
107
107
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
108
|
-
throw new Error(
|
|
108
|
+
throw new Error(`RadioCardGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
return /*#__PURE__*/_jsx(Fieldset, {
|
|
@@ -133,7 +133,7 @@ const RadioCardGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
133
133
|
onChange: itemOnChange,
|
|
134
134
|
...itemRest
|
|
135
135
|
} = _ref2;
|
|
136
|
-
const cardId = id ||
|
|
136
|
+
const cardId = id || `RadioCard[${index}]`;
|
|
137
137
|
|
|
138
138
|
const handleChange = (newCheckedState, event) => {
|
|
139
139
|
if (typeof itemOnChange === 'function') itemOnChange(newCheckedState, event);
|