@xsolla/xui-b2b-sidebar 0.158.0 → 0.160.0

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/native/index.mjs CHANGED
@@ -18,7 +18,9 @@ var DefaultLink = ({
18
18
  className,
19
19
  children,
20
20
  dataId,
21
- onClick
21
+ testID,
22
+ onClick,
23
+ "aria-label": ariaLabel
22
24
  }) => /* @__PURE__ */ jsx(
23
25
  "a",
24
26
  {
@@ -27,6 +29,8 @@ var DefaultLink = ({
27
29
  target: external ? target ?? "_blank" : target ?? void 0,
28
30
  rel: external ? "noopener noreferrer" : void 0,
29
31
  "data-id": dataId,
32
+ "data-testid": testID,
33
+ "aria-label": ariaLabel,
30
34
  onClick,
31
35
  children
32
36
  }
@@ -382,6 +386,62 @@ var SingleLinkWrap = styled.div`
382
386
  text-decoration: none;
383
387
  }
384
388
  `;
389
+ var CollapsedIconLinkWrap = styled.div`
390
+ width: ${(p) => p.$size}px;
391
+ height: ${(p) => p.$size}px;
392
+ flex-shrink: 0;
393
+
394
+ & > a,
395
+ & > * {
396
+ display: flex;
397
+ width: 100%;
398
+ height: 100%;
399
+ align-items: center;
400
+ justify-content: center;
401
+ border: 0;
402
+ border-radius: ${(p) => p.$radius}px;
403
+ background: ${(p) => p.$active ? p.$activeBg : "transparent"};
404
+ color: ${(p) => p.$active ? p.$hoverColor : p.$color};
405
+ cursor: pointer;
406
+ padding: 0;
407
+ font: inherit;
408
+ text-decoration: none;
409
+ transition:
410
+ background-color 0.15s ease-in-out,
411
+ color 0.15s ease-in-out;
412
+
413
+ ${(p) => p.$active && `
414
+ outline: 1px solid ${p.$activeOutline};
415
+ outline-offset: -1px;
416
+ `}
417
+ }
418
+
419
+ & > a:hover,
420
+ & > *:hover {
421
+ background-color: ${(p) => p.$hoverBg};
422
+ color: ${(p) => p.$hoverColor};
423
+ }
424
+
425
+ & > a:focus-visible,
426
+ & > *:focus-visible {
427
+ outline: ${(p) => p.$focusOutlineWidth}px solid ${(p) => p.$focusOutline};
428
+ outline-offset: -${(p) => p.$focusOutlineWidth}px;
429
+ }
430
+
431
+ & > a > span,
432
+ & > * > span {
433
+ display: flex;
434
+ width: ${(p) => p.$iconSize}px;
435
+ height: ${(p) => p.$iconSize}px;
436
+ align-items: center;
437
+ justify-content: center;
438
+
439
+ svg {
440
+ width: ${(p) => p.$iconSize}px;
441
+ height: ${(p) => p.$iconSize}px;
442
+ }
443
+ }
444
+ `;
385
445
  var isChildActive = (item, pathname) => {
386
446
  if (!item.children || !pathname) {
387
447
  return false;
@@ -396,6 +456,7 @@ var isChildActive = (item, pathname) => {
396
456
  };
397
457
  var CollapsedIconItem = ({ item, onPopoverOpen, onPopoverClose, pathname, sizing, colors }) => {
398
458
  const ref = useRef(null);
459
+ const { LinkComponent } = useSidebar();
399
460
  const hasChildren = Boolean(item.children && item.children.length > 0);
400
461
  const isActive = hasChildren && isChildActive(item, pathname);
401
462
  const openPopover = useCallback2(() => {
@@ -421,6 +482,42 @@ var CollapsedIconItem = ({ item, onPopoverOpen, onPopoverClose, pathname, sizing
421
482
  if (!item.icon) {
422
483
  return null;
423
484
  }
485
+ if (!hasChildren) {
486
+ return /* @__PURE__ */ jsx3(
487
+ CollapsedIconLinkWrap,
488
+ {
489
+ ref,
490
+ onMouseEnter: openPopover,
491
+ onMouseLeave: onPopoverClose,
492
+ onFocus: openPopover,
493
+ onBlur: onPopoverClose,
494
+ "data-id": item.dataId,
495
+ $size: sizing.itemHeight,
496
+ $radius: sizing.radius,
497
+ $iconSize: sizing.iconSize,
498
+ $color: colors.content.tertiary,
499
+ $hoverBg: colors.overlay.mono,
500
+ $hoverColor: colors.content.primary,
501
+ $activeBg: colors.overlay.mono,
502
+ $activeOutline: colors.border.secondary,
503
+ $focusOutline: colors.border.brand,
504
+ $focusOutlineWidth: sizing.focusOutlineWidth,
505
+ $active: isSimpleActive,
506
+ children: /* @__PURE__ */ jsx3(
507
+ LinkComponent,
508
+ {
509
+ to: item.to,
510
+ exact: item.exact,
511
+ external: item.external,
512
+ target: item.target,
513
+ dataId: item.dataId,
514
+ "aria-label": typeof item.label === "string" ? item.label : void 0,
515
+ children: /* @__PURE__ */ jsx3("span", { children: item.icon })
516
+ }
517
+ )
518
+ }
519
+ );
520
+ }
424
521
  return /* @__PURE__ */ jsx3(
425
522
  IconBtn,
426
523
  {
@@ -432,7 +529,7 @@ var CollapsedIconItem = ({ item, onPopoverOpen, onPopoverClose, pathname, sizing
432
529
  onBlur: onPopoverClose,
433
530
  onKeyDown: handleKeyDown,
434
531
  "data-id": item.dataId,
435
- "aria-haspopup": hasChildren ? "menu" : "false",
532
+ "aria-haspopup": "menu",
436
533
  $size: sizing.itemHeight,
437
534
  $radius: sizing.radius,
438
535
  $iconSize: sizing.iconSize,