@jetbrains/ring-ui-built 6.0.37 → 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.
Files changed (34) hide show
  1. package/components/_helpers/dialog__body-scroll-preventer.js +1 -1
  2. package/components/_helpers/input.js +3 -2
  3. package/components/checkbox/checkbox.js +1 -0
  4. package/components/confirm/confirm.d.ts +1 -0
  5. package/components/confirm/confirm.js +3 -1
  6. package/components/data-list/data-list.js +1 -0
  7. package/components/data-list/item.js +1 -0
  8. package/components/data-list/title.js +1 -0
  9. package/components/date-picker/date-input.d.ts +1 -0
  10. package/components/date-picker/date-input.js +6 -1
  11. package/components/date-picker/date-picker.js +2 -0
  12. package/components/date-picker/date-popup.js +1 -0
  13. package/components/dialog/dialog.d.ts +5 -1
  14. package/components/dialog/dialog.js +103 -55
  15. package/components/editable-heading/editable-heading.js +1 -0
  16. package/components/global/composeRefs.d.ts +2 -2
  17. package/components/global/composeRefs.js +7 -3
  18. package/components/global/focus-sensor-hoc.js +1 -0
  19. package/components/global/rerender-hoc.js +1 -0
  20. package/components/input/input.d.ts +1 -0
  21. package/components/input/input.js +1 -0
  22. package/components/island/content.js +3 -5
  23. package/components/list/list__item.js +1 -0
  24. package/components/old-browsers-message/white-list.js +2 -2
  25. package/components/select/select__filter.js +1 -1
  26. package/components/style.css +1 -1
  27. package/components/tab-trap/tab-trap.d.ts +2 -1
  28. package/components/tab-trap/tab-trap.js +18 -11
  29. package/components/table/header.js +1 -0
  30. package/components/table/row-with-focus-sensor.js +1 -0
  31. package/components/table/row.js +1 -0
  32. package/components/table/smart-table.js +1 -0
  33. package/components/table/table.js +1 -0
  34. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { Component, ReactNode, HTMLAttributes } from 'react';
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
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
- args[_key] = arguments[_key];
31
- }
32
- _this = _callSuper(this, TabTrap, [].concat(args));
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 && (!this.node || !this.node.contains(this.previousFocusedNode))) {
117
- var _this$trapButtonNode;
118
- this.trapWithoutFocus = true;
119
- (_this$trapButtonNode = this.trapButtonNode) === null || _this$trapButtonNode === void 0 || _this$trapButtonNode.focus();
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
  }, {
@@ -27,6 +27,7 @@ import 'core-js/modules/web.dom-collections.iterator.js';
27
27
  import '../global/prop-types.js';
28
28
  import '../global/composeRefs.js';
29
29
  import 'core-js/modules/web.dom-collections.for-each.js';
30
+ import 'memoize-one';
30
31
  import '../control-help/control-help.js';
31
32
  import 'core-js/modules/es.regexp.to-string.js';
32
33
  import '@jetbrains/icons/unsorted-10px';
@@ -9,6 +9,7 @@ import '../global/prop-types.js';
9
9
  import '../global/composeRefs.js';
10
10
  import 'core-js/modules/es.object.to-string.js';
11
11
  import 'core-js/modules/web.dom-collections.for-each.js';
12
+ import 'memoize-one';
12
13
  import 'core-js/modules/es.array.map.js';
13
14
  import 'classnames';
14
15
  import '@jetbrains/icons/chevron-right';
@@ -65,6 +65,7 @@ import 'core-js/modules/es.array.sort.js';
65
65
  import '../popup/popup.consts.js';
66
66
  import '../popup/popup.target.js';
67
67
  import 'core-js/modules/es.array.reduce.js';
68
+ import 'memoize-one';
68
69
 
69
70
  var _excluded = ["item", "columns", "selectable", "selected", "showFocus", "draggable", "alwaysShowDragHandle", "dragHandleTitle", "level", "collapsible", "parentCollapsible", "collapsed", "maxColSpan", "onCollapse", "onExpand", "showDisabledSelection", "onSelect", "checkboxTooltip", "innerRef", "focused", "autofocus", "onFocusReset", "onFocusRestore", "onHover", "className", "metaColumnClassName", "data-test"];
70
71
  var DragHandle = function DragHandle(_ref) {
@@ -13,6 +13,7 @@ import '../global/prop-types.js';
13
13
  import '../global/composeRefs.js';
14
14
  import 'core-js/modules/es.object.to-string.js';
15
15
  import 'core-js/modules/web.dom-collections.for-each.js';
16
+ import 'memoize-one';
16
17
  import '../global/get-uid.js';
17
18
  import 'core-js/modules/es.regexp.to-string.js';
18
19
  import '../shortcuts/shortcuts.js';
@@ -20,6 +20,7 @@ import '../global/prop-types.js';
20
20
  import '../global/composeRefs.js';
21
21
  import 'core-js/modules/es.object.to-string.js';
22
22
  import 'core-js/modules/web.dom-collections.for-each.js';
23
+ import 'memoize-one';
23
24
  import 'core-js/modules/es.regexp.to-string.js';
24
25
  import '../shortcuts/core.js';
25
26
  import 'core-js/modules/es.array.find-index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui-built",
3
- "version": "6.0.37",
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 '**/*' '!**/*.ts' '!**/*.tsx' '!**/__mocks__/**' ../components --parents --cwd=src/",
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 '**/*.d.ts' ../dist --parents --cwd=components/",
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",