@telus-uds/components-base 1.93.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 +32 -3
- package/lib/Autocomplete/Autocomplete.js +2 -1
- package/lib/Button/ButtonGroup.js +17 -1
- package/lib/Card/Card.js +12 -0
- package/lib/Card/CardBase.js +37 -2
- package/lib/Carousel/Carousel.js +55 -13
- package/lib/Carousel/CarouselItem/CarouselItem.js +86 -12
- package/lib/DownloadApp/DownloadApp.js +168 -0
- package/lib/DownloadApp/dictionary.js +17 -0
- package/lib/DownloadApp/index.js +10 -0
- package/lib/Fieldset/FieldsetContainer.js +7 -2
- package/lib/Fieldset/FieldsetContainer.native.js +4 -1
- package/lib/FileUpload/FileUpload.js +336 -0
- package/lib/FileUpload/NotificationContent.js +60 -0
- package/lib/FileUpload/dictionary.js +47 -0
- package/lib/FileUpload/index.js +10 -0
- package/lib/Icon/IconText.js +19 -2
- package/lib/Link/LinkBase.js +2 -2
- package/lib/Link/TextButton.js +7 -17
- package/lib/Modal/Modal.js +1 -1
- package/lib/Modal/ModalContent.js +12 -6
- package/lib/MultiSelectFilter/ModalOverlay.js +49 -30
- package/lib/MultiSelectFilter/MultiSelectFilter.js +170 -131
- package/lib/Notification/Notification.js +11 -2
- package/lib/Status/Status.js +9 -4
- 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 +24 -0
- package/lib/utils/convertFromMegaByteToByte.js +16 -0
- package/lib/utils/formatImageSource.js +34 -0
- package/lib/utils/index.js +17 -1
- package/lib-module/Autocomplete/Autocomplete.js +2 -1
- package/lib-module/Button/ButtonGroup.js +17 -1
- package/lib-module/Card/Card.js +13 -1
- package/lib-module/Card/CardBase.js +38 -3
- package/lib-module/Carousel/Carousel.js +55 -13
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +86 -12
- 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/Fieldset/FieldsetContainer.js +7 -2
- package/lib-module/Fieldset/FieldsetContainer.native.js +4 -1
- package/lib-module/FileUpload/FileUpload.js +329 -0
- package/lib-module/FileUpload/NotificationContent.js +55 -0
- package/lib-module/FileUpload/dictionary.js +40 -0
- package/lib-module/FileUpload/index.js +2 -0
- package/lib-module/Icon/IconText.js +19 -2
- package/lib-module/Link/LinkBase.js +2 -2
- package/lib-module/Link/TextButton.js +7 -17
- package/lib-module/Modal/Modal.js +1 -1
- package/lib-module/Modal/ModalContent.js +12 -6
- package/lib-module/MultiSelectFilter/ModalOverlay.js +49 -30
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +171 -132
- package/lib-module/Notification/Notification.js +11 -2
- package/lib-module/Status/Status.js +9 -4
- 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 +3 -0
- package/lib-module/utils/convertFromMegaByteToByte.js +10 -0
- package/lib-module/utils/formatImageSource.js +27 -0
- package/lib-module/utils/index.js +3 -1
- package/package.json +4 -3
- package/src/Autocomplete/Autocomplete.jsx +2 -1
- package/src/Button/ButtonGroup.jsx +9 -1
- package/src/Card/Card.jsx +18 -2
- package/src/Card/CardBase.jsx +47 -12
- package/src/Carousel/Carousel.jsx +59 -13
- package/src/Carousel/CarouselItem/CarouselItem.jsx +94 -9
- package/src/DownloadApp/DownloadApp.jsx +165 -0
- package/src/DownloadApp/dictionary.js +10 -0
- package/src/DownloadApp/index.js +3 -0
- package/src/Fieldset/FieldsetContainer.jsx +4 -3
- package/src/Fieldset/FieldsetContainer.native.jsx +9 -6
- package/src/FileUpload/FileUpload.jsx +396 -0
- package/src/FileUpload/NotificationContent.jsx +44 -0
- package/src/FileUpload/dictionary.js +40 -0
- package/src/FileUpload/index.js +3 -0
- package/src/Icon/IconText.jsx +21 -4
- package/src/Link/LinkBase.jsx +2 -2
- package/src/Link/TextButton.jsx +10 -17
- package/src/Modal/Modal.jsx +1 -1
- package/src/Modal/ModalContent.jsx +8 -3
- package/src/MultiSelectFilter/ModalOverlay.jsx +44 -18
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +188 -126
- package/src/Notification/Notification.jsx +12 -4
- package/src/Status/Status.jsx +15 -4
- 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 +3 -0
- package/src/utils/convertFromMegaByteToByte.js +11 -0
- package/src/utils/formatImageSource.js +29 -0
- package/src/utils/index.js +2 -0
|
@@ -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,
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
7
|
+
function getAbsolutePosition(position) {
|
|
8
8
|
const {
|
|
9
9
|
left,
|
|
10
10
|
right,
|
|
@@ -15,7 +15,7 @@ function normalizePosition(position) {
|
|
|
15
15
|
} = position;
|
|
16
16
|
|
|
17
17
|
// adjust the coordinates so that it fits within the window
|
|
18
|
-
const
|
|
18
|
+
const finalPosition = {
|
|
19
19
|
left: Math.max(0, left),
|
|
20
20
|
right: Math.max(0, right),
|
|
21
21
|
top: Math.max(0, top),
|
|
@@ -25,15 +25,14 @@ function normalizePosition(position) {
|
|
|
25
25
|
const getAbsoluteDiff = (value1, value2) => Math.abs(Math.abs(value1) - Math.abs(value2));
|
|
26
26
|
|
|
27
27
|
// adjust the width by whatever has been subtracted from left or right
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
28
|
+
finalPosition.width = width - Math.abs(getAbsoluteDiff(left, finalPosition.left) - getAbsoluteDiff(right, finalPosition.right));
|
|
29
|
+
if (finalPosition.top !== top) {
|
|
30
|
+
finalPosition.bottom += finalPosition.top - top;
|
|
31
31
|
}
|
|
32
|
-
const isNormalized = normalized.right !== right || normalized.left !== left || normalized.top !== top;
|
|
33
32
|
return {
|
|
34
|
-
...
|
|
33
|
+
...finalPosition,
|
|
35
34
|
...rest,
|
|
36
|
-
isNormalized
|
|
35
|
+
isNormalized: false
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
function invertPosition(position) {
|
|
@@ -172,7 +171,7 @@ function getTooltipPosition(position, _ref2) {
|
|
|
172
171
|
|
|
173
172
|
// prefer 'below' over 'above', since we can always expand the document downwards,
|
|
174
173
|
// and 'above' might cause issues on small viewports with large tooltips
|
|
175
|
-
return
|
|
174
|
+
return getAbsolutePosition(leastOverflowing.position === 'above' ? findRectByPosition('below', boundingRects) : leastOverflowing);
|
|
176
175
|
}
|
|
177
176
|
var _default = getTooltipPosition;
|
|
178
177
|
exports.default = _default;
|
package/lib/index.js
CHANGED
|
@@ -13,11 +13,13 @@ var _exportNames = {
|
|
|
13
13
|
Card: true,
|
|
14
14
|
PressableCardBase: true,
|
|
15
15
|
CardGroup: true,
|
|
16
|
+
FileUpload: true,
|
|
16
17
|
Listbox: true,
|
|
17
18
|
Checkbox: true,
|
|
18
19
|
CheckboxCard: true,
|
|
19
20
|
CheckboxCardGroup: true,
|
|
20
21
|
ColourToggle: true,
|
|
22
|
+
DownloadApp: true,
|
|
21
23
|
Divider: true,
|
|
22
24
|
ExpandCollapse: true,
|
|
23
25
|
Accordion: true,
|
|
@@ -57,6 +59,7 @@ var _exportNames = {
|
|
|
57
59
|
Status: true,
|
|
58
60
|
StepTracker: true,
|
|
59
61
|
Tabs: true,
|
|
62
|
+
TabBar: true,
|
|
60
63
|
Tags: true,
|
|
61
64
|
Timeline: true,
|
|
62
65
|
Tooltip: true,
|
|
@@ -177,6 +180,12 @@ Object.defineProperty(exports, "Divider", {
|
|
|
177
180
|
return _Divider.default;
|
|
178
181
|
}
|
|
179
182
|
});
|
|
183
|
+
Object.defineProperty(exports, "DownloadApp", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
get: function () {
|
|
186
|
+
return _DownloadApp.default;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
180
189
|
Object.defineProperty(exports, "ExpandCollapse", {
|
|
181
190
|
enumerable: true,
|
|
182
191
|
get: function () {
|
|
@@ -195,6 +204,12 @@ Object.defineProperty(exports, "Fieldset", {
|
|
|
195
204
|
return _Fieldset.default;
|
|
196
205
|
}
|
|
197
206
|
});
|
|
207
|
+
Object.defineProperty(exports, "FileUpload", {
|
|
208
|
+
enumerable: true,
|
|
209
|
+
get: function () {
|
|
210
|
+
return _FileUpload.default;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
198
213
|
Object.defineProperty(exports, "FlexGrid", {
|
|
199
214
|
enumerable: true,
|
|
200
215
|
get: function () {
|
|
@@ -411,6 +426,12 @@ Object.defineProperty(exports, "StepTracker", {
|
|
|
411
426
|
return _StepTracker.default;
|
|
412
427
|
}
|
|
413
428
|
});
|
|
429
|
+
Object.defineProperty(exports, "TabBar", {
|
|
430
|
+
enumerable: true,
|
|
431
|
+
get: function () {
|
|
432
|
+
return _TabBar.default;
|
|
433
|
+
}
|
|
434
|
+
});
|
|
414
435
|
Object.defineProperty(exports, "Tabs", {
|
|
415
436
|
enumerable: true,
|
|
416
437
|
get: function () {
|
|
@@ -569,6 +590,7 @@ Object.keys(_Carousel).forEach(function (key) {
|
|
|
569
590
|
}
|
|
570
591
|
});
|
|
571
592
|
});
|
|
593
|
+
var _FileUpload = _interopRequireDefault(require("./FileUpload"));
|
|
572
594
|
var _Listbox = _interopRequireDefault(require("./Listbox"));
|
|
573
595
|
var _Checkbox = _interopRequireWildcard(require("./Checkbox"));
|
|
574
596
|
Object.keys(_Checkbox).forEach(function (key) {
|
|
@@ -585,6 +607,7 @@ Object.keys(_Checkbox).forEach(function (key) {
|
|
|
585
607
|
var _CheckboxCard = _interopRequireDefault(require("./CheckboxCard"));
|
|
586
608
|
var _CheckboxCardGroup = _interopRequireDefault(require("./CheckboxCardGroup"));
|
|
587
609
|
var _ColourToggle = _interopRequireDefault(require("./ColourToggle"));
|
|
610
|
+
var _DownloadApp = _interopRequireDefault(require("./DownloadApp"));
|
|
588
611
|
var _Divider = _interopRequireDefault(require("./Divider"));
|
|
589
612
|
var _ExpandCollapse = _interopRequireWildcard(require("./ExpandCollapse"));
|
|
590
613
|
var _Feedback = _interopRequireDefault(require("./Feedback"));
|
|
@@ -688,6 +711,7 @@ Object.keys(_StackView).forEach(function (key) {
|
|
|
688
711
|
var _Status = _interopRequireDefault(require("./Status"));
|
|
689
712
|
var _StepTracker = _interopRequireDefault(require("./StepTracker"));
|
|
690
713
|
var _Tabs = _interopRequireDefault(require("./Tabs"));
|
|
714
|
+
var _TabBar = _interopRequireDefault(require("./TabBar"));
|
|
691
715
|
var _Tags = _interopRequireDefault(require("./Tags"));
|
|
692
716
|
var _TextInput = require("./TextInput");
|
|
693
717
|
Object.keys(_TextInput).forEach(function (key) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = convertFromMegaByteToByte;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a value from megabytes to bytes.
|
|
9
|
+
*
|
|
10
|
+
* @param {number} megaByte - The value in megabytes to be converted.
|
|
11
|
+
* @returns {number} The converted value in bytes.
|
|
12
|
+
*/
|
|
13
|
+
const BYTES_IN_A_MEGABYTE = 1024 * 1024;
|
|
14
|
+
function convertFromMegaByteToByte(megaByte) {
|
|
15
|
+
return megaByte * BYTES_IN_A_MEGABYTE;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// react native source for Image and ImageBackground needs proper formatting to work
|
|
8
|
+
// remote sources that start with 'http' and base64 encoded sources that start with 'data:' need be wrapped in uri when passing source prop for Image and ImageBackground ie. source={ uri: image }
|
|
9
|
+
// local source for image can be passed normally without wrapping in uri ie. source={ image }
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* example code from react native docs: https://reactnative.dev/docs/imagebackground
|
|
13
|
+
*
|
|
14
|
+
* const image = {uri: 'https://legacy.reactjs.org/logo-og.png'}
|
|
15
|
+
*
|
|
16
|
+
* const App = () => (
|
|
17
|
+
* <View style={styles.container}>
|
|
18
|
+
* <ImageBackground source={image} resizeMode="cover" style={styles.image}>
|
|
19
|
+
* <Text style={styles.text}>Inside</Text>
|
|
20
|
+
* </ImageBackground>
|
|
21
|
+
* </View>
|
|
22
|
+
* )
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Formats the image source for React Native Image and ImageBackground components.
|
|
27
|
+
* @param {string|number} source - The image source, either a URI string or a number (when a local image source is bundled in IOS or Android app).
|
|
28
|
+
* @returns {object|string} - The formatted image source.
|
|
29
|
+
*/
|
|
30
|
+
const formatImageSource = source => typeof source === 'string' && (source.startsWith('http') || source.startsWith('data:')) ? {
|
|
31
|
+
uri: source
|
|
32
|
+
} : source;
|
|
33
|
+
var _default = formatImageSource;
|
|
34
|
+
exports.default = _default;
|
package/lib/utils/index.js
CHANGED
|
@@ -17,7 +17,9 @@ var _exportNames = {
|
|
|
17
17
|
containUniqueFields: true,
|
|
18
18
|
BaseView: true,
|
|
19
19
|
htmlAttrs: true,
|
|
20
|
-
transformGradient: true
|
|
20
|
+
transformGradient: true,
|
|
21
|
+
convertFromMegaByteToByte: true,
|
|
22
|
+
formatImageSource: true
|
|
21
23
|
};
|
|
22
24
|
Object.defineProperty(exports, "BaseView", {
|
|
23
25
|
enumerable: true,
|
|
@@ -31,6 +33,18 @@ Object.defineProperty(exports, "containUniqueFields", {
|
|
|
31
33
|
return _containUniqueFields.default;
|
|
32
34
|
}
|
|
33
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "convertFromMegaByteToByte", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _convertFromMegaByteToByte.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "formatImageSource", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _formatImageSource.default;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
34
48
|
Object.defineProperty(exports, "htmlAttrs", {
|
|
35
49
|
enumerable: true,
|
|
36
50
|
get: function () {
|
|
@@ -224,6 +238,8 @@ var _containUniqueFields = _interopRequireDefault(require("./containUniqueFields
|
|
|
224
238
|
var _BaseView = _interopRequireDefault(require("./BaseView"));
|
|
225
239
|
var _htmlAttrs = _interopRequireDefault(require("./htmlAttrs"));
|
|
226
240
|
var _transformGradient = require("./transformGradient");
|
|
241
|
+
var _convertFromMegaByteToByte = _interopRequireDefault(require("./convertFromMegaByteToByte"));
|
|
242
|
+
var _formatImageSource = _interopRequireDefault(require("./formatImageSource"));
|
|
227
243
|
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); }
|
|
228
244
|
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; }
|
|
229
245
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -106,6 +106,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
106
106
|
validation,
|
|
107
107
|
value,
|
|
108
108
|
helpText = '',
|
|
109
|
+
loadingLabel,
|
|
109
110
|
...rest
|
|
110
111
|
} = _ref2;
|
|
111
112
|
const {
|
|
@@ -341,7 +342,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
341
342
|
onLayout: handleMeasure,
|
|
342
343
|
ref: openOverlayRef,
|
|
343
344
|
children: isLoading ? /*#__PURE__*/_jsx(Loading, {
|
|
344
|
-
label: getCopy('loading')
|
|
345
|
+
label: loadingLabel ?? getCopy('loading')
|
|
345
346
|
}) : /*#__PURE__*/_jsx(Suggestions, {
|
|
346
347
|
hasResults: getCopy('hasResults'),
|
|
347
348
|
id: "autocomplete",
|
|
@@ -48,7 +48,11 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
48
48
|
const {
|
|
49
49
|
direction,
|
|
50
50
|
space,
|
|
51
|
-
fieldSpace
|
|
51
|
+
fieldSpace,
|
|
52
|
+
borderRadius,
|
|
53
|
+
backgroundColor,
|
|
54
|
+
padding,
|
|
55
|
+
gap
|
|
52
56
|
} = themeTokens;
|
|
53
57
|
const getButtonTokens = useThemeTokensCallback('ButtonGroupItem', tokens, variant);
|
|
54
58
|
const {
|
|
@@ -87,12 +91,24 @@ const ButtonGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
87
91
|
inactive: inactive,
|
|
88
92
|
validation: validation,
|
|
89
93
|
accessibilityRole: accessibilityRole,
|
|
94
|
+
style: {
|
|
95
|
+
borderRadius,
|
|
96
|
+
backgroundColor,
|
|
97
|
+
padding,
|
|
98
|
+
...(Platform.OS === 'web' ? {
|
|
99
|
+
gap,
|
|
100
|
+
width: 'fit-content'
|
|
101
|
+
} : {
|
|
102
|
+
alignSelf: 'flex-start'
|
|
103
|
+
})
|
|
104
|
+
},
|
|
90
105
|
...selectProps(rest),
|
|
91
106
|
children: /*#__PURE__*/_jsx(StackWrap, {
|
|
92
107
|
accessibilityRole: innerRole,
|
|
93
108
|
space: space,
|
|
94
109
|
direction: direction,
|
|
95
110
|
tokens: stackTokens,
|
|
111
|
+
gap: gap,
|
|
96
112
|
ref: ref,
|
|
97
113
|
children: items.map((_ref2, index) => {
|
|
98
114
|
let {
|
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, linkProps, selectSystemProps, viewProps } from '../utils/props';
|
|
7
|
+
import { a11yProps, linkProps, selectSystemProps, viewProps, responsiveProps } from '../utils/props';
|
|
8
8
|
import CardBase from './CardBase';
|
|
9
9
|
import PressableCardBase from './PressableCardBase';
|
|
10
10
|
import CheckboxButton from '../Checkbox/CheckboxButton';
|
|
@@ -112,6 +112,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
112
112
|
onPress,
|
|
113
113
|
id,
|
|
114
114
|
interactiveCard,
|
|
115
|
+
backgroundImage,
|
|
115
116
|
...rest
|
|
116
117
|
} = _ref3;
|
|
117
118
|
const viewport = useViewport();
|
|
@@ -235,6 +236,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
235
236
|
children: /*#__PURE__*/_jsx(CardBase, {
|
|
236
237
|
ref: ref,
|
|
237
238
|
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : cardStyles,
|
|
239
|
+
backgroundImage: backgroundImage,
|
|
238
240
|
dataSet: mediaIds && {
|
|
239
241
|
media: mediaIds
|
|
240
242
|
},
|
|
@@ -313,6 +315,16 @@ Card.propTypes = {
|
|
|
313
315
|
tokens: getTokensPropType('Card'),
|
|
314
316
|
selectionType: PropTypes.oneOf(Object.values(SelectionType)),
|
|
315
317
|
variant: variantProp.propType
|
|
318
|
+
}),
|
|
319
|
+
/**
|
|
320
|
+
* Apply background image to the card.
|
|
321
|
+
*/
|
|
322
|
+
backgroundImage: PropTypes.shape({
|
|
323
|
+
// The image src is either a URI string or a number (when a local image src is bundled in IOS or Android app)
|
|
324
|
+
// src is an object when used responsively to provide different image sources for different screen sizes
|
|
325
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,
|
|
326
|
+
alt: PropTypes.string,
|
|
327
|
+
resizeMode: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
|
|
316
328
|
})
|
|
317
329
|
};
|
|
318
330
|
export default Card;
|