@rescui/switcher 0.10.3 → 0.10.5

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/index.css CHANGED
@@ -1,10 +1,10 @@
1
- ._themeLight_1i5u8r0_6{
1
+ ._themeLight_1klphaw_6{
2
2
  --rs-theme-dark:0;
3
3
  }
4
- ._themeDark_1i5u8r0_9{
4
+ ._themeDark_1klphaw_9{
5
5
  --rs-theme-dark:1;
6
6
  }
7
- ._sizeXS_1i5u8r0_13{
7
+ ._sizeXS_1klphaw_13{
8
8
  --_rs-switcher-border-radius:4px;
9
9
  --_rs-switcher-compact-border-radius:var(--_rs-switcher-border-radius);
10
10
  --_rs-switcher-option-padding:2px 12px;
@@ -14,7 +14,7 @@
14
14
  --_rs-switcher-compact-icon-offset:var(--_rs-switcher-icon-offset);
15
15
  --_rs-switcher-icon-margin-vertical:2px;
16
16
  }
17
- ._sizeXS_1i5u8r0_13 [data-rs-internal='switcher__option']{
17
+ ._sizeXS_1klphaw_13 [data-rs-internal='switcher__option']{
18
18
  --_rs-typography-letter-spacing:0.0045em;
19
19
  --_rs-typography-text-transform:initial;
20
20
  --_rs-typography-font-variant-numeric:initial;
@@ -48,7 +48,7 @@
48
48
  --_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
49
49
  --_rs-typography-link-border-bottom-width-from-text:1px;
50
50
  }
51
- ._sizeS_1i5u8r0_16{
51
+ ._sizeS_1klphaw_16{
52
52
  --_rs-switcher-border-radius:16px;
53
53
  --_rs-switcher-compact-border-radius:4px;
54
54
  --_rs-switcher-option-padding:6px 16px;
@@ -58,7 +58,7 @@
58
58
  --_rs-switcher-compact-icon-offset:4px;
59
59
  --_rs-switcher-icon-margin-vertical:0px;
60
60
  }
61
- ._sizeS_1i5u8r0_16 [data-rs-internal='switcher__option']{
61
+ ._sizeS_1klphaw_16 [data-rs-internal='switcher__option']{
62
62
  --_rs-typography-letter-spacing:0.0045em;
63
63
  --_rs-typography-text-transform:initial;
64
64
  --_rs-typography-font-variant-numeric:initial;
@@ -92,7 +92,7 @@
92
92
  --_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
93
93
  --_rs-typography-link-border-bottom-width-from-text:1px;
94
94
  }
95
- ._sizeM_1i5u8r0_19{
95
+ ._sizeM_1klphaw_19{
96
96
  --_rs-switcher-border-radius:20px;
97
97
  --_rs-switcher-compact-border-radius:8px;
98
98
  --_rs-switcher-option-padding:8px 24px;
@@ -102,7 +102,7 @@
102
102
  --_rs-switcher-compact-icon-offset:8px;
103
103
  --_rs-switcher-icon-margin-vertical:0px;
104
104
  }
105
- ._sizeM_1i5u8r0_19 [data-rs-internal='switcher__option']{
105
+ ._sizeM_1klphaw_19 [data-rs-internal='switcher__option']{
106
106
  --_rs-typography-letter-spacing:0.0015em;
107
107
  --_rs-typography-text-transform:initial;
108
108
  --_rs-typography-font-variant-numeric:initial;
@@ -137,11 +137,11 @@
137
137
  --_rs-typography-link-border-bottom-width-from-text:1px;
138
138
  }
139
139
  @media screen and (max-width: 640px){
140
- ._sizeM_1i5u8r0_19 [data-rs-internal='switcher__option']{
140
+ ._sizeM_1klphaw_19 [data-rs-internal='switcher__option']{
141
141
  --_rs-typography-list-li-margin-top-from-text:12px;
142
142
  }
143
143
  }
144
- ._sizeL_1i5u8r0_22{
144
+ ._sizeL_1klphaw_22{
145
145
  --_rs-switcher-border-radius:26px;
146
146
  --_rs-switcher-compact-border-radius:12px;
147
147
  --_rs-switcher-option-padding:12px 32px;
@@ -151,7 +151,7 @@
151
151
  --_rs-switcher-compact-icon-offset:12px;
152
152
  --_rs-switcher-icon-margin-vertical:0px;
153
153
  }
154
- ._sizeL_1i5u8r0_22 [data-rs-internal='switcher__option']{
154
+ ._sizeL_1klphaw_22 [data-rs-internal='switcher__option']{
155
155
  --_rs-typography-letter-spacing:normal;
156
156
  --_rs-typography-text-transform:initial;
157
157
  --_rs-typography-font-variant-numeric:initial;
@@ -186,22 +186,22 @@
186
186
  --_rs-typography-link-border-bottom-width-from-text:1px;
187
187
  }
188
188
  @media screen and (max-width: 640px){
189
- ._sizeL_1i5u8r0_22 [data-rs-internal='switcher__option']{
189
+ ._sizeL_1klphaw_22 [data-rs-internal='switcher__option']{
190
190
  --_rs-typography-list-li-margin-top-from-text:16px;
191
191
  }
192
192
  }
193
- ._modeClassic_1i5u8r0_26{
193
+ ._modeClassic_1klphaw_26{
194
194
  --_rs-switcher-option-hover-background:var(--_rs-color-primary-t-fog);
195
195
  --_rs-switcher-mark-border-color:var(--_rs-color-primary);
196
196
  }
197
- ._modeRock_1i5u8r0_29{
197
+ ._modeRock_1klphaw_29{
198
198
  --_rs-switcher-option-hover-background:rgba(
199
199
  calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227),
200
200
  0.1
201
201
  );
202
202
  --_rs-switcher-mark-border-color:rgb(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227));
203
203
  }
204
- ._compact_1i5u8r0_33{
204
+ ._compact_1klphaw_33{
205
205
  --_rs-switcher-border-radius-from-compact:var(
206
206
  --_rs-switcher-compact-border-radius
207
207
  );
@@ -212,7 +212,7 @@
212
212
  --_rs-switcher-compact-icon-offset
213
213
  );
214
214
  }
215
- ._switcher_1i5u8r0_37{
215
+ ._switcher_1klphaw_37{
216
216
  --_rs-theme-dark:var(
217
217
  --_rs-internal-force-theme-dark-consult-rescui-before-using,
218
218
  var(--rs-theme-dark, 0)
@@ -222,7 +222,7 @@
222
222
  --_rs-theme-light-coefficient:calc(1 - var(--_rs-theme-dark-coefficient));
223
223
  }
224
224
  @supports (color: color-mix(in srgb, #fff 50%, #000 50%)){
225
- ._switcher_1i5u8r0_37{
225
+ ._switcher_1klphaw_37{
226
226
  --_rs-color-primary:color-mix(in srgb, var(--rs-color-primary-light-theme, #6B57FF) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-dark-theme, #8473FF) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
227
227
  --_rs-color-primary-dim:color-mix(in srgb, var(--rs-color-primary-dim-light-theme, #8979ff) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-dim-dark-theme, #6f61d2) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
228
228
  --_rs-color-primary-fog:color-mix(in srgb, var(--rs-color-primary-fog-light-theme, #e1ddff) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-fog-dark-theme, #2e2b49) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
@@ -231,7 +231,7 @@
231
231
  }
232
232
  }
233
233
  @supports not (color: color-mix(in srgb, #fff 50%, #000 50%)){
234
- ._switcher_1i5u8r0_37{
234
+ ._switcher_1klphaw_37{
235
235
  --_rs-color-primary:rgb(calc(var(--_rs-theme-light-coefficient, 1)*107 + var(--_rs-theme-dark-coefficient, 0)*132), calc(var(--_rs-theme-light-coefficient, 1)*87 + var(--_rs-theme-dark-coefficient, 0)*115), 255);
236
236
  --_rs-color-primary-dim:rgb(calc(var(--_rs-theme-light-coefficient, 1)*137 + var(--_rs-theme-dark-coefficient, 0)*111), calc(var(--_rs-theme-light-coefficient, 1)*121 + var(--_rs-theme-dark-coefficient, 0)*97), calc(var(--_rs-theme-light-coefficient, 1)*255 + var(--_rs-theme-dark-coefficient, 0)*210));
237
237
  --_rs-color-primary-fog:rgb(calc(var(--_rs-theme-light-coefficient, 1)*225 + var(--_rs-theme-dark-coefficient, 0)*46), calc(var(--_rs-theme-light-coefficient, 1)*221 + var(--_rs-theme-dark-coefficient, 0)*43), calc(var(--_rs-theme-light-coefficient, 1)*255 + var(--_rs-theme-dark-coefficient, 0)*73));
@@ -239,19 +239,13 @@
239
239
  --_rs-color-primary-t-fog:rgba(calc(var(--_rs-theme-light-coefficient, 1)*107 + var(--_rs-theme-dark-coefficient, 0)*132), calc(var(--_rs-theme-light-coefficient, 1)*87 + var(--_rs-theme-dark-coefficient, 0)*115), 255, calc(var(--_rs-theme-light-coefficient, 1)*0.2 + var(--_rs-theme-dark-coefficient, 0)*0.3));
240
240
  }
241
241
  }
242
- ._switcher_1i5u8r0_37 {
242
+ ._switcher_1klphaw_37 {
243
243
 
244
244
  position:relative;
245
245
 
246
- display:-webkit-inline-box;
247
-
248
- display:-ms-inline-flexbox;
249
-
250
246
  display:inline-flex;
251
247
 
252
- -webkit-box-sizing:border-box;
253
-
254
- box-sizing:border-box;
248
+ box-sizing:border-box;
255
249
 
256
250
  border-radius:var(
257
251
  --_rs-switcher-border-radius-from-compact,
@@ -259,20 +253,18 @@
259
253
  );
260
254
 
261
255
  background:transparent;
262
- -webkit-box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.3) 0 0 0 1px;
263
- box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.3) 0 0 0 1px;
256
+ box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.3) 0 0 0 1px;
264
257
  }
265
- ._switcher_1i5u8r0_37._disabled_1i5u8r0_55{
266
- -webkit-box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2) 0 0 0 1px;
267
- box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2) 0 0 0 1px;
258
+ ._switcher_1klphaw_37._disabled_1klphaw_55{
259
+ box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2) 0 0 0 1px;
268
260
  }
269
- ._alignIconLeft_1i5u8r0_60{
261
+ ._alignIconLeft_1klphaw_60{
270
262
  --_rs-switcher-option-flex-direction:row;
271
263
  }
272
- ._alignIconRight_1i5u8r0_63{
264
+ ._alignIconRight_1klphaw_63{
273
265
  --_rs-switcher-option-flex-direction:row-reverse;
274
266
  }
275
- ._option_1i5u8r0_67{
267
+ ._option_1klphaw_67{
276
268
  letter-spacing:var(
277
269
  --rs-text-base-letter-spacing,
278
270
  var(--_rs-typography-letter-spacing)
@@ -283,7 +275,6 @@
283
275
  font-weight:var(--_rs-typography-font-weight);
284
276
  line-height:var(--_rs-typography-line-height);
285
277
  font-variant-numeric:var(--_rs-typography-font-variant-numeric);
286
- -webkit-font-feature-settings:'kern', 'liga', 'calt';
287
278
  font-feature-settings:'kern', 'liga', 'calt';
288
279
  color:var(
289
280
  --rs-color-hard,
@@ -293,32 +284,17 @@
293
284
  position:relative;
294
285
  z-index:1;
295
286
 
296
- display:-webkit-inline-box;
297
-
298
- display:-ms-inline-flexbox;
299
-
300
287
  display:inline-flex;
301
- -webkit-box-flex:1;
302
- -ms-flex:1 1 auto;
303
- flex:1 1 auto;
304
- -webkit-box-orient:vertical;
305
- -webkit-box-direction:normal;
306
- -ms-flex-direction:var(--_rs-switcher-option-flex-direction);
307
- flex-direction:var(--_rs-switcher-option-flex-direction);
308
- -webkit-box-pack:center;
309
- -ms-flex-pack:center;
310
- justify-content:center;
311
- -webkit-box-align:start;
312
- -ms-flex-align:start;
313
- align-items:flex-start;
288
+ flex:1 1 auto;
289
+ flex-direction:var(--_rs-switcher-option-flex-direction);
290
+ justify-content:center;
291
+ align-items:flex-start;
314
292
  gap:var(
315
293
  --_rs-switcher-icon-offset-from-compact,
316
294
  var(--_rs-switcher-icon-offset)
317
295
  );
318
296
 
319
- -webkit-box-sizing:border-box;
320
-
321
- box-sizing:border-box;
297
+ box-sizing:border-box;
322
298
  margin:0;
323
299
  padding:var(
324
300
  --_rs-switcher-option-padding-from-compact,
@@ -339,28 +315,27 @@
339
315
  -moz-appearance:none;
340
316
  appearance:none;
341
317
  }
342
- ._disabled_1i5u8r0_55 ._option_1i5u8r0_67{
318
+ ._disabled_1klphaw_55 ._option_1klphaw_67{
343
319
  cursor:not-allowed;
344
320
  pointer-events:none;
345
321
  }
346
- ._option_1i5u8r0_67:focus[data-focus-method='key']{
347
- -webkit-box-shadow:var(--_rs-color-primary-t-dim) 0 0 0 4px;
348
- box-shadow:var(--_rs-color-primary-t-dim) 0 0 0 4px;
322
+ ._option_1klphaw_67:focus[data-focus-method='key']{
323
+ box-shadow:var(--_rs-color-primary-t-dim) 0 0 0 4px;
349
324
  }
350
325
  @media (hover: hover){
351
- ._option_1i5u8r0_67:hover{
326
+ ._option_1klphaw_67:hover{
352
327
  background:var(--_rs-switcher-option-hover-background);
353
328
  }
354
329
  }
355
- ._option_1i5u8r0_67._selected_1i5u8r0_118:active{
330
+ ._option_1klphaw_67._selected_1klphaw_118:active{
356
331
  background:transparent;
357
332
  }
358
- ._option_1i5u8r0_67._selected_1i5u8r0_118:hover,
359
- ._option_1i5u8r0_67._selected_1i5u8r0_118:active{
333
+ ._option_1klphaw_67._selected_1klphaw_118:hover,
334
+ ._option_1klphaw_67._selected_1klphaw_118:active{
360
335
  cursor:default;
361
336
  }
362
- ._disabled_1i5u8r0_55 ._option_1i5u8r0_67,
363
- ._disabled_1i5u8r0_55 ._option_1i5u8r0_67._selected_1i5u8r0_118{
337
+ ._disabled_1klphaw_55 ._option_1klphaw_67,
338
+ ._disabled_1klphaw_55 ._option_1klphaw_67._selected_1klphaw_118{
364
339
  color:var(
365
340
  --rs-color-pale,
366
341
  rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.5)
@@ -370,10 +345,8 @@
370
345
 
371
346
  background:transparent;
372
347
  }
373
- ._option_1i5u8r0_67 ._icon_1i5u8r0_137{
374
- -webkit-box-flex:0;
375
- -ms-flex:0 0 auto;
376
- flex:0 0 auto;
348
+ ._option_1klphaw_67 ._icon_1klphaw_137{
349
+ flex:0 0 auto;
377
350
 
378
351
  width:auto;
379
352
  height:var(--_rs-switcher-icon-size);
@@ -383,16 +356,14 @@
383
356
  margin-top:var(--_rs-switcher-icon-margin-vertical);
384
357
  margin-bottom:var(--_rs-switcher-icon-margin-vertical);
385
358
  }
386
- ._mark_1i5u8r0_150{
359
+ ._mark_1klphaw_150{
387
360
  position:absolute;
388
361
  top:0;
389
362
  bottom:0;
390
363
 
391
364
  display:inline-block;
392
365
 
393
- -webkit-box-sizing:border-box;
394
-
395
- box-sizing:border-box;
366
+ box-sizing:border-box;
396
367
 
397
368
  border:solid 2px var(--_rs-switcher-mark-border-color);
398
369
 
@@ -401,21 +372,19 @@
401
372
  var(--_rs-switcher-border-radius)
402
373
  );
403
374
 
404
- -webkit-transition:all 0.2s;
405
-
406
375
  transition:all 0.2s;
407
376
  }
408
- ._disabled_1i5u8r0_55 ._mark_1i5u8r0_150{
377
+ ._disabled_1klphaw_55 ._mark_1klphaw_150{
409
378
  border-color:rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2);
410
379
  }
411
380
 
412
- ._themeLight_el1i9h_6{
381
+ ._themeLight_8ywtgh_6{
413
382
  --rs-theme-dark:0;
414
383
  }
415
- ._themeDark_el1i9h_9{
384
+ ._themeDark_8ywtgh_9{
416
385
  --rs-theme-dark:1;
417
386
  }
418
- ._sizeXS_el1i9h_13{
387
+ ._sizeXS_8ywtgh_13{
419
388
  --_rs-switcher-vertical-border-radius:4px;
420
389
  --_rs-switcher-vertical-option-vertical-padding:2px;
421
390
  --_rs-switcher-vertical-option-horizontal-padding:8px;
@@ -423,7 +392,7 @@
423
392
  --_rs-switcher-vertical-icon-offset:4px;
424
393
  --_rs-switcher-vertical-icon-margin-vertical:2px;
425
394
  }
426
- ._sizeXS_el1i9h_13 [data-rs-internal='vertical-switcher__option']{
395
+ ._sizeXS_8ywtgh_13 [data-rs-internal='vertical-switcher__option']{
427
396
  --_rs-typography-letter-spacing:0.0045em;
428
397
  --_rs-typography-text-transform:initial;
429
398
  --_rs-typography-font-variant-numeric:initial;
@@ -457,7 +426,7 @@
457
426
  --_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
458
427
  --_rs-typography-link-border-bottom-width-from-text:1px;
459
428
  }
460
- ._sizeS_el1i9h_16{
429
+ ._sizeS_8ywtgh_16{
461
430
  --_rs-switcher-vertical-border-radius:4px;
462
431
  --_rs-switcher-vertical-option-vertical-padding:6px;
463
432
  --_rs-switcher-vertical-option-horizontal-padding:12px;
@@ -465,7 +434,7 @@
465
434
  --_rs-switcher-vertical-icon-offset:4px;
466
435
  --_rs-switcher-vertical-icon-margin-vertical:0px;
467
436
  }
468
- ._sizeS_el1i9h_16 [data-rs-internal='vertical-switcher__option']{
437
+ ._sizeS_8ywtgh_16 [data-rs-internal='vertical-switcher__option']{
469
438
  --_rs-typography-letter-spacing:0.0045em;
470
439
  --_rs-typography-text-transform:initial;
471
440
  --_rs-typography-font-variant-numeric:initial;
@@ -499,7 +468,7 @@
499
468
  --_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
500
469
  --_rs-typography-link-border-bottom-width-from-text:1px;
501
470
  }
502
- ._sizeM_el1i9h_19{
471
+ ._sizeM_8ywtgh_19{
503
472
  --_rs-switcher-vertical-border-radius:8px;
504
473
  --_rs-switcher-vertical-option-vertical-padding:8px;
505
474
  --_rs-switcher-vertical-option-horizontal-padding:16px;
@@ -507,7 +476,7 @@
507
476
  --_rs-switcher-vertical-icon-offset:8px;
508
477
  --_rs-switcher-vertical-icon-margin-vertical:0px;
509
478
  }
510
- ._sizeM_el1i9h_19 [data-rs-internal='vertical-switcher__option']{
479
+ ._sizeM_8ywtgh_19 [data-rs-internal='vertical-switcher__option']{
511
480
  --_rs-typography-letter-spacing:0.0015em;
512
481
  --_rs-typography-text-transform:initial;
513
482
  --_rs-typography-font-variant-numeric:initial;
@@ -542,11 +511,11 @@
542
511
  --_rs-typography-link-border-bottom-width-from-text:1px;
543
512
  }
544
513
  @media screen and (max-width: 640px){
545
- ._sizeM_el1i9h_19 [data-rs-internal='vertical-switcher__option']{
514
+ ._sizeM_8ywtgh_19 [data-rs-internal='vertical-switcher__option']{
546
515
  --_rs-typography-list-li-margin-top-from-text:12px;
547
516
  }
548
517
  }
549
- ._sizeL_el1i9h_22{
518
+ ._sizeL_8ywtgh_22{
550
519
  --_rs-switcher-vertical-border-radius:12px;
551
520
  --_rs-switcher-vertical-option-vertical-padding:12px;
552
521
  --_rs-switcher-vertical-option-horizontal-padding:24px;
@@ -554,7 +523,7 @@
554
523
  --_rs-switcher-vertical-icon-offset:12px;
555
524
  --_rs-switcher-vertical-icon-margin-vertical:0px;
556
525
  }
557
- ._sizeL_el1i9h_22 [data-rs-internal='vertical-switcher__option']{
526
+ ._sizeL_8ywtgh_22 [data-rs-internal='vertical-switcher__option']{
558
527
  --_rs-typography-letter-spacing:normal;
559
528
  --_rs-typography-text-transform:initial;
560
529
  --_rs-typography-font-variant-numeric:initial;
@@ -589,17 +558,17 @@
589
558
  --_rs-typography-link-border-bottom-width-from-text:1px;
590
559
  }
591
560
  @media screen and (max-width: 640px){
592
- ._sizeL_el1i9h_22 [data-rs-internal='vertical-switcher__option']{
561
+ ._sizeL_8ywtgh_22 [data-rs-internal='vertical-switcher__option']{
593
562
  --_rs-typography-list-li-margin-top-from-text:16px;
594
563
  }
595
564
  }
596
- ._modeClassic_el1i9h_26{
565
+ ._modeClassic_8ywtgh_26{
597
566
  --_rs-switcher-vertical-option-hover-background:var(
598
567
  --_rs-color-primary-t-fog
599
568
  );
600
569
  --_rs-switcher-vertical-mark-border-color:var(--_rs-color-primary);
601
570
  }
602
- ._modeRock_el1i9h_29{
571
+ ._modeRock_8ywtgh_29{
603
572
  --_rs-switcher-vertical-option-hover-background:rgba(
604
573
  calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227),
605
574
  0.1
@@ -608,7 +577,7 @@
608
577
  calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227)
609
578
  );
610
579
  }
611
- ._verticalSwitcher_el1i9h_33{
580
+ ._verticalSwitcher_8ywtgh_33{
612
581
  --_rs-theme-dark:var(
613
582
  --_rs-internal-force-theme-dark-consult-rescui-before-using,
614
583
  var(--rs-theme-dark, 0)
@@ -618,7 +587,7 @@
618
587
  --_rs-theme-light-coefficient:calc(1 - var(--_rs-theme-dark-coefficient));
619
588
  }
620
589
  @supports (color: color-mix(in srgb, #fff 50%, #000 50%)){
621
- ._verticalSwitcher_el1i9h_33{
590
+ ._verticalSwitcher_8ywtgh_33{
622
591
  --_rs-color-primary:color-mix(in srgb, var(--rs-color-primary-light-theme, #6B57FF) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-dark-theme, #8473FF) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
623
592
  --_rs-color-primary-dim:color-mix(in srgb, var(--rs-color-primary-dim-light-theme, #8979ff) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-dim-dark-theme, #6f61d2) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
624
593
  --_rs-color-primary-fog:color-mix(in srgb, var(--rs-color-primary-fog-light-theme, #e1ddff) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-fog-dark-theme, #2e2b49) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
@@ -627,7 +596,7 @@
627
596
  }
628
597
  }
629
598
  @supports not (color: color-mix(in srgb, #fff 50%, #000 50%)){
630
- ._verticalSwitcher_el1i9h_33{
599
+ ._verticalSwitcher_8ywtgh_33{
631
600
  --_rs-color-primary:rgb(calc(var(--_rs-theme-light-coefficient, 1)*107 + var(--_rs-theme-dark-coefficient, 0)*132), calc(var(--_rs-theme-light-coefficient, 1)*87 + var(--_rs-theme-dark-coefficient, 0)*115), 255);
632
601
  --_rs-color-primary-dim:rgb(calc(var(--_rs-theme-light-coefficient, 1)*137 + var(--_rs-theme-dark-coefficient, 0)*111), calc(var(--_rs-theme-light-coefficient, 1)*121 + var(--_rs-theme-dark-coefficient, 0)*97), calc(var(--_rs-theme-light-coefficient, 1)*255 + var(--_rs-theme-dark-coefficient, 0)*210));
633
602
  --_rs-color-primary-fog:rgb(calc(var(--_rs-theme-light-coefficient, 1)*225 + var(--_rs-theme-dark-coefficient, 0)*46), calc(var(--_rs-theme-light-coefficient, 1)*221 + var(--_rs-theme-dark-coefficient, 0)*43), calc(var(--_rs-theme-light-coefficient, 1)*255 + var(--_rs-theme-dark-coefficient, 0)*73));
@@ -635,44 +604,31 @@
635
604
  --_rs-color-primary-t-fog:rgba(calc(var(--_rs-theme-light-coefficient, 1)*107 + var(--_rs-theme-dark-coefficient, 0)*132), calc(var(--_rs-theme-light-coefficient, 1)*87 + var(--_rs-theme-dark-coefficient, 0)*115), 255, calc(var(--_rs-theme-light-coefficient, 1)*0.2 + var(--_rs-theme-dark-coefficient, 0)*0.3));
636
605
  }
637
606
  }
638
- ._verticalSwitcher_el1i9h_33 {
607
+ ._verticalSwitcher_8ywtgh_33 {
639
608
 
640
609
  position:relative;
641
610
 
642
- display:-webkit-inline-box;
643
-
644
- display:-ms-inline-flexbox;
645
-
646
611
  display:inline-flex;
647
- -webkit-box-orient:vertical;
648
- -webkit-box-direction:normal;
649
- -ms-flex-direction:column;
650
- flex-direction:column;
651
- -webkit-box-align:start;
652
- -ms-flex-align:start;
653
- align-items:flex-start;
612
+ flex-direction:column;
613
+ align-items:flex-start;
654
614
 
655
- -webkit-box-sizing:border-box;
656
-
657
- box-sizing:border-box;
615
+ box-sizing:border-box;
658
616
 
659
617
  border-radius:var(--_rs-switcher-vertical-border-radius);
660
618
 
661
619
  background:transparent;
662
- -webkit-box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.3) 0 0 0 1px;
663
- box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.3) 0 0 0 1px;
620
+ box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.3) 0 0 0 1px;
664
621
  }
665
- ._verticalSwitcher_el1i9h_33._disabled_el1i9h_50{
666
- -webkit-box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2) 0 0 0 1px;
667
- box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2) 0 0 0 1px;
622
+ ._verticalSwitcher_8ywtgh_33._disabled_8ywtgh_50{
623
+ box-shadow:inset rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2) 0 0 0 1px;
668
624
  }
669
- ._alignIconLeft_el1i9h_55{
625
+ ._alignIconLeft_8ywtgh_55{
670
626
  --_rs-switcher-vertical-option-flex-direction:row;
671
627
  }
672
- ._alignIconRight_el1i9h_58{
628
+ ._alignIconRight_8ywtgh_58{
673
629
  --_rs-switcher-vertical-option-flex-direction:row-reverse;
674
630
  }
675
- ._option_el1i9h_62{
631
+ ._option_8ywtgh_62{
676
632
  letter-spacing:var(
677
633
  --rs-text-base-letter-spacing,
678
634
  var(--_rs-typography-letter-spacing)
@@ -683,7 +639,6 @@
683
639
  font-weight:var(--_rs-typography-font-weight);
684
640
  line-height:var(--_rs-typography-line-height);
685
641
  font-variant-numeric:var(--_rs-typography-font-variant-numeric);
686
- -webkit-font-feature-settings:'kern', 'liga', 'calt';
687
642
  font-feature-settings:'kern', 'liga', 'calt';
688
643
  color:var(
689
644
  --rs-color-hard,
@@ -693,30 +648,14 @@
693
648
  position:relative;
694
649
  z-index:1;
695
650
 
696
- display:-webkit-inline-box;
697
-
698
- display:-ms-inline-flexbox;
699
-
700
651
  display:inline-flex;
701
- -webkit-box-flex:1;
702
- -ms-flex:1 1 auto;
703
- flex:1 1 auto;
704
- -ms-flex-wrap:nowrap;
705
- flex-wrap:nowrap;
706
- -webkit-box-orient:vertical;
707
- -webkit-box-direction:normal;
708
- -ms-flex-direction:var(--_rs-switcher-vertical-option-flex-direction);
709
- flex-direction:var(--_rs-switcher-vertical-option-flex-direction);
710
- -webkit-box-pack:start;
711
- -ms-flex-pack:start;
712
- justify-content:flex-start;
713
- -webkit-box-align:start;
714
- -ms-flex-align:start;
715
- align-items:flex-start;
716
-
717
- -webkit-box-sizing:border-box;
718
-
719
- box-sizing:border-box;
652
+ flex:1 1 auto;
653
+ flex-wrap:nowrap;
654
+ flex-direction:var(--_rs-switcher-vertical-option-flex-direction);
655
+ justify-content:flex-start;
656
+ align-items:flex-start;
657
+
658
+ box-sizing:border-box;
720
659
  width:100%;
721
660
  margin:0;
722
661
  padding:var(--_rs-switcher-vertical-option-vertical-padding) var(--_rs-switcher-vertical-option-horizontal-padding);
@@ -733,28 +672,27 @@
733
672
  -moz-appearance:none;
734
673
  appearance:none;
735
674
  }
736
- ._disabled_el1i9h_50 ._option_el1i9h_62{
675
+ ._disabled_8ywtgh_50 ._option_8ywtgh_62{
737
676
  cursor:not-allowed;
738
677
  pointer-events:none;
739
678
  }
740
- ._option_el1i9h_62:focus[data-focus-method='key']{
741
- -webkit-box-shadow:var(--_rs-color-primary-t-dim) 0 0 0 4px;
742
- box-shadow:var(--_rs-color-primary-t-dim) 0 0 0 4px;
679
+ ._option_8ywtgh_62:focus[data-focus-method='key']{
680
+ box-shadow:var(--_rs-color-primary-t-dim) 0 0 0 4px;
743
681
  }
744
682
  @media (hover: hover){
745
- ._option_el1i9h_62:hover{
683
+ ._option_8ywtgh_62:hover{
746
684
  background:var(--_rs-switcher-vertical-option-hover-background);
747
685
  }
748
686
  }
749
- ._option_el1i9h_62._selected_el1i9h_107:active{
687
+ ._option_8ywtgh_62._selected_8ywtgh_107:active{
750
688
  background:transparent;
751
689
  }
752
- ._option_el1i9h_62._selected_el1i9h_107:hover,
753
- ._option_el1i9h_62._selected_el1i9h_107:active{
690
+ ._option_8ywtgh_62._selected_8ywtgh_107:hover,
691
+ ._option_8ywtgh_62._selected_8ywtgh_107:active{
754
692
  cursor:default;
755
693
  }
756
- ._disabled_el1i9h_50 ._option_el1i9h_62,
757
- ._disabled_el1i9h_50 ._option_el1i9h_62._selected_el1i9h_107{
694
+ ._disabled_8ywtgh_50 ._option_8ywtgh_62,
695
+ ._disabled_8ywtgh_50 ._option_8ywtgh_62._selected_8ywtgh_107{
758
696
  color:var(
759
697
  --rs-color-pale,
760
698
  rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.5)
@@ -764,17 +702,13 @@
764
702
 
765
703
  background:transparent;
766
704
  }
767
- ._option_el1i9h_62 ._optionLabel_el1i9h_126{
768
- -webkit-box-flex:1;
769
- -ms-flex:1 1 auto;
770
- flex:1 1 auto;
705
+ ._option_8ywtgh_62 ._optionLabel_8ywtgh_126{
706
+ flex:1 1 auto;
771
707
 
772
708
  text-align:left;
773
709
  }
774
- ._option_el1i9h_62 ._icon_el1i9h_132{
775
- -webkit-box-flex:0;
776
- -ms-flex:0 0 auto;
777
- flex:0 0 auto;
710
+ ._option_8ywtgh_62 ._icon_8ywtgh_132{
711
+ flex:0 0 auto;
778
712
 
779
713
  width:auto;
780
714
  height:var(--_rs-switcher-vertical-icon-size);
@@ -784,30 +718,26 @@
784
718
 
785
719
  fill:currentColor;
786
720
  }
787
- ._option_el1i9h_62 ._fakeIcon_el1i9h_143{
721
+ ._option_8ywtgh_62 ._fakeIcon_8ywtgh_143{
788
722
  display:inline-block;
789
723
 
790
724
  width:var(--_rs-switcher-vertical-icon-size);
791
725
  }
792
- ._mark_el1i9h_150{
726
+ ._mark_8ywtgh_150{
793
727
  position:absolute;
794
728
  right:0;
795
729
  left:0;
796
730
 
797
731
  display:inline-block;
798
732
 
799
- -webkit-box-sizing:border-box;
800
-
801
- box-sizing:border-box;
733
+ box-sizing:border-box;
802
734
 
803
735
  border:solid 2px var(--_rs-switcher-vertical-mark-border-color);
804
736
 
805
737
  border-radius:var(--_rs-switcher-vertical-border-radius);
806
738
 
807
- -webkit-transition:all 0.2s;
808
-
809
739
  transition:all 0.2s;
810
740
  }
811
- ._disabled_el1i9h_50 ._mark_el1i9h_150{
741
+ ._disabled_8ywtgh_50 ._mark_8ywtgh_150{
812
742
  border-color:rgba(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227), 0.2);
813
743
  }
package/lib/index.js CHANGED
@@ -6,5 +6,5 @@ export { VerticalSwitcher } from './vertical-switcher.js';
6
6
  * @deprecated use named import instead
7
7
  */
8
8
 
9
- var DefaultSwitcher = Switcher;
9
+ const DefaultSwitcher = Switcher;
10
10
  export { DefaultSwitcher as default };
package/lib/switcher.js CHANGED
@@ -1,48 +1,42 @@
1
- import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
2
- import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
3
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
1
  import React, { cloneElement, useRef, useCallback, useState, useEffect } from 'react';
5
2
  import PropTypes from 'prop-types';
6
3
  import cn from 'classnames';
7
4
  import { useThemeWithUndefined } from '@rescui/ui-contexts';
8
5
  import { useResizeObserver } from '@rescui/use-resize-observer';
9
6
  import styles from './switcher.p.module.css.js';
10
- var sizeToClass = {
7
+ const sizeToClass = {
11
8
  l: styles.sizeL,
12
9
  m: styles.sizeM,
13
10
  s: styles.sizeS,
14
11
  xs: styles.sizeXS
15
12
  };
16
- var themeToClass = {
13
+ const themeToClass = {
17
14
  light: styles.themeLight,
18
15
  dark: styles.themeDark
19
16
  };
20
- var modeToClass = {
17
+ const modeToClass = {
21
18
  classic: styles.modeClassic,
22
19
  rock: styles.modeRock
23
20
  };
24
21
 
25
- var findIndexByValue = function findIndexByValue(options, value) {
26
- var index = _findIndexInstanceProperty(options).call(options, function (option) {
27
- return option.value === value;
28
- });
29
-
22
+ const findIndexByValue = (options, value) => {
23
+ const index = options.findIndex(option => option.value === value);
30
24
  return index === -1 ? 0 : index;
31
25
  }; // check for ignored jsx values and empty string, more info https://reactjs.org/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored
32
26
 
33
27
 
34
- var isNodeEmpty = function isNodeEmpty(node) {
35
- return node === null || typeof node === 'undefined' || node === false || node === true || node === '';
36
- };
28
+ const isNodeEmpty = node => node === null || typeof node === 'undefined' || node === false || node === true || node === '';
37
29
 
38
- var optionRenderer = function optionRenderer(_ref, ref) {
39
- var label = _ref.label,
40
- value = _ref.value,
41
- icon = _ref.icon,
42
- disabled = _ref.disabled,
43
- onClick = _ref.onClick,
44
- selected = _ref.selected;
45
- var isWithoutText = isNodeEmpty(label);
30
+ const optionRenderer = (_ref, ref) => {
31
+ let {
32
+ label,
33
+ value,
34
+ icon,
35
+ disabled,
36
+ onClick,
37
+ selected
38
+ } = _ref;
39
+ const isWithoutText = isNodeEmpty(label);
46
40
  return /*#__PURE__*/React.createElement("button", {
47
41
  key: String(value),
48
42
  ref: ref,
@@ -56,57 +50,49 @@ var optionRenderer = function optionRenderer(_ref, ref) {
56
50
  }), !isWithoutText && /*#__PURE__*/React.createElement("span", null, label));
57
51
  };
58
52
 
59
- var Option = /*#__PURE__*/React.forwardRef(optionRenderer);
53
+ const Option = /*#__PURE__*/React.forwardRef(optionRenderer);
60
54
 
61
55
  function Switcher(_ref2) {
62
- var className = _ref2.className,
63
- themeFromProps = _ref2.theme,
64
- _ref2$size = _ref2.size,
65
- size = _ref2$size === void 0 ? 'm' : _ref2$size,
66
- disabled = _ref2.disabled,
67
- _ref2$compact = _ref2.compact,
68
- compact = _ref2$compact === void 0 ? false : _ref2$compact,
69
- e2eId = _ref2['data-e2e'],
70
- options = _ref2.options,
71
- switcherValue = _ref2.value,
72
- _ref2$mode = _ref2.mode,
73
- mode = _ref2$mode === void 0 ? 'classic' : _ref2$mode,
74
- _ref2$iconPosition = _ref2.iconPosition,
75
- iconPosition = _ref2$iconPosition === void 0 ? 'left' : _ref2$iconPosition,
76
- onChange = _ref2.onChange;
77
- var refsArray = useRef([]);
78
- var containerRef = useRef(null);
79
- var theme = useThemeWithUndefined(themeFromProps);
80
- var handleOptionRef = useCallback(function (index) {
81
- return function (ref) {
82
- if (!ref) {
83
- return;
84
- }
56
+ let {
57
+ className,
58
+ theme: themeFromProps,
59
+ size = 'm',
60
+ disabled,
61
+ compact = false,
62
+ ['data-e2e']: e2eId,
63
+ options,
64
+ value: switcherValue,
65
+ mode = 'classic',
66
+ iconPosition = 'left',
67
+ onChange
68
+ } = _ref2;
69
+ const refsArray = useRef([]);
70
+ const containerRef = useRef(null);
71
+ const theme = useThemeWithUndefined(themeFromProps);
72
+ const handleOptionRef = useCallback(index => ref => {
73
+ if (!ref) {
74
+ return;
75
+ }
85
76
 
86
- if (refsArray.current[index] !== ref) {
87
- refsArray.current[index] = ref;
88
- }
89
- };
77
+ if (refsArray.current[index] !== ref) {
78
+ refsArray.current[index] = ref;
79
+ }
90
80
  }, []);
91
- var activeIndex = findIndexByValue(options, switcherValue);
92
-
93
- var _useState = useState({
81
+ const activeIndex = findIndexByValue(options, switcherValue);
82
+ const [mark, setMark] = useState({
94
83
  offset: 0,
95
84
  width: 0
96
- }),
97
- _useState2 = _slicedToArray(_useState, 2),
98
- mark = _useState2[0],
99
- setMark = _useState2[1];
85
+ });
100
86
 
101
- var onResize = function onResize() {
102
- var activeEl = refsArray.current[activeIndex];
87
+ const onResize = () => {
88
+ const activeEl = refsArray.current[activeIndex];
103
89
 
104
90
  if (!activeEl) {
105
91
  return;
106
92
  }
107
93
 
108
- var activeElBox = activeEl.getBoundingClientRect();
109
- var parentBox = activeEl.parentElement.getBoundingClientRect();
94
+ const activeElBox = activeEl.getBoundingClientRect();
95
+ const parentBox = activeEl.parentElement.getBoundingClientRect();
110
96
  setMark({
111
97
  // standard activeEl.offsetLeft always return rounded value, so it does not suit us
112
98
  offset: activeElBox.left - parentBox.left,
@@ -115,31 +101,29 @@ function Switcher(_ref2) {
115
101
  }; // eslint-disable-next-line react-hooks/exhaustive-deps
116
102
 
117
103
 
118
- useEffect(function () {
119
- return onResize();
120
- }, [activeIndex]);
104
+ useEffect(() => onResize(), [activeIndex]);
121
105
  useResizeObserver(containerRef, onResize);
122
106
  return /*#__PURE__*/React.createElement("span", {
123
107
  className: cn(className, styles.switcher, sizeToClass[size], themeToClass[theme], modeToClass[mode], disabled && styles.disabled, compact && styles.compact, iconPosition === 'right' ? styles.alignIconRight : styles.alignIconLeft),
124
108
  "data-e2e": e2eId,
125
109
  ref: containerRef,
126
110
  "data-rs-internal": 'switcher',
127
- "data-test": cn("switcher", disabled && "switcher-disabled")
128
- }, _mapInstanceProperty(options).call(options, function (_ref3, index) {
111
+ "data-test": cn(`switcher`, disabled && `switcher-disabled`)
112
+ }, options.map((_ref3, index) => {
129
113
  var _options$activeIndex;
130
114
 
131
- var value = _ref3.value,
132
- label = _ref3.label,
133
- icon = _ref3.icon;
115
+ let {
116
+ value,
117
+ label,
118
+ icon
119
+ } = _ref3;
134
120
  return /*#__PURE__*/React.createElement(Option, {
135
121
  key: String(value),
136
122
  value: value,
137
123
  label: label,
138
124
  icon: icon,
139
125
  disabled: disabled,
140
- onClick: function onClick() {
141
- return onChange(value);
142
- },
126
+ onClick: () => onChange(value),
143
127
  ref: handleOptionRef(index),
144
128
  selected: ((_options$activeIndex = options[activeIndex]) === null || _options$activeIndex === void 0 ? void 0 : _options$activeIndex.value) === value
145
129
  });
@@ -152,7 +136,7 @@ function Switcher(_ref2) {
152
136
  }));
153
137
  }
154
138
 
155
- var optionPropType = PropTypes.shape({
139
+ const optionPropType = PropTypes.shape({
156
140
  label: PropTypes.node,
157
141
  value: PropTypes.any.isRequired,
158
142
  icon: PropTypes.node
@@ -1,20 +1,20 @@
1
1
  var styles = {
2
- "themeLight": "_themeLight_1i5u8r0_6",
3
- "themeDark": "_themeDark_1i5u8r0_9",
4
- "sizeXS": "_sizeXS_1i5u8r0_13",
5
- "sizeS": "_sizeS_1i5u8r0_16",
6
- "sizeM": "_sizeM_1i5u8r0_19",
7
- "sizeL": "_sizeL_1i5u8r0_22",
8
- "modeClassic": "_modeClassic_1i5u8r0_26",
9
- "modeRock": "_modeRock_1i5u8r0_29",
10
- "compact": "_compact_1i5u8r0_33",
11
- "switcher": "_switcher_1i5u8r0_37",
12
- "disabled": "_disabled_1i5u8r0_55",
13
- "alignIconLeft": "_alignIconLeft_1i5u8r0_60",
14
- "alignIconRight": "_alignIconRight_1i5u8r0_63",
15
- "option": "_option_1i5u8r0_67",
16
- "selected": "_selected_1i5u8r0_118",
17
- "icon": "_icon_1i5u8r0_137",
18
- "mark": "_mark_1i5u8r0_150"
2
+ "themeLight": "_themeLight_1klphaw_6",
3
+ "themeDark": "_themeDark_1klphaw_9",
4
+ "sizeXS": "_sizeXS_1klphaw_13",
5
+ "sizeS": "_sizeS_1klphaw_16",
6
+ "sizeM": "_sizeM_1klphaw_19",
7
+ "sizeL": "_sizeL_1klphaw_22",
8
+ "modeClassic": "_modeClassic_1klphaw_26",
9
+ "modeRock": "_modeRock_1klphaw_29",
10
+ "compact": "_compact_1klphaw_33",
11
+ "switcher": "_switcher_1klphaw_37",
12
+ "disabled": "_disabled_1klphaw_55",
13
+ "alignIconLeft": "_alignIconLeft_1klphaw_60",
14
+ "alignIconRight": "_alignIconRight_1klphaw_63",
15
+ "option": "_option_1klphaw_67",
16
+ "selected": "_selected_1klphaw_118",
17
+ "icon": "_icon_1klphaw_137",
18
+ "mark": "_mark_1klphaw_150"
19
19
  };
20
20
  export { styles as default };
@@ -1,19 +1,3 @@
1
- import "core-js/modules/es.function.name.js";
2
- import "core-js/modules/es.regexp.exec.js";
3
- import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
4
- import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
5
- import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
6
- import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
7
- import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
8
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
- import "core-js/modules/es.object.to-string.js";
10
-
11
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
12
-
13
- function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
-
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
-
17
1
  import React, { createContext, useRef, useCallback, useState, useEffect, useContext, cloneElement } from 'react';
18
2
  import PropTypes from 'prop-types';
19
3
  import cn from 'classnames';
@@ -21,73 +5,61 @@ import { useThemeWithUndefined } from '@rescui/ui-contexts';
21
5
  import { useResizeObserver } from '@rescui/use-resize-observer';
22
6
  import styles from './vertical-switcher.p.module.css.js'; // eslint-disable-next-line @typescript-eslint/no-empty-function
23
7
 
24
- var noop = function noop() {};
8
+ const noop = () => {};
25
9
 
26
- var verticalSwitcherContext = /*#__PURE__*/createContext({
10
+ const verticalSwitcherContext = /*#__PURE__*/createContext({
27
11
  switcherValue: null,
28
12
  onChange: noop,
29
- handleOptionRef: function handleOptionRef() {
30
- return noop;
31
- },
13
+ handleOptionRef: () => noop,
32
14
  disabled: null
33
15
  });
34
- var sizeToClass = {
16
+ const sizeToClass = {
35
17
  l: styles.sizeL,
36
18
  m: styles.sizeM,
37
19
  s: styles.sizeS,
38
20
  xs: styles.sizeXS
39
21
  };
40
- var themeToClass = {
22
+ const themeToClass = {
41
23
  light: styles.themeLight,
42
24
  dark: styles.themeDark
43
25
  };
44
- var modeToClass = {
26
+ const modeToClass = {
45
27
  classic: styles.modeClassic,
46
28
  rock: styles.modeRock
47
29
  }; // eslint-disable-next-line complexity
48
30
 
49
- var processOptions = function processOptions(_ref) {
50
- var _foundIndexByValue;
51
-
52
- var rawOptions = _ref.rawOptions,
53
- value = _ref.value,
54
- iconPosition = _ref.iconPosition;
55
- var options = [];
56
- var foundIndexByValue = null;
57
- var currentIndex = 0;
58
- var withLeftIcons = false;
59
-
60
- var _iterator = _createForOfIteratorHelper(rawOptions),
61
- _step;
62
-
63
- try {
64
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
65
- var option = _step.value;
66
- options.push({
67
- label: option.label,
68
- value: option.value,
69
- icon: option.icon
70
- });
31
+ const processOptions = _ref => {
32
+ let {
33
+ rawOptions,
34
+ value,
35
+ iconPosition
36
+ } = _ref;
37
+ const options = [];
38
+ let foundIndexByValue = null;
39
+ let currentIndex = 0;
40
+ let withLeftIcons = false;
41
+
42
+ for (const option of rawOptions) {
43
+ options.push({
44
+ label: option.label,
45
+ value: option.value,
46
+ icon: option.icon
47
+ });
71
48
 
72
- if ( /*#__PURE__*/React.isValidElement(option.icon) && iconPosition === 'left') {
73
- withLeftIcons = true;
74
- }
49
+ if ( /*#__PURE__*/React.isValidElement(option.icon) && iconPosition === 'left') {
50
+ withLeftIcons = true;
51
+ }
75
52
 
76
- if (option.value === value && foundIndexByValue === null) {
77
- foundIndexByValue = currentIndex;
78
- }
53
+ if (option.value === value && foundIndexByValue === null) {
54
+ foundIndexByValue = currentIndex;
55
+ }
79
56
 
80
- currentIndex++;
81
- } // If some options on the first depth level have icons, we should align all other options accordingly
57
+ currentIndex++;
58
+ } // If some options on the first depth level have icons, we should align all other options accordingly
82
59
 
83
- } catch (err) {
84
- _iterator.e(err);
85
- } finally {
86
- _iterator.f();
87
- }
88
60
 
89
61
  if (withLeftIcons) {
90
- options.forEach(function (option) {
62
+ options.forEach(option => {
91
63
  if (! /*#__PURE__*/React.isValidElement(option.icon)) {
92
64
  option.icon = /*#__PURE__*/React.createElement("span", {
93
65
  className: styles.fakeIcon
@@ -97,41 +69,38 @@ var processOptions = function processOptions(_ref) {
97
69
  }
98
70
 
99
71
  return {
100
- options: options,
101
- activeIndex: (_foundIndexByValue = foundIndexByValue) !== null && _foundIndexByValue !== void 0 ? _foundIndexByValue : 0
72
+ options,
73
+ activeIndex: foundIndexByValue ?? 0
102
74
  };
103
75
  }; // check for ignored jsx values and empty string, more info https://reactjs.org/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored
104
76
 
105
77
 
106
- var isNodeEmpty = function isNodeEmpty(node) {
107
- return node === null || typeof node === 'undefined' || node === false || node === true || node === '';
108
- };
78
+ const isNodeEmpty = node => node === null || typeof node === 'undefined' || node === false || node === true || node === '';
109
79
 
110
80
  function Option(_ref2) {
111
- var label = _ref2.label,
112
- value = _ref2.value,
113
- icon = _ref2.icon,
114
- index = _ref2.index;
115
-
116
- var _useContext = useContext(verticalSwitcherContext),
117
- switcherValue = _useContext.switcherValue,
118
- onChange = _useContext.onChange,
119
- handleOptionRef = _useContext.handleOptionRef,
120
- disabled = _useContext.disabled;
121
-
122
- var selected = switcherValue === value;
123
- var isWithoutText = isNodeEmpty(label);
81
+ let {
82
+ label,
83
+ value,
84
+ icon,
85
+ index
86
+ } = _ref2;
87
+ const {
88
+ switcherValue,
89
+ onChange,
90
+ handleOptionRef,
91
+ disabled
92
+ } = useContext(verticalSwitcherContext);
93
+ const selected = switcherValue === value;
94
+ const isWithoutText = isNodeEmpty(label);
124
95
  return /*#__PURE__*/React.createElement("button", {
125
96
  key: String(value),
126
97
  ref: handleOptionRef(index),
127
- onClick: function onClick() {
128
- return onChange(value);
129
- },
98
+ onClick: () => onChange(value),
130
99
  type: "button",
131
100
  "data-rs-internal": 'vertical-switcher__option',
132
101
  disabled: disabled,
133
102
  className: cn(styles.option, selected && styles.selected),
134
- "data-test": cn("vertical-switcher-option", selected && ' vertical-switcher-option-selected')
103
+ "data-test": cn(`vertical-switcher-option`, selected && ' vertical-switcher-option-selected')
135
104
  }, /*#__PURE__*/React.isValidElement(icon) && /*#__PURE__*/cloneElement(icon, {
136
105
  className: cn(icon.props.className, styles.icon)
137
106
  }), !isWithoutText && /*#__PURE__*/React.createElement("span", {
@@ -142,62 +111,54 @@ function Option(_ref2) {
142
111
  function VerticalSwitcher(_ref3) {
143
112
  var _options$activeIndex;
144
113
 
145
- var className = _ref3.className,
146
- themeFromProps = _ref3.theme,
147
- _ref3$size = _ref3.size,
148
- size = _ref3$size === void 0 ? 'm' : _ref3$size,
149
- disabled = _ref3.disabled,
150
- e2eId = _ref3['data-e2e'],
151
- rawOptions = _ref3.options,
152
- switcherValue = _ref3.value,
153
- _ref3$mode = _ref3.mode,
154
- mode = _ref3$mode === void 0 ? 'classic' : _ref3$mode,
155
- _ref3$iconPosition = _ref3.iconPosition,
156
- iconPosition = _ref3$iconPosition === void 0 ? 'left' : _ref3$iconPosition,
157
- onChange = _ref3.onChange,
158
- style = _ref3.style;
159
- var refsArray = useRef([]);
160
- var containerRef = useRef(null);
161
- var theme = useThemeWithUndefined(themeFromProps);
162
-
163
- var _processOptions = processOptions({
164
- rawOptions: rawOptions,
114
+ let {
115
+ className,
116
+ theme: themeFromProps,
117
+ size = 'm',
118
+ disabled,
119
+ ['data-e2e']: e2eId,
120
+ options: rawOptions,
165
121
  value: switcherValue,
166
- iconPosition: iconPosition
167
- }),
168
- options = _processOptions.options,
169
- activeIndex = _processOptions.activeIndex;
170
-
171
- var handleOptionRef = useCallback(function (index) {
172
- return function (ref) {
173
- if (!ref) {
174
- return;
175
- }
122
+ mode = 'classic',
123
+ iconPosition = 'left',
124
+ onChange,
125
+ style
126
+ } = _ref3;
127
+ const refsArray = useRef([]);
128
+ const containerRef = useRef(null);
129
+ const theme = useThemeWithUndefined(themeFromProps);
130
+ const {
131
+ options,
132
+ activeIndex
133
+ } = processOptions({
134
+ rawOptions,
135
+ value: switcherValue,
136
+ iconPosition
137
+ });
138
+ const handleOptionRef = useCallback(index => ref => {
139
+ if (!ref) {
140
+ return;
141
+ }
176
142
 
177
- if (refsArray.current[index] !== ref) {
178
- refsArray.current[index] = ref;
179
- }
180
- };
143
+ if (refsArray.current[index] !== ref) {
144
+ refsArray.current[index] = ref;
145
+ }
181
146
  }, []);
182
-
183
- var _useState = useState({
147
+ const [mark, setMark] = useState({
184
148
  offset: 0,
185
149
  height: 0
186
- }),
187
- _useState2 = _slicedToArray(_useState, 2),
188
- mark = _useState2[0],
189
- setMark = _useState2[1];
150
+ });
190
151
 
191
- var onResize = function onResize() {
192
- var activeEl = refsArray.current[activeIndex];
152
+ const onResize = () => {
153
+ const activeEl = refsArray.current[activeIndex];
193
154
 
194
155
  if (!activeEl) {
195
156
  return;
196
157
  }
197
158
 
198
- var parentEl = activeEl.parentElement;
199
- var activeElBox = activeEl.getBoundingClientRect();
200
- var parentBox = parentEl.getBoundingClientRect();
159
+ const parentEl = activeEl.parentElement;
160
+ const activeElBox = activeEl.getBoundingClientRect();
161
+ const parentBox = parentEl.getBoundingClientRect();
201
162
  setMark({
202
163
  // standard activeEl.offsetTop always return rounded value, so it does not suit us
203
164
  offset: activeElBox.top - parentBox.top + parentEl.scrollTop,
@@ -206,28 +167,28 @@ function VerticalSwitcher(_ref3) {
206
167
  }; // eslint-disable-next-line react-hooks/exhaustive-deps
207
168
 
208
169
 
209
- useEffect(function () {
210
- return onResize();
211
- }, [activeIndex]);
170
+ useEffect(() => onResize(), [activeIndex]);
212
171
  useResizeObserver(containerRef, onResize);
213
172
  return /*#__PURE__*/React.createElement("span", {
214
173
  className: cn(className, styles.verticalSwitcher, sizeToClass[size], themeToClass[theme], modeToClass[mode], disabled && styles.disabled, iconPosition === 'right' ? styles.alignIconRight : styles.alignIconLeft),
215
174
  "data-e2e": e2eId,
216
175
  ref: containerRef,
217
176
  "data-rs-internal": 'vertical-switcher',
218
- "data-test": cn("vertical-switcher", disabled && "vertical-switcher-disabled"),
177
+ "data-test": cn(`vertical-switcher`, disabled && `vertical-switcher-disabled`),
219
178
  style: style
220
179
  }, /*#__PURE__*/React.createElement(verticalSwitcherContext.Provider, {
221
180
  value: {
222
181
  switcherValue: (_options$activeIndex = options[activeIndex]) === null || _options$activeIndex === void 0 ? void 0 : _options$activeIndex.value,
223
- onChange: onChange,
224
- handleOptionRef: handleOptionRef,
225
- disabled: disabled
182
+ onChange,
183
+ handleOptionRef,
184
+ disabled
226
185
  }
227
- }, _mapInstanceProperty(options).call(options, function (_ref4, index) {
228
- var value = _ref4.value,
229
- label = _ref4.label,
230
- icon = _ref4.icon;
186
+ }, options.map((_ref4, index) => {
187
+ let {
188
+ value,
189
+ label,
190
+ icon
191
+ } = _ref4;
231
192
  return /*#__PURE__*/React.createElement(Option, {
232
193
  key: String(value),
233
194
  value: value,
@@ -244,7 +205,7 @@ function VerticalSwitcher(_ref3) {
244
205
  })));
245
206
  }
246
207
 
247
- var optionPropType = PropTypes.shape({
208
+ const optionPropType = PropTypes.shape({
248
209
  label: PropTypes.node,
249
210
  value: PropTypes.any.isRequired,
250
211
  icon: PropTypes.node
@@ -1,21 +1,21 @@
1
1
  var styles = {
2
- "themeLight": "_themeLight_el1i9h_6",
3
- "themeDark": "_themeDark_el1i9h_9",
4
- "sizeXS": "_sizeXS_el1i9h_13",
5
- "sizeS": "_sizeS_el1i9h_16",
6
- "sizeM": "_sizeM_el1i9h_19",
7
- "sizeL": "_sizeL_el1i9h_22",
8
- "modeClassic": "_modeClassic_el1i9h_26",
9
- "modeRock": "_modeRock_el1i9h_29",
10
- "verticalSwitcher": "_verticalSwitcher_el1i9h_33",
11
- "disabled": "_disabled_el1i9h_50",
12
- "alignIconLeft": "_alignIconLeft_el1i9h_55",
13
- "alignIconRight": "_alignIconRight_el1i9h_58",
14
- "option": "_option_el1i9h_62",
15
- "selected": "_selected_el1i9h_107",
16
- "optionLabel": "_optionLabel_el1i9h_126",
17
- "icon": "_icon_el1i9h_132",
18
- "fakeIcon": "_fakeIcon_el1i9h_143",
19
- "mark": "_mark_el1i9h_150"
2
+ "themeLight": "_themeLight_8ywtgh_6",
3
+ "themeDark": "_themeDark_8ywtgh_9",
4
+ "sizeXS": "_sizeXS_8ywtgh_13",
5
+ "sizeS": "_sizeS_8ywtgh_16",
6
+ "sizeM": "_sizeM_8ywtgh_19",
7
+ "sizeL": "_sizeL_8ywtgh_22",
8
+ "modeClassic": "_modeClassic_8ywtgh_26",
9
+ "modeRock": "_modeRock_8ywtgh_29",
10
+ "verticalSwitcher": "_verticalSwitcher_8ywtgh_33",
11
+ "disabled": "_disabled_8ywtgh_50",
12
+ "alignIconLeft": "_alignIconLeft_8ywtgh_55",
13
+ "alignIconRight": "_alignIconRight_8ywtgh_58",
14
+ "option": "_option_8ywtgh_62",
15
+ "selected": "_selected_8ywtgh_107",
16
+ "optionLabel": "_optionLabel_8ywtgh_126",
17
+ "icon": "_icon_8ywtgh_132",
18
+ "fakeIcon": "_fakeIcon_8ywtgh_143",
19
+ "mark": "_mark_8ywtgh_150"
20
20
  };
21
21
  export { styles as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rescui/switcher",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -15,10 +15,9 @@
15
15
  "access": "public"
16
16
  },
17
17
  "dependencies": {
18
- "@babel/runtime-corejs3": "^7.14.0",
19
- "@rescui/use-resize-observer": "^0.2.4",
20
- "classnames": "^2.2.6",
21
- "core-js": "^3.9.1"
18
+ "@babel/runtime-corejs3": "^7.26.0",
19
+ "@rescui/use-resize-observer": "^0.2.5",
20
+ "classnames": "^2.2.6"
22
21
  },
23
22
  "peerDependencies": {
24
23
  "@rescui/ui-contexts": "^0.5.0",
@@ -26,15 +25,15 @@
26
25
  "react": ">=16.8.0 <19"
27
26
  },
28
27
  "devDependencies": {
29
- "@rescui/colors": "^0.2.5",
30
- "@rescui/icons": "^0.16.11",
31
- "@rescui/scripts": "^0.3.4",
32
- "@rescui/typography": "^0.19.0"
28
+ "@rescui/colors": "^0.2.6",
29
+ "@rescui/icons": "^0.16.13",
30
+ "@rescui/scripts": "^0.3.5",
31
+ "@rescui/typography": "^0.20.0"
33
32
  },
34
33
  "scripts": {
35
34
  "build": "rescui-scripts build && yarn run build-pcss-api",
36
35
  "build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
37
36
  },
38
37
  "nx": {},
39
- "gitHead": "3ef429c66a082b71861a814ba508693c68a94842"
38
+ "gitHead": "5531e3d285d6e38bf5536ff0690a252f1308c49b"
40
39
  }