@elastic/eui 77.2.0 → 77.2.2
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/es/components/focus_trap/focus_trap.js +21 -5
- package/es/components/form/field_number/field_number.js +15 -17
- package/eui.d.ts +7 -0
- package/lib/components/focus_trap/focus_trap.js +21 -5
- package/lib/components/form/field_number/field_number.js +14 -16
- package/optimize/es/components/focus_trap/focus_trap.js +15 -5
- package/optimize/es/components/form/field_number/field_number.js +15 -17
- package/optimize/lib/components/focus_trap/focus_trap.js +15 -5
- package/optimize/lib/components/form/field_number/field_number.js +14 -16
- package/package.json +2 -1
- package/test-env/components/form/field_number/field_number.js +14 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock"];
|
|
1
|
+
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock", "gapMode"];
|
|
2
2
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -28,6 +28,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
28
28
|
import React, { Component } from 'react';
|
|
29
29
|
import PropTypes from "prop-types";
|
|
30
30
|
import { FocusOn } from 'react-focus-on';
|
|
31
|
+
import { RemoveScrollBar } from 'react-remove-scroll-bar';
|
|
31
32
|
import { findElementBySelectorOrRef } from '../../services';
|
|
32
33
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
33
34
|
export var EuiFocusTrap = /*#__PURE__*/function (_Component) {
|
|
@@ -116,17 +117,25 @@ export var EuiFocusTrap = /*#__PURE__*/function (_Component) {
|
|
|
116
117
|
returnFocus = _this$props3.returnFocus,
|
|
117
118
|
noIsolation = _this$props3.noIsolation,
|
|
118
119
|
scrollLock = _this$props3.scrollLock,
|
|
120
|
+
gapMode = _this$props3.gapMode,
|
|
119
121
|
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
120
122
|
var isDisabled = disabled || this.state.hasBeenDisabledByClick;
|
|
121
123
|
var focusOnProps = _objectSpread(_objectSpread({
|
|
122
124
|
returnFocus: returnFocus,
|
|
123
125
|
noIsolation: noIsolation,
|
|
124
|
-
scrollLock: scrollLock,
|
|
125
126
|
enabled: !isDisabled
|
|
126
127
|
}, rest), {}, {
|
|
127
|
-
onClickOutside: this.handleOutsideClick
|
|
128
|
+
onClickOutside: this.handleOutsideClick,
|
|
129
|
+
/**
|
|
130
|
+
* `scrollLock` should always be unset on FocusOn, as it can prevent scrolling on
|
|
131
|
+
* portals (i.e. popovers, comboboxes, dropdown menus, etc.) within modals & flyouts
|
|
132
|
+
* @see https://github.com/theKashey/react-focus-on/issues/49
|
|
133
|
+
*/
|
|
134
|
+
scrollLock: false
|
|
128
135
|
});
|
|
129
|
-
return ___EmotionJSX(FocusOn, focusOnProps, children
|
|
136
|
+
return ___EmotionJSX(FocusOn, focusOnProps, children, scrollLock && ___EmotionJSX(RemoveScrollBar, {
|
|
137
|
+
gapMode: gapMode
|
|
138
|
+
}));
|
|
130
139
|
}
|
|
131
140
|
}]);
|
|
132
141
|
return EuiFocusTrap;
|
|
@@ -136,7 +145,8 @@ _defineProperty(EuiFocusTrap, "defaultProps", {
|
|
|
136
145
|
disabled: false,
|
|
137
146
|
returnFocus: true,
|
|
138
147
|
noIsolation: true,
|
|
139
|
-
scrollLock: false
|
|
148
|
+
scrollLock: false,
|
|
149
|
+
gapMode: 'padding' // EUI defaults to padding because Kibana's body/layout CSS ignores `margin`
|
|
140
150
|
});
|
|
141
151
|
EuiFocusTrap.propTypes = {
|
|
142
152
|
className: PropTypes.string,
|
|
@@ -157,5 +167,11 @@ EuiFocusTrap.propTypes = {
|
|
|
157
167
|
*/
|
|
158
168
|
initialFocus: PropTypes.any,
|
|
159
169
|
style: PropTypes.any,
|
|
170
|
+
/**
|
|
171
|
+
* if `scrollLock` is set to true, the body's scrollbar width will be preserved on lock
|
|
172
|
+
* via the `gapMode` CSS property. Depending on your custom CSS, you may prefer to use
|
|
173
|
+
* `margin` instead of `padding`.
|
|
174
|
+
*/
|
|
175
|
+
gapMode: PropTypes.oneOf(["padding", "margin"]),
|
|
160
176
|
disabled: PropTypes.bool
|
|
161
177
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "
|
|
1
|
+
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "onKeyUp"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
4
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -16,10 +16,9 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
16
16
|
* Side Public License, v 1.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import React, { useState,
|
|
19
|
+
import React, { useState, useCallback } from 'react';
|
|
20
20
|
import PropTypes from "prop-types";
|
|
21
21
|
import classNames from 'classnames';
|
|
22
|
-
import { useCombinedRefs } from '../../../services';
|
|
23
22
|
import { EuiValidatableControl } from '../validatable_control';
|
|
24
23
|
import { EuiFormControlLayout } from '../form_control_layout';
|
|
25
24
|
import { getFormControlClassNameForIconCount } from '../form_control_layout/_num_icons';
|
|
@@ -48,29 +47,28 @@ export var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
48
47
|
inputRef = props.inputRef,
|
|
49
48
|
readOnly = props.readOnly,
|
|
50
49
|
controlOnly = props.controlOnly,
|
|
51
|
-
|
|
50
|
+
_onKeyUp = props.onKeyUp,
|
|
52
51
|
rest = _objectWithoutProperties(props, _excluded);
|
|
53
52
|
|
|
54
53
|
// Attempt to determine additional invalid state. The native number input
|
|
55
54
|
// will set :invalid state automatically, but we need to also set
|
|
56
55
|
// `aria-invalid` as well as display an icon. We also want to *not* set this on
|
|
57
56
|
// EuiValidatableControl, in order to not override custom validity messages
|
|
58
|
-
var _useState = useState(
|
|
57
|
+
var _useState = useState(),
|
|
59
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
60
59
|
isNativelyInvalid = _useState2[0],
|
|
61
60
|
setIsNativelyInvalid = _useState2[1];
|
|
62
|
-
var validityRef = useRef(null);
|
|
63
|
-
var setRefs = useCombinedRefs([validityRef, inputRef]);
|
|
64
61
|
|
|
65
62
|
// Note that we can't use hook into `onChange` because browsers don't emit change events
|
|
66
63
|
// for invalid values - see https://github.com/facebook/react/issues/16554
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
var onKeyUp = useCallback(function (e) {
|
|
65
|
+
_onKeyUp === null || _onKeyUp === void 0 ? void 0 : _onKeyUp(e);
|
|
66
|
+
var _ref = e.target,
|
|
67
|
+
validity = _ref.validity;
|
|
68
|
+
// Prefer `undefined` over `false` so that the `aria-invalid` prop unsets completely
|
|
69
|
+
var isInvalid = !validity.valid || undefined;
|
|
70
|
+
setIsNativelyInvalid(isInvalid);
|
|
71
|
+
}, [_onKeyUp]);
|
|
74
72
|
var numIconsClass = controlOnly ? false : getFormControlClassNameForIconCount({
|
|
75
73
|
isInvalid: isInvalid || isNativelyInvalid,
|
|
76
74
|
isLoading: isLoading
|
|
@@ -94,9 +92,9 @@ export var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
94
92
|
placeholder: placeholder,
|
|
95
93
|
readOnly: readOnly,
|
|
96
94
|
className: classes,
|
|
97
|
-
ref:
|
|
98
|
-
|
|
99
|
-
"aria-invalid": isInvalid
|
|
95
|
+
ref: inputRef,
|
|
96
|
+
onKeyUp: onKeyUp,
|
|
97
|
+
"aria-invalid": isInvalid == null ? isNativelyInvalid : isInvalid
|
|
100
98
|
}, rest)));
|
|
101
99
|
if (controlOnly) {
|
|
102
100
|
return control;
|
package/eui.d.ts
CHANGED
|
@@ -4266,6 +4266,12 @@ declare module '@elastic/eui/src/components/focus_trap/focus_trap' {
|
|
|
4266
4266
|
*/
|
|
4267
4267
|
initialFocus?: FocusTarget;
|
|
4268
4268
|
style?: CSSProperties;
|
|
4269
|
+
/**
|
|
4270
|
+
* if `scrollLock` is set to true, the body's scrollbar width will be preserved on lock
|
|
4271
|
+
* via the `gapMode` CSS property. Depending on your custom CSS, you may prefer to use
|
|
4272
|
+
* `margin` instead of `padding`.
|
|
4273
|
+
*/
|
|
4274
|
+
gapMode?: 'padding' | 'margin';
|
|
4269
4275
|
disabled?: boolean;
|
|
4270
4276
|
}
|
|
4271
4277
|
export interface EuiFocusTrapProps extends CommonProps, Omit<ReactFocusOnProps, 'enabled'>, // Inverted `disabled` prop used instead
|
|
@@ -4281,6 +4287,7 @@ declare module '@elastic/eui/src/components/focus_trap/focus_trap' {
|
|
|
4281
4287
|
returnFocus: boolean;
|
|
4282
4288
|
noIsolation: boolean;
|
|
4283
4289
|
scrollLock: boolean;
|
|
4290
|
+
gapMode: string;
|
|
4284
4291
|
};
|
|
4285
4292
|
state: State;
|
|
4286
4293
|
lastInterceptedEvent: Event | null;
|
|
@@ -7,9 +7,10 @@ exports.EuiFocusTrap = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _reactFocusOn = require("react-focus-on");
|
|
10
|
+
var _reactRemoveScrollBar = require("react-remove-scroll-bar");
|
|
10
11
|
var _services = require("../../services");
|
|
11
12
|
var _react2 = require("@emotion/react");
|
|
12
|
-
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock"];
|
|
13
|
+
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock", "gapMode"];
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
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); }
|
|
15
16
|
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; }
|
|
@@ -117,17 +118,25 @@ var EuiFocusTrap = /*#__PURE__*/function (_Component) {
|
|
|
117
118
|
returnFocus = _this$props3.returnFocus,
|
|
118
119
|
noIsolation = _this$props3.noIsolation,
|
|
119
120
|
scrollLock = _this$props3.scrollLock,
|
|
121
|
+
gapMode = _this$props3.gapMode,
|
|
120
122
|
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
121
123
|
var isDisabled = disabled || this.state.hasBeenDisabledByClick;
|
|
122
124
|
var focusOnProps = _objectSpread(_objectSpread({
|
|
123
125
|
returnFocus: returnFocus,
|
|
124
126
|
noIsolation: noIsolation,
|
|
125
|
-
scrollLock: scrollLock,
|
|
126
127
|
enabled: !isDisabled
|
|
127
128
|
}, rest), {}, {
|
|
128
|
-
onClickOutside: this.handleOutsideClick
|
|
129
|
+
onClickOutside: this.handleOutsideClick,
|
|
130
|
+
/**
|
|
131
|
+
* `scrollLock` should always be unset on FocusOn, as it can prevent scrolling on
|
|
132
|
+
* portals (i.e. popovers, comboboxes, dropdown menus, etc.) within modals & flyouts
|
|
133
|
+
* @see https://github.com/theKashey/react-focus-on/issues/49
|
|
134
|
+
*/
|
|
135
|
+
scrollLock: false
|
|
129
136
|
});
|
|
130
|
-
return (0, _react2.jsx)(_reactFocusOn.FocusOn, focusOnProps, children)
|
|
137
|
+
return (0, _react2.jsx)(_reactFocusOn.FocusOn, focusOnProps, children, scrollLock && (0, _react2.jsx)(_reactRemoveScrollBar.RemoveScrollBar, {
|
|
138
|
+
gapMode: gapMode
|
|
139
|
+
}));
|
|
131
140
|
}
|
|
132
141
|
}]);
|
|
133
142
|
return EuiFocusTrap;
|
|
@@ -138,7 +147,8 @@ _defineProperty(EuiFocusTrap, "defaultProps", {
|
|
|
138
147
|
disabled: false,
|
|
139
148
|
returnFocus: true,
|
|
140
149
|
noIsolation: true,
|
|
141
|
-
scrollLock: false
|
|
150
|
+
scrollLock: false,
|
|
151
|
+
gapMode: 'padding' // EUI defaults to padding because Kibana's body/layout CSS ignores `margin`
|
|
142
152
|
});
|
|
143
153
|
EuiFocusTrap.propTypes = {
|
|
144
154
|
className: _propTypes.default.string,
|
|
@@ -159,5 +169,11 @@ EuiFocusTrap.propTypes = {
|
|
|
159
169
|
*/
|
|
160
170
|
initialFocus: _propTypes.default.any,
|
|
161
171
|
style: _propTypes.default.any,
|
|
172
|
+
/**
|
|
173
|
+
* if `scrollLock` is set to true, the body's scrollbar width will be preserved on lock
|
|
174
|
+
* via the `gapMode` CSS property. Depending on your custom CSS, you may prefer to use
|
|
175
|
+
* `margin` instead of `padding`.
|
|
176
|
+
*/
|
|
177
|
+
gapMode: _propTypes.default.oneOf(["padding", "margin"]),
|
|
162
178
|
disabled: _propTypes.default.bool
|
|
163
179
|
};
|
|
@@ -8,13 +8,12 @@ exports.EuiFieldNumber = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _services = require("../../../services");
|
|
12
11
|
var _validatable_control = require("../validatable_control");
|
|
13
12
|
var _form_control_layout = require("../form_control_layout");
|
|
14
13
|
var _num_icons = require("../form_control_layout/_num_icons");
|
|
15
14
|
var _eui_form_context = require("../eui_form_context");
|
|
16
15
|
var _react2 = require("@emotion/react");
|
|
17
|
-
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "
|
|
16
|
+
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "onKeyUp"];
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
18
|
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); }
|
|
20
19
|
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; }
|
|
@@ -50,29 +49,28 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
50
49
|
inputRef = props.inputRef,
|
|
51
50
|
readOnly = props.readOnly,
|
|
52
51
|
controlOnly = props.controlOnly,
|
|
53
|
-
|
|
52
|
+
_onKeyUp = props.onKeyUp,
|
|
54
53
|
rest = _objectWithoutProperties(props, _excluded);
|
|
55
54
|
|
|
56
55
|
// Attempt to determine additional invalid state. The native number input
|
|
57
56
|
// will set :invalid state automatically, but we need to also set
|
|
58
57
|
// `aria-invalid` as well as display an icon. We also want to *not* set this on
|
|
59
58
|
// EuiValidatableControl, in order to not override custom validity messages
|
|
60
|
-
var _useState = (0, _react.useState)(
|
|
59
|
+
var _useState = (0, _react.useState)(),
|
|
61
60
|
_useState2 = _slicedToArray(_useState, 2),
|
|
62
61
|
isNativelyInvalid = _useState2[0],
|
|
63
62
|
setIsNativelyInvalid = _useState2[1];
|
|
64
|
-
var validityRef = (0, _react.useRef)(null);
|
|
65
|
-
var setRefs = (0, _services.useCombinedRefs)([validityRef, inputRef]);
|
|
66
63
|
|
|
67
64
|
// Note that we can't use hook into `onChange` because browsers don't emit change events
|
|
68
65
|
// for invalid values - see https://github.com/facebook/react/issues/16554
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
var onKeyUp = (0, _react.useCallback)(function (e) {
|
|
67
|
+
_onKeyUp === null || _onKeyUp === void 0 ? void 0 : _onKeyUp(e);
|
|
68
|
+
var _ref = e.target,
|
|
69
|
+
validity = _ref.validity;
|
|
70
|
+
// Prefer `undefined` over `false` so that the `aria-invalid` prop unsets completely
|
|
71
|
+
var isInvalid = !validity.valid || undefined;
|
|
72
|
+
setIsNativelyInvalid(isInvalid);
|
|
73
|
+
}, [_onKeyUp]);
|
|
76
74
|
var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
|
|
77
75
|
isInvalid: isInvalid || isNativelyInvalid,
|
|
78
76
|
isLoading: isLoading
|
|
@@ -96,9 +94,9 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
96
94
|
placeholder: placeholder,
|
|
97
95
|
readOnly: readOnly,
|
|
98
96
|
className: classes,
|
|
99
|
-
ref:
|
|
100
|
-
|
|
101
|
-
"aria-invalid": isInvalid
|
|
97
|
+
ref: inputRef,
|
|
98
|
+
onKeyUp: onKeyUp,
|
|
99
|
+
"aria-invalid": isInvalid == null ? isNativelyInvalid : isInvalid
|
|
102
100
|
}, rest)));
|
|
103
101
|
if (controlOnly) {
|
|
104
102
|
return control;
|
|
@@ -6,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock"];
|
|
9
|
+
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock", "gapMode"];
|
|
10
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -21,6 +21,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
21
21
|
|
|
22
22
|
import React, { Component } from 'react';
|
|
23
23
|
import { FocusOn } from 'react-focus-on';
|
|
24
|
+
import { RemoveScrollBar } from 'react-remove-scroll-bar';
|
|
24
25
|
import { findElementBySelectorOrRef } from '../../services';
|
|
25
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
26
27
|
export var EuiFocusTrap = /*#__PURE__*/function (_Component) {
|
|
@@ -109,17 +110,25 @@ export var EuiFocusTrap = /*#__PURE__*/function (_Component) {
|
|
|
109
110
|
returnFocus = _this$props3.returnFocus,
|
|
110
111
|
noIsolation = _this$props3.noIsolation,
|
|
111
112
|
scrollLock = _this$props3.scrollLock,
|
|
113
|
+
gapMode = _this$props3.gapMode,
|
|
112
114
|
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
113
115
|
var isDisabled = disabled || this.state.hasBeenDisabledByClick;
|
|
114
116
|
var focusOnProps = _objectSpread(_objectSpread({
|
|
115
117
|
returnFocus: returnFocus,
|
|
116
118
|
noIsolation: noIsolation,
|
|
117
|
-
scrollLock: scrollLock,
|
|
118
119
|
enabled: !isDisabled
|
|
119
120
|
}, rest), {}, {
|
|
120
|
-
onClickOutside: this.handleOutsideClick
|
|
121
|
+
onClickOutside: this.handleOutsideClick,
|
|
122
|
+
/**
|
|
123
|
+
* `scrollLock` should always be unset on FocusOn, as it can prevent scrolling on
|
|
124
|
+
* portals (i.e. popovers, comboboxes, dropdown menus, etc.) within modals & flyouts
|
|
125
|
+
* @see https://github.com/theKashey/react-focus-on/issues/49
|
|
126
|
+
*/
|
|
127
|
+
scrollLock: false
|
|
121
128
|
});
|
|
122
|
-
return ___EmotionJSX(FocusOn, focusOnProps, children
|
|
129
|
+
return ___EmotionJSX(FocusOn, focusOnProps, children, scrollLock && ___EmotionJSX(RemoveScrollBar, {
|
|
130
|
+
gapMode: gapMode
|
|
131
|
+
}));
|
|
123
132
|
}
|
|
124
133
|
}]);
|
|
125
134
|
return EuiFocusTrap;
|
|
@@ -129,5 +138,6 @@ _defineProperty(EuiFocusTrap, "defaultProps", {
|
|
|
129
138
|
disabled: false,
|
|
130
139
|
returnFocus: true,
|
|
131
140
|
noIsolation: true,
|
|
132
|
-
scrollLock: false
|
|
141
|
+
scrollLock: false,
|
|
142
|
+
gapMode: 'padding' // EUI defaults to padding because Kibana's body/layout CSS ignores `margin`
|
|
133
143
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "
|
|
4
|
+
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "onKeyUp"];
|
|
5
5
|
/*
|
|
6
6
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
7
7
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -10,9 +10,8 @@ var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max",
|
|
|
10
10
|
* Side Public License, v 1.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import React, { useState,
|
|
13
|
+
import React, { useState, useCallback } from 'react';
|
|
14
14
|
import classNames from 'classnames';
|
|
15
|
-
import { useCombinedRefs } from '../../../services';
|
|
16
15
|
import { EuiValidatableControl } from '../validatable_control';
|
|
17
16
|
import { EuiFormControlLayout } from '../form_control_layout';
|
|
18
17
|
import { getFormControlClassNameForIconCount } from '../form_control_layout/_num_icons';
|
|
@@ -41,29 +40,28 @@ export var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
41
40
|
inputRef = props.inputRef,
|
|
42
41
|
readOnly = props.readOnly,
|
|
43
42
|
controlOnly = props.controlOnly,
|
|
44
|
-
|
|
43
|
+
_onKeyUp = props.onKeyUp,
|
|
45
44
|
rest = _objectWithoutProperties(props, _excluded);
|
|
46
45
|
|
|
47
46
|
// Attempt to determine additional invalid state. The native number input
|
|
48
47
|
// will set :invalid state automatically, but we need to also set
|
|
49
48
|
// `aria-invalid` as well as display an icon. We also want to *not* set this on
|
|
50
49
|
// EuiValidatableControl, in order to not override custom validity messages
|
|
51
|
-
var _useState = useState(
|
|
50
|
+
var _useState = useState(),
|
|
52
51
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
52
|
isNativelyInvalid = _useState2[0],
|
|
54
53
|
setIsNativelyInvalid = _useState2[1];
|
|
55
|
-
var validityRef = useRef(null);
|
|
56
|
-
var setRefs = useCombinedRefs([validityRef, inputRef]);
|
|
57
54
|
|
|
58
55
|
// Note that we can't use hook into `onChange` because browsers don't emit change events
|
|
59
56
|
// for invalid values - see https://github.com/facebook/react/issues/16554
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
var onKeyUp = useCallback(function (e) {
|
|
58
|
+
_onKeyUp === null || _onKeyUp === void 0 ? void 0 : _onKeyUp(e);
|
|
59
|
+
var _ref = e.target,
|
|
60
|
+
validity = _ref.validity;
|
|
61
|
+
// Prefer `undefined` over `false` so that the `aria-invalid` prop unsets completely
|
|
62
|
+
var isInvalid = !validity.valid || undefined;
|
|
63
|
+
setIsNativelyInvalid(isInvalid);
|
|
64
|
+
}, [_onKeyUp]);
|
|
67
65
|
var numIconsClass = controlOnly ? false : getFormControlClassNameForIconCount({
|
|
68
66
|
isInvalid: isInvalid || isNativelyInvalid,
|
|
69
67
|
isLoading: isLoading
|
|
@@ -87,9 +85,9 @@ export var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
87
85
|
placeholder: placeholder,
|
|
88
86
|
readOnly: readOnly,
|
|
89
87
|
className: classes,
|
|
90
|
-
ref:
|
|
91
|
-
|
|
92
|
-
"aria-invalid": isInvalid
|
|
88
|
+
ref: inputRef,
|
|
89
|
+
onKeyUp: onKeyUp,
|
|
90
|
+
"aria-invalid": isInvalid == null ? isNativelyInvalid : isInvalid
|
|
93
91
|
}, rest)));
|
|
94
92
|
if (controlOnly) {
|
|
95
93
|
return control;
|
|
@@ -16,9 +16,10 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
17
|
var _react = _interopRequireWildcard(require("react"));
|
|
18
18
|
var _reactFocusOn = require("react-focus-on");
|
|
19
|
+
var _reactRemoveScrollBar = require("react-remove-scroll-bar");
|
|
19
20
|
var _services = require("../../services");
|
|
20
21
|
var _react2 = require("@emotion/react");
|
|
21
|
-
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock"];
|
|
22
|
+
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock", "gapMode"];
|
|
22
23
|
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); }
|
|
23
24
|
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; }
|
|
24
25
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -111,17 +112,25 @@ var EuiFocusTrap = /*#__PURE__*/function (_Component) {
|
|
|
111
112
|
returnFocus = _this$props3.returnFocus,
|
|
112
113
|
noIsolation = _this$props3.noIsolation,
|
|
113
114
|
scrollLock = _this$props3.scrollLock,
|
|
115
|
+
gapMode = _this$props3.gapMode,
|
|
114
116
|
rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
115
117
|
var isDisabled = disabled || this.state.hasBeenDisabledByClick;
|
|
116
118
|
var focusOnProps = _objectSpread(_objectSpread({
|
|
117
119
|
returnFocus: returnFocus,
|
|
118
120
|
noIsolation: noIsolation,
|
|
119
|
-
scrollLock: scrollLock,
|
|
120
121
|
enabled: !isDisabled
|
|
121
122
|
}, rest), {}, {
|
|
122
|
-
onClickOutside: this.handleOutsideClick
|
|
123
|
+
onClickOutside: this.handleOutsideClick,
|
|
124
|
+
/**
|
|
125
|
+
* `scrollLock` should always be unset on FocusOn, as it can prevent scrolling on
|
|
126
|
+
* portals (i.e. popovers, comboboxes, dropdown menus, etc.) within modals & flyouts
|
|
127
|
+
* @see https://github.com/theKashey/react-focus-on/issues/49
|
|
128
|
+
*/
|
|
129
|
+
scrollLock: false
|
|
123
130
|
});
|
|
124
|
-
return (0, _react2.jsx)(_reactFocusOn.FocusOn, focusOnProps, children)
|
|
131
|
+
return (0, _react2.jsx)(_reactFocusOn.FocusOn, focusOnProps, children, scrollLock && (0, _react2.jsx)(_reactRemoveScrollBar.RemoveScrollBar, {
|
|
132
|
+
gapMode: gapMode
|
|
133
|
+
}));
|
|
125
134
|
}
|
|
126
135
|
}]);
|
|
127
136
|
return EuiFocusTrap;
|
|
@@ -132,5 +141,6 @@ exports.EuiFocusTrap = EuiFocusTrap;
|
|
|
132
141
|
disabled: false,
|
|
133
142
|
returnFocus: true,
|
|
134
143
|
noIsolation: true,
|
|
135
|
-
scrollLock: false
|
|
144
|
+
scrollLock: false,
|
|
145
|
+
gapMode: 'padding' // EUI defaults to padding because Kibana's body/layout CSS ignores `margin`
|
|
136
146
|
});
|
|
@@ -11,13 +11,12 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _services = require("../../../services");
|
|
15
14
|
var _validatable_control = require("../validatable_control");
|
|
16
15
|
var _form_control_layout = require("../form_control_layout");
|
|
17
16
|
var _num_icons = require("../form_control_layout/_num_icons");
|
|
18
17
|
var _eui_form_context = require("../eui_form_context");
|
|
19
18
|
var _react2 = require("@emotion/react");
|
|
20
|
-
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "
|
|
19
|
+
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "onKeyUp"];
|
|
21
20
|
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); }
|
|
22
21
|
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; }
|
|
23
22
|
var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
@@ -43,29 +42,28 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
43
42
|
inputRef = props.inputRef,
|
|
44
43
|
readOnly = props.readOnly,
|
|
45
44
|
controlOnly = props.controlOnly,
|
|
46
|
-
|
|
45
|
+
_onKeyUp = props.onKeyUp,
|
|
47
46
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
48
47
|
|
|
49
48
|
// Attempt to determine additional invalid state. The native number input
|
|
50
49
|
// will set :invalid state automatically, but we need to also set
|
|
51
50
|
// `aria-invalid` as well as display an icon. We also want to *not* set this on
|
|
52
51
|
// EuiValidatableControl, in order to not override custom validity messages
|
|
53
|
-
var _useState = (0, _react.useState)(
|
|
52
|
+
var _useState = (0, _react.useState)(),
|
|
54
53
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
55
54
|
isNativelyInvalid = _useState2[0],
|
|
56
55
|
setIsNativelyInvalid = _useState2[1];
|
|
57
|
-
var validityRef = (0, _react.useRef)(null);
|
|
58
|
-
var setRefs = (0, _services.useCombinedRefs)([validityRef, inputRef]);
|
|
59
56
|
|
|
60
57
|
// Note that we can't use hook into `onChange` because browsers don't emit change events
|
|
61
58
|
// for invalid values - see https://github.com/facebook/react/issues/16554
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
var onKeyUp = (0, _react.useCallback)(function (e) {
|
|
60
|
+
_onKeyUp === null || _onKeyUp === void 0 ? void 0 : _onKeyUp(e);
|
|
61
|
+
var _ref = e.target,
|
|
62
|
+
validity = _ref.validity;
|
|
63
|
+
// Prefer `undefined` over `false` so that the `aria-invalid` prop unsets completely
|
|
64
|
+
var isInvalid = !validity.valid || undefined;
|
|
65
|
+
setIsNativelyInvalid(isInvalid);
|
|
66
|
+
}, [_onKeyUp]);
|
|
69
67
|
var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
|
|
70
68
|
isInvalid: isInvalid || isNativelyInvalid,
|
|
71
69
|
isLoading: isLoading
|
|
@@ -89,9 +87,9 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
89
87
|
placeholder: placeholder,
|
|
90
88
|
readOnly: readOnly,
|
|
91
89
|
className: classes,
|
|
92
|
-
ref:
|
|
93
|
-
|
|
94
|
-
"aria-invalid": isInvalid
|
|
90
|
+
ref: inputRef,
|
|
91
|
+
onKeyUp: onKeyUp,
|
|
92
|
+
"aria-invalid": isInvalid == null ? isNativelyInvalid : isInvalid
|
|
95
93
|
}, rest)));
|
|
96
94
|
if (controlOnly) {
|
|
97
95
|
return control;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/eui",
|
|
3
3
|
"description": "Elastic UI Component Library",
|
|
4
|
-
"version": "77.2.
|
|
4
|
+
"version": "77.2.2",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "lib",
|
|
7
7
|
"module": "es",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"react-focus-on": "^3.7.0",
|
|
81
81
|
"react-input-autosize": "^3.0.0",
|
|
82
82
|
"react-is": "^17.0.2",
|
|
83
|
+
"react-remove-scroll-bar": "^2.3.4",
|
|
83
84
|
"react-virtualized-auto-sizer": "^1.0.6",
|
|
84
85
|
"react-window": "^1.8.6",
|
|
85
86
|
"refractor": "^3.5.0",
|
|
@@ -12,13 +12,12 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
var _services = require("../../../services");
|
|
16
15
|
var _validatable_control = require("../validatable_control");
|
|
17
16
|
var _form_control_layout = require("../form_control_layout");
|
|
18
17
|
var _num_icons = require("../form_control_layout/_num_icons");
|
|
19
18
|
var _eui_form_context = require("../eui_form_context");
|
|
20
19
|
var _react2 = require("@emotion/react");
|
|
21
|
-
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "
|
|
20
|
+
var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "onKeyUp"];
|
|
22
21
|
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); }
|
|
23
22
|
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; }
|
|
24
23
|
var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
@@ -44,29 +43,28 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
44
43
|
inputRef = props.inputRef,
|
|
45
44
|
readOnly = props.readOnly,
|
|
46
45
|
controlOnly = props.controlOnly,
|
|
47
|
-
|
|
46
|
+
_onKeyUp = props.onKeyUp,
|
|
48
47
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
49
48
|
|
|
50
49
|
// Attempt to determine additional invalid state. The native number input
|
|
51
50
|
// will set :invalid state automatically, but we need to also set
|
|
52
51
|
// `aria-invalid` as well as display an icon. We also want to *not* set this on
|
|
53
52
|
// EuiValidatableControl, in order to not override custom validity messages
|
|
54
|
-
var _useState = (0, _react.useState)(
|
|
53
|
+
var _useState = (0, _react.useState)(),
|
|
55
54
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
56
55
|
isNativelyInvalid = _useState2[0],
|
|
57
56
|
setIsNativelyInvalid = _useState2[1];
|
|
58
|
-
var validityRef = (0, _react.useRef)(null);
|
|
59
|
-
var setRefs = (0, _services.useCombinedRefs)([validityRef, inputRef]);
|
|
60
57
|
|
|
61
58
|
// Note that we can't use hook into `onChange` because browsers don't emit change events
|
|
62
59
|
// for invalid values - see https://github.com/facebook/react/issues/16554
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
var onKeyUp = (0, _react.useCallback)(function (e) {
|
|
61
|
+
_onKeyUp === null || _onKeyUp === void 0 ? void 0 : _onKeyUp(e);
|
|
62
|
+
var _ref = e.target,
|
|
63
|
+
validity = _ref.validity;
|
|
64
|
+
// Prefer `undefined` over `false` so that the `aria-invalid` prop unsets completely
|
|
65
|
+
var isInvalid = !validity.valid || undefined;
|
|
66
|
+
setIsNativelyInvalid(isInvalid);
|
|
67
|
+
}, [_onKeyUp]);
|
|
70
68
|
var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
|
|
71
69
|
isInvalid: isInvalid || isNativelyInvalid,
|
|
72
70
|
isLoading: isLoading
|
|
@@ -90,9 +88,9 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
|
|
|
90
88
|
placeholder: placeholder,
|
|
91
89
|
readOnly: readOnly,
|
|
92
90
|
className: classes,
|
|
93
|
-
ref:
|
|
94
|
-
|
|
95
|
-
"aria-invalid": isInvalid
|
|
91
|
+
ref: inputRef,
|
|
92
|
+
onKeyUp: onKeyUp,
|
|
93
|
+
"aria-invalid": isInvalid == null ? isNativelyInvalid : isInvalid
|
|
96
94
|
}, rest)));
|
|
97
95
|
if (controlOnly) {
|
|
98
96
|
return control;
|