@rescui/menu 0.10.8 → 0.10.10
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 +47 -71
- package/lib/index.p.module.css.js +26 -26
- package/lib/menu.js +33 -53
- package/lib/parts/divider.js +13 -28
- package/lib/parts/group-header.js +12 -14
- package/lib/parts/menu-context.js +10 -13
- package/lib/parts/menu-item.js +51 -77
- package/lib/parts/navigation-utils.js +4 -12
- package/lib/parts/use-menu-keyboard-navigation.js +32 -52
- package/package.json +6 -7
package/lib/index.css
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
.
|
|
1
|
+
._themeLight_fxllk5_8{
|
|
2
2
|
--rs-theme-dark:0;
|
|
3
3
|
}
|
|
4
|
-
.
|
|
4
|
+
._themeDark_fxllk5_11{
|
|
5
5
|
--rs-theme-dark:1;
|
|
6
6
|
}
|
|
7
|
-
.
|
|
7
|
+
._sizeS_fxllk5_15{
|
|
8
8
|
--_rs-menu-mi-icon-offset:8px;
|
|
9
9
|
--_rs-menu-mi-vertical-padding:6px;
|
|
10
10
|
--_rs-menu-mi-horizontal-padding:8px;
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
--_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
|
|
42
42
|
--_rs-typography-link-border-bottom-width-from-text:1px;
|
|
43
43
|
}
|
|
44
|
-
.
|
|
44
|
+
._sizeM_fxllk5_18{
|
|
45
45
|
--_rs-menu-mi-icon-offset:8px;
|
|
46
46
|
--_rs-menu-mi-vertical-padding:8px;
|
|
47
47
|
--_rs-menu-mi-horizontal-padding:16px;
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
--_rs-typography-link-border-bottom-width-from-text:1px;
|
|
80
80
|
}
|
|
81
81
|
@media screen and (max-width: 640px){
|
|
82
|
-
.
|
|
82
|
+
._sizeM_fxllk5_18{
|
|
83
83
|
--_rs-typography-list-li-margin-top-from-text:12px;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
.
|
|
86
|
+
._sizeL_fxllk5_21{
|
|
87
87
|
--_rs-menu-mi-icon-offset:16px;
|
|
88
88
|
--_rs-menu-mi-vertical-padding:12px;
|
|
89
89
|
--_rs-menu-mi-horizontal-padding:16px;
|
|
@@ -121,11 +121,11 @@
|
|
|
121
121
|
--_rs-typography-link-border-bottom-width-from-text:1px;
|
|
122
122
|
}
|
|
123
123
|
@media screen and (max-width: 640px){
|
|
124
|
-
.
|
|
124
|
+
._sizeL_fxllk5_21{
|
|
125
125
|
--_rs-typography-list-li-margin-top-from-text:16px;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
.
|
|
128
|
+
._modeClassic_fxllk5_25{
|
|
129
129
|
--_rs-menu-mi-horizontal-padding-with-mode:var(
|
|
130
130
|
--_rs-menu-mi-horizontal-padding
|
|
131
131
|
);
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(51 + var(--_rs-theme-dark-coefficient, 0)*181)
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
|
-
.
|
|
142
|
+
._modeRock_fxllk5_28{
|
|
143
143
|
--_rs-menu-mi-horizontal-padding-with-mode:var(
|
|
144
144
|
--_rs-menu-mi-horizontal-padding
|
|
145
145
|
);
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(48 + var(--_rs-theme-dark-coefficient, 0)*184), calc(51 + var(--_rs-theme-dark-coefficient, 0)*181)
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
|
-
.
|
|
156
|
+
._modeClear_fxllk5_31{
|
|
157
157
|
--_rs-menu-mi-horizontal-padding-with-mode:0;
|
|
158
158
|
--_rs-menu-mi-active-background:none;
|
|
159
159
|
--_rs-menu-mi-selected-color:var(--_rs-color-primary);
|
|
@@ -166,15 +166,15 @@
|
|
|
166
166
|
0.1
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
|
-
.
|
|
169
|
+
._iconPlacementLeft_fxllk5_35{
|
|
170
170
|
--_rs-menu-mi-flex-direction:row;
|
|
171
171
|
--_rs-menu-mi-justify-content:initial;
|
|
172
172
|
}
|
|
173
|
-
.
|
|
173
|
+
._iconPlacementRight_fxllk5_39{
|
|
174
174
|
--_rs-menu-mi-flex-direction:row-reverse;
|
|
175
175
|
--_rs-menu-mi-justify-content:space-between;
|
|
176
176
|
}
|
|
177
|
-
.
|
|
177
|
+
._wrapper_fxllk5_43{
|
|
178
178
|
--_rs-theme-dark:var(
|
|
179
179
|
--_rs-internal-force-theme-dark-consult-rescui-before-using,
|
|
180
180
|
var(--rs-theme-dark, 0)
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
--_rs-theme-light-coefficient:calc(1 - var(--_rs-theme-dark-coefficient));
|
|
185
185
|
}
|
|
186
186
|
@supports (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
187
|
-
.
|
|
187
|
+
._wrapper_fxllk5_43{
|
|
188
188
|
--_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)));
|
|
189
189
|
--_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)));
|
|
190
190
|
--_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)));
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
@supports not (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
196
|
-
.
|
|
196
|
+
._wrapper_fxllk5_43{
|
|
197
197
|
--_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);
|
|
198
198
|
--_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));
|
|
199
199
|
--_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));
|
|
@@ -201,15 +201,11 @@
|
|
|
201
201
|
--_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));
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
.
|
|
205
|
-
|
|
206
|
-
display:-webkit-box;
|
|
207
|
-
|
|
208
|
-
display:-ms-flexbox;
|
|
204
|
+
._wrapper_fxllk5_43 {
|
|
209
205
|
|
|
210
206
|
display:flex;
|
|
211
207
|
}
|
|
212
|
-
.
|
|
208
|
+
._menuItem_fxllk5_50{
|
|
213
209
|
letter-spacing:var(
|
|
214
210
|
--rs-text-base-letter-spacing,
|
|
215
211
|
var(--_rs-typography-letter-spacing)
|
|
@@ -220,26 +216,14 @@
|
|
|
220
216
|
font-weight:var(--_rs-typography-font-weight);
|
|
221
217
|
line-height:var(--_rs-typography-line-height);
|
|
222
218
|
font-variant-numeric:var(--_rs-typography-font-variant-numeric);
|
|
223
|
-
-webkit-font-feature-settings:'kern', 'liga', 'calt';
|
|
224
219
|
font-feature-settings:'kern', 'liga', 'calt';
|
|
225
220
|
|
|
226
|
-
display:-webkit-box;
|
|
227
|
-
|
|
228
|
-
display:-ms-flexbox;
|
|
229
|
-
|
|
230
221
|
display:flex;
|
|
231
222
|
overflow:auto;
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
-ms-flex-direction:var(--_rs-menu-mi-flex-direction);
|
|
235
|
-
flex-direction:var(--_rs-menu-mi-flex-direction);
|
|
236
|
-
-webkit-box-flex:1;
|
|
237
|
-
-ms-flex-positive:1;
|
|
238
|
-
flex-grow:1;
|
|
223
|
+
flex-direction:var(--_rs-menu-mi-flex-direction);
|
|
224
|
+
flex-grow:1;
|
|
239
225
|
gap:var(--_rs-menu-mi-icon-offset);
|
|
240
|
-
-
|
|
241
|
-
-ms-flex-pack:var(--_rs-menu-mi-justify-content);
|
|
242
|
-
justify-content:var(--_rs-menu-mi-justify-content);
|
|
226
|
+
justify-content:var(--_rs-menu-mi-justify-content);
|
|
243
227
|
|
|
244
228
|
width:auto;
|
|
245
229
|
|
|
@@ -262,56 +246,49 @@
|
|
|
262
246
|
-webkit-font-smoothing:inherit;
|
|
263
247
|
-moz-osx-font-smoothing:inherit;
|
|
264
248
|
}
|
|
265
|
-
.
|
|
249
|
+
._menuItem_fxllk5_50:focus{
|
|
266
250
|
outline:none;
|
|
267
251
|
}
|
|
268
|
-
.
|
|
269
|
-
|
|
270
|
-
box-shadow:0 0 0 2px var(--_rs-color-primary-dim), inset 0 0 0 2px var(--_rs-color-primary-dim);
|
|
252
|
+
._keyboardNavigationDisabled_fxllk5_85 ._menuItem_fxllk5_50:focus[data-focus-method='key']{
|
|
253
|
+
box-shadow:0 0 0 2px var(--_rs-color-primary-dim), inset 0 0 0 2px var(--_rs-color-primary-dim);
|
|
271
254
|
}
|
|
272
|
-
.
|
|
255
|
+
._menuItem_fxllk5_50:active{
|
|
273
256
|
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));
|
|
274
257
|
background:var(--_rs-menu-mi-active-background);
|
|
275
258
|
}
|
|
276
|
-
.
|
|
259
|
+
._menuItem_fxllk5_50._selected_fxllk5_99{
|
|
277
260
|
color:var(--_rs-menu-mi-selected-color);
|
|
278
261
|
background:var(--_rs-menu-mi-selected-background);
|
|
279
262
|
}
|
|
280
|
-
.
|
|
281
|
-
.
|
|
263
|
+
._menuItem_fxllk5_50._highlighted_fxllk5_106,
|
|
264
|
+
._menuItem_fxllk5_50:not(._disableCursor_fxllk5_107):hover{
|
|
282
265
|
color:var(--_rs-menu-mi-hover-color);
|
|
283
266
|
background:var(--_rs-menu-mi-hover-background);
|
|
284
267
|
}
|
|
285
|
-
.
|
|
286
|
-
.
|
|
268
|
+
._menuItem_fxllk5_50._highlighted_fxllk5_106._selected_fxllk5_99,
|
|
269
|
+
._menuItem_fxllk5_50._selected_fxllk5_99:not(._disableCursor_fxllk5_107):hover{
|
|
287
270
|
color:var(--_rs-menu-mi-selected-hover-color);
|
|
288
271
|
background-color:var(--_rs-menu-mi-selected-hover-background);
|
|
289
272
|
}
|
|
290
|
-
.
|
|
273
|
+
._menuItem_fxllk5_50._disabled_fxllk5_120{
|
|
291
274
|
pointer-events:none;
|
|
292
275
|
|
|
293
276
|
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.5);
|
|
294
277
|
}
|
|
295
|
-
.
|
|
278
|
+
._disableCursor_fxllk5_107{
|
|
296
279
|
pointer-events:none;
|
|
297
280
|
}
|
|
298
|
-
.
|
|
299
|
-
-
|
|
300
|
-
-ms-flex-positive:1;
|
|
301
|
-
flex-grow:1;
|
|
281
|
+
._content_fxllk5_131{
|
|
282
|
+
flex-grow:1;
|
|
302
283
|
|
|
303
284
|
font-size:inherit;
|
|
304
285
|
}
|
|
305
|
-
.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
flex:0 0;
|
|
309
|
-
-ms-flex-preferred-size:auto;
|
|
310
|
-
flex-basis:auto;
|
|
286
|
+
._icon_fxllk5_35{
|
|
287
|
+
flex:0 0;
|
|
288
|
+
flex-basis:auto;
|
|
311
289
|
}
|
|
312
|
-
.
|
|
313
|
-
|
|
314
|
-
flex-shrink:0;
|
|
290
|
+
._divider_fxllk5_144{
|
|
291
|
+
flex-shrink:0;
|
|
315
292
|
|
|
316
293
|
width:100%;
|
|
317
294
|
height:1px;
|
|
@@ -321,13 +298,13 @@
|
|
|
321
298
|
|
|
322
299
|
background-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), 0.2);
|
|
323
300
|
}
|
|
324
|
-
.
|
|
301
|
+
._groupHeaderThemeLight_fxllk5_158{
|
|
325
302
|
--rs-theme-dark:0;
|
|
326
303
|
}
|
|
327
|
-
.
|
|
304
|
+
._groupHeaderThemeDark_fxllk5_161{
|
|
328
305
|
--rs-theme-dark:1;
|
|
329
306
|
}
|
|
330
|
-
.
|
|
307
|
+
._groupHeaderSizeL_fxllk5_165{
|
|
331
308
|
--_rs-menu-gh-vertical-padding:12px;
|
|
332
309
|
--_rs-menu-gh-horizontal-padding:16px;
|
|
333
310
|
--_rs-typography-letter-spacing:normal;
|
|
@@ -360,7 +337,7 @@
|
|
|
360
337
|
--_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
|
|
361
338
|
--_rs-typography-link-border-bottom-width-from-text:2px;
|
|
362
339
|
}
|
|
363
|
-
.
|
|
340
|
+
._groupHeaderSizeM_fxllk5_168{
|
|
364
341
|
--_rs-menu-gh-vertical-padding:8px;
|
|
365
342
|
--_rs-menu-gh-horizontal-padding:16px;
|
|
366
343
|
--_rs-typography-letter-spacing:normal;
|
|
@@ -393,7 +370,7 @@
|
|
|
393
370
|
--_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
|
|
394
371
|
--_rs-typography-link-border-bottom-width-from-text:2px;
|
|
395
372
|
}
|
|
396
|
-
.
|
|
373
|
+
._groupHeaderSizeS_fxllk5_171{
|
|
397
374
|
--_rs-menu-gh-vertical-padding:6px;
|
|
398
375
|
--_rs-menu-gh-horizontal-padding:8px;
|
|
399
376
|
--_rs-typography-letter-spacing:normal;
|
|
@@ -426,7 +403,7 @@
|
|
|
426
403
|
--_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
|
|
427
404
|
--_rs-typography-link-border-bottom-width-from-text:2px;
|
|
428
405
|
}
|
|
429
|
-
.
|
|
406
|
+
._groupHeader_fxllk5_158{
|
|
430
407
|
--_rs-theme-dark:var(
|
|
431
408
|
--_rs-internal-force-theme-dark-consult-rescui-before-using,
|
|
432
409
|
var(--rs-theme-dark, 0)
|
|
@@ -436,7 +413,7 @@
|
|
|
436
413
|
--_rs-theme-light-coefficient:calc(1 - var(--_rs-theme-dark-coefficient));
|
|
437
414
|
}
|
|
438
415
|
@supports (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
439
|
-
.
|
|
416
|
+
._groupHeader_fxllk5_158{
|
|
440
417
|
--_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)));
|
|
441
418
|
--_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)));
|
|
442
419
|
--_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)));
|
|
@@ -445,7 +422,7 @@
|
|
|
445
422
|
}
|
|
446
423
|
}
|
|
447
424
|
@supports not (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
448
|
-
.
|
|
425
|
+
._groupHeader_fxllk5_158{
|
|
449
426
|
--_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);
|
|
450
427
|
--_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));
|
|
451
428
|
--_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));
|
|
@@ -453,7 +430,7 @@
|
|
|
453
430
|
--_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));
|
|
454
431
|
}
|
|
455
432
|
}
|
|
456
|
-
.
|
|
433
|
+
._groupHeader_fxllk5_158 {
|
|
457
434
|
letter-spacing:var(
|
|
458
435
|
--rs-text-base-letter-spacing,
|
|
459
436
|
var(--_rs-typography-letter-spacing)
|
|
@@ -464,7 +441,6 @@
|
|
|
464
441
|
font-weight:var(--_rs-typography-font-weight);
|
|
465
442
|
line-height:var(--_rs-typography-line-height);
|
|
466
443
|
font-variant-numeric:var(--_rs-typography-font-variant-numeric);
|
|
467
|
-
-webkit-font-feature-settings:'kern', 'liga', 'calt';
|
|
468
444
|
font-feature-settings:'kern', 'liga', 'calt';
|
|
469
445
|
|
|
470
446
|
padding:var(--_rs-menu-gh-vertical-padding) var(--_rs-menu-gh-horizontal-padding);
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"modeClassic": "
|
|
8
|
-
"modeRock": "
|
|
9
|
-
"modeClear": "
|
|
10
|
-
"iconPlacementLeft": "
|
|
11
|
-
"iconPlacementRight": "
|
|
12
|
-
"wrapper": "
|
|
13
|
-
"menuItem": "
|
|
14
|
-
"keyboardNavigationDisabled": "
|
|
15
|
-
"selected": "
|
|
16
|
-
"highlighted": "
|
|
17
|
-
"disableCursor": "
|
|
18
|
-
"disabled": "
|
|
19
|
-
"content": "
|
|
20
|
-
"icon": "
|
|
21
|
-
"divider": "
|
|
22
|
-
"groupHeaderThemeLight": "
|
|
23
|
-
"groupHeaderThemeDark": "
|
|
24
|
-
"groupHeaderSizeL": "
|
|
25
|
-
"groupHeaderSizeM": "
|
|
26
|
-
"groupHeaderSizeS": "
|
|
27
|
-
"groupHeader": "
|
|
2
|
+
"themeLight": "_themeLight_fxllk5_8",
|
|
3
|
+
"themeDark": "_themeDark_fxllk5_11",
|
|
4
|
+
"sizeS": "_sizeS_fxllk5_15",
|
|
5
|
+
"sizeM": "_sizeM_fxllk5_18",
|
|
6
|
+
"sizeL": "_sizeL_fxllk5_21",
|
|
7
|
+
"modeClassic": "_modeClassic_fxllk5_25",
|
|
8
|
+
"modeRock": "_modeRock_fxllk5_28",
|
|
9
|
+
"modeClear": "_modeClear_fxllk5_31",
|
|
10
|
+
"iconPlacementLeft": "_iconPlacementLeft_fxllk5_35",
|
|
11
|
+
"iconPlacementRight": "_iconPlacementRight_fxllk5_39",
|
|
12
|
+
"wrapper": "_wrapper_fxllk5_43",
|
|
13
|
+
"menuItem": "_menuItem_fxllk5_50",
|
|
14
|
+
"keyboardNavigationDisabled": "_keyboardNavigationDisabled_fxllk5_85",
|
|
15
|
+
"selected": "_selected_fxllk5_99",
|
|
16
|
+
"highlighted": "_highlighted_fxllk5_106",
|
|
17
|
+
"disableCursor": "_disableCursor_fxllk5_107",
|
|
18
|
+
"disabled": "_disabled_fxllk5_120",
|
|
19
|
+
"content": "_content_fxllk5_131",
|
|
20
|
+
"icon": "_icon_fxllk5_35",
|
|
21
|
+
"divider": "_divider_fxllk5_144",
|
|
22
|
+
"groupHeaderThemeLight": "_groupHeaderThemeLight_fxllk5_158",
|
|
23
|
+
"groupHeaderThemeDark": "_groupHeaderThemeDark_fxllk5_161",
|
|
24
|
+
"groupHeaderSizeL": "_groupHeaderSizeL_fxllk5_165",
|
|
25
|
+
"groupHeaderSizeM": "_groupHeaderSizeM_fxllk5_168",
|
|
26
|
+
"groupHeaderSizeS": "_groupHeaderSizeS_fxllk5_171",
|
|
27
|
+
"groupHeader": "_groupHeader_fxllk5_158"
|
|
28
28
|
};
|
|
29
29
|
export { styles as default };
|
package/lib/menu.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/es.object.to-string.js";
|
|
2
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
5
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
6
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
7
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
10
|
-
var _excluded = ["tag", "itemTag", "iconPlacement", "disabled", "size", "mode", "disableCursor", "theme", "enableKeyboardNavigation", "activateFirstItem", "className", "wrapItemsWithLi", "returnFocusOnUnmount"];
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
1
|
import React from 'react';
|
|
17
2
|
import PropTypes from 'prop-types';
|
|
18
3
|
import cn from 'classnames';
|
|
@@ -20,40 +5,34 @@ import { MenuProvider } from './parts/menu-context.js';
|
|
|
20
5
|
import styles from './index.p.module.css.js';
|
|
21
6
|
import { useMenuKeyboardNavigation } from './parts/use-menu-keyboard-navigation.js';
|
|
22
7
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}),
|
|
52
|
-
activeItemRef = _useMenuKeyboardNavig.activeItemRef,
|
|
53
|
-
registerItem = _useMenuKeyboardNavig.registerItem,
|
|
54
|
-
unregisterItem = _useMenuKeyboardNavig.unregisterItem,
|
|
55
|
-
isKeyboardNavigating = _useMenuKeyboardNavig.isKeyboardNavigating;
|
|
56
|
-
|
|
8
|
+
const Menu = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
tag = 'ul',
|
|
11
|
+
itemTag,
|
|
12
|
+
iconPlacement,
|
|
13
|
+
disabled,
|
|
14
|
+
size = 'm',
|
|
15
|
+
mode,
|
|
16
|
+
disableCursor = false,
|
|
17
|
+
theme,
|
|
18
|
+
enableKeyboardNavigation = false,
|
|
19
|
+
activateFirstItem = false,
|
|
20
|
+
className,
|
|
21
|
+
wrapItemsWithLi,
|
|
22
|
+
returnFocusOnUnmount = false,
|
|
23
|
+
...restProps
|
|
24
|
+
} = _ref;
|
|
25
|
+
const Tag = tag;
|
|
26
|
+
const {
|
|
27
|
+
activeItemRef,
|
|
28
|
+
registerItem,
|
|
29
|
+
unregisterItem,
|
|
30
|
+
isKeyboardNavigating
|
|
31
|
+
} = useMenuKeyboardNavigation({
|
|
32
|
+
enableKeyboardNavigation,
|
|
33
|
+
activateFirstItem,
|
|
34
|
+
returnFocusOnUnmount
|
|
35
|
+
});
|
|
57
36
|
return /*#__PURE__*/React.createElement(MenuProvider, {
|
|
58
37
|
itemTag: itemTag,
|
|
59
38
|
iconPlacement: iconPlacement,
|
|
@@ -66,10 +45,11 @@ var Menu = function Menu(_ref) {
|
|
|
66
45
|
unregisterItem: unregisterItem,
|
|
67
46
|
activeItemRef: activeItemRef.current,
|
|
68
47
|
isKeyboardNavigating: isKeyboardNavigating,
|
|
69
|
-
wrapWithLi: wrapItemsWithLi
|
|
70
|
-
}, /*#__PURE__*/React.createElement(Tag,
|
|
71
|
-
className: cn(!enableKeyboardNavigation && styles.keyboardNavigationDisabled, className)
|
|
72
|
-
|
|
48
|
+
wrapWithLi: wrapItemsWithLi ?? tag === 'ul'
|
|
49
|
+
}, /*#__PURE__*/React.createElement(Tag, {
|
|
50
|
+
className: cn(!enableKeyboardNavigation && styles.keyboardNavigationDisabled, className),
|
|
51
|
+
...restProps
|
|
52
|
+
}));
|
|
73
53
|
};
|
|
74
54
|
|
|
75
55
|
Menu.propTypes = {
|
package/lib/parts/divider.js
CHANGED
|
@@ -1,41 +1,26 @@
|
|
|
1
|
-
import "core-js/modules/es.object.to-string.js";
|
|
2
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
5
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
6
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
7
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
10
|
-
var _excluded = ["className", "theme"];
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
1
|
import React from 'react';
|
|
17
2
|
import cn from 'classnames';
|
|
18
3
|
import PropTypes from 'prop-types';
|
|
19
4
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
20
5
|
import styles from '../index.p.module.css.js';
|
|
21
6
|
import { useMenuContext } from './menu-context.js';
|
|
22
|
-
|
|
7
|
+
const THEME_CLASS = {
|
|
23
8
|
light: styles.themeLight,
|
|
24
9
|
dark: styles.themeDark
|
|
25
10
|
};
|
|
26
11
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
12
|
+
const Divider = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
className,
|
|
15
|
+
theme,
|
|
16
|
+
...restProps
|
|
17
|
+
} = _ref;
|
|
18
|
+
const menuContext = useMenuContext();
|
|
19
|
+
const actualTheme = useThemeWithUndefined(menuContext.theme ?? theme);
|
|
20
|
+
return /*#__PURE__*/React.createElement("hr", {
|
|
21
|
+
className: cn(styles.divider, THEME_CLASS[actualTheme], className),
|
|
22
|
+
...restProps
|
|
23
|
+
});
|
|
39
24
|
};
|
|
40
25
|
|
|
41
26
|
Divider.propTypes = {
|
|
@@ -4,30 +4,28 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
5
5
|
import styles from '../index.p.module.css.js';
|
|
6
6
|
import { useMenuContext } from './menu-context.js';
|
|
7
|
-
|
|
7
|
+
const SIZE_CLASS = {
|
|
8
8
|
s: styles.groupHeaderSizeS,
|
|
9
9
|
m: styles.groupHeaderSizeM,
|
|
10
10
|
l: styles.groupHeaderSizeL
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
const THEME_CLASS = {
|
|
13
13
|
light: styles.groupHeaderThemeLight,
|
|
14
14
|
dark: styles.groupHeaderThemeDark
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
function GroupHeader(_ref) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var Tag = menuContext.wrapWithLi ? 'li' : 'span';
|
|
28
|
-
var actualTheme = useThemeWithUndefined((_menuContext$theme = menuContext.theme) !== null && _menuContext$theme !== void 0 ? _menuContext$theme : propsTheme);
|
|
18
|
+
let {
|
|
19
|
+
className = null,
|
|
20
|
+
text,
|
|
21
|
+
size: propsSize = 'm',
|
|
22
|
+
theme: propsTheme
|
|
23
|
+
} = _ref;
|
|
24
|
+
const menuContext = useMenuContext();
|
|
25
|
+
const Tag = menuContext.wrapWithLi ? 'li' : 'span';
|
|
26
|
+
const actualTheme = useThemeWithUndefined(menuContext.theme ?? propsTheme);
|
|
29
27
|
return /*#__PURE__*/React.createElement(Tag, {
|
|
30
|
-
className: cn(styles.groupHeader, SIZE_CLASS[
|
|
28
|
+
className: cn(styles.groupHeader, SIZE_CLASS[menuContext.size ?? propsSize], THEME_CLASS[actualTheme], className),
|
|
31
29
|
"data-rs-internal": 'menu__group-header'
|
|
32
30
|
}, text);
|
|
33
31
|
}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
2
|
-
var _excluded = ["children"];
|
|
3
1
|
import React, { useContext } from 'react';
|
|
4
2
|
import PropTypes from 'prop-types';
|
|
5
|
-
|
|
3
|
+
const DEFAULT_MENU_CONTEXT = {
|
|
6
4
|
disabled: false,
|
|
7
5
|
isKeyboardNavigating: false,
|
|
8
6
|
wrapWithLi: false,
|
|
9
7
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
10
|
-
registerItem:
|
|
8
|
+
registerItem: () => {},
|
|
11
9
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
12
|
-
unregisterItem:
|
|
10
|
+
unregisterItem: () => {}
|
|
13
11
|
};
|
|
14
|
-
|
|
12
|
+
const MenuContext = /*#__PURE__*/React.createContext(DEFAULT_MENU_CONTEXT);
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
return useContext(MenuContext);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var MenuProvider = function MenuProvider(_ref) {
|
|
21
|
-
var children = _ref.children,
|
|
22
|
-
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
14
|
+
const useMenuContext = () => useContext(MenuContext);
|
|
23
15
|
|
|
16
|
+
const MenuProvider = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
...restProps
|
|
20
|
+
} = _ref;
|
|
24
21
|
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
25
22
|
value: restProps
|
|
26
23
|
}, children);
|
package/lib/parts/menu-item.js
CHANGED
|
@@ -1,87 +1,60 @@
|
|
|
1
|
-
import "core-js/modules/es.object.to-string.js";
|
|
2
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
5
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
6
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
7
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
|
-
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
|
10
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
11
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
12
|
-
var _excluded = ["className", "tag", "children", "icon", "size", "mode", "theme", "disabled", "disableCursor", "selected", "highlighted", "iconPlacement"],
|
|
13
|
-
_excluded2 = ["unregisterItem", "registerItem", "activeItemRef", "isKeyboardNavigating", "wrapWithLi"];
|
|
14
|
-
|
|
15
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
|
|
19
1
|
import React, { useState, useEffect, cloneElement } from 'react';
|
|
20
2
|
import cn from 'classnames';
|
|
21
3
|
import PropTypes from 'prop-types';
|
|
22
4
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
23
5
|
import styles from '../index.p.module.css.js';
|
|
24
6
|
import { useMenuContext } from './menu-context.js';
|
|
25
|
-
|
|
7
|
+
const ICON_PLACEMENT_STYLES = {
|
|
26
8
|
left: styles.iconPlacementLeft,
|
|
27
9
|
right: styles.iconPlacementRight
|
|
28
10
|
};
|
|
29
|
-
|
|
11
|
+
const MODE_STYLES = {
|
|
30
12
|
classic: styles.modeClassic,
|
|
31
13
|
clear: styles.modeClear,
|
|
32
14
|
rock: styles.modeRock
|
|
33
15
|
};
|
|
34
|
-
|
|
16
|
+
const SIZE_STYLES = {
|
|
35
17
|
s: styles.sizeS,
|
|
36
18
|
m: styles.sizeM,
|
|
37
19
|
l: styles.sizeL
|
|
38
20
|
};
|
|
39
|
-
|
|
21
|
+
const THEME_STYLES = {
|
|
40
22
|
light: styles.themeLight,
|
|
41
23
|
dark: styles.themeDark
|
|
42
24
|
}; // eslint-disable-next-line complexity
|
|
43
25
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var _useState = useState(null),
|
|
75
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
76
|
-
thisRef = _useState2[0],
|
|
77
|
-
setThisRef = _useState2[1];
|
|
78
|
-
|
|
79
|
-
useEffect(function () {
|
|
80
|
-
return function () {
|
|
81
|
-
return unregisterItem(thisRef);
|
|
82
|
-
};
|
|
26
|
+
const MenuItemInner = (_ref, ref) => {
|
|
27
|
+
let {
|
|
28
|
+
className,
|
|
29
|
+
tag,
|
|
30
|
+
children,
|
|
31
|
+
icon,
|
|
32
|
+
size = 'm',
|
|
33
|
+
mode = 'classic',
|
|
34
|
+
theme,
|
|
35
|
+
disabled,
|
|
36
|
+
disableCursor,
|
|
37
|
+
selected,
|
|
38
|
+
|
|
39
|
+
/* @private */
|
|
40
|
+
highlighted,
|
|
41
|
+
iconPlacement = 'left',
|
|
42
|
+
...restProps
|
|
43
|
+
} = _ref;
|
|
44
|
+
const {
|
|
45
|
+
unregisterItem,
|
|
46
|
+
registerItem,
|
|
47
|
+
activeItemRef,
|
|
48
|
+
isKeyboardNavigating,
|
|
49
|
+
wrapWithLi,
|
|
50
|
+
...menuContext
|
|
51
|
+
} = useMenuContext();
|
|
52
|
+
const actualTheme = useThemeWithUndefined(menuContext.theme ?? theme);
|
|
53
|
+
const [thisRef, setThisRef] = useState(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
return () => unregisterItem(thisRef);
|
|
83
56
|
}, [unregisterItem, thisRef]);
|
|
84
|
-
|
|
57
|
+
let autoTag = 'span';
|
|
85
58
|
|
|
86
59
|
if (restProps.href) {
|
|
87
60
|
autoTag = 'a';
|
|
@@ -89,28 +62,28 @@ var MenuItemInner = function MenuItemInner(_ref, ref) {
|
|
|
89
62
|
autoTag = 'button';
|
|
90
63
|
}
|
|
91
64
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
65
|
+
const Tag = menuContext.itemTag ?? tag ?? autoTag;
|
|
66
|
+
const actualIconPlacement = menuContext.iconPlacement ?? iconPlacement ?? 'left';
|
|
67
|
+
const actualMode = menuContext.mode ?? mode;
|
|
68
|
+
const actualSize = menuContext.size ?? size;
|
|
69
|
+
const actualDisableCursor = menuContext.disableCursor ?? disableCursor;
|
|
70
|
+
const iconElement = icon ? /*#__PURE__*/cloneElement(icon, {
|
|
98
71
|
className: cn(icon.props.className, styles.icon)
|
|
99
72
|
}) : null;
|
|
100
|
-
|
|
73
|
+
const actualHighlighted = highlighted || activeItemRef === thisRef && isKeyboardNavigating;
|
|
101
74
|
|
|
102
|
-
|
|
75
|
+
const handleRef = r => {
|
|
103
76
|
registerItem(r);
|
|
104
77
|
setThisRef(r);
|
|
105
78
|
|
|
106
79
|
if (typeof ref === 'function') {
|
|
107
80
|
ref(r);
|
|
108
|
-
} else if (ref != null &&
|
|
81
|
+
} else if (ref != null && typeof ref === 'object') {
|
|
109
82
|
ref.current = r;
|
|
110
83
|
}
|
|
111
84
|
};
|
|
112
85
|
|
|
113
|
-
|
|
86
|
+
const handleKeyDown = e => {
|
|
114
87
|
if (isKeyboardNavigating && (e.key === ' ' || e.key === 'Enter')) {
|
|
115
88
|
e.preventDefault();
|
|
116
89
|
|
|
@@ -120,24 +93,25 @@ var MenuItemInner = function MenuItemInner(_ref, ref) {
|
|
|
120
93
|
}
|
|
121
94
|
};
|
|
122
95
|
|
|
123
|
-
|
|
96
|
+
const Wrapper = wrapWithLi ? 'li' : 'div';
|
|
124
97
|
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
125
98
|
className: cn(styles.wrapper, className, ICON_PLACEMENT_STYLES[actualIconPlacement], MODE_STYLES[actualMode], SIZE_STYLES[actualSize], THEME_STYLES[actualTheme]),
|
|
126
99
|
"data-test": 'menu-item__wrapper',
|
|
127
100
|
"data-rs-internal": 'menu__menu-item'
|
|
128
|
-
}, /*#__PURE__*/React.createElement(Tag,
|
|
101
|
+
}, /*#__PURE__*/React.createElement(Tag, {
|
|
129
102
|
onKeyDown: handleKeyDown,
|
|
130
103
|
ref: handleRef,
|
|
131
104
|
className: cn(styles.menuItem, (menuContext.disabled || disabled) && styles.disabled, selected && styles.selected, actualHighlighted && styles.highlighted, actualDisableCursor && styles.disableCursor),
|
|
132
105
|
"data-test": 'menu-item',
|
|
133
106
|
"data-rs-internal": 'menu__menu-item__inner',
|
|
134
|
-
tabIndex: 0
|
|
135
|
-
|
|
107
|
+
tabIndex: 0,
|
|
108
|
+
...restProps
|
|
109
|
+
}, iconElement, /*#__PURE__*/React.createElement("span", {
|
|
136
110
|
className: styles.content
|
|
137
111
|
}, children)));
|
|
138
112
|
};
|
|
139
113
|
|
|
140
|
-
|
|
114
|
+
const MenuItem = /*#__PURE__*/React.forwardRef(MenuItemInner);
|
|
141
115
|
MenuItem.propTypes = {
|
|
142
116
|
size: PropTypes.oneOf(['l', 'm', 's']),
|
|
143
117
|
mode: PropTypes.oneOf(['clear', 'classic', 'rock']),
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
2
|
-
|
|
3
1
|
function getFirstItem(sortedItems) {
|
|
4
2
|
return sortedItems[0];
|
|
5
3
|
}
|
|
@@ -9,11 +7,8 @@ function getLastItem(sortedItems) {
|
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
function getNextItem(sortedItems, activeItem) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
var indexToFocus = focusedIndex + 1;
|
|
10
|
+
const focusedIndex = sortedItems.findIndex(el => el === activeItem);
|
|
11
|
+
const indexToFocus = focusedIndex + 1;
|
|
17
12
|
|
|
18
13
|
if (indexToFocus < sortedItems.length) {
|
|
19
14
|
return sortedItems[indexToFocus];
|
|
@@ -23,11 +18,8 @@ function getNextItem(sortedItems, activeItem) {
|
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
function getPrevItem(sortedItems, activeItem) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
var indexToFocus = focusedIndex - 1;
|
|
21
|
+
const focusedIndex = sortedItems.findIndex(el => el === activeItem);
|
|
22
|
+
const indexToFocus = focusedIndex - 1;
|
|
31
23
|
|
|
32
24
|
if (indexToFocus >= 0) {
|
|
33
25
|
return sortedItems[indexToFocus];
|
|
@@ -1,62 +1,49 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
|
-
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
|
3
|
-
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
4
|
-
import _valuesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/values";
|
|
5
|
-
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
6
1
|
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
7
2
|
import { getLastItem, getFirstItem, getPrevItem, getNextItem, htmlElementsComparator } from './navigation-utils.js';
|
|
8
3
|
|
|
9
4
|
function debounce(callback, timeout) {
|
|
10
|
-
|
|
5
|
+
let id;
|
|
11
6
|
return function () {
|
|
12
7
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
8
|
args[_key] = arguments[_key];
|
|
14
9
|
}
|
|
15
10
|
|
|
16
11
|
clearTimeout(id);
|
|
17
|
-
id = setTimeout(
|
|
18
|
-
return callback.apply(void 0, args);
|
|
19
|
-
}, timeout);
|
|
12
|
+
id = setTimeout(() => callback(...args), timeout);
|
|
20
13
|
return id;
|
|
21
14
|
};
|
|
22
15
|
}
|
|
23
16
|
|
|
24
17
|
function getSortedItems(itemsSet) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return _sortInstanceProperty(_context = _Array$from(_valuesInstanceProperty(itemsSet).call(itemsSet))).call(_context, htmlElementsComparator);
|
|
18
|
+
return Array.from(itemsSet.values()).sort(htmlElementsComparator);
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
function useMenuKeyboardNavigation(_ref) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var setActiveItemRef = useCallback(function (ref) {
|
|
22
|
+
let {
|
|
23
|
+
enableKeyboardNavigation,
|
|
24
|
+
activateFirstItem,
|
|
25
|
+
returnFocusOnUnmount
|
|
26
|
+
} = _ref;
|
|
27
|
+
const activeItemRef = useRef(null);
|
|
28
|
+
const [, setDummyState] = useState(false);
|
|
29
|
+
const setActiveItemRef = useCallback(ref => {
|
|
41
30
|
activeItemRef.current = ref;
|
|
42
31
|
|
|
43
32
|
if (ref) {
|
|
44
33
|
ref.focus();
|
|
45
34
|
}
|
|
46
35
|
|
|
47
|
-
setDummyState(
|
|
48
|
-
return !t;
|
|
49
|
-
});
|
|
36
|
+
setDummyState(t => !t);
|
|
50
37
|
}, [setDummyState]);
|
|
51
|
-
|
|
52
|
-
useEffect(
|
|
38
|
+
const menuItemsSet = useRef(new Set());
|
|
39
|
+
useEffect(() => {
|
|
53
40
|
if (!enableKeyboardNavigation || !activateFirstItem || !returnFocusOnUnmount) {
|
|
54
41
|
return;
|
|
55
42
|
}
|
|
56
43
|
|
|
57
|
-
|
|
44
|
+
const lastFocusedEl = document.activeElement; // eslint-disable-next-line consistent-return
|
|
58
45
|
|
|
59
|
-
return
|
|
46
|
+
return () => {
|
|
60
47
|
if (lastFocusedEl) {
|
|
61
48
|
lastFocusedEl.focus({
|
|
62
49
|
preventScroll: true
|
|
@@ -64,11 +51,11 @@ function useMenuKeyboardNavigation(_ref) {
|
|
|
64
51
|
}
|
|
65
52
|
};
|
|
66
53
|
}, []);
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
const debouncedActivateFirstItem = debounce(() => {
|
|
55
|
+
const items = getSortedItems(menuItemsSet.current);
|
|
69
56
|
setActiveItemRef(getFirstItem(items));
|
|
70
57
|
}, 50);
|
|
71
|
-
|
|
58
|
+
const registerItem = useCallback(ref => {
|
|
72
59
|
if (ref && !menuItemsSet.current.has(ref)) {
|
|
73
60
|
menuItemsSet.current.add(ref);
|
|
74
61
|
|
|
@@ -77,16 +64,11 @@ function useMenuKeyboardNavigation(_ref) {
|
|
|
77
64
|
}
|
|
78
65
|
}
|
|
79
66
|
}, []);
|
|
80
|
-
|
|
67
|
+
const unregisterItem = useCallback(ref => {
|
|
81
68
|
menuItemsSet.current.delete(ref);
|
|
82
69
|
}, []);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
86
|
-
isKeyboardNavigating = _useState4[0],
|
|
87
|
-
setIsKeyboardNavigating = _useState4[1];
|
|
88
|
-
|
|
89
|
-
var handleMouseMove = useCallback(function () {
|
|
70
|
+
const [isKeyboardNavigating, setIsKeyboardNavigating] = useState(true);
|
|
71
|
+
const handleMouseMove = useCallback(() => {
|
|
90
72
|
if (menuItemsSet.current.has(document.activeElement) && document.activeElement.blur) {
|
|
91
73
|
document.activeElement.blur();
|
|
92
74
|
}
|
|
@@ -95,22 +77,20 @@ function useMenuKeyboardNavigation(_ref) {
|
|
|
95
77
|
setIsKeyboardNavigating(false);
|
|
96
78
|
}, []); // eslint-disable-next-line consistent-return
|
|
97
79
|
|
|
98
|
-
useEffect(
|
|
80
|
+
useEffect(() => {
|
|
99
81
|
if (isKeyboardNavigating) {
|
|
100
82
|
document.addEventListener('mousemove', handleMouseMove);
|
|
101
|
-
return
|
|
102
|
-
return document.removeEventListener('mousemove', handleMouseMove);
|
|
103
|
-
};
|
|
83
|
+
return () => document.removeEventListener('mousemove', handleMouseMove);
|
|
104
84
|
}
|
|
105
85
|
}, [handleMouseMove, isKeyboardNavigating]);
|
|
106
|
-
useEffect(
|
|
86
|
+
useEffect(() => {
|
|
107
87
|
if (!enableKeyboardNavigation) {
|
|
108
88
|
return;
|
|
109
89
|
}
|
|
110
90
|
|
|
111
|
-
|
|
91
|
+
const handler = e => {
|
|
112
92
|
setIsKeyboardNavigating(true);
|
|
113
|
-
|
|
93
|
+
const items = getSortedItems(menuItemsSet.current);
|
|
114
94
|
|
|
115
95
|
switch (e.key) {
|
|
116
96
|
case 'ArrowDown':
|
|
@@ -137,15 +117,15 @@ function useMenuKeyboardNavigation(_ref) {
|
|
|
137
117
|
|
|
138
118
|
document.addEventListener('keydown', handler, true); // eslint-disable-next-line consistent-return
|
|
139
119
|
|
|
140
|
-
return
|
|
120
|
+
return () => {
|
|
141
121
|
document.removeEventListener('keydown', handler, true);
|
|
142
122
|
};
|
|
143
123
|
}, [enableKeyboardNavigation]);
|
|
144
124
|
return {
|
|
145
|
-
activeItemRef
|
|
146
|
-
registerItem
|
|
147
|
-
unregisterItem
|
|
148
|
-
isKeyboardNavigating
|
|
125
|
+
activeItemRef,
|
|
126
|
+
registerItem,
|
|
127
|
+
unregisterItem,
|
|
128
|
+
isKeyboardNavigating
|
|
149
129
|
};
|
|
150
130
|
}
|
|
151
131
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/menu",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime-corejs3": "^7.
|
|
17
|
+
"@babel/runtime-corejs3": "^7.26.0",
|
|
18
18
|
"classnames": "^2.2.6",
|
|
19
|
-
"core-js": "^3",
|
|
20
19
|
"nanoid": "^3.3.3"
|
|
21
20
|
},
|
|
22
21
|
"peerDependencies": {
|
|
@@ -25,10 +24,10 @@
|
|
|
25
24
|
"react": ">=16.8.0 <19"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"@rescui/colors": "^0.2.
|
|
27
|
+
"@rescui/colors": "^0.2.6",
|
|
29
28
|
"@rescui/postcss-preset-library": "^0.2.2",
|
|
30
|
-
"@rescui/scripts": "^0.3.
|
|
31
|
-
"@rescui/typography": "^0.
|
|
29
|
+
"@rescui/scripts": "^0.3.5",
|
|
30
|
+
"@rescui/typography": "^0.19.1",
|
|
32
31
|
"@rescui/visual-regression": "^0.1.2",
|
|
33
32
|
"postcss": "^8.3.0"
|
|
34
33
|
},
|
|
@@ -37,5 +36,5 @@
|
|
|
37
36
|
"build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
|
|
38
37
|
},
|
|
39
38
|
"nx": {},
|
|
40
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "67627f69be3de4b4c6a21244fd7de36e841f01f0"
|
|
41
40
|
}
|