@rescui/collapse 0.8.4-RUI-297-Add-react-compiler-to-the-packages-build-dbbefd7b8.10 → 0.8.4-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.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.
package/lib/collapse.js CHANGED
@@ -5,7 +5,6 @@ import React, { useState, useContext, useRef, useEffect } from 'react';
5
5
  import cn from 'classnames';
6
6
  import PropTypes from 'prop-types';
7
7
  import { useThemeWithUndefined } from '@rescui/ui-contexts';
8
- import { useResizeObserver } from '@rescui/use-resize-observer';
9
8
  import RightIcon from './_virtual/right.js';
10
9
  import PlusIcon from './_virtual/plus.js';
11
10
  import { collapseContext } from './context.js';
@@ -33,7 +32,7 @@ const ICON_STYLES = {
33
32
  };
34
33
  const Collapse = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
35
34
  (t0, ref) => {
36
- const $ = c(71);
35
+ const $ = c(63);
37
36
  let borderBottomFromProps;
38
37
  let children;
39
38
  let className;
@@ -109,6 +108,7 @@ const Collapse = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line comp
109
108
  }
110
109
 
111
110
  const [key] = useState(t2);
111
+ const [isAccordionConnected, setIsAccordionConnected] = useState(false);
112
112
  const theme = useThemeWithUndefined(themeFromProps);
113
113
  const {
114
114
  openedKey,
@@ -129,52 +129,69 @@ const Collapse = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line comp
129
129
  const borderBottom = borderBottomFromProps ?? borderBottomFromContext ?? false;
130
130
  const disableLeftPadding = disableLeftPaddingFromProps ?? disableLeftPaddingFromContext ?? false;
131
131
  const openedClassName = openedClassnameFromProps ?? openedClassNameFromContext;
132
- const resizeRef = useRef(null);
133
- const [height, setHeight] = useState("initial");
132
+ const contentRef = useRef(null);
133
+ const [isAnimationEnabled, setIsAnimationEnabled] = useState(!isInAccordion);
134
+ const [shouldBeOpenedLocal, setShouldBeOpenedLocal] = useState(isDefaultOpened);
135
+ const shouldBeOpened = isAccordionConnected ? openedKey === key : shouldBeOpenedLocal;
134
136
  let t3;
137
+ let t4;
138
+
139
+ if ($[17] !== isAccordionConnected || $[18] !== isDefaultOpened || $[19] !== isInAccordion || $[20] !== isInControlledAccordion || $[21] !== key || $[22] !== setActiveKey) {
140
+ t3 = () => {
141
+ if (!isInAccordion) {
142
+ return;
143
+ }
144
+
145
+ if (!isAccordionConnected) {
146
+ if (!isInControlledAccordion && isDefaultOpened && setActiveKey) {
147
+ setActiveKey(key);
148
+ }
149
+
150
+ setIsAccordionConnected(true);
151
+ return;
152
+ }
135
153
 
136
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
137
- t3 = entry => setHeight(entry.target.offsetHeight);
154
+ setIsAnimationEnabled(true);
155
+ };
138
156
 
139
- $[17] = t3;
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;
140
166
  } else {
141
- t3 = $[17];
167
+ t3 = $[23];
168
+ t4 = $[24];
142
169
  }
143
170
 
144
- useResizeObserver(resizeRef, t3);
145
- const isHeightCalculated = height !== "initial";
146
- const [shouldBeOpenedLocal, setShouldBeOpenedLocal] = useState(isDefaultOpened);
147
- const shouldBeOpened = isInAccordion ? openedKey === key : shouldBeOpenedLocal;
148
- const t4 = !isHeightCalculated;
171
+ useEffect(t3, t4);
149
172
  let t5;
150
173
 
151
- if ($[18] !== shouldBeOpened || $[19] !== t4) {
174
+ if ($[25] !== shouldBeOpened) {
152
175
  t5 = {
153
176
  shouldBeOpened,
154
- cancelAnimation: t4
177
+ contentRef
155
178
  };
156
- $[18] = shouldBeOpened;
157
- $[19] = t4;
158
- $[20] = t5;
179
+ $[25] = shouldBeOpened;
180
+ $[26] = t5;
159
181
  } else {
160
- t5 = $[20];
182
+ t5 = $[26];
161
183
  }
162
184
 
163
- const {
164
- contentRef,
165
- isStartedClosing,
166
- onAnimationEnd: handleTransitionEnd,
167
- state: collapseState
168
- } = useCollapseState(t5);
185
+ const collapseState = useCollapseState(t5);
169
186
  const isOpening = collapseState === COLLAPSE_STATES.OPENING;
170
187
  const isOpened = collapseState === COLLAPSE_STATES.OPEN;
171
- const isClosing = collapseState === COLLAPSE_STATES.CLOSING_PREPARE || collapseState === COLLAPSE_STATES.CLOSING;
188
+ const isClosing = collapseState === COLLAPSE_STATES.CLOSING;
172
189
  const isClosed = collapseState === COLLAPSE_STATES.CLOSE;
173
190
  const isRightIcon = icon === "right-plus";
174
191
  const Icon = icon === "arrow" ? RightIcon : PlusIcon;
175
192
  let t6;
176
193
 
177
- if ($[21] !== key || $[22] !== shouldBeOpened || $[23] !== toggleActiveKey) {
194
+ if ($[27] !== key || $[28] !== shouldBeOpened || $[29] !== toggleActiveKey) {
178
195
  t6 = () => {
179
196
  if (toggleActiveKey) {
180
197
  toggleActiveKey(key);
@@ -183,200 +200,142 @@ const Collapse = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line comp
183
200
  setShouldBeOpenedLocal(!shouldBeOpened);
184
201
  };
185
202
 
186
- $[21] = key;
187
- $[22] = shouldBeOpened;
188
- $[23] = toggleActiveKey;
189
- $[24] = t6;
203
+ $[27] = key;
204
+ $[28] = shouldBeOpened;
205
+ $[29] = toggleActiveKey;
206
+ $[30] = t6;
190
207
  } else {
191
- t6 = $[24];
208
+ t6 = $[30];
192
209
  }
193
210
 
194
211
  const toggleOpened = t6;
195
- let t7;
196
-
197
- if ($[25] !== isDefaultOpened || $[26] !== isInAccordion || $[27] !== isInControlledAccordion || $[28] !== key || $[29] !== setActiveKey) {
198
- t7 = () => {
199
- if (isInAccordion && !isInControlledAccordion && isDefaultOpened && setActiveKey) {
200
- setActiveKey(key);
201
- }
202
- };
203
-
204
- $[25] = isDefaultOpened;
205
- $[26] = isInAccordion;
206
- $[27] = isInControlledAccordion;
207
- $[28] = key;
208
- $[29] = setActiveKey;
209
- $[30] = t7;
210
- } else {
211
- t7 = $[30];
212
- }
213
-
214
- let t8;
215
-
216
- if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
217
- t8 = [];
218
- $[31] = t8;
219
- } else {
220
- t8 = $[31];
221
- }
222
-
223
- useEffect(t7, t8);
224
- const t9 = isOpening && styles.opening;
225
- const t10 = isOpened && styles.opened;
226
- const t11 = isClosing && !isStartedClosing && styles.closingTransition;
227
- const t12 = isClosing && styles.closing;
228
- const t13 = isClosed && styles.closed;
229
- const t14 = !isClosed && openedClassName;
230
- const t15 = SIZE_STYLES[size];
231
- const t16 = MODE_STYLES[mode];
232
- const t17 = ICON_STYLES[icon];
233
- const t18 = borderBottom && styles.hasBorderBottom;
234
- const t19 = disableLeftPadding && styles.disableLeftPadding;
235
- const t20 = isRightIcon ? styles.rightIcon : styles.leftIcon;
236
- const t21 = THEME_STYLES[theme];
237
- let t22;
238
-
239
- if ($[32] !== className || $[33] !== t10 || $[34] !== t11 || $[35] !== t12 || $[36] !== t13 || $[37] !== t14 || $[38] !== t15 || $[39] !== t16 || $[40] !== t17 || $[41] !== t18 || $[42] !== t19 || $[43] !== t20 || $[44] !== t21 || $[45] !== t9) {
240
- t22 = cn(className, styles.main, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21);
241
- $[32] = className;
242
- $[33] = t10;
243
- $[34] = t11;
244
- $[35] = t12;
245
- $[36] = t13;
246
- $[37] = t14;
247
- $[38] = t15;
248
- $[39] = t16;
249
- $[40] = t17;
250
- $[41] = t18;
251
- $[42] = t19;
252
- $[43] = t20;
253
- $[44] = t21;
254
- $[45] = t9;
255
- $[46] = t22;
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;
256
244
  } else {
257
- t22 = $[46];
245
+ t20 = $[45];
258
246
  }
259
247
 
260
- let t23;
248
+ let t21;
261
249
 
262
- if ($[47] !== Icon) {
263
- t23 = /*#__PURE__*/React.createElement(Icon, {
250
+ if ($[46] !== Icon) {
251
+ t21 = /*#__PURE__*/React.createElement(Icon, {
264
252
  className: styles.icon,
265
253
  "data-render-all-sizes": true
266
254
  });
267
- $[47] = Icon;
268
- $[48] = t23;
255
+ $[46] = Icon;
256
+ $[47] = t21;
269
257
  } else {
270
- t23 = $[48];
258
+ t21 = $[47];
271
259
  }
272
260
 
273
- let t24;
261
+ let t22;
274
262
 
275
- if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
276
- t24 = cn(styles.title);
277
- $[49] = t24;
263
+ if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
264
+ t22 = cn(styles.title);
265
+ $[48] = t22;
278
266
  } else {
279
- t24 = $[49];
267
+ t22 = $[48];
280
268
  }
281
269
 
282
- let t25;
270
+ let t23;
283
271
 
284
- if ($[50] !== title) {
285
- t25 = /*#__PURE__*/React.createElement("span", {
286
- className: t24,
272
+ if ($[49] !== title) {
273
+ t23 = /*#__PURE__*/React.createElement("span", {
274
+ className: t22,
287
275
  "data-rs-internal": "collapse__title"
288
276
  }, title);
289
- $[50] = title;
290
- $[51] = t25;
277
+ $[49] = title;
278
+ $[50] = t23;
291
279
  } else {
292
- t25 = $[51];
280
+ t23 = $[50];
293
281
  }
294
282
 
295
- let t26;
283
+ let t24;
296
284
 
297
- if ($[52] !== t23 || $[53] !== t25 || $[54] !== toggleOpened) {
298
- t26 = /*#__PURE__*/React.createElement("button", {
285
+ if ($[51] !== t21 || $[52] !== t23 || $[53] !== toggleOpened) {
286
+ t24 = /*#__PURE__*/React.createElement("button", {
299
287
  type: "button",
300
288
  "data-test": "collapse__button",
301
289
  "data-rs-internal": "collapse__button",
302
290
  className: styles.button,
303
291
  onClick: toggleOpened
304
- }, t23, t25);
292
+ }, t21, t23);
293
+ $[51] = t21;
305
294
  $[52] = t23;
306
- $[53] = t25;
307
- $[54] = toggleOpened;
308
- $[55] = t26;
295
+ $[53] = toggleOpened;
296
+ $[54] = t24;
309
297
  } else {
310
- t26 = $[55];
298
+ t24 = $[54];
311
299
  }
312
300
 
313
- const t27 = isOpening || isStartedClosing ? height : null;
314
- let t28;
315
-
316
- if ($[56] !== t27) {
317
- t28 = {
318
- height: t27
319
- };
320
- $[56] = t27;
321
- $[57] = t28;
322
- } else {
323
- t28 = $[57];
324
- }
325
-
326
- let t29;
327
-
328
- if ($[58] !== children) {
329
- t29 = /*#__PURE__*/React.createElement("div", {
330
- ref: resizeRef,
331
- className: styles.innerWrapper
332
- }, children);
333
- $[58] = children;
334
- $[59] = t29;
335
- } else {
336
- t29 = $[59];
337
- }
338
-
339
- let t30;
301
+ let t25;
340
302
 
341
- if ($[60] !== contentRef || $[61] !== handleTransitionEnd || $[62] !== t28 || $[63] !== t29) {
342
- t30 = /*#__PURE__*/React.createElement("div", {
303
+ if ($[55] !== children) {
304
+ t25 = /*#__PURE__*/React.createElement("div", {
343
305
  className: styles.content,
344
306
  "data-rs-internal": "collapse__content",
345
- style: t28,
346
307
  ref: contentRef,
347
- onTransitionEnd: handleTransitionEnd,
348
308
  tabIndex: -1
349
- }, t29);
350
- $[60] = contentRef;
351
- $[61] = handleTransitionEnd;
352
- $[62] = t28;
353
- $[63] = t29;
354
- $[64] = t30;
309
+ }, /*#__PURE__*/React.createElement("div", {
310
+ className: styles.innerWrapper
311
+ }, children));
312
+ $[55] = children;
313
+ $[56] = t25;
355
314
  } else {
356
- t30 = $[64];
315
+ t25 = $[56];
357
316
  }
358
317
 
359
- let t31;
318
+ let t26;
360
319
 
361
- if ($[65] !== ref || $[66] !== restProps || $[67] !== t22 || $[68] !== t26 || $[69] !== t30) {
362
- t31 = /*#__PURE__*/React.createElement("div", _extends({
320
+ if ($[57] !== ref || $[58] !== restProps || $[59] !== t20 || $[60] !== t24 || $[61] !== t25) {
321
+ t26 = /*#__PURE__*/React.createElement("div", _extends({
363
322
  "data-test": "collapse"
364
323
  }, restProps, {
365
- className: t22,
324
+ className: t20,
366
325
  "data-rs-internal": "collapse__collapse",
367
326
  ref: ref
368
- }), t26, t30);
369
- $[65] = ref;
370
- $[66] = restProps;
371
- $[67] = t22;
372
- $[68] = t26;
373
- $[69] = t30;
374
- $[70] = t31;
327
+ }), t24, t25);
328
+ $[57] = ref;
329
+ $[58] = restProps;
330
+ $[59] = t20;
331
+ $[60] = t24;
332
+ $[61] = t25;
333
+ $[62] = t26;
375
334
  } else {
376
- t31 = $[70];
335
+ t26 = $[62];
377
336
  }
378
337
 
379
- return t31;
338
+ return t26;
380
339
  });
381
340
  Collapse.displayName = 'Collapse';
382
341
  Collapse.propTypes = {
@@ -1,35 +1,35 @@
1
1
  var styles = {
2
- "themeLight": "_themeLight_1t0qfuj_6",
3
- "themeDark": "_themeDark_1t0qfuj_9",
4
- "sizeS": "_sizeS_1t0qfuj_13",
5
- "sizeM": "_sizeM_1t0qfuj_16",
6
- "sizeL": "_sizeL_1t0qfuj_19",
7
- "classic": "_classic_1t0qfuj_23",
8
- "rock": "_rock_1t0qfuj_26",
9
- "clear": "_clear_1t0qfuj_29",
10
- "hasBorderBottom": "_hasBorderBottom_1t0qfuj_33",
11
- "leftIcon": "_leftIcon_1t0qfuj_37",
12
- "rightIcon": "_rightIcon_1t0qfuj_40",
13
- "disableLeftPadding": "_disableLeftPadding_1t0qfuj_44",
14
- "main": "_main_1t0qfuj_48",
15
- "opening": "_opening_1t0qfuj_59",
16
- "opened": "_opened_1t0qfuj_60",
17
- "closing": "_closing_1t0qfuj_61",
18
- "title": "_title_1t0qfuj_95",
19
- "content": "_content_1t0qfuj_103",
20
- "closed": "_closed_1t0qfuj_111",
21
- "closingTransition": "_closingTransition_1t0qfuj_120",
22
- "innerWrapper": "_innerWrapper_1t0qfuj_127",
23
- "button": "_button_1t0qfuj_133",
24
- "icon": "_icon_1t0qfuj_186",
25
- "iconPlus": "_iconPlus_1t0qfuj_202",
26
- "iconArrow": "_iconArrow_1t0qfuj_207",
27
- "accordion": "_accordion_1t0qfuj_213",
28
- "accordionGap0": "_accordionGap0_1t0qfuj_218",
29
- "accordionGap8": "_accordionGap8_1t0qfuj_221",
30
- "accordionGap12": "_accordionGap12_1t0qfuj_224",
31
- "accordionGap16": "_accordionGap16_1t0qfuj_227",
32
- "accordionGap24": "_accordionGap24_1t0qfuj_230",
33
- "accordionGap32": "_accordionGap32_1t0qfuj_233"
2
+ "themeLight": "_themeLight_diwgr6_6",
3
+ "themeDark": "_themeDark_diwgr6_9",
4
+ "sizeS": "_sizeS_diwgr6_13",
5
+ "sizeM": "_sizeM_diwgr6_16",
6
+ "sizeL": "_sizeL_diwgr6_19",
7
+ "classic": "_classic_diwgr6_23",
8
+ "rock": "_rock_diwgr6_26",
9
+ "clear": "_clear_diwgr6_29",
10
+ "hasBorderBottom": "_hasBorderBottom_diwgr6_33",
11
+ "leftIcon": "_leftIcon_diwgr6_37",
12
+ "rightIcon": "_rightIcon_diwgr6_40",
13
+ "disableLeftPadding": "_disableLeftPadding_diwgr6_44",
14
+ "main": "_main_diwgr6_48",
15
+ "opening": "_opening_diwgr6_59",
16
+ "opened": "_opened_diwgr6_60",
17
+ "closing": "_closing_diwgr6_61",
18
+ "title": "_title_diwgr6_95",
19
+ "content": "_content_diwgr6_103",
20
+ "animationEnabled": "_animationEnabled_diwgr6_115",
21
+ "closed": "_closed_diwgr6_128",
22
+ "innerWrapper": "_innerWrapper_diwgr6_133",
23
+ "button": "_button_diwgr6_140",
24
+ "icon": "_icon_diwgr6_196",
25
+ "iconPlus": "_iconPlus_diwgr6_217",
26
+ "iconArrow": "_iconArrow_diwgr6_222",
27
+ "accordion": "_accordion_diwgr6_228",
28
+ "accordionGap0": "_accordionGap0_diwgr6_233",
29
+ "accordionGap8": "_accordionGap8_diwgr6_236",
30
+ "accordionGap12": "_accordionGap12_diwgr6_239",
31
+ "accordionGap16": "_accordionGap16_diwgr6_242",
32
+ "accordionGap24": "_accordionGap24_diwgr6_245",
33
+ "accordionGap32": "_accordionGap32_diwgr6_248"
34
34
  };
35
35
  export { styles as default };