@jetbrains/ring-ui 7.0.0 → 7.0.1

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.
@@ -1,4 +1,5 @@
1
- import React, { PropsWithChildren } from 'react';
1
+ import { PropsWithChildren } from 'react';
2
+ import * as React from 'react';
2
3
  type Props = {
3
4
  minHeight?: number;
4
5
  className?: string;
@@ -1,4 +1,5 @@
1
- import React, { useState, useEffect, useRef, useContext, useMemo } from 'react';
1
+ import { useState, useEffect, useRef, useContext, useMemo } from 'react';
2
+ import * as React from 'react';
2
3
  import classNames from 'classnames';
3
4
  import dataTests from '../global/data-tests';
4
5
  import { getRect } from '../global/dom';
@@ -19,30 +20,19 @@ export const CollapseContent = ({ children, minHeight = DEFAULT_HEIGHT, 'data-te
19
20
  const contentRef = useRef(null);
20
21
  const initialContentHeight = useRef(minHeight);
21
22
  const contentHeight = useRef(DEFAULT_HEIGHT);
22
- const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
23
+ const [dimensions, setDimensions] = useState({
24
+ width: 0,
25
+ height: 0,
26
+ });
23
27
  const [height, setHeight] = useState(toPx(minHeight));
24
- const [showFade, setShowFade] = useState(collapsed);
25
- const [shouldHideContent, setShouldHideContent] = useState(collapsed && minHeight <= DEFAULT_HEIGHT);
28
+ const [showFade, setShowFade] = useState(true);
26
29
  useEffect(() => {
27
- function onTransitionEnd() {
28
- if (initialContentHeight.current <= DEFAULT_HEIGHT) {
29
- setShouldHideContent(collapsed);
30
- }
30
+ if (!collapsed) {
31
+ setShowFade(false);
31
32
  }
32
- const container = containerRef.current;
33
- if (container) {
34
- container.addEventListener('transitionend', onTransitionEnd);
33
+ else {
34
+ setShowFade(true);
35
35
  }
36
- return () => {
37
- if (container) {
38
- container.removeEventListener('transitionend', onTransitionEnd);
39
- }
40
- };
41
- }, [collapsed]);
42
- useEffect(() => {
43
- setShowFade(collapsed);
44
- if (!collapsed)
45
- setShouldHideContent(false);
46
36
  }, [collapsed]);
47
37
  useEffect(() => {
48
38
  if (contentRef.current) {
@@ -73,10 +63,9 @@ export const CollapseContent = ({ children, minHeight = DEFAULT_HEIGHT, 'data-te
73
63
  };
74
64
  }, [duration, height, collapsed, minHeight]);
75
65
  const fadeShouldBeVisible = useMemo(() => Boolean(minHeight && showFade), [minHeight, showFade]);
76
- const shouldRenderContent = disableAnimation ? !collapsed : !shouldHideContent;
77
66
  return (<div ref={containerRef} id={`collapse-content-${id}`} data-test={dataTests(COLLAPSE_CONTENT_CONTAINER_TEST_ID)} className={classNames(styles.container, { [styles.transition]: !disableAnimation })} style={style}>
78
67
  <div ref={contentRef} data-test={dataTests(COLLAPSE_CONTENT_TEST_ID, dataTest)}>
79
- {shouldRenderContent ? children : null}
68
+ {children}
80
69
  </div>
81
70
  {fadeShouldBeVisible && <div className={styles.fade}/>}
82
71
  </div>);
@@ -156,8 +156,9 @@ class Shortcuts {
156
156
  !(element instanceof HTMLElement) ||
157
157
  key == null ||
158
158
  element.matches(this.ALLOW_SHORTCUTS_SELECTOR) ||
159
- element.closest(this.ALLOW_SHORTCUTS_SELECTOR) != null ||
160
- (element.dataset.enabledShortcuts != null && element.dataset.enabledShortcuts.split(',').includes(key))) {
159
+ (element.dataset.enabledShortcuts != null
160
+ ? element.dataset.enabledShortcuts.split(',').includes(key)
161
+ : element.closest(this.ALLOW_SHORTCUTS_SELECTOR) != null)) {
161
162
  return false;
162
163
  }
163
164
  const elementContentEditableAttribute = element.contentEditable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -127,7 +127,7 @@
127
127
  "acorn": "^8.14.0",
128
128
  "axe-playwright": "^2.0.3",
129
129
  "babel-plugin-require-context-hook": "^1.0.0",
130
- "caniuse-lite": "^1.0.30001677",
130
+ "caniuse-lite": "^1.0.30001678",
131
131
  "chai": "^5.1.2",
132
132
  "chai-as-promised": "^8.0.0",
133
133
  "chai-dom": "^1.10.0",