@rescui/collapse 0.8.6-RUI-308-Fix-select-issues-405b9fa40.12 → 0.9.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/lib/collapse.js CHANGED
@@ -1,4 +1,6 @@
1
1
  "use client";
2
+ import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
3
+ import { c } from 'react-compiler-runtime';
2
4
  import React, { useState, useContext, useRef, useEffect } from 'react';
3
5
  import cn from 'classnames';
4
6
  import PropTypes from 'prop-types';
@@ -29,24 +31,83 @@ const ICON_STYLES = {
29
31
  arrow: styles.iconArrow
30
32
  };
31
33
  const Collapse = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
32
- (_ref, ref) => {
33
- let {
34
- children,
35
- className,
36
- openedClassName: openedClassnameFromProps,
37
- size: sizeFromProps,
38
- mode: modeFromProps,
39
- icon: iconFromProps,
40
- borderBottom: borderBottomFromProps,
41
- disableLeftPadding: disableLeftPaddingFromProps,
42
- title,
43
- isDefaultOpened = false,
44
- theme: themeFromProps,
45
- itemKey,
46
- ...restProps
47
- } = _ref;
34
+ (t0, ref) => {
35
+ const $ = c(63);
36
+ let borderBottomFromProps;
37
+ let children;
38
+ let className;
39
+ let disableLeftPaddingFromProps;
40
+ let iconFromProps;
41
+ let itemKey;
42
+ let modeFromProps;
43
+ let openedClassnameFromProps;
44
+ let restProps;
45
+ let sizeFromProps;
46
+ let t1;
47
+ let themeFromProps;
48
+ let title;
49
+
50
+ if ($[0] !== t0) {
51
+ ({
52
+ children,
53
+ className,
54
+ openedClassName: openedClassnameFromProps,
55
+ size: sizeFromProps,
56
+ mode: modeFromProps,
57
+ icon: iconFromProps,
58
+ borderBottom: borderBottomFromProps,
59
+ disableLeftPadding: disableLeftPaddingFromProps,
60
+ title,
61
+ isDefaultOpened: t1,
62
+ theme: themeFromProps,
63
+ itemKey,
64
+ ...restProps
65
+ } = t0);
66
+ $[0] = t0;
67
+ $[1] = borderBottomFromProps;
68
+ $[2] = children;
69
+ $[3] = className;
70
+ $[4] = disableLeftPaddingFromProps;
71
+ $[5] = iconFromProps;
72
+ $[6] = itemKey;
73
+ $[7] = modeFromProps;
74
+ $[8] = openedClassnameFromProps;
75
+ $[9] = restProps;
76
+ $[10] = sizeFromProps;
77
+ $[11] = t1;
78
+ $[12] = themeFromProps;
79
+ $[13] = title;
80
+ } else {
81
+ borderBottomFromProps = $[1];
82
+ children = $[2];
83
+ className = $[3];
84
+ disableLeftPaddingFromProps = $[4];
85
+ iconFromProps = $[5];
86
+ itemKey = $[6];
87
+ modeFromProps = $[7];
88
+ openedClassnameFromProps = $[8];
89
+ restProps = $[9];
90
+ sizeFromProps = $[10];
91
+ t1 = $[11];
92
+ themeFromProps = $[12];
93
+ title = $[13];
94
+ }
95
+
96
+ const isDefaultOpened = t1 === undefined ? false : t1;
48
97
  const uniqueId = useSafeId();
49
- const [key] = useState(() => itemKey ?? uniqueId);
98
+ let t2;
99
+
100
+ if ($[14] !== itemKey || $[15] !== uniqueId) {
101
+ t2 = () => itemKey ?? uniqueId;
102
+
103
+ $[14] = itemKey;
104
+ $[15] = uniqueId;
105
+ $[16] = t2;
106
+ } else {
107
+ t2 = $[16];
108
+ }
109
+
110
+ const [key] = useState(t2);
50
111
  const [isAccordionConnected, setIsAccordionConnected] = useState(false);
51
112
  const theme = useThemeWithUndefined(themeFromProps);
52
113
  const {
@@ -62,88 +123,219 @@ const Collapse = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line comp
62
123
  disableLeftPadding: disableLeftPaddingFromContext,
63
124
  openedClassName: openedClassNameFromContext
64
125
  } = useContext(collapseContext);
65
- const size = sizeFromProps ?? sizeFromContext ?? 'm';
66
- const mode = modeFromProps ?? modeFromContext ?? 'classic';
67
- const icon = iconFromProps ?? iconFromContext ?? 'left-plus';
126
+ const size = sizeFromProps ?? sizeFromContext ?? "m";
127
+ const mode = modeFromProps ?? modeFromContext ?? "classic";
128
+ const icon = iconFromProps ?? iconFromContext ?? "left-plus";
68
129
  const borderBottom = borderBottomFromProps ?? borderBottomFromContext ?? false;
69
130
  const disableLeftPadding = disableLeftPaddingFromProps ?? disableLeftPaddingFromContext ?? false;
70
131
  const openedClassName = openedClassnameFromProps ?? openedClassNameFromContext;
71
132
  const contentRef = useRef(null);
72
- const [isAnimationEnabled, setIsAnimationEnabled] = useState(!isInAccordion); // this state is ignored in accordion
133
+ const [isAnimationEnabled, setIsAnimationEnabled] = useState(!isInAccordion);
134
+ const [shouldBeOpenedLocal, setShouldBeOpenedLocal] = useState(isDefaultOpened);
135
+ const shouldBeOpened = isAccordionConnected ? openedKey === key : shouldBeOpenedLocal;
136
+ let t3;
137
+ let t4;
73
138
 
74
- const [shouldBeOpenedLocal, setShouldBeOpenedLocal] = useState(isDefaultOpened); // boolean state. ignores CLOSING and OPENING states
139
+ if ($[17] !== isAccordionConnected || $[18] !== isDefaultOpened || $[19] !== isInAccordion || $[20] !== isInControlledAccordion || $[21] !== key || $[22] !== setActiveKey) {
140
+ t3 = () => {
141
+ if (!isInAccordion) {
142
+ return;
143
+ }
75
144
 
76
- const shouldBeOpened = isAccordionConnected ? openedKey === key : shouldBeOpenedLocal;
77
- useEffect(() => {
78
- if (!isInAccordion) {
79
- return;
80
- }
81
-
82
- if (!isAccordionConnected) {
83
- // For an uncontrolled accordion, register the initially opened item.
84
- // Keep using the local state until this update and the connection update
85
- // have rendered together.
86
- if (!isInControlledAccordion && isDefaultOpened && setActiveKey) {
87
- setActiveKey(key);
88
- } // eslint-disable-next-line react-hooks/set-state-in-effect
89
-
90
-
91
- setIsAccordionConnected(true);
92
- return;
93
- } // The first accordion state has already been committed. Enabling
94
- // transitions separately makes its initial reconciliation instantaneous.
95
- // eslint-disable-next-line react-hooks/set-state-in-effect
96
-
97
-
98
- setIsAnimationEnabled(true);
99
- }, [isAccordionConnected, isInAccordion, isInControlledAccordion, isDefaultOpened, setActiveKey, key]); // add CLOSING and OPENING states
100
-
101
- const collapseState = useCollapseState({
102
- shouldBeOpened,
103
- contentRef
104
- });
145
+ if (!isAccordionConnected) {
146
+ if (!isInControlledAccordion && isDefaultOpened && setActiveKey) {
147
+ setActiveKey(key);
148
+ }
149
+
150
+ setIsAccordionConnected(true);
151
+ return;
152
+ }
153
+
154
+ setIsAnimationEnabled(true);
155
+ };
156
+
157
+ t4 = [isAccordionConnected, isInAccordion, isInControlledAccordion, isDefaultOpened, setActiveKey, key];
158
+ $[17] = isAccordionConnected;
159
+ $[18] = isDefaultOpened;
160
+ $[19] = isInAccordion;
161
+ $[20] = isInControlledAccordion;
162
+ $[21] = key;
163
+ $[22] = setActiveKey;
164
+ $[23] = t3;
165
+ $[24] = t4;
166
+ } else {
167
+ t3 = $[23];
168
+ t4 = $[24];
169
+ }
170
+
171
+ useEffect(t3, t4);
172
+ let t5;
173
+
174
+ if ($[25] !== shouldBeOpened) {
175
+ t5 = {
176
+ shouldBeOpened,
177
+ contentRef
178
+ };
179
+ $[25] = shouldBeOpened;
180
+ $[26] = t5;
181
+ } else {
182
+ t5 = $[26];
183
+ }
184
+
185
+ const collapseState = useCollapseState(t5);
105
186
  const isOpening = collapseState === COLLAPSE_STATES.OPENING;
106
187
  const isOpened = collapseState === COLLAPSE_STATES.OPEN;
107
188
  const isClosing = collapseState === COLLAPSE_STATES.CLOSING;
108
189
  const isClosed = collapseState === COLLAPSE_STATES.CLOSE;
109
- const isRightIcon = icon === 'right-plus';
110
- const Icon = icon === 'arrow' ? RightIcon : PlusIcon;
111
-
112
- const toggleOpened = () => {
113
- if (toggleActiveKey) {
114
- toggleActiveKey(key);
115
- } // this state update does nothing in accordion
116
-
117
-
118
- setShouldBeOpenedLocal(!shouldBeOpened);
119
- };
120
-
121
- return /*#__PURE__*/React.createElement("div", {
122
- "data-test": 'collapse',
123
- ...restProps,
124
- className: cn(className, styles.main, isAnimationEnabled && styles.animationEnabled, isOpening && styles.opening, isOpened && styles.opened, 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]),
125
- "data-rs-internal": "collapse__collapse",
126
- ref: ref
127
- }, /*#__PURE__*/React.createElement("button", {
128
- type: "button",
129
- "data-test": 'collapse__button',
130
- "data-rs-internal": "collapse__button",
131
- className: styles.button,
132
- onClick: toggleOpened
133
- }, /*#__PURE__*/React.createElement(Icon, {
134
- className: styles.icon,
135
- "data-render-all-sizes": true
136
- }), /*#__PURE__*/React.createElement("span", {
137
- className: cn(styles.title),
138
- "data-rs-internal": "collapse__title"
139
- }, title)), /*#__PURE__*/React.createElement("div", {
140
- className: styles.content,
141
- "data-rs-internal": "collapse__content",
142
- ref: contentRef,
143
- tabIndex: -1
144
- }, /*#__PURE__*/React.createElement("div", {
145
- className: styles.innerWrapper
146
- }, children)));
190
+ const isRightIcon = icon === "right-plus";
191
+ const Icon = icon === "arrow" ? RightIcon : PlusIcon;
192
+ let t6;
193
+
194
+ if ($[27] !== key || $[28] !== shouldBeOpened || $[29] !== toggleActiveKey) {
195
+ t6 = () => {
196
+ if (toggleActiveKey) {
197
+ toggleActiveKey(key);
198
+ }
199
+
200
+ setShouldBeOpenedLocal(!shouldBeOpened);
201
+ };
202
+
203
+ $[27] = key;
204
+ $[28] = shouldBeOpened;
205
+ $[29] = toggleActiveKey;
206
+ $[30] = t6;
207
+ } else {
208
+ t6 = $[30];
209
+ }
210
+
211
+ const toggleOpened = t6;
212
+ const t7 = isAnimationEnabled && styles.animationEnabled;
213
+ const t8 = isOpening && styles.opening;
214
+ const t9 = isOpened && styles.opened;
215
+ const t10 = isClosing && styles.closing;
216
+ const t11 = isClosed && styles.closed;
217
+ const t12 = !isClosed && openedClassName;
218
+ const t13 = SIZE_STYLES[size];
219
+ const t14 = MODE_STYLES[mode];
220
+ const t15 = ICON_STYLES[icon];
221
+ const t16 = borderBottom && styles.hasBorderBottom;
222
+ const t17 = disableLeftPadding && styles.disableLeftPadding;
223
+ const t18 = isRightIcon ? styles.rightIcon : styles.leftIcon;
224
+ const t19 = THEME_STYLES[theme];
225
+ let t20;
226
+
227
+ if ($[31] !== className || $[32] !== t10 || $[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14 || $[37] !== t15 || $[38] !== t16 || $[39] !== t17 || $[40] !== t18 || $[41] !== t19 || $[42] !== t7 || $[43] !== t8 || $[44] !== t9) {
228
+ t20 = cn(className, styles.main, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19);
229
+ $[31] = className;
230
+ $[32] = t10;
231
+ $[33] = t11;
232
+ $[34] = t12;
233
+ $[35] = t13;
234
+ $[36] = t14;
235
+ $[37] = t15;
236
+ $[38] = t16;
237
+ $[39] = t17;
238
+ $[40] = t18;
239
+ $[41] = t19;
240
+ $[42] = t7;
241
+ $[43] = t8;
242
+ $[44] = t9;
243
+ $[45] = t20;
244
+ } else {
245
+ t20 = $[45];
246
+ }
247
+
248
+ let t21;
249
+
250
+ if ($[46] !== Icon) {
251
+ t21 = /*#__PURE__*/React.createElement(Icon, {
252
+ className: styles.icon,
253
+ "data-render-all-sizes": true
254
+ });
255
+ $[46] = Icon;
256
+ $[47] = t21;
257
+ } else {
258
+ t21 = $[47];
259
+ }
260
+
261
+ let t22;
262
+
263
+ if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
264
+ t22 = cn(styles.title);
265
+ $[48] = t22;
266
+ } else {
267
+ t22 = $[48];
268
+ }
269
+
270
+ let t23;
271
+
272
+ if ($[49] !== title) {
273
+ t23 = /*#__PURE__*/React.createElement("span", {
274
+ className: t22,
275
+ "data-rs-internal": "collapse__title"
276
+ }, title);
277
+ $[49] = title;
278
+ $[50] = t23;
279
+ } else {
280
+ t23 = $[50];
281
+ }
282
+
283
+ let t24;
284
+
285
+ if ($[51] !== t21 || $[52] !== t23 || $[53] !== toggleOpened) {
286
+ t24 = /*#__PURE__*/React.createElement("button", {
287
+ type: "button",
288
+ "data-test": "collapse__button",
289
+ "data-rs-internal": "collapse__button",
290
+ className: styles.button,
291
+ onClick: toggleOpened
292
+ }, t21, t23);
293
+ $[51] = t21;
294
+ $[52] = t23;
295
+ $[53] = toggleOpened;
296
+ $[54] = t24;
297
+ } else {
298
+ t24 = $[54];
299
+ }
300
+
301
+ let t25;
302
+
303
+ if ($[55] !== children) {
304
+ t25 = /*#__PURE__*/React.createElement("div", {
305
+ className: styles.content,
306
+ "data-rs-internal": "collapse__content",
307
+ ref: contentRef,
308
+ tabIndex: -1
309
+ }, /*#__PURE__*/React.createElement("div", {
310
+ className: styles.innerWrapper
311
+ }, children));
312
+ $[55] = children;
313
+ $[56] = t25;
314
+ } else {
315
+ t25 = $[56];
316
+ }
317
+
318
+ let t26;
319
+
320
+ if ($[57] !== ref || $[58] !== restProps || $[59] !== t20 || $[60] !== t24 || $[61] !== t25) {
321
+ t26 = /*#__PURE__*/React.createElement("div", _extends({
322
+ "data-test": "collapse"
323
+ }, restProps, {
324
+ className: t20,
325
+ "data-rs-internal": "collapse__collapse",
326
+ ref: ref
327
+ }), t24, t25);
328
+ $[57] = ref;
329
+ $[58] = restProps;
330
+ $[59] = t20;
331
+ $[60] = t24;
332
+ $[61] = t25;
333
+ $[62] = t26;
334
+ } else {
335
+ t26 = $[62];
336
+ }
337
+
338
+ return t26;
147
339
  });
148
340
  Collapse.displayName = 'Collapse';
149
341
  Collapse.propTypes = {
@@ -1,35 +1,35 @@
1
1
  var styles = {
2
- "themeLight": "_themeLight_1m640ib_6",
3
- "themeDark": "_themeDark_1m640ib_9",
4
- "sizeS": "_sizeS_1m640ib_13",
5
- "sizeM": "_sizeM_1m640ib_16",
6
- "sizeL": "_sizeL_1m640ib_19",
7
- "classic": "_classic_1m640ib_23",
8
- "rock": "_rock_1m640ib_26",
9
- "clear": "_clear_1m640ib_29",
10
- "hasBorderBottom": "_hasBorderBottom_1m640ib_33",
11
- "leftIcon": "_leftIcon_1m640ib_37",
12
- "rightIcon": "_rightIcon_1m640ib_40",
13
- "disableLeftPadding": "_disableLeftPadding_1m640ib_44",
14
- "main": "_main_1m640ib_48",
15
- "opening": "_opening_1m640ib_59",
16
- "opened": "_opened_1m640ib_60",
17
- "closing": "_closing_1m640ib_61",
18
- "title": "_title_1m640ib_95",
19
- "content": "_content_1m640ib_103",
20
- "animationEnabled": "_animationEnabled_1m640ib_115",
21
- "closed": "_closed_1m640ib_128",
22
- "innerWrapper": "_innerWrapper_1m640ib_133",
23
- "button": "_button_1m640ib_140",
24
- "icon": "_icon_1m640ib_196",
25
- "iconPlus": "_iconPlus_1m640ib_217",
26
- "iconArrow": "_iconArrow_1m640ib_222",
27
- "accordion": "_accordion_1m640ib_228",
28
- "accordionGap0": "_accordionGap0_1m640ib_233",
29
- "accordionGap8": "_accordionGap8_1m640ib_236",
30
- "accordionGap12": "_accordionGap12_1m640ib_239",
31
- "accordionGap16": "_accordionGap16_1m640ib_242",
32
- "accordionGap24": "_accordionGap24_1m640ib_245",
33
- "accordionGap32": "_accordionGap32_1m640ib_248"
2
+ "themeLight": "_themeLight_1rx64ql_6",
3
+ "themeDark": "_themeDark_1rx64ql_9",
4
+ "sizeS": "_sizeS_1rx64ql_13",
5
+ "sizeM": "_sizeM_1rx64ql_16",
6
+ "sizeL": "_sizeL_1rx64ql_19",
7
+ "classic": "_classic_1rx64ql_23",
8
+ "rock": "_rock_1rx64ql_26",
9
+ "clear": "_clear_1rx64ql_29",
10
+ "hasBorderBottom": "_hasBorderBottom_1rx64ql_33",
11
+ "leftIcon": "_leftIcon_1rx64ql_37",
12
+ "rightIcon": "_rightIcon_1rx64ql_40",
13
+ "disableLeftPadding": "_disableLeftPadding_1rx64ql_44",
14
+ "main": "_main_1rx64ql_48",
15
+ "opening": "_opening_1rx64ql_59",
16
+ "opened": "_opened_1rx64ql_60",
17
+ "closing": "_closing_1rx64ql_61",
18
+ "title": "_title_1rx64ql_95",
19
+ "content": "_content_1rx64ql_103",
20
+ "animationEnabled": "_animationEnabled_1rx64ql_115",
21
+ "closed": "_closed_1rx64ql_128",
22
+ "innerWrapper": "_innerWrapper_1rx64ql_133",
23
+ "button": "_button_1rx64ql_140",
24
+ "icon": "_icon_1rx64ql_196",
25
+ "iconPlus": "_iconPlus_1rx64ql_220",
26
+ "iconArrow": "_iconArrow_1rx64ql_225",
27
+ "accordion": "_accordion_1rx64ql_231",
28
+ "accordionGap0": "_accordionGap0_1rx64ql_236",
29
+ "accordionGap8": "_accordionGap8_1rx64ql_239",
30
+ "accordionGap12": "_accordionGap12_1rx64ql_242",
31
+ "accordionGap16": "_accordionGap16_1rx64ql_245",
32
+ "accordionGap24": "_accordionGap24_1rx64ql_248",
33
+ "accordionGap32": "_accordionGap32_1rx64ql_251"
34
34
  };
35
35
  export { styles as default };