@canonical/react-components 0.37.8 → 0.37.9
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.
|
@@ -52,10 +52,14 @@ export declare type Props = PropsWithSpread<{
|
|
|
52
52
|
* Whether to focus on the input on initial render.
|
|
53
53
|
*/
|
|
54
54
|
takeFocus?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Delay takeFocus in milliseconds i.e. to let animations finish
|
|
57
|
+
*/
|
|
58
|
+
takeFocusDelay?: number;
|
|
55
59
|
/**
|
|
56
60
|
* Optional class(es) to pass to the wrapping Field component
|
|
57
61
|
*/
|
|
58
62
|
wrapperClassName?: string;
|
|
59
63
|
}, InputHTMLAttributes<HTMLInputElement>>;
|
|
60
|
-
declare const Input: ({ caution, className, error, help, helpClassName, id, label, labelClassName, required, stacked, success, takeFocus, type, wrapperClassName, ...inputProps }: Props) => JSX.Element;
|
|
64
|
+
declare const Input: ({ caution, className, error, help, helpClassName, id, label, labelClassName, required, stacked, success, takeFocus, takeFocusDelay, type, wrapperClassName, ...inputProps }: Props) => JSX.Element;
|
|
61
65
|
export default Input;
|
|
@@ -19,7 +19,7 @@ var _RadioInput = _interopRequireDefault(require("../RadioInput"));
|
|
|
19
19
|
|
|
20
20
|
var _hooks = require("../../hooks");
|
|
21
21
|
|
|
22
|
-
var _excluded = ["caution", "className", "error", "help", "helpClassName", "id", "label", "labelClassName", "required", "stacked", "success", "takeFocus", "type", "wrapperClassName"];
|
|
22
|
+
var _excluded = ["caution", "className", "error", "help", "helpClassName", "id", "label", "labelClassName", "required", "stacked", "success", "takeFocus", "takeFocusDelay", "type", "wrapperClassName"];
|
|
23
23
|
|
|
24
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
25
|
|
|
@@ -52,6 +52,7 @@ var Input = function Input(_ref) {
|
|
|
52
52
|
stacked = _ref.stacked,
|
|
53
53
|
success = _ref.success,
|
|
54
54
|
takeFocus = _ref.takeFocus,
|
|
55
|
+
takeFocusDelay = _ref.takeFocusDelay,
|
|
55
56
|
type = _ref.type,
|
|
56
57
|
wrapperClassName = _ref.wrapperClassName,
|
|
57
58
|
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -73,7 +74,13 @@ var Input = function Input(_ref) {
|
|
|
73
74
|
|
|
74
75
|
(0, _react.useEffect)(function () {
|
|
75
76
|
if (takeFocus) {
|
|
76
|
-
|
|
77
|
+
if (takeFocusDelay) {
|
|
78
|
+
setTimeout(function () {
|
|
79
|
+
return inputRef.current.focus();
|
|
80
|
+
}, takeFocusDelay);
|
|
81
|
+
} else {
|
|
82
|
+
inputRef.current.focus();
|
|
83
|
+
}
|
|
77
84
|
}
|
|
78
85
|
}, [takeFocus]);
|
|
79
86
|
var input;
|
|
@@ -61,7 +61,12 @@ var Modal = function Modal(_ref) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var handleEscKey = function handleEscKey(e) {
|
|
65
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
66
|
+
close();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var keyListenersMap = new Map([["Escape", handleEscKey], ["Tab", handleTabKey]]);
|
|
65
70
|
(0, _react.useEffect)(function () {
|
|
66
71
|
modalRef.current.focus();
|
|
67
72
|
}, [modalRef]);
|
|
@@ -69,7 +74,13 @@ var Modal = function Modal(_ref) {
|
|
|
69
74
|
var _focusableModalElemen;
|
|
70
75
|
|
|
71
76
|
focusableModalElements.current = modalRef.current.querySelectorAll(focusableElementSelectors);
|
|
72
|
-
|
|
77
|
+
var focusIndex = 0; // when the close button is rendered, focus on the 2nd content element and not the close btn.
|
|
78
|
+
|
|
79
|
+
if (close && focusableModalElements.current.length > 1) {
|
|
80
|
+
focusIndex = 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
(_focusableModalElemen = focusableModalElements.current[focusIndex]) === null || _focusableModalElemen === void 0 ? void 0 : _focusableModalElemen.focus();
|
|
73
84
|
}, []);
|
|
74
85
|
(0, _react.useEffect)(function () {
|
|
75
86
|
var keyDown = function keyDown(e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"ts-jest": "27.1.5",
|
|
80
80
|
"tsc-alias": "1.7.0",
|
|
81
81
|
"typescript": "4.7.4",
|
|
82
|
-
"vanilla-framework": "3.
|
|
82
|
+
"vanilla-framework": "3.10.0",
|
|
83
83
|
"wait-on": "5.3.0",
|
|
84
84
|
"webpack": "5.74.0"
|
|
85
85
|
},
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^17.0.2 || ^18.0.0",
|
|
105
105
|
"react-dom": "^17.0.2 || ^18.0.0",
|
|
106
|
-
"vanilla-framework": "3.
|
|
106
|
+
"vanilla-framework": "3.10.0"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|