@telus-uds/components-base 3.6.0 → 3.7.1
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 +22 -2
- package/lib/cjs/Card/Card.js +12 -2
- package/lib/cjs/Card/PressableCardBase.js +70 -1
- package/lib/cjs/Icon/Icon.js +2 -1
- package/lib/cjs/InputLabel/InputLabel.js +9 -3
- package/lib/cjs/InputSupports/InputSupports.js +6 -2
- package/lib/cjs/List/ListItemMark.js +8 -4
- package/lib/cjs/ToggleSwitch/ToggleSwitch.js +11 -3
- package/lib/cjs/ToggleSwitch/ToggleSwitchGroup.js +9 -1
- package/lib/cjs/Tooltip/shared.js +5 -4
- package/lib/cjs/utils/props/inputSupportsProps.js +6 -2
- package/lib/esm/Card/Card.js +13 -3
- package/lib/esm/Card/PressableCardBase.js +70 -1
- package/lib/esm/Icon/Icon.js +2 -1
- package/lib/esm/InputLabel/InputLabel.js +9 -3
- package/lib/esm/InputSupports/InputSupports.js +6 -2
- package/lib/esm/List/ListItemMark.js +9 -5
- package/lib/esm/ToggleSwitch/ToggleSwitch.js +11 -3
- package/lib/esm/ToggleSwitch/ToggleSwitchGroup.js +9 -1
- package/lib/esm/Tooltip/shared.js +2 -1
- package/lib/esm/utils/props/inputSupportsProps.js +6 -2
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Card/Card.jsx +20 -3
- package/src/Card/PressableCardBase.jsx +60 -2
- package/src/Icon/Icon.jsx +6 -1
- package/src/InputLabel/InputLabel.jsx +7 -2
- package/src/InputSupports/InputSupports.jsx +6 -2
- package/src/List/ListItemMark.jsx +5 -3
- package/src/ToggleSwitch/ToggleSwitch.jsx +14 -2
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +9 -1
- package/src/Tooltip/shared.js +2 -2
- package/src/utils/props/inputSupportsProps.js +6 -2
- package/types/ToggleSwitch.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 05 May 2025 21:28:44 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.7.1
|
|
8
|
+
|
|
9
|
+
Mon, 05 May 2025 21:28:44 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- `Card`: fix underline style (guillermo.peitzner@telus.com)
|
|
14
|
+
|
|
15
|
+
## 3.7.0
|
|
16
|
+
|
|
17
|
+
Thu, 01 May 2025 20:13:57 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- `Card`: add href and hrefAttrs props (guillermo.peitzner@telus.com)
|
|
22
|
+
- `Icon`: add gradient color support (guillermo.peitzner@telus.com)
|
|
23
|
+
- `togglePosition`: add prop to ToggleSwitch & ToggleSwitchGroup (sergio.ramirez@telus.com)
|
|
24
|
+
- `TextArea`: update tooltip prop object to control tooltip entirely by only one prop object (shivam.gupta3@telus.com)
|
|
25
|
+
- Bump @telus-uds/system-theme-tokens to v4.5.0
|
|
26
|
+
|
|
7
27
|
## 3.6.0
|
|
8
28
|
|
|
9
|
-
Thu, 24 Apr 2025 18:
|
|
29
|
+
Thu, 24 Apr 2025 18:56:23 GMT
|
|
10
30
|
|
|
11
31
|
### Minor changes
|
|
12
32
|
|
package/lib/cjs/Card/Card.js
CHANGED
|
@@ -251,6 +251,8 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
251
251
|
tokens: getThemeTokens,
|
|
252
252
|
dataSet: dataSet,
|
|
253
253
|
onPress: onPress,
|
|
254
|
+
href: interactiveCard?.href,
|
|
255
|
+
hrefAttrs: interactiveCard?.hrefAttrs,
|
|
254
256
|
...selectProps(rest),
|
|
255
257
|
children: cardState => {
|
|
256
258
|
const {
|
|
@@ -313,12 +315,16 @@ Card.propTypes = {
|
|
|
313
315
|
- `radiogroup`
|
|
314
316
|
- `checkbox`
|
|
315
317
|
* - variant: The variant to be used for the interactive card
|
|
318
|
+
* - href: The href to be used for the interactive card
|
|
319
|
+
* - hrefAttrs: The href attributes to be used for the interactive card
|
|
316
320
|
*/
|
|
317
321
|
interactiveCard: _propTypes.default.shape({
|
|
318
322
|
body: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
319
323
|
tokens: (0, _utils.getTokensPropType)('Card'),
|
|
320
324
|
selectionType: _propTypes.default.oneOf(Object.values(SelectionType)),
|
|
321
|
-
variant: _utils.variantProp.propType
|
|
325
|
+
variant: _utils.variantProp.propType,
|
|
326
|
+
href: _propTypes.default.string,
|
|
327
|
+
hrefAttrs: _propTypes.default.shape(_props.hrefAttrsProp.types)
|
|
322
328
|
}),
|
|
323
329
|
/**
|
|
324
330
|
* Apply background image to the card.
|
|
@@ -329,6 +335,10 @@ Card.propTypes = {
|
|
|
329
335
|
src: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.object]).isRequired,
|
|
330
336
|
alt: _propTypes.default.string,
|
|
331
337
|
resizeMode: _props.responsiveProps.getTypeOptionallyByViewport(_propTypes.default.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
|
|
332
|
-
})
|
|
338
|
+
}),
|
|
339
|
+
/**
|
|
340
|
+
* Data set for the card.
|
|
341
|
+
*/
|
|
342
|
+
dataSet: _propTypes.default.object
|
|
333
343
|
};
|
|
334
344
|
var _default = exports.default = Card;
|
|
@@ -8,6 +8,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
10
10
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
12
|
+
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
13
|
var _ViewportProvider = require("../ViewportProvider");
|
|
12
14
|
var _ThemeProvider = require("../ThemeProvider");
|
|
13
15
|
var _utils = require("../utils");
|
|
@@ -88,8 +90,69 @@ const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
88
90
|
});
|
|
89
91
|
const handleKeyDown = event => {
|
|
90
92
|
// The expected keyboard shortcut for selecting a focused item is the Space key
|
|
91
|
-
if (event?.key === ' ') handleChange(event);
|
|
93
|
+
if (event?.key === ' ') handleChange?.(event);
|
|
92
94
|
};
|
|
95
|
+
const [hovered, setHovered] = _react.default.useState(false);
|
|
96
|
+
const [focused, setFocused] = _react.default.useState(false);
|
|
97
|
+
const [pressed, setPressed] = _react.default.useState(false);
|
|
98
|
+
if (_Platform.default.OS === 'web' && href) {
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
100
|
+
ref: ref,
|
|
101
|
+
style: getOuterBorderStyle({
|
|
102
|
+
pressed,
|
|
103
|
+
focused,
|
|
104
|
+
hovered
|
|
105
|
+
}),
|
|
106
|
+
dataSet: dataSet,
|
|
107
|
+
onMouseEnter: () => setHovered(true),
|
|
108
|
+
onMouseLeave: () => setHovered(false),
|
|
109
|
+
...selectProps({
|
|
110
|
+
...rest,
|
|
111
|
+
accessibilityRole
|
|
112
|
+
}),
|
|
113
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
114
|
+
href: href,
|
|
115
|
+
tabIndex: 0,
|
|
116
|
+
onClick: event => {
|
|
117
|
+
setPressed(false);
|
|
118
|
+
handleChange?.(event);
|
|
119
|
+
},
|
|
120
|
+
onKeyDown: event => {
|
|
121
|
+
if (event.key === ' ') {
|
|
122
|
+
setPressed(true);
|
|
123
|
+
handleKeyDown(event);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
onKeyUp: event => {
|
|
127
|
+
if (event.key === ' ') setPressed(false);
|
|
128
|
+
},
|
|
129
|
+
onMouseDown: () => setPressed(true),
|
|
130
|
+
onMouseUp: () => setPressed(false),
|
|
131
|
+
onFocus: () => setFocused(true),
|
|
132
|
+
onBlur: () => {
|
|
133
|
+
setFocused(false);
|
|
134
|
+
setPressed(false);
|
|
135
|
+
},
|
|
136
|
+
style: {
|
|
137
|
+
...staticStyles.container,
|
|
138
|
+
textDecoration: 'none'
|
|
139
|
+
},
|
|
140
|
+
...(hrefAttrs || {}),
|
|
141
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
|
|
142
|
+
tokens: getCardTokens({
|
|
143
|
+
pressed,
|
|
144
|
+
focused,
|
|
145
|
+
hovered
|
|
146
|
+
}),
|
|
147
|
+
children: typeof children === 'function' ? children(getCardState({
|
|
148
|
+
pressed,
|
|
149
|
+
focused,
|
|
150
|
+
hovered
|
|
151
|
+
})) : children
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
}
|
|
93
156
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
94
157
|
ref: ref,
|
|
95
158
|
href: href,
|
|
@@ -108,6 +171,12 @@ const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
108
171
|
})
|
|
109
172
|
});
|
|
110
173
|
});
|
|
174
|
+
const staticStyles = _StyleSheet.default.create({
|
|
175
|
+
container: {
|
|
176
|
+
flex: 1,
|
|
177
|
+
display: 'flex'
|
|
178
|
+
}
|
|
179
|
+
});
|
|
111
180
|
PressableCardBase.displayName = 'PressableCardBase';
|
|
112
181
|
PressableCardBase.propTypes = {
|
|
113
182
|
...selectedSystemPropTypes,
|
package/lib/cjs/Icon/Icon.js
CHANGED
|
@@ -31,7 +31,8 @@ const Icon = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
31
31
|
const iconContent = /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
|
|
32
32
|
title: accessibilityLabel,
|
|
33
33
|
size: size,
|
|
34
|
-
color: themeTokens.color
|
|
34
|
+
color: themeTokens.color,
|
|
35
|
+
gradient: themeTokens.gradient
|
|
35
36
|
});
|
|
36
37
|
const paddingStyles = variant?.padding ? {
|
|
37
38
|
padding: themeTokens.width,
|
|
@@ -13,6 +13,7 @@ var _ThemeProvider = require("../ThemeProvider");
|
|
|
13
13
|
var _utils = require("../utils");
|
|
14
14
|
var _LabelContent = _interopRequireDefault(require("./LabelContent"));
|
|
15
15
|
var _Tooltip = _interopRequireDefault(require("../Tooltip"));
|
|
16
|
+
var _shared = _interopRequireDefault(require("../Tooltip/shared"));
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
@@ -66,6 +67,11 @@ const InputLabel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
66
67
|
const {
|
|
67
68
|
themeOptions
|
|
68
69
|
} = (0, _ThemeProvider.useTheme)();
|
|
70
|
+
const getTooltipProps = () => {
|
|
71
|
+
return typeof tooltip === 'string' ? {
|
|
72
|
+
content: tooltip
|
|
73
|
+
} : tooltip;
|
|
74
|
+
};
|
|
69
75
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
70
76
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
71
77
|
ref: ref,
|
|
@@ -87,8 +93,8 @@ const InputLabel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
87
93
|
color: themeTokens.color
|
|
88
94
|
}],
|
|
89
95
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
copy: copy,
|
|
97
|
+
...getTooltipProps()
|
|
92
98
|
})
|
|
93
99
|
}), maxCharacterAllowed && isHintInline && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Text.default, {
|
|
94
100
|
style: [selectHintStyles({
|
|
@@ -143,7 +149,7 @@ InputLabel.propTypes = {
|
|
|
143
149
|
/**
|
|
144
150
|
* Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
|
|
145
151
|
*/
|
|
146
|
-
tooltip: _propTypes.default.string,
|
|
152
|
+
tooltip: _propTypes.default.oneOfType([_shared.default, _propTypes.default.string]),
|
|
147
153
|
/**
|
|
148
154
|
* Current number of characterts of an input text.
|
|
149
155
|
*/
|
|
@@ -13,6 +13,7 @@ var _ThemeProvider = require("../ThemeProvider");
|
|
|
13
13
|
var _useInputSupports = _interopRequireDefault(require("./useInputSupports"));
|
|
14
14
|
var _utils = require("../utils");
|
|
15
15
|
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
16
|
+
var _shared = _interopRequireDefault(require("../Tooltip/shared"));
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
const InputSupports = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
@@ -117,9 +118,12 @@ InputSupports.propTypes = {
|
|
|
117
118
|
*/
|
|
118
119
|
feedbackProps: _propTypes.default.object,
|
|
119
120
|
/**
|
|
120
|
-
*
|
|
121
|
+
* an optional `Tooltip`. If set, tooltip will be shown next to the label.
|
|
122
|
+
* Props can be passed to the tooltip in one of the following ways.
|
|
123
|
+
* 1. `tooltip` as a string - The content of the tooltip.
|
|
124
|
+
* 2. `tooltip` as an object - Tooltip component props to be passed.
|
|
121
125
|
*/
|
|
122
|
-
tooltip: _propTypes.default.string,
|
|
126
|
+
tooltip: _propTypes.default.oneOfType([_shared.default, _propTypes.default.string]),
|
|
123
127
|
/**
|
|
124
128
|
* Use to visually mark an input as valid or invalid.
|
|
125
129
|
*/
|
|
@@ -75,7 +75,6 @@ const ListItemMark = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
|
|
|
75
75
|
iconSize,
|
|
76
76
|
tokens = {}
|
|
77
77
|
} = _ref5;
|
|
78
|
-
const IconComponent = icon || /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
|
|
79
78
|
const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
|
|
80
79
|
const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
|
|
81
80
|
const bulletContainerStyles = selectBulletContainerStyles(themeTokens);
|
|
@@ -83,9 +82,14 @@ const ListItemMark = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
|
|
|
83
82
|
const iconTokens = selectItemIconTokens(themeTokens);
|
|
84
83
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
85
84
|
style: [sideItemContainerStyles, bulletContainerStyles],
|
|
86
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
86
|
+
icon: icon,
|
|
87
|
+
tokens: {
|
|
88
|
+
size: iconSize ?? iconTokens.size
|
|
89
|
+
},
|
|
90
|
+
variant: {
|
|
91
|
+
color: iconColor ?? iconTokens.color
|
|
92
|
+
}
|
|
89
93
|
})
|
|
90
94
|
});
|
|
91
95
|
}
|
|
@@ -139,6 +139,7 @@ const ToggleSwitch = /*#__PURE__*/_react.default.forwardRef((_ref9, ref) => {
|
|
|
139
139
|
variant,
|
|
140
140
|
accessibilityRole = 'switch',
|
|
141
141
|
accessibilityLabel = label,
|
|
142
|
+
togglePosition = 'end',
|
|
142
143
|
...rest
|
|
143
144
|
} = _ref9;
|
|
144
145
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ToggleSwitch', tokens, variant);
|
|
@@ -157,9 +158,10 @@ const ToggleSwitch = /*#__PURE__*/_react.default.forwardRef((_ref9, ref) => {
|
|
|
157
158
|
const inputId = id ?? uniqueId;
|
|
158
159
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
|
|
159
160
|
space: themeTokens.space,
|
|
160
|
-
direction:
|
|
161
|
+
direction: togglePosition === 'start' ? 'row-reverse' : 'row',
|
|
161
162
|
tokens: {
|
|
162
|
-
alignItems: 'center'
|
|
163
|
+
alignItems: 'center',
|
|
164
|
+
justifyContent: 'start'
|
|
163
165
|
},
|
|
164
166
|
children: [Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
165
167
|
style: [selectLabelStyles(themeTokens), staticStyles.containText],
|
|
@@ -265,7 +267,13 @@ ToggleSwitch.propTypes = {
|
|
|
265
267
|
/**
|
|
266
268
|
* Content of an optional Tooltip. If set, a tooltip button will be shown next to the label.
|
|
267
269
|
*/
|
|
268
|
-
tooltip: _propTypes.default.string
|
|
270
|
+
tooltip: _propTypes.default.string,
|
|
271
|
+
/**
|
|
272
|
+
* Controls the position of the switch in relation to the label.
|
|
273
|
+
* - 'start': switch on the start, before the `label` and `tooltip`.
|
|
274
|
+
* - 'end': switch to the end, after the `label` and `tooltip` (default).
|
|
275
|
+
*/
|
|
276
|
+
togglePosition: _propTypes.default.oneOf(['start', 'end'])
|
|
269
277
|
};
|
|
270
278
|
const staticStyles = _StyleSheet.default.create({
|
|
271
279
|
track: {
|
|
@@ -79,6 +79,7 @@ const ToggleSwitchGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
79
79
|
onChange: itemOnChange,
|
|
80
80
|
ref: itemRef,
|
|
81
81
|
tooltip: itemTooltip,
|
|
82
|
+
togglePosition,
|
|
82
83
|
...itemRest
|
|
83
84
|
} = _ref2;
|
|
84
85
|
const isSelected = currentValues.includes(id);
|
|
@@ -104,6 +105,7 @@ const ToggleSwitchGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
104
105
|
inactive: inactive,
|
|
105
106
|
label: label,
|
|
106
107
|
tooltip: itemTooltip,
|
|
108
|
+
togglePosition: togglePosition,
|
|
107
109
|
...itemA11y,
|
|
108
110
|
...selectItemProps(itemRest)
|
|
109
111
|
}, id);
|
|
@@ -163,7 +165,13 @@ ToggleSwitchGroup.propTypes = {
|
|
|
163
165
|
/**
|
|
164
166
|
* An optional ref for one individual ToggleSwitch in the ToggleSwitchGroup
|
|
165
167
|
*/
|
|
166
|
-
ref: _airbnbPropTypes.default.ref()
|
|
168
|
+
ref: _airbnbPropTypes.default.ref(),
|
|
169
|
+
/**
|
|
170
|
+
* Controls the position of the switch in relation to the label.
|
|
171
|
+
* - 'start': switch on the start, before the `label` and `tooltip`.
|
|
172
|
+
* - 'end': switch to the end, after the `label` and `tooltip` (default).
|
|
173
|
+
*/
|
|
174
|
+
togglePosition: _propTypes.default.oneOf(['start', 'end'])
|
|
167
175
|
})),
|
|
168
176
|
/**
|
|
169
177
|
* If provided, this function is called when the current selection is changed
|
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var
|
|
8
|
+
var _tokens = require("../utils/props/tokens");
|
|
9
|
+
var _variantProp = _interopRequireDefault(require("../utils/props/variantProp"));
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
const propTypes = {
|
|
11
12
|
/**
|
|
@@ -41,8 +42,8 @@ const propTypes = {
|
|
|
41
42
|
* Set to `true` to open the tooltip on hover
|
|
42
43
|
*/
|
|
43
44
|
activateOnHover: _propTypes.default.bool,
|
|
44
|
-
tooltipButtonTokens: (0,
|
|
45
|
-
tokens: (0,
|
|
46
|
-
variant:
|
|
45
|
+
tooltipButtonTokens: (0, _tokens.getTokensPropType)('TooltipButton'),
|
|
46
|
+
tokens: (0, _tokens.getTokensPropType)('Tooltip'),
|
|
47
|
+
variant: _variantProp.default.propType
|
|
47
48
|
};
|
|
48
49
|
var _default = exports.default = propTypes;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _shared = _interopRequireDefault(require("../../Tooltip/shared"));
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
var _default = exports.default = {
|
|
10
11
|
types: {
|
|
@@ -38,9 +39,12 @@ var _default = exports.default = {
|
|
|
38
39
|
*/
|
|
39
40
|
feedbackProps: _propTypes.default.object,
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* an optional `Tooltip`. If set, tooltip will be shown next to the label.
|
|
43
|
+
* Props can be passed to the tooltip in one of the following ways.
|
|
44
|
+
* 1. `tooltip` as a string - The content of the tooltip.
|
|
45
|
+
* 2. `tooltip` as an object - Tooltip component props to be passed.
|
|
42
46
|
*/
|
|
43
|
-
tooltip: _propTypes.default.string,
|
|
47
|
+
tooltip: _propTypes.default.oneOfType([_shared.default, _propTypes.default.string]),
|
|
44
48
|
/**
|
|
45
49
|
* Use to visually mark an input as valid or invalid.
|
|
46
50
|
*/
|
package/lib/esm/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, responsiveProps } from '../utils/props';
|
|
7
|
+
import { a11yProps, linkProps, selectSystemProps, viewProps, responsiveProps, hrefAttrsProp } from '../utils/props';
|
|
8
8
|
import CardBase from './CardBase';
|
|
9
9
|
import PressableCardBase from './PressableCardBase';
|
|
10
10
|
import CheckboxButton from '../Checkbox/CheckboxButton';
|
|
@@ -244,6 +244,8 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
244
244
|
tokens: getThemeTokens,
|
|
245
245
|
dataSet: dataSet,
|
|
246
246
|
onPress: onPress,
|
|
247
|
+
href: interactiveCard?.href,
|
|
248
|
+
hrefAttrs: interactiveCard?.hrefAttrs,
|
|
247
249
|
...selectProps(rest),
|
|
248
250
|
children: cardState => {
|
|
249
251
|
const {
|
|
@@ -306,12 +308,16 @@ Card.propTypes = {
|
|
|
306
308
|
- `radiogroup`
|
|
307
309
|
- `checkbox`
|
|
308
310
|
* - variant: The variant to be used for the interactive card
|
|
311
|
+
* - href: The href to be used for the interactive card
|
|
312
|
+
* - hrefAttrs: The href attributes to be used for the interactive card
|
|
309
313
|
*/
|
|
310
314
|
interactiveCard: PropTypes.shape({
|
|
311
315
|
body: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
312
316
|
tokens: getTokensPropType('Card'),
|
|
313
317
|
selectionType: PropTypes.oneOf(Object.values(SelectionType)),
|
|
314
|
-
variant: variantProp.propType
|
|
318
|
+
variant: variantProp.propType,
|
|
319
|
+
href: PropTypes.string,
|
|
320
|
+
hrefAttrs: PropTypes.shape(hrefAttrsProp.types)
|
|
315
321
|
}),
|
|
316
322
|
/**
|
|
317
323
|
* Apply background image to the card.
|
|
@@ -322,6 +328,10 @@ Card.propTypes = {
|
|
|
322
328
|
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,
|
|
323
329
|
alt: PropTypes.string,
|
|
324
330
|
resizeMode: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
|
|
325
|
-
})
|
|
331
|
+
}),
|
|
332
|
+
/**
|
|
333
|
+
* Data set for the card.
|
|
334
|
+
*/
|
|
335
|
+
dataSet: PropTypes.object
|
|
326
336
|
};
|
|
327
337
|
export default Card;
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
4
4
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
+
import View from "react-native-web/dist/exports/View";
|
|
6
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
7
|
import { useViewport } from '../ViewportProvider';
|
|
6
8
|
import { applyOuterBorder, validateThemeTokens } from '../ThemeProvider';
|
|
7
9
|
import { a11yProps, clickProps, focusHandlerProps, getTokensSetPropType, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
|
|
@@ -80,8 +82,69 @@ const PressableCardBase = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
80
82
|
});
|
|
81
83
|
const handleKeyDown = event => {
|
|
82
84
|
// The expected keyboard shortcut for selecting a focused item is the Space key
|
|
83
|
-
if (event?.key === ' ') handleChange(event);
|
|
85
|
+
if (event?.key === ' ') handleChange?.(event);
|
|
84
86
|
};
|
|
87
|
+
const [hovered, setHovered] = React.useState(false);
|
|
88
|
+
const [focused, setFocused] = React.useState(false);
|
|
89
|
+
const [pressed, setPressed] = React.useState(false);
|
|
90
|
+
if (Platform.OS === 'web' && href) {
|
|
91
|
+
return /*#__PURE__*/_jsx(View, {
|
|
92
|
+
ref: ref,
|
|
93
|
+
style: getOuterBorderStyle({
|
|
94
|
+
pressed,
|
|
95
|
+
focused,
|
|
96
|
+
hovered
|
|
97
|
+
}),
|
|
98
|
+
dataSet: dataSet,
|
|
99
|
+
onMouseEnter: () => setHovered(true),
|
|
100
|
+
onMouseLeave: () => setHovered(false),
|
|
101
|
+
...selectProps({
|
|
102
|
+
...rest,
|
|
103
|
+
accessibilityRole
|
|
104
|
+
}),
|
|
105
|
+
children: /*#__PURE__*/_jsx("a", {
|
|
106
|
+
href: href,
|
|
107
|
+
tabIndex: 0,
|
|
108
|
+
onClick: event => {
|
|
109
|
+
setPressed(false);
|
|
110
|
+
handleChange?.(event);
|
|
111
|
+
},
|
|
112
|
+
onKeyDown: event => {
|
|
113
|
+
if (event.key === ' ') {
|
|
114
|
+
setPressed(true);
|
|
115
|
+
handleKeyDown(event);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
onKeyUp: event => {
|
|
119
|
+
if (event.key === ' ') setPressed(false);
|
|
120
|
+
},
|
|
121
|
+
onMouseDown: () => setPressed(true),
|
|
122
|
+
onMouseUp: () => setPressed(false),
|
|
123
|
+
onFocus: () => setFocused(true),
|
|
124
|
+
onBlur: () => {
|
|
125
|
+
setFocused(false);
|
|
126
|
+
setPressed(false);
|
|
127
|
+
},
|
|
128
|
+
style: {
|
|
129
|
+
...staticStyles.container,
|
|
130
|
+
textDecoration: 'none'
|
|
131
|
+
},
|
|
132
|
+
...(hrefAttrs || {}),
|
|
133
|
+
children: /*#__PURE__*/_jsx(CardBase, {
|
|
134
|
+
tokens: getCardTokens({
|
|
135
|
+
pressed,
|
|
136
|
+
focused,
|
|
137
|
+
hovered
|
|
138
|
+
}),
|
|
139
|
+
children: typeof children === 'function' ? children(getCardState({
|
|
140
|
+
pressed,
|
|
141
|
+
focused,
|
|
142
|
+
hovered
|
|
143
|
+
})) : children
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
}
|
|
85
148
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
86
149
|
ref: ref,
|
|
87
150
|
href: href,
|
|
@@ -100,6 +163,12 @@ const PressableCardBase = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
100
163
|
})
|
|
101
164
|
});
|
|
102
165
|
});
|
|
166
|
+
const staticStyles = StyleSheet.create({
|
|
167
|
+
container: {
|
|
168
|
+
flex: 1,
|
|
169
|
+
display: 'flex'
|
|
170
|
+
}
|
|
171
|
+
});
|
|
103
172
|
PressableCardBase.displayName = 'PressableCardBase';
|
|
104
173
|
PressableCardBase.propTypes = {
|
|
105
174
|
...selectedSystemPropTypes,
|
package/lib/esm/Icon/Icon.js
CHANGED
|
@@ -24,7 +24,8 @@ const Icon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
24
24
|
const iconContent = /*#__PURE__*/_jsx(IconComponent, {
|
|
25
25
|
title: accessibilityLabel,
|
|
26
26
|
size: size,
|
|
27
|
-
color: themeTokens.color
|
|
27
|
+
color: themeTokens.color,
|
|
28
|
+
gradient: themeTokens.gradient
|
|
28
29
|
});
|
|
29
30
|
const paddingStyles = variant?.padding ? {
|
|
30
31
|
padding: themeTokens.width,
|
|
@@ -7,6 +7,7 @@ import { applyTextStyles, useTheme, useThemeTokens } from '../ThemeProvider';
|
|
|
7
7
|
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils';
|
|
8
8
|
import LabelContent from './LabelContent';
|
|
9
9
|
import Tooltip from '../Tooltip';
|
|
10
|
+
import tooltipPropTypes from '../Tooltip/shared';
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
12
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
12
13
|
const selectLabelStyles = (tokens, themeOptions) => applyTextStyles({
|
|
@@ -59,6 +60,11 @@ const InputLabel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
59
60
|
const {
|
|
60
61
|
themeOptions
|
|
61
62
|
} = useTheme();
|
|
63
|
+
const getTooltipProps = () => {
|
|
64
|
+
return typeof tooltip === 'string' ? {
|
|
65
|
+
content: tooltip
|
|
66
|
+
} : tooltip;
|
|
67
|
+
};
|
|
62
68
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
63
69
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
64
70
|
ref: ref,
|
|
@@ -80,8 +86,8 @@ const InputLabel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
80
86
|
color: themeTokens.color
|
|
81
87
|
}],
|
|
82
88
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
copy: copy,
|
|
90
|
+
...getTooltipProps()
|
|
85
91
|
})
|
|
86
92
|
}), maxCharacterAllowed && isHintInline && /*#__PURE__*/_jsxs(Text, {
|
|
87
93
|
style: [selectHintStyles({
|
|
@@ -136,7 +142,7 @@ InputLabel.propTypes = {
|
|
|
136
142
|
/**
|
|
137
143
|
* Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
|
|
138
144
|
*/
|
|
139
|
-
tooltip: PropTypes.string,
|
|
145
|
+
tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
|
|
140
146
|
/**
|
|
141
147
|
* Current number of characterts of an input text.
|
|
142
148
|
*/
|
|
@@ -7,6 +7,7 @@ import { useThemeTokens } from '../ThemeProvider';
|
|
|
7
7
|
import useInputSupports from './useInputSupports';
|
|
8
8
|
import { getTokensPropType, useCopy } from '../utils';
|
|
9
9
|
import dictionary from './dictionary';
|
|
10
|
+
import tooltipPropTypes from '../Tooltip/shared';
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
const InputSupports = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
12
13
|
let {
|
|
@@ -110,9 +111,12 @@ InputSupports.propTypes = {
|
|
|
110
111
|
*/
|
|
111
112
|
feedbackProps: PropTypes.object,
|
|
112
113
|
/**
|
|
113
|
-
*
|
|
114
|
+
* an optional `Tooltip`. If set, tooltip will be shown next to the label.
|
|
115
|
+
* Props can be passed to the tooltip in one of the following ways.
|
|
116
|
+
* 1. `tooltip` as a string - The content of the tooltip.
|
|
117
|
+
* 2. `tooltip` as an object - Tooltip component props to be passed.
|
|
114
118
|
*/
|
|
115
|
-
tooltip: PropTypes.string,
|
|
119
|
+
tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
|
|
116
120
|
/**
|
|
117
121
|
* Use to visually mark an input as valid or invalid.
|
|
118
122
|
*/
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
4
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
5
|
import Icon from '../Icon';
|
|
6
|
-
import {
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const tokenTypes = {
|
|
8
8
|
itemIconSize: PropTypes.number.isRequired,
|
|
9
9
|
itemIconColor: PropTypes.string.isRequired,
|
|
@@ -68,7 +68,6 @@ const ListItemMark = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
68
68
|
iconSize,
|
|
69
69
|
tokens = {}
|
|
70
70
|
} = _ref5;
|
|
71
|
-
const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
|
|
72
71
|
const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
|
|
73
72
|
const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
|
|
74
73
|
const bulletContainerStyles = selectBulletContainerStyles(themeTokens);
|
|
@@ -76,9 +75,14 @@ const ListItemMark = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
76
75
|
const iconTokens = selectItemIconTokens(themeTokens);
|
|
77
76
|
return /*#__PURE__*/_jsx(View, {
|
|
78
77
|
style: [sideItemContainerStyles, bulletContainerStyles],
|
|
79
|
-
children: /*#__PURE__*/_jsx(
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
79
|
+
icon: icon,
|
|
80
|
+
tokens: {
|
|
81
|
+
size: iconSize ?? iconTokens.size
|
|
82
|
+
},
|
|
83
|
+
variant: {
|
|
84
|
+
color: iconColor ?? iconTokens.color
|
|
85
|
+
}
|
|
82
86
|
})
|
|
83
87
|
});
|
|
84
88
|
}
|
|
@@ -132,6 +132,7 @@ const ToggleSwitch = /*#__PURE__*/React.forwardRef((_ref9, ref) => {
|
|
|
132
132
|
variant,
|
|
133
133
|
accessibilityRole = 'switch',
|
|
134
134
|
accessibilityLabel = label,
|
|
135
|
+
togglePosition = 'end',
|
|
135
136
|
...rest
|
|
136
137
|
} = _ref9;
|
|
137
138
|
const getTokens = useThemeTokensCallback('ToggleSwitch', tokens, variant);
|
|
@@ -150,9 +151,10 @@ const ToggleSwitch = /*#__PURE__*/React.forwardRef((_ref9, ref) => {
|
|
|
150
151
|
const inputId = id ?? uniqueId;
|
|
151
152
|
return /*#__PURE__*/_jsxs(StackView, {
|
|
152
153
|
space: themeTokens.space,
|
|
153
|
-
direction:
|
|
154
|
+
direction: togglePosition === 'start' ? 'row-reverse' : 'row',
|
|
154
155
|
tokens: {
|
|
155
|
-
alignItems: 'center'
|
|
156
|
+
alignItems: 'center',
|
|
157
|
+
justifyContent: 'start'
|
|
156
158
|
},
|
|
157
159
|
children: [Boolean(label) && /*#__PURE__*/_jsx(View, {
|
|
158
160
|
style: [selectLabelStyles(themeTokens), staticStyles.containText],
|
|
@@ -258,7 +260,13 @@ ToggleSwitch.propTypes = {
|
|
|
258
260
|
/**
|
|
259
261
|
* Content of an optional Tooltip. If set, a tooltip button will be shown next to the label.
|
|
260
262
|
*/
|
|
261
|
-
tooltip: PropTypes.string
|
|
263
|
+
tooltip: PropTypes.string,
|
|
264
|
+
/**
|
|
265
|
+
* Controls the position of the switch in relation to the label.
|
|
266
|
+
* - 'start': switch on the start, before the `label` and `tooltip`.
|
|
267
|
+
* - 'end': switch to the end, after the `label` and `tooltip` (default).
|
|
268
|
+
*/
|
|
269
|
+
togglePosition: PropTypes.oneOf(['start', 'end'])
|
|
262
270
|
};
|
|
263
271
|
const staticStyles = StyleSheet.create({
|
|
264
272
|
track: {
|
|
@@ -72,6 +72,7 @@ const ToggleSwitchGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
72
72
|
onChange: itemOnChange,
|
|
73
73
|
ref: itemRef,
|
|
74
74
|
tooltip: itemTooltip,
|
|
75
|
+
togglePosition,
|
|
75
76
|
...itemRest
|
|
76
77
|
} = _ref2;
|
|
77
78
|
const isSelected = currentValues.includes(id);
|
|
@@ -97,6 +98,7 @@ const ToggleSwitchGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
97
98
|
inactive: inactive,
|
|
98
99
|
label: label,
|
|
99
100
|
tooltip: itemTooltip,
|
|
101
|
+
togglePosition: togglePosition,
|
|
100
102
|
...itemA11y,
|
|
101
103
|
...selectItemProps(itemRest)
|
|
102
104
|
}, id);
|
|
@@ -156,7 +158,13 @@ ToggleSwitchGroup.propTypes = {
|
|
|
156
158
|
/**
|
|
157
159
|
* An optional ref for one individual ToggleSwitch in the ToggleSwitchGroup
|
|
158
160
|
*/
|
|
159
|
-
ref: ABBPropTypes.ref()
|
|
161
|
+
ref: ABBPropTypes.ref(),
|
|
162
|
+
/**
|
|
163
|
+
* Controls the position of the switch in relation to the label.
|
|
164
|
+
* - 'start': switch on the start, before the `label` and `tooltip`.
|
|
165
|
+
* - 'end': switch to the end, after the `label` and `tooltip` (default).
|
|
166
|
+
*/
|
|
167
|
+
togglePosition: PropTypes.oneOf(['start', 'end'])
|
|
160
168
|
})),
|
|
161
169
|
/**
|
|
162
170
|
* If provided, this function is called when the current selection is changed
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import { getTokensPropType
|
|
2
|
+
import { getTokensPropType } from '../utils/props/tokens';
|
|
3
|
+
import variantProp from '../utils/props/variantProp';
|
|
3
4
|
const propTypes = {
|
|
4
5
|
/**
|
|
5
6
|
* Used to render the control (i.e. tooltip trigger). If a render function is used it will receive the
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
import tooltipPropTypes from '../../Tooltip/shared';
|
|
2
3
|
export default {
|
|
3
4
|
types: {
|
|
4
5
|
/**
|
|
@@ -31,9 +32,12 @@ export default {
|
|
|
31
32
|
*/
|
|
32
33
|
feedbackProps: PropTypes.object,
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* an optional `Tooltip`. If set, tooltip will be shown next to the label.
|
|
36
|
+
* Props can be passed to the tooltip in one of the following ways.
|
|
37
|
+
* 1. `tooltip` as a string - The content of the tooltip.
|
|
38
|
+
* 2. `tooltip` as an object - Tooltip component props to be passed.
|
|
35
39
|
*/
|
|
36
|
-
tooltip: PropTypes.string,
|
|
40
|
+
tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
|
|
37
41
|
/**
|
|
38
42
|
* Use to visually mark an input as valid or invalid.
|
|
39
43
|
*/
|
package/lib/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@react-native-picker/picker": "^2.9.0",
|
|
14
14
|
"@telus-uds/system-constants": "^3.0.0",
|
|
15
|
-
"@telus-uds/system-theme-tokens": "^4.
|
|
15
|
+
"@telus-uds/system-theme-tokens": "^4.5.0",
|
|
16
16
|
"airbnb-prop-types": "^2.16.0",
|
|
17
17
|
"css-mediaquery": "^0.1.2",
|
|
18
18
|
"expo-document-picker": "^13.0.1",
|
|
@@ -84,6 +84,6 @@
|
|
|
84
84
|
"standard-engine": {
|
|
85
85
|
"skip": true
|
|
86
86
|
},
|
|
87
|
-
"version": "3.
|
|
87
|
+
"version": "3.7.1",
|
|
88
88
|
"types": "types/index.d.ts"
|
|
89
89
|
}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@react-native-picker/picker": "^2.9.0",
|
|
14
14
|
"@telus-uds/system-constants": "^3.0.0",
|
|
15
|
-
"@telus-uds/system-theme-tokens": "^4.
|
|
15
|
+
"@telus-uds/system-theme-tokens": "^4.5.0",
|
|
16
16
|
"airbnb-prop-types": "^2.16.0",
|
|
17
17
|
"css-mediaquery": "^0.1.2",
|
|
18
18
|
"expo-document-picker": "^13.0.1",
|
|
@@ -84,6 +84,6 @@
|
|
|
84
84
|
"standard-engine": {
|
|
85
85
|
"skip": true
|
|
86
86
|
},
|
|
87
|
-
"version": "3.
|
|
87
|
+
"version": "3.7.1",
|
|
88
88
|
"types": "types/index.d.ts"
|
|
89
89
|
}
|
package/src/Card/Card.jsx
CHANGED
|
@@ -9,7 +9,14 @@ import {
|
|
|
9
9
|
} from '../ThemeProvider'
|
|
10
10
|
import { getTokensPropType, variantProp, StyleSheet, createMediaQueryStyles } from '../utils'
|
|
11
11
|
import { useViewport } from '../ViewportProvider'
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
a11yProps,
|
|
14
|
+
linkProps,
|
|
15
|
+
selectSystemProps,
|
|
16
|
+
viewProps,
|
|
17
|
+
responsiveProps,
|
|
18
|
+
hrefAttrsProp
|
|
19
|
+
} from '../utils/props'
|
|
13
20
|
import CardBase from './CardBase'
|
|
14
21
|
import PressableCardBase from './PressableCardBase'
|
|
15
22
|
import CheckboxButton from '../Checkbox/CheckboxButton'
|
|
@@ -227,6 +234,8 @@ const Card = React.forwardRef(
|
|
|
227
234
|
tokens={getThemeTokens}
|
|
228
235
|
dataSet={dataSet}
|
|
229
236
|
onPress={onPress}
|
|
237
|
+
href={interactiveCard?.href}
|
|
238
|
+
hrefAttrs={interactiveCard?.hrefAttrs}
|
|
230
239
|
{...selectProps(rest)}
|
|
231
240
|
>
|
|
232
241
|
{(cardState) => {
|
|
@@ -308,12 +317,16 @@ Card.propTypes = {
|
|
|
308
317
|
- `radiogroup`
|
|
309
318
|
- `checkbox`
|
|
310
319
|
* - variant: The variant to be used for the interactive card
|
|
320
|
+
* - href: The href to be used for the interactive card
|
|
321
|
+
* - hrefAttrs: The href attributes to be used for the interactive card
|
|
311
322
|
*/
|
|
312
323
|
interactiveCard: PropTypes.shape({
|
|
313
324
|
body: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
314
325
|
tokens: getTokensPropType('Card'),
|
|
315
326
|
selectionType: PropTypes.oneOf(Object.values(SelectionType)),
|
|
316
|
-
variant: variantProp.propType
|
|
327
|
+
variant: variantProp.propType,
|
|
328
|
+
href: PropTypes.string,
|
|
329
|
+
hrefAttrs: PropTypes.shape(hrefAttrsProp.types)
|
|
317
330
|
}),
|
|
318
331
|
/**
|
|
319
332
|
* Apply background image to the card.
|
|
@@ -326,7 +339,11 @@ Card.propTypes = {
|
|
|
326
339
|
resizeMode: responsiveProps.getTypeOptionallyByViewport(
|
|
327
340
|
PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center'])
|
|
328
341
|
)
|
|
329
|
-
})
|
|
342
|
+
}),
|
|
343
|
+
/**
|
|
344
|
+
* Data set for the card.
|
|
345
|
+
*/
|
|
346
|
+
dataSet: PropTypes.object
|
|
330
347
|
}
|
|
331
348
|
|
|
332
349
|
export default Card
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { Pressable, Platform } from 'react-native'
|
|
3
|
+
import { Pressable, Platform, View, StyleSheet } from 'react-native'
|
|
4
4
|
|
|
5
5
|
import { useViewport } from '../ViewportProvider'
|
|
6
6
|
import { applyOuterBorder, validateThemeTokens } from '../ThemeProvider'
|
|
@@ -118,7 +118,57 @@ const PressableCardBase = React.forwardRef(
|
|
|
118
118
|
const handleChange = linkProps.handleHref({ href, onPress })
|
|
119
119
|
const handleKeyDown = (event) => {
|
|
120
120
|
// The expected keyboard shortcut for selecting a focused item is the Space key
|
|
121
|
-
if (event?.key === ' ') handleChange(event)
|
|
121
|
+
if (event?.key === ' ') handleChange?.(event)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const [hovered, setHovered] = React.useState(false)
|
|
125
|
+
const [focused, setFocused] = React.useState(false)
|
|
126
|
+
const [pressed, setPressed] = React.useState(false)
|
|
127
|
+
|
|
128
|
+
if (Platform.OS === 'web' && href) {
|
|
129
|
+
return (
|
|
130
|
+
<View
|
|
131
|
+
ref={ref}
|
|
132
|
+
style={getOuterBorderStyle({ pressed, focused, hovered })}
|
|
133
|
+
dataSet={dataSet}
|
|
134
|
+
onMouseEnter={() => setHovered(true)}
|
|
135
|
+
onMouseLeave={() => setHovered(false)}
|
|
136
|
+
{...selectProps({ ...rest, accessibilityRole })}
|
|
137
|
+
>
|
|
138
|
+
<a
|
|
139
|
+
href={href}
|
|
140
|
+
tabIndex={0}
|
|
141
|
+
onClick={(event) => {
|
|
142
|
+
setPressed(false)
|
|
143
|
+
handleChange?.(event)
|
|
144
|
+
}}
|
|
145
|
+
onKeyDown={(event) => {
|
|
146
|
+
if (event.key === ' ') {
|
|
147
|
+
setPressed(true)
|
|
148
|
+
handleKeyDown(event)
|
|
149
|
+
}
|
|
150
|
+
}}
|
|
151
|
+
onKeyUp={(event) => {
|
|
152
|
+
if (event.key === ' ') setPressed(false)
|
|
153
|
+
}}
|
|
154
|
+
onMouseDown={() => setPressed(true)}
|
|
155
|
+
onMouseUp={() => setPressed(false)}
|
|
156
|
+
onFocus={() => setFocused(true)}
|
|
157
|
+
onBlur={() => {
|
|
158
|
+
setFocused(false)
|
|
159
|
+
setPressed(false)
|
|
160
|
+
}}
|
|
161
|
+
style={{ ...staticStyles.container, textDecoration: 'none' }}
|
|
162
|
+
{...(hrefAttrs || {})}
|
|
163
|
+
>
|
|
164
|
+
<CardBase tokens={getCardTokens({ pressed, focused, hovered })}>
|
|
165
|
+
{typeof children === 'function'
|
|
166
|
+
? children(getCardState({ pressed, focused, hovered }))
|
|
167
|
+
: children}
|
|
168
|
+
</CardBase>
|
|
169
|
+
</a>
|
|
170
|
+
</View>
|
|
171
|
+
)
|
|
122
172
|
}
|
|
123
173
|
|
|
124
174
|
return (
|
|
@@ -141,6 +191,14 @@ const PressableCardBase = React.forwardRef(
|
|
|
141
191
|
)
|
|
142
192
|
}
|
|
143
193
|
)
|
|
194
|
+
|
|
195
|
+
const staticStyles = StyleSheet.create({
|
|
196
|
+
container: {
|
|
197
|
+
flex: 1,
|
|
198
|
+
display: 'flex'
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
|
|
144
202
|
PressableCardBase.displayName = 'PressableCardBase'
|
|
145
203
|
|
|
146
204
|
PressableCardBase.propTypes = {
|
package/src/Icon/Icon.jsx
CHANGED
|
@@ -24,7 +24,12 @@ const Icon = React.forwardRef(
|
|
|
24
24
|
const size = scalesWithText ? themeTokens.size * fontScale : themeTokens.size
|
|
25
25
|
|
|
26
26
|
const iconContent = (
|
|
27
|
-
<IconComponent
|
|
27
|
+
<IconComponent
|
|
28
|
+
title={accessibilityLabel}
|
|
29
|
+
size={size}
|
|
30
|
+
color={themeTokens.color}
|
|
31
|
+
gradient={themeTokens.gradient}
|
|
32
|
+
/>
|
|
28
33
|
)
|
|
29
34
|
|
|
30
35
|
const paddingStyles = variant?.padding
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
import LabelContent from './LabelContent'
|
|
16
16
|
import Tooltip from '../Tooltip'
|
|
17
|
+
import tooltipPropTypes from '../Tooltip/shared'
|
|
17
18
|
|
|
18
19
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
19
20
|
|
|
@@ -56,10 +57,14 @@ const InputLabel = React.forwardRef(
|
|
|
56
57
|
const themeTokens = useThemeTokens('InputLabel', tokens, variant)
|
|
57
58
|
|
|
58
59
|
const hasTooltip = tooltip !== undefined
|
|
60
|
+
|
|
59
61
|
const isHintInline = hintPosition === 'inline'
|
|
60
62
|
|
|
61
63
|
const { themeOptions } = useTheme()
|
|
62
64
|
|
|
65
|
+
const getTooltipProps = () => {
|
|
66
|
+
return typeof tooltip === 'string' ? { content: tooltip } : tooltip
|
|
67
|
+
}
|
|
63
68
|
return (
|
|
64
69
|
<>
|
|
65
70
|
<View ref={ref} style={staticStyles.container} {...selectProps(rest)}>
|
|
@@ -94,7 +99,7 @@ const InputLabel = React.forwardRef(
|
|
|
94
99
|
}
|
|
95
100
|
]}
|
|
96
101
|
>
|
|
97
|
-
<Tooltip
|
|
102
|
+
<Tooltip copy={copy} {...getTooltipProps()} />
|
|
98
103
|
</View>
|
|
99
104
|
)}
|
|
100
105
|
{maxCharacterAllowed && isHintInline && (
|
|
@@ -156,7 +161,7 @@ InputLabel.propTypes = {
|
|
|
156
161
|
/**
|
|
157
162
|
* Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
|
|
158
163
|
*/
|
|
159
|
-
tooltip: PropTypes.string,
|
|
164
|
+
tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
|
|
160
165
|
/**
|
|
161
166
|
* Current number of characterts of an input text.
|
|
162
167
|
*/
|
|
@@ -8,6 +8,7 @@ import { useThemeTokens } from '../ThemeProvider'
|
|
|
8
8
|
import useInputSupports from './useInputSupports'
|
|
9
9
|
import { getTokensPropType, useCopy } from '../utils'
|
|
10
10
|
import dictionary from './dictionary'
|
|
11
|
+
import tooltipPropTypes from '../Tooltip/shared'
|
|
11
12
|
|
|
12
13
|
const InputSupports = React.forwardRef(
|
|
13
14
|
(
|
|
@@ -115,9 +116,12 @@ InputSupports.propTypes = {
|
|
|
115
116
|
*/
|
|
116
117
|
feedbackProps: PropTypes.object,
|
|
117
118
|
/**
|
|
118
|
-
*
|
|
119
|
+
* an optional `Tooltip`. If set, tooltip will be shown next to the label.
|
|
120
|
+
* Props can be passed to the tooltip in one of the following ways.
|
|
121
|
+
* 1. `tooltip` as a string - The content of the tooltip.
|
|
122
|
+
* 2. `tooltip` as an object - Tooltip component props to be passed.
|
|
119
123
|
*/
|
|
120
|
-
tooltip: PropTypes.string,
|
|
124
|
+
tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
|
|
121
125
|
/**
|
|
122
126
|
* Use to visually mark an input as valid or invalid.
|
|
123
127
|
*/
|
|
@@ -45,8 +45,6 @@ const selectBulletContainerStyles = ({
|
|
|
45
45
|
* icon or bullet nicely against the first line of text in a ListIconContent.
|
|
46
46
|
*/
|
|
47
47
|
const ListItemMark = React.forwardRef(({ icon, iconColor, iconSize, tokens = {} }, ref) => {
|
|
48
|
-
const IconComponent = icon || <></>
|
|
49
|
-
|
|
50
48
|
const themeTokens = typeof tokens === 'function' ? tokens() : tokens
|
|
51
49
|
|
|
52
50
|
const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens)
|
|
@@ -56,7 +54,11 @@ const ListItemMark = React.forwardRef(({ icon, iconColor, iconSize, tokens = {}
|
|
|
56
54
|
const iconTokens = selectItemIconTokens(themeTokens)
|
|
57
55
|
return (
|
|
58
56
|
<View style={[sideItemContainerStyles, bulletContainerStyles]}>
|
|
59
|
-
<
|
|
57
|
+
<Icon
|
|
58
|
+
icon={icon}
|
|
59
|
+
tokens={{ size: iconSize ?? iconTokens.size }}
|
|
60
|
+
variant={{ color: iconColor ?? iconTokens.color }}
|
|
61
|
+
/>
|
|
60
62
|
</View>
|
|
61
63
|
)
|
|
62
64
|
}
|
|
@@ -107,6 +107,7 @@ const ToggleSwitch = React.forwardRef(
|
|
|
107
107
|
variant,
|
|
108
108
|
accessibilityRole = 'switch',
|
|
109
109
|
accessibilityLabel = label,
|
|
110
|
+
togglePosition = 'end',
|
|
110
111
|
...rest
|
|
111
112
|
},
|
|
112
113
|
ref
|
|
@@ -125,8 +126,13 @@ const ToggleSwitch = React.forwardRef(
|
|
|
125
126
|
selectButtonTokens(getTokens(buttonState), getTokens(themeTokens))
|
|
126
127
|
const uniqueId = useUniqueId('toggleSwitch')
|
|
127
128
|
const inputId = id ?? uniqueId
|
|
129
|
+
|
|
128
130
|
return (
|
|
129
|
-
<StackView
|
|
131
|
+
<StackView
|
|
132
|
+
space={themeTokens.space}
|
|
133
|
+
direction={togglePosition === 'start' ? 'row-reverse' : 'row'}
|
|
134
|
+
tokens={{ alignItems: 'center', justifyContent: 'start' }}
|
|
135
|
+
>
|
|
130
136
|
{Boolean(label) && (
|
|
131
137
|
<View style={[selectLabelStyles(themeTokens), staticStyles.containText]}>
|
|
132
138
|
<InputLabel
|
|
@@ -225,7 +231,13 @@ ToggleSwitch.propTypes = {
|
|
|
225
231
|
/**
|
|
226
232
|
* Content of an optional Tooltip. If set, a tooltip button will be shown next to the label.
|
|
227
233
|
*/
|
|
228
|
-
tooltip: PropTypes.string
|
|
234
|
+
tooltip: PropTypes.string,
|
|
235
|
+
/**
|
|
236
|
+
* Controls the position of the switch in relation to the label.
|
|
237
|
+
* - 'start': switch on the start, before the `label` and `tooltip`.
|
|
238
|
+
* - 'end': switch to the end, after the `label` and `tooltip` (default).
|
|
239
|
+
*/
|
|
240
|
+
togglePosition: PropTypes.oneOf(['start', 'end'])
|
|
229
241
|
}
|
|
230
242
|
|
|
231
243
|
const staticStyles = StyleSheet.create({
|
|
@@ -87,6 +87,7 @@ const ToggleSwitchGroup = React.forwardRef(
|
|
|
87
87
|
onChange: itemOnChange,
|
|
88
88
|
ref: itemRef,
|
|
89
89
|
tooltip: itemTooltip,
|
|
90
|
+
togglePosition,
|
|
90
91
|
...itemRest
|
|
91
92
|
},
|
|
92
93
|
index
|
|
@@ -117,6 +118,7 @@ const ToggleSwitchGroup = React.forwardRef(
|
|
|
117
118
|
inactive={inactive}
|
|
118
119
|
label={label}
|
|
119
120
|
tooltip={itemTooltip}
|
|
121
|
+
togglePosition={togglePosition}
|
|
120
122
|
{...itemA11y}
|
|
121
123
|
{...selectItemProps(itemRest)}
|
|
122
124
|
/>
|
|
@@ -182,7 +184,13 @@ ToggleSwitchGroup.propTypes = {
|
|
|
182
184
|
/**
|
|
183
185
|
* An optional ref for one individual ToggleSwitch in the ToggleSwitchGroup
|
|
184
186
|
*/
|
|
185
|
-
ref: ABBPropTypes.ref()
|
|
187
|
+
ref: ABBPropTypes.ref(),
|
|
188
|
+
/**
|
|
189
|
+
* Controls the position of the switch in relation to the label.
|
|
190
|
+
* - 'start': switch on the start, before the `label` and `tooltip`.
|
|
191
|
+
* - 'end': switch to the end, after the `label` and `tooltip` (default).
|
|
192
|
+
*/
|
|
193
|
+
togglePosition: PropTypes.oneOf(['start', 'end'])
|
|
186
194
|
})
|
|
187
195
|
),
|
|
188
196
|
/**
|
package/src/Tooltip/shared.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
|
+
import tooltipPropTypes from '../../Tooltip/shared'
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
types: {
|
|
@@ -32,9 +33,12 @@ export default {
|
|
|
32
33
|
*/
|
|
33
34
|
feedbackProps: PropTypes.object,
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
+
* an optional `Tooltip`. If set, tooltip will be shown next to the label.
|
|
37
|
+
* Props can be passed to the tooltip in one of the following ways.
|
|
38
|
+
* 1. `tooltip` as a string - The content of the tooltip.
|
|
39
|
+
* 2. `tooltip` as an object - Tooltip component props to be passed.
|
|
36
40
|
*/
|
|
37
|
-
tooltip: PropTypes.string,
|
|
41
|
+
tooltip: PropTypes.oneOfType([tooltipPropTypes, PropTypes.string]),
|
|
38
42
|
/**
|
|
39
43
|
* Use to visually mark an input as valid or invalid.
|
|
40
44
|
*/
|