@karakuri-ui/react 0.3.9 → 0.3.11

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.
Files changed (79) hide show
  1. package/dist/components/ui/accordion.d.mts +1 -1
  2. package/dist/components/ui/accordion.d.ts +1 -1
  3. package/dist/components/ui/alert.d.mts +2 -2
  4. package/dist/components/ui/alert.d.ts +2 -2
  5. package/dist/components/ui/avatar.d.mts +1 -1
  6. package/dist/components/ui/avatar.d.ts +1 -1
  7. package/dist/components/ui/badge.d.mts +2 -2
  8. package/dist/components/ui/badge.d.ts +2 -2
  9. package/dist/components/ui/badge.js +54 -43
  10. package/dist/components/ui/badge.js.map +1 -1
  11. package/dist/components/ui/badge.mjs +55 -44
  12. package/dist/components/ui/badge.mjs.map +1 -1
  13. package/dist/components/ui/breadcrumb.js +15 -9
  14. package/dist/components/ui/breadcrumb.js.map +1 -1
  15. package/dist/components/ui/breadcrumb.mjs +15 -9
  16. package/dist/components/ui/breadcrumb.mjs.map +1 -1
  17. package/dist/components/ui/button.d.mts +2 -2
  18. package/dist/components/ui/button.d.ts +2 -2
  19. package/dist/components/ui/button.js +31 -20
  20. package/dist/components/ui/button.js.map +1 -1
  21. package/dist/components/ui/button.mjs +31 -20
  22. package/dist/components/ui/button.mjs.map +1 -1
  23. package/dist/components/ui/card.d.mts +2 -2
  24. package/dist/components/ui/card.d.ts +2 -2
  25. package/dist/components/ui/chart.d.mts +1 -1
  26. package/dist/components/ui/chart.d.ts +1 -1
  27. package/dist/components/ui/checkbox.d.mts +1 -1
  28. package/dist/components/ui/checkbox.d.ts +1 -1
  29. package/dist/components/ui/divider.d.mts +1 -1
  30. package/dist/components/ui/divider.d.ts +1 -1
  31. package/dist/components/ui/drawer.d.mts +2 -2
  32. package/dist/components/ui/drawer.d.ts +2 -2
  33. package/dist/components/ui/field.d.mts +1 -1
  34. package/dist/components/ui/field.d.ts +1 -1
  35. package/dist/components/ui/icon-button.d.mts +2 -2
  36. package/dist/components/ui/icon-button.d.ts +2 -2
  37. package/dist/components/ui/icon-button.js +24 -13
  38. package/dist/components/ui/icon-button.js.map +1 -1
  39. package/dist/components/ui/icon-button.mjs +24 -13
  40. package/dist/components/ui/icon-button.mjs.map +1 -1
  41. package/dist/components/ui/input.d.mts +2 -2
  42. package/dist/components/ui/input.d.ts +2 -2
  43. package/dist/components/ui/metric-card.d.mts +2 -2
  44. package/dist/components/ui/metric-card.d.ts +2 -2
  45. package/dist/components/ui/modal.d.mts +2 -2
  46. package/dist/components/ui/modal.d.ts +2 -2
  47. package/dist/components/ui/navigation-menu.js +25 -11
  48. package/dist/components/ui/navigation-menu.js.map +1 -1
  49. package/dist/components/ui/navigation-menu.mjs +25 -11
  50. package/dist/components/ui/navigation-menu.mjs.map +1 -1
  51. package/dist/components/ui/pagination.d.mts +1 -1
  52. package/dist/components/ui/pagination.d.ts +1 -1
  53. package/dist/components/ui/popover.d.mts +1 -1
  54. package/dist/components/ui/popover.d.ts +1 -1
  55. package/dist/components/ui/progress.d.mts +1 -1
  56. package/dist/components/ui/progress.d.ts +1 -1
  57. package/dist/components/ui/radio-group.d.mts +1 -1
  58. package/dist/components/ui/radio-group.d.ts +1 -1
  59. package/dist/components/ui/segmented.d.mts +4 -4
  60. package/dist/components/ui/segmented.d.ts +4 -4
  61. package/dist/components/ui/slider.d.mts +1 -1
  62. package/dist/components/ui/slider.d.ts +1 -1
  63. package/dist/components/ui/spinner.d.mts +1 -1
  64. package/dist/components/ui/spinner.d.ts +1 -1
  65. package/dist/components/ui/switch.d.mts +1 -1
  66. package/dist/components/ui/switch.d.ts +1 -1
  67. package/dist/components/ui/tabs.d.mts +1 -1
  68. package/dist/components/ui/tabs.d.ts +1 -1
  69. package/dist/components/ui/textarea.d.mts +1 -1
  70. package/dist/components/ui/textarea.d.ts +1 -1
  71. package/dist/components/ui/toast.d.mts +1 -1
  72. package/dist/components/ui/toast.d.ts +1 -1
  73. package/dist/components/ui/toggle-group.d.mts +2 -2
  74. package/dist/components/ui/toggle-group.d.ts +2 -2
  75. package/dist/components/ui/toggle.d.mts +2 -2
  76. package/dist/components/ui/toggle.d.ts +2 -2
  77. package/dist/components/ui/tooltip.d.mts +1 -1
  78. package/dist/components/ui/tooltip.d.ts +1 -1
  79. package/package.json +5 -5
@@ -25,7 +25,7 @@ interface AccordionItemProps extends React.ComponentPropsWithoutRef<typeof Accor
25
25
  }
26
26
  declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
27
27
  declare const accordionTriggerVariants: (props?: ({
28
- size?: "sm" | "default" | "lg" | null | undefined;
28
+ size?: "default" | "sm" | "lg" | null | undefined;
29
29
  iconPosition?: "left" | "right" | null | undefined;
30
30
  } & class_variance_authority_types.ClassProp) | undefined) => string;
31
31
  interface AccordionTriggerProps extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {
@@ -25,7 +25,7 @@ interface AccordionItemProps extends React.ComponentPropsWithoutRef<typeof Accor
25
25
  }
26
26
  declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
27
27
  declare const accordionTriggerVariants: (props?: ({
28
- size?: "sm" | "default" | "lg" | null | undefined;
28
+ size?: "default" | "sm" | "lg" | null | undefined;
29
29
  iconPosition?: "left" | "right" | null | undefined;
30
30
  } & class_variance_authority_types.ClassProp) | undefined) => string;
31
31
  interface AccordionTriggerProps extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {
@@ -3,8 +3,8 @@ import * as React from 'react';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const alertVariants: (props?: ({
6
- size?: "sm" | "default" | "lg" | null | undefined;
7
- radius?: "sm" | "lg" | "xl" | "2xl" | "base" | "none" | "md" | "3xl" | "full" | null | undefined;
6
+ size?: "default" | "sm" | "lg" | null | undefined;
7
+ radius?: "sm" | "lg" | "base" | "none" | "md" | "xl" | "2xl" | "3xl" | "full" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  type AlertVariant = 'default' | 'outline' | 'filled';
10
10
  type AlertColor = 'info' | 'success' | 'warning' | 'error';
@@ -3,8 +3,8 @@ import * as React from 'react';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const alertVariants: (props?: ({
6
- size?: "sm" | "default" | "lg" | null | undefined;
7
- radius?: "sm" | "lg" | "xl" | "2xl" | "base" | "none" | "md" | "3xl" | "full" | null | undefined;
6
+ size?: "default" | "sm" | "lg" | null | undefined;
7
+ radius?: "sm" | "lg" | "base" | "none" | "md" | "xl" | "2xl" | "3xl" | "full" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  type AlertVariant = 'default' | 'outline' | 'filled';
10
10
  type AlertColor = 'info' | 'success' | 'warning' | 'error';
@@ -4,7 +4,7 @@ import * as AvatarPrimitive from '@radix-ui/react-avatar';
4
4
  import { VariantProps } from 'class-variance-authority';
5
5
 
6
6
  declare const avatarVariants: (props?: ({
7
- size?: "xs" | "sm" | "default" | "lg" | "xl" | "2xl" | null | undefined;
7
+ size?: "default" | "sm" | "lg" | "xl" | "2xl" | "xs" | null | undefined;
8
8
  shape?: "circle" | "square" | null | undefined;
9
9
  } & class_variance_authority_types.ClassProp) | undefined) => string;
10
10
  declare const avatarColors: readonly [{
@@ -4,7 +4,7 @@ import * as AvatarPrimitive from '@radix-ui/react-avatar';
4
4
  import { VariantProps } from 'class-variance-authority';
5
5
 
6
6
  declare const avatarVariants: (props?: ({
7
- size?: "xs" | "sm" | "default" | "lg" | "xl" | "2xl" | null | undefined;
7
+ size?: "default" | "sm" | "lg" | "xl" | "2xl" | "xs" | null | undefined;
8
8
  shape?: "circle" | "square" | null | undefined;
9
9
  } & class_variance_authority_types.ClassProp) | undefined) => string;
10
10
  declare const avatarColors: readonly [{
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const badgeVariants: (props?: ({
6
- size?: "sm" | "default" | "lg" | null | undefined;
6
+ size?: "default" | "sm" | "lg" | null | undefined;
7
7
  radius?: "sm" | "lg" | "base" | "md" | "full" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  type BadgeVariant = 'solid' | 'subtle' | 'outline';
@@ -19,7 +19,7 @@ interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps
19
19
  icon?: React.ReactNode;
20
20
  /** Show a status dot before text */
21
21
  dot?: boolean;
22
- /** Show a remove button */
22
+ /** Show a remove button (not rendered with asChild — a button inside a link is invalid HTML) */
23
23
  removable?: boolean;
24
24
  /** Callback when remove button is clicked */
25
25
  onRemove?: () => void;
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const badgeVariants: (props?: ({
6
- size?: "sm" | "default" | "lg" | null | undefined;
6
+ size?: "default" | "sm" | "lg" | null | undefined;
7
7
  radius?: "sm" | "lg" | "base" | "md" | "full" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  type BadgeVariant = 'solid' | 'subtle' | 'outline';
@@ -19,7 +19,7 @@ interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps
19
19
  icon?: React.ReactNode;
20
20
  /** Show a status dot before text */
21
21
  dot?: boolean;
22
- /** Show a remove button */
22
+ /** Show a remove button (not rendered with asChild — a button inside a link is invalid HTML) */
23
23
  removable?: boolean;
24
24
  /** Callback when remove button is clicked */
25
25
  onRemove?: () => void;
@@ -122,6 +122,16 @@ const dotColorMap = {
122
122
  error: "bg-error",
123
123
  info: "bg-info"
124
124
  };
125
+ const REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
126
+ function renderInsideChild(children, render) {
127
+ let child = children;
128
+ const resolve = React.use;
129
+ if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE && typeof resolve === "function") {
130
+ child = resolve(child._payload);
131
+ }
132
+ if (!React.isValidElement(child)) return render(children);
133
+ return React.cloneElement(child, void 0, render(child.props.children));
134
+ }
125
135
  const Badge = React.forwardRef(
126
136
  ({
127
137
  className,
@@ -142,7 +152,49 @@ const Badge = React.forwardRef(
142
152
  const colorClasses = colorMap[color][variant];
143
153
  const outlineClasses = variant === "outline" ? "border bg-transparent" : "";
144
154
  const dotColor = variant === "solid" ? "bg-current" : dotColorMap[color];
145
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
155
+ const renderContent = (content) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
156
+ dot && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
157
+ "span",
158
+ {
159
+ className: (0, import_utils.cn)("shrink-0 rounded-full", badgeDotSizes[resolvedSize], dotColor),
160
+ "aria-hidden": "true"
161
+ }
162
+ ),
163
+ icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
164
+ "span",
165
+ {
166
+ className: (0, import_utils.cn)("shrink-0 [&>svg]:w-full [&>svg]:h-full", badgeIconSizes[resolvedSize]),
167
+ "aria-hidden": "true",
168
+ children: icon
169
+ }
170
+ ),
171
+ content,
172
+ removable && !asChild && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ "button",
174
+ {
175
+ type: "button",
176
+ 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",
177
+ onClick: (e) => {
178
+ e.stopPropagation();
179
+ onRemove?.();
180
+ },
181
+ "aria-label": "Remove",
182
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
+ "svg",
184
+ {
185
+ className: "w-3 h-3",
186
+ fill: "none",
187
+ viewBox: "0 0 24 24",
188
+ stroke: "currentColor",
189
+ strokeWidth: 2,
190
+ "aria-hidden": "true",
191
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
192
+ }
193
+ )
194
+ }
195
+ )
196
+ ] });
197
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
146
198
  Comp,
147
199
  {
148
200
  ref,
@@ -153,48 +205,7 @@ const Badge = React.forwardRef(
153
205
  className
154
206
  ),
155
207
  ...props,
156
- children: [
157
- dot && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
- "span",
159
- {
160
- className: (0, import_utils.cn)("shrink-0 rounded-full", badgeDotSizes[resolvedSize], dotColor),
161
- "aria-hidden": "true"
162
- }
163
- ),
164
- icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
165
- "span",
166
- {
167
- className: (0, import_utils.cn)("shrink-0 [&>svg]:w-full [&>svg]:h-full", badgeIconSizes[resolvedSize]),
168
- "aria-hidden": "true",
169
- children: icon
170
- }
171
- ),
172
- children,
173
- removable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
174
- "button",
175
- {
176
- type: "button",
177
- 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",
178
- onClick: (e) => {
179
- e.stopPropagation();
180
- onRemove?.();
181
- },
182
- "aria-label": "Remove",
183
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
184
- "svg",
185
- {
186
- className: "w-3 h-3",
187
- fill: "none",
188
- viewBox: "0 0 24 24",
189
- stroke: "currentColor",
190
- strokeWidth: 2,
191
- "aria-hidden": "true",
192
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
193
- }
194
- )
195
- }
196
- )
197
- ]
208
+ children: asChild ? renderInsideChild(children, renderContent) : renderContent(children)
198
209
  }
199
210
  );
200
211
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ui/badge.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Badge color maps for variant × color combinations\n// Uses semantic tokens (*.tint, text-text-*) for v4 dark mode compatibility\nconst colorMap = {\n default: {\n solid: 'bg-foreground text-background',\n subtle: 'bg-background-muted text-foreground',\n outline: 'border-border text-foreground',\n },\n primary: {\n solid: 'bg-primary text-primary-foreground',\n subtle: 'bg-primary-tint text-text-primary',\n outline: 'border-primary text-text-primary',\n },\n success: {\n solid: 'bg-success text-success-foreground',\n subtle: 'bg-success-tint text-text-success',\n outline: 'border-success text-text-success',\n },\n warning: {\n solid: 'bg-warning text-warning-foreground',\n subtle: 'bg-warning-tint text-text-warning',\n outline: 'border-warning text-text-warning',\n },\n error: {\n solid: 'bg-error text-error-foreground',\n subtle: 'bg-error-tint text-text-error',\n outline: 'border-error text-text-error',\n },\n info: {\n solid: 'bg-info text-info-foreground',\n subtle: 'bg-info-tint text-text-info',\n outline: 'border-info text-text-info',\n },\n} as const\n\nconst badgeVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap font-semibold transition-colors select-none',\n {\n variants: {\n size: {\n sm: 'h-5 min-w-5 px-1.5 text-2xs gap-1', // 20px height, 6px paddingX, 11px font\n default: 'h-6 min-w-6 px-2 text-xs gap-1', // 24px height, 8px paddingX, 12px font\n lg: 'h-7 min-w-7 px-2.5 text-sm gap-1.5', // 28px height, 10px paddingX, 13px font\n },\n radius: {\n sm: 'rounded-sm', // 2px\n base: 'rounded', // 4px\n md: 'rounded-md', // 6px\n lg: 'rounded-lg', // 8px\n full: 'rounded-full', // 9999px\n },\n },\n defaultVariants: {\n size: 'default',\n radius: 'full',\n },\n }\n)\n\n// Icon sizes per badge size\nconst badgeIconSizes = {\n sm: 'icon-2xs', // 12px\n default: 'icon-2xs', // 12px\n lg: 'icon-xs', // 14px\n} as const\n\n// Dot sizes per badge size\nconst badgeDotSizes = {\n sm: 'w-1 h-1',\n default: 'w-1.5 h-1.5',\n lg: 'w-1.5 h-1.5',\n} as const\n\n// Dot colors per color (matches the solid background)\nconst dotColorMap = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n success: 'bg-success',\n warning: 'bg-warning',\n error: 'bg-error',\n info: 'bg-info',\n} as const\n\nexport type BadgeVariant = 'solid' | 'subtle' | 'outline'\nexport type BadgeColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info'\nexport type BadgeSize = 'sm' | 'default' | 'lg'\nexport type BadgeRadius = 'sm' | 'base' | 'md' | 'lg' | 'full'\n\nexport interface BadgeProps\n extends React.HTMLAttributes<HTMLSpanElement>,\n VariantProps<typeof badgeVariants> {\n /** Visual style */\n variant?: BadgeVariant\n /** Semantic color */\n color?: BadgeColor\n /** Leading icon slot */\n icon?: React.ReactNode\n /** Show a status dot before text */\n dot?: boolean\n /** Show a remove button */\n removable?: boolean\n /** Callback when remove button is clicked */\n onRemove?: () => void\n /** Render as child element (Slot pattern) */\n asChild?: boolean\n}\n\nconst Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(\n ({\n className,\n variant = 'subtle',\n color = 'default',\n size,\n radius,\n icon,\n dot = false,\n removable = false,\n onRemove,\n asChild = false,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'span'\n const resolvedSize = size || 'default'\n\n // Color classes from variant × color map\n const colorClasses = colorMap[color][variant]\n // Outline variant needs border\n const outlineClasses = variant === 'outline' ? 'border bg-transparent' : ''\n\n // Dot color: in solid variant use currentColor (white/foreground), otherwise use semantic color\n const dotColor = variant === 'solid' ? 'bg-current' : dotColorMap[color]\n\n return (\n <Comp\n ref={ref}\n className={cn(\n badgeVariants({ size, radius }),\n colorClasses,\n outlineClasses,\n className\n )}\n {...props}\n >\n {dot && (\n <span\n className={cn('shrink-0 rounded-full', badgeDotSizes[resolvedSize], dotColor)}\n aria-hidden=\"true\"\n />\n )}\n {icon && (\n <span\n className={cn('shrink-0 [&>svg]:w-full [&>svg]:h-full', badgeIconSizes[resolvedSize])}\n aria-hidden=\"true\"\n >\n {icon}\n </span>\n )}\n {children}\n {removable && (\n <button\n type=\"button\"\n 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\"\n onClick={(e) => {\n e.stopPropagation()\n onRemove?.()\n }}\n aria-label=\"Remove\"\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n </Comp>\n )\n }\n)\nBadge.displayName = 'Badge'\n\nexport { Badge, badgeVariants }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6IM;AA3IN,YAAuB;AACvB,wBAAqB;AACrB,sCAAuC;AACvC,mBAAmB;AAInB,MAAM,WAAW;AAAA,EACf,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;AAEA,MAAM,oBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,SA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AAG,yBAAyB,cAAc,YAAY,GAAG,QAAQ;AAAA,cAC5E,eAAY;AAAA;AAAA,UACd;AAAA,UAED,QACC;AAAA,YAAC;AAAA;AAAA,cACC,eAAW,iBAAG,0CAA0C,eAAe,YAAY,CAAC;AAAA,cACpF,eAAY;AAAA,cAEX;AAAA;AAAA,UACH;AAAA,UAED;AAAA,UACA,aACC;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,SAAS,CAAC,MAAM;AACd,kBAAE,gBAAgB;AAClB,2BAAW;AAAA,cACb;AAAA,cACA,cAAW;AAAA,cAEX;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAU;AAAA,kBACV,MAAK;AAAA,kBACL,SAAQ;AAAA,kBACR,QAAO;AAAA,kBACP,aAAa;AAAA,kBACb,eAAY;AAAA,kBAEZ,sDAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,GAAE,wBAAuB;AAAA;AAAA,cAC9E;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACF;AACA,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/ui/badge.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Badge color maps for variant × color combinations\n// Uses semantic tokens (*.tint, text-text-*) for v4 dark mode compatibility\nconst colorMap = {\n default: {\n solid: 'bg-foreground text-background',\n subtle: 'bg-background-muted text-foreground',\n outline: 'border-border text-foreground',\n },\n primary: {\n solid: 'bg-primary text-primary-foreground',\n subtle: 'bg-primary-tint text-text-primary',\n outline: 'border-primary text-text-primary',\n },\n success: {\n solid: 'bg-success text-success-foreground',\n subtle: 'bg-success-tint text-text-success',\n outline: 'border-success text-text-success',\n },\n warning: {\n solid: 'bg-warning text-warning-foreground',\n subtle: 'bg-warning-tint text-text-warning',\n outline: 'border-warning text-text-warning',\n },\n error: {\n solid: 'bg-error text-error-foreground',\n subtle: 'bg-error-tint text-text-error',\n outline: 'border-error text-text-error',\n },\n info: {\n solid: 'bg-info text-info-foreground',\n subtle: 'bg-info-tint text-text-info',\n outline: 'border-info text-text-info',\n },\n} as const\n\nconst badgeVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap font-semibold transition-colors select-none',\n {\n variants: {\n size: {\n sm: 'h-5 min-w-5 px-1.5 text-2xs gap-1', // 20px height, 6px paddingX, 11px font\n default: 'h-6 min-w-6 px-2 text-xs gap-1', // 24px height, 8px paddingX, 12px font\n lg: 'h-7 min-w-7 px-2.5 text-sm gap-1.5', // 28px height, 10px paddingX, 13px font\n },\n radius: {\n sm: 'rounded-sm', // 2px\n base: 'rounded', // 4px\n md: 'rounded-md', // 6px\n lg: 'rounded-lg', // 8px\n full: 'rounded-full', // 9999px\n },\n },\n defaultVariants: {\n size: 'default',\n radius: 'full',\n },\n }\n)\n\n// Icon sizes per badge size\nconst badgeIconSizes = {\n sm: 'icon-2xs', // 12px\n default: 'icon-2xs', // 12px\n lg: 'icon-xs', // 14px\n} as const\n\n// Dot sizes per badge size\nconst badgeDotSizes = {\n sm: 'w-1 h-1',\n default: 'w-1.5 h-1.5',\n lg: 'w-1.5 h-1.5',\n} as const\n\n// Dot colors per color (matches the solid background)\nconst dotColorMap = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n success: 'bg-success',\n warning: 'bg-warning',\n error: 'bg-error',\n info: 'bg-info',\n} as const\n\nexport type BadgeVariant = 'solid' | 'subtle' | 'outline'\nexport type BadgeColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info'\nexport type BadgeSize = 'sm' | 'default' | 'lg'\nexport type BadgeRadius = 'sm' | 'base' | 'md' | 'lg' | 'full'\n\nconst REACT_LAZY_TYPE = Symbol.for('react.lazy')\n\n// asChild: Slot merges props only into a single child element, so the dot and\n// icon must go inside that child, not next to it. Lazy children (from Server\n// Components) are resolved the same way Radix Slot does.\nfunction renderInsideChild(\n children: React.ReactNode,\n render: (content: React.ReactNode) => React.ReactNode\n): React.ReactNode {\n let child: unknown = children\n const resolve = (React as { use?: (usable: unknown) => unknown }).use\n if (\n typeof child === 'object' && child !== null &&\n (child as { $$typeof?: symbol }).$$typeof === REACT_LAZY_TYPE &&\n typeof resolve === 'function'\n ) {\n child = resolve((child as { _payload: unknown })._payload)\n }\n if (!React.isValidElement<{ children?: React.ReactNode }>(child)) return render(children)\n return React.cloneElement(child, undefined, render(child.props.children))\n}\n\nexport interface BadgeProps\n extends React.HTMLAttributes<HTMLSpanElement>,\n VariantProps<typeof badgeVariants> {\n /** Visual style */\n variant?: BadgeVariant\n /** Semantic color */\n color?: BadgeColor\n /** Leading icon slot */\n icon?: React.ReactNode\n /** Show a status dot before text */\n dot?: boolean\n /** Show a remove button (not rendered with asChild — a button inside a link is invalid HTML) */\n removable?: boolean\n /** Callback when remove button is clicked */\n onRemove?: () => void\n /** Render as child element (Slot pattern) */\n asChild?: boolean\n}\n\nconst Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(\n ({\n className,\n variant = 'subtle',\n color = 'default',\n size,\n radius,\n icon,\n dot = false,\n removable = false,\n onRemove,\n asChild = false,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'span'\n const resolvedSize = size || 'default'\n\n // Color classes from variant × color map\n const colorClasses = colorMap[color][variant]\n // Outline variant needs border\n const outlineClasses = variant === 'outline' ? 'border bg-transparent' : ''\n\n // Dot color: in solid variant use currentColor (white/foreground), otherwise use semantic color\n const dotColor = variant === 'solid' ? 'bg-current' : dotColorMap[color]\n\n const renderContent = (content: React.ReactNode) => (\n <>\n {dot && (\n <span\n className={cn('shrink-0 rounded-full', badgeDotSizes[resolvedSize], dotColor)}\n aria-hidden=\"true\"\n />\n )}\n {icon && (\n <span\n className={cn('shrink-0 [&>svg]:w-full [&>svg]:h-full', badgeIconSizes[resolvedSize])}\n aria-hidden=\"true\"\n >\n {icon}\n </span>\n )}\n {content}\n {/* A button inside the asChild element (usually a link) would be invalid HTML */}\n {removable && !asChild && (\n <button\n type=\"button\"\n 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\"\n onClick={(e) => {\n e.stopPropagation()\n onRemove?.()\n }}\n aria-label=\"Remove\"\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n </>\n )\n\n return (\n <Comp\n ref={ref}\n className={cn(\n badgeVariants({ size, radius }),\n colorClasses,\n outlineClasses,\n className\n )}\n {...props}\n >\n {asChild ? renderInsideChild(children, renderContent) : renderContent(children)}\n </Comp>\n )\n }\n)\nBadge.displayName = 'Badge'\n\nexport { Badge, badgeVariants }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmKM;AAjKN,YAAuB;AACvB,wBAAqB;AACrB,sCAAuC;AACvC,mBAAmB;AAInB,MAAM,WAAW;AAAA,EACf,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,I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AAQ;AAAA;AAAA,IAChF;AAAA,EAEJ;AACF;AACA,MAAM,cAAc;","names":[]}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { Slot } from "@radix-ui/react-slot";
5
5
  import { cva } from "class-variance-authority";
@@ -88,6 +88,16 @@ const dotColorMap = {
88
88
  error: "bg-error",
89
89
  info: "bg-info"
90
90
  };
91
+ const REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
92
+ function renderInsideChild(children, render) {
93
+ let child = children;
94
+ const resolve = React.use;
95
+ if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE && typeof resolve === "function") {
96
+ child = resolve(child._payload);
97
+ }
98
+ if (!React.isValidElement(child)) return render(children);
99
+ return React.cloneElement(child, void 0, render(child.props.children));
100
+ }
91
101
  const Badge = React.forwardRef(
92
102
  ({
93
103
  className,
@@ -108,7 +118,49 @@ const Badge = React.forwardRef(
108
118
  const colorClasses = colorMap[color][variant];
109
119
  const outlineClasses = variant === "outline" ? "border bg-transparent" : "";
110
120
  const dotColor = variant === "solid" ? "bg-current" : dotColorMap[color];
111
- return /* @__PURE__ */ jsxs(
121
+ const renderContent = (content) => /* @__PURE__ */ jsxs(Fragment, { children: [
122
+ dot && /* @__PURE__ */ jsx(
123
+ "span",
124
+ {
125
+ className: cn("shrink-0 rounded-full", badgeDotSizes[resolvedSize], dotColor),
126
+ "aria-hidden": "true"
127
+ }
128
+ ),
129
+ icon && /* @__PURE__ */ jsx(
130
+ "span",
131
+ {
132
+ className: cn("shrink-0 [&>svg]:w-full [&>svg]:h-full", badgeIconSizes[resolvedSize]),
133
+ "aria-hidden": "true",
134
+ children: icon
135
+ }
136
+ ),
137
+ content,
138
+ removable && !asChild && /* @__PURE__ */ jsx(
139
+ "button",
140
+ {
141
+ type: "button",
142
+ 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",
143
+ onClick: (e) => {
144
+ e.stopPropagation();
145
+ onRemove?.();
146
+ },
147
+ "aria-label": "Remove",
148
+ children: /* @__PURE__ */ jsx(
149
+ "svg",
150
+ {
151
+ className: "w-3 h-3",
152
+ fill: "none",
153
+ viewBox: "0 0 24 24",
154
+ stroke: "currentColor",
155
+ strokeWidth: 2,
156
+ "aria-hidden": "true",
157
+ children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
158
+ }
159
+ )
160
+ }
161
+ )
162
+ ] });
163
+ return /* @__PURE__ */ jsx(
112
164
  Comp,
113
165
  {
114
166
  ref,
@@ -119,48 +171,7 @@ const Badge = React.forwardRef(
119
171
  className
120
172
  ),
121
173
  ...props,
122
- children: [
123
- dot && /* @__PURE__ */ jsx(
124
- "span",
125
- {
126
- className: cn("shrink-0 rounded-full", badgeDotSizes[resolvedSize], dotColor),
127
- "aria-hidden": "true"
128
- }
129
- ),
130
- icon && /* @__PURE__ */ jsx(
131
- "span",
132
- {
133
- className: cn("shrink-0 [&>svg]:w-full [&>svg]:h-full", badgeIconSizes[resolvedSize]),
134
- "aria-hidden": "true",
135
- children: icon
136
- }
137
- ),
138
- children,
139
- removable && /* @__PURE__ */ jsx(
140
- "button",
141
- {
142
- type: "button",
143
- 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",
144
- onClick: (e) => {
145
- e.stopPropagation();
146
- onRemove?.();
147
- },
148
- "aria-label": "Remove",
149
- children: /* @__PURE__ */ jsx(
150
- "svg",
151
- {
152
- className: "w-3 h-3",
153
- fill: "none",
154
- viewBox: "0 0 24 24",
155
- stroke: "currentColor",
156
- strokeWidth: 2,
157
- "aria-hidden": "true",
158
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
159
- }
160
- )
161
- }
162
- )
163
- ]
174
+ children: asChild ? renderInsideChild(children, renderContent) : renderContent(children)
164
175
  }
165
176
  );
166
177
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ui/badge.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Badge color maps for variant × color combinations\n// Uses semantic tokens (*.tint, text-text-*) for v4 dark mode compatibility\nconst colorMap = {\n default: {\n solid: 'bg-foreground text-background',\n subtle: 'bg-background-muted text-foreground',\n outline: 'border-border text-foreground',\n },\n primary: {\n solid: 'bg-primary text-primary-foreground',\n subtle: 'bg-primary-tint text-text-primary',\n outline: 'border-primary text-text-primary',\n },\n success: {\n solid: 'bg-success text-success-foreground',\n subtle: 'bg-success-tint text-text-success',\n outline: 'border-success text-text-success',\n },\n warning: {\n solid: 'bg-warning text-warning-foreground',\n subtle: 'bg-warning-tint text-text-warning',\n outline: 'border-warning text-text-warning',\n },\n error: {\n solid: 'bg-error text-error-foreground',\n subtle: 'bg-error-tint text-text-error',\n outline: 'border-error text-text-error',\n },\n info: {\n solid: 'bg-info text-info-foreground',\n subtle: 'bg-info-tint text-text-info',\n outline: 'border-info text-text-info',\n },\n} as const\n\nconst badgeVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap font-semibold transition-colors select-none',\n {\n variants: {\n size: {\n sm: 'h-5 min-w-5 px-1.5 text-2xs gap-1', // 20px height, 6px paddingX, 11px font\n default: 'h-6 min-w-6 px-2 text-xs gap-1', // 24px height, 8px paddingX, 12px font\n lg: 'h-7 min-w-7 px-2.5 text-sm gap-1.5', // 28px height, 10px paddingX, 13px font\n },\n radius: {\n sm: 'rounded-sm', // 2px\n base: 'rounded', // 4px\n md: 'rounded-md', // 6px\n lg: 'rounded-lg', // 8px\n full: 'rounded-full', // 9999px\n },\n },\n defaultVariants: {\n size: 'default',\n radius: 'full',\n },\n }\n)\n\n// Icon sizes per badge size\nconst badgeIconSizes = {\n sm: 'icon-2xs', // 12px\n default: 'icon-2xs', // 12px\n lg: 'icon-xs', // 14px\n} as const\n\n// Dot sizes per badge size\nconst badgeDotSizes = {\n sm: 'w-1 h-1',\n default: 'w-1.5 h-1.5',\n lg: 'w-1.5 h-1.5',\n} as const\n\n// Dot colors per color (matches the solid background)\nconst dotColorMap = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n success: 'bg-success',\n warning: 'bg-warning',\n error: 'bg-error',\n info: 'bg-info',\n} as const\n\nexport type BadgeVariant = 'solid' | 'subtle' | 'outline'\nexport type BadgeColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info'\nexport type BadgeSize = 'sm' | 'default' | 'lg'\nexport type BadgeRadius = 'sm' | 'base' | 'md' | 'lg' | 'full'\n\nexport interface BadgeProps\n extends React.HTMLAttributes<HTMLSpanElement>,\n VariantProps<typeof badgeVariants> {\n /** Visual style */\n variant?: BadgeVariant\n /** Semantic color */\n color?: BadgeColor\n /** Leading icon slot */\n icon?: React.ReactNode\n /** Show a status dot before text */\n dot?: boolean\n /** Show a remove button */\n removable?: boolean\n /** Callback when remove button is clicked */\n onRemove?: () => void\n /** Render as child element (Slot pattern) */\n asChild?: boolean\n}\n\nconst Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(\n ({\n className,\n variant = 'subtle',\n color = 'default',\n size,\n radius,\n icon,\n dot = false,\n removable = false,\n onRemove,\n asChild = false,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'span'\n const resolvedSize = size || 'default'\n\n // Color classes from variant × color map\n const colorClasses = colorMap[color][variant]\n // Outline variant needs border\n const outlineClasses = variant === 'outline' ? 'border bg-transparent' : ''\n\n // Dot color: in solid variant use currentColor (white/foreground), otherwise use semantic color\n const dotColor = variant === 'solid' ? 'bg-current' : dotColorMap[color]\n\n return (\n <Comp\n ref={ref}\n className={cn(\n badgeVariants({ size, radius }),\n colorClasses,\n outlineClasses,\n className\n )}\n {...props}\n >\n {dot && (\n <span\n className={cn('shrink-0 rounded-full', badgeDotSizes[resolvedSize], dotColor)}\n aria-hidden=\"true\"\n />\n )}\n {icon && (\n <span\n className={cn('shrink-0 [&>svg]:w-full [&>svg]:h-full', badgeIconSizes[resolvedSize])}\n aria-hidden=\"true\"\n >\n {icon}\n </span>\n )}\n {children}\n {removable && (\n <button\n type=\"button\"\n 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\"\n onClick={(e) => {\n e.stopPropagation()\n onRemove?.()\n }}\n aria-label=\"Remove\"\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n </Comp>\n )\n }\n)\nBadge.displayName = 'Badge'\n\nexport { Badge, badgeVariants }\n"],"mappings":";AA6IM,SAWI,KAXJ;AA3IN,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AACvC,SAAS,UAAU;AAInB,MAAM,WAAW;AAAA,EACf,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,I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QACA,WAAW;AAAA,UACT,cAAc,EAAE,MAAM,OAAO,CAAC;AAAA,UAC9B;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,iBACC;AAAA,YAAC;AAAA;AAAA,cACC,WAAW,GAAG,yBAAyB,cAAc,YAAY,GAAG,QAAQ;AAAA,cAC5E,eAAY;AAAA;AAAA,UACd;AAAA,UAED,QACC;AAAA,YAAC;AAAA;AAAA,cACC,WAAW,GAAG,0CAA0C,eAAe,YAAY,CAAC;AAAA,cACpF,eAAY;AAAA,cAEX;AAAA;AAAA,UACH;AAAA,UAED;AAAA,UACA,aACC;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,SAAS,CAAC,MAAM;AACd,kBAAE,gBAAgB;AAClB,2BAAW;AAAA,cACb;AAAA,cACA,cAAW;AAAA,cAEX;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAU;AAAA,kBACV,MAAK;AAAA,kBACL,SAAQ;AAAA,kBACR,QAAO;AAAA,kBACP,aAAa;AAAA,kBACb,eAAY;AAAA,kBAEZ,8BAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,GAAE,wBAAuB;AAAA;AAAA,cAC9E;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACF;AACA,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/ui/badge.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Badge color maps for variant × color combinations\n// Uses semantic tokens (*.tint, text-text-*) for v4 dark mode compatibility\nconst colorMap = {\n default: {\n solid: 'bg-foreground text-background',\n subtle: 'bg-background-muted text-foreground',\n outline: 'border-border text-foreground',\n },\n primary: {\n solid: 'bg-primary text-primary-foreground',\n subtle: 'bg-primary-tint text-text-primary',\n outline: 'border-primary text-text-primary',\n },\n success: {\n solid: 'bg-success text-success-foreground',\n subtle: 'bg-success-tint text-text-success',\n outline: 'border-success text-text-success',\n },\n warning: {\n solid: 'bg-warning text-warning-foreground',\n subtle: 'bg-warning-tint text-text-warning',\n outline: 'border-warning text-text-warning',\n },\n error: {\n solid: 'bg-error text-error-foreground',\n subtle: 'bg-error-tint text-text-error',\n outline: 'border-error text-text-error',\n },\n info: {\n solid: 'bg-info text-info-foreground',\n subtle: 'bg-info-tint text-text-info',\n outline: 'border-info text-text-info',\n },\n} as const\n\nconst badgeVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap font-semibold transition-colors select-none',\n {\n variants: {\n size: {\n sm: 'h-5 min-w-5 px-1.5 text-2xs gap-1', // 20px height, 6px paddingX, 11px font\n default: 'h-6 min-w-6 px-2 text-xs gap-1', // 24px height, 8px paddingX, 12px font\n lg: 'h-7 min-w-7 px-2.5 text-sm gap-1.5', // 28px height, 10px paddingX, 13px font\n },\n radius: {\n sm: 'rounded-sm', // 2px\n base: 'rounded', // 4px\n md: 'rounded-md', // 6px\n lg: 'rounded-lg', // 8px\n full: 'rounded-full', // 9999px\n },\n },\n defaultVariants: {\n size: 'default',\n radius: 'full',\n },\n }\n)\n\n// Icon sizes per badge size\nconst badgeIconSizes = {\n sm: 'icon-2xs', // 12px\n default: 'icon-2xs', // 12px\n lg: 'icon-xs', // 14px\n} as const\n\n// Dot sizes per badge size\nconst badgeDotSizes = {\n sm: 'w-1 h-1',\n default: 'w-1.5 h-1.5',\n lg: 'w-1.5 h-1.5',\n} as const\n\n// Dot colors per color (matches the solid background)\nconst dotColorMap = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n success: 'bg-success',\n warning: 'bg-warning',\n error: 'bg-error',\n info: 'bg-info',\n} as const\n\nexport type BadgeVariant = 'solid' | 'subtle' | 'outline'\nexport type BadgeColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info'\nexport type BadgeSize = 'sm' | 'default' | 'lg'\nexport type BadgeRadius = 'sm' | 'base' | 'md' | 'lg' | 'full'\n\nconst REACT_LAZY_TYPE = Symbol.for('react.lazy')\n\n// asChild: Slot merges props only into a single child element, so the dot and\n// icon must go inside that child, not next to it. Lazy children (from Server\n// Components) are resolved the same way Radix Slot does.\nfunction renderInsideChild(\n children: React.ReactNode,\n render: (content: React.ReactNode) => React.ReactNode\n): React.ReactNode {\n let child: unknown = children\n const resolve = (React as { use?: (usable: unknown) => unknown }).use\n if (\n typeof child === 'object' && child !== null &&\n (child as { $$typeof?: symbol }).$$typeof === REACT_LAZY_TYPE &&\n typeof resolve === 'function'\n ) {\n child = resolve((child as { _payload: unknown })._payload)\n }\n if (!React.isValidElement<{ children?: React.ReactNode }>(child)) return render(children)\n return React.cloneElement(child, undefined, render(child.props.children))\n}\n\nexport interface BadgeProps\n extends React.HTMLAttributes<HTMLSpanElement>,\n VariantProps<typeof badgeVariants> {\n /** Visual style */\n variant?: BadgeVariant\n /** Semantic color */\n color?: BadgeColor\n /** Leading icon slot */\n icon?: React.ReactNode\n /** Show a status dot before text */\n dot?: boolean\n /** Show a remove button (not rendered with asChild — a button inside a link is invalid HTML) */\n removable?: boolean\n /** Callback when remove button is clicked */\n onRemove?: () => void\n /** Render as child element (Slot pattern) */\n asChild?: boolean\n}\n\nconst Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(\n ({\n className,\n variant = 'subtle',\n color = 'default',\n size,\n radius,\n icon,\n dot = false,\n removable = false,\n onRemove,\n asChild = false,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'span'\n const resolvedSize = size || 'default'\n\n // Color classes from variant × color map\n const colorClasses = colorMap[color][variant]\n // Outline variant needs border\n const outlineClasses = variant === 'outline' ? 'border bg-transparent' : ''\n\n // Dot color: in solid variant use currentColor (white/foreground), otherwise use semantic color\n const dotColor = variant === 'solid' ? 'bg-current' : dotColorMap[color]\n\n const renderContent = (content: React.ReactNode) => (\n <>\n {dot && (\n <span\n className={cn('shrink-0 rounded-full', badgeDotSizes[resolvedSize], dotColor)}\n aria-hidden=\"true\"\n />\n )}\n {icon && (\n <span\n className={cn('shrink-0 [&>svg]:w-full [&>svg]:h-full', badgeIconSizes[resolvedSize])}\n aria-hidden=\"true\"\n >\n {icon}\n </span>\n )}\n {content}\n {/* A button inside the asChild element (usually a link) would be invalid HTML */}\n {removable && !asChild && (\n <button\n type=\"button\"\n 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\"\n onClick={(e) => {\n e.stopPropagation()\n onRemove?.()\n }}\n aria-label=\"Remove\"\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n </>\n )\n\n return (\n <Comp\n ref={ref}\n className={cn(\n badgeVariants({ size, radius }),\n colorClasses,\n outlineClasses,\n className\n )}\n {...props}\n >\n {asChild ? renderInsideChild(children, renderContent) : renderContent(children)}\n </Comp>\n )\n }\n)\nBadge.displayName = 'Badge'\n\nexport { Badge, badgeVariants }\n"],"mappings":";AAmKM,mBAEI,KAFJ;AAjKN,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AACvC,SAAS,UAAU;AAInB,MAAM,WAAW;AAAA,EACf,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA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AM,OAAO,CAAC;AAAA,UAC9B;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QACC,GAAG;AAAA,QAEH,oBAAU,kBAAkB,UAAU,aAAa,IAAI,cAAc,QAAQ;AAAA;AAAA,IAChF;AAAA,EAEJ;AACF;AACA,MAAM,cAAc;","names":[]}
@@ -203,24 +203,30 @@ function flattenFragments(children) {
203
203
  ) : [node]
204
204
  );
205
205
  }
206
+ function classifyNodes(nodes) {
207
+ const known = nodes.map((node) => {
208
+ const type = React.isValidElement(node) ? node.type : null;
209
+ return type === BreadcrumbSeparator ? "separator" : type === BreadcrumbItem ? "item" : null;
210
+ });
211
+ if (known.every((kind) => kind === null)) {
212
+ return nodes.map((_, i) => i % 2 === 0 ? "item" : "separator");
213
+ }
214
+ return known.map((kind) => kind ?? "item");
215
+ }
206
216
  function collapseItems(children, maxItems, before, after) {
207
217
  if (maxItems === void 0) return children;
208
218
  const nodes = flattenFragments(children);
219
+ const kinds = classifyNodes(nodes);
209
220
  const segments = [];
210
221
  let pendingSeparator = null;
211
- for (const node of nodes) {
212
- const type = React.isValidElement(node) ? node.type : null;
213
- if (type === BreadcrumbSeparator) {
222
+ nodes.forEach((node, i) => {
223
+ if (kinds[i] === "separator") {
214
224
  pendingSeparator = node;
215
- } else if (type === BreadcrumbItem) {
225
+ } else {
216
226
  segments.push({ separator: pendingSeparator, nodes: [node] });
217
227
  pendingSeparator = null;
218
- } else if (segments.length > 0) {
219
- segments[segments.length - 1].nodes.push(node);
220
- } else {
221
- segments.push({ separator: null, nodes: [node] });
222
228
  }
223
- }
229
+ });
224
230
  if (segments.length <= maxItems || before + after >= segments.length) return children;
225
231
  const head = segments.slice(0, before);
226
232
  const tail = segments.slice(segments.length - after);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ui/breadcrumb.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// ─── Context ──────────────────────────────────────────────\n\ntype BreadcrumbContextValue = {\n size?: 'sm' | 'default' | 'lg'\n separator?: React.ReactNode\n maxItems?: number\n itemsBeforeCollapse?: number\n itemsAfterCollapse?: number\n}\n\nconst BreadcrumbContext = React.createContext<BreadcrumbContextValue>({})\nconst useBreadcrumbContext = () => React.useContext(BreadcrumbContext)\n\n// ─── Default Separator Icon ───────────────────────────────\n\nfunction ChevronRightIcon({ className }: { className?: string }) {\n return (\n <svg\n className={className}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M9 5l7 7-7 7\" />\n </svg>\n )\n}\n\n// ─── Ellipsis Icon ────────────────────────────────────────\n\nfunction EllipsisIcon({ className }: { className?: string }) {\n return (\n <svg\n className={className}\n fill=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <circle cx=\"6\" cy=\"12\" r=\"1.5\" />\n <circle cx=\"12\" cy=\"12\" r=\"1.5\" />\n <circle cx=\"18\" cy=\"12\" r=\"1.5\" />\n </svg>\n )\n}\n\n// ─── Breadcrumb (Root) ────────────────────────────────────\n\nconst breadcrumbSizeMap = {\n sm: { text: 'text-xs', icon: 'icon-xs', gap: 'gap-1.5' },\n default: { text: 'text-sm', icon: 'icon-xs', gap: 'gap-2' },\n lg: { text: 'text-md', icon: 'icon-sm', gap: 'gap-2' },\n} as const\n\nexport interface BreadcrumbProps extends React.ComponentPropsWithoutRef<'nav'> {\n /** Separator element between items */\n separator?: React.ReactNode\n /** Size of the breadcrumb */\n size?: 'sm' | 'default' | 'lg'\n /** Collapse the middle items into an ellipsis when there are more items than this (undefined = no collapse) */\n maxItems?: number\n /** Items kept before the ellipsis when collapsed */\n itemsBeforeCollapse?: number\n /** Items kept after the ellipsis when collapsed */\n itemsAfterCollapse?: number\n}\n\nconst Breadcrumb = React.forwardRef<HTMLElement, BreadcrumbProps>(\n ({ className, separator, size = 'default', maxItems, itemsBeforeCollapse = 1, itemsAfterCollapse = 1, ...props }, ref) => (\n <BreadcrumbContext.Provider value={{ size, separator, maxItems, itemsBeforeCollapse, itemsAfterCollapse }}>\n <nav\n ref={ref}\n aria-label=\"breadcrumb\"\n className={cn('', className)}\n {...props}\n />\n </BreadcrumbContext.Provider>\n )\n)\nBreadcrumb.displayName = 'Breadcrumb'\n\n// ─── BreadcrumbList ───────────────────────────────────────\n\nconst BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<'ol'>>(\n ({ className, children, ...props }, ref) => {\n const { size = 'default', maxItems, itemsBeforeCollapse = 1, itemsAfterCollapse = 1 } = useBreadcrumbContext()\n const sizeClass = breadcrumbSizeMap[size]\n return (\n <ol\n ref={ref}\n className={cn(\n 'flex flex-wrap items-center',\n sizeClass.gap,\n sizeClass.text,\n 'text-text-muted',\n className\n )}\n {...props}\n >\n {collapseItems(children, maxItems, itemsBeforeCollapse, itemsAfterCollapse)}\n </ol>\n )\n }\n)\nBreadcrumbList.displayName = 'BreadcrumbList'\n\n// ─── BreadcrumbItem ───────────────────────────────────────\n\nconst BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(\n ({ className, ...props }, ref) => (\n <li\n ref={ref}\n className={cn('inline-flex items-center gap-1.5', className)}\n {...props}\n />\n )\n)\nBreadcrumbItem.displayName = 'BreadcrumbItem'\n\n// ─── BreadcrumbLink ───────────────────────────────────────\n\nexport interface BreadcrumbLinkProps extends React.ComponentPropsWithoutRef<'a'> {\n /** Use Radix Slot to compose with custom link components */\n asChild?: boolean\n}\n\nconst BreadcrumbLink = React.forwardRef<HTMLAnchorElement, BreadcrumbLinkProps>(\n ({ asChild, className, ...props }, ref) => {\n const Comp = asChild ? Slot : 'a'\n return (\n <Comp\n ref={ref}\n className={cn(\n 'transition-colors duration-fast hover:text-foreground',\n className\n )}\n {...props}\n />\n )\n }\n)\nBreadcrumbLink.displayName = 'BreadcrumbLink'\n\n// ─── BreadcrumbPage ───────────────────────────────────────\n\nconst BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<'span'>>(\n ({ className, ...props }, ref) => (\n <span\n ref={ref}\n role=\"link\"\n aria-disabled=\"true\"\n aria-current=\"page\"\n className={cn('text-foreground', className)}\n {...props}\n />\n )\n)\nBreadcrumbPage.displayName = 'BreadcrumbPage'\n\n// ─── BreadcrumbSeparator ──────────────────────────────────\n\nconst BreadcrumbSeparator = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(\n ({ children, className, ...props }, ref) => {\n const { separator, size = 'default' } = useBreadcrumbContext()\n const sizeClass = breadcrumbSizeMap[size]\n return (\n <li\n ref={ref}\n role=\"presentation\"\n aria-hidden=\"true\"\n className={cn('flex items-center text-text-subtle', className)}\n {...props}\n >\n {children ?? separator ?? <ChevronRightIcon className={sizeClass.icon} />}\n </li>\n )\n }\n)\nBreadcrumbSeparator.displayName = 'BreadcrumbSeparator'\n\n// ─── BreadcrumbEllipsis ───────────────────────────────────\n\nexport interface BreadcrumbEllipsisProps extends React.ComponentPropsWithoutRef<'span'> {}\n\nconst BreadcrumbEllipsis = React.forwardRef<HTMLSpanElement, BreadcrumbEllipsisProps>(\n ({ className, ...props }, ref) => {\n const { size = 'default' } = useBreadcrumbContext()\n const sizeClass = breadcrumbSizeMap[size]\n return (\n <span\n ref={ref}\n role=\"presentation\"\n aria-hidden=\"true\"\n className={cn('flex items-center justify-center', className)}\n {...props}\n >\n <EllipsisIcon className={sizeClass.icon} />\n <span className=\"sr-only\">More</span>\n </span>\n )\n }\n)\nBreadcrumbEllipsis.displayName = 'BreadcrumbEllipsis'\n\n// ─── Collapse ─────────────────────────────────────────────\n\n// Items are often rendered from a list as <Fragment>{separator}{item}</Fragment>,\n// so fragments are unwrapped before counting.\nfunction flattenFragments(children: React.ReactNode): React.ReactNode[] {\n return React.Children.toArray(children).flatMap((node) =>\n React.isValidElement<{ children?: React.ReactNode }>(node) && node.type === React.Fragment\n ? flattenFragments(node.props.children).map((child) =>\n // Prefix keys so children of different fragments stay unique\n React.isValidElement(child) ? React.cloneElement(child, { key: `${node.key}${child.key}` }) : child\n )\n : [node]\n )\n}\n\n// Groups children into segments (the separator before an item + the item),\n// then keeps the first `before` and last `after` segments around one ellipsis\n// item. The user's own separators are reused, so custom separators survive.\nfunction collapseItems(children: React.ReactNode, maxItems: number | undefined, before: number, after: number) {\n if (maxItems === undefined) return children\n\n const nodes = flattenFragments(children)\n const segments: { separator: React.ReactNode; nodes: React.ReactNode[] }[] = []\n let pendingSeparator: React.ReactNode = null\n for (const node of nodes) {\n const type = React.isValidElement(node) ? node.type : null\n if (type === BreadcrumbSeparator) {\n pendingSeparator = node\n } else if (type === BreadcrumbItem) {\n segments.push({ separator: pendingSeparator, nodes: [node] })\n pendingSeparator = null\n } else if (segments.length > 0) {\n segments[segments.length - 1].nodes.push(node)\n } else {\n segments.push({ separator: null, nodes: [node] })\n }\n }\n\n if (segments.length <= maxItems || before + after >= segments.length) return children\n\n const head = segments.slice(0, before)\n const tail = segments.slice(segments.length - after)\n const render = (list: typeof segments) => list.flatMap((seg) => (seg.separator ? [seg.separator, ...seg.nodes] : seg.nodes))\n const ellipsisSeparator = segments[before].separator\n\n return [\n ...render(head),\n ...(ellipsisSeparator ? [ellipsisSeparator] : []),\n <BreadcrumbItem key=\"breadcrumb-collapsed\">\n <BreadcrumbEllipsis />\n </BreadcrumbItem>,\n ...render(tail),\n ]\n}\n\n// ─── Exports ──────────────────────────────────────────────\n\nexport {\n Breadcrumb,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbPage,\n BreadcrumbSeparator,\n BreadcrumbEllipsis,\n breadcrumbSizeMap,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BM;AA7BN,YA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'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// ─── Context ──────────────────────────────────────────────\n\ntype BreadcrumbContextValue = {\n size?: 'sm' | 'default' | 'lg'\n separator?: React.ReactNode\n maxItems?: number\n itemsBeforeCollapse?: number\n itemsAfterCollapse?: number\n}\n\nconst BreadcrumbContext = React.createContext<BreadcrumbContextValue>({})\nconst useBreadcrumbContext = () => React.useContext(BreadcrumbContext)\n\n// ─── Default Separator Icon ───────────────────────────────\n\nfunction ChevronRightIcon({ className }: { className?: string }) {\n return (\n <svg\n className={className}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M9 5l7 7-7 7\" />\n </svg>\n )\n}\n\n// ─── Ellipsis Icon ────────────────────────────────────────\n\nfunction EllipsisIcon({ className }: { className?: string }) {\n return (\n <svg\n className={className}\n fill=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <circle cx=\"6\" cy=\"12\" r=\"1.5\" />\n <circle cx=\"12\" cy=\"12\" r=\"1.5\" />\n <circle cx=\"18\" cy=\"12\" r=\"1.5\" />\n </svg>\n )\n}\n\n// ─── Breadcrumb (Root) ────────────────────────────────────\n\nconst breadcrumbSizeMap = {\n sm: { text: 'text-xs', icon: 'icon-xs', gap: 'gap-1.5' },\n default: { text: 'text-sm', icon: 'icon-xs', gap: 'gap-2' },\n lg: { text: 'text-md', icon: 'icon-sm', gap: 'gap-2' },\n} as const\n\nexport interface BreadcrumbProps extends React.ComponentPropsWithoutRef<'nav'> {\n /** Separator element between items */\n separator?: React.ReactNode\n /** Size of the breadcrumb */\n size?: 'sm' | 'default' | 'lg'\n /** Collapse the middle items into an ellipsis when there are more items than this (undefined = no collapse) */\n maxItems?: number\n /** Items kept before the ellipsis when collapsed */\n itemsBeforeCollapse?: number\n /** Items kept after the ellipsis when collapsed */\n itemsAfterCollapse?: number\n}\n\nconst Breadcrumb = React.forwardRef<HTMLElement, BreadcrumbProps>(\n ({ className, separator, size = 'default', maxItems, itemsBeforeCollapse = 1, itemsAfterCollapse = 1, ...props }, ref) => (\n <BreadcrumbContext.Provider value={{ size, separator, maxItems, itemsBeforeCollapse, itemsAfterCollapse }}>\n <nav\n ref={ref}\n aria-label=\"breadcrumb\"\n className={cn('', className)}\n {...props}\n />\n </BreadcrumbContext.Provider>\n )\n)\nBreadcrumb.displayName = 'Breadcrumb'\n\n// ─── BreadcrumbList ───────────────────────────────────────\n\nconst BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<'ol'>>(\n ({ className, children, ...props }, ref) => {\n const { size = 'default', maxItems, itemsBeforeCollapse = 1, itemsAfterCollapse = 1 } = useBreadcrumbContext()\n const sizeClass = breadcrumbSizeMap[size]\n return (\n <ol\n ref={ref}\n className={cn(\n 'flex flex-wrap items-center',\n sizeClass.gap,\n sizeClass.text,\n 'text-text-muted',\n className\n )}\n {...props}\n >\n {collapseItems(children, maxItems, itemsBeforeCollapse, itemsAfterCollapse)}\n </ol>\n )\n }\n)\nBreadcrumbList.displayName = 'BreadcrumbList'\n\n// ─── BreadcrumbItem ───────────────────────────────────────\n\nconst BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(\n ({ className, ...props }, ref) => (\n <li\n ref={ref}\n className={cn('inline-flex items-center gap-1.5', className)}\n {...props}\n />\n )\n)\nBreadcrumbItem.displayName = 'BreadcrumbItem'\n\n// ─── BreadcrumbLink ───────────────────────────────────────\n\nexport interface BreadcrumbLinkProps extends React.ComponentPropsWithoutRef<'a'> {\n /** Use Radix Slot to compose with custom link components */\n asChild?: boolean\n}\n\nconst BreadcrumbLink = React.forwardRef<HTMLAnchorElement, BreadcrumbLinkProps>(\n ({ asChild, className, ...props }, ref) => {\n const Comp = asChild ? Slot : 'a'\n return (\n <Comp\n ref={ref}\n className={cn(\n 'transition-colors duration-fast hover:text-foreground',\n className\n )}\n {...props}\n />\n )\n }\n)\nBreadcrumbLink.displayName = 'BreadcrumbLink'\n\n// ─── BreadcrumbPage ───────────────────────────────────────\n\nconst BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<'span'>>(\n ({ className, ...props }, ref) => (\n <span\n ref={ref}\n role=\"link\"\n aria-disabled=\"true\"\n aria-current=\"page\"\n className={cn('text-foreground', className)}\n {...props}\n />\n )\n)\nBreadcrumbPage.displayName = 'BreadcrumbPage'\n\n// ─── BreadcrumbSeparator ──────────────────────────────────\n\nconst BreadcrumbSeparator = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(\n ({ children, className, ...props }, ref) => {\n const { separator, size = 'default' } = useBreadcrumbContext()\n const sizeClass = breadcrumbSizeMap[size]\n return (\n <li\n ref={ref}\n role=\"presentation\"\n aria-hidden=\"true\"\n className={cn('flex items-center text-text-subtle', className)}\n {...props}\n >\n {children ?? separator ?? <ChevronRightIcon className={sizeClass.icon} />}\n </li>\n )\n }\n)\nBreadcrumbSeparator.displayName = 'BreadcrumbSeparator'\n\n// ─── BreadcrumbEllipsis ───────────────────────────────────\n\nexport interface BreadcrumbEllipsisProps extends React.ComponentPropsWithoutRef<'span'> {}\n\nconst BreadcrumbEllipsis = React.forwardRef<HTMLSpanElement, BreadcrumbEllipsisProps>(\n ({ className, ...props }, ref) => {\n const { size = 'default' } = useBreadcrumbContext()\n const sizeClass = breadcrumbSizeMap[size]\n return (\n <span\n ref={ref}\n role=\"presentation\"\n aria-hidden=\"true\"\n className={cn('flex items-center justify-center', className)}\n {...props}\n >\n <EllipsisIcon className={sizeClass.icon} />\n <span className=\"sr-only\">More</span>\n </span>\n )\n }\n)\nBreadcrumbEllipsis.displayName = 'BreadcrumbEllipsis'\n\n// ─── Collapse ─────────────────────────────────────────────\n\n// Items are often rendered from a list as <Fragment>{separator}{item}</Fragment>,\n// so fragments are unwrapped before counting.\nfunction flattenFragments(children: React.ReactNode): React.ReactNode[] {\n return React.Children.toArray(children).flatMap((node) =>\n React.isValidElement<{ children?: React.ReactNode }>(node) && node.type === React.Fragment\n ? flattenFragments(node.props.children).map((child) =>\n // Prefix keys so children of different fragments stay unique\n React.isValidElement(child) ? React.cloneElement(child, { key: `${node.key}${child.key}` }) : child\n )\n : [node]\n )\n}\n\n// Children passed from a Server Component arrive with lazy element types, so\n// `node.type === BreadcrumbItem` cannot tell them apart. When no child can be\n// identified, the list is read as the alternating item / separator order every\n// breadcrumb uses. Unidentified children next to identified separators (items\n// wrapped in the caller's own component) count as items.\nfunction classifyNodes(nodes: React.ReactNode[]): ('item' | 'separator')[] {\n const known = nodes.map((node) => {\n const type = React.isValidElement(node) ? node.type : null\n return type === BreadcrumbSeparator ? 'separator' : type === BreadcrumbItem ? 'item' : null\n })\n if (known.every((kind) => kind === null)) {\n return nodes.map((_, i) => (i % 2 === 0 ? 'item' : 'separator'))\n }\n return known.map((kind) => kind ?? 'item')\n}\n\n// Groups children into segments (the separator before an item + the item),\n// then keeps the first `before` and last `after` segments around one ellipsis\n// item. The user's own separators are reused, so custom separators survive.\nfunction collapseItems(children: React.ReactNode, maxItems: number | undefined, before: number, after: number) {\n if (maxItems === undefined) return children\n\n const nodes = flattenFragments(children)\n const kinds = classifyNodes(nodes)\n const segments: { separator: React.ReactNode; nodes: React.ReactNode[] }[] = []\n let pendingSeparator: React.ReactNode = null\n nodes.forEach((node, i) => {\n if (kinds[i] === 'separator') {\n pendingSeparator = node\n } else {\n segments.push({ separator: pendingSeparator, nodes: [node] })\n pendingSeparator = null\n }\n })\n\n if (segments.length <= maxItems || before + after >= segments.length) return children\n\n const head = segments.slice(0, before)\n const tail = segments.slice(segments.length - after)\n const render = (list: typeof segments) => list.flatMap((seg) => (seg.separator ? [seg.separator, ...seg.nodes] : seg.nodes))\n const ellipsisSeparator = segments[before].separator\n\n return [\n ...render(head),\n ...(ellipsisSeparator ? [ellipsisSeparator] : []),\n <BreadcrumbItem key=\"breadcrumb-collapsed\">\n <BreadcrumbEllipsis />\n </BreadcrumbItem>,\n ...render(tail),\n ]\n}\n\n// ─── Exports ──────────────────────────────────────────────\n\nexport {\n Breadcrumb,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbPage,\n BreadcrumbSeparator,\n BreadcrumbEllipsis,\n breadcrumbSizeMap,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BM;AA7BN,YAAuB;AACvB,wBAAqB;AAErB,mBAAmB;AAYnB,MAAM,oBAAoB,MAAM,cAAsC,CAAC,CAAC;AACxE,MAAM,uBAAuB,MAAM,MAAM,WAAW,iBAAiB;AAIrE,SAAS,iBAAiB,EAAE,UAAU,GAA2B;AAC/D,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,QAAO;AAAA,MACP,aAAa;AAAA,MAEb,sDAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,GAAE,gBAAe;AAAA;AAAA,EACtE;AAEJ;AAIA,SAAS,aAAa,EAAE,UAAU,GAA2B;AAC3D,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,SAAQ;AAAA,MAER;AAAA,oDAAC,YAAO,IAAG,KAAI,IAAG,MAAK,GAAE,OAAM;AAAA,QAC/B,4CAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM;AAAA,QAChC,4CAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM;AAAA;AAAA;AAAA,EAClC;AAEJ;AAIA,MAAM,oBAAoB;AAAA,EACxB,IAAI,EAAE,MAAM,WAAW,MAAM,WAAW,KAAK,UAAU;AAAA,EACvD,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,KAAK,QAAQ;AAAA,EAC1D,I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,YAAY,SAAS,SAAS,SAAS,OAAQ,QAAO;AAE7E,QAAM,OAAO,SAAS,MAAM,GAAG,MAAM;AACrC,QAAM,OAAO,SAAS,MAAM,SAAS,SAAS,KAAK;AACnD,QAAM,SAAS,CAAC,SAA0B,KAAK,QAAQ,CAAC,QAAS,IAAI,YAAY,CAAC,IAAI,WAAW,GAAG,IAAI,KAAK,IAAI,IAAI,KAAM;AAC3H,QAAM,oBAAoB,SAAS,MAAM,EAAE;AAE3C,SAAO;AAAA,IACL,GAAG,OAAO,IAAI;AAAA,IACd,GAAI,oBAAoB,CAAC,iBAAiB,IAAI,CAAC;AAAA,IAC/C,4CAAC,kBACC,sDAAC,sBAAmB,KADF,sBAEpB;AAAA,IACA,GAAG,OAAO,IAAI;AAAA,EAChB;AACF;","names":[]}
@@ -163,24 +163,30 @@ function flattenFragments(children) {
163
163
  ) : [node]
164
164
  );
165
165
  }
166
+ function classifyNodes(nodes) {
167
+ const known = nodes.map((node) => {
168
+ const type = React.isValidElement(node) ? node.type : null;
169
+ return type === BreadcrumbSeparator ? "separator" : type === BreadcrumbItem ? "item" : null;
170
+ });
171
+ if (known.every((kind) => kind === null)) {
172
+ return nodes.map((_, i) => i % 2 === 0 ? "item" : "separator");
173
+ }
174
+ return known.map((kind) => kind ?? "item");
175
+ }
166
176
  function collapseItems(children, maxItems, before, after) {
167
177
  if (maxItems === void 0) return children;
168
178
  const nodes = flattenFragments(children);
179
+ const kinds = classifyNodes(nodes);
169
180
  const segments = [];
170
181
  let pendingSeparator = null;
171
- for (const node of nodes) {
172
- const type = React.isValidElement(node) ? node.type : null;
173
- if (type === BreadcrumbSeparator) {
182
+ nodes.forEach((node, i) => {
183
+ if (kinds[i] === "separator") {
174
184
  pendingSeparator = node;
175
- } else if (type === BreadcrumbItem) {
185
+ } else {
176
186
  segments.push({ separator: pendingSeparator, nodes: [node] });
177
187
  pendingSeparator = null;
178
- } else if (segments.length > 0) {
179
- segments[segments.length - 1].nodes.push(node);
180
- } else {
181
- segments.push({ separator: null, nodes: [node] });
182
188
  }
183
- }
189
+ });
184
190
  if (segments.length <= maxItems || before + after >= segments.length) return children;
185
191
  const head = segments.slice(0, before);
186
192
  const tail = segments.slice(segments.length - after);