gridsmith-ui 0.3.0 → 0.3.2

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
@@ -1,5 +1,5 @@
1
1
  import { cn, GLASS_BACKDROP, GLASS_DROPDOWN, lockBodyScroll, unlockBodyScroll, GLASS_OVERLAY, GLASS_SURFACE } from './chunk-5XIPPVH7.js';
2
- import { Icon } from './chunk-H2XI6OUB.js';
2
+ import { Icon } from './chunk-WVB3SRXW.js';
3
3
  import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
4
4
  import * as React6 from 'react';
5
5
  import React6__default, { createContext, forwardRef, useState, useCallback, useRef, useContext, useId, useMemo, useEffect, useLayoutEffect, isValidElement, cloneElement, createElement, Fragment as Fragment$1, useDebugValue, memo, useReducer, useSyncExternalStore as useSyncExternalStore$1, useImperativeHandle } from 'react';
@@ -1731,7 +1731,7 @@ function Spinner({ size = "md", color = "default", label = "Loading", className
1731
1731
  );
1732
1732
  }
1733
1733
  var variantStyles = {
1734
- default: "bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)] text-[var(--ds-text-on-primary)] border-transparent hover:bg-[var(--ds-accent-primary-hover)] hover:brightness-110",
1734
+ default: "bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)] [background-origin:border-box] text-[var(--ds-text-on-primary)] border-transparent hover:bg-[var(--ds-accent-primary-hover)] hover:brightness-110",
1735
1735
  secondary: "bg-[var(--ds-bg-surface)] text-[var(--ds-text-primary)] border-[var(--ds-border-default)] hover:bg-[var(--ds-bg-muted)]",
1736
1736
  tertiary: "bg-[var(--ds-bg-muted)] text-[var(--ds-text-primary)] border-transparent hover:brightness-95",
1737
1737
  outline: "bg-[var(--ds-input-bg)] text-[var(--ds-text-primary)] border-[var(--ds-border-default)] hover:bg-[var(--ds-bg-muted)]",
@@ -2093,51 +2093,64 @@ function Label({ className, children, ...props }) {
2093
2093
  }
2094
2094
  );
2095
2095
  }
2096
- function Toggle({ checked, onChange, label, disabled, error = false, "aria-labelledby": ariaLabelledBy, ...rest }) {
2097
- return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center justify-between gap-ds-4", disabled && "opacity-disabled"), children: [
2098
- label && /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-[var(--ds-text-primary)]", children: label }),
2099
- /* @__PURE__ */ jsx(
2100
- "button",
2101
- {
2102
- role: "switch",
2103
- "aria-checked": checked,
2104
- "aria-label": !label && !ariaLabelledBy ? "Toggle" : void 0,
2105
- "aria-labelledby": ariaLabelledBy,
2106
- "aria-invalid": error || void 0,
2107
- disabled,
2108
- onClick: () => !disabled && onChange(!checked),
2109
- ...rest,
2110
- className: cn(
2111
- "relative inline-flex shrink-0 items-center overflow-hidden",
2112
- "border-[length:var(--ds-border-width)]",
2113
- "rounded-[var(--ds-radius-full)]",
2114
- "transition-colors duration-[var(--ds-transition-speed)]",
2115
- "focus-visible:outline-none focus-visible:shadow-[var(--ds-shadow-focus)]",
2116
- disabled ? "cursor-not-allowed" : "cursor-pointer",
2117
- checked ? "bg-[var(--ds-accent-primary)]" : "bg-[var(--ds-bg-muted)]",
2118
- error ? "border-[var(--ds-status-error)]" : checked ? "border-transparent" : "border-[var(--ds-border-default)]"
2119
- ),
2120
- style: { width: 44, height: 24 },
2121
- children: /* @__PURE__ */ jsx(
2122
- "span",
2123
- {
2124
- className: cn(
2125
- "pointer-events-none inline-block shrink-0",
2126
- "bg-[var(--ds-bg-surface)]",
2127
- "border-[length:var(--ds-border-width)] border-transparent",
2128
- "rounded-[var(--ds-radius-full)]",
2129
- "transition-transform"
2130
- ),
2131
- style: {
2132
- width: 16,
2133
- height: 16,
2134
- transform: checked ? "translateX(calc(25px - var(--ds-border-width)))" : "translateX(calc(1px + var(--ds-border-width)))"
2135
- }
2096
+ function Toggle({ checked, onChange, label, disabled, error = false, layout = "full", "aria-labelledby": ariaLabelledBy, ...rest }) {
2097
+ const switchButton = /* @__PURE__ */ jsx(
2098
+ "button",
2099
+ {
2100
+ role: "switch",
2101
+ "aria-checked": checked,
2102
+ "aria-label": !label && !ariaLabelledBy ? "Toggle" : void 0,
2103
+ "aria-labelledby": ariaLabelledBy,
2104
+ "aria-invalid": error || void 0,
2105
+ disabled,
2106
+ onClick: () => !disabled && onChange(!checked),
2107
+ ...rest,
2108
+ className: cn(
2109
+ "relative inline-flex shrink-0 items-center overflow-hidden",
2110
+ "border-[length:var(--ds-border-width)]",
2111
+ "rounded-[var(--ds-radius-full)]",
2112
+ "transition-colors duration-[var(--ds-transition-speed)]",
2113
+ "focus-visible:outline-none focus-visible:shadow-[var(--ds-shadow-focus)]",
2114
+ disabled ? "cursor-not-allowed" : "cursor-pointer",
2115
+ checked ? "bg-[var(--ds-accent-primary)]" : "bg-[var(--ds-bg-muted)]",
2116
+ error ? "border-[var(--ds-status-error)]" : checked ? "border-transparent" : "border-[var(--ds-border-default)]"
2117
+ ),
2118
+ style: { width: 44, height: 24 },
2119
+ children: /* @__PURE__ */ jsx(
2120
+ "span",
2121
+ {
2122
+ className: cn(
2123
+ "pointer-events-none inline-block shrink-0",
2124
+ "bg-[var(--ds-bg-surface)]",
2125
+ "border-[length:var(--ds-border-width)] border-transparent",
2126
+ "rounded-[var(--ds-radius-full)]",
2127
+ "transition-transform"
2128
+ ),
2129
+ style: {
2130
+ width: 16,
2131
+ height: 16,
2132
+ transform: checked ? "translateX(calc(25px - var(--ds-border-width)))" : "translateX(calc(1px + var(--ds-border-width)))"
2136
2133
  }
2137
- )
2138
- }
2139
- )
2140
- ] });
2134
+ }
2135
+ )
2136
+ }
2137
+ );
2138
+ if (!label) {
2139
+ return /* @__PURE__ */ jsx("div", { className: cn(disabled && "opacity-disabled"), children: switchButton });
2140
+ }
2141
+ return /* @__PURE__ */ jsxs(
2142
+ "label",
2143
+ {
2144
+ className: cn(
2145
+ layout === "full" ? "flex items-center justify-between gap-ds-4" : "inline-flex items-center gap-ds-3",
2146
+ disabled ? "cursor-not-allowed opacity-disabled" : "cursor-pointer"
2147
+ ),
2148
+ children: [
2149
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-[var(--ds-text-primary)]", children: label }),
2150
+ switchButton
2151
+ ]
2152
+ }
2153
+ );
2141
2154
  }
2142
2155
  function Dropdown({
2143
2156
  options,
@@ -2156,6 +2169,7 @@ function Dropdown({
2156
2169
  }) {
2157
2170
  const [open, setOpen] = useState(false);
2158
2171
  const [search, setSearch] = useState("");
2172
+ const [positioned, setPositioned] = useState(false);
2159
2173
  const triggerRef = useRef(null);
2160
2174
  const menuRef = useRef(null);
2161
2175
  const searchRef = useRef(null);
@@ -2181,12 +2195,16 @@ function Dropdown({
2181
2195
  setPos({ top, left, width });
2182
2196
  }, []);
2183
2197
  useEffect(() => {
2184
- if (!open) return;
2198
+ if (!open) {
2199
+ setPositioned(false);
2200
+ return;
2201
+ }
2185
2202
  updatePos();
2186
2203
  setSearch("");
2187
2204
  requestAnimationFrame(() => {
2188
2205
  searchRef.current?.focus();
2189
2206
  updatePos();
2207
+ setPositioned(true);
2190
2208
  });
2191
2209
  const onScroll = () => updatePos();
2192
2210
  window.addEventListener("scroll", onScroll, true);
@@ -2267,7 +2285,7 @@ function Dropdown({
2267
2285
  "rounded-[var(--ds-radius-md)] overflow-hidden",
2268
2286
  "shadow-[var(--ds-shadow-dropdown),var(--ds-glass-inset)]"
2269
2287
  ),
2270
- style: { top: pos.top, left: pos.left, minWidth: pos.width, width: "max-content", maxWidth: "calc(100vw - 16px)" },
2288
+ style: { top: pos.top, left: pos.left, minWidth: pos.width, width: "max-content", maxWidth: "calc(100vw - 16px)", visibility: positioned ? "visible" : "hidden" },
2271
2289
  children: [
2272
2290
  searchable && /* @__PURE__ */ jsx("div", { className: "border-b-[length:var(--ds-border-width)] border-[var(--ds-border-subtle)]", style: { padding: "var(--ds-space-2)" }, children: /* @__PURE__ */ jsx(
2273
2291
  "input",
@@ -2581,7 +2599,7 @@ function Checkbox({ checked, onChange, label, disabled = false, indeterminate =
2581
2599
  "border-[2px]",
2582
2600
  "transition-all",
2583
2601
  "peer-focus-visible:shadow-[var(--ds-shadow-focus)]",
2584
- filled ? "bg-[var(--ds-check-bg)] border-[var(--ds-check-border)]" : "bg-[var(--ds-input-bg)] border-[var(--ds-input-border)]",
2602
+ filled ? "bg-[var(--ds-check-bg)] [background-image:var(--ds-gradient)] border-[var(--ds-check-border)]" : "bg-[var(--ds-input-bg)] border-[var(--ds-input-border)]",
2585
2603
  disabled && "pointer-events-none"
2586
2604
  ),
2587
2605
  children: /* @__PURE__ */ jsx(
@@ -2695,7 +2713,7 @@ function RadioGroup({ value, onChange, options, orientation = "vertical", classN
2695
2713
  selected && "border-[var(--ds-check-border)]",
2696
2714
  "focus-visible:shadow-[var(--ds-shadow-focus)]"
2697
2715
  ),
2698
- children: selected && /* @__PURE__ */ jsx("span", { className: "h-2.5 w-2.5 rounded-full bg-[var(--ds-accent-primary)]" })
2716
+ children: selected && /* @__PURE__ */ jsx("span", { className: "h-2.5 w-2.5 rounded-full bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)]" })
2699
2717
  }
2700
2718
  ),
2701
2719
  /* @__PURE__ */ jsx("span", { className: "text-sm text-[var(--ds-text-primary)]", children: option.label })
@@ -3131,7 +3149,7 @@ function SliderRange({
3131
3149
  /* @__PURE__ */ jsx(
3132
3150
  "div",
3133
3151
  {
3134
- className: "absolute h-1.5 rounded-[var(--ds-radius-full)] bg-[var(--ds-accent-primary)]",
3152
+ className: "absolute h-1.5 rounded-[var(--ds-radius-full)] bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)]",
3135
3153
  style: {
3136
3154
  left: `${isRange ? pct(low) : 0}%`,
3137
3155
  width: `${isRange ? pct(high) - pct(low) : pct(low)}%`
@@ -83140,7 +83158,7 @@ function MonthView({
83140
83158
  {
83141
83159
  className: cn(
83142
83160
  "text-xs w-6 h-6 flex items-center justify-center rounded-full",
83143
- today ? "bg-[var(--ds-accent-primary)] text-[var(--ds-text-on-primary)] font-bold" : "text-[var(--ds-text-secondary)]"
83161
+ today ? "bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)] text-[var(--ds-text-on-primary)] font-bold" : "text-[var(--ds-text-secondary)]"
83144
83162
  ),
83145
83163
  children: day.getDate()
83146
83164
  }
@@ -93809,7 +93827,7 @@ function Pagination({ currentPage, totalPages, onPageChange, pageSize, pageSizeO
93809
93827
  "rounded-[var(--ds-radius-md)]",
93810
93828
  "border-[length:var(--ds-border-width)]",
93811
93829
  "transition-colors duration-[var(--ds-transition-speed)]",
93812
- p === currentPage ? "bg-[var(--ds-accent-primary)] text-[var(--ds-text-on-primary)] border-[var(--ds-accent-primary)]" : "bg-[var(--ds-bg-surface)] text-[var(--ds-text-secondary)] border-[var(--ds-border-default)] hover:bg-[var(--ds-bg-muted)] hover:text-[var(--ds-text-primary)]"
93830
+ p === currentPage ? "bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)] text-[var(--ds-text-on-primary)] border-[var(--ds-accent-primary)]" : "bg-[var(--ds-bg-surface)] text-[var(--ds-text-secondary)] border-[var(--ds-border-default)] hover:bg-[var(--ds-bg-muted)] hover:text-[var(--ds-text-primary)]"
93813
93831
  ),
93814
93832
  children: p
93815
93833
  },
@@ -93943,7 +93961,7 @@ function StepCircle({ status, index, onClick, clickable }) {
93943
93961
  "focus-visible:outline-none focus-visible:shadow-[var(--ds-shadow-focus)]",
93944
93962
  clickable && "cursor-pointer",
93945
93963
  !clickable && "cursor-default",
93946
- status === "complete" && "bg-[var(--ds-accent-primary)] text-[var(--ds-text-on-primary)]",
93964
+ status === "complete" && "bg-[var(--ds-accent-primary)] [background-image:var(--ds-gradient)] text-[var(--ds-text-on-primary)]",
93947
93965
  status === "current" && "border-2 border-[var(--ds-accent-primary)] text-[var(--ds-accent-primary)] bg-[var(--ds-bg-surface)]",
93948
93966
  status === "error" && "bg-[var(--ds-status-error)] text-[var(--ds-text-on-primary)]",
93949
93967
  status === "loading" && "border-2 border-[var(--ds-accent-primary)] text-[var(--ds-accent-primary)] bg-[var(--ds-bg-surface)] animate-pulse",
@@ -95047,7 +95065,7 @@ var borderByPosition = {
95047
95065
  left: "border-r-[length:var(--ds-border-width)] border-r-[var(--ds-border-default)]",
95048
95066
  bottom: "border-t-[length:var(--ds-border-width)] border-t-[var(--ds-border-default)]"
95049
95067
  };
95050
- function Drawer({ open, onClose, position = "right", width = "400px", title, children, footer, container, flush, lightBackdrop }) {
95068
+ function Drawer({ open, onClose, position = "right", width = "400px", title, children, footer, container, flush, lightBackdrop, topOffset }) {
95051
95069
  const titleId = useId();
95052
95070
  const isMobile = useBreakpoint("sm");
95053
95071
  const panelRef = useRef(null);
@@ -95083,9 +95101,11 @@ function Drawer({ open, onClose, position = "right", width = "400px", title, chi
95083
95101
  "div",
95084
95102
  {
95085
95103
  className: cn(
95086
- `${positionClass} inset-0 z-50 transition-opacity duration-[var(--ds-transition-speed)]`,
95104
+ `${positionClass} z-50 transition-opacity duration-[var(--ds-transition-speed)]`,
95105
+ topOffset ? "left-0 right-0 bottom-0" : "inset-0",
95087
95106
  open ? "pointer-events-auto" : "pointer-events-none"
95088
95107
  ),
95108
+ style: topOffset ? { top: topOffset } : void 0,
95089
95109
  onTransitionEnd: handleTransitionEnd,
95090
95110
  children: [
95091
95111
  /* @__PURE__ */ jsx(
@@ -95237,6 +95257,7 @@ var AppShell = forwardRef(function AppShell2({
95237
95257
  container: shellRef.current ?? void 0,
95238
95258
  flush: mobileMenuFlush,
95239
95259
  lightBackdrop: mobileMenuLightBackdrop,
95260
+ topOffset: layout !== "stacked" && navbar != null ? "var(--ds-navbar-height)" : void 0,
95240
95261
  children: mobileMenu
95241
95262
  }
95242
95263
  ),
@@ -95297,12 +95318,13 @@ function getTypeClasses(type, active) {
95297
95318
  );
95298
95319
  }
95299
95320
  }
95300
- function HamburgerButton({ onClick, className: cls }) {
95321
+ function HamburgerButton({ onClick, open, className: cls }) {
95301
95322
  return /* @__PURE__ */ jsx(
95302
95323
  "button",
95303
95324
  {
95304
95325
  onClick,
95305
- "aria-label": "Toggle navigation menu",
95326
+ "aria-label": open ? "Close navigation menu" : "Open navigation menu",
95327
+ "aria-expanded": open ?? void 0,
95306
95328
  className: cn(
95307
95329
  "flex items-center justify-center shrink-0",
95308
95330
  "w-10 h-10 rounded-[var(--ds-radius-md)]",
@@ -95312,7 +95334,7 @@ function HamburgerButton({ onClick, className: cls }) {
95312
95334
  "cursor-pointer",
95313
95335
  cls
95314
95336
  ),
95315
- children: /* @__PURE__ */ jsx(Icon, { name: "menu", size: 20 })
95337
+ children: /* @__PURE__ */ jsx(Icon, { name: open ? "close" : "menu", size: 20 })
95316
95338
  }
95317
95339
  );
95318
95340
  }
@@ -95360,7 +95382,7 @@ var Navbar = forwardRef(function Navbar2({
95360
95382
  style: { padding: padStyle, gap: "var(--ds-space-4)" },
95361
95383
  children: [
95362
95384
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-ds-4", children: [
95363
- showHamburger && /* @__PURE__ */ jsx(HamburgerButton, { onClick: handleHamburger }),
95385
+ showHamburger && /* @__PURE__ */ jsx(HamburgerButton, { onClick: handleHamburger, open: appShell?.sidebarOpen }),
95364
95386
  logo && /* @__PURE__ */ jsx("div", { className: "flex items-center shrink-0", children: logo })
95365
95387
  ] }),
95366
95388
  navLinks && !hideNavLinks ? /* @__PURE__ */ jsx(NavbarTypeContext.Provider, { value: type, children: /* @__PURE__ */ jsx("nav", { className: "flex items-center gap-ds-1 min-w-0 overflow-x-clip justify-center", "data-navbar-type": type, children: navLinks }) }) : /* @__PURE__ */ jsx("div", {}),
@@ -95386,7 +95408,7 @@ var Navbar = forwardRef(function Navbar2({
95386
95408
  ),
95387
95409
  style: { padding: padStyle, gap: "var(--ds-space-4)" },
95388
95410
  children: [
95389
- showHamburger && /* @__PURE__ */ jsx(HamburgerButton, { onClick: handleHamburger }),
95411
+ showHamburger && /* @__PURE__ */ jsx(HamburgerButton, { onClick: handleHamburger, open: appShell?.sidebarOpen }),
95390
95412
  logo && /* @__PURE__ */ jsx("div", { className: "flex items-center shrink-0", children: logo }),
95391
95413
  align === "right" && /* @__PURE__ */ jsx("div", { className: "flex-1" }),
95392
95414
  navLinks && !hideNavLinks && /* @__PURE__ */ jsx(NavbarTypeContext.Provider, { value: type, children: /* @__PURE__ */ jsx("nav", { className: cn("flex items-center gap-ds-1 min-w-0 overflow-x-clip", align === "left" && "flex-1"), "data-navbar-type": type, children: navLinks }) }),
@@ -96902,7 +96924,7 @@ var positionClasses = {
96902
96924
  "top-center": "top-ds-4 left-1/2 -translate-x-1/2",
96903
96925
  "bottom-center": "bottom-ds-4 left-1/2 -translate-x-1/2"
96904
96926
  };
96905
- function Toast({ variant = "default", message, visible, onDismiss, duration = 3e3, pauseOnHover = false, action, position = "bottom-right", container }) {
96927
+ function Toast({ variant = "default", message, visible, onDismiss, duration = 3e3, pauseOnHover = false, action, position = "bottom-right", mode, container }) {
96906
96928
  const isMobile = useBreakpoint("sm");
96907
96929
  const isCentered = position === "top-center" || position === "bottom-center";
96908
96930
  const timerRef = useRef(void 0);
@@ -96944,6 +96966,7 @@ function Toast({ variant = "default", message, visible, onDismiss, duration = 3e
96944
96966
  {
96945
96967
  role: "status",
96946
96968
  "aria-live": "polite",
96969
+ "data-mode": mode,
96947
96970
  onMouseEnter: handleMouseEnter,
96948
96971
  onMouseLeave: handleMouseLeave2,
96949
96972
  className: cn(