gridsmith-ui 0.6.2 → 0.6.3

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
@@ -7,8 +7,8 @@ export { BreakpointWidthProvider, useBreakpoint } from './chunk-DPF6776I.js';
7
7
  import { Tooltip, useTextOverflow, usePosition, Slot } from './chunk-R5QGJURZ.js';
8
8
  export { Tooltip, useTextOverflow } from './chunk-R5QGJURZ.js';
9
9
  import { Icon } from './chunk-GX6O72IV.js';
10
- import { cn, GLASS_SURFACE, ACTIVE_RING, GLASS_BACKDROP, GLASS_DROPDOWN, lockBodyScroll, unlockBodyScroll, GLASS_OVERLAY, HAS_FOCUS_RING, FOCUS_RING, FOCUS_WITHIN_RING } from './chunk-TTZSZNJ6.js';
11
- import { createContext, forwardRef, useContext, useState, useRef, useEffect, useCallback, useId, isValidElement, cloneElement, useMemo, Children, Fragment as Fragment$1, useLayoutEffect } from 'react';
10
+ import { cn, GLASS_SURFACE, ACTIVE_RING, GLASS_BACKDROP, GLASS_DROPDOWN, lockBodyScroll, unlockBodyScroll, GLASS_OVERLAY, FOCUS_RING, HAS_FOCUS_RING, FOCUS_WITHIN_RING } from './chunk-TTZSZNJ6.js';
11
+ import { createContext, forwardRef, useContext, useState, useRef, useEffect, useCallback, useId, isValidElement, cloneElement, Fragment as Fragment$1, useMemo, Children, useLayoutEffect } from 'react';
12
12
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
13
  import { createPortal } from 'react-dom';
14
14
 
@@ -3580,13 +3580,30 @@ var sizeStyles3 = {
3580
3580
  md: "h-10 w-10 text-sm",
3581
3581
  lg: "h-12 w-12 text-base"
3582
3582
  };
3583
+ var paletteStyles = {
3584
+ 1: "bg-[var(--ds-palette-1-bg,var(--ds-bg-muted))] text-[var(--ds-palette-1-text,var(--ds-text-secondary))]",
3585
+ 2: "bg-[var(--ds-palette-2-bg,var(--ds-bg-muted))] text-[var(--ds-palette-2-text,var(--ds-text-secondary))]",
3586
+ 3: "bg-[var(--ds-palette-3-bg,var(--ds-bg-muted))] text-[var(--ds-palette-3-text,var(--ds-text-secondary))]",
3587
+ 4: "bg-[var(--ds-palette-4-bg,var(--ds-bg-muted))] text-[var(--ds-palette-4-text,var(--ds-text-secondary))]",
3588
+ 5: "bg-[var(--ds-palette-5-bg,var(--ds-bg-muted))] text-[var(--ds-palette-5-text,var(--ds-text-secondary))]"
3589
+ };
3590
+ function paletteFor(seed) {
3591
+ let h = 0;
3592
+ for (const ch of seed) h = h * 31 + ch.charCodeAt(0) >>> 0;
3593
+ return h % 5 + 1;
3594
+ }
3595
+ function colorStyles(color, seed) {
3596
+ if (color === "accent") return "bg-[var(--ds-accent-primary)] text-[var(--ds-text-on-primary)]";
3597
+ if (color === "neutral") return "bg-[var(--ds-bg-muted)] text-[var(--ds-text-secondary)]";
3598
+ return paletteStyles[color === "auto" ? paletteFor(seed) : color];
3599
+ }
3583
3600
  var statusVariantMap = {
3584
3601
  online: "success",
3585
3602
  away: "warning",
3586
3603
  busy: "error",
3587
3604
  offline: "offline"
3588
3605
  };
3589
- function Avatar({ initials, src, alt, size = "md", status, className }) {
3606
+ function Avatar({ initials, src, alt, size = "md", status, color = "auto", className }) {
3590
3607
  const base = cn(
3591
3608
  "inline-flex items-center justify-center font-medium shrink-0",
3592
3609
  "rounded-[var(--ds-radius-full)]",
@@ -3605,7 +3622,7 @@ function Avatar({ initials, src, alt, size = "md", status, className }) {
3605
3622
  {
3606
3623
  className: cn(
3607
3624
  base,
3608
- "bg-[var(--ds-accent-primary)] text-[var(--ds-text-on-primary)]",
3625
+ colorStyles(color, alt ?? initials ?? ""),
3609
3626
  "border-[length:var(--ds-border-width)] border-transparent"
3610
3627
  ),
3611
3628
  children: initials
@@ -6344,6 +6361,7 @@ function AvatarGroup({ items, max = 4, size = "sm", ring = "canvas", onOverflowC
6344
6361
  initials,
6345
6362
  size,
6346
6363
  status: item.status,
6364
+ color: item.color,
6347
6365
  className: ringClass
6348
6366
  },
6349
6367
  i
@@ -7561,9 +7579,23 @@ function TabsRoot(props) {
7561
7579
  overflow = "scroll",
7562
7580
  className
7563
7581
  } = props;
7582
+ const isMobile = useBreakpoint("md");
7583
+ const effectiveOrientation = orientation === "responsive" ? "vertical" : orientation;
7564
7584
  if ("tabs" in props && props.tabs) {
7565
- const { tabs } = props;
7566
- if (orientation === "vertical") {
7585
+ const { tabs, mobile = "scroll" } = props;
7586
+ const collapseToDropdown = isMobile && (orientation === "responsive" || mobile === "dropdown");
7587
+ if (collapseToDropdown) {
7588
+ return /* @__PURE__ */ jsx(
7589
+ Dropdown,
7590
+ {
7591
+ options: tabs.filter((t) => !t.disabled).map((t) => ({ id: t.id, label: t.label, group: t.group })),
7592
+ value: activeTab,
7593
+ onChange: (v) => onTabChange(v),
7594
+ className
7595
+ }
7596
+ );
7597
+ }
7598
+ if (effectiveOrientation === "vertical") {
7567
7599
  return /* @__PURE__ */ jsx(
7568
7600
  "div",
7569
7601
  {
@@ -7574,7 +7606,20 @@ function TabsRoot(props) {
7574
7606
  variant === "underline" && "border-r-[length:var(--ds-border-width)] border-[var(--ds-border-default)] pr-ds-1",
7575
7607
  className
7576
7608
  ),
7577
- children: tabs.map((tab) => /* @__PURE__ */ jsx(TabButton, { hasPanel: false, ...tab, orientation, variant, activeTab, onTabChange, fullWidth, onKeyDown: (e) => handleTabKeyDown(e, tab.id, () => tabs, orientation, onTabChange) }, tab.id))
7609
+ children: tabs.map((tab, i) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
7610
+ tab.group && tab.group !== tabs[i - 1]?.group && /* @__PURE__ */ jsx(
7611
+ "span",
7612
+ {
7613
+ "aria-hidden": "true",
7614
+ className: cn(
7615
+ "px-ds-3 pb-ds-1 text-xs font-semibold uppercase tracking-wider text-[var(--ds-text-muted)]",
7616
+ i > 0 && "mt-ds-3"
7617
+ ),
7618
+ children: tab.group
7619
+ }
7620
+ ),
7621
+ /* @__PURE__ */ jsx(TabButton, { hasPanel: false, ...tab, orientation: effectiveOrientation, variant, activeTab, onTabChange, fullWidth, onKeyDown: (e) => handleTabKeyDown(e, tab.id, () => tabs, effectiveOrientation, onTabChange) })
7622
+ ] }, tab.id))
7578
7623
  }
7579
7624
  );
7580
7625
  }
@@ -7591,11 +7636,11 @@ function TabsRoot(props) {
7591
7636
  fullWidth && "w-full",
7592
7637
  className
7593
7638
  ),
7594
- children: tabs.map((tab) => /* @__PURE__ */ jsx(TabButton, { hasPanel: false, ...tab, orientation, variant, activeTab, onTabChange, fullWidth, onKeyDown: (e) => handleTabKeyDown(e, tab.id, () => tabs, orientation, onTabChange) }, tab.id))
7639
+ children: tabs.map((tab) => /* @__PURE__ */ jsx(TabButton, { hasPanel: false, ...tab, orientation: effectiveOrientation, variant, activeTab, onTabChange, fullWidth, onKeyDown: (e) => handleTabKeyDown(e, tab.id, () => tabs, effectiveOrientation, onTabChange) }, tab.id))
7595
7640
  }
7596
7641
  );
7597
7642
  }
7598
- return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { activeTab, onTabChange, orientation, variant, fullWidth, overflow }, children: /* @__PURE__ */ jsx("div", { className, children: props.children }) });
7643
+ return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { activeTab, onTabChange, orientation: effectiveOrientation, variant, fullWidth, overflow }, children: /* @__PURE__ */ jsx("div", { className, children: props.children }) });
7599
7644
  }
7600
7645
  var Tabs = Object.assign(TabsRoot, {
7601
7646
  List: TabsList,