@jetbrains/ring-ui 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>;
@@ -26,6 +26,9 @@ export default class DateInput extends React.PureComponent {
26
26
  onClear: PropTypes.func,
27
27
  locale: PropTypes.object
28
28
  };
29
+ componentDidMount() {
30
+ this.updateInput(this.props);
31
+ }
29
32
  componentDidUpdate(prevProps) {
30
33
  const { text, active } = this.props;
31
34
  if (text !== prevProps.text || active !== prevProps.active) {
@@ -36,7 +39,6 @@ export default class DateInput extends React.PureComponent {
36
39
  input;
37
40
  inputRef = (el) => {
38
41
  this.input = el;
39
- this.updateInput(this.props);
40
42
  };
41
43
  updateInput({ text, active }) {
42
44
  const el = this.input;
@@ -28,7 +28,7 @@ const PopupComponent = ({ hidden = false, className, popupRef, onClear, datePopu
28
28
  Popup.PopupProps.Directions.BOTTOM_LEFT,
29
29
  Popup.PopupProps.Directions.TOP_LEFT,
30
30
  Popup.PopupProps.Directions.TOP_RIGHT
31
- ]} {...restProps}>
31
+ ]} {...restProps} trapFocus>
32
32
  <DatePopup onClear={onClear} {...datePopupProps} onComplete={onComplete}/>
33
33
  </Popup>);
34
34
  PopupComponent.propTypes = {
@@ -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;
@@ -21,15 +21,29 @@ export default class TabTrap extends Component {
21
21
  focusBackOnClose: true,
22
22
  focusBackOnExit: false
23
23
  };
24
- componentDidMount() {
24
+ constructor(props) {
25
+ super(props);
26
+ // It's the same approach as in focus-trap-react:
27
+ // https://github.com/focus-trap/focus-trap-react/commit/3b22fca9eebeb883edc89548850fe5a5b9d6d50e
28
+ // We can't do it in componentDidMount because it's too late, some children might have already
29
+ // focused itself.
25
30
  this.previousFocusedNode = document.activeElement;
31
+ }
32
+ componentDidMount() {
26
33
  if (this.props.autoFocusFirst) {
27
34
  this.focusFirst();
28
35
  }
29
- else if (!this.props.trapDisabled &&
30
- (!this.node || !this.node.contains(this.previousFocusedNode))) {
31
- this.trapWithoutFocus = true;
32
- this.trapButtonNode?.focus();
36
+ else if (!this.props.trapDisabled) {
37
+ const previousFocusedElementIsInContainer = this.previousFocusedNode &&
38
+ this.node?.contains(this.previousFocusedNode);
39
+ // The component wrapped in TabTrap can already have a focused element (e.g. Date Picker),
40
+ // so we need to check if it does. If so, we don't need to focus anything.
41
+ const currentlyFocusedElementIsInContainer = this.node?.contains(document.activeElement);
42
+ if (!this.node ||
43
+ (!previousFocusedElementIsInContainer && !currentlyFocusedElementIsInContainer)) {
44
+ this.trapWithoutFocus = true;
45
+ this.trapButtonNode?.focus();
46
+ }
33
47
  }
34
48
  }
35
49
  componentWillUnmount() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "6.0.38",
3
+ "version": "6.0.39",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -45,9 +45,9 @@
45
45
  "screenshots-test-ci": "npm --prefix packages/screenshots run test-ci",
46
46
  "screenshots-gather": "npm --prefix packages/screenshots run gather",
47
47
  "build-stories": "storybook build --quiet -c .storybook -o storybook-dist",
48
- "prebuild": "rimraf components && tsc --project tsconfig-build.json && cpy '**/*' '!**/*.ts' '!**/*.tsx' '!**/__mocks__/**' ../components --parents --cwd=src/",
48
+ "prebuild": "rimraf components && tsc --project tsconfig-build.json && cpy './**/*' '!**/*.ts' '!**/*.tsx' '!**/__mocks__/**' ../components --parents --cwd=src/",
49
49
  "build": "./node_modules/.bin/rollup -c --bundleConfigAsCjs",
50
- "postbuild": "cpy '**/*.d.ts' ../dist --parents --cwd=components/",
50
+ "postbuild": "cpy './**/*.d.ts' ../dist --parents --cwd=components/",
51
51
  "serve": "http-server storybook-dist/ -p 9999",
52
52
  "start": "storybook dev -p 9999",
53
53
  "storybook-debug": "node --inspect-brk node_modules/@storybook/react/bin -p 9999",
@@ -78,7 +78,7 @@
78
78
  "devDependencies": {
79
79
  "@babel/cli": "^7.24.7",
80
80
  "@babel/eslint-parser": "^7.24.7",
81
- "@csstools/css-parser-algorithms": "^2.6.1",
81
+ "@csstools/css-parser-algorithms": "^2.7.0",
82
82
  "@csstools/stylelint-no-at-nest-rule": "^2.0.0",
83
83
  "@jetbrains/eslint-config": "^5.4.2",
84
84
  "@jetbrains/logos": "3.0.0-canary.734b213.0",
@@ -112,21 +112,21 @@
112
112
  "@types/sinon": "^17.0.3",
113
113
  "@types/sinon-chai": "^3.2.12",
114
114
  "@types/webpack-env": "^1.18.5",
115
- "@typescript-eslint/eslint-plugin": "^7.14.1",
116
- "@typescript-eslint/parser": "^7.14.1",
115
+ "@typescript-eslint/eslint-plugin": "^7.15.0",
116
+ "@typescript-eslint/parser": "^7.15.0",
117
117
  "@vitejs/plugin-react": "^4.3.1",
118
118
  "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
119
119
  "acorn": "^8.12.0",
120
120
  "axe-playwright": "^2.0.1",
121
121
  "babel-plugin-require-context-hook": "^1.0.0",
122
- "caniuse-lite": "^1.0.30001638",
122
+ "caniuse-lite": "^1.0.30001639",
123
123
  "chai": "^5.1.1",
124
124
  "chai-as-promised": "^8.0.0",
125
125
  "chai-dom": "^1.10.0",
126
126
  "chai-enzyme": "1.0.0-beta.1",
127
127
  "cheerio": "^1.0.0-rc.12",
128
128
  "core-js": "^3.37.1",
129
- "cpy-cli": "^3.1.1",
129
+ "cpy-cli": "^5.0.0",
130
130
  "enzyme": "^3.11.0",
131
131
  "eslint": "^8.57.0",
132
132
  "eslint-import-resolver-webpack": "^0.13.8",
@@ -167,7 +167,7 @@
167
167
  "svg-inline-loader": "^0.8.2",
168
168
  "teamcity-service-messages": "^0.1.14",
169
169
  "terser-webpack-plugin": "^5.3.10",
170
- "typescript": "~5.5.2",
170
+ "typescript": "~5.5.3",
171
171
  "vitest": "^1.6.0",
172
172
  "vitest-teamcity-reporter": "^0.3.0",
173
173
  "wallaby-webpack": "^3.9.16",
@@ -226,13 +226,13 @@
226
226
  "highlight.js": "^10.7.2",
227
227
  "just-debounce-it": "^3.2.0",
228
228
  "memoize-one": "^6.0.0",
229
- "postcss": "^8.4.38",
229
+ "postcss": "^8.4.39",
230
230
  "postcss-calc": "^10.0.0",
231
231
  "postcss-flexbugs-fixes": "^5.0.2",
232
232
  "postcss-font-family-system-ui": "^5.0.0",
233
233
  "postcss-loader": "^8.1.1",
234
234
  "postcss-modules-values-replace": "^4.2.0",
235
- "postcss-preset-env": "^9.5.14",
235
+ "postcss-preset-env": "^9.5.15",
236
236
  "prop-types": "^15.8.1",
237
237
  "react-movable": "^3.2.0",
238
238
  "react-virtualized": "^9.22.5",