@box/blueprint-web 12.69.0 → 12.69.2
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/dist/lib-esm/index.css +71 -48
- package/dist/lib-esm/primitives/base-button/base-button-context.js +2 -2
- package/dist/lib-esm/primitives/base-button/base-button-icon.js +8 -7
- package/dist/lib-esm/primitives/base-button/base-button.js +15 -6
- package/dist/lib-esm/primitives/base-button/base-button.module.js +1 -1
- package/dist/lib-esm/primitives/base-button/types.d.ts +1 -1
- package/dist/lib-esm/primitives/base-button/utils.d.ts +1 -1
- package/dist/lib-esm/primitives/base-button/utils.js +10 -5
- package/dist/lib-esm/status/types.d.ts +12 -2
- package/package.json +3 -3
package/dist/lib-esm/index.css
CHANGED
|
@@ -271,23 +271,23 @@
|
|
|
271
271
|
background-color:var(--loading-indicator-segment-light-background);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
|
|
274
|
+
|
|
275
|
+
.bp_base_button_module_button--85575[data-modern=true]{
|
|
275
276
|
--button-border-radius:var(--bp-radius-10);
|
|
276
277
|
}
|
|
277
|
-
.bp_base_button_module_button--
|
|
278
|
+
.bp_base_button_module_button--85575[data-modern=true]:not(:disabled)[data-focus-visible]{
|
|
278
279
|
box-shadow:0 0 0 var(--border-1, 1px) var(--background-background), 0 0 0 var(--border-3) var(--bp-outline-focus-on-light);
|
|
279
280
|
}
|
|
280
|
-
.bp_base_button_module_button--
|
|
281
|
-
--button-color:var(--bp-text-text-
|
|
281
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_primary--85575{
|
|
282
|
+
--button-color:var(--bp-text-text-on-dark);
|
|
282
283
|
--button-background:var(--bp-surface-surface-brand);
|
|
283
284
|
--button-border:var(--bp-border-01) solid var(--bp-surface-surface-brand);
|
|
284
|
-
--button-disabled-background:var(--bp-surface-surface-brand-disabled);
|
|
285
285
|
--button-focus-or-hover-background:var(--bp-surface-surface-brand-hover);
|
|
286
286
|
--button-focus-or-hover-border:var(--bp-border-01) solid var(--bp-surface-surface-brand-hover);
|
|
287
287
|
--button-active-background:var(--bp-surface-surface-brand-pressed);
|
|
288
288
|
--button-active-border:var(--bp-border-01) solid var(--bp-surface-surface-brand-pressed);
|
|
289
289
|
}
|
|
290
|
-
.bp_base_button_module_button--
|
|
290
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_secondary--85575{
|
|
291
291
|
--button-color:var(--bp-text-text-on-light);
|
|
292
292
|
--button-background:var(--bp-surface-cta-surface-secondary);
|
|
293
293
|
--button-border:var(--bp-border-01) solid var(--bp-border-cta-border-secondary);
|
|
@@ -295,14 +295,16 @@
|
|
|
295
295
|
--button-focus-or-hover-border:var(--bp-border-01) solid var(--bp-border-cta-border-secondary);
|
|
296
296
|
--button-active-background:var(--bp-surface-cta-surface-secondary-pressed);
|
|
297
297
|
--button-active-border:var(--bp-border-01) solid var(--bp-border-cta-border-secondary);
|
|
298
|
+
--button-backdrop-filter:blur(16px);
|
|
298
299
|
}
|
|
299
|
-
.bp_base_button_module_button--
|
|
300
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_tertiary--85575{
|
|
300
301
|
--button-color:var(--bp-text-cta-link);
|
|
301
|
-
--button-background
|
|
302
|
+
--button-background:var(--bp-surface-cta-surface-tertiary);
|
|
302
303
|
--button-focus-or-hover-background:var(--bp-surface-cta-surface-tertiary-hover);
|
|
303
304
|
--button-active-background:var(--bp-surface-cta-surface-tertiary-pressed);
|
|
305
|
+
--button-backdrop-filter:blur(16px);
|
|
304
306
|
}
|
|
305
|
-
.bp_base_button_module_button--
|
|
307
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_outline--85575{
|
|
306
308
|
--button-color:var(--bp-text-text-on-light);
|
|
307
309
|
--button-background:var(--bp-surface-cta-surface-outline);
|
|
308
310
|
--button-border:var(--bp-border-01) solid var(--bp-border-cta-border-high-contrast);
|
|
@@ -310,45 +312,51 @@
|
|
|
310
312
|
--button-focus-or-hover-border:var(--bp-border-01) solid var(--bp-border-cta-border-high-contrast);
|
|
311
313
|
--button-active-background:var(--bp-surface-cta-surface-outline-pressed);
|
|
312
314
|
--button-active-border:var(--bp-border-01) solid var(--bp-border-cta-border-high-contrast);
|
|
315
|
+
--button-backdrop-filter:blur(16px);
|
|
313
316
|
}
|
|
314
|
-
.bp_base_button_module_button--
|
|
317
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_small--85575{
|
|
315
318
|
--button-small-gap:var(--bp-space-010);
|
|
316
319
|
--button-small-min-height:var(--bp-size-080);
|
|
317
320
|
--button-small-padding:0 var(--bp-size-040);
|
|
318
321
|
}
|
|
319
|
-
.bp_base_button_module_button--
|
|
322
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_small--85575.bp_base_button_module_isIconButton--85575{
|
|
320
323
|
--icon-button-small-width:var(--bp-size-080);
|
|
321
324
|
--icon-button-small-height:var(--bp-size-080);
|
|
322
325
|
--icon-button-small-padding:0 calc((var(--bp-size-080) - var(--bp-size-040))/2);
|
|
323
326
|
}
|
|
324
|
-
.bp_base_button_module_button--
|
|
327
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_small--85575.bp_base_button_module_isTextWithIconButton--85575{
|
|
328
|
+
--button-small-padding:0 0.625rem 0 var(--bp-space-030);
|
|
329
|
+
}
|
|
330
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_large--85575{
|
|
325
331
|
--button-large-gap:var(--bp-space-020);
|
|
326
332
|
--button-large-min-height:var(--bp-size-100);
|
|
327
333
|
--button-large-padding:0 var(--bp-size-040);
|
|
328
334
|
}
|
|
329
|
-
.bp_base_button_module_button--
|
|
335
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_large--85575.bp_base_button_module_isIconButton--85575{
|
|
330
336
|
--icon-button-large-width:var(--bp-size-100);
|
|
331
337
|
--icon-button-large-height:var(--bp-size-100);
|
|
332
338
|
--icon-button-large-padding:0 calc((var(--bp-size-100) - var(--bp-size-050))/2);
|
|
333
339
|
}
|
|
340
|
+
.bp_base_button_module_button--85575[data-modern=true].bp_base_button_module_large--85575.bp_base_button_module_isTextWithIconButton--85575{
|
|
341
|
+
--button-large-padding:0 0.875rem 0 var(--bp-space-040);
|
|
342
|
+
}
|
|
334
343
|
|
|
335
|
-
.bp_base_button_module_button--
|
|
344
|
+
.bp_base_button_module_button--85575[data-modern=false]{
|
|
336
345
|
--button-border-radius:var(--radius-2);
|
|
337
346
|
}
|
|
338
|
-
.bp_base_button_module_button--
|
|
347
|
+
.bp_base_button_module_button--85575[data-modern=false]:not(:disabled)[data-focus-visible]{
|
|
339
348
|
box-shadow:0 0 0 var(--border-1, 1px) var(--background-background), 0 0 0 var(--border-3) var(--outline-focus-on-light);
|
|
340
349
|
}
|
|
341
|
-
.bp_base_button_module_button--
|
|
350
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_primary--85575{
|
|
342
351
|
--button-color:var(--text-text-brand-on-color);
|
|
343
352
|
--button-background:var(--surface-surface-brand);
|
|
344
353
|
--button-border:var(--border-1) solid var(--surface-surface-brand);
|
|
345
|
-
--button-disabled-background:var(--surface-surface-brand-disabled);
|
|
346
354
|
--button-focus-or-hover-background:var(--surface-surface-brand-hover);
|
|
347
355
|
--button-focus-or-hover-border:var(--border-1) solid var(--surface-surface-brand-hover);
|
|
348
356
|
--button-active-background:var(--surface-surface-brand-pressed);
|
|
349
357
|
--button-active-border:var(--border-1) solid var(--surface-surface-brand-pressed);
|
|
350
358
|
}
|
|
351
|
-
.bp_base_button_module_button--
|
|
359
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_secondary--85575{
|
|
352
360
|
--button-color:var(--text-text-on-light);
|
|
353
361
|
--button-background:var(--surface-cta-surface-secondary);
|
|
354
362
|
--button-border:var(--border-1) solid var(--border-cta-border-secondary);
|
|
@@ -356,15 +364,17 @@
|
|
|
356
364
|
--button-focus-or-hover-border:var(--border-1) solid var(--border-cta-border-secondary-hover);
|
|
357
365
|
--button-active-background:var(--surface-cta-surface-secondary-pressed);
|
|
358
366
|
--button-active-border:var(--border-1) solid var(--border-cta-border-secondary-pressed);
|
|
367
|
+
--button-backdrop-filter:none;
|
|
359
368
|
}
|
|
360
|
-
.bp_base_button_module_button--
|
|
369
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_tertiary--85575{
|
|
361
370
|
--button-color:var(--text-cta-link);
|
|
362
371
|
--button-background:#0000;
|
|
363
372
|
--button-border:var(--border-1) solid #0000;
|
|
364
373
|
--button-focus-or-hover-background:var(--surface-cta-surface-tertiary-hover);
|
|
365
374
|
--button-active-background:var(--surface-cta-surface-tertiary-pressed);
|
|
375
|
+
--button-backdrop-filter:none;
|
|
366
376
|
}
|
|
367
|
-
.bp_base_button_module_button--
|
|
377
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_outline--85575{
|
|
368
378
|
--button-color:var(--text-text-on-light);
|
|
369
379
|
--button-background:var(--surface-cta-surface-outline);
|
|
370
380
|
--button-border:var(--border-1) solid var(--border-cta-border-outline);
|
|
@@ -372,29 +382,36 @@
|
|
|
372
382
|
--button-focus-or-hover-border:var(--border-1) solid var(--border-cta-border-outline-hover);
|
|
373
383
|
--button-active-background:var(--surface-cta-surface-outline-pressed);
|
|
374
384
|
--button-active-border:var(--border-1) solid var(--border-cta-border-outline-pressed);
|
|
385
|
+
--button-backdrop-filter:none;
|
|
375
386
|
}
|
|
376
|
-
.bp_base_button_module_button--
|
|
387
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_small--85575{
|
|
377
388
|
--button-small-gap:var(--space-1);
|
|
378
389
|
--button-small-min-height:var(--size-8);
|
|
379
390
|
--button-small-padding:0 var(--space-4);
|
|
380
391
|
}
|
|
381
|
-
.bp_base_button_module_button--
|
|
392
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_small--85575.bp_base_button_module_isIconButton--85575{
|
|
382
393
|
--icon-button-small-width:var(--size-8);
|
|
383
394
|
--icon-button-small-height:var(--size-8);
|
|
384
395
|
--icon-button-small-padding:0 calc((var(--space-8) - var(--space-4))/2);
|
|
385
396
|
}
|
|
386
|
-
.bp_base_button_module_button--
|
|
397
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_small--85575.bp_base_button_module_isTextWithIconButton--85575{
|
|
398
|
+
--button-small-padding:0 var(--space-3);
|
|
399
|
+
}
|
|
400
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_large--85575{
|
|
387
401
|
--button-large-gap:var(--space-2);
|
|
388
402
|
--button-large-min-height:var(--size-10);
|
|
389
403
|
--button-large-padding:0 var(--space-4);
|
|
390
404
|
}
|
|
391
|
-
.bp_base_button_module_button--
|
|
405
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_large--85575.bp_base_button_module_isIconButton--85575{
|
|
392
406
|
--icon-button-large-width:var(--size-10);
|
|
393
407
|
--icon-button-large-height:var(--size-10);
|
|
394
408
|
--icon-button-large-padding:0 calc((var(--space-10) - var(--space-5))/2);
|
|
395
409
|
}
|
|
410
|
+
.bp_base_button_module_button--85575[data-modern=false].bp_base_button_module_large--85575.bp_base_button_module_isTextWithIconButton--85575{
|
|
411
|
+
--button-large-padding:0 var(--space-4);
|
|
412
|
+
}
|
|
396
413
|
|
|
397
|
-
.bp_base_button_module_button--
|
|
414
|
+
.bp_base_button_module_button--85575{
|
|
398
415
|
border-radius:var(--button-border-radius);
|
|
399
416
|
cursor:pointer;
|
|
400
417
|
font-family:var(--body-default-bold-font-family);
|
|
@@ -411,92 +428,98 @@
|
|
|
411
428
|
user-select:none;
|
|
412
429
|
white-space:nowrap;
|
|
413
430
|
}
|
|
414
|
-
.bp_base_button_module_button--
|
|
431
|
+
.bp_base_button_module_button--85575,.bp_base_button_module_button--85575 .bp_base_button_module_icon--85575{
|
|
415
432
|
align-items:center;
|
|
416
433
|
display:flex;
|
|
417
434
|
}
|
|
418
|
-
.bp_base_button_module_button--
|
|
435
|
+
.bp_base_button_module_button--85575:disabled{
|
|
419
436
|
opacity:.3;
|
|
420
437
|
}
|
|
421
|
-
.bp_base_button_module_button--
|
|
438
|
+
.bp_base_button_module_button--85575.bp_base_button_module_primary--85575{
|
|
422
439
|
background:var(--button-background);
|
|
423
440
|
border:var(--button-border);
|
|
424
441
|
color:var(--button-color);
|
|
425
442
|
}
|
|
426
|
-
.bp_base_button_module_button--
|
|
427
|
-
background:var(--button-disabled-background);
|
|
428
|
-
}
|
|
429
|
-
.bp_base_button_module_button--0e19f.bp_base_button_module_primary--0e19f:not(:disabled):hover,.bp_base_button_module_button--0e19f.bp_base_button_module_primary--0e19f:not(:disabled)[data-focus-visible]{
|
|
443
|
+
.bp_base_button_module_button--85575.bp_base_button_module_primary--85575:not(:disabled):hover,.bp_base_button_module_button--85575.bp_base_button_module_primary--85575:not(:disabled)[data-focus-visible]{
|
|
430
444
|
background:var(--button-focus-or-hover-background);
|
|
431
445
|
border:var(--button-focus-or-hover-border);
|
|
432
446
|
}
|
|
433
|
-
.bp_base_button_module_button--
|
|
447
|
+
.bp_base_button_module_button--85575.bp_base_button_module_primary--85575:not(:disabled):active{
|
|
434
448
|
background:var(--button-active-background);
|
|
435
449
|
border:var(--button-active-border);
|
|
436
450
|
}
|
|
437
|
-
.bp_base_button_module_button--
|
|
451
|
+
.bp_base_button_module_button--85575.bp_base_button_module_secondary--85575{
|
|
452
|
+
backdrop-filter:var(--button-backdrop-filter);
|
|
438
453
|
background:var(--button-background);
|
|
439
454
|
border:var(--button-border);
|
|
440
455
|
color:var(--button-color);
|
|
441
456
|
}
|
|
442
|
-
.bp_base_button_module_button--
|
|
457
|
+
.bp_base_button_module_button--85575.bp_base_button_module_secondary--85575:not(:disabled):hover,.bp_base_button_module_button--85575.bp_base_button_module_secondary--85575:not(:disabled)[data-focus-visible]{
|
|
443
458
|
background:var(--button-focus-or-hover-background);
|
|
444
459
|
border:var(--button-focus-or-hover-border);
|
|
445
460
|
}
|
|
446
|
-
.bp_base_button_module_button--
|
|
461
|
+
.bp_base_button_module_button--85575.bp_base_button_module_secondary--85575:not(:disabled):active{
|
|
447
462
|
background:var(--button-active-background);
|
|
448
463
|
border:var(--button-active-border);
|
|
449
464
|
}
|
|
450
|
-
.bp_base_button_module_button--
|
|
465
|
+
.bp_base_button_module_button--85575.bp_base_button_module_tertiary--85575{
|
|
466
|
+
backdrop-filter:var(--button-backdrop-filter);
|
|
451
467
|
background:var(--button-background);
|
|
452
468
|
border:var(--button-border);
|
|
453
469
|
color:var(--button-color);
|
|
454
470
|
}
|
|
455
|
-
.bp_base_button_module_button--
|
|
471
|
+
.bp_base_button_module_button--85575.bp_base_button_module_tertiary--85575:not(:disabled):hover,.bp_base_button_module_button--85575.bp_base_button_module_tertiary--85575:not(:disabled)[data-focus-visible]{
|
|
456
472
|
background:var(--button-focus-or-hover-background);
|
|
457
473
|
}
|
|
458
|
-
.bp_base_button_module_button--
|
|
474
|
+
.bp_base_button_module_button--85575.bp_base_button_module_tertiary--85575:not(:disabled):active{
|
|
459
475
|
background:var(--button-active-background);
|
|
460
476
|
}
|
|
461
|
-
.bp_base_button_module_button--
|
|
477
|
+
.bp_base_button_module_button--85575.bp_base_button_module_outline--85575{
|
|
478
|
+
backdrop-filter:var(--button-backdrop-filter);
|
|
462
479
|
background:var(--button-background);
|
|
463
480
|
border:var(--button-border);
|
|
464
481
|
color:var(--button-color);
|
|
465
482
|
}
|
|
466
|
-
.bp_base_button_module_button--
|
|
483
|
+
.bp_base_button_module_button--85575.bp_base_button_module_outline--85575:not(:disabled):hover,.bp_base_button_module_button--85575.bp_base_button_module_outline--85575:not(:disabled)[data-focus-visible]{
|
|
467
484
|
background:var(--button-focus-or-hover-background);
|
|
468
485
|
border:var(--button-focus-or-hover-border);
|
|
469
486
|
}
|
|
470
|
-
.bp_base_button_module_button--
|
|
487
|
+
.bp_base_button_module_button--85575.bp_base_button_module_outline--85575:not(:disabled):active{
|
|
471
488
|
background:var(--button-active-background);
|
|
472
489
|
border:var(--button-active-border);
|
|
473
490
|
}
|
|
474
|
-
.bp_base_button_module_button--
|
|
491
|
+
.bp_base_button_module_button--85575.bp_base_button_module_small--85575{
|
|
475
492
|
gap:var(--button-small-gap);
|
|
476
493
|
min-height:var(--button-small-min-height);
|
|
477
494
|
padding:var(--button-small-padding);
|
|
478
495
|
}
|
|
479
|
-
.bp_base_button_module_button--
|
|
496
|
+
.bp_base_button_module_button--85575.bp_base_button_module_small--85575.bp_base_button_module_isIconButton--85575{
|
|
480
497
|
height:var(--icon-button-small-height);
|
|
481
498
|
min-height:unset;
|
|
482
499
|
padding:var(--icon-button-small-padding);
|
|
483
500
|
width:var(--icon-button-small-width);
|
|
484
501
|
}
|
|
485
|
-
.bp_base_button_module_button--
|
|
502
|
+
.bp_base_button_module_button--85575.bp_base_button_module_small--85575.bp_base_button_module_isTextWithIconButton--85575{
|
|
503
|
+
padding:var(--button-small-padding);
|
|
504
|
+
}
|
|
505
|
+
.bp_base_button_module_button--85575.bp_base_button_module_large--85575{
|
|
486
506
|
gap:var(--button-large-gap);
|
|
487
507
|
min-height:var(--button-large-min-height);
|
|
488
508
|
padding:var(--button-large-padding);
|
|
489
509
|
}
|
|
490
|
-
.bp_base_button_module_button--
|
|
510
|
+
.bp_base_button_module_button--85575.bp_base_button_module_large--85575.bp_base_button_module_isIconButton--85575{
|
|
491
511
|
height:var(--icon-button-large-height);
|
|
492
512
|
padding:var(--icon-button-large-padding);
|
|
493
513
|
width:var(--icon-button-large-width);
|
|
494
514
|
}
|
|
495
|
-
.bp_base_button_module_button--
|
|
515
|
+
.bp_base_button_module_button--85575.bp_base_button_module_large--85575.bp_base_button_module_isTextWithIconButton--85575{
|
|
516
|
+
padding:var(--button-large-padding);
|
|
517
|
+
}
|
|
518
|
+
.bp_base_button_module_button--85575.bp_base_button_module_hide--85575{
|
|
496
519
|
pointer-events:none;
|
|
497
520
|
position:relative;
|
|
498
521
|
}
|
|
499
|
-
.bp_base_button_module_button--
|
|
522
|
+
.bp_base_button_module_button--85575.bp_base_button_module_hide--85575 span{
|
|
500
523
|
color:#0000;
|
|
501
524
|
opacity:0;
|
|
502
525
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
2
|
|
|
3
3
|
const BaseButtonContext = /*#__PURE__*/createContext({
|
|
4
|
-
isIconButton: false,
|
|
5
4
|
variant: 'primary',
|
|
6
|
-
size: 'small'
|
|
5
|
+
size: 'small',
|
|
6
|
+
buttonType: 'text-only'
|
|
7
7
|
});
|
|
8
8
|
const useBaseButtonContext = () => useContext(BaseButtonContext);
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useCallback, createElement } from 'react';
|
|
3
2
|
import clsx from 'clsx';
|
|
4
|
-
import {
|
|
3
|
+
import { forwardRef, useCallback, createElement } from 'react';
|
|
5
4
|
import { useBaseButtonContext } from './base-button-context.js';
|
|
6
5
|
import styles from './base-button.module.js';
|
|
6
|
+
import { getIconSize, buttonVariantToIconColorMap } from './utils.js';
|
|
7
7
|
|
|
8
8
|
const BaseButtonIcon = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
9
9
|
const {
|
|
@@ -14,29 +14,30 @@ const BaseButtonIcon = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
14
14
|
loading,
|
|
15
15
|
size,
|
|
16
16
|
variant,
|
|
17
|
-
|
|
17
|
+
buttonType,
|
|
18
18
|
ariaLabel
|
|
19
19
|
} = useBaseButtonContext();
|
|
20
|
+
const isIconOnly = buttonType === 'icon-only';
|
|
20
21
|
const renderIcon = useCallback(() => {
|
|
21
22
|
if (!icon) {
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
|
-
if (
|
|
25
|
+
if (isIconOnly && !ariaLabel) {
|
|
25
26
|
// eslint-disable-next-line no-console
|
|
26
27
|
console.warn('Icon only button must have an aria-label');
|
|
27
28
|
return null;
|
|
28
29
|
}
|
|
29
30
|
return /*#__PURE__*/createElement(icon, {
|
|
30
|
-
...getIconSize(size,
|
|
31
|
+
...getIconSize(size, isIconOnly),
|
|
31
32
|
color: loading ? 'transparent' : buttonVariantToIconColorMap[variant],
|
|
32
33
|
role: 'presentation',
|
|
33
34
|
...iconProps
|
|
34
35
|
});
|
|
35
|
-
}, [icon, size, loading, variant,
|
|
36
|
+
}, [icon, isIconOnly, ariaLabel, size, loading, variant, iconProps]);
|
|
36
37
|
return jsx("span", {
|
|
37
38
|
ref: forwardedRef,
|
|
38
39
|
className: clsx(styles.icon, {
|
|
39
|
-
[styles.isIconButton]:
|
|
40
|
+
[styles.isIconButton]: isIconOnly,
|
|
40
41
|
[styles.loading]: loading
|
|
41
42
|
}),
|
|
42
43
|
children: renderIcon()
|
|
@@ -8,6 +8,7 @@ import { getButtonOptions } from '../../utils/getButtonOptions.js';
|
|
|
8
8
|
import { useForkRef } from '../../utils/useForkRef.js';
|
|
9
9
|
import { BaseButtonContext } from './base-button-context.js';
|
|
10
10
|
import { BaseButtonIcon } from './base-button-icon.js';
|
|
11
|
+
import { BaseButtonLabel } from './base-button-label.js';
|
|
11
12
|
import styles from './base-button.module.js';
|
|
12
13
|
import { loadingIndicatorVariantMap } from './utils.js';
|
|
13
14
|
|
|
@@ -26,24 +27,32 @@ const BaseButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
26
27
|
enableModernizedComponents
|
|
27
28
|
} = useBlueprintModernization();
|
|
28
29
|
const ref = useRef(null);
|
|
29
|
-
const
|
|
30
|
+
const buttonType = useMemo(() => {
|
|
30
31
|
const childArray = Children.toArray(children);
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const hasIcon = childArray.some(child => /*#__PURE__*/isValidElement(child) && child.type === BaseButtonIcon);
|
|
33
|
+
const hasText = childArray.some(child => /*#__PURE__*/isValidElement(child) && child.type === BaseButtonLabel);
|
|
34
|
+
if (hasIcon && hasText) {
|
|
35
|
+
return 'text-with-icon';
|
|
36
|
+
}
|
|
37
|
+
if (hasIcon && !hasText) {
|
|
38
|
+
return 'icon-only';
|
|
39
|
+
}
|
|
40
|
+
return 'text-only';
|
|
33
41
|
}, [children]);
|
|
34
42
|
const context = useMemo(() => ({
|
|
35
43
|
ariaLabel,
|
|
36
44
|
loading,
|
|
37
45
|
size,
|
|
38
46
|
variant,
|
|
39
|
-
|
|
40
|
-
}), [ariaLabel, loading, size, variant,
|
|
47
|
+
buttonType
|
|
48
|
+
}), [ariaLabel, loading, size, variant, buttonType]);
|
|
41
49
|
return jsx(Button, {
|
|
42
50
|
...rest,
|
|
43
51
|
ref: useForkRef(ref, forwardedRef),
|
|
44
52
|
"aria-label": loading ? undefined : ariaLabel,
|
|
45
53
|
className: clsx([styles.button, styles[variant], styles[size]], {
|
|
46
|
-
[styles.isIconButton]:
|
|
54
|
+
[styles.isIconButton]: buttonType === 'icon-only',
|
|
55
|
+
[styles.isTextWithIconButton]: buttonType === 'text-with-icon',
|
|
47
56
|
[styles.hide]: loading
|
|
48
57
|
}, className),
|
|
49
58
|
"data-modern": enableModernizedComponents,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"button":"bp_base_button_module_button--
|
|
2
|
+
var styles = {"button":"bp_base_button_module_button--85575","primary":"bp_base_button_module_primary--85575","secondary":"bp_base_button_module_secondary--85575","tertiary":"bp_base_button_module_tertiary--85575","outline":"bp_base_button_module_outline--85575","small":"bp_base_button_module_small--85575","isIconButton":"bp_base_button_module_isIconButton--85575","isTextWithIconButton":"bp_base_button_module_isTextWithIconButton--85575","large":"bp_base_button_module_large--85575","icon":"bp_base_button_module_icon--85575","hide":"bp_base_button_module_hide--85575"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -24,5 +24,5 @@ export type BaseButtonIconProps = ComponentPropsWithRef<'span'> & {
|
|
|
24
24
|
};
|
|
25
25
|
export type BaseButtonContextType = Pick<BaseButtonProps, 'loading'> & Required<Pick<BaseButtonProps, 'variant' | 'size'>> & {
|
|
26
26
|
ariaLabel?: BaseButtonProps['aria-label'];
|
|
27
|
-
|
|
27
|
+
buttonType: 'text-only' | 'icon-only' | 'text-with-icon';
|
|
28
28
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LoadingIndicatorProps } from '../../loading-indicator/loading-indicator';
|
|
2
2
|
import { type BaseButtonProps } from './types';
|
|
3
|
-
export declare const getIconSize: (buttonSize: NonNullable<BaseButtonProps["size"]>, isIconButton: boolean) => {
|
|
3
|
+
export declare const getIconSize: (buttonSize: NonNullable<BaseButtonProps["size"]>, isIconButton: boolean, enableModernizedComponents?: boolean) => {
|
|
4
4
|
readonly width: string;
|
|
5
5
|
readonly height: string;
|
|
6
6
|
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { IconIconOnDark, IconIconOnLight, TextCtaLink, Size5, Size4, Size3 } from '@box/blueprint-web-assets/tokens/tokens';
|
|
1
|
+
import { IconIconOnDark, IconIconOnLight, TextCtaLink, bpSize050, bpSize040, bpSize030, Size5, Size4, Size3 } from '@box/blueprint-web-assets/tokens/tokens';
|
|
2
2
|
|
|
3
|
-
const getIconSize = (buttonSize, isIconButton) => {
|
|
3
|
+
const getIconSize = (buttonSize, isIconButton, enableModernizedComponents = false) => {
|
|
4
|
+
const isLarge = buttonSize === 'large';
|
|
4
5
|
let size;
|
|
5
|
-
if (isIconButton) {
|
|
6
|
-
size =
|
|
6
|
+
if (enableModernizedComponents && isIconButton) {
|
|
7
|
+
size = isLarge ? bpSize050 : bpSize040;
|
|
8
|
+
} else if (enableModernizedComponents && !isIconButton) {
|
|
9
|
+
size = isLarge ? bpSize040 : bpSize030;
|
|
10
|
+
} else if (!enableModernizedComponents && isIconButton) {
|
|
11
|
+
size = isLarge ? Size5 : Size4;
|
|
7
12
|
} else {
|
|
8
|
-
size =
|
|
13
|
+
size = isLarge ? Size4 : Size3;
|
|
9
14
|
}
|
|
10
15
|
return {
|
|
11
16
|
width: size,
|
|
@@ -12,9 +12,19 @@ interface ColorProps {
|
|
|
12
12
|
colorIndex?: number;
|
|
13
13
|
}
|
|
14
14
|
type CommonProps = {
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Text inside the Status. Needs to be an UPPERCASED string.
|
|
17
|
+
* This text is used as an icon's aria-label when hideText is true.
|
|
18
|
+
* Passing an empty string or null should only be done in exceptional cases,
|
|
19
|
+
* when the status does not have any meaning that can be conveyed by a screen reader
|
|
20
|
+
* or an icon with aria-label is already passed.
|
|
21
|
+
*/
|
|
16
22
|
text: string;
|
|
17
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Hide the text visually, but it will still be available to screen readers.
|
|
25
|
+
* This can be useful for accessibility purposes when the visual text is not needed.
|
|
26
|
+
* When hideText is true, the text is used as an icon's aria-label.
|
|
27
|
+
*/
|
|
18
28
|
hideText?: boolean;
|
|
19
29
|
/** Should the component be interactive (button without onClick) */
|
|
20
30
|
interactive?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "12.69.
|
|
3
|
+
"version": "12.69.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@ariakit/react": "0.4.15",
|
|
49
49
|
"@ariakit/react-core": "0.4.15",
|
|
50
|
-
"@box/blueprint-web-assets": "^4.
|
|
50
|
+
"@box/blueprint-web-assets": "^4.67.0",
|
|
51
51
|
"@internationalized/date": "^3.7.0",
|
|
52
52
|
"@radix-ui/react-accordion": "1.1.2",
|
|
53
53
|
"@radix-ui/react-checkbox": "1.0.4",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"type-fest": "^3.2.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@box/storybook-utils": "^0.14.
|
|
80
|
+
"@box/storybook-utils": "^0.14.3",
|
|
81
81
|
"@types/react": "^18.0.0",
|
|
82
82
|
"@types/react-dom": "^18.0.0",
|
|
83
83
|
"react": "^18.3.0",
|