@telus-uds/components-base 1.6.1 → 1.8.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/.storybook/main.js +7 -0
- package/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-lint.log +3 -13
- package/CHANGELOG.json +112 -1
- package/CHANGELOG.md +41 -2
- package/__fixtures__/Accessible.js +1 -2
- package/__fixtures__/Accessible.native.js +1 -2
- package/__tests__/FlexGrid/Col.test.jsx +5 -0
- package/__tests__/InputLabel/InputLabel.test.jsx +28 -0
- package/__tests__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +3 -0
- package/__tests__/InputSupports/InputSupports.test.jsx +10 -0
- package/component-docs.json +278 -40
- package/lib/Button/ButtonGroup.js +118 -45
- package/lib/Checkbox/CheckboxGroup.js +3 -3
- package/lib/ExpandCollapse/Panel.js +2 -1
- package/lib/Fieldset/Fieldset.js +7 -0
- package/lib/InputLabel/InputLabel.js +8 -1
- package/lib/InputSupports/InputSupports.js +7 -0
- package/lib/List/ListItem.js +22 -12
- package/lib/Notification/Notification.js +1 -1
- package/lib/Radio/RadioGroup.js +12 -5
- package/lib/RadioCard/RadioCardGroup.js +7 -0
- package/lib/Search/Search.js +28 -20
- package/lib/Skeleton/Skeleton.js +48 -2
- package/lib/TextInput/TextArea.js +1 -1
- package/lib/TextInput/TextInput.js +1 -1
- package/lib/TextInput/TextInputBase.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitch.js +7 -0
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +7 -0
- package/lib/Tooltip/Tooltip.js +1 -1
- package/lib/Typography/Typography.js +12 -10
- package/lib/index.js +22 -1
- package/lib/utils/animation/useVerticalExpandAnimation.js +26 -13
- package/lib/utils/input.js +5 -6
- package/lib/utils/props/index.js +18 -0
- package/lib/utils/props/inputSupportsProps.js +7 -0
- package/lib/utils/props/textInputProps.js +207 -0
- package/lib/utils/props/textProps.js +72 -0
- package/lib-module/Button/ButtonGroup.js +117 -45
- package/lib-module/Checkbox/CheckboxGroup.js +3 -3
- package/lib-module/ExpandCollapse/Panel.js +2 -1
- package/lib-module/Fieldset/Fieldset.js +7 -0
- package/lib-module/InputLabel/InputLabel.js +8 -1
- package/lib-module/InputSupports/InputSupports.js +7 -0
- package/lib-module/List/ListItem.js +22 -12
- package/lib-module/Notification/Notification.js +1 -1
- package/lib-module/Radio/RadioGroup.js +12 -5
- package/lib-module/RadioCard/RadioCardGroup.js +7 -0
- package/lib-module/Search/Search.js +30 -22
- package/lib-module/Skeleton/Skeleton.js +49 -3
- package/lib-module/TextInput/TextArea.js +2 -2
- package/lib-module/TextInput/TextInput.js +2 -2
- package/lib-module/TextInput/TextInputBase.js +2 -2
- package/lib-module/ToggleSwitch/ToggleSwitch.js +7 -0
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +7 -0
- package/lib-module/Tooltip/Tooltip.js +1 -1
- package/lib-module/Typography/Typography.js +13 -11
- package/lib-module/index.js +1 -1
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +26 -14
- package/lib-module/utils/input.js +6 -6
- package/lib-module/utils/props/index.js +2 -0
- package/lib-module/utils/props/inputSupportsProps.js +7 -0
- package/lib-module/utils/props/textInputProps.js +194 -0
- package/lib-module/utils/props/textProps.js +59 -0
- package/package.json +9 -4
- package/src/Button/ButtonGroup.jsx +106 -41
- package/src/Checkbox/Checkbox.jsx +7 -4
- package/src/Checkbox/CheckboxGroup.jsx +3 -3
- package/src/ExpandCollapse/Panel.jsx +3 -1
- package/src/Fieldset/Fieldset.jsx +6 -0
- package/src/InputLabel/InputLabel.jsx +17 -2
- package/src/InputSupports/InputSupports.jsx +9 -1
- package/src/List/ListItem.jsx +17 -9
- package/src/Notification/Notification.jsx +1 -1
- package/src/Radio/Radio.jsx +5 -1
- package/src/Radio/RadioGroup.jsx +11 -5
- package/src/RadioCard/RadioCard.jsx +5 -1
- package/src/RadioCard/RadioCardGroup.jsx +6 -0
- package/src/Search/Search.jsx +34 -22
- package/src/Skeleton/Skeleton.jsx +56 -3
- package/src/TextInput/TextArea.jsx +2 -0
- package/src/TextInput/TextInput.jsx +2 -0
- package/src/TextInput/TextInputBase.jsx +2 -0
- package/src/ToggleSwitch/ToggleSwitch.jsx +6 -0
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +6 -0
- package/src/Tooltip/Tooltip.jsx +1 -1
- package/src/Typography/Typography.jsx +13 -9
- package/src/index.js +4 -1
- package/src/utils/animation/useVerticalExpandAnimation.js +25 -12
- package/src/utils/input.js +5 -7
- package/src/utils/props/index.js +2 -0
- package/src/utils/props/inputSupportsProps.js +6 -1
- package/src/utils/props/textInputProps.js +178 -0
- package/src/utils/props/textProps.js +58 -0
- package/src/utils/props/tokens.js +21 -19
- package/stories/Search/Search.stories.jsx +49 -2
- package/stories/Tabs/Tabs.stories.jsx +4 -3
package/lib/Skeleton/Skeleton.js
CHANGED
|
@@ -68,13 +68,23 @@ const Skeleton = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
68
68
|
tokens,
|
|
69
69
|
variant,
|
|
70
70
|
size,
|
|
71
|
+
sizeIndex = size,
|
|
72
|
+
sizePixels,
|
|
71
73
|
characters,
|
|
72
74
|
lines,
|
|
73
75
|
shape = 'line',
|
|
74
76
|
...rest
|
|
75
77
|
}, ref) => {
|
|
76
78
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Skeleton', tokens, variant);
|
|
77
|
-
const
|
|
79
|
+
const pixels = (0, _utils.useResponsiveProp)(sizePixels);
|
|
80
|
+
const spacingScaleValue = typeof pixels === 'number' ? // Size by an exact number of pixels
|
|
81
|
+
{
|
|
82
|
+
options: {
|
|
83
|
+
size: pixels
|
|
84
|
+
}
|
|
85
|
+
} : // Size by an index on the spacing scale (getting default index from theme if none provided)
|
|
86
|
+
sizeIndex || themeTokens.size;
|
|
87
|
+
const skeletonHeight = (0, _utils.useSpacingScale)(spacingScaleValue);
|
|
78
88
|
const nativeAnimation = (0, _useSkeletonNativeAnimation.default)();
|
|
79
89
|
|
|
80
90
|
const getAnimationBaseOnPlatform = () => {
|
|
@@ -132,9 +142,45 @@ Skeleton.displayName = 'Skeleton';
|
|
|
132
142
|
Skeleton.propTypes = { ...selectedSystemPropTypes,
|
|
133
143
|
tokens: (0, _utils.getTokensPropType)('Skeleton'),
|
|
134
144
|
variant: _utils.variantProp.propType,
|
|
135
|
-
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Sets the size of Skeleton lines or shape according to the theme's spacing scale. For example, size={1} gives the smallest non-zero theme-defined spacing size.
|
|
148
|
+
*
|
|
149
|
+
* May also accept an object with responsive viewport keys or spacing scale options - see `useSpacingScale` for details.
|
|
150
|
+
*/
|
|
151
|
+
sizeIndex: _utils.spacingProps.types.spacingValue,
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated alias for `sizeIndex`
|
|
155
|
+
*/
|
|
156
|
+
size: _utils.spacingProps.types.spacingValue,
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Sets the size of Skeleton lines or shape to an exact number of pixels. Use when it's necessary to exactly match sizes of images or other boxes.
|
|
160
|
+
*
|
|
161
|
+
* Accepts a number or an object with responsive viewport keys, e.g. { xs: 32, lg: 64 } would be 32px at xs, sm and md and 64 at lg and xl viewports.
|
|
162
|
+
*/
|
|
163
|
+
sizePixels: _utils.responsiveProps.getTypeOptionallyByViewport(_propTypes.default.number),
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Determines the width of simulated lines of text if the Skeleton's shape is 'line' (the default shape).
|
|
167
|
+
*
|
|
168
|
+
* Only has any affect if shape is line (the default). If unset, takes a default value from the theme.
|
|
169
|
+
*/
|
|
136
170
|
characters: _propTypes.default.number,
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Determines how many Skeleton items are rendered (default 1).
|
|
174
|
+
*
|
|
175
|
+
* Recommended usage is to simulate paragraphs of text when Skeleton's shape is 'line' (the default shape).
|
|
176
|
+
*
|
|
177
|
+
* The amount of spacing between multiple lines is controlled by theme tokens.
|
|
178
|
+
*/
|
|
137
179
|
lines: _propTypes.default.number,
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Determines if the skeleton should resemble lines of text (default), a circle, or a square box with themed rounded corners.
|
|
183
|
+
*/
|
|
138
184
|
shape: _propTypes.default.oneOf(['line', 'circle', 'box'])
|
|
139
185
|
};
|
|
140
186
|
var _default = Skeleton;
|
|
@@ -27,7 +27,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
27
|
|
|
28
28
|
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; }
|
|
29
29
|
|
|
30
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.viewProps]);
|
|
30
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.textInputProps, _utils.viewProps]);
|
|
31
31
|
/**
|
|
32
32
|
* Use to collect long-form information such as product feedback or support queries.
|
|
33
33
|
* Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
|
|
@@ -25,7 +25,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
25
|
|
|
26
26
|
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; }
|
|
27
27
|
|
|
28
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.viewProps]);
|
|
28
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.textInputProps, _utils.viewProps]);
|
|
29
29
|
/**
|
|
30
30
|
* A basic text input component. Use in forms or individually to receive user's input.
|
|
31
31
|
* Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
|
|
@@ -29,7 +29,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
29
29
|
|
|
30
30
|
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; }
|
|
31
31
|
|
|
32
|
-
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.textInputHandlerProps, _utils.viewProps]);
|
|
32
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.textInputHandlerProps, _utils.textInputProps, _utils.viewProps]);
|
|
33
33
|
|
|
34
34
|
const selectInputStyles = ({
|
|
35
35
|
backgroundColor,
|
|
@@ -107,6 +107,7 @@ const selectLabelTokens = ({
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
110
|
+
copy = 'en',
|
|
110
111
|
value,
|
|
111
112
|
initialValue,
|
|
112
113
|
onChange,
|
|
@@ -143,6 +144,7 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
143
144
|
children: [Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
144
145
|
style: [selectLabelStyles(themeTokens), staticStyles.containText],
|
|
145
146
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, {
|
|
147
|
+
copy: copy,
|
|
146
148
|
forId: inputId,
|
|
147
149
|
label: label,
|
|
148
150
|
tokens: selectLabelTokens(themeTokens),
|
|
@@ -191,6 +193,11 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
191
193
|
});
|
|
192
194
|
ToggleSwitch.displayName = 'ToggleSwitch';
|
|
193
195
|
ToggleSwitch.propTypes = { ...selectedSystemPropTypes,
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Whether the English or French copy will be used (e.g. for accessibility labels).
|
|
199
|
+
*/
|
|
200
|
+
copy: _propTypes.default.oneOf(['en', 'fr']),
|
|
194
201
|
tokens: (0, _utils.getTokensPropType)('ToggleSwitch'),
|
|
195
202
|
variant: _utils.variantProp.propType,
|
|
196
203
|
|
|
@@ -36,6 +36,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
36
36
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
37
37
|
const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
|
|
38
38
|
const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
39
|
+
copy = 'en',
|
|
39
40
|
variant,
|
|
40
41
|
tokens,
|
|
41
42
|
items = [],
|
|
@@ -112,6 +113,7 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
112
113
|
..._utils.a11yProps.getPositionInSet(items.length, index)
|
|
113
114
|
};
|
|
114
115
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleSwitch.default, {
|
|
116
|
+
copy: copy,
|
|
115
117
|
id: id,
|
|
116
118
|
ref: itemRef,
|
|
117
119
|
onChange: handleChange,
|
|
@@ -143,6 +145,11 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
143
145
|
});
|
|
144
146
|
ToggleSwitchGroup.displayName = 'ToggleSwitchGroup';
|
|
145
147
|
ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Whether the English or French copy will be used (e.g. for accessibility labels).
|
|
151
|
+
*/
|
|
152
|
+
copy: _propTypes.default.oneOf(['en', 'fr']),
|
|
146
153
|
tokens: (0, _utils.getTokensPropType)('ToggleSwitchGroup'),
|
|
147
154
|
variant: _utils.variantProp.propType,
|
|
148
155
|
|
package/lib/Tooltip/Tooltip.js
CHANGED
|
@@ -330,7 +330,7 @@ Tooltip.propTypes = { ...selectedSystemPropTypes,
|
|
|
330
330
|
content: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
|
-
* Select
|
|
333
|
+
* Select English or French copy for the accessible label.
|
|
334
334
|
*/
|
|
335
335
|
copy: _propTypes.default.oneOf(['en', 'fr']),
|
|
336
336
|
|
|
@@ -32,7 +32,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
32
32
|
/**
|
|
33
33
|
* @typedef {import('../utils/a11y/semantics').TextTag} TextTag
|
|
34
34
|
*/
|
|
35
|
-
const [
|
|
35
|
+
const [selectContainerProps, selectedContainerPropTypes] = (0, _utils2.selectSystemProps)([_utils2.a11yProps, _utils2.viewProps]);
|
|
36
|
+
const [selectTextProps, selectedTextPropTypes] = (0, _utils2.selectSystemProps)([_utils2.textProps]);
|
|
36
37
|
|
|
37
38
|
const selectTextStyles = ({
|
|
38
39
|
fontWeight,
|
|
@@ -71,31 +72,32 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
71
72
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Typography', tokens, variant, {
|
|
72
73
|
viewport
|
|
73
74
|
});
|
|
74
|
-
const
|
|
75
|
+
const resolvedTextProps = { ...selectTextProps(rest),
|
|
75
76
|
style: selectTextStyles(align ? { ...themeTokens,
|
|
76
77
|
textAlign: align
|
|
77
78
|
} : themeTokens),
|
|
78
79
|
dataSet,
|
|
79
80
|
maxFontSizeMultiplier: (0, _utils2.getMaxFontMultiplier)(themeTokens)
|
|
80
81
|
};
|
|
81
|
-
const
|
|
82
|
-
...rest
|
|
83
|
-
}
|
|
82
|
+
const containerProps = { ...(0, _utils2.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
83
|
+
...selectContainerProps(rest)
|
|
84
|
+
};
|
|
84
85
|
return block ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
85
86
|
ref: ref,
|
|
86
|
-
...
|
|
87
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, { ...
|
|
87
|
+
...containerProps,
|
|
88
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, { ...resolvedTextProps,
|
|
88
89
|
children: children
|
|
89
90
|
})
|
|
90
91
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
91
92
|
ref: ref,
|
|
92
|
-
...
|
|
93
|
-
...
|
|
93
|
+
...containerProps,
|
|
94
|
+
...resolvedTextProps,
|
|
94
95
|
children: children
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
Typography.displayName = 'Typography';
|
|
98
|
-
Typography.propTypes = { ...
|
|
99
|
+
Typography.propTypes = { ...selectedContainerPropTypes,
|
|
100
|
+
...selectedTextPropTypes,
|
|
99
101
|
tokens: (0, _utils2.getTokensPropType)('Typography'),
|
|
100
102
|
variant: _utils2.variantProp.propType,
|
|
101
103
|
|
package/lib/index.js
CHANGED
|
@@ -51,7 +51,10 @@ var _exportNames = {
|
|
|
51
51
|
useTheme: true,
|
|
52
52
|
useSetTheme: true,
|
|
53
53
|
useThemeTokens: true,
|
|
54
|
-
getThemeTokens: true
|
|
54
|
+
getThemeTokens: true,
|
|
55
|
+
applyOuterBorder: true,
|
|
56
|
+
applyTextStyles: true,
|
|
57
|
+
applyShadowToken: true
|
|
55
58
|
};
|
|
56
59
|
Object.defineProperty(exports, "A11yText", {
|
|
57
60
|
enumerable: true,
|
|
@@ -341,6 +344,24 @@ Object.defineProperty(exports, "getThemeTokens", {
|
|
|
341
344
|
return _ThemeProvider.getThemeTokens;
|
|
342
345
|
}
|
|
343
346
|
});
|
|
347
|
+
Object.defineProperty(exports, "applyOuterBorder", {
|
|
348
|
+
enumerable: true,
|
|
349
|
+
get: function () {
|
|
350
|
+
return _ThemeProvider.applyOuterBorder;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
Object.defineProperty(exports, "applyTextStyles", {
|
|
354
|
+
enumerable: true,
|
|
355
|
+
get: function () {
|
|
356
|
+
return _ThemeProvider.applyTextStyles;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
Object.defineProperty(exports, "applyShadowToken", {
|
|
360
|
+
enumerable: true,
|
|
361
|
+
get: function () {
|
|
362
|
+
return _ThemeProvider.applyShadowToken;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
344
365
|
|
|
345
366
|
var _A11yText = _interopRequireDefault(require("./A11yText"));
|
|
346
367
|
|
|
@@ -22,14 +22,25 @@ function useVerticalExpandAnimation({
|
|
|
22
22
|
isExpanded,
|
|
23
23
|
tokens
|
|
24
24
|
}) {
|
|
25
|
+
const [isAnimating, setIsAnimating] = (0, _react.useState)(false);
|
|
25
26
|
const expandAnimatedValue = (0, _react.useRef)(new _Animated.default.Value(0)).current;
|
|
27
|
+
const elementRef = (0, _react.useRef)(null);
|
|
26
28
|
const {
|
|
27
29
|
expandDuration,
|
|
28
30
|
collapseDuration
|
|
29
|
-
} = tokens;
|
|
31
|
+
} = tokens; // Treat as animating from when expanded state changes, until animation completes
|
|
32
|
+
|
|
33
|
+
(0, _react.useEffect)(() => setIsAnimating(true), [isExpanded]);
|
|
30
34
|
(0, _react.useEffect)(() => {
|
|
35
|
+
const onComplete = () => !isExpanded && setIsAnimating(false);
|
|
36
|
+
|
|
31
37
|
if (_Platform.default.OS === 'web') {
|
|
32
|
-
return;
|
|
38
|
+
if (!elementRef.current) return () => {}; // React Native Web does not pass `onTransitionEnd` through, must attach manually.
|
|
39
|
+
// https://github.com/necolas/react-native-web/pull/1713
|
|
40
|
+
|
|
41
|
+
const element = elementRef.current;
|
|
42
|
+
element.addEventListener('transitionend', onComplete);
|
|
43
|
+
return () => element.removeEventListener('transitionend', onComplete);
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
const animationConfig = {
|
|
@@ -39,25 +50,27 @@ function useVerticalExpandAnimation({
|
|
|
39
50
|
useNativeDriver: false
|
|
40
51
|
};
|
|
41
52
|
|
|
42
|
-
_Animated.default.timing(expandAnimatedValue, animationConfig)
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
const animation = _Animated.default.timing(expandAnimatedValue, animationConfig);
|
|
54
|
+
|
|
55
|
+
animation.start(onComplete);
|
|
56
|
+
return () => animation.stop();
|
|
57
|
+
}, [isExpanded, expandAnimatedValue, containerHeight, expandDuration, collapseDuration]); // Without `visibility: 'hidden', descendents are focusable on web even when collapsed
|
|
58
|
+
|
|
59
|
+
const containerStyles = !isExpanded && !isAnimating ? {
|
|
60
|
+
visibility: 'hidden'
|
|
61
|
+
} : {}; // don't visually collapse the container until we have it measured
|
|
45
62
|
|
|
46
63
|
if (containerHeight !== null) {
|
|
47
64
|
if (_Platform.default.OS === 'web') {
|
|
48
65
|
const transitionDuration = isExpanded ? expandDuration : collapseDuration;
|
|
49
|
-
containerStyles = {
|
|
50
|
-
|
|
51
|
-
height: isExpanded ? containerHeight : 0
|
|
52
|
-
};
|
|
66
|
+
containerStyles.transition = `height ${transitionDuration}ms ease-in-out`;
|
|
67
|
+
containerStyles.height = isExpanded ? containerHeight : 0;
|
|
53
68
|
} else {
|
|
54
|
-
containerStyles =
|
|
55
|
-
height: expandAnimatedValue
|
|
56
|
-
};
|
|
69
|
+
containerStyles.height = expandAnimatedValue;
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
72
|
|
|
60
|
-
return containerStyles;
|
|
73
|
+
return [containerStyles, elementRef];
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
var _default = useVerticalExpandAnimation;
|
package/lib/utils/input.js
CHANGED
|
@@ -7,6 +7,9 @@ exports.useMultipleInputValues = exports.useInputValue = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import('react').SyntheticEvent} Event
|
|
12
|
+
*/
|
|
10
13
|
const pluralHooks = ['useMultipleInputValues'];
|
|
11
14
|
|
|
12
15
|
const validateProps = ({
|
|
@@ -64,11 +67,9 @@ Consumers of this hook must be one of:
|
|
|
64
67
|
*
|
|
65
68
|
* @param {string} hookName - optional, used for tailoring error messages
|
|
66
69
|
*
|
|
67
|
-
* @typedef {(oldValue: string|number|null) => string|number|null} UpdaterFunction - `setValue` takes a value or
|
|
68
|
-
* a function returning a new value from the old value
|
|
69
70
|
* @returns {{
|
|
70
71
|
* currentValue: string|number|null
|
|
71
|
-
* setValue: (newValue: string|number|null|
|
|
72
|
+
* setValue: (newValue: string|number|null|(oldValue: string|number) => string|number, event: Event) => void
|
|
72
73
|
* resetValue: () => void
|
|
73
74
|
* isControlled: bool
|
|
74
75
|
* }}
|
|
@@ -130,12 +131,10 @@ const useInputValue = (props = {}, hookName = 'useInputValue') => {
|
|
|
130
131
|
*
|
|
131
132
|
* @param {string} componentName - optional, used in error messages
|
|
132
133
|
*
|
|
133
|
-
* @typedef {(oldValues: string[]|number[]) => string[]|number[]} UpdaterFunction - `setValues` takes values or
|
|
134
|
-
* a function returning new values from old values
|
|
135
134
|
* @returns {{
|
|
136
135
|
* currentValues: any
|
|
137
136
|
* resetValues: () => void
|
|
138
|
-
* setValues: (newValues: string[]|number[]|
|
|
137
|
+
* setValues: (newValues: string[]|number[]|(oldValues: string[]|number[]) => string[]|number[], event: Event) => void
|
|
139
138
|
* toggleOneValue: (value: string|number) => void
|
|
140
139
|
* unsetValues: () => void
|
|
141
140
|
* }}
|
package/lib/utils/props/index.js
CHANGED
|
@@ -17,6 +17,8 @@ var _exportNames = {
|
|
|
17
17
|
responsiveProps: true,
|
|
18
18
|
spacingProps: true,
|
|
19
19
|
selectSystemProps: true,
|
|
20
|
+
textInputProps: true,
|
|
21
|
+
textProps: true,
|
|
20
22
|
variantProp: true,
|
|
21
23
|
viewProps: true
|
|
22
24
|
};
|
|
@@ -98,6 +100,18 @@ Object.defineProperty(exports, "selectSystemProps", {
|
|
|
98
100
|
return _selectSystemProps.default;
|
|
99
101
|
}
|
|
100
102
|
});
|
|
103
|
+
Object.defineProperty(exports, "textInputProps", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return _textInputProps.default;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, "textProps", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _textProps.default;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
101
115
|
Object.defineProperty(exports, "variantProp", {
|
|
102
116
|
enumerable: true,
|
|
103
117
|
get: function () {
|
|
@@ -165,6 +179,10 @@ var _spacingProps = _interopRequireDefault(require("./spacingProps"));
|
|
|
165
179
|
|
|
166
180
|
var _selectSystemProps = _interopRequireDefault(require("./selectSystemProps"));
|
|
167
181
|
|
|
182
|
+
var _textInputProps = _interopRequireDefault(require("./textInputProps"));
|
|
183
|
+
|
|
184
|
+
var _textProps = _interopRequireDefault(require("./textProps"));
|
|
185
|
+
|
|
168
186
|
var _variantProp = _interopRequireDefault(require("./variantProp"));
|
|
169
187
|
|
|
170
188
|
var _viewProps = _interopRequireDefault(require("./viewProps"));
|
|
@@ -11,6 +11,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
11
11
|
|
|
12
12
|
var _default = {
|
|
13
13
|
types: {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the English or French copy will be used (e.g. for accessibility labels).
|
|
16
|
+
*/
|
|
17
|
+
copy: _propTypes.default.oneOf(['en', 'fr']),
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* The input label.
|
|
16
21
|
*/
|
|
@@ -43,6 +48,7 @@ var _default = {
|
|
|
43
48
|
validation: _propTypes.default.oneOf(['error', 'success'])
|
|
44
49
|
},
|
|
45
50
|
select: ({
|
|
51
|
+
copy,
|
|
46
52
|
label,
|
|
47
53
|
hint,
|
|
48
54
|
hintPosition,
|
|
@@ -51,6 +57,7 @@ var _default = {
|
|
|
51
57
|
validation
|
|
52
58
|
}) => ({
|
|
53
59
|
supportsProps: {
|
|
60
|
+
copy,
|
|
54
61
|
label,
|
|
55
62
|
hint,
|
|
56
63
|
hintPosition,
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
+
|
|
12
|
+
var _getPropSelector = _interopRequireDefault(require("./getPropSelector"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
// This file contains common props for components that render a React Native TextInput
|
|
17
|
+
// It excludes interaction handler functions which are in `./handlerProps.js`
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* TextInput (web and native) supports some common React Native props
|
|
21
|
+
* shared with React Native's Text component.
|
|
22
|
+
*/
|
|
23
|
+
const textProps = {
|
|
24
|
+
maxFontSizeMultiplier: _propTypes.default.number,
|
|
25
|
+
nativeId: _propTypes.default.string,
|
|
26
|
+
onLayout: _propTypes.default.func
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* UDS text inputs accept props related to UDS's useInputValue hook
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
const inputValueProps = {
|
|
33
|
+
value: _propTypes.default.string,
|
|
34
|
+
initialValue: _propTypes.default.string,
|
|
35
|
+
readOnly: _propTypes.default.bool,
|
|
36
|
+
inactive: _propTypes.default.bool
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* This collection adds props that can be passed through to both React Native's
|
|
40
|
+
* and React Native Web's implementations of the React Native TextInput component.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const crossPlatform = { ...textProps,
|
|
44
|
+
...inputValueProps,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Web and Android; 'off' disables device autocomplete, other strings are platform-specific.
|
|
48
|
+
* Valid values on Native: https://reactnative.dev/docs/textinput#autocomplete-android
|
|
49
|
+
* Valid values on Web: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
|
50
|
+
*/
|
|
51
|
+
autoComplete: _propTypes.default.string,
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* On Native, default is `true`, passing `false` disables autoCorrect.
|
|
55
|
+
* On web, only supported by Safari and expects "on" or "off" strings.
|
|
56
|
+
*/
|
|
57
|
+
autoCorrect: _propTypes.default.oneOf([true, false, 'on', 'off']),
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Focuses the element on mount. On Web, only the first form element with autoFocus is focussed.
|
|
61
|
+
*/
|
|
62
|
+
autoFocus: _propTypes.default.bool,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Default is `true` for single line, `false` for multi-line
|
|
66
|
+
*/
|
|
67
|
+
blurOnSubmit: _propTypes.default.bool,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* iOS and Web only, no effect on Android
|
|
71
|
+
*/
|
|
72
|
+
clearTextOnFocus: _propTypes.default.bool,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Default is `true`. On web, this works by mapping to input's `readonly` attribute
|
|
76
|
+
*/
|
|
77
|
+
editable: _propTypes.default.bool,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* See documentation for allowed values (varies between Web, Android and iOS) and important notes:
|
|
81
|
+
* - Native: https://reactnative.dev/docs/textinput#keyboardtype
|
|
82
|
+
* - Web: equivalent to `inputmode` but see https://necolas.github.io/react-native-web/docs/text-input/
|
|
83
|
+
*/
|
|
84
|
+
keyboardType: _propTypes.default.string,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Uses native tools (no flicker) to cap the maximum number of characters.
|
|
88
|
+
* On Web, works via `maxlength` attr.
|
|
89
|
+
*/
|
|
90
|
+
maxLength: _propTypes.default.number,
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* If passed as true, the text input can be multiple lines.
|
|
94
|
+
*
|
|
95
|
+
* > It is important to note that this aligns the text to the top on iOS, and centers it on Android.
|
|
96
|
+
* > Use with textAlignVertical set to top for the same behavior in both platforms.
|
|
97
|
+
*/
|
|
98
|
+
multiline: _propTypes.default.bool,
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Web and Android only, requires `multiline` to be `true`.
|
|
102
|
+
*/
|
|
103
|
+
numberOfLines: _propTypes.default.number,
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Text to display when no value set.
|
|
107
|
+
* Accesibility guidelines recommend using labels to describe the input and using
|
|
108
|
+
* placeholders rarely and sparingly to prompt a particular format.
|
|
109
|
+
*/
|
|
110
|
+
placeholder: _propTypes.default.string,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Sets placeholder colour. On Web, uses `::placeholder { color: ... }` selector.
|
|
114
|
+
*/
|
|
115
|
+
placeholderTextColor: _propTypes.default.string,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* One of a subset of platform-specific options that controls labelling and presentation
|
|
119
|
+
* in on-screen keyboards and accessibility tools. Uses `enterkeyhint` attr on Web.
|
|
120
|
+
*
|
|
121
|
+
* 'done', 'go', 'next', 'search', and 'send' are available for Web, Android and iOS.
|
|
122
|
+
*/
|
|
123
|
+
returnKeyType: _propTypes.default.string,
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Obscures passwords and similar. Equivalent to type="password" on Web.
|
|
127
|
+
* Does not work if multiline is true.
|
|
128
|
+
*/
|
|
129
|
+
secureTextEntry: _propTypes.default.bool,
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* If true, all text will automatically be selected on focus.
|
|
133
|
+
*/
|
|
134
|
+
selectTextOnFocus: _propTypes.default.bool,
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Web and iOS. On iOS, default inherits from `autoCorrect`.
|
|
138
|
+
* On Web, equivalent to `spellcheck` attr.
|
|
139
|
+
*/
|
|
140
|
+
spellCheck: _propTypes.default.bool
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* These web-only props all control HTML `input` attributes of the same name.
|
|
144
|
+
* Refer to general HTML documentation for more details.
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
const webOnly = {
|
|
148
|
+
disabled: _propTypes.default.bool,
|
|
149
|
+
dir: _propTypes.default.oneOf(['auto', 'ltr', 'rtl']),
|
|
150
|
+
lang: _propTypes.default.string
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* These props are supported in React Native but not React Native Web.
|
|
154
|
+
*
|
|
155
|
+
* React Native text inputs can be quirky, so a full set of props should be allowed to handle edge cases.
|
|
156
|
+
* Refer to React Native documentation for details, allowed values, and Android/iOS support and versions:
|
|
157
|
+
* https://reactnative.dev/docs/textinput
|
|
158
|
+
*
|
|
159
|
+
* Beware that many React Native text input props apply via complicated logic that chooses a built-in
|
|
160
|
+
* native component based on the values of multiple boolean flags, and may sometimes appear to pick an
|
|
161
|
+
* option that is inappropriate for one flag based on the values of one or more other other flags.
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
const nativeOnly = {
|
|
165
|
+
caretHidden: _propTypes.default.bool,
|
|
166
|
+
clearButtonMode: _propTypes.default.string,
|
|
167
|
+
contextMenuHidden: _propTypes.default.bool,
|
|
168
|
+
dataDetectorTypes: _propTypes.default.string,
|
|
169
|
+
disableFullscreenUI: _propTypes.default.bool,
|
|
170
|
+
enablesReturnKeyAutomatically: _propTypes.default.bool,
|
|
171
|
+
importantForAutofill: _propTypes.default.string,
|
|
172
|
+
inlineImageLeft: _propTypes.default.string,
|
|
173
|
+
keyboardAppearance: _propTypes.default.string,
|
|
174
|
+
returnKeyLabel: _propTypes.default.string,
|
|
175
|
+
rejectResponderTermination: _propTypes.default.bool,
|
|
176
|
+
scrollEnabled: _propTypes.default.bool,
|
|
177
|
+
selection: _propTypes.default.object,
|
|
178
|
+
selectionColor: _propTypes.default.string,
|
|
179
|
+
showSoftInputOnFocus: _propTypes.default.bool,
|
|
180
|
+
textAlign: _propTypes.default.string,
|
|
181
|
+
textContentType: _propTypes.default.string,
|
|
182
|
+
passwordRules: _propTypes.default.string,
|
|
183
|
+
textBreakStrategy: _propTypes.default.string,
|
|
184
|
+
underlineColorAndroid: _propTypes.default.string
|
|
185
|
+
};
|
|
186
|
+
var _default = {
|
|
187
|
+
/**
|
|
188
|
+
* Subset of proptypes that can be passed down to a React Native or React Native Web
|
|
189
|
+
* `TextInput` component. Allow regardless of platform, so cross-platform apps don't warn.
|
|
190
|
+
*/
|
|
191
|
+
types: { ...crossPlatform,
|
|
192
|
+
...webOnly,
|
|
193
|
+
...nativeOnly
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Filters a props object. Return only platform-appropriate TextInput props, native inputs
|
|
198
|
+
* may throw errors on receiving unknown props.
|
|
199
|
+
*/
|
|
200
|
+
select: (0, _getPropSelector.default)({ ...crossPlatform,
|
|
201
|
+
..._Platform.default.select({
|
|
202
|
+
web: webOnly,
|
|
203
|
+
default: nativeOnly
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
};
|
|
207
|
+
exports.default = _default;
|