@7onic-ui/react 0.3.13 → 0.3.15

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.
@@ -8,7 +8,7 @@ import {
8
8
  BreadcrumbPage,
9
9
  BreadcrumbSeparator,
10
10
  breadcrumbSizeMap
11
- } from "../chunk-ZN7DBSKH.mjs";
11
+ } from "../chunk-MUAIQGMU.mjs";
12
12
  import "../chunk-53MIUPSY.mjs";
13
13
  export {
14
14
  Breadcrumb,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  Button,
4
4
  buttonVariants
5
- } from "../chunk-IPCIC2BI.mjs";
5
+ } from "../chunk-YJFM5CG5.mjs";
6
6
  import "../chunk-Q5WVLK2L.mjs";
7
7
  import "../chunk-53MIUPSY.mjs";
8
8
  export {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  IconButton,
4
4
  iconButtonVariants
5
- } from "../chunk-ZDRUTJ4T.mjs";
5
+ } from "../chunk-CAKZAZRW.mjs";
6
6
  import "../chunk-Q5WVLK2L.mjs";
7
7
  import "../chunk-53MIUPSY.mjs";
8
8
  export {
@@ -10,7 +10,7 @@ import {
10
10
  NavigationMenuTrigger,
11
11
  NavigationMenuViewport,
12
12
  navigationMenuSizeMap
13
- } from "../chunk-C5D3VRNJ.mjs";
13
+ } from "../chunk-4ATPYNTP.mjs";
14
14
  import "../chunk-53MIUPSY.mjs";
15
15
  export {
16
16
  NavigationMenu,
package/dist/index.d.ts CHANGED
@@ -713,7 +713,7 @@ interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps
713
713
  icon?: React.ReactNode;
714
714
  /** Show a status dot before text */
715
715
  dot?: boolean;
716
- /** Show a remove button */
716
+ /** Show a remove button (not rendered with asChild — a button inside a link is invalid HTML) */
717
717
  removable?: boolean;
718
718
  /** Callback when remove button is clicked */
719
719
  onRemove?: () => void;
package/dist/index.js CHANGED
@@ -587,24 +587,30 @@ function flattenFragments(children) {
587
587
  ) : [node]
588
588
  );
589
589
  }
590
+ function classifyNodes(nodes) {
591
+ const known = nodes.map((node) => {
592
+ const type = React2.isValidElement(node) ? node.type : null;
593
+ return type === BreadcrumbSeparator ? "separator" : type === BreadcrumbItem ? "item" : null;
594
+ });
595
+ if (known.every((kind) => kind === null)) {
596
+ return nodes.map((_, i) => i % 2 === 0 ? "item" : "separator");
597
+ }
598
+ return known.map((kind) => kind ?? "item");
599
+ }
590
600
  function collapseItems(children, maxItems, before, after) {
591
601
  if (maxItems === void 0) return children;
592
602
  const nodes = flattenFragments(children);
603
+ const kinds = classifyNodes(nodes);
593
604
  const segments = [];
594
605
  let pendingSeparator = null;
595
- for (const node of nodes) {
596
- const type = React2.isValidElement(node) ? node.type : null;
597
- if (type === BreadcrumbSeparator) {
606
+ nodes.forEach((node, i) => {
607
+ if (kinds[i] === "separator") {
598
608
  pendingSeparator = node;
599
- } else if (type === BreadcrumbItem) {
609
+ } else {
600
610
  segments.push({ separator: pendingSeparator, nodes: [node] });
601
611
  pendingSeparator = null;
602
- } else if (segments.length > 0) {
603
- segments[segments.length - 1].nodes.push(node);
604
- } else {
605
- segments.push({ separator: null, nodes: [node] });
606
612
  }
607
- }
613
+ });
608
614
  if (segments.length <= maxItems || before + after >= segments.length) return children;
609
615
  const head = segments.slice(0, before);
610
616
  const tail = segments.slice(segments.length - after);
@@ -860,6 +866,16 @@ var buttonVariants = (0, import_class_variance_authority3.cva)(
860
866
  }
861
867
  }
862
868
  );
869
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
870
+ function renderInsideChild(children, render) {
871
+ let child = children;
872
+ const resolve = React5.use;
873
+ if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE && typeof resolve === "function") {
874
+ child = resolve(child._payload);
875
+ }
876
+ if (!React5.isValidElement(child)) return render(children);
877
+ return React5.cloneElement(child, void 0, render(child.props.children));
878
+ }
863
879
  var Button = React5.forwardRef(
864
880
  ({
865
881
  className,
@@ -903,6 +919,17 @@ var Button = React5.forwardRef(
903
919
  // icon-only → 20px
904
920
  }[size || "default"];
905
921
  const selectedStyles = selected ? variant === "outline" ? "bg-background-muted" : variant === "ghost" ? "font-semibold" : "" : "";
922
+ const renderContent = (content) => loading ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
923
+ "svg",
924
+ {
925
+ className: cn(iconSizeClass, "animate-spin"),
926
+ fill: "none",
927
+ viewBox: "0 0 24 24",
928
+ "aria-hidden": "true"
929
+ },
930
+ /* @__PURE__ */ React5.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
931
+ /* @__PURE__ */ React5.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
932
+ ), /* @__PURE__ */ React5.createElement("span", null, content)) : /* @__PURE__ */ React5.createElement(React5.Fragment, null, leftIcon && /* @__PURE__ */ React5.createElement("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true" }, leftIcon), content, rightIcon && /* @__PURE__ */ React5.createElement("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true" }, rightIcon));
906
933
  return /* @__PURE__ */ React5.createElement(
907
934
  Comp,
908
935
  {
@@ -913,17 +940,7 @@ var Button = React5.forwardRef(
913
940
  "aria-pressed": selected || void 0,
914
941
  ...props
915
942
  },
916
- loading ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
917
- "svg",
918
- {
919
- className: cn(iconSizeClass, "animate-spin"),
920
- fill: "none",
921
- viewBox: "0 0 24 24",
922
- "aria-hidden": "true"
923
- },
924
- /* @__PURE__ */ React5.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
925
- /* @__PURE__ */ React5.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
926
- ), /* @__PURE__ */ React5.createElement("span", null, children)) : /* @__PURE__ */ React5.createElement(React5.Fragment, null, leftIcon && /* @__PURE__ */ React5.createElement("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true" }, leftIcon), children, rightIcon && /* @__PURE__ */ React5.createElement("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true" }, rightIcon))
943
+ asChild ? renderInsideChild(children, renderContent) : renderContent(children)
927
944
  );
928
945
  }
929
946
  );
@@ -989,6 +1006,16 @@ var iconButtonVariants = (0, import_class_variance_authority4.cva)(
989
1006
  }
990
1007
  }
991
1008
  );
1009
+ var REACT_LAZY_TYPE2 = /* @__PURE__ */ Symbol.for("react.lazy");
1010
+ function renderInsideChild2(children, render) {
1011
+ let child = children;
1012
+ const resolve = React6.use;
1013
+ if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE2 && typeof resolve === "function") {
1014
+ child = resolve(child._payload);
1015
+ }
1016
+ if (!React6.isValidElement(child)) return render(children);
1017
+ return React6.cloneElement(child, void 0, render(child.props.children));
1018
+ }
992
1019
  var IconButton = React6.forwardRef(
993
1020
  ({ className, variant: variantProp, color: colorProp, size: sizeProp, radius: radiusProp, asChild = false, loading, pressEffect, children, disabled: disabledProp, ...props }, ref) => {
994
1021
  const groupContext = useButtonGroup();
@@ -1010,6 +1037,17 @@ var IconButton = React6.forwardRef(
1010
1037
  lg: "icon-lg"
1011
1038
  // 24px
1012
1039
  }[size || "default"];
1040
+ const renderContent = (content) => loading ? /* @__PURE__ */ React6.createElement(
1041
+ "svg",
1042
+ {
1043
+ className: cn(iconSize, "animate-spin"),
1044
+ fill: "none",
1045
+ viewBox: "0 0 24 24",
1046
+ "aria-hidden": "true"
1047
+ },
1048
+ /* @__PURE__ */ React6.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
1049
+ /* @__PURE__ */ React6.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
1050
+ ) : /* @__PURE__ */ React6.createElement("span", { className: cn(iconSize, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true" }, content);
1013
1051
  return /* @__PURE__ */ React6.createElement(
1014
1052
  Comp,
1015
1053
  {
@@ -1019,17 +1057,7 @@ var IconButton = React6.forwardRef(
1019
1057
  "aria-busy": loading || void 0,
1020
1058
  ...props
1021
1059
  },
1022
- loading ? /* @__PURE__ */ React6.createElement(
1023
- "svg",
1024
- {
1025
- className: cn(iconSize, "animate-spin"),
1026
- fill: "none",
1027
- viewBox: "0 0 24 24",
1028
- "aria-hidden": "true"
1029
- },
1030
- /* @__PURE__ */ React6.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
1031
- /* @__PURE__ */ React6.createElement("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
1032
- ) : /* @__PURE__ */ React6.createElement("span", { className: cn(iconSize, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true" }, children)
1060
+ asChild ? renderInsideChild2(children, renderContent) : renderContent(children)
1033
1061
  );
1034
1062
  }
1035
1063
  );
@@ -3521,6 +3549,16 @@ var dotColorMap = {
3521
3549
  error: "bg-error",
3522
3550
  info: "bg-info"
3523
3551
  };
3552
+ var REACT_LAZY_TYPE3 = /* @__PURE__ */ Symbol.for("react.lazy");
3553
+ function renderInsideChild3(children, render) {
3554
+ let child = children;
3555
+ const resolve = React21.use;
3556
+ if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE3 && typeof resolve === "function") {
3557
+ child = resolve(child._payload);
3558
+ }
3559
+ if (!React21.isValidElement(child)) return render(children);
3560
+ return React21.cloneElement(child, void 0, render(child.props.children));
3561
+ }
3524
3562
  var Badge = React21.forwardRef(
3525
3563
  ({
3526
3564
  className,
@@ -3541,6 +3579,43 @@ var Badge = React21.forwardRef(
3541
3579
  const colorClasses = colorMap[color][variant];
3542
3580
  const outlineClasses = variant === "outline" ? "border bg-transparent" : "";
3543
3581
  const dotColor = variant === "solid" ? "bg-current" : dotColorMap[color];
3582
+ const renderContent = (content) => /* @__PURE__ */ React21.createElement(React21.Fragment, null, dot && /* @__PURE__ */ React21.createElement(
3583
+ "span",
3584
+ {
3585
+ className: cn("shrink-0 rounded-full", badgeDotSizes[resolvedSize], dotColor),
3586
+ "aria-hidden": "true"
3587
+ }
3588
+ ), icon && /* @__PURE__ */ React21.createElement(
3589
+ "span",
3590
+ {
3591
+ className: cn("shrink-0 [&>svg]:w-full [&>svg]:h-full", badgeIconSizes[resolvedSize]),
3592
+ "aria-hidden": "true"
3593
+ },
3594
+ icon
3595
+ ), content, removable && !asChild && /* @__PURE__ */ React21.createElement(
3596
+ "button",
3597
+ {
3598
+ type: "button",
3599
+ className: "shrink-0 -mr-0.5 ml-0.5 rounded-full p-0.5 opacity-70 hover:opacity-100 transition-opacity focus-visible:focus-ring",
3600
+ onClick: (e) => {
3601
+ e.stopPropagation();
3602
+ onRemove?.();
3603
+ },
3604
+ "aria-label": "Remove"
3605
+ },
3606
+ /* @__PURE__ */ React21.createElement(
3607
+ "svg",
3608
+ {
3609
+ className: "w-3 h-3",
3610
+ fill: "none",
3611
+ viewBox: "0 0 24 24",
3612
+ stroke: "currentColor",
3613
+ strokeWidth: 2,
3614
+ "aria-hidden": "true"
3615
+ },
3616
+ /* @__PURE__ */ React21.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
3617
+ )
3618
+ ));
3544
3619
  return /* @__PURE__ */ React21.createElement(
3545
3620
  Comp,
3546
3621
  {
@@ -3553,46 +3628,7 @@ var Badge = React21.forwardRef(
3553
3628
  ),
3554
3629
  ...props
3555
3630
  },
3556
- dot && /* @__PURE__ */ React21.createElement(
3557
- "span",
3558
- {
3559
- className: cn("shrink-0 rounded-full", badgeDotSizes[resolvedSize], dotColor),
3560
- "aria-hidden": "true"
3561
- }
3562
- ),
3563
- icon && /* @__PURE__ */ React21.createElement(
3564
- "span",
3565
- {
3566
- className: cn("shrink-0 [&>svg]:w-full [&>svg]:h-full", badgeIconSizes[resolvedSize]),
3567
- "aria-hidden": "true"
3568
- },
3569
- icon
3570
- ),
3571
- children,
3572
- removable && /* @__PURE__ */ React21.createElement(
3573
- "button",
3574
- {
3575
- type: "button",
3576
- className: "shrink-0 -mr-0.5 ml-0.5 rounded-full p-0.5 opacity-70 hover:opacity-100 transition-opacity focus-visible:focus-ring",
3577
- onClick: (e) => {
3578
- e.stopPropagation();
3579
- onRemove?.();
3580
- },
3581
- "aria-label": "Remove"
3582
- },
3583
- /* @__PURE__ */ React21.createElement(
3584
- "svg",
3585
- {
3586
- className: "w-3 h-3",
3587
- fill: "none",
3588
- viewBox: "0 0 24 24",
3589
- stroke: "currentColor",
3590
- strokeWidth: 2,
3591
- "aria-hidden": "true"
3592
- },
3593
- /* @__PURE__ */ React21.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
3594
- )
3595
- )
3631
+ asChild ? renderInsideChild3(children, renderContent) : renderContent(children)
3596
3632
  );
3597
3633
  }
3598
3634
  );
@@ -4287,6 +4323,16 @@ function ChevronDownIcon({ className }) {
4287
4323
  function ChevronRightIcon2({ className }) {
4288
4324
  return /* @__PURE__ */ React25.createElement("svg", { className, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, "aria-hidden": "true" }, /* @__PURE__ */ React25.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" }));
4289
4325
  }
4326
+ var REACT_LAZY_TYPE4 = /* @__PURE__ */ Symbol.for("react.lazy");
4327
+ function renderInsideChild4(children, render) {
4328
+ let child = children;
4329
+ const resolve = React25.use;
4330
+ if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE4 && typeof resolve === "function") {
4331
+ child = resolve(child._payload);
4332
+ }
4333
+ if (!React25.isValidElement(child)) return render(children);
4334
+ return React25.cloneElement(child, void 0, render(child.props.children));
4335
+ }
4290
4336
  var contentRadiusMap3 = {
4291
4337
  sm: "rounded",
4292
4338
  // 4px
@@ -4636,7 +4682,10 @@ var NavigationMenuLink = React25.forwardRef(
4636
4682
  );
4637
4683
  }
4638
4684
  const Comp = asChild ? import_react_slot6.Slot : "a";
4685
+ const iconNode = icon && /* @__PURE__ */ React25.createElement("span", { className: cn("shrink-0", s.icon) }, icon);
4686
+ const childText = asChild && React25.isValidElement(children) ? children.props.children : children;
4639
4687
  if (inContent) {
4688
+ const renderContent2 = (content) => /* @__PURE__ */ React25.createElement(React25.Fragment, null, iconNode, !collapsed && content);
4640
4689
  return /* @__PURE__ */ React25.createElement(
4641
4690
  Comp,
4642
4691
  {
@@ -4654,10 +4703,10 @@ var NavigationMenuLink = React25.forwardRef(
4654
4703
  ...active ? { "aria-current": "page" } : {},
4655
4704
  ...props
4656
4705
  },
4657
- icon && /* @__PURE__ */ React25.createElement("span", { className: cn("shrink-0", s.icon) }, icon),
4658
- !collapsed && children
4706
+ asChild ? renderInsideChild4(children, renderContent2) : renderContent2(children)
4659
4707
  );
4660
4708
  }
4709
+ const renderContent = (content) => /* @__PURE__ */ React25.createElement(React25.Fragment, null, iconNode, !collapsed && /* @__PURE__ */ React25.createElement("span", { className: "truncate" }, content));
4661
4710
  return /* @__PURE__ */ React25.createElement(
4662
4711
  Comp,
4663
4712
  {
@@ -4673,11 +4722,10 @@ var NavigationMenuLink = React25.forwardRef(
4673
4722
  className
4674
4723
  ),
4675
4724
  ...active ? { "aria-current": "page" } : {},
4676
- ...collapsed && typeof children === "string" ? { title: children } : {},
4725
+ ...collapsed && typeof childText === "string" ? { title: childText } : {},
4677
4726
  ...props
4678
4727
  },
4679
- icon && /* @__PURE__ */ React25.createElement("span", { className: cn("shrink-0", s.icon) }, icon),
4680
- !collapsed && /* @__PURE__ */ React25.createElement("span", { className: "truncate" }, children)
4728
+ asChild ? renderInsideChild4(children, renderContent) : renderContent(children)
4681
4729
  );
4682
4730
  }
4683
4731
  );