@rescui/collapse 0.7.0 → 0.7.1-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.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.
- package/package.json +7 -7
- package/lib/_virtual/index.css.js +0 -15
- package/lib/_virtual/plus.js +0 -106
- package/lib/_virtual/right.js +0 -106
- package/lib/accordion.d.ts +0 -47
- package/lib/accordion.js +0 -87
- package/lib/collapse.d.ts +0 -51
- package/lib/collapse.js +0 -173
- package/lib/collapse.p.module.css.js +0 -35
- package/lib/context.d.ts +0 -16
- package/lib/context.js +0 -16
- package/lib/index.css +0 -600
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -3
- package/lib/public-api.p.css +0 -622
- package/lib/public-api.pcss +0 -622
- package/lib/types.d.ts +0 -5
- package/lib/use-collapse-state.d.ts +0 -18
- package/lib/use-collapse-state.js +0 -75
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/collapse",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.1+8695a904",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
19
|
-
"@rescui/use-resize-observer": "
|
|
19
|
+
"@rescui/use-resize-observer": "0.3.1-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.19+8695a904",
|
|
20
20
|
"classnames": "^2.2.6"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"react": ">=16.8.0 <20"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@rescui/colors": "
|
|
29
|
-
"@rescui/scripts": "
|
|
30
|
-
"@rescui/typography": "
|
|
31
|
-
"@rescui/visual-regression": "
|
|
28
|
+
"@rescui/colors": "0.2.11-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.19+8695a904",
|
|
29
|
+
"@rescui/scripts": "0.5.1",
|
|
30
|
+
"@rescui/typography": "0.24.1-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.19+8695a904",
|
|
31
|
+
"@rescui/visual-regression": "0.1.2",
|
|
32
32
|
"@types/classnames": "^2.2.11"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
|
|
37
37
|
},
|
|
38
38
|
"nx": {},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "8695a9042a55369f8df8f03ffd61c988cd3d3df4"
|
|
40
40
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"icon": "_icon_1vjehu8_4",
|
|
3
|
-
"sizeXS": "_sizeXS_1vjehu8_14",
|
|
4
|
-
"sizeS": "_sizeS_1vjehu8_18",
|
|
5
|
-
"sizeM": "_sizeM_1vjehu8_22",
|
|
6
|
-
"sizeL": "_sizeL_1vjehu8_26",
|
|
7
|
-
"light": "_light_1vjehu8_30",
|
|
8
|
-
"dark": "_dark_1vjehu8_34",
|
|
9
|
-
"allVariants": "_allVariants_1vjehu8_48",
|
|
10
|
-
"variant16": "_variant16_1vjehu8_53",
|
|
11
|
-
"variant20": "_variant20_1vjehu8_54",
|
|
12
|
-
"variant24": "_variant24_1vjehu8_55",
|
|
13
|
-
"variant28": "_variant28_1vjehu8_58"
|
|
14
|
-
};
|
|
15
|
-
export { styles as default };
|
package/lib/_virtual/plus.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import cn from 'classnames';
|
|
5
|
-
import styles from './index.css.js';
|
|
6
|
-
const sizeStyles = {
|
|
7
|
-
"xs": styles.sizeXS,
|
|
8
|
-
"s": styles.sizeS,
|
|
9
|
-
"m": styles.sizeM,
|
|
10
|
-
"l": styles.sizeL
|
|
11
|
-
};
|
|
12
|
-
const Size = {
|
|
13
|
-
"xs": "xs",
|
|
14
|
-
"s": "s",
|
|
15
|
-
"m": "m",
|
|
16
|
-
"l": "l"
|
|
17
|
-
};
|
|
18
|
-
const PlusIcon16 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
19
|
-
viewBox: "0 0 16 16"
|
|
20
|
-
}, props, {
|
|
21
|
-
ref: ref
|
|
22
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
23
|
-
d: "M8 1.75a.75.75 0 0 1 .75.75v4.75h4.75a.75.75 0 0 1 0 1.5H8.75v4.75a.75.75 0 0 1-1.5 0V8.75H2.5a.75.75 0 0 1 0-1.5h4.75V2.5A.75.75 0 0 1 8 1.75"
|
|
24
|
-
})));
|
|
25
|
-
PlusIcon16.displayName = 'PlusIcon16';
|
|
26
|
-
const PlusIcon20 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
27
|
-
viewBox: "0 0 20 20"
|
|
28
|
-
}, props, {
|
|
29
|
-
ref: ref
|
|
30
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
31
|
-
d: "M10 3a1 1 0 0 1 1 1v5h5a1 1 0 1 1 0 2h-5v5a1 1 0 1 1-2 0v-5H4a1 1 0 1 1 0-2h5V4a1 1 0 0 1 1-1"
|
|
32
|
-
})));
|
|
33
|
-
PlusIcon20.displayName = 'PlusIcon20';
|
|
34
|
-
const PlusIcon24 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
35
|
-
viewBox: "0 0 24 24"
|
|
36
|
-
}, props, {
|
|
37
|
-
ref: ref
|
|
38
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
39
|
-
d: "M12.5 3A1.5 1.5 0 0 1 14 4.5V10h5.5a1.5 1.5 0 0 1 0 3H14v5.5a1.5 1.5 0 0 1-3 0V13H5.5a1.5 1.5 0 0 1 0-3H11V4.5A1.5 1.5 0 0 1 12.5 3"
|
|
40
|
-
})));
|
|
41
|
-
PlusIcon24.displayName = 'PlusIcon24';
|
|
42
|
-
const PlusIcon28 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
43
|
-
viewBox: "0 0 28 28"
|
|
44
|
-
}, props, {
|
|
45
|
-
ref: ref
|
|
46
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
47
|
-
d: "M14.5 4A1.5 1.5 0 0 1 16 5.5V12h6.5a1.5 1.5 0 0 1 0 3H16v6.5a1.5 1.5 0 0 1-3 0V15H6.5a1.5 1.5 0 0 1 0-3H13V5.5A1.5 1.5 0 0 1 14.5 4"
|
|
48
|
-
})));
|
|
49
|
-
PlusIcon28.displayName = 'PlusIcon28';
|
|
50
|
-
const PlusIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
51
|
-
let {
|
|
52
|
-
theme,
|
|
53
|
-
size: sizeFromProps = "m",
|
|
54
|
-
className,
|
|
55
|
-
style,
|
|
56
|
-
['data-render-all-sizes']: renderAllSizes = false,
|
|
57
|
-
...props
|
|
58
|
-
} = _ref;
|
|
59
|
-
const size = sizeFromProps in Size ? sizeFromProps : "m";
|
|
60
|
-
const mainProps = { ...props,
|
|
61
|
-
className: cn(styles.icon, styles[theme], sizeStyles[size], renderAllSizes && styles.allVariants, className),
|
|
62
|
-
style: renderAllSizes ? {
|
|
63
|
-
'--rs-icon-ar-width': 28,
|
|
64
|
-
'--rs-icon-ar-height': 28,
|
|
65
|
-
...style
|
|
66
|
-
} : style,
|
|
67
|
-
ref
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
if (renderAllSizes) {
|
|
71
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
72
|
-
viewBox: "0 0 28 28"
|
|
73
|
-
}, mainProps), /*#__PURE__*/React.createElement(PlusIcon16, {
|
|
74
|
-
className: styles.variant16
|
|
75
|
-
}), /*#__PURE__*/React.createElement(PlusIcon20, {
|
|
76
|
-
className: styles.variant20
|
|
77
|
-
}), /*#__PURE__*/React.createElement(PlusIcon24, {
|
|
78
|
-
className: styles.variant24
|
|
79
|
-
}), /*#__PURE__*/React.createElement(PlusIcon28, {
|
|
80
|
-
className: styles.variant28
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (size === Size['xs']) {
|
|
85
|
-
return /*#__PURE__*/React.createElement(PlusIcon16, mainProps);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (size === Size['s']) {
|
|
89
|
-
return /*#__PURE__*/React.createElement(PlusIcon20, mainProps);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (size === Size['m']) {
|
|
93
|
-
return /*#__PURE__*/React.createElement(PlusIcon24, mainProps);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return /*#__PURE__*/React.createElement(PlusIcon28, mainProps);
|
|
97
|
-
});
|
|
98
|
-
PlusIcon.displayName = 'PlusIcon';
|
|
99
|
-
PlusIcon.propTypes = {
|
|
100
|
-
className: PropTypes.string,
|
|
101
|
-
theme: PropTypes.oneOf(["light", "dark"]),
|
|
102
|
-
size: PropTypes.oneOf(["xs", "s", "m", "l"]),
|
|
103
|
-
'data-render-all-sizes': PropTypes.bool,
|
|
104
|
-
style: PropTypes.object
|
|
105
|
-
};
|
|
106
|
-
export { Size, PlusIcon as default };
|
package/lib/_virtual/right.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import cn from 'classnames';
|
|
5
|
-
import styles from './index.css.js';
|
|
6
|
-
const sizeStyles = {
|
|
7
|
-
"xs": styles.sizeXS,
|
|
8
|
-
"s": styles.sizeS,
|
|
9
|
-
"m": styles.sizeM,
|
|
10
|
-
"l": styles.sizeL
|
|
11
|
-
};
|
|
12
|
-
const Size = {
|
|
13
|
-
"xs": "xs",
|
|
14
|
-
"s": "s",
|
|
15
|
-
"m": "m",
|
|
16
|
-
"l": "l"
|
|
17
|
-
};
|
|
18
|
-
const RightIcon16 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
19
|
-
viewBox: "0 0 16 16"
|
|
20
|
-
}, props, {
|
|
21
|
-
ref: ref
|
|
22
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
23
|
-
d: "M5.97 4.47a.75.75 0 0 0 0 1.06L8.44 8l-2.47 2.47a.75.75 0 1 0 1.06 1.06l3-3a.75.75 0 0 0 0-1.06l-3-3a.75.75 0 0 0-1.06 0"
|
|
24
|
-
})));
|
|
25
|
-
RightIcon16.displayName = 'RightIcon16';
|
|
26
|
-
const RightIcon20 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
27
|
-
viewBox: "0 0 20 20"
|
|
28
|
-
}, props, {
|
|
29
|
-
ref: ref
|
|
30
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
31
|
-
d: "M7.293 5.293a1 1 0 0 0 0 1.414L10.586 10l-3.293 3.293a1 1 0 1 0 1.414 1.414l4-4a1 1 0 0 0 0-1.414l-4-4a1 1 0 0 0-1.414 0"
|
|
32
|
-
})));
|
|
33
|
-
RightIcon20.displayName = 'RightIcon20';
|
|
34
|
-
const RightIcon24 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
35
|
-
viewBox: "0 0 24 24"
|
|
36
|
-
}, props, {
|
|
37
|
-
ref: ref
|
|
38
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
39
|
-
d: "M7.94 4.94a1.5 1.5 0 0 0 0 2.12L12.878 12l-4.94 4.94a1.5 1.5 0 0 0 2.122 2.12l6-6a1.5 1.5 0 0 0 0-2.12l-6-6a1.5 1.5 0 0 0-2.122 0"
|
|
40
|
-
})));
|
|
41
|
-
RightIcon24.displayName = 'RightIcon24';
|
|
42
|
-
const RightIcon28 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
43
|
-
viewBox: "0 0 28 28"
|
|
44
|
-
}, props, {
|
|
45
|
-
ref: ref
|
|
46
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
47
|
-
d: "M9.44 5.94a1.5 1.5 0 0 0 0 2.12L15.378 14l-5.94 5.94a1.5 1.5 0 0 0 2.122 2.12l7-7a1.5 1.5 0 0 0 0-2.12l-7-7a1.5 1.5 0 0 0-2.122 0"
|
|
48
|
-
})));
|
|
49
|
-
RightIcon28.displayName = 'RightIcon28';
|
|
50
|
-
const RightIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
51
|
-
let {
|
|
52
|
-
theme,
|
|
53
|
-
size: sizeFromProps = "m",
|
|
54
|
-
className,
|
|
55
|
-
style,
|
|
56
|
-
['data-render-all-sizes']: renderAllSizes = false,
|
|
57
|
-
...props
|
|
58
|
-
} = _ref;
|
|
59
|
-
const size = sizeFromProps in Size ? sizeFromProps : "m";
|
|
60
|
-
const mainProps = { ...props,
|
|
61
|
-
className: cn(styles.icon, styles[theme], sizeStyles[size], renderAllSizes && styles.allVariants, className),
|
|
62
|
-
style: renderAllSizes ? {
|
|
63
|
-
'--rs-icon-ar-width': 28,
|
|
64
|
-
'--rs-icon-ar-height': 28,
|
|
65
|
-
...style
|
|
66
|
-
} : style,
|
|
67
|
-
ref
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
if (renderAllSizes) {
|
|
71
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
72
|
-
viewBox: "0 0 28 28"
|
|
73
|
-
}, mainProps), /*#__PURE__*/React.createElement(RightIcon16, {
|
|
74
|
-
className: styles.variant16
|
|
75
|
-
}), /*#__PURE__*/React.createElement(RightIcon20, {
|
|
76
|
-
className: styles.variant20
|
|
77
|
-
}), /*#__PURE__*/React.createElement(RightIcon24, {
|
|
78
|
-
className: styles.variant24
|
|
79
|
-
}), /*#__PURE__*/React.createElement(RightIcon28, {
|
|
80
|
-
className: styles.variant28
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (size === Size['xs']) {
|
|
85
|
-
return /*#__PURE__*/React.createElement(RightIcon16, mainProps);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (size === Size['s']) {
|
|
89
|
-
return /*#__PURE__*/React.createElement(RightIcon20, mainProps);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (size === Size['m']) {
|
|
93
|
-
return /*#__PURE__*/React.createElement(RightIcon24, mainProps);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return /*#__PURE__*/React.createElement(RightIcon28, mainProps);
|
|
97
|
-
});
|
|
98
|
-
RightIcon.displayName = 'RightIcon';
|
|
99
|
-
RightIcon.propTypes = {
|
|
100
|
-
className: PropTypes.string,
|
|
101
|
-
theme: PropTypes.oneOf(["light", "dark"]),
|
|
102
|
-
size: PropTypes.oneOf(["xs", "s", "m", "l"]),
|
|
103
|
-
'data-render-all-sizes': PropTypes.bool,
|
|
104
|
-
style: PropTypes.object
|
|
105
|
-
};
|
|
106
|
-
export { Size, RightIcon as default };
|
package/lib/accordion.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
import type { AccordionGap, CollapseSize, CollapseMode, CollapseIcon, KeyType } from './types';
|
|
4
|
-
export declare type AccordionExplicitProps = {
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
className?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Opened collapse classname
|
|
9
|
-
*/
|
|
10
|
-
openedClassName?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Collapse items size
|
|
13
|
-
*/
|
|
14
|
-
size?: CollapseSize;
|
|
15
|
-
/**
|
|
16
|
-
* Collapse items appearance mode
|
|
17
|
-
*/
|
|
18
|
-
mode?: CollapseMode;
|
|
19
|
-
/**
|
|
20
|
-
* Collapse items icon type
|
|
21
|
-
*/
|
|
22
|
-
icon?: CollapseIcon;
|
|
23
|
-
/**
|
|
24
|
-
* Controls the bottom border of collapse items
|
|
25
|
-
*/
|
|
26
|
-
borderBottom?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Disable left content padding of collapse items
|
|
29
|
-
*/
|
|
30
|
-
disableLeftPadding?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Vertical gap between children items
|
|
33
|
-
*/
|
|
34
|
-
gap?: AccordionGap;
|
|
35
|
-
theme?: Theme;
|
|
36
|
-
/**
|
|
37
|
-
* Active collapse key. Must be used with `itemKey` prop on the collapse items.
|
|
38
|
-
* Any value except `undefined` turns accordion into controlled mode.
|
|
39
|
-
*/
|
|
40
|
-
value?: KeyType;
|
|
41
|
-
/**
|
|
42
|
-
* Event which fired when the active collapse item is changed.
|
|
43
|
-
*/
|
|
44
|
-
onChange?: (key: KeyType) => void;
|
|
45
|
-
};
|
|
46
|
-
export declare type AccordionProps = AccordionExplicitProps & Omit<React.HTMLProps<HTMLDivElement>, keyof AccordionExplicitProps | 'ref'>;
|
|
47
|
-
export declare const Accordion: React.ForwardRefExoticComponent<AccordionExplicitProps & Omit<React.HTMLProps<HTMLDivElement>, keyof AccordionExplicitProps | "ref"> & React.RefAttributes<HTMLDivElement>>;
|
package/lib/accordion.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import cn from 'classnames';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
6
|
-
import { collapseContext } from './context.js';
|
|
7
|
-
import styles from './collapse.p.module.css.js';
|
|
8
|
-
const GAP_STYLES = {
|
|
9
|
-
0: styles.accordionGap0,
|
|
10
|
-
8: styles.accordionGap8,
|
|
11
|
-
12: styles.accordionGap12,
|
|
12
|
-
16: styles.accordionGap16,
|
|
13
|
-
24: styles.accordionGap24,
|
|
14
|
-
32: styles.accordionGap32
|
|
15
|
-
};
|
|
16
|
-
const THEME_STYLES = {
|
|
17
|
-
light: styles.themeLight,
|
|
18
|
-
dark: styles.themeDark
|
|
19
|
-
};
|
|
20
|
-
const Accordion = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
|
|
21
|
-
(_ref, ref) => {
|
|
22
|
-
let {
|
|
23
|
-
children,
|
|
24
|
-
className,
|
|
25
|
-
openedClassName,
|
|
26
|
-
size = 'm',
|
|
27
|
-
mode = 'classic',
|
|
28
|
-
icon = 'left-plus',
|
|
29
|
-
borderBottom = false,
|
|
30
|
-
disableLeftPadding = false,
|
|
31
|
-
gap = 0,
|
|
32
|
-
theme: themeFromProps,
|
|
33
|
-
value,
|
|
34
|
-
onChange,
|
|
35
|
-
...restProps
|
|
36
|
-
} = _ref;
|
|
37
|
-
const isControlled = typeof value !== 'undefined';
|
|
38
|
-
const theme = useThemeWithUndefined(themeFromProps);
|
|
39
|
-
const [openKey, setActiveKey] = useState(isControlled ? value : null);
|
|
40
|
-
|
|
41
|
-
const toggleActiveKey = key => {
|
|
42
|
-
const activatingKey = key !== openKey ? key : null;
|
|
43
|
-
|
|
44
|
-
if (onChange) {
|
|
45
|
-
onChange(activatingKey);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
setActiveKey(activatingKey);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return /*#__PURE__*/React.createElement(collapseContext.Provider, {
|
|
52
|
-
value: {
|
|
53
|
-
openedKey: isControlled ? value : openKey,
|
|
54
|
-
isInAccordion: true,
|
|
55
|
-
isInControlledAccordion: isControlled,
|
|
56
|
-
toggleActiveKey,
|
|
57
|
-
setActiveKey,
|
|
58
|
-
size,
|
|
59
|
-
mode,
|
|
60
|
-
icon,
|
|
61
|
-
borderBottom,
|
|
62
|
-
disableLeftPadding,
|
|
63
|
-
openedClassName
|
|
64
|
-
}
|
|
65
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
66
|
-
"data-test": 'accordion',
|
|
67
|
-
...restProps,
|
|
68
|
-
className: cn(styles.accordion, GAP_STYLES[gap], THEME_STYLES[theme], className),
|
|
69
|
-
ref: ref
|
|
70
|
-
}, children));
|
|
71
|
-
});
|
|
72
|
-
Accordion.displayName = 'Accordion';
|
|
73
|
-
Accordion.propTypes = {
|
|
74
|
-
children: PropTypes.node,
|
|
75
|
-
className: PropTypes.string,
|
|
76
|
-
openedClassName: PropTypes.string,
|
|
77
|
-
size: PropTypes.oneOf(['s', 'm', 'l']),
|
|
78
|
-
mode: PropTypes.oneOf(['classic', 'rock', 'clear']),
|
|
79
|
-
icon: PropTypes.oneOf(['arrow', 'left-plus', 'right-plus']),
|
|
80
|
-
gap: PropTypes.oneOf([0, 8, 12, 16, 24, 32]),
|
|
81
|
-
theme: PropTypes.oneOf(['light', 'dark']),
|
|
82
|
-
borderBottom: PropTypes.bool,
|
|
83
|
-
disableLeftPadding: PropTypes.bool,
|
|
84
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.symbol]),
|
|
85
|
-
onChange: PropTypes.func
|
|
86
|
-
};
|
|
87
|
-
export { Accordion };
|
package/lib/collapse.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
import type { CollapseIcon, CollapseMode, CollapseSize, KeyType } from './types';
|
|
4
|
-
export declare type CollapseExplicitProps = {
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
className?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Classname for the opened state
|
|
9
|
-
*/
|
|
10
|
-
openedClassName?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Collapse title slot
|
|
13
|
-
*/
|
|
14
|
-
title?: React.ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Collapse size
|
|
17
|
-
* @default m
|
|
18
|
-
*/
|
|
19
|
-
size?: CollapseSize;
|
|
20
|
-
/**
|
|
21
|
-
* Collapse appearance mode
|
|
22
|
-
* @default classic
|
|
23
|
-
*/
|
|
24
|
-
mode?: CollapseMode;
|
|
25
|
-
/**
|
|
26
|
-
* Collapse icon type
|
|
27
|
-
* @default left-plus
|
|
28
|
-
*/
|
|
29
|
-
icon?: CollapseIcon;
|
|
30
|
-
/**
|
|
31
|
-
* Controls the Collapse bottom border
|
|
32
|
-
* @default false
|
|
33
|
-
*/
|
|
34
|
-
borderBottom?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Disable left content padding
|
|
37
|
-
* @default false
|
|
38
|
-
*/
|
|
39
|
-
disableLeftPadding?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Is collapse opened by default. Will be ignored in controlled `Accordion`
|
|
42
|
-
*/
|
|
43
|
-
isDefaultOpened?: boolean;
|
|
44
|
-
theme?: Theme;
|
|
45
|
-
/**
|
|
46
|
-
* Collapse item key. May be required for the controlled `Accordion`
|
|
47
|
-
*/
|
|
48
|
-
itemKey?: KeyType;
|
|
49
|
-
};
|
|
50
|
-
export declare type CollapseProps = CollapseExplicitProps & Omit<React.HTMLProps<HTMLDivElement>, keyof CollapseExplicitProps | 'ref'>;
|
|
51
|
-
export declare const Collapse: React.ForwardRefExoticComponent<CollapseExplicitProps & Omit<React.HTMLProps<HTMLDivElement>, keyof CollapseExplicitProps | "ref"> & React.RefAttributes<HTMLDivElement>>;
|
package/lib/collapse.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { useRef, useContext, useState, useEffect } from 'react';
|
|
3
|
-
import cn from 'classnames';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
6
|
-
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
7
|
-
import RightIcon from './_virtual/right.js';
|
|
8
|
-
import PlusIcon from './_virtual/plus.js';
|
|
9
|
-
import { collapseContext } from './context.js';
|
|
10
|
-
import { useCollapseState, COLLAPSE_STATES, useStartedClosing } from './use-collapse-state.js';
|
|
11
|
-
import styles from './collapse.p.module.css.js';
|
|
12
|
-
|
|
13
|
-
function getRandId() {
|
|
14
|
-
return Math.random().toString(36).substring(7);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const THEME_STYLES = {
|
|
18
|
-
light: styles.themeLight,
|
|
19
|
-
dark: styles.themeDark
|
|
20
|
-
};
|
|
21
|
-
const SIZE_STYLES = {
|
|
22
|
-
s: styles.sizeS,
|
|
23
|
-
m: styles.sizeM,
|
|
24
|
-
l: styles.sizeL
|
|
25
|
-
};
|
|
26
|
-
const MODE_STYLES = {
|
|
27
|
-
classic: styles.classic,
|
|
28
|
-
rock: styles.rock,
|
|
29
|
-
clear: styles.clear
|
|
30
|
-
};
|
|
31
|
-
const ICON_STYLES = {
|
|
32
|
-
'left-plus': styles.iconPlus,
|
|
33
|
-
'right-plus': styles.iconPlus,
|
|
34
|
-
arrow: styles.iconArrow
|
|
35
|
-
};
|
|
36
|
-
const Collapse = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
|
|
37
|
-
(_ref, ref) => {
|
|
38
|
-
let {
|
|
39
|
-
children,
|
|
40
|
-
className,
|
|
41
|
-
openedClassName: openedClassnameFromProps,
|
|
42
|
-
size: sizeFromProps,
|
|
43
|
-
mode: modeFromProps,
|
|
44
|
-
icon: iconFromProps,
|
|
45
|
-
borderBottom: borderBottomFromProps,
|
|
46
|
-
disableLeftPadding: disableLeftPaddingFromProps,
|
|
47
|
-
title,
|
|
48
|
-
isDefaultOpened = false,
|
|
49
|
-
theme: themeFromProps,
|
|
50
|
-
itemKey,
|
|
51
|
-
...restProps
|
|
52
|
-
} = _ref;
|
|
53
|
-
// using the trick from https://github.com/Yaska/react-use-id-hook/
|
|
54
|
-
const {
|
|
55
|
-
current: key
|
|
56
|
-
} = useRef(itemKey ?? getRandId());
|
|
57
|
-
const theme = useThemeWithUndefined(themeFromProps);
|
|
58
|
-
const {
|
|
59
|
-
openedKey,
|
|
60
|
-
isInAccordion,
|
|
61
|
-
isInControlledAccordion,
|
|
62
|
-
toggleActiveKey,
|
|
63
|
-
setActiveKey,
|
|
64
|
-
size: sizeFromContext,
|
|
65
|
-
mode: modeFromContext,
|
|
66
|
-
icon: iconFromContext,
|
|
67
|
-
borderBottom: borderBottomFromContext,
|
|
68
|
-
disableLeftPadding: disableLeftPaddingFromContext,
|
|
69
|
-
openedClassName: openedClassNameFromContext
|
|
70
|
-
} = useContext(collapseContext);
|
|
71
|
-
const size = sizeFromProps ?? sizeFromContext ?? 'm';
|
|
72
|
-
const mode = modeFromProps ?? modeFromContext ?? 'classic';
|
|
73
|
-
const icon = iconFromProps ?? iconFromContext ?? 'left-plus';
|
|
74
|
-
const borderBottom = borderBottomFromProps ?? borderBottomFromContext ?? false;
|
|
75
|
-
const disableLeftPadding = disableLeftPaddingFromProps ?? disableLeftPaddingFromContext ?? false;
|
|
76
|
-
const openedClassName = openedClassnameFromProps ?? openedClassNameFromContext; // height calculations
|
|
77
|
-
|
|
78
|
-
const resizeRef = useRef(null);
|
|
79
|
-
const [height, setHeight] = useState('initial');
|
|
80
|
-
useResizeObserver(resizeRef, entry => setHeight(entry.target.offsetHeight));
|
|
81
|
-
const isHeightCalculated = height !== 'initial'; // this state is ignored in accordion
|
|
82
|
-
|
|
83
|
-
const [shouldBeOpenedLocal, setShouldBeOpenedLocal] = useState(isDefaultOpened); // boolean state. ignores CLOSING and OPENING states
|
|
84
|
-
|
|
85
|
-
const shouldBeOpened = isInAccordion ? openedKey === key : shouldBeOpenedLocal; // add CLOSING and OPENING states.
|
|
86
|
-
|
|
87
|
-
const {
|
|
88
|
-
onAnimationEnd: handleTransitionEnd,
|
|
89
|
-
state: collapseState
|
|
90
|
-
} = useCollapseState({
|
|
91
|
-
shouldBeOpened,
|
|
92
|
-
// because how css transitions work, we shouldn't use OPENING and CLOSING states while height still calculating
|
|
93
|
-
// it also allows us to skip animation on the first renders
|
|
94
|
-
cancelAnimation: !isHeightCalculated
|
|
95
|
-
});
|
|
96
|
-
const isOpening = collapseState === COLLAPSE_STATES.OPENING;
|
|
97
|
-
const isOpened = collapseState === COLLAPSE_STATES.OPEN;
|
|
98
|
-
const isClosing = collapseState === COLLAPSE_STATES.CLOSING;
|
|
99
|
-
const isClosed = collapseState === COLLAPSE_STATES.CLOSE;
|
|
100
|
-
const {
|
|
101
|
-
isStartedClosing,
|
|
102
|
-
contentRef
|
|
103
|
-
} = useStartedClosing(collapseState);
|
|
104
|
-
const isRightIcon = icon === 'right-plus';
|
|
105
|
-
const Icon = icon === 'arrow' ? RightIcon : PlusIcon;
|
|
106
|
-
|
|
107
|
-
const toggleOpened = () => {
|
|
108
|
-
if (toggleActiveKey) {
|
|
109
|
-
toggleActiveKey(key);
|
|
110
|
-
} // this state update does nothing in accordion
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
setShouldBeOpenedLocal(!shouldBeOpened);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
// for uncontrolled accordion, tell it that this collapse is opened by default
|
|
118
|
-
if (isInAccordion && !isInControlledAccordion && isDefaultOpened && setActiveKey) {
|
|
119
|
-
setActiveKey(key);
|
|
120
|
-
}
|
|
121
|
-
}, []);
|
|
122
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
123
|
-
"data-test": 'collapse',
|
|
124
|
-
...restProps,
|
|
125
|
-
className: cn(className, styles.main, isOpening && styles.opening, isOpened && styles.opened, isClosing && !isStartedClosing && styles.closingTransition, isClosing && styles.closing, isClosed && styles.closed, !isClosed && openedClassName, SIZE_STYLES[size], MODE_STYLES[mode], ICON_STYLES[icon], borderBottom && styles.hasBorderBottom, disableLeftPadding && styles.disableLeftPadding, isRightIcon ? styles.rightIcon : styles.leftIcon, THEME_STYLES[theme]),
|
|
126
|
-
"data-rs-internal": "collapse__collapse",
|
|
127
|
-
ref: ref
|
|
128
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
129
|
-
type: "button",
|
|
130
|
-
"data-test": 'collapse__button',
|
|
131
|
-
"data-rs-internal": "collapse__button",
|
|
132
|
-
className: styles.button,
|
|
133
|
-
onClick: toggleOpened
|
|
134
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
135
|
-
className: styles.icon,
|
|
136
|
-
"data-render-all-sizes": true
|
|
137
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
138
|
-
className: cn(styles.title),
|
|
139
|
-
"data-rs-internal": "collapse__title"
|
|
140
|
-
}, title)), /*#__PURE__*/React.createElement("div", {
|
|
141
|
-
className: styles.content,
|
|
142
|
-
"data-rs-internal": "collapse__content",
|
|
143
|
-
style: {
|
|
144
|
-
// So, we set the height value only on OPENING stage and just after beginning CLOSING stage
|
|
145
|
-
// The reason we don't leave this style for OPEN stage is because some content of the expanded Collapse may change its height dynamically
|
|
146
|
-
// This will be processed by resizeObserver, but some devices may lag behind
|
|
147
|
-
// And to make collapsing transition work, we need to have a frame with numbered height value before starting the collapse transition
|
|
148
|
-
height: isOpening || isStartedClosing ? height : null
|
|
149
|
-
},
|
|
150
|
-
ref: contentRef,
|
|
151
|
-
onTransitionEnd: handleTransitionEnd,
|
|
152
|
-
tabIndex: -1
|
|
153
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
154
|
-
ref: resizeRef,
|
|
155
|
-
className: styles.innerWrapper
|
|
156
|
-
}, children)));
|
|
157
|
-
});
|
|
158
|
-
Collapse.displayName = 'Collapse';
|
|
159
|
-
Collapse.propTypes = {
|
|
160
|
-
children: PropTypes.node,
|
|
161
|
-
className: PropTypes.string,
|
|
162
|
-
openedClassName: PropTypes.string,
|
|
163
|
-
size: PropTypes.oneOf(['s', 'm', 'l']),
|
|
164
|
-
mode: PropTypes.oneOf(['classic', 'rock', 'clear']),
|
|
165
|
-
icon: PropTypes.oneOf(['arrow', 'left-plus', 'right-plus']),
|
|
166
|
-
theme: PropTypes.oneOf(['light', 'dark']),
|
|
167
|
-
itemKey: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.symbol]),
|
|
168
|
-
isDefaultOpened: PropTypes.bool,
|
|
169
|
-
borderBottom: PropTypes.bool,
|
|
170
|
-
disableLeftPadding: PropTypes.bool,
|
|
171
|
-
title: PropTypes.node
|
|
172
|
-
};
|
|
173
|
-
export { Collapse };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"themeLight": "_themeLight_swbn7y_6",
|
|
3
|
-
"themeDark": "_themeDark_swbn7y_9",
|
|
4
|
-
"sizeS": "_sizeS_swbn7y_13",
|
|
5
|
-
"sizeM": "_sizeM_swbn7y_16",
|
|
6
|
-
"sizeL": "_sizeL_swbn7y_19",
|
|
7
|
-
"classic": "_classic_swbn7y_23",
|
|
8
|
-
"rock": "_rock_swbn7y_26",
|
|
9
|
-
"clear": "_clear_swbn7y_29",
|
|
10
|
-
"hasBorderBottom": "_hasBorderBottom_swbn7y_33",
|
|
11
|
-
"leftIcon": "_leftIcon_swbn7y_37",
|
|
12
|
-
"rightIcon": "_rightIcon_swbn7y_40",
|
|
13
|
-
"disableLeftPadding": "_disableLeftPadding_swbn7y_44",
|
|
14
|
-
"main": "_main_swbn7y_48",
|
|
15
|
-
"opening": "_opening_swbn7y_59",
|
|
16
|
-
"opened": "_opened_swbn7y_60",
|
|
17
|
-
"closing": "_closing_swbn7y_61",
|
|
18
|
-
"title": "_title_swbn7y_95",
|
|
19
|
-
"content": "_content_swbn7y_103",
|
|
20
|
-
"closed": "_closed_swbn7y_111",
|
|
21
|
-
"closingTransition": "_closingTransition_swbn7y_120",
|
|
22
|
-
"innerWrapper": "_innerWrapper_swbn7y_127",
|
|
23
|
-
"button": "_button_swbn7y_133",
|
|
24
|
-
"icon": "_icon_swbn7y_186",
|
|
25
|
-
"iconPlus": "_iconPlus_swbn7y_202",
|
|
26
|
-
"iconArrow": "_iconArrow_swbn7y_207",
|
|
27
|
-
"accordion": "_accordion_swbn7y_213",
|
|
28
|
-
"accordionGap0": "_accordionGap0_swbn7y_218",
|
|
29
|
-
"accordionGap8": "_accordionGap8_swbn7y_221",
|
|
30
|
-
"accordionGap12": "_accordionGap12_swbn7y_224",
|
|
31
|
-
"accordionGap16": "_accordionGap16_swbn7y_227",
|
|
32
|
-
"accordionGap24": "_accordionGap24_swbn7y_230",
|
|
33
|
-
"accordionGap32": "_accordionGap32_swbn7y_233"
|
|
34
|
-
};
|
|
35
|
-
export { styles as default };
|
package/lib/context.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CollapseIcon, CollapseMode, CollapseSize, KeyType } from './types';
|
|
3
|
-
export declare type CollapseContext = {
|
|
4
|
-
openedKey?: KeyType;
|
|
5
|
-
isInAccordion?: boolean;
|
|
6
|
-
isInControlledAccordion?: boolean;
|
|
7
|
-
toggleActiveKey?: (key: KeyType) => void;
|
|
8
|
-
setActiveKey?: (key: KeyType) => void;
|
|
9
|
-
size?: CollapseSize;
|
|
10
|
-
mode?: CollapseMode;
|
|
11
|
-
icon?: CollapseIcon;
|
|
12
|
-
borderBottom?: boolean;
|
|
13
|
-
disableLeftPadding?: boolean;
|
|
14
|
-
openedClassName?: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const collapseContext: React.Context<CollapseContext>;
|