@jetbrains/ring-ui-built 6.0.38 → 6.0.39
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.
@@ -35,6 +35,7 @@ export default class DateInput extends React.PureComponent<DateInputProps> {
|
|
35
35
|
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
36
36
|
locale: PropTypes.Requireable<object>;
|
37
37
|
};
|
38
|
+
componentDidMount(): void;
|
38
39
|
componentDidUpdate(prevProps: DateInputProps): void;
|
39
40
|
static contextType: React.Context<import("../i18n/i18n-context").I18nContextProps>;
|
40
41
|
context: React.ContextType<typeof DateInput.contextType>;
|
@@ -54,7 +54,6 @@ var DateInput = /*#__PURE__*/function (_React$PureComponent) {
|
|
54
54
|
_defineProperty(_this, "input", void 0);
|
55
55
|
_defineProperty(_this, "inputRef", function (el) {
|
56
56
|
_this.input = el;
|
57
|
-
_this.updateInput(_this.props);
|
58
57
|
});
|
59
58
|
_defineProperty(_this, "handleChange", function (e) {
|
60
59
|
return _this.props.onInput(e.currentTarget.value, e.currentTarget.dataset.name);
|
@@ -66,6 +65,11 @@ var DateInput = /*#__PURE__*/function (_React$PureComponent) {
|
|
66
65
|
}
|
67
66
|
_inherits(DateInput, _React$PureComponent);
|
68
67
|
return _createClass(DateInput, [{
|
68
|
+
key: "componentDidMount",
|
69
|
+
value: function componentDidMount() {
|
70
|
+
this.updateInput(this.props);
|
71
|
+
}
|
72
|
+
}, {
|
69
73
|
key: "componentDidUpdate",
|
70
74
|
value: function componentDidUpdate(prevProps) {
|
71
75
|
var _this$props = this.props,
|
@@ -132,6 +132,7 @@ var PopupComponent = function PopupComponent(_ref) {
|
|
132
132
|
ref: popupRef,
|
133
133
|
directions: [Popup.PopupProps.Directions.BOTTOM_RIGHT, Popup.PopupProps.Directions.BOTTOM_LEFT, Popup.PopupProps.Directions.TOP_LEFT, Popup.PopupProps.Directions.TOP_RIGHT]
|
134
134
|
}, restProps), {}, {
|
135
|
+
trapFocus: true,
|
135
136
|
children: /*#__PURE__*/jsx(DatePopup, _objectSpread2(_objectSpread2({
|
136
137
|
onClear: onClear
|
137
138
|
}, datePopupProps), {}, {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Component,
|
1
|
+
import { Component, HTMLAttributes, ReactNode } from 'react';
|
2
2
|
import * as React from 'react';
|
3
3
|
import PropTypes from 'prop-types';
|
4
4
|
export declare const FOCUSABLE_ELEMENTS = "input, button, select, textarea, a[href], *[tabindex]:not([data-trap-button]):not([data-scrollable-container])";
|
@@ -26,6 +26,7 @@ export default class TabTrap extends Component<TabTrapProps> {
|
|
26
26
|
focusBackOnClose: boolean;
|
27
27
|
focusBackOnExit: boolean;
|
28
28
|
};
|
29
|
+
constructor(props: TabTrapProps);
|
29
30
|
componentDidMount(): void;
|
30
31
|
componentWillUnmount(): void;
|
31
32
|
previousFocusedNode?: Element | null;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { _ as _defineProperty, a as _inherits, b as _createClass, c as _objectWithoutProperties, d as _objectSpread2, e as _classCallCheck, f as _callSuper, j as _toConsumableArray } from '../_helpers/_rollupPluginBabelHelpers.js';
|
2
|
-
import 'core-js/modules/es.array.concat.js';
|
3
2
|
import 'core-js/modules/es.array.filter.js';
|
4
3
|
import 'core-js/modules/es.object.to-string.js';
|
5
4
|
import { Component } from 'react';
|
@@ -23,13 +22,14 @@ var FOCUSABLE_ELEMENTS = 'input, button, select, textarea, a[href], *[tabindex]:
|
|
23
22
|
* @name TabTrap
|
24
23
|
*/
|
25
24
|
var TabTrap = /*#__PURE__*/function (_Component) {
|
26
|
-
function TabTrap() {
|
25
|
+
function TabTrap(props) {
|
27
26
|
var _this;
|
28
27
|
_classCallCheck(this, TabTrap);
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
_this = _callSuper(this, TabTrap, [props]);
|
29
|
+
// It's the same approach as in focus-trap-react:
|
30
|
+
// https://github.com/focus-trap/focus-trap-react/commit/3b22fca9eebeb883edc89548850fe5a5b9d6d50e
|
31
|
+
// We can't do it in componentDidMount because it's too late, some children might have already
|
32
|
+
// focused itself.
|
33
33
|
_defineProperty(_this, "previousFocusedNode", void 0);
|
34
34
|
_defineProperty(_this, "trapWithoutFocus", void 0);
|
35
35
|
_defineProperty(_this, "restoreFocus", function () {
|
@@ -104,19 +104,26 @@ var TabTrap = /*#__PURE__*/function (_Component) {
|
|
104
104
|
}
|
105
105
|
_this.trapButtonNode = node;
|
106
106
|
});
|
107
|
+
_this.previousFocusedNode = document.activeElement;
|
107
108
|
return _this;
|
108
109
|
}
|
109
110
|
_inherits(TabTrap, _Component);
|
110
111
|
return _createClass(TabTrap, [{
|
111
112
|
key: "componentDidMount",
|
112
113
|
value: function componentDidMount() {
|
113
|
-
this.previousFocusedNode = document.activeElement;
|
114
114
|
if (this.props.autoFocusFirst) {
|
115
115
|
this.focusFirst();
|
116
|
-
} else if (!this.props.trapDisabled
|
117
|
-
var _this$
|
118
|
-
this.
|
119
|
-
|
116
|
+
} else if (!this.props.trapDisabled) {
|
117
|
+
var _this$node2, _this$node3;
|
118
|
+
var previousFocusedElementIsInContainer = this.previousFocusedNode && ((_this$node2 = this.node) === null || _this$node2 === void 0 ? void 0 : _this$node2.contains(this.previousFocusedNode));
|
119
|
+
// The component wrapped in TabTrap can already have a focused element (e.g. Date Picker),
|
120
|
+
// so we need to check if it does. If so, we don't need to focus anything.
|
121
|
+
var currentlyFocusedElementIsInContainer = (_this$node3 = this.node) === null || _this$node3 === void 0 ? void 0 : _this$node3.contains(document.activeElement);
|
122
|
+
if (!this.node || !previousFocusedElementIsInContainer && !currentlyFocusedElementIsInContainer) {
|
123
|
+
var _this$trapButtonNode;
|
124
|
+
this.trapWithoutFocus = true;
|
125
|
+
(_this$trapButtonNode = this.trapButtonNode) === null || _this$trapButtonNode === void 0 || _this$trapButtonNode.focus();
|
126
|
+
}
|
120
127
|
}
|
121
128
|
}
|
122
129
|
}, {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jetbrains/ring-ui-built",
|
3
|
-
"version": "6.0.
|
3
|
+
"version": "6.0.39",
|
4
4
|
"description": "JetBrains UI library",
|
5
5
|
"author": "JetBrains",
|
6
6
|
"license": "Apache-2.0",
|
@@ -41,9 +41,9 @@
|
|
41
41
|
"screenshots-test-ci": "npm --prefix packages/screenshots run test-ci",
|
42
42
|
"screenshots-gather": "npm --prefix packages/screenshots run gather",
|
43
43
|
"build-stories": "storybook build --quiet -c .storybook -o storybook-dist",
|
44
|
-
"prebuild": "rimraf components && tsc --project tsconfig-build.json && cpy '
|
44
|
+
"prebuild": "rimraf components && tsc --project tsconfig-build.json && cpy './**/*' '!**/*.ts' '!**/*.tsx' '!**/__mocks__/**' ../components --parents --cwd=src/",
|
45
45
|
"build": "./node_modules/.bin/rollup -c --bundleConfigAsCjs",
|
46
|
-
"postbuild": "cpy '
|
46
|
+
"postbuild": "cpy './**/*.d.ts' ../dist --parents --cwd=components/",
|
47
47
|
"serve": "http-server storybook-dist/ -p 9999",
|
48
48
|
"start": "storybook dev -p 9999",
|
49
49
|
"storybook-debug": "node --inspect-brk node_modules/@storybook/react/bin -p 9999",
|