@telus-uds/components-base 1.86.0 → 1.88.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 +34 -2
- package/lib/ActionCard/ActionCard.js +350 -0
- package/lib/ActionCard/index.js +10 -0
- package/lib/Card/Card.js +3 -3
- package/lib/Card/PressableCardBase.js +1 -1
- package/lib/Checkbox/Checkbox.js +4 -0
- package/lib/List/List.js +9 -2
- package/lib/Modal/WebModal.js +2 -1
- package/lib/Notification/Notification.js +20 -15
- package/lib/OrderedList/Item.js +14 -23
- package/lib/Radio/Radio.js +4 -0
- package/lib/Radio/RadioGroup.js +1 -1
- package/lib/Tabs/Tabs.js +4 -1
- package/lib/Tabs/TabsItem.js +7 -1
- package/lib/Validator/Validator.js +18 -9
- package/lib/index.js +8 -0
- package/lib/utils/animation/useVerticalExpandAnimation.js +3 -3
- package/lib/utils/props/tokens.js +2 -2
- package/lib-module/ActionCard/ActionCard.js +343 -0
- package/lib-module/ActionCard/index.js +2 -0
- package/lib-module/Card/Card.js +4 -4
- package/lib-module/Card/PressableCardBase.js +1 -1
- package/lib-module/Checkbox/Checkbox.js +4 -0
- package/lib-module/List/List.js +9 -2
- package/lib-module/Modal/WebModal.js +2 -1
- package/lib-module/Notification/Notification.js +20 -15
- package/lib-module/OrderedList/Item.js +14 -23
- package/lib-module/Radio/Radio.js +4 -0
- package/lib-module/Radio/RadioGroup.js +1 -1
- package/lib-module/Tabs/Tabs.js +4 -1
- package/lib-module/Tabs/TabsItem.js +7 -1
- package/lib-module/Validator/Validator.js +18 -9
- package/lib-module/index.js +1 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +3 -3
- package/lib-module/utils/props/tokens.js +2 -2
- package/package.json +2 -2
- package/src/ActionCard/ActionCard.jsx +306 -0
- package/src/ActionCard/index.js +3 -0
- package/src/Card/Card.jsx +6 -4
- package/src/Card/PressableCardBase.jsx +1 -1
- package/src/Checkbox/Checkbox.jsx +3 -1
- package/src/List/List.jsx +7 -2
- package/src/Modal/WebModal.jsx +2 -1
- package/src/Notification/Notification.jsx +36 -16
- package/src/OrderedList/Item.jsx +12 -16
- package/src/Radio/Radio.jsx +3 -1
- package/src/Radio/RadioGroup.jsx +1 -1
- package/src/Tabs/Tabs.jsx +4 -1
- package/src/Tabs/TabsItem.jsx +5 -1
- package/src/Validator/Validator.jsx +21 -9
- package/src/index.js +1 -0
- package/src/utils/animation/useVerticalExpandAnimation.js +3 -3
- package/src/utils/props/tokens.js +4 -2
package/lib/Radio/Radio.js
CHANGED
|
@@ -172,6 +172,7 @@ const Radio = /*#__PURE__*/_react.default.forwardRef((_ref4, ref) => {
|
|
|
172
172
|
onKeyDown: handleKeyDown,
|
|
173
173
|
onPress: handleChange,
|
|
174
174
|
...selectedProps,
|
|
175
|
+
style: staticStyles.removeOutline,
|
|
175
176
|
children: _ref5 => {
|
|
176
177
|
let {
|
|
177
178
|
focused: focus,
|
|
@@ -284,5 +285,8 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
284
285
|
alignWithLabel: {
|
|
285
286
|
alignSelf: 'flex-start',
|
|
286
287
|
justifyContent: 'center'
|
|
288
|
+
},
|
|
289
|
+
removeOutline: {
|
|
290
|
+
outlineStyle: 'none'
|
|
287
291
|
}
|
|
288
292
|
});
|
package/lib/Radio/RadioGroup.js
CHANGED
|
@@ -121,7 +121,7 @@ const RadioGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
121
121
|
onChange,
|
|
122
122
|
readOnly: readOnly || inactive
|
|
123
123
|
});
|
|
124
|
-
const uniqueFields = ['id'
|
|
124
|
+
const uniqueFields = ['id'];
|
|
125
125
|
if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
|
|
126
126
|
throw new Error(`RadioGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
127
127
|
}
|
package/lib/Tabs/Tabs.js
CHANGED
|
@@ -115,6 +115,7 @@ const Tabs = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
115
115
|
ref: itemRef,
|
|
116
116
|
LinkRouter: ItemLinkRouter = LinkRouter,
|
|
117
117
|
linkRouterProps: itemLinkRouterProps,
|
|
118
|
+
render,
|
|
118
119
|
...itemRest
|
|
119
120
|
} = _ref3;
|
|
120
121
|
const itemId = id ?? label;
|
|
@@ -140,6 +141,7 @@ const Tabs = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
140
141
|
...linkRouterProps,
|
|
141
142
|
...itemLinkRouterProps
|
|
142
143
|
},
|
|
144
|
+
render: render,
|
|
143
145
|
...itemProps,
|
|
144
146
|
children: label
|
|
145
147
|
}, itemId);
|
|
@@ -160,7 +162,8 @@ Tabs.propTypes = {
|
|
|
160
162
|
href: _propTypes.default.string,
|
|
161
163
|
label: _propTypes.default.string,
|
|
162
164
|
id: _propTypes.default.string,
|
|
163
|
-
ref: _airbnbPropTypes.default.ref()
|
|
165
|
+
ref: _airbnbPropTypes.default.ref(),
|
|
166
|
+
render: _propTypes.default.func
|
|
164
167
|
})),
|
|
165
168
|
/**
|
|
166
169
|
* `id` property of the current tab in the items array
|
package/lib/Tabs/TabsItem.js
CHANGED
|
@@ -101,6 +101,7 @@ const TabsItem = /*#__PURE__*/_react.default.forwardRef((_ref4, ref) => {
|
|
|
101
101
|
selected
|
|
102
102
|
} : undefined,
|
|
103
103
|
id,
|
|
104
|
+
render,
|
|
104
105
|
...rawRest
|
|
105
106
|
} = _ref4;
|
|
106
107
|
// Convert onClick etc to onPress etc if used in an integration
|
|
@@ -156,6 +157,10 @@ const TabsItem = /*#__PURE__*/_react.default.forwardRef((_ref4, ref) => {
|
|
|
156
157
|
}
|
|
157
158
|
// itemPositions is a ref object so this should only re-run when `selected` (or `index`) change
|
|
158
159
|
}, [selected, index, itemPositions]);
|
|
160
|
+
if (render) return render({
|
|
161
|
+
selected,
|
|
162
|
+
handlePress
|
|
163
|
+
});
|
|
159
164
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
160
165
|
ref: ref,
|
|
161
166
|
onPress: handlePress,
|
|
@@ -213,7 +218,8 @@ TabsItem.propTypes = {
|
|
|
213
218
|
selected: _propTypes.default.bool,
|
|
214
219
|
itemPositions: itemPositionsPropType,
|
|
215
220
|
children: _propTypes.default.string,
|
|
216
|
-
id: _propTypes.default.string
|
|
221
|
+
id: _propTypes.default.string,
|
|
222
|
+
render: _propTypes.default.func
|
|
217
223
|
};
|
|
218
224
|
const staticStyles = _StyleSheet.default.create({
|
|
219
225
|
center: {
|
|
@@ -32,6 +32,7 @@ const Validator = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
32
32
|
let {
|
|
33
33
|
value = '',
|
|
34
34
|
inactive,
|
|
35
|
+
mask = '',
|
|
35
36
|
onChange,
|
|
36
37
|
tokens = {},
|
|
37
38
|
variant = {},
|
|
@@ -77,32 +78,36 @@ const Validator = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
77
78
|
[codeId]: val
|
|
78
79
|
});
|
|
79
80
|
};
|
|
81
|
+
const changeDataMasking = boxElement => {
|
|
82
|
+
let charMasking = '';
|
|
83
|
+
const element = boxElement;
|
|
84
|
+
if (mask && mask.length === 1) charMasking = mask;else if (mask && mask.length > 1) charMasking = mask.substring(0, 1);
|
|
85
|
+
if (charMasking) element.value = charMasking;
|
|
86
|
+
};
|
|
80
87
|
const handleChangeCode = () => {
|
|
81
88
|
let code = '';
|
|
82
89
|
for (let i = 0; i < validatorsLength; i += 1) code += singleCodes[prefix + i];
|
|
83
90
|
if (typeof onChange === 'function') onChange(code, singleCodes);
|
|
84
91
|
};
|
|
85
92
|
const handleChangeCodeValues = (event, codeId, nextIndex) => {
|
|
86
|
-
var _codeReferences$codeI, _event$nativeEvent, _event$target, _codeElement$value
|
|
93
|
+
var _codeReferences$codeI, _event$nativeEvent, _event$target, _codeElement$value;
|
|
87
94
|
const codeElement = (_codeReferences$codeI = codeReferences[codeId]) === null || _codeReferences$codeI === void 0 ? void 0 : _codeReferences$codeI.current;
|
|
88
95
|
const val = ((_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.value) || ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
|
|
89
96
|
if (Number(val).toString() === 'NaN') {
|
|
90
97
|
codeElement.value = singleCodes[codeId] ?? '';
|
|
91
98
|
return;
|
|
92
99
|
}
|
|
93
|
-
if ((codeElement === null || codeElement === void 0 ? void 0 : (_codeElement$value = codeElement.value) === null || _codeElement$value === void 0 ? void 0 : _codeElement$value.length) > 1) {
|
|
94
|
-
const oldValue = singleCodes[codeId];
|
|
95
|
-
const newValue = codeElement.value.replace(oldValue, '');
|
|
96
|
-
codeElement.value = newValue;
|
|
97
|
-
handleSingleCodes(codeId, codeElement.value, 'success');
|
|
98
|
-
}
|
|
99
100
|
handleSingleCodes(codeId, (codeElement === null || codeElement === void 0 ? void 0 : codeElement.value) ?? singleCodes[codeId], 'success');
|
|
100
101
|
handleChangeCode();
|
|
101
102
|
if (nextIndex === validatorsLength) {
|
|
102
103
|
codeElement.blur();
|
|
104
|
+
changeDataMasking(codeElement);
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
|
-
if ((codeElement === null || codeElement === void 0 ? void 0 : (_codeElement$
|
|
107
|
+
if ((codeElement === null || codeElement === void 0 ? void 0 : (_codeElement$value = codeElement.value) === null || _codeElement$value === void 0 ? void 0 : _codeElement$value.length) > 0) {
|
|
108
|
+
codeReferences[prefix + nextIndex].current.focus();
|
|
109
|
+
changeDataMasking(codeElement);
|
|
110
|
+
}
|
|
106
111
|
};
|
|
107
112
|
const handleKeyPress = (event, currentIndex, previousIndex) => {
|
|
108
113
|
if (!(event.keyCode === 8 || event.code === 'Backspace')) return;
|
|
@@ -150,7 +155,7 @@ const Validator = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
150
155
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
151
156
|
_react.default.useEffect(() => {
|
|
152
157
|
for (let i = 0; i < validatorsLength; i += 1) {
|
|
153
|
-
codeReferences[prefix + i].current.value = text[i] ?? '';
|
|
158
|
+
if (mask && text[i]) codeReferences[prefix + i].current.value = mask;else codeReferences[prefix + i].current.value = text[i] ?? '';
|
|
154
159
|
handleSingleCodes(prefix + i, text[i] ?? '', text[i] ? 'success' : '');
|
|
155
160
|
}
|
|
156
161
|
}, [text]);
|
|
@@ -207,6 +212,10 @@ Validator.propTypes = {
|
|
|
207
212
|
* If true, the component is inactive and non editable.
|
|
208
213
|
*/
|
|
209
214
|
inactive: _propTypes.default.bool,
|
|
215
|
+
/**
|
|
216
|
+
* Show masked characters and obscure the actual input. For example: '*'
|
|
217
|
+
*/
|
|
218
|
+
mask: _propTypes.default.string,
|
|
210
219
|
/**
|
|
211
220
|
* Use to react upon input's value changes. Required when the `value` prop is set. Will receive the input's value as an argument.
|
|
212
221
|
*/
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
A11yText: true,
|
|
8
|
+
ActionCard: true,
|
|
8
9
|
ActivityIndicator: true,
|
|
9
10
|
Autocomplete: true,
|
|
10
11
|
Box: true,
|
|
@@ -97,6 +98,12 @@ Object.defineProperty(exports, "Accordion", {
|
|
|
97
98
|
return _ExpandCollapse.Accordion;
|
|
98
99
|
}
|
|
99
100
|
});
|
|
101
|
+
Object.defineProperty(exports, "ActionCard", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return _ActionCard.default;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
100
107
|
Object.defineProperty(exports, "ActivityIndicator", {
|
|
101
108
|
enumerable: true,
|
|
102
109
|
get: function () {
|
|
@@ -524,6 +531,7 @@ Object.defineProperty(exports, "useViewport", {
|
|
|
524
531
|
}
|
|
525
532
|
});
|
|
526
533
|
var _A11yText = _interopRequireDefault(require("./A11yText"));
|
|
534
|
+
var _ActionCard = _interopRequireDefault(require("./ActionCard"));
|
|
527
535
|
var _ActivityIndicator = _interopRequireDefault(require("./ActivityIndicator"));
|
|
528
536
|
var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
|
|
529
537
|
var _Box = _interopRequireDefault(require("./Box"));
|
|
@@ -58,8 +58,8 @@ function useVerticalExpandAnimation(_ref) {
|
|
|
58
58
|
if (isAnimating || expandStateChanged) containerStyles.overflow = 'hidden';
|
|
59
59
|
if (!isExpanded && !isAnimating && !expandStateChanged) {
|
|
60
60
|
if (_Platform.default.OS === 'web') {
|
|
61
|
-
// Without `
|
|
62
|
-
containerStyles.
|
|
61
|
+
// Without `display: 'none', descendents are focusable on web even when collapsed.
|
|
62
|
+
containerStyles.display = 'none';
|
|
63
63
|
} else {
|
|
64
64
|
// There's no `visibility: hidden` in React Native, and display: none causes a flicker on expand.
|
|
65
65
|
// Without some form of hiding, some children leak through even when closed e.g. `List.Item` bullets.
|
|
@@ -73,7 +73,7 @@ function useVerticalExpandAnimation(_ref) {
|
|
|
73
73
|
// on web we can hide the contents until we have the container measured and avoid occasional jitter
|
|
74
74
|
// this won't work on native platforms
|
|
75
75
|
containerStyles.height = 0;
|
|
76
|
-
containerStyles.
|
|
76
|
+
containerStyles.display = 'none';
|
|
77
77
|
}
|
|
78
78
|
} else if (_Platform.default.OS === 'web') {
|
|
79
79
|
const transitionDuration = isExpanded ? expandDuration : collapseDuration;
|
|
@@ -113,7 +113,7 @@ const getTokensPropType = function () {
|
|
|
113
113
|
* For example, for a set of tokens used in a common style, or for a set of tokens required by
|
|
114
114
|
* a themeless component whose tokens are set by a parent but requires tokens of a certain shape.
|
|
115
115
|
*
|
|
116
|
-
* By default, requires an object with a complete set of tokens (allowing `null
|
|
116
|
+
* By default, requires an object with a complete set of tokens (allowing `null` and `undefined`).
|
|
117
117
|
*
|
|
118
118
|
* @param {string[]} componentTokenKeys - array of strings of token names
|
|
119
119
|
* @param {object} [options]
|
|
@@ -133,7 +133,7 @@ const getTokensSetPropType = function (componentTokenKeys) {
|
|
|
133
133
|
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
134
134
|
args[_key2 - 2] = arguments[_key2];
|
|
135
135
|
}
|
|
136
|
-
return props[propName] !== null && tokenValueType.isRequired(props, propName, ...args);
|
|
136
|
+
return props[propName] !== null && props[propName] !== undefined && tokenValueType.isRequired(props, propName, ...args);
|
|
137
137
|
}])));
|
|
138
138
|
return allowFunction ? _propTypes.default.oneOfType([tokensObjectValidator, _propTypes.default.func]) : tokensObjectValidator;
|
|
139
139
|
};
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Animated from "react-native-web/dist/exports/Animated";
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { applyTextStyles, useThemeTokens } from '../ThemeProvider';
|
|
8
|
+
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps, wrapStringsInText, clickProps, hrefAttrsProp, linkProps } from '../utils';
|
|
9
|
+
import Icon from '../Icon';
|
|
10
|
+
import Card from '../Card';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps]);
|
|
14
|
+
const selectCardStyles = styles => ['borderColor', 'borderRadius', 'borderWidth'].reduce((acc, key) => {
|
|
15
|
+
if (styles[key]) acc[key] = styles[key];
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
const selectInteractiveCardStyles = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
backgroundColor,
|
|
21
|
+
paddingBottom,
|
|
22
|
+
paddingLeft,
|
|
23
|
+
paddingRight,
|
|
24
|
+
paddingTop
|
|
25
|
+
} = _ref;
|
|
26
|
+
return {
|
|
27
|
+
...(backgroundColor && {
|
|
28
|
+
backgroundColor
|
|
29
|
+
}),
|
|
30
|
+
paddingBottom,
|
|
31
|
+
paddingLeft,
|
|
32
|
+
paddingRight,
|
|
33
|
+
paddingTop
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const selectIconStyles = _ref2 => {
|
|
37
|
+
let {
|
|
38
|
+
iconMarginBottom,
|
|
39
|
+
iconMarginLeft,
|
|
40
|
+
iconMarginRight,
|
|
41
|
+
iconMarginTop
|
|
42
|
+
} = _ref2;
|
|
43
|
+
return {
|
|
44
|
+
marginBottom: iconMarginBottom,
|
|
45
|
+
marginLeft: iconMarginLeft,
|
|
46
|
+
marginRight: iconMarginRight,
|
|
47
|
+
marginTop: iconMarginTop
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const selectIconProps = _ref3 => {
|
|
51
|
+
let {
|
|
52
|
+
icon,
|
|
53
|
+
iconBackgroundColor,
|
|
54
|
+
iconColor
|
|
55
|
+
} = _ref3;
|
|
56
|
+
return {
|
|
57
|
+
icon,
|
|
58
|
+
variant: {
|
|
59
|
+
background: true,
|
|
60
|
+
padding: 'small'
|
|
61
|
+
},
|
|
62
|
+
tokens: {
|
|
63
|
+
backgroundColor: iconBackgroundColor,
|
|
64
|
+
color: iconColor
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const selectTitleStyles = _ref4 => {
|
|
69
|
+
let {
|
|
70
|
+
titleMarginBottom,
|
|
71
|
+
titleMarginLeft,
|
|
72
|
+
titleMarginRight,
|
|
73
|
+
titleMarginTop
|
|
74
|
+
} = _ref4;
|
|
75
|
+
return {
|
|
76
|
+
marginBottom: titleMarginBottom,
|
|
77
|
+
marginLeft: titleMarginLeft,
|
|
78
|
+
marginRight: titleMarginRight,
|
|
79
|
+
marginTop: titleMarginTop
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const selectTitleTextStyles = _ref5 => {
|
|
83
|
+
let {
|
|
84
|
+
titleFontColor,
|
|
85
|
+
titleFontName,
|
|
86
|
+
titleFontSize,
|
|
87
|
+
titleFontWeight,
|
|
88
|
+
titleLineHeight
|
|
89
|
+
} = _ref5;
|
|
90
|
+
return applyTextStyles({
|
|
91
|
+
fontColor: titleFontColor,
|
|
92
|
+
fontName: titleFontName,
|
|
93
|
+
fontSize: titleFontSize,
|
|
94
|
+
fontWeight: titleFontWeight,
|
|
95
|
+
lineHeight: titleLineHeight
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const selectContentStyles = _ref6 => {
|
|
99
|
+
let {
|
|
100
|
+
contentMarginBottom,
|
|
101
|
+
contentMarginLeft,
|
|
102
|
+
contentMarginRight,
|
|
103
|
+
contentMarginTop
|
|
104
|
+
} = _ref6;
|
|
105
|
+
return {
|
|
106
|
+
marginBottom: contentMarginBottom,
|
|
107
|
+
marginLeft: contentMarginLeft,
|
|
108
|
+
marginRight: contentMarginRight,
|
|
109
|
+
marginTop: contentMarginTop
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const selectContentTextStyles = _ref7 => {
|
|
113
|
+
let {
|
|
114
|
+
contentFontColor,
|
|
115
|
+
contentFontName,
|
|
116
|
+
contentFontSize,
|
|
117
|
+
contentFontWeight,
|
|
118
|
+
contentLineHeight
|
|
119
|
+
} = _ref7;
|
|
120
|
+
return applyTextStyles({
|
|
121
|
+
fontColor: contentFontColor,
|
|
122
|
+
fontName: contentFontName,
|
|
123
|
+
fontSize: contentFontSize,
|
|
124
|
+
fontWeight: contentFontWeight,
|
|
125
|
+
lineHeight: contentLineHeight
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const selectStatusIconProps = _ref8 => {
|
|
129
|
+
let {
|
|
130
|
+
statusIcon,
|
|
131
|
+
statusIconColor
|
|
132
|
+
} = _ref8;
|
|
133
|
+
return {
|
|
134
|
+
icon: statusIcon,
|
|
135
|
+
tokens: {
|
|
136
|
+
color: statusIconColor
|
|
137
|
+
},
|
|
138
|
+
variant: {
|
|
139
|
+
size: 'micro'
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const selectActionIconStyles = _ref9 => {
|
|
144
|
+
let {
|
|
145
|
+
actionIconMarginBottom,
|
|
146
|
+
actionIconMarginLeft,
|
|
147
|
+
actionIconMarginRight,
|
|
148
|
+
actionIconMarginTop
|
|
149
|
+
} = _ref9;
|
|
150
|
+
return {
|
|
151
|
+
marginBottom: actionIconMarginBottom,
|
|
152
|
+
marginLeft: actionIconMarginLeft,
|
|
153
|
+
marginRight: actionIconMarginRight,
|
|
154
|
+
marginTop: actionIconMarginTop
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
const selectActionIconProps = _ref10 => {
|
|
158
|
+
let {
|
|
159
|
+
actionIcon,
|
|
160
|
+
actionIconColor
|
|
161
|
+
} = _ref10;
|
|
162
|
+
return {
|
|
163
|
+
icon: actionIcon,
|
|
164
|
+
tokens: {
|
|
165
|
+
color: actionIconColor
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
const ACTION_ICON_ANIMATION_DURATION = 100;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* ActionCard component represents a card with an action that can be triggered by the user.
|
|
173
|
+
*
|
|
174
|
+
* @component
|
|
175
|
+
* @example
|
|
176
|
+
* return (
|
|
177
|
+
* <ActionCard
|
|
178
|
+
* icon={<Icon icon={Icons.EyeMasked} />}
|
|
179
|
+
* title="Like"
|
|
180
|
+
* href="/like"
|
|
181
|
+
* accessibilityRole="link"
|
|
182
|
+
* tokens={themeTokens}
|
|
183
|
+
* variant={{validation: 'warning'}}
|
|
184
|
+
* onPress={() => handleLike()}
|
|
185
|
+
* >
|
|
186
|
+
* Click here to like the post
|
|
187
|
+
* </ActionCard>
|
|
188
|
+
* )
|
|
189
|
+
*/
|
|
190
|
+
const ActionCard = /*#__PURE__*/React.forwardRef((_ref11, ref) => {
|
|
191
|
+
let {
|
|
192
|
+
icon,
|
|
193
|
+
title,
|
|
194
|
+
children,
|
|
195
|
+
href,
|
|
196
|
+
direction = true,
|
|
197
|
+
accessibilityRole,
|
|
198
|
+
tokens,
|
|
199
|
+
variant,
|
|
200
|
+
...rest
|
|
201
|
+
} = _ref11;
|
|
202
|
+
const themeTokens = useThemeTokens('ActionCard', tokens, variant);
|
|
203
|
+
const actionIconAnimation = React.useRef(new Animated.Value(0)).current;
|
|
204
|
+
const {
|
|
205
|
+
onPress,
|
|
206
|
+
...props
|
|
207
|
+
} = clickProps.toPressProps(rest);
|
|
208
|
+
const {
|
|
209
|
+
hrefAttrs,
|
|
210
|
+
rawRest
|
|
211
|
+
} = hrefAttrsProp.bundle(props);
|
|
212
|
+
const selectedProps = selectProps({
|
|
213
|
+
accessibilityRole,
|
|
214
|
+
href,
|
|
215
|
+
onPress: linkProps.handleHref({
|
|
216
|
+
href,
|
|
217
|
+
onPress
|
|
218
|
+
}),
|
|
219
|
+
hrefAttrs,
|
|
220
|
+
...rawRest
|
|
221
|
+
});
|
|
222
|
+
return /*#__PURE__*/_jsx(Card, {
|
|
223
|
+
ref: ref,
|
|
224
|
+
interactiveCard: {
|
|
225
|
+
body: pressableState => {
|
|
226
|
+
const animate = pressableState.pressed || pressableState.hover || pressableState.focus;
|
|
227
|
+
Animated.timing(actionIconAnimation, {
|
|
228
|
+
toValue: animate ? themeTokens.actionIconTranslate : 0,
|
|
229
|
+
duration: ACTION_ICON_ANIMATION_DURATION,
|
|
230
|
+
useNativeDriver: false
|
|
231
|
+
}).start();
|
|
232
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
233
|
+
style: staticStyles.container,
|
|
234
|
+
children: [icon && /*#__PURE__*/_jsx(View, {
|
|
235
|
+
style: selectIconStyles(themeTokens),
|
|
236
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
237
|
+
...selectIconProps({
|
|
238
|
+
icon,
|
|
239
|
+
...themeTokens
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
243
|
+
style: staticStyles.content,
|
|
244
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
245
|
+
style: staticStyles.header,
|
|
246
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
247
|
+
style: [selectTitleStyles(themeTokens), staticStyles.title],
|
|
248
|
+
children: /*#__PURE__*/_jsxs(Text, {
|
|
249
|
+
children: [wrapStringsInText(title, {
|
|
250
|
+
style: selectTitleTextStyles(themeTokens)
|
|
251
|
+
}), themeTokens.statusIcon && /*#__PURE__*/_jsx(View, {
|
|
252
|
+
style: staticStyles.statusIcon,
|
|
253
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
254
|
+
...selectStatusIconProps(themeTokens)
|
|
255
|
+
})
|
|
256
|
+
})]
|
|
257
|
+
})
|
|
258
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
259
|
+
style: staticStyles.icons,
|
|
260
|
+
children: direction && /*#__PURE__*/_jsx(Animated.View, {
|
|
261
|
+
style: [selectActionIconStyles(themeTokens), {
|
|
262
|
+
transform: [{
|
|
263
|
+
translateX: actionIconAnimation
|
|
264
|
+
}]
|
|
265
|
+
}],
|
|
266
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
267
|
+
...selectActionIconProps(themeTokens)
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
})]
|
|
271
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
272
|
+
style: [staticStyles.body, selectContentStyles(themeTokens)],
|
|
273
|
+
children: typeof children === 'string' ? wrapStringsInText(children, {
|
|
274
|
+
style: selectContentTextStyles(themeTokens)
|
|
275
|
+
}) : children
|
|
276
|
+
})]
|
|
277
|
+
})]
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
tokens: selectInteractiveCardStyles(themeTokens)
|
|
281
|
+
},
|
|
282
|
+
tokens: selectCardStyles(themeTokens),
|
|
283
|
+
...selectedProps
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
ActionCard.displayName = 'ActionCard';
|
|
287
|
+
ActionCard.propTypes = {
|
|
288
|
+
...selectedSystemPropTypes,
|
|
289
|
+
tokens: getTokensPropType('ActionCard'),
|
|
290
|
+
variant: variantProp.propType,
|
|
291
|
+
/**
|
|
292
|
+
* Icon for the ActionCard
|
|
293
|
+
*/
|
|
294
|
+
icon: PropTypes.elementType,
|
|
295
|
+
/**
|
|
296
|
+
* Title for the ActionCard
|
|
297
|
+
*/
|
|
298
|
+
title: PropTypes.string,
|
|
299
|
+
/**
|
|
300
|
+
* Children for the ActionCard
|
|
301
|
+
*/
|
|
302
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
303
|
+
/**
|
|
304
|
+
* href for the ActionCard
|
|
305
|
+
*/
|
|
306
|
+
href: PropTypes.string,
|
|
307
|
+
/**
|
|
308
|
+
* Enable or disable the direction of the ActionCard
|
|
309
|
+
*/
|
|
310
|
+
direction: PropTypes.bool,
|
|
311
|
+
/**
|
|
312
|
+
* AccesibilityRole for the ActionCard
|
|
313
|
+
*/
|
|
314
|
+
accessibilityRole: PropTypes.string
|
|
315
|
+
};
|
|
316
|
+
const staticStyles = StyleSheet.create({
|
|
317
|
+
body: {
|
|
318
|
+
flexDirection: 'column'
|
|
319
|
+
},
|
|
320
|
+
container: {
|
|
321
|
+
flex: 1,
|
|
322
|
+
flexDirection: 'row'
|
|
323
|
+
},
|
|
324
|
+
content: {
|
|
325
|
+
flex: 1,
|
|
326
|
+
flexDirection: 'column'
|
|
327
|
+
},
|
|
328
|
+
icons: {
|
|
329
|
+
flexDirection: 'row',
|
|
330
|
+
alignItems: 'center'
|
|
331
|
+
},
|
|
332
|
+
header: {
|
|
333
|
+
flexDirection: 'row',
|
|
334
|
+
justifyContent: 'space-between'
|
|
335
|
+
},
|
|
336
|
+
title: {
|
|
337
|
+
flexShrink: 1
|
|
338
|
+
},
|
|
339
|
+
statusIcon: {
|
|
340
|
+
marginLeft: 4
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
export default ActionCard;
|
package/lib-module/Card/Card.js
CHANGED
|
@@ -4,7 +4,7 @@ import View from "react-native-web/dist/exports/View";
|
|
|
4
4
|
import { useThemeTokens, useThemeTokensCallback, useResponsiveThemeTokens, useTheme } from '../ThemeProvider';
|
|
5
5
|
import { getTokensPropType, variantProp, StyleSheet, createMediaQueryStyles } from '../utils';
|
|
6
6
|
import { useViewport } from '../ViewportProvider';
|
|
7
|
-
import { a11yProps, selectSystemProps, viewProps } from '../utils/props';
|
|
7
|
+
import { a11yProps, linkProps, selectSystemProps, viewProps } from '../utils/props';
|
|
8
8
|
import CardBase from './CardBase';
|
|
9
9
|
import PressableCardBase from './PressableCardBase';
|
|
10
10
|
import CheckboxButton from '../Checkbox/CheckboxButton';
|
|
@@ -12,7 +12,7 @@ import RadioButton from '../Radio/RadioButton';
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
15
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps, linkProps]);
|
|
16
16
|
const SelectionType = {
|
|
17
17
|
Checkbox: 'checkbox',
|
|
18
18
|
Radio: 'radiogroup',
|
|
@@ -267,7 +267,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
267
267
|
isChecked: selected || (cardState === null || cardState === void 0 ? void 0 : cardState.hover),
|
|
268
268
|
isInactive: inactive,
|
|
269
269
|
onPress
|
|
270
|
-
})), interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.body]
|
|
270
|
+
})), typeof (interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.body) === 'function' ? interactiveCard.body(cardState) : interactiveCard.body]
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
273
|
}), children && selectionType !== SelectionType.None ? renderNoSelectionView() : null]
|
|
@@ -309,7 +309,7 @@ Card.propTypes = {
|
|
|
309
309
|
* - variant: The variant to be used for the interactive card
|
|
310
310
|
*/
|
|
311
311
|
interactiveCard: PropTypes.shape({
|
|
312
|
-
body: PropTypes.node,
|
|
312
|
+
body: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
313
313
|
tokens: getTokensPropType('Card'),
|
|
314
314
|
selectionType: PropTypes.oneOf(Object.values(SelectionType)),
|
|
315
315
|
variant: variantProp.propType
|
|
@@ -104,7 +104,7 @@ PressableCardBase.propTypes = {
|
|
|
104
104
|
...selectedSystemPropTypes,
|
|
105
105
|
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
106
106
|
tokens: getTokensSetPropType(tokenKeys, {
|
|
107
|
-
|
|
107
|
+
partial: true,
|
|
108
108
|
allowFunction: true
|
|
109
109
|
}),
|
|
110
110
|
variant: variantProp.propType
|
|
@@ -204,6 +204,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
204
204
|
onKeyDown: handleKeyDown,
|
|
205
205
|
onPress: handleChange,
|
|
206
206
|
...selectedProps,
|
|
207
|
+
style: staticStyles.removeOutline,
|
|
207
208
|
children: _ref6 => {
|
|
208
209
|
let {
|
|
209
210
|
focused: focus,
|
|
@@ -335,5 +336,8 @@ const staticStyles = StyleSheet.create({
|
|
|
335
336
|
alignWithLabel: {
|
|
336
337
|
alignSelf: 'flex-start',
|
|
337
338
|
justifyContent: 'center'
|
|
339
|
+
},
|
|
340
|
+
removeOutline: {
|
|
341
|
+
outlineStyle: 'none'
|
|
338
342
|
}
|
|
339
343
|
});
|
package/lib-module/List/List.js
CHANGED
|
@@ -42,15 +42,22 @@ const List = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
42
42
|
}
|
|
43
43
|
return child;
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
ref: ref,
|
|
45
|
+
const content = /*#__PURE__*/_jsx(View, {
|
|
47
46
|
style: styles.list,
|
|
48
47
|
accessibilityRole: accessibilityRole,
|
|
48
|
+
ref: ref,
|
|
49
49
|
...selectProps(rest),
|
|
50
50
|
children: items
|
|
51
51
|
});
|
|
52
|
+
return Platform.OS === 'web' ? /*#__PURE__*/_jsx("div", {
|
|
53
|
+
style: styles.container,
|
|
54
|
+
children: content
|
|
55
|
+
}) : content;
|
|
52
56
|
});
|
|
53
57
|
const styles = StyleSheet.create({
|
|
58
|
+
container: {
|
|
59
|
+
display: 'block'
|
|
60
|
+
},
|
|
54
61
|
list: {
|
|
55
62
|
flex: 1,
|
|
56
63
|
flexShrink: 1
|