@telus-uds/components-base 1.80.1 → 1.82.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 +30 -2
- package/lib/Autocomplete/Autocomplete.js +3 -1
- package/lib/Badge/Badge.js +1 -10
- package/lib/Fieldset/Fieldset.js +3 -1
- package/lib/Fieldset/FieldsetContainer.js +9 -2
- package/lib/Fieldset/FieldsetContainer.native.js +7 -1
- package/lib/Icon/Icon.js +24 -2
- package/lib/Listbox/Listbox.js +7 -1
- package/lib/Modal/Modal.js +40 -4
- package/lib/Modal/WebModal.js +73 -0
- package/lib/PriceLockup/PriceLockup.js +4 -1
- package/lib/PriceLockup/utils/renderFootnoteContent.js +2 -2
- package/lib/PriceLockup/utils/renderFootnoteLinks.js +2 -2
- package/lib/PriceLockup/utils/renderPrice.js +2 -2
- package/lib/PriceLockup/utils/renderTypography.js +1 -1
- package/lib/ProductCard/ProductCard.js +238 -0
- package/lib/ProductCard/dictionary.js +45 -0
- package/lib/ProductCard/index.js +10 -0
- package/lib/ProductCardGroup/ProductCardGroup.js +79 -0
- package/lib/ProductCardGroup/index.js +10 -0
- package/lib/TextInput/TextInput.js +1 -0
- package/lib/TextInput/TextInputBase.js +4 -1
- package/lib/index.js +16 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +2 -1
- package/lib/utils/ssr-media-query/utils/common.js +21 -2
- package/lib-module/Autocomplete/Autocomplete.js +3 -1
- package/lib-module/Badge/Badge.js +1 -10
- package/lib-module/Fieldset/Fieldset.js +3 -1
- package/lib-module/Fieldset/FieldsetContainer.js +7 -2
- package/lib-module/Fieldset/FieldsetContainer.native.js +10 -3
- package/lib-module/Icon/Icon.js +24 -2
- package/lib-module/Listbox/Listbox.js +7 -1
- package/lib-module/Modal/Modal.js +42 -5
- package/lib-module/Modal/WebModal.js +65 -0
- package/lib-module/PriceLockup/PriceLockup.js +4 -1
- package/lib-module/PriceLockup/utils/renderFootnoteContent.js +2 -2
- package/lib-module/PriceLockup/utils/renderFootnoteLinks.js +2 -2
- package/lib-module/PriceLockup/utils/renderPrice.js +2 -2
- package/lib-module/PriceLockup/utils/renderTypography.js +1 -1
- package/lib-module/ProductCard/ProductCard.js +231 -0
- package/lib-module/ProductCard/dictionary.js +38 -0
- package/lib-module/ProductCard/index.js +2 -0
- package/lib-module/ProductCardGroup/ProductCardGroup.js +69 -0
- package/lib-module/ProductCardGroup/index.js +2 -0
- package/lib-module/TextInput/TextInput.js +1 -0
- package/lib-module/TextInput/TextInputBase.js +4 -1
- package/lib-module/index.js +2 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.js +3 -2
- package/lib-module/utils/ssr-media-query/utils/common.js +19 -1
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +4 -1
- package/src/Badge/Badge.jsx +7 -10
- package/src/Fieldset/Fieldset.jsx +3 -1
- package/src/Fieldset/FieldsetContainer.jsx +8 -1
- package/src/Fieldset/FieldsetContainer.native.jsx +7 -2
- package/src/Icon/Icon.jsx +30 -2
- package/src/Listbox/Listbox.jsx +6 -1
- package/src/Modal/Modal.jsx +42 -3
- package/src/Modal/WebModal.jsx +60 -0
- package/src/PriceLockup/PriceLockup.jsx +8 -2
- package/src/PriceLockup/utils/renderFootnoteContent.jsx +2 -2
- package/src/PriceLockup/utils/renderFootnoteLinks.jsx +2 -2
- package/src/PriceLockup/utils/renderPrice.jsx +2 -2
- package/src/PriceLockup/utils/renderTypography.jsx +1 -1
- package/src/ProductCard/ProductCard.jsx +193 -0
- package/src/ProductCard/dictionary.js +38 -0
- package/src/ProductCard/index.js +3 -0
- package/src/ProductCardGroup/ProductCardGroup.jsx +75 -0
- package/src/ProductCardGroup/index.js +3 -0
- package/src/TextInput/TextInput.jsx +1 -0
- package/src/TextInput/TextInputBase.jsx +4 -1
- package/src/index.js +2 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.js +3 -2
- package/src/utils/ssr-media-query/utils/common.js +19 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
10
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
11
|
+
var _Image = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Image"));
|
|
12
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
14
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
15
|
+
var _utils = require("../utils");
|
|
16
|
+
var _Badge = _interopRequireDefault(require("../Badge"));
|
|
17
|
+
var _PriceLockup = _interopRequireDefault(require("../PriceLockup"));
|
|
18
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
19
|
+
var _Button = require("../Button");
|
|
20
|
+
var _StackView = _interopRequireDefault(require("../StackView"));
|
|
21
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
|
22
|
+
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
23
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.htmlAttrs, _utils.viewProps, _utils.a11yProps]);
|
|
26
|
+
const selectProductCardTokens = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
borderStyle,
|
|
29
|
+
borderColor,
|
|
30
|
+
borderWidth,
|
|
31
|
+
borderRadius,
|
|
32
|
+
paddingHorizontal,
|
|
33
|
+
paddingVertical
|
|
34
|
+
} = _ref;
|
|
35
|
+
return {
|
|
36
|
+
borderStyle,
|
|
37
|
+
borderColor,
|
|
38
|
+
borderWidth,
|
|
39
|
+
borderRadius,
|
|
40
|
+
paddingHorizontal,
|
|
41
|
+
paddingVertical
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const ProductCard = _ref2 => {
|
|
45
|
+
var _getCopy;
|
|
46
|
+
let {
|
|
47
|
+
copy = 'en',
|
|
48
|
+
dictionary = _dictionary.default,
|
|
49
|
+
image = {
|
|
50
|
+
src: '',
|
|
51
|
+
alt: ''
|
|
52
|
+
},
|
|
53
|
+
cardId,
|
|
54
|
+
isSelected,
|
|
55
|
+
onSelect,
|
|
56
|
+
tokens,
|
|
57
|
+
...rest
|
|
58
|
+
} = _ref2;
|
|
59
|
+
const viewport = (0, _ViewportProvider.useViewport)();
|
|
60
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('ProductCard', tokens, {
|
|
61
|
+
viewport
|
|
62
|
+
});
|
|
63
|
+
const getCopy = (0, _utils.useCopy)({
|
|
64
|
+
copy,
|
|
65
|
+
dictionary
|
|
66
|
+
});
|
|
67
|
+
const {
|
|
68
|
+
currentValue,
|
|
69
|
+
setValue
|
|
70
|
+
} = (0, _utils.useInputValue)();
|
|
71
|
+
const hasClicked = isSelected || currentValue;
|
|
72
|
+
const handlePress = event => {
|
|
73
|
+
if (cardId) {
|
|
74
|
+
onSelect(cardId);
|
|
75
|
+
} else {
|
|
76
|
+
setValue(!currentValue, event);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const renderButton = hasClicked ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
80
|
+
vertical: 1,
|
|
81
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
82
|
+
space: 2,
|
|
83
|
+
direction: "row",
|
|
84
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
85
|
+
icon: themeTokens.selectedButtonIcon,
|
|
86
|
+
variant: {
|
|
87
|
+
color: 'success'
|
|
88
|
+
}
|
|
89
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
90
|
+
variant: {
|
|
91
|
+
size: 'h4'
|
|
92
|
+
},
|
|
93
|
+
tokens: {
|
|
94
|
+
fontWeight: 400
|
|
95
|
+
},
|
|
96
|
+
children: getCopy('selectedButtonLabel')
|
|
97
|
+
})]
|
|
98
|
+
})
|
|
99
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
100
|
+
onPress: handlePress,
|
|
101
|
+
variant: {
|
|
102
|
+
purpose: 'primary',
|
|
103
|
+
size: 'small',
|
|
104
|
+
width: 'full'
|
|
105
|
+
},
|
|
106
|
+
children: getCopy('buttonLabel')
|
|
107
|
+
});
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
109
|
+
...selectProps(rest),
|
|
110
|
+
style: [selectProductCardTokens(themeTokens), staticStyles.container],
|
|
111
|
+
children: [image !== null && image !== void 0 && image.src ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
112
|
+
style: staticStyles.imageContainer,
|
|
113
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
|
|
114
|
+
source: image.src,
|
|
115
|
+
style: staticStyles.image,
|
|
116
|
+
alt: image.alt,
|
|
117
|
+
accessibilityLabel: image.alt,
|
|
118
|
+
resizeMethod: "resize",
|
|
119
|
+
accessibilityIgnoresInvertColors: true
|
|
120
|
+
})
|
|
121
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
122
|
+
style: staticStyles.textContainer,
|
|
123
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
124
|
+
left: 3,
|
|
125
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
126
|
+
space: 1,
|
|
127
|
+
children: [getCopy('badgeText') ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.default, {
|
|
128
|
+
variant: {
|
|
129
|
+
outline: true,
|
|
130
|
+
purpose: 'editorial'
|
|
131
|
+
},
|
|
132
|
+
children: getCopy('badgeText')
|
|
133
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
134
|
+
variant: {
|
|
135
|
+
size: 'h6'
|
|
136
|
+
},
|
|
137
|
+
children: getCopy('brandName')
|
|
138
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
139
|
+
variant: {
|
|
140
|
+
size: 'h4',
|
|
141
|
+
colour: 'brand'
|
|
142
|
+
},
|
|
143
|
+
tokens: {
|
|
144
|
+
fontWeight: 400
|
|
145
|
+
},
|
|
146
|
+
children: getCopy('productName')
|
|
147
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
148
|
+
space: 3,
|
|
149
|
+
divider: true,
|
|
150
|
+
direction: "row",
|
|
151
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PriceLockup.default, {
|
|
152
|
+
...getCopy('primaryPrice'),
|
|
153
|
+
size: "small",
|
|
154
|
+
ratePosition: "bottom"
|
|
155
|
+
}), (_getCopy = getCopy('secondaryPrice')) !== null && _getCopy !== void 0 && _getCopy.price ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_PriceLockup.default, {
|
|
156
|
+
...getCopy('secondaryPrice'),
|
|
157
|
+
size: "small",
|
|
158
|
+
ratePosition: "bottom"
|
|
159
|
+
}) : null]
|
|
160
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
161
|
+
top: 2,
|
|
162
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
163
|
+
space: 2,
|
|
164
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
165
|
+
variant: {
|
|
166
|
+
size: 'h6'
|
|
167
|
+
},
|
|
168
|
+
tokens: {
|
|
169
|
+
fontWeight: 500
|
|
170
|
+
},
|
|
171
|
+
children: getCopy('term')
|
|
172
|
+
}), getCopy('buttonLabel') ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
173
|
+
top: 1,
|
|
174
|
+
children: renderButton
|
|
175
|
+
}) : null]
|
|
176
|
+
})
|
|
177
|
+
})]
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
})]
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
ProductCard.displayName = 'ProductCard';
|
|
184
|
+
|
|
185
|
+
// If a language dictionary entry is provided, it must contain every key
|
|
186
|
+
const dictionaryContentShape = _propTypes.default.shape({
|
|
187
|
+
badgeText: _propTypes.default.string,
|
|
188
|
+
brandName: _propTypes.default.string.isRequired,
|
|
189
|
+
productName: _propTypes.default.string.isRequired,
|
|
190
|
+
primaryPrice: _propTypes.default.object.isRequired,
|
|
191
|
+
secondaryPrice: _propTypes.default.object,
|
|
192
|
+
term: _propTypes.default.string.isRequired,
|
|
193
|
+
buttonLabel: _propTypes.default.string.isRequired,
|
|
194
|
+
selectedButtonLabel: _propTypes.default.string.isRequired
|
|
195
|
+
});
|
|
196
|
+
ProductCard.propTypes = {
|
|
197
|
+
...selectedSystemPropTypes,
|
|
198
|
+
image: _propTypes.default.shape({
|
|
199
|
+
src: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
|
|
200
|
+
alt: _propTypes.default.string
|
|
201
|
+
}),
|
|
202
|
+
/**
|
|
203
|
+
* Select English or French copy for the place holder labels.
|
|
204
|
+
* You may also pass in a custom dictionary object.
|
|
205
|
+
*/
|
|
206
|
+
copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr'])]),
|
|
207
|
+
/**
|
|
208
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
209
|
+
*/
|
|
210
|
+
dictionary: _propTypes.default.shape({
|
|
211
|
+
en: dictionaryContentShape,
|
|
212
|
+
fr: dictionaryContentShape
|
|
213
|
+
}),
|
|
214
|
+
tokens: (0, _utils.getTokensPropType)('ProductCard')
|
|
215
|
+
};
|
|
216
|
+
var _default = ProductCard;
|
|
217
|
+
exports.default = _default;
|
|
218
|
+
const staticStyles = _StyleSheet.default.create({
|
|
219
|
+
container: {
|
|
220
|
+
flexDirection: 'row',
|
|
221
|
+
flex: 1
|
|
222
|
+
},
|
|
223
|
+
imageContainer: {
|
|
224
|
+
width: '30%',
|
|
225
|
+
minWidth: 96,
|
|
226
|
+
maxWidth: 96
|
|
227
|
+
},
|
|
228
|
+
image: {
|
|
229
|
+
resizeMode: 'contain',
|
|
230
|
+
width: '100%',
|
|
231
|
+
height: undefined,
|
|
232
|
+
// This is to maintain the aspect ratio
|
|
233
|
+
aspectRatio: 0.8
|
|
234
|
+
},
|
|
235
|
+
textContainer: {
|
|
236
|
+
width: '70%'
|
|
237
|
+
}
|
|
238
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
en: {
|
|
9
|
+
badgeText: '',
|
|
10
|
+
brandName: 'Brand name',
|
|
11
|
+
productName: 'Product name',
|
|
12
|
+
primaryPrice: {
|
|
13
|
+
price: '00',
|
|
14
|
+
signDirection: 'left',
|
|
15
|
+
rateText: '/month'
|
|
16
|
+
},
|
|
17
|
+
secondaryPrice: {
|
|
18
|
+
price: '',
|
|
19
|
+
signDirection: 'left',
|
|
20
|
+
rateText: 'Upfront'
|
|
21
|
+
},
|
|
22
|
+
term: '24 months | 0% APR Bring-it-Back applied',
|
|
23
|
+
buttonLabel: 'Select this phone',
|
|
24
|
+
selectedButtonLabel: 'Selected phone'
|
|
25
|
+
},
|
|
26
|
+
fr: {
|
|
27
|
+
badgeText: '',
|
|
28
|
+
brandName: 'Brand name',
|
|
29
|
+
productName: 'Product name',
|
|
30
|
+
primaryPrice: {
|
|
31
|
+
price: '00',
|
|
32
|
+
signDirection: 'right',
|
|
33
|
+
rateText: '/mois'
|
|
34
|
+
},
|
|
35
|
+
secondaryPrice: {
|
|
36
|
+
price: '',
|
|
37
|
+
signDirection: 'right',
|
|
38
|
+
rateText: "d'acompte"
|
|
39
|
+
},
|
|
40
|
+
term: '24 mois | TAP de 0% | avec Option retour',
|
|
41
|
+
buttonLabel: 'Sélectionner ce téléphone',
|
|
42
|
+
selectedButtonLabel: 'Téléphone sélectionné'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.default = _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ProductCard = _interopRequireDefault(require("./ProductCard"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _ProductCard.default;
|
|
10
|
+
exports.default = _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
var _ProductCard = _interopRequireDefault(require("../ProductCard"));
|
|
12
|
+
var _StackView = require("../StackView");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.htmlAttrs, _utils.viewProps, _utils.a11yProps]);
|
|
18
|
+
const ProductCardGroup = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
productCards,
|
|
21
|
+
maxSelection = 1,
|
|
22
|
+
...rest
|
|
23
|
+
} = _ref;
|
|
24
|
+
const [selectedCardIds, setSelectedCardIds] = (0, _react.useState)([]);
|
|
25
|
+
const handleSelect = id => {
|
|
26
|
+
const isAlreadySelected = selectedCardIds.includes(id);
|
|
27
|
+
let updatedSelectedCardIds;
|
|
28
|
+
if (isAlreadySelected) {
|
|
29
|
+
updatedSelectedCardIds = selectedCardIds.filter(cardId => cardId !== id);
|
|
30
|
+
} else if (maxSelection && selectedCardIds.length >= maxSelection) {
|
|
31
|
+
updatedSelectedCardIds = selectedCardIds.filter((_, index) => index !== 0).concat(id);
|
|
32
|
+
} else {
|
|
33
|
+
updatedSelectedCardIds = [...selectedCardIds, id];
|
|
34
|
+
}
|
|
35
|
+
setSelectedCardIds(updatedSelectedCardIds);
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
38
|
+
...selectProps(rest),
|
|
39
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, {
|
|
40
|
+
direction: {
|
|
41
|
+
xs: 'column',
|
|
42
|
+
lg: 'row'
|
|
43
|
+
},
|
|
44
|
+
space: 4,
|
|
45
|
+
children: productCards.map((cardProperties, index) => {
|
|
46
|
+
const cardId = cardProperties.id || index;
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
48
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductCard.default, {
|
|
49
|
+
cardId: cardId,
|
|
50
|
+
isSelected: selectedCardIds.includes(cardId),
|
|
51
|
+
onSelect: handleSelect,
|
|
52
|
+
...cardProperties
|
|
53
|
+
}, cardId)
|
|
54
|
+
}, cardId);
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
ProductCardGroup.displayName = 'ProductCardGroup';
|
|
60
|
+
ProductCardGroup.propTypes = {
|
|
61
|
+
...selectedSystemPropTypes,
|
|
62
|
+
/**
|
|
63
|
+
* The maximum number of ProductCards a user may select at once. Defaults to 1.
|
|
64
|
+
* To have no limit and allow any number of selections, pass `null`.
|
|
65
|
+
*/
|
|
66
|
+
maxSelection: _propTypes.default.number,
|
|
67
|
+
/**
|
|
68
|
+
* Props to be passed to the `ProductCard` component.
|
|
69
|
+
* id is required for each card.
|
|
70
|
+
* You may also pass in a custom dictionary object.
|
|
71
|
+
*/
|
|
72
|
+
productCards: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
73
|
+
id: _propTypes.default.string.isRequired,
|
|
74
|
+
image: _propTypes.default.object,
|
|
75
|
+
dictionary: _propTypes.default.object
|
|
76
|
+
})).isRequired
|
|
77
|
+
};
|
|
78
|
+
var _default = ProductCardGroup;
|
|
79
|
+
exports.default = _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ProductCardGroup = _interopRequireDefault(require("./ProductCardGroup"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _ProductCardGroup.default;
|
|
10
|
+
exports.default = _default;
|
|
@@ -80,6 +80,7 @@ TextInput.propTypes = {
|
|
|
80
80
|
* A callback which if provided will get a clear button rendered and will be called whenever that button gets pressed.
|
|
81
81
|
*/
|
|
82
82
|
onClear: _propTypes.default.func,
|
|
83
|
+
onKeyPress: _propTypes.default.func,
|
|
83
84
|
tokens: (0, _utils.getTokensPropType)('TextInput'),
|
|
84
85
|
variant: _utils.variantProp.propType
|
|
85
86
|
};
|
|
@@ -203,6 +203,7 @@ const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)((_ref7, ref) => {
|
|
|
203
203
|
value,
|
|
204
204
|
variant = {},
|
|
205
205
|
type,
|
|
206
|
+
onKeyPress,
|
|
206
207
|
...rest
|
|
207
208
|
} = _ref7;
|
|
208
209
|
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
@@ -335,7 +336,8 @@ const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)((_ref7, ref) => {
|
|
|
335
336
|
onChange: handleChangeText,
|
|
336
337
|
defaultValue: initialValue,
|
|
337
338
|
maxLength: type === 'card' ? 19 : undefined,
|
|
338
|
-
value: isControlled ? currentValue : undefined
|
|
339
|
+
value: isControlled ? currentValue : undefined,
|
|
340
|
+
onKeyPress
|
|
339
341
|
};
|
|
340
342
|
const {
|
|
341
343
|
themeOptions
|
|
@@ -404,6 +406,7 @@ TextInputBase.propTypes = {
|
|
|
404
406
|
onFocus: _propTypes.default.func,
|
|
405
407
|
onMouseOut: _propTypes.default.func,
|
|
406
408
|
onMouseOver: _propTypes.default.func,
|
|
409
|
+
onKeyPress: _propTypes.default.func,
|
|
407
410
|
readOnly: _propTypes.default.bool,
|
|
408
411
|
tokens: (0, _utils.getTokensPropType)('TextInput', 'TextArea'),
|
|
409
412
|
value: _propTypes.default.string,
|
package/lib/index.js
CHANGED
|
@@ -37,6 +37,8 @@ var _exportNames = {
|
|
|
37
37
|
OrderedList: true,
|
|
38
38
|
Pagination: true,
|
|
39
39
|
PriceLockup: true,
|
|
40
|
+
ProductCard: true,
|
|
41
|
+
ProductCardGroup: true,
|
|
40
42
|
Progress: true,
|
|
41
43
|
QuickLinks: true,
|
|
42
44
|
QuickLinksFeature: true,
|
|
@@ -292,6 +294,18 @@ Object.defineProperty(exports, "PriceLockup", {
|
|
|
292
294
|
return _PriceLockup.default;
|
|
293
295
|
}
|
|
294
296
|
});
|
|
297
|
+
Object.defineProperty(exports, "ProductCard", {
|
|
298
|
+
enumerable: true,
|
|
299
|
+
get: function () {
|
|
300
|
+
return _ProductCard.default;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
Object.defineProperty(exports, "ProductCardGroup", {
|
|
304
|
+
enumerable: true,
|
|
305
|
+
get: function () {
|
|
306
|
+
return _ProductCardGroup.default;
|
|
307
|
+
}
|
|
308
|
+
});
|
|
295
309
|
Object.defineProperty(exports, "Progress", {
|
|
296
310
|
enumerable: true,
|
|
297
311
|
get: function () {
|
|
@@ -600,6 +614,8 @@ var _Notification = _interopRequireDefault(require("./Notification"));
|
|
|
600
614
|
var _OrderedList = _interopRequireDefault(require("./OrderedList"));
|
|
601
615
|
var _Pagination = _interopRequireDefault(require("./Pagination"));
|
|
602
616
|
var _PriceLockup = _interopRequireDefault(require("./PriceLockup"));
|
|
617
|
+
var _ProductCard = _interopRequireDefault(require("./ProductCard"));
|
|
618
|
+
var _ProductCardGroup = _interopRequireDefault(require("./ProductCardGroup"));
|
|
603
619
|
var _Progress = _interopRequireDefault(require("./Progress"));
|
|
604
620
|
var _QuickLinks = _interopRequireDefault(require("./QuickLinks"));
|
|
605
621
|
var _QuickLinksFeature = _interopRequireDefault(require("./QuickLinksFeature"));
|
|
@@ -22,7 +22,8 @@ const createStyleSheet = stylesWithQuery => {
|
|
|
22
22
|
const mediaQueriesAndPseudoClasses = Object.keys(stylesWithQuery[key]).filter(_common.isMediaOrPseudo);
|
|
23
23
|
mediaQueriesAndPseudoClasses.forEach(query => {
|
|
24
24
|
var _ids;
|
|
25
|
-
const
|
|
25
|
+
const sanitizedStyle = (0, _common.sanitizeStyle)(stylesWithQuery[key][query]);
|
|
26
|
+
const css = (0, _createDeclarationBlock.default)(sanitizedStyle);
|
|
26
27
|
const stringHash = `rnmq-${(0, _hash.default)(`${key}${query}${css}`)}`;
|
|
27
28
|
const rule = (0, _common.createCssRule)(query, stringHash, css);
|
|
28
29
|
(0, _inject.addCss)(`${stringHash}`, rule);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isPseudo = exports.isMediaOrPseudo = exports.isMedia = exports.deepClone = exports.createCssRule = void 0;
|
|
6
|
+
exports.sanitizeStyle = exports.isPseudo = exports.isMediaOrPseudo = exports.isMedia = exports.deepClone = exports.createCssRule = void 0;
|
|
7
7
|
const isMedia = query => query.indexOf('@media') === 0;
|
|
8
8
|
exports.isMedia = isMedia;
|
|
9
9
|
const isPseudo = query => query.indexOf(':') === 0;
|
|
@@ -22,4 +22,23 @@ const createCssRule = (query, stringHash, css) => {
|
|
|
22
22
|
}
|
|
23
23
|
return rule;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sanitizes the style object by converting any functions to their string representation.
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} style - The style object to sanitize.
|
|
30
|
+
* @returns {Object} - The sanitized style object.
|
|
31
|
+
*/
|
|
32
|
+
exports.createCssRule = createCssRule;
|
|
33
|
+
const sanitizeStyle = style => {
|
|
34
|
+
const sanitizedStyle = {
|
|
35
|
+
...style
|
|
36
|
+
};
|
|
37
|
+
Object.keys(sanitizedStyle).forEach(property => {
|
|
38
|
+
if (typeof sanitizedStyle[property] === 'function') {
|
|
39
|
+
sanitizedStyle[property] = sanitizedStyle[property].toString();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return sanitizedStyle;
|
|
43
|
+
};
|
|
44
|
+
exports.sanitizeStyle = sanitizeStyle;
|
|
@@ -239,6 +239,7 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
239
239
|
setCurrentValue(newValue);
|
|
240
240
|
if (!isControlled && inputRef !== null && inputRef !== void 0 && inputRef.current) inputRef.current.value = newValue;
|
|
241
241
|
if (nested) setNestedSelectedValue(newValue);
|
|
242
|
+
inputRef.current.focus();
|
|
242
243
|
};
|
|
243
244
|
|
|
244
245
|
/**
|
|
@@ -268,7 +269,8 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
268
269
|
if (event.type === 'keydown' && (event.key === 'Escape' || event.key === '27') || event.type === 'click' && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target)) || event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
|
|
269
270
|
setIsExpanded(false);
|
|
270
271
|
setNestedSelectedValue(null);
|
|
271
|
-
} else if (event.type === 'keydown' && event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
|
|
272
|
+
} else if (event.type === 'keydown' && (event.key === 'ArrowDown' || event.key === 'Tab') && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
|
|
273
|
+
event.preventDefault();
|
|
272
274
|
targetRef.current.focus();
|
|
273
275
|
}
|
|
274
276
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import View from "react-native-web/dist/exports/View";
|
|
3
3
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
-
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import { useThemeTokens } from '../ThemeProvider';
|
|
7
6
|
import Typography from '../Typography';
|
|
@@ -77,15 +76,7 @@ const Badge = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
|
77
76
|
const themeTokens = useThemeTokens('Badge', tokens, variant);
|
|
78
77
|
return /*#__PURE__*/_jsx(View, {
|
|
79
78
|
ref: ref,
|
|
80
|
-
style:
|
|
81
|
-
native: {
|
|
82
|
-
...staticStyles.container,
|
|
83
|
-
...selectContainerBackground(themeTokens),
|
|
84
|
-
...selectContainerBorder(themeTokens),
|
|
85
|
-
...selectContainerPadding(themeTokens)
|
|
86
|
-
},
|
|
87
|
-
web: {}
|
|
88
|
-
}),
|
|
79
|
+
style: [staticStyles.container, selectContainerBackground(themeTokens), selectContainerBorder(themeTokens), selectContainerPadding(themeTokens)],
|
|
89
80
|
...selectProps(rest),
|
|
90
81
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
91
82
|
tokens: getTypographyTokens(themeTokens),
|
|
@@ -34,7 +34,8 @@ const Fieldset = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
34
34
|
name: fieldsetName,
|
|
35
35
|
children,
|
|
36
36
|
variant = {},
|
|
37
|
-
tokens = {}
|
|
37
|
+
tokens = {},
|
|
38
|
+
...rest
|
|
38
39
|
} = _ref;
|
|
39
40
|
/* Fieldset tokenization:
|
|
40
41
|
- error variant can only be activated by passing showErrorBorder and also having validaton as 'error'
|
|
@@ -120,6 +121,7 @@ const Fieldset = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
120
121
|
name: fieldsetName,
|
|
121
122
|
borderStyle: borderStyles(themeTokens),
|
|
122
123
|
showBorderStyle: showErrorBorder,
|
|
124
|
+
...rest,
|
|
123
125
|
children: stackedContent
|
|
124
126
|
});
|
|
125
127
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import cssReset from './cssReset';
|
|
4
|
+
import { selectSystemProps, a11yProps, htmlAttrs } from '../utils';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, htmlAttrs]);
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* On Web, wraps children with a HTML `<fieldset>` and sets its attributes as necessary.
|
|
7
10
|
*/
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
11
|
const FieldsetContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
10
12
|
let {
|
|
11
13
|
children,
|
|
@@ -13,7 +15,8 @@ const FieldsetContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
13
15
|
accessibilityRole,
|
|
14
16
|
name: fieldsetName,
|
|
15
17
|
showBorderStyle = false,
|
|
16
|
-
borderStyle
|
|
18
|
+
borderStyle,
|
|
19
|
+
...rest
|
|
17
20
|
} = _ref;
|
|
18
21
|
// If needs border for error design or reset the component style
|
|
19
22
|
const styleContainer = showBorderStyle && borderStyle ? borderStyle : cssReset;
|
|
@@ -23,11 +26,13 @@ const FieldsetContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
23
26
|
style: styleContainer,
|
|
24
27
|
role: accessibilityRole,
|
|
25
28
|
name: fieldsetName,
|
|
29
|
+
...selectProps(rest),
|
|
26
30
|
children: children
|
|
27
31
|
});
|
|
28
32
|
});
|
|
29
33
|
FieldsetContainer.displayName = 'FieldsetContainer';
|
|
30
34
|
FieldsetContainer.propTypes = {
|
|
35
|
+
...selectedSystemPropTypes,
|
|
31
36
|
accessibilityRole: PropTypes.string,
|
|
32
37
|
children: PropTypes.node,
|
|
33
38
|
inactive: PropTypes.bool,
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import View from "react-native-web/dist/exports/View";
|
|
4
|
-
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import { selectSystemProps, a11yProps, viewProps } from '../utils';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
7
|
+
|
|
8
|
+
// No equivalent of `<fieldset>` on native, so just apply accessibility role to container.
|
|
9
|
+
// If a11y testing finds any additional handling is needed at the container level, add it here.
|
|
6
10
|
const FieldsetContainer = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
7
11
|
let {
|
|
8
12
|
children,
|
|
9
|
-
accessibilityRole
|
|
13
|
+
accessibilityRole,
|
|
14
|
+
...rest
|
|
10
15
|
} = _ref;
|
|
11
16
|
return /*#__PURE__*/_jsx(View, {
|
|
12
17
|
ref: ref,
|
|
13
18
|
accessibilityRole: accessibilityRole,
|
|
19
|
+
...selectProps(rest),
|
|
14
20
|
children: children
|
|
15
21
|
});
|
|
16
22
|
});
|
|
17
23
|
FieldsetContainer.displayName = 'FieldsetContainer';
|
|
18
24
|
FieldsetContainer.propTypes = {
|
|
25
|
+
...selectedSystemPropTypes,
|
|
19
26
|
children: PropTypes.node,
|
|
20
27
|
accessibilityRole: PropTypes.string
|
|
21
28
|
};
|