@jetbrains/ring-ui 7.0.0 → 7.0.2-beta.0
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/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
This collection of UI components aims to provide all the necessary building blocks for web-based products built inside JetBrains, as well as third-party plugins developed for JetBrains' products.
|
|
7
7
|
|
|
8
8
|
## Try now
|
|
9
|
-
* Try the [codesandbox](https://codesandbox.io/p/sandbox/ring-ui-
|
|
9
|
+
* Try the [codesandbox](https://codesandbox.io/p/sandbox/ring-ui-7-0-demo-z6v6ym), based on `create-react-app` tooling, to see and try the UI components
|
|
10
10
|
* Check out [list of examples](https://jetbrains.github.io/ring-ui/master/index.html) for each component
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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({
|
|
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(
|
|
25
|
-
const [shouldHideContent, setShouldHideContent] = useState(collapsed && minHeight <= DEFAULT_HEIGHT);
|
|
28
|
+
const [showFade, setShowFade] = useState(true);
|
|
26
29
|
useEffect(() => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setShouldHideContent(collapsed);
|
|
30
|
-
}
|
|
30
|
+
if (!collapsed) {
|
|
31
|
+
setShowFade(false);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
{
|
|
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.
|
|
160
|
-
|
|
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.2-beta.0",
|
|
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.
|
|
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",
|