@bison-lab/ui 5.5.0 → 5.9.1

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.mjs CHANGED
@@ -3798,8 +3798,9 @@ const TabsList = React.forwardRef(({ className, children, ...props }, forwardedR
3798
3798
  }
3799
3799
  if (!animate) pill.style.transitionProperty = "none";
3800
3800
  pill.style.opacity = "1";
3801
- pill.style.transform = `translateX(${active.offsetLeft}px)`;
3801
+ pill.style.transform = `translate(${active.offsetLeft}px, ${active.offsetTop}px)`;
3802
3802
  pill.style.width = `${active.offsetWidth}px`;
3803
+ pill.style.height = `${active.offsetHeight}px`;
3803
3804
  if (!animate) {
3804
3805
  pill.offsetWidth;
3805
3806
  pill.style.transitionProperty = "";
@@ -3809,15 +3810,23 @@ const TabsList = React.forwardRef(({ className, children, ...props }, forwardedR
3809
3810
  move(false);
3810
3811
  const list = innerRef.current;
3811
3812
  if (!list) return;
3812
- const observer = new MutationObserver(() => move(true));
3813
+ const resize = new ResizeObserver(() => move(false));
3814
+ const observeSizes = () => {
3815
+ resize.disconnect();
3816
+ resize.observe(list);
3817
+ list.querySelectorAll("[role=\"tab\"]").forEach((tab) => resize.observe(tab));
3818
+ };
3819
+ observeSizes();
3820
+ const observer = new MutationObserver((records) => {
3821
+ if (records.some((record) => record.type === "childList")) observeSizes();
3822
+ move(true);
3823
+ });
3813
3824
  observer.observe(list, {
3814
3825
  subtree: true,
3815
3826
  attributes: true,
3816
3827
  attributeFilter: ["data-state"],
3817
3828
  childList: true
3818
3829
  });
3819
- const resize = new ResizeObserver(() => move(false));
3820
- resize.observe(list);
3821
3830
  return () => {
3822
3831
  observer.disconnect();
3823
3832
  resize.disconnect();
@@ -3825,12 +3834,12 @@ const TabsList = React.forwardRef(({ className, children, ...props }, forwardedR
3825
3834
  }, [move]);
3826
3835
  return /* @__PURE__ */ jsxs(Tabs$1.List, {
3827
3836
  ref: setRef,
3828
- className: cn("relative isolate inline-flex h-[var(--density-height-md)] items-center justify-center rounded-md bg-muted p-1 text-muted-foreground", className),
3837
+ className: cn("relative isolate inline-flex min-h-[var(--density-height-md)] flex-wrap items-center justify-center rounded-md bg-muted p-1 text-muted-foreground", className),
3829
3838
  ...props,
3830
3839
  children: [/* @__PURE__ */ jsx("span", {
3831
3840
  ref: pillRef,
3832
3841
  "aria-hidden": "true",
3833
- className: cn("pointer-events-none absolute bottom-1 left-0 top-1 z-0 rounded-sm opacity-0 shadow-sm", "bg-[var(--bison-tab-active-bg,hsl(var(--primary)))]", "transition-[transform,width] motion-reduce:transition-none"),
3842
+ className: cn("pointer-events-none absolute left-0 top-0 z-0 rounded-sm opacity-0 shadow-sm", "bg-[var(--bison-tab-active-bg,hsl(var(--primary)))]", "transition-[transform,width,height] motion-reduce:transition-none"),
3834
3843
  style: {
3835
3844
  transitionDuration: "var(--tabs-dur)",
3836
3845
  transitionTimingFunction: "var(--tabs-ease)"
@@ -3841,7 +3850,7 @@ const TabsList = React.forwardRef(({ className, children, ...props }, forwardedR
3841
3850
  TabsList.displayName = Tabs$1.List.displayName;
3842
3851
  const TabsTrigger = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Tabs$1.Trigger, {
3843
3852
  ref,
3844
- className: cn("relative z-[1] inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-[var(--bison-tab-active-fg,hsl(var(--primary-foreground)))]", className),
3853
+ className: cn("relative z-[1] inline-flex h-[calc(var(--density-height-md)-0.5rem)] items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-[var(--bison-tab-active-fg,hsl(var(--primary-foreground)))]", className),
3845
3854
  ...props
3846
3855
  }));
3847
3856
  TabsTrigger.displayName = Tabs$1.Trigger.displayName;
@@ -8721,7 +8730,7 @@ const ShowcasePanelsBlock = React.forwardRef(({ items, defaultActiveIndex = 0, a
8721
8730
  alt: item.image.alt ?? "",
8722
8731
  className: "absolute inset-0 h-full w-full object-cover"
8723
8732
  });
8724
- const defaultSpine = (item, i, { numeral }) => {
8733
+ const defaultSpine = (item, _i, { numeral }) => {
8725
8734
  if (spineVariant === "minimal") return /* @__PURE__ */ jsx("span", {
8726
8735
  className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-180 text-sm font-light tracking-[0.25em] whitespace-nowrap text-foreground/90 uppercase [writing-mode:vertical-rl] md:text-base",
8727
8736
  children: item.title
@@ -8757,17 +8766,10 @@ const ShowcasePanelsBlock = React.forwardRef(({ items, defaultActiveIndex = 0, a
8757
8766
  className: "absolute top-16 left-1/2 -translate-x-1/2 text-xl font-light tracking-widest text-foreground/70 md:text-2xl",
8758
8767
  children: numeral
8759
8768
  }),
8769
+ " ",
8760
8770
  /* @__PURE__ */ jsx("span", {
8761
8771
  className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-180 text-sm font-light tracking-[0.25em] whitespace-nowrap text-foreground/90 uppercase [writing-mode:vertical-rl] md:text-base",
8762
8772
  children: item.title
8763
- }),
8764
- watermark && /* @__PURE__ */ jsxs("span", {
8765
- className: "absolute bottom-16 left-1/2 -translate-x-1/2 font-mono text-[0.625rem] tracking-widest text-foreground/40 uppercase",
8766
- children: [
8767
- watermark,
8768
- " · ",
8769
- String(i + 1).padStart(2, "0")
8770
- ]
8771
8773
  })
8772
8774
  ] });
8773
8775
  };
@@ -8841,6 +8843,18 @@ const ShowcasePanelsBlock = React.forwardRef(({ items, defaultActiveIndex = 0, a
8841
8843
  })
8842
8844
  })
8843
8845
  }),
8846
+ watermark && !renderSpine && spineVariant !== "minimal" && /* @__PURE__ */ jsx("span", {
8847
+ "aria-hidden": true,
8848
+ className: cn("pointer-events-none absolute inset-0 z-10 transition-opacity duration-300 ease-out", isShown ? "opacity-0" : "opacity-100"),
8849
+ children: /* @__PURE__ */ jsxs("span", {
8850
+ className: "absolute bottom-16 left-1/2 -translate-x-1/2 font-mono text-[0.625rem] tracking-widest text-foreground/40 uppercase",
8851
+ children: [
8852
+ watermark,
8853
+ " · ",
8854
+ String(i + 1).padStart(2, "0")
8855
+ ]
8856
+ })
8857
+ }),
8844
8858
  /* @__PURE__ */ jsxs("div", {
8845
8859
  id: panelId(i),
8846
8860
  "aria-hidden": !isShown,
@@ -10102,49 +10116,59 @@ function ResourceScrim({ item, cardVariant }) {
10102
10116
  return /* @__PURE__ */ jsx("div", {
10103
10117
  "aria-hidden": true,
10104
10118
  "data-resource-scrim": "true",
10105
- className: cn("absolute inset-0", item.backgroundClass)
10119
+ className: cn("absolute inset-0 -z-10", item.backgroundClass)
10106
10120
  });
10107
10121
  }
10108
10122
  if (item.scrim) return /* @__PURE__ */ jsx("div", {
10109
10123
  "aria-hidden": true,
10110
10124
  "data-resource-scrim": "true",
10111
- className: "absolute inset-0 bg-gradient-to-t from-black/85 to-black/55"
10125
+ className: "absolute inset-0 -z-10 bg-gradient-to-t from-black/85 to-black/55"
10112
10126
  });
10113
10127
  return null;
10114
10128
  }
10115
- /** Renders the card wrapper as an anchor, a button, or a plain div, depending on which action props are set. */
10116
- function ResourceCardWrapper({ item, className, cardVariant, renderLink, children }) {
10117
- const dataAttrs = {
10129
+ /**
10130
+ * The card box. A linked or clickable card stays a plain box: its title is
10131
+ * the link (`ResourceTitleAction`), stretched over the card, so the link's
10132
+ * accessible name is exactly its visible text (WCAG 2.5.3, Label in Name).
10133
+ * The focus ring is drawn here, around the whole card. `isolate` gives
10134
+ * each card its own stacking context, which the overlay image and the
10135
+ * stretched link's z-index both rely on.
10136
+ */
10137
+ function ResourceCardWrapper({ item, className, cardVariant, children }) {
10138
+ const actionable = Boolean(item.href || item.onClick);
10139
+ return /* @__PURE__ */ jsx("div", {
10118
10140
  "data-resource-id": item.id,
10119
- ...cardVariant === "overlay" && { "data-card-variant": "overlay" }
10120
- };
10141
+ ...cardVariant === "overlay" && { "data-card-variant": "overlay" },
10142
+ className: cn("relative isolate", actionable && "has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-primary/40 has-[:focus-visible]:ring-offset-2", className),
10143
+ children
10144
+ });
10145
+ }
10146
+ /**
10147
+ * The card's title text, as an anchor (`href`), a button (`onClick`) or plain
10148
+ * text. Its `::after` covers the nearest positioned ancestor, the card, so
10149
+ * the whole card still takes the click.
10150
+ */
10151
+ function ResourceTitleAction({ item, renderLink }) {
10152
+ const stretch = "after:absolute after:inset-0 after:z-10 after:content-[''] focus-visible:outline-none";
10121
10153
  if (item.href) return renderLink({
10122
10154
  href: item.href,
10123
10155
  ...newTabAttributes(item.target === "_blank"),
10124
- "aria-label": item.header,
10125
- ...dataAttrs,
10126
- className: cn("block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2", className),
10127
- children
10156
+ className: stretch,
10157
+ children: item.header
10128
10158
  });
10129
10159
  if (item.onClick) return /* @__PURE__ */ jsx("button", {
10130
10160
  type: "button",
10131
- "aria-label": item.header,
10132
10161
  onClick: item.onClick,
10133
- ...dataAttrs,
10134
- className: cn("block w-full text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2", className),
10135
- children
10136
- });
10137
- return /* @__PURE__ */ jsx("div", {
10138
- className,
10139
- ...dataAttrs,
10140
- children
10162
+ className: cn("text-left", stretch),
10163
+ children: item.header
10141
10164
  });
10165
+ return /* @__PURE__ */ jsx(Fragment, { children: item.header });
10142
10166
  }
10143
- function OverlayCardBody({ item, categoryStyles, headingClassName }) {
10167
+ function OverlayCardBody({ item, categoryStyles, headingClassName, renderLink }) {
10144
10168
  const tone = item.image || item.backgroundClass || item.scrim ? "light" : "default";
10145
10169
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10146
10170
  /* @__PURE__ */ jsx("div", {
10147
- className: "absolute inset-0",
10171
+ className: "absolute inset-0 -z-10",
10148
10172
  children: /* @__PURE__ */ jsx(ResourceImage, { item })
10149
10173
  }),
10150
10174
  /* @__PURE__ */ jsx(ResourceScrim, {
@@ -10152,7 +10176,7 @@ function OverlayCardBody({ item, categoryStyles, headingClassName }) {
10152
10176
  cardVariant: "overlay"
10153
10177
  }),
10154
10178
  /* @__PURE__ */ jsxs("div", {
10155
- className: "relative flex h-full min-w-0 flex-col justify-between gap-4 p-6",
10179
+ className: "flex h-full min-w-0 flex-col justify-between gap-4 p-6",
10156
10180
  children: [/* @__PURE__ */ jsx(ResourceCategories, {
10157
10181
  item,
10158
10182
  categoryStyles
@@ -10161,7 +10185,10 @@ function OverlayCardBody({ item, categoryStyles, headingClassName }) {
10161
10185
  children: [
10162
10186
  /* @__PURE__ */ jsx("h3", {
10163
10187
  className: cn("line-clamp-2 font-semibold tracking-tight", tone === "light" ? "text-white" : "text-foreground", headingClassName),
10164
- children: item.header
10188
+ children: /* @__PURE__ */ jsx(ResourceTitleAction, {
10189
+ item,
10190
+ renderLink
10191
+ })
10165
10192
  }),
10166
10193
  item.subtext && /* @__PURE__ */ jsx("p", {
10167
10194
  className: cn("line-clamp-2 text-sm", tone === "light" ? "text-white/80" : "text-muted-foreground"),
@@ -10180,18 +10207,17 @@ function FeaturedResourceCard({ item, categoryStyles, cardVariant = "default", r
10180
10207
  if (cardVariant === "overlay") return /* @__PURE__ */ jsx(ResourceCardWrapper, {
10181
10208
  item,
10182
10209
  cardVariant,
10183
- renderLink,
10184
- className: "group relative min-h-[24rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
10210
+ className: "group min-h-[24rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
10185
10211
  children: /* @__PURE__ */ jsx(OverlayCardBody, {
10186
10212
  item,
10187
10213
  categoryStyles,
10188
- headingClassName: "text-xl md:text-2xl"
10214
+ headingClassName: "text-xl md:text-2xl",
10215
+ renderLink
10189
10216
  })
10190
10217
  });
10191
10218
  return /* @__PURE__ */ jsxs(ResourceCardWrapper, {
10192
10219
  item,
10193
10220
  cardVariant,
10194
- renderLink,
10195
10221
  className: "group overflow-hidden rounded-lg border bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-md",
10196
10222
  children: [/* @__PURE__ */ jsx("div", {
10197
10223
  className: "aspect-[16/9] w-full overflow-hidden",
@@ -10207,7 +10233,10 @@ function FeaturedResourceCard({ item, categoryStyles, cardVariant = "default", r
10207
10233
  className: "space-y-2",
10208
10234
  children: [/* @__PURE__ */ jsx("h3", {
10209
10235
  className: "text-xl font-semibold tracking-tight md:text-2xl",
10210
- children: item.header
10236
+ children: /* @__PURE__ */ jsx(ResourceTitleAction, {
10237
+ item,
10238
+ renderLink
10239
+ })
10211
10240
  }), item.subtext && /* @__PURE__ */ jsx("p", {
10212
10241
  className: "text-muted-foreground",
10213
10242
  children: item.subtext
@@ -10222,17 +10251,16 @@ function ResourceListCard({ item, categoryStyles, cardVariant = "default", rende
10222
10251
  if (cardVariant === "overlay") return /* @__PURE__ */ jsx(ResourceCardWrapper, {
10223
10252
  item,
10224
10253
  cardVariant,
10225
- renderLink,
10226
- className: "group relative aspect-[2/1] min-h-[14rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
10254
+ className: "group aspect-[2/1] min-h-[14rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
10227
10255
  children: /* @__PURE__ */ jsx(OverlayCardBody, {
10228
10256
  item,
10229
- categoryStyles
10257
+ categoryStyles,
10258
+ renderLink
10230
10259
  })
10231
10260
  });
10232
10261
  return /* @__PURE__ */ jsxs(ResourceCardWrapper, {
10233
10262
  item,
10234
10263
  cardVariant,
10235
- renderLink,
10236
10264
  className: "group flex flex-1 gap-4 rounded-lg border bg-card p-4 text-card-foreground shadow-sm transition-shadow hover:shadow-md",
10237
10265
  children: [/* @__PURE__ */ jsx("div", {
10238
10266
  "data-resource-image": true,
@@ -10248,7 +10276,10 @@ function ResourceListCard({ item, categoryStyles, cardVariant = "default", rende
10248
10276
  categoryStyles
10249
10277
  }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
10250
10278
  className: "font-semibold tracking-tight",
10251
- children: item.header
10279
+ children: /* @__PURE__ */ jsx(ResourceTitleAction, {
10280
+ item,
10281
+ renderLink
10282
+ })
10252
10283
  }), item.subtext && /* @__PURE__ */ jsx("p", {
10253
10284
  className: "line-clamp-2 text-sm text-muted-foreground",
10254
10285
  children: item.subtext