@telus-uds/components-base 1.94.0 → 1.95.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 +20 -2
- package/lib/Autocomplete/Autocomplete.js +2 -1
- package/lib/DownloadApp/DownloadApp.js +168 -0
- package/lib/DownloadApp/dictionary.js +17 -0
- package/lib/DownloadApp/index.js +10 -0
- package/lib/Icon/IconText.js +19 -2
- package/lib/Link/LinkBase.js +2 -2
- package/lib/Modal/Modal.js +1 -1
- package/lib/TabBar/TabBar.js +133 -0
- package/lib/TabBar/TabBarItem.js +184 -0
- package/lib/TabBar/index.js +10 -0
- package/lib/TextInput/TextInputBase.js +2 -1
- package/lib/Tooltip/getTooltipPosition.js +8 -9
- package/lib/index.js +16 -0
- package/lib-module/Autocomplete/Autocomplete.js +2 -1
- package/lib-module/DownloadApp/DownloadApp.js +160 -0
- package/lib-module/DownloadApp/dictionary.js +10 -0
- package/lib-module/DownloadApp/index.js +2 -0
- package/lib-module/Icon/IconText.js +19 -2
- package/lib-module/Link/LinkBase.js +2 -2
- package/lib-module/Modal/Modal.js +1 -1
- package/lib-module/TabBar/TabBar.js +125 -0
- package/lib-module/TabBar/TabBarItem.js +177 -0
- package/lib-module/TabBar/index.js +2 -0
- package/lib-module/TextInput/TextInputBase.js +2 -1
- package/lib-module/Tooltip/getTooltipPosition.js +8 -9
- package/lib-module/index.js +2 -0
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +2 -1
- package/src/DownloadApp/DownloadApp.jsx +165 -0
- package/src/DownloadApp/dictionary.js +10 -0
- package/src/DownloadApp/index.js +3 -0
- package/src/Icon/IconText.jsx +21 -4
- package/src/Link/LinkBase.jsx +2 -2
- package/src/Modal/Modal.jsx +1 -1
- package/src/TabBar/TabBar.jsx +123 -0
- package/src/TabBar/TabBarItem.jsx +149 -0
- package/src/TabBar/index.js +3 -0
- package/src/TextInput/TextInputBase.jsx +1 -1
- package/src/Tooltip/getTooltipPosition.js +11 -12
- package/src/index.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 25 Sep 2024 16:57:49 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.95.0
|
|
8
|
+
|
|
9
|
+
Wed, 25 Sep 2024 16:57:49 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `DownloadApp`: add component (Mauricio.BatresMontejo@telus.com)
|
|
14
|
+
- `TabBar`: new component added (35577399+JoshHC@users.noreply.github.com)
|
|
15
|
+
- `Link`: add `inline` variant to `iconPosition` (evander.owusu@telus.com)
|
|
16
|
+
- Bump @telus-uds/system-theme-tokens to v2.64.0
|
|
17
|
+
|
|
18
|
+
### Patches
|
|
19
|
+
|
|
20
|
+
- `Modal`: fix focusing on undefined ref for close button (kristina.kirpichnikova@telus.com)
|
|
21
|
+
- `TextInput`: masked characters issue in password fixed (35577399+JoshHC@users.noreply.github.com)
|
|
22
|
+
- `Tooltip`: fix positioning (guillermo.peitzner@telus.com)
|
|
23
|
+
- `Autocomplete`: add missing loading-label functionality (guillermo.peitzner@telus.com)
|
|
24
|
+
|
|
7
25
|
## 1.94.0
|
|
8
26
|
|
|
9
|
-
Mon, 16 Sep 2024 12:
|
|
27
|
+
Mon, 16 Sep 2024 12:35:38 GMT
|
|
10
28
|
|
|
11
29
|
### Minor changes
|
|
12
30
|
|
|
@@ -111,6 +111,7 @@ const Autocomplete = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
111
111
|
validation,
|
|
112
112
|
value,
|
|
113
113
|
helpText = '',
|
|
114
|
+
loadingLabel,
|
|
114
115
|
...rest
|
|
115
116
|
} = _ref2;
|
|
116
117
|
const {
|
|
@@ -346,7 +347,7 @@ const Autocomplete = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
346
347
|
onLayout: handleMeasure,
|
|
347
348
|
ref: openOverlayRef,
|
|
348
349
|
children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.default, {
|
|
349
|
-
label: getCopy('loading')
|
|
350
|
+
label: loadingLabel ?? getCopy('loading')
|
|
350
351
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Suggestions.default, {
|
|
351
352
|
hasResults: getCopy('hasResults'),
|
|
352
353
|
id: "autocomplete",
|
|
@@ -0,0 +1,168 @@
|
|
|
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 _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
10
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
14
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.linkProps, _utils.viewProps]);
|
|
18
|
+
const selectOuterStyles = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
borderColor,
|
|
21
|
+
borderWidth,
|
|
22
|
+
borderGap,
|
|
23
|
+
borderRadius,
|
|
24
|
+
padding
|
|
25
|
+
} = _ref;
|
|
26
|
+
return {
|
|
27
|
+
outline: 'none',
|
|
28
|
+
borderColor,
|
|
29
|
+
borderWidth,
|
|
30
|
+
borderGap,
|
|
31
|
+
borderRadius,
|
|
32
|
+
padding
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const DownloadApp = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
36
|
+
let {
|
|
37
|
+
copy = 'en',
|
|
38
|
+
dictionary = _dictionary.default,
|
|
39
|
+
type = 'ios',
|
|
40
|
+
href,
|
|
41
|
+
onPress,
|
|
42
|
+
tokens = {},
|
|
43
|
+
variant = {},
|
|
44
|
+
...props
|
|
45
|
+
} = _ref2;
|
|
46
|
+
const getCopy = (0, _utils.useCopy)({
|
|
47
|
+
dictionary,
|
|
48
|
+
copy
|
|
49
|
+
});
|
|
50
|
+
const {
|
|
51
|
+
hrefAttrs,
|
|
52
|
+
rest
|
|
53
|
+
} = _utils.hrefAttrsProp.bundle(props);
|
|
54
|
+
const selectedProps = selectProps({
|
|
55
|
+
accessibilityRole: href ? 'link' : 'button',
|
|
56
|
+
href,
|
|
57
|
+
onPress: _utils.linkProps.handleHref({
|
|
58
|
+
href,
|
|
59
|
+
onPress
|
|
60
|
+
}),
|
|
61
|
+
hrefAttrs,
|
|
62
|
+
...rest
|
|
63
|
+
});
|
|
64
|
+
const getDownloadAppTokens = (0, _ThemeProvider.useThemeTokensCallback)('DownloadApp', tokens, variant);
|
|
65
|
+
const resolveDownloadAppTokens = pressableState => {
|
|
66
|
+
const themeTokens = (0, _utils.resolvePressableTokens)(getDownloadAppTokens, pressableState, {});
|
|
67
|
+
return selectOuterStyles(themeTokens);
|
|
68
|
+
};
|
|
69
|
+
const {
|
|
70
|
+
androidENIcon,
|
|
71
|
+
androidFRIcon,
|
|
72
|
+
iosENIcon,
|
|
73
|
+
iosFRIcon
|
|
74
|
+
} = getDownloadAppTokens();
|
|
75
|
+
const imageResources = {
|
|
76
|
+
en: {
|
|
77
|
+
android: androidENIcon,
|
|
78
|
+
ios: iosENIcon
|
|
79
|
+
},
|
|
80
|
+
fr: {
|
|
81
|
+
android: androidFRIcon,
|
|
82
|
+
ios: iosFRIcon
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const IconComponent = imageResources[copy][type];
|
|
86
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
87
|
+
ref: ref,
|
|
88
|
+
style: pressState => [resolveDownloadAppTokens(pressState), staticStyles.row],
|
|
89
|
+
...selectedProps,
|
|
90
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
|
|
91
|
+
style: staticImageSizes[type][copy],
|
|
92
|
+
alt: type === 'ios' ? getCopy('altTextIos') : getCopy('altTextAndroid')
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
DownloadApp.displayName = 'DownloadApp';
|
|
97
|
+
const dictionaryContentShape = _propTypes.default.shape({
|
|
98
|
+
altTextAndroid: _propTypes.default.string.isRequired,
|
|
99
|
+
altTextIos: _propTypes.default.string.isRequired
|
|
100
|
+
});
|
|
101
|
+
DownloadApp.propTypes = {
|
|
102
|
+
...selectedSystemPropTypes,
|
|
103
|
+
copy: _utils.copyPropTypes,
|
|
104
|
+
/**
|
|
105
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
106
|
+
*/
|
|
107
|
+
dictionary: _propTypes.default.shape({
|
|
108
|
+
en: dictionaryContentShape,
|
|
109
|
+
fr: dictionaryContentShape
|
|
110
|
+
}),
|
|
111
|
+
/**
|
|
112
|
+
* Select the type of image to show.
|
|
113
|
+
*/
|
|
114
|
+
type: _propTypes.default.oneOf(['android', 'ios']),
|
|
115
|
+
/**
|
|
116
|
+
* It's a simple link that opens the Download Button instead of the onPress function.
|
|
117
|
+
*/
|
|
118
|
+
href: _propTypes.default.string,
|
|
119
|
+
/**
|
|
120
|
+
* Function called when the button is pressed. Required unless the button has a href.
|
|
121
|
+
*/
|
|
122
|
+
onPress: _propTypes.default.func,
|
|
123
|
+
/**
|
|
124
|
+
* DownloadApp tokens.
|
|
125
|
+
*/
|
|
126
|
+
tokens: (0, _utils.getTokensPropType)('DownloadApp'),
|
|
127
|
+
/**
|
|
128
|
+
* DownloadApp variant.
|
|
129
|
+
*/
|
|
130
|
+
variant: _utils.variantProp.propType
|
|
131
|
+
};
|
|
132
|
+
const staticStyles = _StyleSheet.default.create({
|
|
133
|
+
row: {
|
|
134
|
+
..._Platform.default.select({
|
|
135
|
+
web: {
|
|
136
|
+
display: 'inline-flex',
|
|
137
|
+
width: 'fit-content'
|
|
138
|
+
},
|
|
139
|
+
default: {
|
|
140
|
+
alignSelf: 'flex-start'
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const staticImageSizes = {
|
|
146
|
+
android: {
|
|
147
|
+
en: {
|
|
148
|
+
width: 162,
|
|
149
|
+
height: 48
|
|
150
|
+
},
|
|
151
|
+
fr: {
|
|
152
|
+
width: 162,
|
|
153
|
+
height: 48
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
ios: {
|
|
157
|
+
en: {
|
|
158
|
+
width: 144,
|
|
159
|
+
height: 48
|
|
160
|
+
},
|
|
161
|
+
fr: {
|
|
162
|
+
width: 152,
|
|
163
|
+
height: 48
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
var _default = DownloadApp;
|
|
168
|
+
exports.default = _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
en: {
|
|
9
|
+
altTextAndroid: 'Get it on Google Play',
|
|
10
|
+
altTextIos: 'Download on the App Store'
|
|
11
|
+
},
|
|
12
|
+
fr: {
|
|
13
|
+
altTextAndroid: 'Disponible sur Google Play',
|
|
14
|
+
altTextIos: 'Télécharger dans l’App Store'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
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 _DownloadApp = _interopRequireDefault(require("./DownloadApp"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _DownloadApp.default;
|
|
10
|
+
exports.default = _default;
|
package/lib/Icon/IconText.js
CHANGED
|
@@ -8,6 +8,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
10
10
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
11
|
+
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
12
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
13
|
var _Icon = _interopRequireWildcard(require("./Icon"));
|
|
12
14
|
var _StackView = require("../StackView");
|
|
13
15
|
var _utils = require("../utils");
|
|
@@ -66,6 +68,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
66
68
|
});
|
|
67
69
|
const mobile = _Platform.default.OS === 'android' ? iconAdjustedAndroid : iconAdjustedIOS;
|
|
68
70
|
const adjustedContainer = _Platform.default.OS === 'web' ? iconContent : mobile;
|
|
71
|
+
const adjustedContainerWithPosition = /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
72
|
+
style: staticStyles.adjustedContainer,
|
|
73
|
+
children: adjustedContainer
|
|
74
|
+
});
|
|
75
|
+
if (iconPosition === 'inline') {
|
|
76
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Text.default, {
|
|
77
|
+
children: [children, " ", adjustedContainerWithPosition]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
69
80
|
return (0, _StackView.getStackedContent)(iconPosition === 'left' ? [adjustedContainer, children] : [children, adjustedContainer], {
|
|
70
81
|
space,
|
|
71
82
|
direction: 'row'
|
|
@@ -80,9 +91,9 @@ IconText.propTypes = {
|
|
|
80
91
|
*/
|
|
81
92
|
space: _utils.spacingProps.types.spacingValue,
|
|
82
93
|
/**
|
|
83
|
-
* Whether the icon should be to the left of the content
|
|
94
|
+
* Whether the icon should be to the left of the content, the right of the content or inline with the content.
|
|
84
95
|
*/
|
|
85
|
-
iconPosition: _propTypes.default.oneOf(['left', 'right']),
|
|
96
|
+
iconPosition: _propTypes.default.oneOf(['left', 'right', 'inline']),
|
|
86
97
|
/**
|
|
87
98
|
* A valid UDS icon component imported from a UDS palette.
|
|
88
99
|
*/
|
|
@@ -100,5 +111,11 @@ IconText.propTypes = {
|
|
|
100
111
|
children: _propTypes.default.node
|
|
101
112
|
/* eslint-enable react/no-unused-prop-types */
|
|
102
113
|
};
|
|
114
|
+
|
|
115
|
+
const staticStyles = _StyleSheet.default.create({
|
|
116
|
+
adjustedContainer: {
|
|
117
|
+
position: 'absolute'
|
|
118
|
+
}
|
|
119
|
+
});
|
|
103
120
|
var _default = IconText;
|
|
104
121
|
exports.default = _default;
|
package/lib/Link/LinkBase.js
CHANGED
|
@@ -245,9 +245,9 @@ LinkBase.propTypes = {
|
|
|
245
245
|
*/
|
|
246
246
|
icon: _propTypes.default.elementType,
|
|
247
247
|
/**
|
|
248
|
-
* When `icon` is provided, use `iconPosition` to place the Icon to the left or
|
|
248
|
+
* When `icon` is provided, use `iconPosition` to place the Icon to the left, right or inline with Link.
|
|
249
249
|
*/
|
|
250
|
-
iconPosition: _propTypes.default.oneOf(['left', 'right']),
|
|
250
|
+
iconPosition: _propTypes.default.oneOf(['left', 'right', 'inline']),
|
|
251
251
|
/**
|
|
252
252
|
* On Web if href is passed, React Native Web maps this object's props to
|
|
253
253
|
* `rel`, `target` and `download` attrs.
|
package/lib/Modal/Modal.js
CHANGED
|
@@ -158,7 +158,7 @@ const Modal = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
|
|
|
158
158
|
if (_Platform.default.OS === 'web') {
|
|
159
159
|
const handleFocus = () => {
|
|
160
160
|
// If the focus is on the last item of the web modal container, move it to the close button
|
|
161
|
-
if (document.activeElement === focusTrapRef.current) {
|
|
161
|
+
if (document.activeElement === focusTrapRef.current && closeButtonRef.current) {
|
|
162
162
|
closeButtonRef.current.focus();
|
|
163
163
|
}
|
|
164
164
|
return undefined;
|
|
@@ -0,0 +1,133 @@
|
|
|
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 _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
|
+
var _TabBarItem = _interopRequireDefault(require("./TabBarItem"));
|
|
12
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
13
|
+
var _utils = require("../utils");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
const selectTabBarContainerStyles = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
paddingTop,
|
|
19
|
+
paddingBottom,
|
|
20
|
+
borderTopWidth,
|
|
21
|
+
borderTopColor,
|
|
22
|
+
backgroundColor
|
|
23
|
+
} = _ref;
|
|
24
|
+
return {
|
|
25
|
+
paddingTop,
|
|
26
|
+
paddingBottom,
|
|
27
|
+
borderTopWidth,
|
|
28
|
+
borderTopColor,
|
|
29
|
+
backgroundColor
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const selectTabBarItemContainerStyles = _ref2 => {
|
|
33
|
+
let {
|
|
34
|
+
paddingLeft,
|
|
35
|
+
paddingRight,
|
|
36
|
+
gap
|
|
37
|
+
} = _ref2;
|
|
38
|
+
return {
|
|
39
|
+
paddingLeft,
|
|
40
|
+
paddingRight,
|
|
41
|
+
gap
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* TabBar component renders a navigation bar with multiple TabBarItems.
|
|
48
|
+
* It allows users to switch between different views or sections.
|
|
49
|
+
*
|
|
50
|
+
* @component
|
|
51
|
+
* @example
|
|
52
|
+
* const items = [
|
|
53
|
+
* { id: '1', label: 'Home', icon: <HomeIcon />, iconActive: <HomeActiveIcon /> },
|
|
54
|
+
* { id: '2', label: 'Profile', icon: <ProfileIcon />, iconActive: <ProfileActiveIcon /> },
|
|
55
|
+
* ]
|
|
56
|
+
* return (
|
|
57
|
+
* <TabBar
|
|
58
|
+
* items={items}
|
|
59
|
+
* initiallySelectedItem="1"
|
|
60
|
+
* onChange={(itemId) => console.log(itemId)}
|
|
61
|
+
* />
|
|
62
|
+
* )
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
const TabBar = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
66
|
+
let {
|
|
67
|
+
items = [],
|
|
68
|
+
initiallySelectedItem = '0',
|
|
69
|
+
onChange,
|
|
70
|
+
variant,
|
|
71
|
+
tokens,
|
|
72
|
+
...rest
|
|
73
|
+
} = _ref3;
|
|
74
|
+
const [isSelected, setIsSelected] = _react.default.useState(initiallySelectedItem);
|
|
75
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('TabBar', tokens, variant);
|
|
76
|
+
const handlePress = itemId => {
|
|
77
|
+
setIsSelected(itemId);
|
|
78
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(itemId);
|
|
79
|
+
};
|
|
80
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
81
|
+
ref: ref,
|
|
82
|
+
style: [styles.tabBar, selectTabBarContainerStyles(themeTokens)],
|
|
83
|
+
...selectProps(rest),
|
|
84
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
85
|
+
style: [styles.tabBarItem, selectTabBarItemContainerStyles(themeTokens)],
|
|
86
|
+
children: items.map((item, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabBarItem.default, {
|
|
87
|
+
label: item.label,
|
|
88
|
+
href: item.href,
|
|
89
|
+
isSelected: isSelected === item.id,
|
|
90
|
+
icon: item.icon,
|
|
91
|
+
iconActive: item.iconActive,
|
|
92
|
+
onPress: () => handlePress(item.id),
|
|
93
|
+
id: `tab-item-${index}`,
|
|
94
|
+
accessibilityRole: "tablist"
|
|
95
|
+
}, item.id))
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
TabBar.displayName = 'TabBar';
|
|
100
|
+
TabBar.propTypes = {
|
|
101
|
+
...selectedSystemPropTypes,
|
|
102
|
+
/** Array of TabBarItems to be displayed in TabBar */
|
|
103
|
+
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
104
|
+
id: _propTypes.default.string.isRequired,
|
|
105
|
+
icon: _propTypes.default.node,
|
|
106
|
+
iconActive: _propTypes.default.node,
|
|
107
|
+
label: _propTypes.default.string.isRequired,
|
|
108
|
+
href: _propTypes.default.string
|
|
109
|
+
})).isRequired,
|
|
110
|
+
/** Id of the initially selected item. */
|
|
111
|
+
initiallySelectedItem: _propTypes.default.number,
|
|
112
|
+
/** Callback function to handle item selection change. */
|
|
113
|
+
onChange: _propTypes.default.func,
|
|
114
|
+
/** Variant of TabBar for styling purposes. */
|
|
115
|
+
variant: _utils.variantProp.propType,
|
|
116
|
+
/** Tokens for theming and styling. */
|
|
117
|
+
tokens: (0, _utils.getTokensPropType)('TabBar')
|
|
118
|
+
};
|
|
119
|
+
const styles = _StyleSheet.default.create({
|
|
120
|
+
tabBar: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
justifyContent: 'center',
|
|
123
|
+
alignItems: 'center'
|
|
124
|
+
},
|
|
125
|
+
tabBarItem: {
|
|
126
|
+
flex: 1,
|
|
127
|
+
flexDirection: 'row',
|
|
128
|
+
justifyContent: 'space-between',
|
|
129
|
+
width: '100%'
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
var _default = TabBar;
|
|
133
|
+
exports.default = _default;
|
|
@@ -0,0 +1,184 @@
|
|
|
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 _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
10
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
11
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
14
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
15
|
+
var _Spacer = _interopRequireDefault(require("../Spacer"));
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
const selectTypographyStyles = (_ref, isSelected) => {
|
|
19
|
+
let {
|
|
20
|
+
fontWeight,
|
|
21
|
+
color,
|
|
22
|
+
lineHeight,
|
|
23
|
+
fontName,
|
|
24
|
+
activeColor
|
|
25
|
+
} = _ref;
|
|
26
|
+
return {
|
|
27
|
+
fontWeight,
|
|
28
|
+
color: isSelected ? activeColor : color,
|
|
29
|
+
lineHeight,
|
|
30
|
+
fontName
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const selectIconContainerStyles = _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
paddingTop,
|
|
36
|
+
paddingBottom
|
|
37
|
+
} = _ref2;
|
|
38
|
+
return {
|
|
39
|
+
paddingTop,
|
|
40
|
+
paddingBottom,
|
|
41
|
+
alignItems: 'center'
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const selectIconStyles = (_ref3, isSelected) => {
|
|
45
|
+
let {
|
|
46
|
+
iconSize,
|
|
47
|
+
iconColor,
|
|
48
|
+
activeColor
|
|
49
|
+
} = _ref3;
|
|
50
|
+
return {
|
|
51
|
+
size: iconSize,
|
|
52
|
+
color: isSelected ? activeColor : iconColor
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const selectContainerStyles = _ref4 => {
|
|
56
|
+
let {
|
|
57
|
+
borderRadius,
|
|
58
|
+
backgroundColor
|
|
59
|
+
} = _ref4;
|
|
60
|
+
return {
|
|
61
|
+
borderRadius,
|
|
62
|
+
backgroundColor,
|
|
63
|
+
alignSelf: 'center',
|
|
64
|
+
alignItems: 'center'
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const TabBarItem = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
|
|
68
|
+
let {
|
|
69
|
+
href,
|
|
70
|
+
variant,
|
|
71
|
+
tokens,
|
|
72
|
+
label,
|
|
73
|
+
isSelected,
|
|
74
|
+
id,
|
|
75
|
+
onPress,
|
|
76
|
+
icon: IconComponent,
|
|
77
|
+
iconActive: IconActiveComponent,
|
|
78
|
+
accessibilityRole = 'tab'
|
|
79
|
+
} = _ref5;
|
|
80
|
+
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('TabBarItem', tokens, variant);
|
|
81
|
+
const getPressableStyle = _ref6 => {
|
|
82
|
+
let {
|
|
83
|
+
pressed,
|
|
84
|
+
focused,
|
|
85
|
+
hovered
|
|
86
|
+
} = _ref6;
|
|
87
|
+
const resolvedTokens = (0, _utils.resolvePressableTokens)(getTokens, {
|
|
88
|
+
pressed,
|
|
89
|
+
focused,
|
|
90
|
+
hovered
|
|
91
|
+
}, {
|
|
92
|
+
isSelected
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
...resolvedTokens,
|
|
96
|
+
outline: 'none' // removes the default browser :focus outline
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
101
|
+
ref: ref,
|
|
102
|
+
href: href,
|
|
103
|
+
nativeID: id,
|
|
104
|
+
onPress: onPress,
|
|
105
|
+
style: _ref7 => {
|
|
106
|
+
let {
|
|
107
|
+
pressed,
|
|
108
|
+
focused,
|
|
109
|
+
hovered
|
|
110
|
+
} = _ref7;
|
|
111
|
+
return [styles.flexContainer, getPressableStyle({
|
|
112
|
+
pressed,
|
|
113
|
+
focused,
|
|
114
|
+
hovered
|
|
115
|
+
})];
|
|
116
|
+
},
|
|
117
|
+
accessibilityRole: accessibilityRole,
|
|
118
|
+
testID: id,
|
|
119
|
+
children: pressableState => {
|
|
120
|
+
const resolvedTokens = getPressableStyle(pressableState);
|
|
121
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
122
|
+
style: selectContainerStyles(resolvedTokens),
|
|
123
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
124
|
+
style: [selectIconContainerStyles(resolvedTokens), styles.iconContainer],
|
|
125
|
+
children: isSelected ? IconActiveComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(IconActiveComponent, {
|
|
126
|
+
...selectIconStyles(resolvedTokens, isSelected)
|
|
127
|
+
}) : IconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
|
|
128
|
+
...selectIconStyles(resolvedTokens)
|
|
129
|
+
})
|
|
130
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
131
|
+
space: 1
|
|
132
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
133
|
+
variant: {
|
|
134
|
+
size: 'micro'
|
|
135
|
+
},
|
|
136
|
+
tokens: selectTypographyStyles(resolvedTokens, isSelected),
|
|
137
|
+
align: "center",
|
|
138
|
+
children: label
|
|
139
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spacer.default, {
|
|
140
|
+
space: 1
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
TabBarItem.displayName = 'TabBarItem';
|
|
147
|
+
TabBarItem.propTypes = {
|
|
148
|
+
/** The icon to be displayed when the item is not selected. */
|
|
149
|
+
icon: _propTypes.default.elementType,
|
|
150
|
+
/** The icon to be displayed when the item is selected. */
|
|
151
|
+
iconActive: _propTypes.default.elementType,
|
|
152
|
+
/** Tokens for theming and styling the TabBarItem. */
|
|
153
|
+
tokens: (0, _utils.getTokensPropType)('TabBarItem'),
|
|
154
|
+
/** Variant of the TabBarItem for styling purposes. */
|
|
155
|
+
variant: _utils.variantProp.propType,
|
|
156
|
+
/** Callback function to handle press events. */
|
|
157
|
+
onPress: _propTypes.default.func,
|
|
158
|
+
/** URL to navigate to when the item is pressed. */
|
|
159
|
+
href: _propTypes.default.string,
|
|
160
|
+
/** Indicates whether the item is selected. */
|
|
161
|
+
isSelected: _propTypes.default.bool,
|
|
162
|
+
/** Unique identifier for the item. */
|
|
163
|
+
id: _propTypes.default.string,
|
|
164
|
+
/** Label text for the item. */
|
|
165
|
+
label: _propTypes.default.string.isRequired,
|
|
166
|
+
/** Accessibility role for the item. */
|
|
167
|
+
accessibilityRole: _propTypes.default.string
|
|
168
|
+
};
|
|
169
|
+
const styles = _StyleSheet.default.create({
|
|
170
|
+
flexContainer: {
|
|
171
|
+
flex: 1,
|
|
172
|
+
alignItems: 'center'
|
|
173
|
+
},
|
|
174
|
+
iconContainer: {
|
|
175
|
+
flex: 1,
|
|
176
|
+
justifyContent: 'center',
|
|
177
|
+
alignItems: 'center',
|
|
178
|
+
minWidth: 44,
|
|
179
|
+
minHeight: 40,
|
|
180
|
+
aspectRatio: 1.1
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
var _default = TabBarItem;
|
|
184
|
+
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 _TabBar = _interopRequireDefault(require("./TabBar"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _TabBar.default;
|
|
10
|
+
exports.default = _default;
|
|
@@ -48,7 +48,8 @@ const selectInputStyles = function (_ref, themeOptions, inactive, type) {
|
|
|
48
48
|
// jump around if the border width changes (avoiding NaN and negative padding)
|
|
49
49
|
const offsetBorder = value => typeof value === 'number' ? Math.max(0, value - borderWidth) : value;
|
|
50
50
|
const textStyles = (0, _ThemeProvider.applyTextStyles)({
|
|
51
|
-
fontName,
|
|
51
|
+
fontName: isPassword ? undefined : fontName,
|
|
52
|
+
// In this case, we don't want to apply the fontName to the input if it's a password because Monotype don't have support for the masked characters in mobile.
|
|
52
53
|
fontSize,
|
|
53
54
|
lineHeight,
|
|
54
55
|
fontWeight,
|