@labpane/ui 1.5.1 → 1.6.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/dist/index.js CHANGED
@@ -634,6 +634,7 @@ var AvatarBadge = React5.forwardRef(function AvatarBadge2({ className, ...props
634
634
  {
635
635
  ref,
636
636
  "data-slot": "avatar-badge",
637
+ role: props["aria-label"] || props["aria-labelledby"] ? "img" : void 0,
637
638
  className: cn(
638
639
  "labui:absolute labui:right-0 labui:bottom-0 labui:z-10 labui:inline-flex labui:items-center labui:justify-center labui:rounded-full labui:bg-primary labui:text-primary-foreground labui:ring-2 labui:ring-background labui:select-none",
639
640
  "labui:group-data-[size=sm]/avatar:size-2 labui:group-data-[size=sm]/avatar:[&>svg]:hidden",
@@ -681,8 +682,8 @@ import { jsx as jsx5 } from "react/jsx-runtime";
681
682
  var badgeVariants = {
682
683
  default: "labui:bg-primary labui:text-primary-foreground labui:[a&]:hover:bg-primary/90",
683
684
  secondary: "labui:bg-secondary labui:text-secondary-foreground labui:[a&]:hover:bg-secondary/90",
684
- destructive: "labui:border-destructive/30 labui:bg-destructive/15 labui:text-destructive labui:focus-visible:ring-destructive/20 labui:[a&]:hover:bg-destructive/25",
685
- success: "labui:border-success/30 labui:bg-success/15 labui:text-success labui:[a&]:hover:bg-success/25",
685
+ destructive: "labui:border-destructive/30 labui:bg-destructive-muted labui:text-destructive labui:focus-visible:ring-destructive/20 labui:[a&]:hover:underline",
686
+ success: "labui:border-success/30 labui:bg-success/10 labui:text-success labui:[a&]:hover:underline",
686
687
  warning: "labui:border-warning/30 labui:bg-warning/15 labui:text-warning labui:[a&]:hover:bg-warning/25",
687
688
  info: "labui:border-info/30 labui:bg-info/15 labui:text-info labui:[a&]:hover:bg-info/25",
688
689
  outline: "labui:border-border labui:text-foreground labui:[a&]:hover:bg-accent labui:[a&]:hover:text-accent-foreground",
@@ -812,6 +813,7 @@ var BreadcrumbEllipsis = React7.forwardRef(function BreadcrumbEllipsis2({ classN
812
813
 
813
814
  // browser-layout.tsx
814
815
  import * as React8 from "react";
816
+ import { Slot as Slot3 } from "@radix-ui/react-slot";
815
817
  import { PanelLeftIcon } from "lucide-react";
816
818
  import { jsx as jsx7 } from "react/jsx-runtime";
817
819
  var BrowserLayoutContext = React8.createContext({
@@ -874,9 +876,10 @@ var BrowserLayoutNav = React8.forwardRef(function BrowserLayoutNav2({ className,
874
876
  }
875
877
  );
876
878
  });
877
- var BrowserLayoutPane = React8.forwardRef(function BrowserLayoutPane2({ className, ...props }, ref) {
879
+ var BrowserLayoutPane = React8.forwardRef(function BrowserLayoutPane2({ className, asChild = false, ...props }, ref) {
880
+ const Comp = asChild ? Slot3 : "main";
878
881
  return /* @__PURE__ */ jsx7(
879
- "main",
882
+ Comp,
880
883
  {
881
884
  ref,
882
885
  "data-slot": "browser-layout-pane",
@@ -1309,6 +1312,7 @@ var CommandSeparator = React13.forwardRef(function CommandSeparator2({ className
1309
1312
  {
1310
1313
  ref,
1311
1314
  "data-slot": "command-separator",
1315
+ "aria-hidden": "true",
1312
1316
  className: cn("labui:-mx-1 labui:h-px labui:bg-border", className),
1313
1317
  ...props
1314
1318
  }
@@ -2615,7 +2619,7 @@ var FlameGraph = React24.forwardRef(
2615
2619
  role: "button",
2616
2620
  tabIndex: current ? 0 : -1,
2617
2621
  "data-node-id": node.id,
2618
- "aria-label": `${node.name}, total ${formatValue(node.total)} ${unit}, self ${formatValue(node.self)} ${unit}. Press to zoom in`,
2622
+ "aria-label": `${node.name}, total ${formatValue(node.total)} ${unit}, self ${formatValue(node.self)} ${unit}. ${barWidth > 38 ? `Displayed: ${barText(node, barWidth, root.total)}. ` : ""}Press to zoom in`,
2619
2623
  className: "labui:cursor-pointer labui:outline-none labui:focus-visible:[&>rect]:stroke-foreground labui:focus-visible:[&>rect]:stroke-2",
2620
2624
  onClick: () => zoom(node),
2621
2625
  onKeyDown: (event) => keydown(event, node),
@@ -3174,7 +3178,7 @@ var InputGroupAddon = React28.forwardRef(function InputGroupAddon2({ className,
3174
3178
  "data-slot": "input-group-addon",
3175
3179
  "data-align": align,
3176
3180
  className: cn(
3177
- "labui:flex labui:h-auto labui:cursor-text labui:items-center labui:justify-center labui:gap-2 labui:py-1.5 labui:text-sm labui:font-medium labui:text-muted-foreground labui:select-none labui:group-data-[disabled=true]/input-group:opacity-50 labui:[&>kbd]:rounded-[calc(var(--labui-radius)-5px)] labui:[&>svg:not([class*='size-'])]:size-4",
3181
+ "labui:flex labui:h-auto labui:cursor-text labui:items-center labui:justify-center labui:gap-2 labui:py-1.5 labui:text-sm labui:font-medium labui:text-muted-foreground labui:select-none labui:[&>kbd]:rounded-[calc(var(--labui-radius)-5px)] labui:[&>svg:not([class*='size-'])]:size-4",
3178
3182
  addonAlignments[align],
3179
3183
  className
3180
3184
  ),
@@ -3347,7 +3351,7 @@ var NativeSelectOptGroup = React30.forwardRef(function NativeSelectOptGroup2({ c
3347
3351
 
3348
3352
  // nav-tabs.tsx
3349
3353
  import * as React31 from "react";
3350
- import { Slot as Slot3 } from "@radix-ui/react-slot";
3354
+ import { Slot as Slot4 } from "@radix-ui/react-slot";
3351
3355
  import { jsx as jsx32 } from "react/jsx-runtime";
3352
3356
  function moveFocus(nav, step) {
3353
3357
  const tabs = [...nav.querySelectorAll("[data-slot=nav-tab]")];
@@ -3381,7 +3385,7 @@ var NavTabs = React31.forwardRef(function NavTabs2({ className, onKeyDown, ...pr
3381
3385
  );
3382
3386
  });
3383
3387
  var NavTab = React31.forwardRef(function NavTab2({ active = false, asChild = false, className, ...props }, ref) {
3384
- const Comp = asChild ? Slot3 : "a";
3388
+ const Comp = asChild ? Slot4 : "a";
3385
3389
  return /* @__PURE__ */ jsx32(
3386
3390
  Comp,
3387
3391
  {
@@ -3551,7 +3555,7 @@ import * as React38 from "react";
3551
3555
 
3552
3556
  // sidebar.tsx
3553
3557
  import * as React37 from "react";
3554
- import { Slot as Slot4 } from "@radix-ui/react-slot";
3558
+ import { Slot as Slot5 } from "@radix-ui/react-slot";
3555
3559
  import { PanelLeftIcon as PanelLeftIcon2 } from "lucide-react";
3556
3560
 
3557
3561
  // sheet.tsx
@@ -3973,9 +3977,10 @@ var SidebarRail = React37.forwardRef(function SidebarRail2({ className, ...props
3973
3977
  }
3974
3978
  );
3975
3979
  });
3976
- var SidebarInset = React37.forwardRef(function SidebarInset2({ className, ...props }, ref) {
3980
+ var SidebarInset = React37.forwardRef(function SidebarInset2({ className, asChild = false, ...props }, ref) {
3981
+ const Comp = asChild ? Slot5 : "main";
3977
3982
  return /* @__PURE__ */ jsx37(
3978
- "main",
3983
+ Comp,
3979
3984
  {
3980
3985
  ref,
3981
3986
  "data-slot": "sidebar-inset",
@@ -4054,7 +4059,7 @@ var SidebarSeparator = React37.forwardRef(function SidebarSeparator2({ className
4054
4059
  );
4055
4060
  });
4056
4061
  var SidebarGroupLabel = React37.forwardRef(function SidebarGroupLabel2({ className, asChild = false, ...props }, ref) {
4057
- const Comp = asChild ? Slot4 : "div";
4062
+ const Comp = asChild ? Slot5 : "div";
4058
4063
  return /* @__PURE__ */ jsx37(
4059
4064
  Comp,
4060
4065
  {
@@ -4071,7 +4076,7 @@ var SidebarGroupLabel = React37.forwardRef(function SidebarGroupLabel2({ classNa
4071
4076
  );
4072
4077
  });
4073
4078
  var SidebarGroupAction = React37.forwardRef(function SidebarGroupAction2({ className, asChild = false, ...props }, ref) {
4074
- const Comp = asChild ? Slot4 : "button";
4079
+ const Comp = asChild ? Slot5 : "button";
4075
4080
  return /* @__PURE__ */ jsx37(
4076
4081
  Comp,
4077
4082
  {
@@ -4133,7 +4138,7 @@ var SidebarMenuButton = React37.forwardRef(function SidebarMenuButton2({
4133
4138
  className,
4134
4139
  ...props
4135
4140
  }, ref) {
4136
- const Comp = asChild ? Slot4 : "button";
4141
+ const Comp = asChild ? Slot5 : "button";
4137
4142
  const { isMobile, state } = useSidebar();
4138
4143
  const button = /* @__PURE__ */ jsx37(
4139
4144
  Comp,
@@ -4168,7 +4173,7 @@ var SidebarMenuButton = React37.forwardRef(function SidebarMenuButton2({
4168
4173
  ] });
4169
4174
  });
4170
4175
  var SidebarMenuAction = React37.forwardRef(function SidebarMenuAction2({ className, asChild = false, showOnHover = false, ...props }, ref) {
4171
- const Comp = asChild ? Slot4 : "button";
4176
+ const Comp = asChild ? Slot5 : "button";
4172
4177
  return /* @__PURE__ */ jsx37(
4173
4178
  Comp,
4174
4179
  {
@@ -4266,7 +4271,7 @@ var SidebarMenuSubItem = React37.forwardRef(function SidebarMenuSubItem2({ class
4266
4271
  );
4267
4272
  });
4268
4273
  var SidebarMenuSubButton = React37.forwardRef(function SidebarMenuSubButton2({ asChild = false, size = "md", isActive = false, className, ...props }, ref) {
4269
- const Comp = asChild ? Slot4 : "a";
4274
+ const Comp = asChild ? Slot5 : "a";
4270
4275
  return /* @__PURE__ */ jsx37(
4271
4276
  Comp,
4272
4277
  {
@@ -5473,7 +5478,7 @@ var TabsTrigger = React48.forwardRef(function TabsTrigger2({ className, ...props
5473
5478
  ref,
5474
5479
  "data-slot": "tabs-trigger",
5475
5480
  className: cn(
5476
- "labui:relative labui:inline-flex labui:h-[calc(100%-1px)] labui:flex-1 labui:items-center labui:justify-center labui:gap-1.5 labui:rounded-md labui:border labui:border-transparent labui:px-2 labui:py-1 labui:text-sm labui:font-medium labui:whitespace-nowrap labui:text-foreground/60 labui:transition-all labui:group-data-[orientation=vertical]/tabs:w-full labui:group-data-[orientation=vertical]/tabs:justify-start labui:hover:text-foreground labui:focus-visible:border-ring labui:focus-visible:ring-[3px] labui:focus-visible:ring-ring/50 labui:focus-visible:outline-1 labui:focus-visible:outline-ring labui:disabled:pointer-events-none labui:disabled:opacity-50 labui:group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm labui:group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none labui:dark:text-muted-foreground labui:dark:hover:text-foreground labui:[&_svg]:pointer-events-none labui:[&_svg]:shrink-0 labui:[&_svg:not([class*='size-'])]:size-4",
5481
+ "labui:relative labui:inline-flex labui:h-[calc(100%-1px)] labui:flex-1 labui:items-center labui:justify-center labui:gap-1.5 labui:rounded-md labui:border labui:border-transparent labui:px-2 labui:py-1 labui:text-sm labui:font-medium labui:whitespace-nowrap labui:text-muted-foreground labui:transition-all labui:group-data-[orientation=vertical]/tabs:w-full labui:group-data-[orientation=vertical]/tabs:justify-start labui:hover:text-foreground labui:focus-visible:border-ring labui:focus-visible:ring-[3px] labui:focus-visible:ring-ring/50 labui:focus-visible:outline-1 labui:focus-visible:outline-ring labui:disabled:pointer-events-none labui:disabled:opacity-50 labui:group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm labui:group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none labui:dark:text-muted-foreground labui:dark:hover:text-foreground labui:[&_svg]:pointer-events-none labui:[&_svg]:shrink-0 labui:[&_svg:not([class*='size-'])]:size-4",
5477
5482
  "labui:group-data-[variant=line]/tabs-list:bg-transparent labui:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent labui:dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent labui:dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
5478
5483
  "labui:data-[state=active]:bg-background labui:data-[state=active]:text-foreground labui:dark:data-[state=active]:border-input labui:dark:data-[state=active]:bg-input/30 labui:dark:data-[state=active]:text-foreground",
5479
5484
  "labui:after:absolute labui:after:bg-foreground labui:after:opacity-0 labui:after:transition-opacity labui:group-data-[orientation=horizontal]/tabs:after:inset-x-0 labui:group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] labui:group-data-[orientation=horizontal]/tabs:after:h-0.5 labui:group-data-[orientation=vertical]/tabs:after:inset-y-0 labui:group-data-[orientation=vertical]/tabs:after:-right-1 labui:group-data-[orientation=vertical]/tabs:after:w-0.5 labui:group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
@@ -7516,19 +7521,38 @@ var TICKS = 5;
7516
7521
  var formatValue2 = (value) => value.toLocaleString(void 0, { maximumFractionDigits: 3 });
7517
7522
  var TimingTracks = React52.forwardRef(
7518
7523
  function TimingTracks2({ tracks, from, to, label = "Timeline", unit = "ms", onSelect }, ref) {
7524
+ const { container, width } = useChartWidth();
7525
+ React52.useImperativeHandle(ref, () => container.current, [
7526
+ container
7527
+ ]);
7528
+ const plotWidth = Math.max(560, width - 32) - 142;
7519
7529
  const [active, setActive] = React52.useState(null);
7520
7530
  const range = Math.max(1e-3, to - from);
7521
7531
  const visible = (span) => span.end >= from && span.start <= to;
7522
- const placement = (span) => {
7523
- const left = Math.max(from, span.start);
7524
- const right = Math.min(to, span.end);
7525
- return {
7526
- left: `${(left - from) / range * 100}%`,
7527
- width: `max(3px, ${(right - left) / range * 100}%)`
7528
- };
7532
+ const layout = (track) => {
7533
+ const lanes = [];
7534
+ const spans = track.spans.filter(visible).map((span) => {
7535
+ const start = (Math.max(from, span.start) - from) / range * plotWidth;
7536
+ const end = (Math.min(to, span.end) - from) / range * plotWidth;
7537
+ const barWidth = Math.max(3, end - start);
7538
+ const targetWidth = Math.max(24, barWidth);
7539
+ const left = Math.max(0, Math.min(start, plotWidth - targetWidth));
7540
+ let lane = lanes.findIndex((right) => right + 4 <= left);
7541
+ if (lane < 0) lane = lanes.length;
7542
+ lanes[lane] = left + targetWidth;
7543
+ return {
7544
+ span,
7545
+ left,
7546
+ targetWidth,
7547
+ barWidth,
7548
+ offset: start - left,
7549
+ lane
7550
+ };
7551
+ });
7552
+ return { spans, height: Math.max(1, lanes.length) * 32 + 4 };
7529
7553
  };
7530
7554
  const duration = (span) => `${formatValue2(span.end - span.start)} ${unit}`;
7531
- return /* @__PURE__ */ jsxs29(ChartFrame, { "data-slot": "timing-tracks", "aria-label": label, ref, children: [
7555
+ return /* @__PURE__ */ jsxs29(ChartFrame, { "data-slot": "timing-tracks", "aria-label": label, ref: container, children: [
7532
7556
  /* @__PURE__ */ jsx50("div", { className: "labui:border-b labui:px-4 labui:py-3 labui:text-sm labui:font-semibold", children: label }),
7533
7557
  /* @__PURE__ */ jsx50("div", { className: "labui:overflow-x-auto labui:p-4", children: /* @__PURE__ */ jsxs29("div", { className: "labui:min-w-[560px]", children: [
7534
7558
  /* @__PURE__ */ jsx50("div", { className: "labui:mb-2 labui:ml-36 labui:flex labui:justify-between labui:text-xs labui:text-muted-foreground labui:tabular-nums", children: Array.from({ length: TICKS }, (_, i) => /* @__PURE__ */ jsxs29("span", { children: [
@@ -7536,46 +7560,67 @@ var TimingTracks = React52.forwardRef(
7536
7560
  " ",
7537
7561
  unit
7538
7562
  ] }, i)) }),
7539
- tracks.map((track) => /* @__PURE__ */ jsxs29(
7540
- "div",
7541
- {
7542
- className: "labui:mb-2 labui:flex labui:items-center labui:gap-3",
7543
- children: [
7544
- /* @__PURE__ */ jsx50("span", { className: "labui:w-32 labui:shrink-0 labui:text-xs labui:font-medium", children: track.label }),
7545
- /* @__PURE__ */ jsx50(
7546
- "div",
7547
- {
7548
- className: "labui:relative labui:h-9 labui:flex-1 labui:rounded labui:border labui:bg-muted/30",
7549
- "aria-label": track.label,
7550
- children: track.spans.filter(visible).map((span) => /* @__PURE__ */ jsx50(
7551
- "button",
7552
- {
7553
- type: "button",
7554
- className: "labui:absolute labui:top-1 labui:h-7 labui:overflow-hidden labui:rounded labui:px-1 labui:text-left labui:text-[11px] labui:text-primary-foreground labui:outline-offset-2 labui:focus-visible:outline-2",
7555
- style: {
7556
- ...placement(span),
7557
- background: span.color || "var(--labui-chart-4)",
7558
- border: span.uncertain ? "1px dashed currentColor" : void 0,
7559
- opacity: span.uncertain ? 0.65 : 1
7560
- },
7561
- title: `${span.label}: ${duration(span)}. ${span.detail ?? ""}`,
7562
- onPointerEnter: () => setActive(span),
7563
- onFocus: () => setActive(span),
7564
- onClick: () => {
7565
- setActive(span);
7566
- onSelect?.(span);
7567
- },
7568
- "aria-label": `${span.label}, ${formatValue2(span.start)} to ${formatValue2(span.end)} ${unit}${span.uncertain ? ", observation window" : ""}`,
7569
- children: span.label
7570
- },
7571
- span.id
7572
- ))
7573
- }
7574
- )
7575
- ]
7576
- },
7577
- track.id
7578
- ))
7563
+ tracks.map((track) => {
7564
+ const { spans, height } = layout(track);
7565
+ return /* @__PURE__ */ jsxs29(
7566
+ "div",
7567
+ {
7568
+ className: "labui:mb-2 labui:flex labui:items-center labui:gap-3",
7569
+ children: [
7570
+ /* @__PURE__ */ jsx50("span", { className: "labui:w-32 labui:shrink-0 labui:text-xs labui:font-medium", children: track.label }),
7571
+ /* @__PURE__ */ jsx50(
7572
+ "div",
7573
+ {
7574
+ className: "labui:relative labui:flex-1 labui:rounded labui:border labui:bg-muted/30",
7575
+ style: { height },
7576
+ role: "group",
7577
+ "aria-label": track.label,
7578
+ children: spans.map(
7579
+ ({ span, left, targetWidth, barWidth, offset, lane }) => /* @__PURE__ */ jsxs29(
7580
+ "button",
7581
+ {
7582
+ type: "button",
7583
+ className: "labui:absolute labui:h-7 labui:overflow-hidden labui:rounded labui:px-1 labui:text-left labui:text-[11px] labui:outline-offset-2 labui:focus-visible:outline-2",
7584
+ style: {
7585
+ left,
7586
+ top: lane * 32 + 4,
7587
+ width: targetWidth
7588
+ },
7589
+ title: `${span.label}: ${duration(span)}. ${span.detail ?? ""}`,
7590
+ onPointerEnter: () => setActive(span),
7591
+ onFocus: () => setActive(span),
7592
+ onClick: () => {
7593
+ setActive(span);
7594
+ onSelect?.(span);
7595
+ },
7596
+ "aria-label": `${span.label}, ${formatValue2(span.start)} to ${formatValue2(span.end)} ${unit}${span.uncertain ? ", observation window" : ""}`,
7597
+ children: [
7598
+ /* @__PURE__ */ jsx50(
7599
+ "span",
7600
+ {
7601
+ "aria-hidden": "true",
7602
+ className: "labui:absolute labui:inset-y-0 labui:rounded",
7603
+ style: {
7604
+ left: offset,
7605
+ width: barWidth,
7606
+ background: span.color || "var(--labui-chart-4)",
7607
+ border: span.uncertain ? "1px dashed var(--labui-foreground)" : void 0
7608
+ }
7609
+ }
7610
+ ),
7611
+ /* @__PURE__ */ jsx50("span", { className: "labui:relative labui:whitespace-nowrap labui:rounded labui:bg-card labui:px-0.5 labui:text-card-foreground", children: span.label })
7612
+ ]
7613
+ },
7614
+ span.id
7615
+ )
7616
+ )
7617
+ }
7618
+ )
7619
+ ]
7620
+ },
7621
+ track.id
7622
+ );
7623
+ })
7579
7624
  ] }) }),
7580
7625
  /* @__PURE__ */ jsx50(
7581
7626
  "div",