@telus-uds/components-base 1.18.1 → 1.20.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 +42 -2
- package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +2 -1
- package/component-docs.json +1035 -231
- package/jest.config-android.js +17 -0
- package/jest.config-ios.js +18 -0
- package/jest.config-web.js +31 -0
- package/lib/BaseProvider/index.js +2 -1
- package/lib/Box/Box.js +14 -1
- package/lib/Button/ButtonBase.js +6 -2
- package/lib/Button/ButtonDropdown.js +207 -0
- package/lib/Button/index.js +8 -0
- package/lib/Carousel/Carousel.js +34 -6
- package/lib/Carousel/CarouselItem/CarouselItem.js +7 -1
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +22 -14
- package/lib/FlexGrid/Col/Col.js +1 -3
- package/lib/FlexGrid/FlexGrid.js +3 -5
- package/lib/FlexGrid/Row/Row.js +3 -3
- package/lib/IconButton/IconButton.js +12 -4
- package/lib/MultiSelectFilter/MultiSelectFilter.js +276 -0
- package/lib/MultiSelectFilter/dictionary.js +19 -0
- package/lib/MultiSelectFilter/index.js +13 -0
- package/lib/Pagination/SideButton.js +6 -4
- package/lib/Responsive/Responsive.js +58 -0
- package/lib/Responsive/index.js +13 -0
- package/lib/Search/Search.js +33 -63
- package/lib/Select/Picker.native.js +16 -13
- package/lib/Select/Select.js +7 -1
- package/lib/Select/constants.js +15 -0
- package/lib/StepTracker/Step.js +2 -1
- package/lib/Tags/Tags.js +10 -4
- package/lib/TextInput/TextInput.js +9 -2
- package/lib/TextInput/TextInputBase.js +98 -20
- package/lib/TextInput/dictionary.js +15 -0
- package/lib/ThemeProvider/ThemeProvider.js +6 -1
- package/lib/index.js +18 -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/index.js +10 -1
- package/lib/utils/input.js +11 -3
- package/lib/utils/props/handlerProps.js +5 -0
- package/lib-module/BaseProvider/index.js +2 -1
- package/lib-module/Box/Box.js +14 -1
- package/lib-module/Button/ButtonBase.js +6 -2
- package/lib-module/Button/ButtonDropdown.js +181 -0
- package/lib-module/Button/index.js +2 -1
- package/lib-module/Carousel/Carousel.js +34 -6
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +8 -2
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +24 -16
- package/lib-module/FlexGrid/Col/Col.js +2 -3
- package/lib-module/FlexGrid/FlexGrid.js +2 -3
- package/lib-module/FlexGrid/Row/Row.js +2 -2
- package/lib-module/IconButton/IconButton.js +14 -4
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +248 -0
- package/lib-module/MultiSelectFilter/dictionary.js +12 -0
- package/lib-module/MultiSelectFilter/index.js +2 -0
- package/lib-module/Pagination/SideButton.js +6 -4
- package/lib-module/Responsive/Responsive.js +45 -0
- package/lib-module/Responsive/index.js +2 -0
- package/lib-module/Search/Search.js +33 -61
- package/lib-module/Select/Picker.native.js +15 -13
- package/lib-module/Select/Select.js +6 -1
- package/lib-module/Select/constants.js +5 -0
- package/lib-module/StepTracker/Step.js +2 -1
- package/lib-module/Tags/Tags.js +10 -4
- package/lib-module/TextInput/TextInput.js +6 -0
- package/lib-module/TextInput/TextInputBase.js +96 -21
- package/lib-module/TextInput/dictionary.js +8 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +6 -1
- package/lib-module/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/index.js +2 -1
- package/lib-module/utils/input.js +11 -3
- package/lib-module/utils/props/handlerProps.js +5 -0
- package/package.json +6 -3
- package/src/BaseProvider/index.jsx +4 -1
- package/src/Box/Box.jsx +14 -1
- package/src/Button/ButtonBase.jsx +4 -2
- package/src/Button/ButtonDropdown.jsx +179 -0
- package/src/Button/index.js +2 -1
- package/src/Carousel/Carousel.jsx +48 -13
- package/src/Carousel/CarouselItem/CarouselItem.jsx +9 -2
- package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +19 -15
- package/src/FlexGrid/Col/Col.jsx +4 -4
- package/src/FlexGrid/FlexGrid.jsx +11 -10
- package/src/FlexGrid/Row/Row.jsx +4 -3
- package/src/IconButton/IconButton.jsx +3 -1
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +227 -0
- package/src/MultiSelectFilter/dictionary.js +12 -0
- package/src/MultiSelectFilter/index.js +3 -0
- package/src/Pagination/SideButton.jsx +5 -5
- package/src/Responsive/Responsive.jsx +33 -0
- package/src/Responsive/index.js +3 -0
- package/src/Search/Search.jsx +19 -33
- package/src/Select/Picker.native.jsx +29 -14
- package/src/Select/Select.jsx +7 -1
- package/src/Select/constants.js +5 -0
- package/src/StepTracker/Step.jsx +5 -1
- package/src/Tags/Tags.jsx +46 -33
- package/src/TextInput/TextInput.jsx +5 -0
- package/src/TextInput/TextInputBase.jsx +85 -20
- package/src/TextInput/dictionary.js +8 -0
- package/src/ThemeProvider/ThemeProvider.jsx +5 -1
- package/src/index.js +2 -0
- package/src/utils/BaseView/BaseView.jsx +38 -0
- package/src/utils/BaseView/BaseView.native.jsx +6 -0
- package/src/utils/BaseView/index.js +3 -0
- package/src/utils/index.js +1 -0
- package/src/utils/input.js +9 -4
- package/src/utils/props/handlerProps.js +4 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
13
|
+
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
|
|
16
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
17
|
+
|
|
18
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
|
19
|
+
|
|
20
|
+
var _Button = require("../Button");
|
|
21
|
+
|
|
22
|
+
var _Checkbox = require("../Checkbox");
|
|
23
|
+
|
|
24
|
+
var _Divider = _interopRequireDefault(require("../Divider"));
|
|
25
|
+
|
|
26
|
+
var _FlexGrid = _interopRequireDefault(require("../FlexGrid"));
|
|
27
|
+
|
|
28
|
+
var _Modal = _interopRequireDefault(require("../Modal"));
|
|
29
|
+
|
|
30
|
+
var _Spacer = _interopRequireDefault(require("../Spacer"));
|
|
31
|
+
|
|
32
|
+
var _StackView = _interopRequireDefault(require("../StackView"));
|
|
33
|
+
|
|
34
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
35
|
+
|
|
36
|
+
var _Link = require("../Link");
|
|
37
|
+
|
|
38
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
39
|
+
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
+
|
|
42
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
|
+
|
|
44
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
+
|
|
46
|
+
const {
|
|
47
|
+
Col,
|
|
48
|
+
Row
|
|
49
|
+
} = _FlexGrid.default;
|
|
50
|
+
const MultiSelectFilter = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
51
|
+
let {
|
|
52
|
+
label,
|
|
53
|
+
id = label,
|
|
54
|
+
variant,
|
|
55
|
+
tokens,
|
|
56
|
+
items = [],
|
|
57
|
+
values,
|
|
58
|
+
initialValues,
|
|
59
|
+
maxValues,
|
|
60
|
+
onChange,
|
|
61
|
+
copy = 'en',
|
|
62
|
+
readOnly = false,
|
|
63
|
+
inactive = false,
|
|
64
|
+
rowLimit = 12,
|
|
65
|
+
...rest
|
|
66
|
+
} = _ref;
|
|
67
|
+
const {
|
|
68
|
+
currentValues,
|
|
69
|
+
setValues
|
|
70
|
+
} = (0, _utils.useMultipleInputValues)({
|
|
71
|
+
initialValues,
|
|
72
|
+
values,
|
|
73
|
+
maxValues,
|
|
74
|
+
onChange,
|
|
75
|
+
readOnly
|
|
76
|
+
});
|
|
77
|
+
const getItemTokens = (0, _ThemeProvider.useThemeTokensCallback)('ButtonDropdown', tokens, variant);
|
|
78
|
+
|
|
79
|
+
const getButtonTokens = buttonState => (0, _utils.selectTokens)('Button', getItemTokens(buttonState));
|
|
80
|
+
|
|
81
|
+
const getCopy = (0, _utils.useCopy)({
|
|
82
|
+
dictionary: _dictionary.default,
|
|
83
|
+
copy
|
|
84
|
+
});
|
|
85
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
86
|
+
const [checkedIds, setCheckedIds] = (0, _react.useState)(currentValues !== null && currentValues !== void 0 ? currentValues : []);
|
|
87
|
+
const colSize = items.length > rowLimit ? 2 : 1;
|
|
88
|
+
const isSelected = currentValues.length > 0;
|
|
89
|
+
const uniqueFields = ['id', 'label'];
|
|
90
|
+
|
|
91
|
+
if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
|
|
92
|
+
throw new Error("MultiSelectFilter items must have unique ".concat(uniqueFields.join(', ')));
|
|
93
|
+
} // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
const pressHandlers = (0, _utils.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(true);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const onApply = e => {
|
|
108
|
+
setValues(e);
|
|
109
|
+
setIsOpen(false);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
113
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Modal.default, {
|
|
114
|
+
isOpen: isOpen,
|
|
115
|
+
onClose: () => setIsOpen(false),
|
|
116
|
+
variant: {
|
|
117
|
+
width: colSize > 1 ? 'size576' : 's'
|
|
118
|
+
},
|
|
119
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
121
|
+
variant: {
|
|
122
|
+
size: 'h4'
|
|
123
|
+
},
|
|
124
|
+
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
125
|
+
})
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
127
|
+
space: 4
|
|
128
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
129
|
+
space: 1
|
|
130
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
131
|
+
scroll: true,
|
|
132
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
|
|
133
|
+
distribute: "between",
|
|
134
|
+
children: [...Array(colSize).keys()].map(i => /*#__PURE__*/(0, _jsxRuntime.jsxs)(Col, {
|
|
135
|
+
xs: 12 / colSize,
|
|
136
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.CheckboxGroup, {
|
|
137
|
+
items: items.slice(i * rowLimit, (i + 1) * rowLimit),
|
|
138
|
+
checkedIds: checkedIds,
|
|
139
|
+
onChange: e => setCheckedIds(e, i)
|
|
140
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
141
|
+
size: 4
|
|
142
|
+
})]
|
|
143
|
+
}, i))
|
|
144
|
+
})
|
|
145
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
|
|
146
|
+
variant: {
|
|
147
|
+
width: 'full',
|
|
148
|
+
color: 'E3E6E8',
|
|
149
|
+
decorative: true,
|
|
150
|
+
weight: 'thin'
|
|
151
|
+
},
|
|
152
|
+
space: 4
|
|
153
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Row, {
|
|
154
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
155
|
+
direction: "row",
|
|
156
|
+
space: 3,
|
|
157
|
+
tokens: {
|
|
158
|
+
alignItems: 'center'
|
|
159
|
+
},
|
|
160
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
161
|
+
onPress: () => onApply(checkedIds),
|
|
162
|
+
variant: {
|
|
163
|
+
size: 'small',
|
|
164
|
+
priority: 'high'
|
|
165
|
+
},
|
|
166
|
+
children: getCopy('applyButtonLabel')
|
|
167
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
168
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link.TextButton, {
|
|
169
|
+
onPress: () => setCheckedIds([]),
|
|
170
|
+
children: getCopy('clearButtonLabel')
|
|
171
|
+
})
|
|
172
|
+
})]
|
|
173
|
+
})
|
|
174
|
+
})]
|
|
175
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.ButtonDropdown, {
|
|
176
|
+
ref: ref,
|
|
177
|
+
...pressHandlers,
|
|
178
|
+
value: isOpen,
|
|
179
|
+
selected: isSelected,
|
|
180
|
+
label: label,
|
|
181
|
+
onChange: handleChange,
|
|
182
|
+
tokens: getButtonTokens,
|
|
183
|
+
inactive: inactive
|
|
184
|
+
}, id)]
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
MultiSelectFilter.displayName = 'MultiSelectFilter';
|
|
188
|
+
MultiSelectFilter.propTypes = {
|
|
189
|
+
/**
|
|
190
|
+
* The text displayed to the user in a ButtonDropdown.
|
|
191
|
+
*/
|
|
192
|
+
label: _propTypes.default.string.isRequired,
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* An optional unique string may be provided to identify the ButtonDropdown.
|
|
196
|
+
* If not provided, the label is used.
|
|
197
|
+
*/
|
|
198
|
+
id: _propTypes.default.string,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Sets the variant for ButtonDropdown element.
|
|
202
|
+
*/
|
|
203
|
+
variant: _utils.variantProp.propType,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sets the tokens for ButtonDropdown element.
|
|
207
|
+
*/
|
|
208
|
+
tokens: (0, _utils.getTokensPropType)('ButtonDropdown'),
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The options a user may select.
|
|
212
|
+
*/
|
|
213
|
+
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
214
|
+
/**
|
|
215
|
+
* The text displayed to the user with a checkbox, describing this option.
|
|
216
|
+
*/
|
|
217
|
+
label: _propTypes.default.string.isRequired,
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* An optional unique string may be provided to identify this option.
|
|
221
|
+
* If not provided, the label is used.
|
|
222
|
+
*/
|
|
223
|
+
id: _propTypes.default.string
|
|
224
|
+
})),
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* If the selected item(s) in the checkbox group(s) are to be controlled externally by
|
|
228
|
+
* a parent component, pass an array of strings as well as an `onChange` handler.
|
|
229
|
+
* Passing an array for "values" makes the MultiSelectFilter a "controlled" component that
|
|
230
|
+
* expects its state to be handled via `onChange` and so doesn't handle it itself.
|
|
231
|
+
*/
|
|
232
|
+
values: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* If `values` is not passed, making the MultiSelectFilter an "uncontrolled" component
|
|
236
|
+
* managing its own selected state, a default set of selections may be provided.
|
|
237
|
+
* Changing the `initialValues` does not change the user's selections.
|
|
238
|
+
*/
|
|
239
|
+
initialValues: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* If provided, sets a maximum number of items a user may select at once.
|
|
243
|
+
*/
|
|
244
|
+
maxValues: _propTypes.default.number,
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* If provided, this function is called when the current selection is changed
|
|
248
|
+
* and is passed an array of the `id`s of all currently selected `items`.
|
|
249
|
+
*/
|
|
250
|
+
onChange: _propTypes.default.func,
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Select English or French copy for the accessible label.
|
|
254
|
+
*/
|
|
255
|
+
copy: _propTypes.default.oneOf(['en', 'fr']),
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* If true, the ButtonDropdown cannot be selected by the user and simply show their current state.
|
|
259
|
+
*/
|
|
260
|
+
readOnly: _propTypes.default.string,
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* If true, the MultiSelectFilter cannot be interacted with, ButtonDropdown is
|
|
264
|
+
* set as `disabled` and if the theme supports `inactive` appearances rules, these
|
|
265
|
+
* are applied.
|
|
266
|
+
*/
|
|
267
|
+
inactive: _propTypes.default.string,
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Sets the maximum number of items in one column. If number of items are more
|
|
271
|
+
* than the `rowLimit`, they will be rendered in 2 columns.
|
|
272
|
+
*/
|
|
273
|
+
rowLimit: _propTypes.default.number
|
|
274
|
+
};
|
|
275
|
+
var _default = MultiSelectFilter;
|
|
276
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
en: {
|
|
9
|
+
filterByLabel: 'Filter by %{filterCategory}:',
|
|
10
|
+
applyButtonLabel: 'Apply',
|
|
11
|
+
clearButtonLabel: 'Clear'
|
|
12
|
+
},
|
|
13
|
+
fr: {
|
|
14
|
+
filterByLabel: 'Filtrer par %{filterCategory}:',
|
|
15
|
+
applyButtonLabel: 'Appliquer',
|
|
16
|
+
clearButtonLabel: 'Effacer'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _MultiSelectFilter = _interopRequireDefault(require("./MultiSelectFilter"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _MultiSelectFilter.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -34,10 +34,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
34
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
35
|
|
|
36
36
|
// We need to drop the icon here since it gets rendered via children and not
|
|
37
|
-
// `ButtonBase` in order to tap into the state of the button
|
|
37
|
+
// `ButtonBase` in order to tap into the state of the button; `displayLabel` flag
|
|
38
|
+
// is also not needed
|
|
38
39
|
const selectButtonTokens = _ref => {
|
|
39
40
|
let {
|
|
40
41
|
icon: _,
|
|
42
|
+
displayLabel: __,
|
|
41
43
|
...rest
|
|
42
44
|
} = _ref;
|
|
43
45
|
return (0, _utils.selectTokens)('Button', rest);
|
|
@@ -82,7 +84,8 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
82
84
|
copy
|
|
83
85
|
});
|
|
84
86
|
const {
|
|
85
|
-
icon
|
|
87
|
+
icon,
|
|
88
|
+
displayLabel
|
|
86
89
|
} = getTokens(tokens, buttonVariant);
|
|
87
90
|
|
|
88
91
|
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
|
|
@@ -90,7 +93,6 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
90
93
|
const getIconTokens = buttonState => selectIconTokens(getTokens(buttonState), direction);
|
|
91
94
|
|
|
92
95
|
const label = direction === 'previous' ? getCopy('previousText') : getCopy('nextText');
|
|
93
|
-
const showLabel = viewport !== 'sm' && viewport !== 'xs';
|
|
94
96
|
const accessibilityLabel = direction === 'previous' ? getCopy('previousLabel') : getCopy('nextLabel');
|
|
95
97
|
const accessibilityRole = href !== undefined ? 'link' : 'button';
|
|
96
98
|
|
|
@@ -124,7 +126,7 @@ const SideButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
124
126
|
space: 1,
|
|
125
127
|
iconPosition: directionToSide[direction],
|
|
126
128
|
iconProps: iconProps,
|
|
127
|
-
children:
|
|
129
|
+
children: displayLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
128
130
|
style: textStyles,
|
|
129
131
|
children: label
|
|
130
132
|
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _systemConstants = require("@telus-uds/system-constants");
|
|
13
|
+
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Responsive conditionally renders children based on whether the viewport matches the provided
|
|
22
|
+
* min and max viewports.
|
|
23
|
+
*
|
|
24
|
+
* In SSR, like other viewport utilities, it treats the viewport as `xs` both in SSR itself and
|
|
25
|
+
* during first hydration on the client side; then if the viewport is not `xs`, it re-renders
|
|
26
|
+
* after hydration. This may cause a layout shift on devices other than the narrowest.
|
|
27
|
+
*/
|
|
28
|
+
const Responsive = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
min = 'xs',
|
|
31
|
+
max,
|
|
32
|
+
children
|
|
33
|
+
} = _ref;
|
|
34
|
+
// Start returning children at the 'min' viewport or greater
|
|
35
|
+
const byViewports = {
|
|
36
|
+
[min]: children
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (max && max !== 'xl') {
|
|
40
|
+
// Stop returning children at the viewport one above 'max' or greater
|
|
41
|
+
const maxIndex = _systemConstants.viewports.keys.indexOf(max);
|
|
42
|
+
|
|
43
|
+
const maxPlusOne = maxIndex >= 0 ? _systemConstants.viewports.keys[maxIndex + 1] : null;
|
|
44
|
+
if (maxPlusOne) byViewports[maxPlusOne] = null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
48
|
+
children: (0, _utils.useResponsiveProp)(byViewports, null)
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Responsive.propTypes = {
|
|
53
|
+
min: _propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
|
54
|
+
max: _propTypes.default.oneOf(['sm', 'md', 'lg', 'xl']),
|
|
55
|
+
children: _propTypes.default.node.isRequired
|
|
56
|
+
};
|
|
57
|
+
var _default = Responsive;
|
|
58
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _Responsive = _interopRequireDefault(require("./Responsive"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _Responsive.default;
|
|
13
|
+
exports.default = _default;
|
package/lib/Search/Search.js
CHANGED
|
@@ -9,8 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
11
11
|
|
|
12
|
-
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
13
|
-
|
|
14
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
13
|
|
|
16
14
|
var _ThemeProvider = require("../ThemeProvider");
|
|
@@ -21,8 +19,6 @@ var _TextInputBase = _interopRequireDefault(require("../TextInput/TextInputBase"
|
|
|
21
19
|
|
|
22
20
|
var _ButtonBase = _interopRequireDefault(require("../Button/ButtonBase"));
|
|
23
21
|
|
|
24
|
-
var _StackView = _interopRequireDefault(require("../StackView"));
|
|
25
|
-
|
|
26
22
|
var _useCopy = _interopRequireDefault(require("../utils/useCopy"));
|
|
27
23
|
|
|
28
24
|
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
@@ -63,20 +59,11 @@ const selectInputTokens = _ref => {
|
|
|
63
59
|
|
|
64
60
|
const selectButtonTokens = tokens => (0, _utils.selectTokens)('Button', tokens);
|
|
65
61
|
|
|
66
|
-
const
|
|
67
|
-
let {
|
|
68
|
-
paddingRight
|
|
69
|
-
} = _ref2;
|
|
70
|
-
return {
|
|
71
|
-
paddingRight
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const selectIconTokens = _ref3 => {
|
|
62
|
+
const selectIconTokens = _ref2 => {
|
|
76
63
|
let {
|
|
77
64
|
iconSize,
|
|
78
65
|
iconColor
|
|
79
|
-
} =
|
|
66
|
+
} = _ref2;
|
|
80
67
|
return {
|
|
81
68
|
color: iconColor,
|
|
82
69
|
size: iconSize
|
|
@@ -97,7 +84,7 @@ const selectIconTokens = _ref3 => {
|
|
|
97
84
|
*/
|
|
98
85
|
|
|
99
86
|
|
|
100
|
-
const Search = /*#__PURE__*/(0, _react.forwardRef)((
|
|
87
|
+
const Search = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
101
88
|
let {
|
|
102
89
|
initialValue,
|
|
103
90
|
value,
|
|
@@ -112,7 +99,7 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
|
112
99
|
tokens,
|
|
113
100
|
variant,
|
|
114
101
|
...rest
|
|
115
|
-
} =
|
|
102
|
+
} = _ref3;
|
|
116
103
|
const {
|
|
117
104
|
currentValue = '',
|
|
118
105
|
setValue
|
|
@@ -146,8 +133,11 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
|
146
133
|
};
|
|
147
134
|
|
|
148
135
|
const handleClear = event => {
|
|
136
|
+
var _ref$current;
|
|
137
|
+
|
|
149
138
|
setValue('', event);
|
|
150
|
-
|
|
139
|
+
onClear === null || onClear === void 0 ? void 0 : onClear('', event);
|
|
140
|
+
ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
|
151
141
|
};
|
|
152
142
|
|
|
153
143
|
const handleFocus = event => {
|
|
@@ -164,10 +154,8 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
|
164
154
|
testID,
|
|
165
155
|
...containerProps
|
|
166
156
|
} = selectContainerProps(rest);
|
|
167
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
168
|
-
|
|
169
|
-
...containerProps,
|
|
170
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
157
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, { ...containerProps,
|
|
158
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
|
|
171
159
|
nativeID: nativeID,
|
|
172
160
|
testID: testID,
|
|
173
161
|
...selectInputProps(rest),
|
|
@@ -187,35 +175,29 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
|
187
175
|
onChange: setValue,
|
|
188
176
|
onSubmitEditing: handleSubmit,
|
|
189
177
|
onFocus: handleFocus,
|
|
190
|
-
accessibilityLabel: a11yLabelText
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
accessibilityLabel: getCopy('submitButtonAccessibilityLabel'),
|
|
209
|
-
tokens: buttonState => selectButtonTokens(getButtonTokens({ ...buttonState,
|
|
178
|
+
accessibilityLabel: a11yLabelText,
|
|
179
|
+
buttons: [ClearButtonIcon && !isEmpty && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
180
|
+
accessibilityLabel: getCopy('clearButtonAccessibilityLabel'),
|
|
181
|
+
accessibilityRole: "button",
|
|
182
|
+
inactive: inactive,
|
|
183
|
+
onPress: handleClear,
|
|
184
|
+
tokens: appearances => selectButtonTokens(getButtonTokens(appearances)),
|
|
185
|
+
children: buttonState => /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearButtonIcon, { ...selectIconTokens(getButtonTokens(buttonState))
|
|
186
|
+
})
|
|
187
|
+
}, "clear"), SubmitButtonIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
188
|
+
accessibilityLabel: getCopy('submitButtonAccessibilityLabel'),
|
|
189
|
+
accessibilityRole: "button",
|
|
190
|
+
inactive: inactive,
|
|
191
|
+
onPress: handleSubmit,
|
|
192
|
+
tokens: buttonState => selectButtonTokens(getButtonTokens({ ...buttonState,
|
|
193
|
+
priority: 'high'
|
|
194
|
+
})),
|
|
195
|
+
children: buttonState => /*#__PURE__*/(0, _jsxRuntime.jsx)(SubmitButtonIcon, { ...selectIconTokens(getButtonTokens({ ...buttonState,
|
|
210
196
|
priority: 'high'
|
|
211
|
-
}))
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
})
|
|
216
|
-
})]
|
|
217
|
-
})
|
|
218
|
-
})]
|
|
197
|
+
}))
|
|
198
|
+
})
|
|
199
|
+
}, "submit")]
|
|
200
|
+
})
|
|
219
201
|
});
|
|
220
202
|
});
|
|
221
203
|
Search.displayName = 'Search';
|
|
@@ -280,16 +262,4 @@ Search.propTypes = { ...selectedContainerPropTypes,
|
|
|
280
262
|
variant: _utils.variantProp.propType
|
|
281
263
|
};
|
|
282
264
|
var _default = Search;
|
|
283
|
-
exports.default = _default;
|
|
284
|
-
|
|
285
|
-
const staticStyles = _StyleSheet.default.create({
|
|
286
|
-
container: {// No styles needed here except the View defaults (position: relative etc)
|
|
287
|
-
},
|
|
288
|
-
iconsContainer: {
|
|
289
|
-
position: 'absolute',
|
|
290
|
-
right: 0,
|
|
291
|
-
top: 0,
|
|
292
|
-
bottom: 0,
|
|
293
|
-
justifyContent: 'center'
|
|
294
|
-
}
|
|
295
|
-
});
|
|
265
|
+
exports.default = _default;
|
|
@@ -19,6 +19,8 @@ var _utils = require("../utils");
|
|
|
19
19
|
|
|
20
20
|
var _Group = _interopRequireDefault(require("./Group"));
|
|
21
21
|
|
|
22
|
+
var _constants = require("./constants");
|
|
23
|
+
|
|
22
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -27,32 +29,33 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
29
|
|
|
28
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
31
|
|
|
30
|
-
//
|
|
32
|
+
// Styling of the native input is very limited, most of the styles have to be applied to an additional View
|
|
31
33
|
const selectAndroidInputStyles = _ref => {
|
|
32
34
|
let {
|
|
33
35
|
height = 0,
|
|
34
|
-
paddingBottom = 0,
|
|
35
|
-
paddingTop = 0,
|
|
36
|
-
borderWidth = 0,
|
|
37
36
|
color
|
|
38
37
|
} = _ref;
|
|
39
38
|
return {
|
|
40
|
-
height
|
|
39
|
+
height,
|
|
40
|
+
paddingBottom: 0,
|
|
41
|
+
paddingTop: 0,
|
|
41
42
|
color
|
|
42
43
|
};
|
|
43
|
-
}; //
|
|
44
|
+
}; // The native input has a side padding of 8px, which can't be adjusted, so we have to account for that in the container
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
const selectAndroidContainerStyles = _ref2 => {
|
|
47
48
|
let {
|
|
48
|
-
paddingLeft =
|
|
49
|
-
paddingRight =
|
|
49
|
+
paddingLeft = _constants.ANDROID_DEFAULT_PADDING,
|
|
50
|
+
paddingRight = _constants.ANDROID_DEFAULT_PADDING,
|
|
50
51
|
...rest
|
|
51
52
|
} = _ref2;
|
|
52
|
-
return {
|
|
53
|
-
paddingLeft: paddingLeft >
|
|
54
|
-
paddingRight: paddingRight >
|
|
55
|
-
|
|
53
|
+
return { ...rest,
|
|
54
|
+
paddingLeft: paddingLeft > _constants.ANDROID_HORIZONTAL_PADDING_OFFSET ? paddingLeft - _constants.ANDROID_HORIZONTAL_PADDING_OFFSET : _constants.ANDROID_DEFAULT_PADDING,
|
|
55
|
+
paddingRight: paddingRight > _constants.ANDROID_HORIZONTAL_PADDING_OFFSET ? paddingRight - _constants.ANDROID_HORIZONTAL_PADDING_OFFSET : _constants.ANDROID_DEFAULT_PADDING,
|
|
56
|
+
paddingBottom: _constants.ANDROID_DEFAULT_PADDING,
|
|
57
|
+
paddingTop: _constants.ANDROID_DEFAULT_PADDING,
|
|
58
|
+
height: rest.height + _constants.ANDROID_HEIGHT_OFFSET
|
|
56
59
|
};
|
|
57
60
|
};
|
|
58
61
|
|
|
@@ -69,7 +72,7 @@ const Picker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
69
72
|
...rest
|
|
70
73
|
} = _ref3;
|
|
71
74
|
|
|
72
|
-
//
|
|
75
|
+
// Ungroup items, since there's no way to support groups on native
|
|
73
76
|
const flatChildren = _react.Children.toArray(children).flatMap(child => {
|
|
74
77
|
if (child.type === _Group.default) {
|
|
75
78
|
return child.props.children;
|
package/lib/Select/Select.js
CHANGED
|
@@ -23,6 +23,8 @@ var _Picker = _interopRequireDefault(require("./Picker"));
|
|
|
23
23
|
|
|
24
24
|
var _InputSupports = _interopRequireDefault(require("../InputSupports"));
|
|
25
25
|
|
|
26
|
+
var _constants = require("./constants");
|
|
27
|
+
|
|
26
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
29
|
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -166,7 +168,11 @@ const selectValidationIconContainerStyles = _ref6 => {
|
|
|
166
168
|
} = _ref6;
|
|
167
169
|
return {
|
|
168
170
|
paddingRight: icon ? paddingRight + iconSize : paddingRight,
|
|
169
|
-
|
|
171
|
+
...(_Platform.default.OS === 'android' ? {
|
|
172
|
+
paddingBottom: paddingBottom + _constants.ANDROID_VALIDATION_ICON_CONTAINER_OFFSET
|
|
173
|
+
} : {
|
|
174
|
+
paddingBottom
|
|
175
|
+
})
|
|
170
176
|
};
|
|
171
177
|
};
|
|
172
178
|
/**
|