@telus-uds/components-base 1.8.5 → 1.9.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 +16 -2
- package/component-docs.json +16 -0
- package/lib/Card/Card.js +9 -4
- package/lib/ExpandCollapse/Panel.js +10 -1
- package/lib/TextInput/TextInput.js +0 -11
- package/lib/TextInput/TextInputBase.js +9 -0
- package/lib/TextInput/propTypes.js +3 -8
- package/lib/utils/props/textInputProps.js +8 -1
- package/lib-module/Card/Card.js +5 -4
- package/lib-module/ExpandCollapse/Panel.js +9 -1
- package/lib-module/TextInput/TextInput.js +0 -8
- package/lib-module/TextInput/TextInputBase.js +10 -1
- package/lib-module/TextInput/propTypes.js +4 -8
- package/lib-module/utils/props/textInputProps.js +8 -1
- package/package.json +2 -2
- package/src/Card/Card.jsx +6 -4
- package/src/ExpandCollapse/Panel.jsx +8 -1
- package/src/TextInput/TextInput.jsx +1 -8
- package/src/TextInput/TextInputBase.jsx +11 -1
- package/src/TextInput/propTypes.js +3 -7
- package/src/utils/props/textInputProps.js +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 08 Jul 2022 22:41:05 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.9.0
|
|
8
|
+
|
|
9
|
+
Fri, 08 Jul 2022 22:41:05 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- feat: add a controlRef prop to ExpandCollapse.Panel (ruslan.bredikhin@nearform.com)
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- don't throw if pattern used without ref (alan.slater@nearform.com)
|
|
18
|
+
- Add forwardRef to Card (alan.slater@nearform.com)
|
|
19
|
+
- Support pattern in all text input components (alan.slater@nearform.com)
|
|
20
|
+
|
|
7
21
|
## 1.8.5
|
|
8
22
|
|
|
9
|
-
Tue, 28 Jun 2022 21:
|
|
23
|
+
Tue, 28 Jun 2022 21:36:14 GMT
|
|
10
24
|
|
|
11
25
|
### Patches
|
|
12
26
|
|
package/component-docs.json
CHANGED
|
@@ -1810,6 +1810,14 @@
|
|
|
1810
1810
|
},
|
|
1811
1811
|
"required": false,
|
|
1812
1812
|
"description": "Optional theme token overrides that may be passed to the ExpandCollapseControl element."
|
|
1813
|
+
},
|
|
1814
|
+
"controlRef": {
|
|
1815
|
+
"type": {
|
|
1816
|
+
"name": "custom",
|
|
1817
|
+
"raw": "ABBPropTypes.ref()"
|
|
1818
|
+
},
|
|
1819
|
+
"required": false,
|
|
1820
|
+
"description": "An optional ref to be attached to the control"
|
|
1813
1821
|
}
|
|
1814
1822
|
},
|
|
1815
1823
|
"attributes": {
|
|
@@ -2694,6 +2702,14 @@
|
|
|
2694
2702
|
},
|
|
2695
2703
|
"required": false,
|
|
2696
2704
|
"description": "Optional theme token overrides that may be passed to the ExpandCollapseControl element."
|
|
2705
|
+
},
|
|
2706
|
+
"controlRef": {
|
|
2707
|
+
"type": {
|
|
2708
|
+
"name": "custom",
|
|
2709
|
+
"raw": "ABBPropTypes.ref()"
|
|
2710
|
+
},
|
|
2711
|
+
"required": false,
|
|
2712
|
+
"description": "An optional ref to be attached to the control"
|
|
2697
2713
|
}
|
|
2698
2714
|
},
|
|
2699
2715
|
"attributes": {
|
package/lib/Card/Card.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -23,6 +23,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
23
23
|
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
26
|
+
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); }
|
|
27
|
+
|
|
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
|
+
|
|
26
30
|
const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_props.a11yProps, _props.viewProps]);
|
|
27
31
|
/**
|
|
28
32
|
* A basic card component, unstyled by default.
|
|
@@ -73,7 +77,7 @@ const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_p
|
|
|
73
77
|
* depending on what you are trying to achieve.
|
|
74
78
|
*/
|
|
75
79
|
|
|
76
|
-
const Card = _ref => {
|
|
80
|
+
const Card = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
77
81
|
let {
|
|
78
82
|
children,
|
|
79
83
|
tokens,
|
|
@@ -86,13 +90,14 @@ const Card = _ref => {
|
|
|
86
90
|
viewport
|
|
87
91
|
});
|
|
88
92
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
|
|
93
|
+
ref: ref,
|
|
89
94
|
tokens: themeTokens,
|
|
90
95
|
dataSet: dataSet,
|
|
91
96
|
...selectProps(rest),
|
|
92
97
|
children: children
|
|
93
98
|
});
|
|
94
|
-
};
|
|
95
|
-
|
|
99
|
+
});
|
|
100
|
+
Card.displayName = 'Card';
|
|
96
101
|
Card.propTypes = { ...selectedSystemPropTypes,
|
|
97
102
|
children: _propTypes.default.node,
|
|
98
103
|
tokens: (0, _utils.getTokensPropType)('Card'),
|
|
@@ -15,6 +15,8 @@ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Vi
|
|
|
15
15
|
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
17
|
|
|
18
|
+
var _airbnbPropTypes = _interopRequireDefault(require("airbnb-prop-types"));
|
|
19
|
+
|
|
18
20
|
var _Control = _interopRequireDefault(require("./Control"));
|
|
19
21
|
|
|
20
22
|
var _ThemeProvider = require("../ThemeProvider");
|
|
@@ -70,6 +72,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
70
72
|
children,
|
|
71
73
|
tokens,
|
|
72
74
|
variant,
|
|
75
|
+
controlRef,
|
|
73
76
|
...rest
|
|
74
77
|
} = _ref2;
|
|
75
78
|
const [containerHeight, setContainerHeight] = (0, _react.useState)(null);
|
|
@@ -112,6 +115,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
|
|
|
112
115
|
isExpanded: isExpanded,
|
|
113
116
|
tokens: controlTokens,
|
|
114
117
|
onPress: handleControlPress,
|
|
118
|
+
ref: controlRef,
|
|
115
119
|
children: control
|
|
116
120
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Animated.default.View, {
|
|
117
121
|
ref: animatedRef,
|
|
@@ -167,7 +171,12 @@ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
|
|
|
167
171
|
/**
|
|
168
172
|
* Optional theme token overrides that may be passed to the ExpandCollapseControl element.
|
|
169
173
|
*/
|
|
170
|
-
controlTokens: (0, _utils.getTokensPropType)('ExpandCollapseControl')
|
|
174
|
+
controlTokens: (0, _utils.getTokensPropType)('ExpandCollapseControl'),
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* An optional ref to be attached to the control
|
|
178
|
+
*/
|
|
179
|
+
controlRef: _airbnbPropTypes.default.ref()
|
|
171
180
|
};
|
|
172
181
|
var _default = ExpandCollapsePanel;
|
|
173
182
|
exports.default = _default;
|
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
-
|
|
12
10
|
var _utils = require("../utils");
|
|
13
11
|
|
|
14
12
|
var _InputSupports = _interopRequireDefault(require("../InputSupports"));
|
|
@@ -49,17 +47,8 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
49
47
|
let {
|
|
50
48
|
tokens,
|
|
51
49
|
variant = {},
|
|
52
|
-
pattern,
|
|
53
50
|
...rest
|
|
54
51
|
} = _ref;
|
|
55
|
-
|
|
56
|
-
_react.default.useEffect(() => {
|
|
57
|
-
if (_Platform.default.OS === 'web' && pattern && ref.current) {
|
|
58
|
-
// eslint-disable-next-line no-param-reassign
|
|
59
|
-
ref.current.pattern = pattern;
|
|
60
|
-
}
|
|
61
|
-
}, [ref, pattern]);
|
|
62
|
-
|
|
63
52
|
const {
|
|
64
53
|
supportsProps,
|
|
65
54
|
...selectedProps
|
|
@@ -156,6 +156,7 @@ const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
156
156
|
onBlur,
|
|
157
157
|
onMouseOver,
|
|
158
158
|
onMouseOut,
|
|
159
|
+
pattern,
|
|
159
160
|
tokens,
|
|
160
161
|
variant = {},
|
|
161
162
|
...rest
|
|
@@ -194,6 +195,14 @@ const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
194
195
|
onChange,
|
|
195
196
|
readOnly
|
|
196
197
|
});
|
|
198
|
+
const element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
199
|
+
(0, _react.useEffect)(() => {
|
|
200
|
+
if (_Platform.default.OS === 'web' && pattern && element) {
|
|
201
|
+
// React Native Web doesn't support `pattern`, so we have to attach it via a ref,
|
|
202
|
+
// which a `pattern` user must provide anyway to call .checkValidity() on the element.
|
|
203
|
+
element.pattern = pattern;
|
|
204
|
+
}
|
|
205
|
+
}, [element, pattern]);
|
|
197
206
|
|
|
198
207
|
const handleChangeText = event => {
|
|
199
208
|
var _event$nativeEvent, _event$target;
|
|
@@ -7,10 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
-
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
-
|
|
12
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
11
|
|
|
12
|
+
// These are prop types specific to UDS TextInput; see also ../utils/props/textInputProps
|
|
13
|
+
// for generic React Native props and HTML input attrs that are passed through.
|
|
14
14
|
const textInputPropTypes = {
|
|
15
15
|
/**
|
|
16
16
|
* If the input's state is to be controlled by a parent component, use this prop
|
|
@@ -38,12 +38,7 @@ const textInputPropTypes = {
|
|
|
38
38
|
* Use to react upon input's value changes. Required when the `value` prop is set.
|
|
39
39
|
* Will receive the input's value as an argument.
|
|
40
40
|
*/
|
|
41
|
-
onChange: _propTypes.default.func
|
|
42
|
-
..._Platform.default.select({
|
|
43
|
-
web: {
|
|
44
|
-
pattern: _propTypes.default.string
|
|
45
|
-
}
|
|
46
|
-
})
|
|
41
|
+
onChange: _propTypes.default.func
|
|
47
42
|
};
|
|
48
43
|
var _default = textInputPropTypes;
|
|
49
44
|
exports.default = _default;
|
|
@@ -147,7 +147,14 @@ const crossPlatform = { ...textProps,
|
|
|
147
147
|
const webOnly = {
|
|
148
148
|
disabled: _propTypes.default.bool,
|
|
149
149
|
dir: _propTypes.default.oneOf(['auto', 'ltr', 'rtl']),
|
|
150
|
-
lang: _propTypes.default.string
|
|
150
|
+
lang: _propTypes.default.string,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Sets the HTML input `pattern` attr. Not supported by React Native Web, but is supported by UDS.
|
|
154
|
+
* Must also pass in a ref and check validity by calling the HTML element's checkValidity method:
|
|
155
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
|
|
156
|
+
*/
|
|
157
|
+
pattern: _propTypes.default.string
|
|
151
158
|
};
|
|
152
159
|
/**
|
|
153
160
|
* These props are supported in React Native but not React Native Web.
|
package/lib-module/Card/Card.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useThemeTokens } from '../ThemeProvider';
|
|
4
4
|
import { getTokensPropType, variantProp } from '../utils';
|
|
@@ -56,7 +56,7 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
56
56
|
* depending on what you are trying to achieve.
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
|
-
const Card = _ref => {
|
|
59
|
+
const Card = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
60
60
|
let {
|
|
61
61
|
children,
|
|
62
62
|
tokens,
|
|
@@ -69,13 +69,14 @@ const Card = _ref => {
|
|
|
69
69
|
viewport
|
|
70
70
|
});
|
|
71
71
|
return /*#__PURE__*/_jsx(CardBase, {
|
|
72
|
+
ref: ref,
|
|
72
73
|
tokens: themeTokens,
|
|
73
74
|
dataSet: dataSet,
|
|
74
75
|
...selectProps(rest),
|
|
75
76
|
children: children
|
|
76
77
|
});
|
|
77
|
-
};
|
|
78
|
-
|
|
78
|
+
});
|
|
79
|
+
Card.displayName = 'Card';
|
|
79
80
|
Card.propTypes = { ...selectedSystemPropTypes,
|
|
80
81
|
children: PropTypes.node,
|
|
81
82
|
tokens: getTokensPropType('Card'),
|
|
@@ -3,6 +3,7 @@ import Animated from "react-native-web/dist/exports/Animated";
|
|
|
3
3
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
4
|
import View from "react-native-web/dist/exports/View";
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import ABBPropTypes from 'airbnb-prop-types';
|
|
6
7
|
import ExpandCollapseControl from './Control';
|
|
7
8
|
import { useThemeTokens } from '../ThemeProvider';
|
|
8
9
|
import { a11yProps, getTokensPropType, selectSystemProps, useVerticalExpandAnimation, variantProp, viewProps } from '../utils';
|
|
@@ -49,6 +50,7 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
49
50
|
children,
|
|
50
51
|
tokens,
|
|
51
52
|
variant,
|
|
53
|
+
controlRef,
|
|
52
54
|
...rest
|
|
53
55
|
} = _ref2;
|
|
54
56
|
const [containerHeight, setContainerHeight] = useState(null);
|
|
@@ -91,6 +93,7 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
91
93
|
isExpanded: isExpanded,
|
|
92
94
|
tokens: controlTokens,
|
|
93
95
|
onPress: handleControlPress,
|
|
96
|
+
ref: controlRef,
|
|
94
97
|
children: control
|
|
95
98
|
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
96
99
|
ref: animatedRef,
|
|
@@ -146,6 +149,11 @@ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
|
|
|
146
149
|
/**
|
|
147
150
|
* Optional theme token overrides that may be passed to the ExpandCollapseControl element.
|
|
148
151
|
*/
|
|
149
|
-
controlTokens: getTokensPropType('ExpandCollapseControl')
|
|
152
|
+
controlTokens: getTokensPropType('ExpandCollapseControl'),
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* An optional ref to be attached to the control
|
|
156
|
+
*/
|
|
157
|
+
controlRef: ABBPropTypes.ref()
|
|
150
158
|
};
|
|
151
159
|
export default ExpandCollapsePanel;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import Platform from "react-native-web/dist/exports/Platform";
|
|
3
2
|
import { a11yProps, focusHandlerProps, getTokensPropType, inputSupportsProps, selectSystemProps, textInputHandlerProps, textInputProps, variantProp, viewProps } from '../utils';
|
|
4
3
|
import InputSupports from '../InputSupports';
|
|
5
4
|
import TextInputBase from './TextInputBase';
|
|
@@ -29,15 +28,8 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
29
28
|
let {
|
|
30
29
|
tokens,
|
|
31
30
|
variant = {},
|
|
32
|
-
pattern,
|
|
33
31
|
...rest
|
|
34
32
|
} = _ref;
|
|
35
|
-
React.useEffect(() => {
|
|
36
|
-
if (Platform.OS === 'web' && pattern && ref.current) {
|
|
37
|
-
// eslint-disable-next-line no-param-reassign
|
|
38
|
-
ref.current.pattern = pattern;
|
|
39
|
-
}
|
|
40
|
-
}, [ref, pattern]);
|
|
41
33
|
const {
|
|
42
34
|
supportsProps,
|
|
43
35
|
...selectedProps
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useEffect, useState } from 'react';
|
|
2
2
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
3
3
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
4
|
import NativeTextInput from "react-native-web/dist/exports/TextInput";
|
|
@@ -133,6 +133,7 @@ const TextInputBase = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
133
133
|
onBlur,
|
|
134
134
|
onMouseOver,
|
|
135
135
|
onMouseOut,
|
|
136
|
+
pattern,
|
|
136
137
|
tokens,
|
|
137
138
|
variant = {},
|
|
138
139
|
...rest
|
|
@@ -171,6 +172,14 @@ const TextInputBase = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
171
172
|
onChange,
|
|
172
173
|
readOnly
|
|
173
174
|
});
|
|
175
|
+
const element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (Platform.OS === 'web' && pattern && element) {
|
|
178
|
+
// React Native Web doesn't support `pattern`, so we have to attach it via a ref,
|
|
179
|
+
// which a `pattern` user must provide anyway to call .checkValidity() on the element.
|
|
180
|
+
element.pattern = pattern;
|
|
181
|
+
}
|
|
182
|
+
}, [element, pattern]);
|
|
174
183
|
|
|
175
184
|
const handleChangeText = event => {
|
|
176
185
|
var _event$nativeEvent, _event$target;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
|
|
1
|
+
import PropTypes from 'prop-types'; // These are prop types specific to UDS TextInput; see also ../utils/props/textInputProps
|
|
2
|
+
// for generic React Native props and HTML input attrs that are passed through.
|
|
3
|
+
|
|
3
4
|
const textInputPropTypes = {
|
|
4
5
|
/**
|
|
5
6
|
* If the input's state is to be controlled by a parent component, use this prop
|
|
@@ -27,11 +28,6 @@ const textInputPropTypes = {
|
|
|
27
28
|
* Use to react upon input's value changes. Required when the `value` prop is set.
|
|
28
29
|
* Will receive the input's value as an argument.
|
|
29
30
|
*/
|
|
30
|
-
onChange: PropTypes.func
|
|
31
|
-
...Platform.select({
|
|
32
|
-
web: {
|
|
33
|
-
pattern: PropTypes.string
|
|
34
|
-
}
|
|
35
|
-
})
|
|
31
|
+
onChange: PropTypes.func
|
|
36
32
|
};
|
|
37
33
|
export default textInputPropTypes;
|
|
@@ -135,7 +135,14 @@ const crossPlatform = { ...textProps,
|
|
|
135
135
|
const webOnly = {
|
|
136
136
|
disabled: PropTypes.bool,
|
|
137
137
|
dir: PropTypes.oneOf(['auto', 'ltr', 'rtl']),
|
|
138
|
-
lang: PropTypes.string
|
|
138
|
+
lang: PropTypes.string,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Sets the HTML input `pattern` attr. Not supported by React Native Web, but is supported by UDS.
|
|
142
|
+
* Must also pass in a ref and check validity by calling the HTML element's checkValidity method:
|
|
143
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
|
|
144
|
+
*/
|
|
145
|
+
pattern: PropTypes.string
|
|
139
146
|
};
|
|
140
147
|
/**
|
|
141
148
|
* These props are supported in React Native but not React Native Web.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telus-uds/components-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Base components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"base"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^17.0.2",
|
|
48
48
|
"react-dom": "^17.0.2",
|
|
49
|
-
"react-native": "
|
|
49
|
+
"react-native": "0.68.2",
|
|
50
50
|
"react-native-web": "^0.17.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
package/src/Card/Card.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
4
|
import { useThemeTokens } from '../ThemeProvider'
|
|
@@ -57,16 +57,18 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
57
57
|
* you automatically make inaccessible its children, which may or may not be appropriate
|
|
58
58
|
* depending on what you are trying to achieve.
|
|
59
59
|
*/
|
|
60
|
-
const Card = ({ children, tokens, variant, dataSet, ...rest }) => {
|
|
60
|
+
const Card = forwardRef(({ children, tokens, variant, dataSet, ...rest }, ref) => {
|
|
61
61
|
const viewport = useViewport()
|
|
62
62
|
const themeTokens = useThemeTokens('Card', tokens, variant, { viewport })
|
|
63
63
|
|
|
64
64
|
return (
|
|
65
|
-
<CardBase tokens={themeTokens} dataSet={dataSet} {...selectProps(rest)}>
|
|
65
|
+
<CardBase ref={ref} tokens={themeTokens} dataSet={dataSet} {...selectProps(rest)}>
|
|
66
66
|
{children}
|
|
67
67
|
</CardBase>
|
|
68
68
|
)
|
|
69
|
-
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
Card.displayName = 'Card'
|
|
70
72
|
|
|
71
73
|
Card.propTypes = {
|
|
72
74
|
...selectedSystemPropTypes,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useState } from 'react'
|
|
2
2
|
import { Animated, Platform, View } from 'react-native'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
|
+
import ABBPropTypes from 'airbnb-prop-types'
|
|
4
5
|
|
|
5
6
|
import ExpandCollapseControl from './Control'
|
|
6
7
|
import { useThemeTokens } from '../ThemeProvider'
|
|
@@ -51,6 +52,7 @@ const ExpandCollapsePanel = forwardRef(
|
|
|
51
52
|
children,
|
|
52
53
|
tokens,
|
|
53
54
|
variant,
|
|
55
|
+
controlRef,
|
|
54
56
|
...rest
|
|
55
57
|
},
|
|
56
58
|
ref
|
|
@@ -95,6 +97,7 @@ const ExpandCollapsePanel = forwardRef(
|
|
|
95
97
|
isExpanded={isExpanded}
|
|
96
98
|
tokens={controlTokens}
|
|
97
99
|
onPress={handleControlPress}
|
|
100
|
+
ref={controlRef}
|
|
98
101
|
>
|
|
99
102
|
{control}
|
|
100
103
|
</ExpandCollapseControl>
|
|
@@ -142,7 +145,11 @@ ExpandCollapsePanel.propTypes = {
|
|
|
142
145
|
/**
|
|
143
146
|
* Optional theme token overrides that may be passed to the ExpandCollapseControl element.
|
|
144
147
|
*/
|
|
145
|
-
controlTokens: getTokensPropType('ExpandCollapseControl')
|
|
148
|
+
controlTokens: getTokensPropType('ExpandCollapseControl'),
|
|
149
|
+
/**
|
|
150
|
+
* An optional ref to be attached to the control
|
|
151
|
+
*/
|
|
152
|
+
controlRef: ABBPropTypes.ref()
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
export default ExpandCollapsePanel
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
|
-
import { Platform } from 'react-native'
|
|
3
2
|
import {
|
|
4
3
|
a11yProps,
|
|
5
4
|
focusHandlerProps,
|
|
@@ -42,13 +41,7 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([
|
|
|
42
41
|
* supported props and <a href="https://reactnative.dev/docs/textinput" target="_blank">React Native Web documentation</a> for
|
|
43
42
|
* their implementation on the web.
|
|
44
43
|
*/
|
|
45
|
-
const TextInput = forwardRef(({ tokens, variant = {},
|
|
46
|
-
React.useEffect(() => {
|
|
47
|
-
if (Platform.OS === 'web' && pattern && ref.current) {
|
|
48
|
-
// eslint-disable-next-line no-param-reassign
|
|
49
|
-
ref.current.pattern = pattern
|
|
50
|
-
}
|
|
51
|
-
}, [ref, pattern])
|
|
44
|
+
const TextInput = forwardRef(({ tokens, variant = {}, ...rest }, ref) => {
|
|
52
45
|
const { supportsProps, ...selectedProps } = selectProps(rest)
|
|
53
46
|
|
|
54
47
|
const inputProps = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useState } from 'react'
|
|
1
|
+
import React, { forwardRef, useEffect, useState } from 'react'
|
|
2
2
|
import { Platform, StyleSheet, TextInput as NativeTextInput, View } from 'react-native'
|
|
3
3
|
|
|
4
4
|
import PropTypes from 'prop-types'
|
|
@@ -128,6 +128,7 @@ const TextInputBase = forwardRef(
|
|
|
128
128
|
onBlur,
|
|
129
129
|
onMouseOver,
|
|
130
130
|
onMouseOut,
|
|
131
|
+
pattern,
|
|
131
132
|
tokens,
|
|
132
133
|
variant = {},
|
|
133
134
|
...rest
|
|
@@ -161,6 +162,15 @@ const TextInputBase = forwardRef(
|
|
|
161
162
|
readOnly
|
|
162
163
|
})
|
|
163
164
|
|
|
165
|
+
const element = ref?.current
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (Platform.OS === 'web' && pattern && element) {
|
|
168
|
+
// React Native Web doesn't support `pattern`, so we have to attach it via a ref,
|
|
169
|
+
// which a `pattern` user must provide anyway to call .checkValidity() on the element.
|
|
170
|
+
element.pattern = pattern
|
|
171
|
+
}
|
|
172
|
+
}, [element, pattern])
|
|
173
|
+
|
|
164
174
|
const handleChangeText = (event) => {
|
|
165
175
|
const text = event.nativeEvent?.text || event.target?.value
|
|
166
176
|
setValue(text, event)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
|
-
import { Platform } from 'react-native'
|
|
3
2
|
|
|
3
|
+
// These are prop types specific to UDS TextInput; see also ../utils/props/textInputProps
|
|
4
|
+
// for generic React Native props and HTML input attrs that are passed through.
|
|
4
5
|
const textInputPropTypes = {
|
|
5
6
|
/**
|
|
6
7
|
* If the input's state is to be controlled by a parent component, use this prop
|
|
@@ -24,12 +25,7 @@ const textInputPropTypes = {
|
|
|
24
25
|
* Use to react upon input's value changes. Required when the `value` prop is set.
|
|
25
26
|
* Will receive the input's value as an argument.
|
|
26
27
|
*/
|
|
27
|
-
onChange: PropTypes.func
|
|
28
|
-
...Platform.select({
|
|
29
|
-
web: {
|
|
30
|
-
pattern: PropTypes.string
|
|
31
|
-
}
|
|
32
|
-
})
|
|
28
|
+
onChange: PropTypes.func
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
export default textInputPropTypes
|
|
@@ -121,7 +121,13 @@ const crossPlatform = {
|
|
|
121
121
|
const webOnly = {
|
|
122
122
|
disabled: PropTypes.bool,
|
|
123
123
|
dir: PropTypes.oneOf(['auto', 'ltr', 'rtl']),
|
|
124
|
-
lang: PropTypes.string
|
|
124
|
+
lang: PropTypes.string,
|
|
125
|
+
/**
|
|
126
|
+
* Sets the HTML input `pattern` attr. Not supported by React Native Web, but is supported by UDS.
|
|
127
|
+
* Must also pass in a ref and check validity by calling the HTML element's checkValidity method:
|
|
128
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
|
|
129
|
+
*/
|
|
130
|
+
pattern: PropTypes.string
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
/**
|