@gryt/ui 0.16.0 → 0.17.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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as o, jsxs as d } from "react/jsx-runtime";
2
2
  import { Tooltip as I } from "@base-ui/react/tooltip";
3
3
  import { createGrytTheme as bt } from "@gryt/theme";
4
- import { GRYT_HUE_KEYS as ca, GRYT_NEUTRAL_KEYS as la, GRYT_RADIUS_KEYS as da, GRYT_THEME_NAME_MAX as ga, alphaScale as ua, cloneGrytTheme as ya, contrast as pa, createGrytTheme as ma, decodeGrytTheme as ba, encodeGrytTheme as fa, grytAlphaScales as xa, grytAlphaScalesLight as ha, grytLightTokens as wa, grytPresets as va, grytPresetsById as Na, grytScales as Pa, grytScalesLight as Ta, grytTheme as ka, grytThemeHues as Ca, grytThemeToOptions as Sa, grytTokens as $a, hexToOklch as Ra, hexToRgb as Ia, hueScale as Aa, hueScaleLight as Da, isHexColor as Ma, neutralScale as Ga, neutralScaleLight as La, normalizeHexColor as ja, normalizeThemeName as Ba, oklchToHex as za, rgbToHex as Fa } from "@gryt/theme";
4
+ import { GRYT_HUE_KEYS as ca, GRYT_NEUTRAL_KEYS as la, GRYT_RADIUS_KEYS as da, GRYT_THEME_NAME_MAX as ga, alphaScale as ua, cloneGrytTheme as ya, contrast as ma, createGrytTheme as pa, decodeGrytTheme as ba, encodeGrytTheme as fa, grytAlphaScales as xa, grytAlphaScalesLight as ha, grytLightTokens as wa, grytPresets as va, grytPresetsById as Na, grytScales as Pa, grytScalesLight as Ta, grytTheme as ka, grytThemeHues as Ca, grytThemeToOptions as Sa, grytTokens as $a, hexToOklch as Ra, hexToRgb as Ia, hueScale as Aa, hueScaleLight as Da, isHexColor as Ma, neutralScale as Ga, neutralScaleLight as La, normalizeHexColor as ja, normalizeThemeName as Ba, oklchToHex as za, rgbToHex as Fa } from "@gryt/theme";
5
5
  import { Button as nt } from "@base-ui/react/button";
6
6
  import { forwardRef as s, useRef as it, useCallback as U, useLayoutEffect as ft, useState as xt, useEffect as ht, useSyncExternalStore as wt, useContext as K, createContext as vt } from "react";
7
7
  import { clsx as Nt } from "clsx";
@@ -30,7 +30,7 @@ import { Toggle as Dt } from "@base-ui/react/toggle";
30
30
  import { ToggleGroup as Mt } from "@base-ui/react/toggle-group";
31
31
  import { Meter as z } from "@base-ui/react/meter";
32
32
  import { AlertDialog as S } from "@base-ui/react/alert-dialog";
33
- import { Autocomplete as m } from "@base-ui/react/autocomplete";
33
+ import { Autocomplete as p } from "@base-ui/react/autocomplete";
34
34
  import { Combobox as g } from "@base-ui/react/combobox";
35
35
  import { CheckboxGroup as Gt } from "@base-ui/react/checkbox-group";
36
36
  import { Collapsible as W } from "@base-ui/react/collapsible";
@@ -58,10 +58,10 @@ function n(...a) {
58
58
  return Pt(Nt(a));
59
59
  }
60
60
  const zt = {
61
- primary: "bg-gryt-accent text-gryt-on-accent hover:not-data-disabled:bg-gryt-accent-light",
62
- secondary: "bg-gryt-secondary text-gryt-on-secondary hover:not-data-disabled:bg-gryt-secondary-light",
63
- neutral: "bg-gryt-surface-raised text-gryt-text hover:not-data-disabled:bg-gryt-surface-hover",
64
- danger: "bg-gryt-danger text-gryt-on-danger hover:not-data-disabled:bg-gryt-danger-light",
61
+ primary: "bg-gryt-accent text-gryt-on-accent hover:not-data-disabled:bg-gryt-accent-light data-disabled:bg-gryt-surface-raised data-disabled:text-gryt-muted",
62
+ secondary: "bg-gryt-secondary text-gryt-on-secondary hover:not-data-disabled:bg-gryt-secondary-light data-disabled:bg-gryt-surface-raised data-disabled:text-gryt-muted",
63
+ neutral: "bg-gryt-surface-raised text-gryt-text hover:not-data-disabled:bg-gryt-surface-hover data-disabled:text-gryt-muted",
64
+ danger: "bg-gryt-danger text-gryt-on-danger hover:not-data-disabled:bg-gryt-danger-light data-disabled:bg-gryt-surface-raised data-disabled:text-gryt-muted",
65
65
  ghost: "bg-transparent text-gryt-muted hover:not-data-disabled:bg-white/8 hover:not-data-disabled:text-gryt-text"
66
66
  }, Ft = {
67
67
  xsmall: "min-h-8 px-3 text-xs",
@@ -76,7 +76,7 @@ const zt = {
76
76
  size: i = "medium",
77
77
  startIcon: c,
78
78
  tone: l = "primary",
79
- ...p
79
+ ...m
80
80
  }, u) {
81
81
  return /* @__PURE__ */ d(
82
82
  nt,
@@ -102,12 +102,17 @@ const zt = {
102
102
  "motion-safe:not-[[aria-haspopup]]:hover:not-data-disabled:scale-[1.03]",
103
103
  "motion-safe:not-[[aria-haspopup]]:active:not-data-disabled:scale-[0.96]",
104
104
  "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gryt-accent-light",
105
- "data-disabled:cursor-not-allowed data-disabled:opacity-50",
105
+ // Lighter than it was, because the fill swap above is doing the work
106
+ // now. It is kept because `startIcon` and `endIcon` are the caller's
107
+ // elements with the caller's colours — nothing here can mute those,
108
+ // and an icon at full strength on a dead button is the same lie in
109
+ // miniature.
110
+ "data-disabled:cursor-not-allowed data-disabled:opacity-60",
106
111
  Ft[i],
107
112
  zt[l],
108
113
  e
109
114
  ),
110
- ...p,
115
+ ...m,
111
116
  children: [
112
117
  c,
113
118
  t,
@@ -242,7 +247,7 @@ const zt = {
242
247
  helperText: i,
243
248
  label: c,
244
249
  minRows: l = 3,
245
- multiline: p = !1,
250
+ multiline: m = !1,
246
251
  size: u = "medium",
247
252
  ...w
248
253
  }, y) {
@@ -250,11 +255,11 @@ const zt = {
250
255
  V.Control,
251
256
  {
252
257
  ref: y,
253
- render: p ? /* @__PURE__ */ o("textarea", { rows: l }) : void 0,
258
+ render: m ? /* @__PURE__ */ o("textarea", { rows: l }) : void 0,
254
259
  className: n(
255
260
  "gryt-text-field-control",
256
261
  dt,
257
- p && "resize-y leading-6",
262
+ m && "resize-y leading-6",
258
263
  e ? "border-gryt-danger" : "border-gryt-border",
259
264
  gt[u],
260
265
  t
@@ -286,7 +291,7 @@ const zt = {
286
291
  }
287
292
  );
288
293
  }
289
- ), po = s(
294
+ ), mo = s(
290
295
  function({
291
296
  className: t,
292
297
  disabled: e = !1,
@@ -294,7 +299,7 @@ const zt = {
294
299
  minRows: i = 1,
295
300
  onSubmit: c,
296
301
  placeholder: l = "Message Gryt",
297
- submitLabel: p = "Send",
302
+ submitLabel: m = "Send",
298
303
  ...u
299
304
  }, w) {
300
305
  const y = it(null), N = U(() => {
@@ -337,7 +342,7 @@ const zt = {
337
342
  disabled: e,
338
343
  size: "small",
339
344
  endIcon: /* @__PURE__ */ o(Tt, { size: 14, weight: "fill" }),
340
- children: p
345
+ children: m
341
346
  }
342
347
  )
343
348
  ] });
@@ -346,7 +351,7 @@ const zt = {
346
351
  small: "h-8 w-8 text-xs",
347
352
  medium: "h-10 w-10 text-sm",
348
353
  large: "h-12 w-12 text-base"
349
- }, Kt = s(function({ alt: t, children: e, className: r, fallback: i, size: c = "medium", src: l, ...p }, u) {
354
+ }, Kt = s(function({ alt: t, children: e, className: r, fallback: i, size: c = "medium", src: l, ...m }, u) {
350
355
  return /* @__PURE__ */ d(
351
356
  H.Root,
352
357
  {
@@ -357,7 +362,7 @@ const zt = {
357
362
  Ut[c],
358
363
  r
359
364
  ),
360
- ...p,
365
+ ...m,
361
366
  children: [
362
367
  l ? /* @__PURE__ */ o(
363
368
  H.Image,
@@ -371,11 +376,11 @@ const zt = {
371
376
  ]
372
377
  }
373
378
  );
374
- }), mo = s(function({ active: t = !1, avatar: e, className: r, subtitle: i, title: c, ...l }, p) {
379
+ }), po = s(function({ active: t = !1, avatar: e, className: r, subtitle: i, title: c, ...l }, m) {
375
380
  return /* @__PURE__ */ d(
376
381
  "button",
377
382
  {
378
- ref: p,
383
+ ref: m,
379
384
  type: "button",
380
385
  className: n(
381
386
  "gryt-conversation-item enabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
@@ -410,12 +415,12 @@ const zt = {
410
415
  ]
411
416
  }
412
417
  );
413
- }), bo = s(function({ badgeContent: t, children: e, className: r, max: i = 99, showZero: c = !1, ...l }, p) {
418
+ }), bo = s(function({ badgeContent: t, children: e, className: r, max: i = 99, showZero: c = !1, ...l }, m) {
414
419
  const u = typeof t == "number" ? t : null, w = u !== null && u === 0 && !c, y = u !== null && u > i ? `${i}+` : t;
415
420
  return /* @__PURE__ */ d(
416
421
  "span",
417
422
  {
418
- ref: p,
423
+ ref: m,
419
424
  className: n("gryt-badge relative inline-flex", r),
420
425
  ...l,
421
426
  children: [
@@ -442,7 +447,7 @@ const zt = {
442
447
  success: "border-gryt-success-6 bg-gryt-success-3 text-gryt-success-11",
443
448
  warning: "border-gryt-warning-6 bg-gryt-warning-3 text-gryt-warning-11",
444
449
  danger: "border-gryt-danger-6 bg-gryt-danger-3 text-gryt-danger-11"
445
- }, fo = s(function({ children: t, className: e, icon: r, label: i, onDelete: c, tone: l = "neutral", ...p }, u) {
450
+ }, fo = s(function({ children: t, className: e, icon: r, label: i, onDelete: c, tone: l = "neutral", ...m }, u) {
446
451
  return /* @__PURE__ */ d(
447
452
  "span",
448
453
  {
@@ -452,7 +457,7 @@ const zt = {
452
457
  Wt[l],
453
458
  e
454
459
  ),
455
- ...p,
460
+ ...m,
456
461
  children: [
457
462
  r,
458
463
  i ?? t,
@@ -613,7 +618,7 @@ function No({
613
618
  window.removeEventListener("pointerup", y), window.removeEventListener("pointercancel", y);
614
619
  };
615
620
  }, [i]);
616
- function p(y) {
621
+ function m(y) {
617
622
  l.current = { x: y.clientX, y: y.clientY };
618
623
  }
619
624
  function u(y) {
@@ -627,7 +632,7 @@ function No({
627
632
  B.Control,
628
633
  {
629
634
  className: "flex w-full cursor-pointer touch-none items-center py-2 select-none",
630
- onPointerDown: p,
635
+ onPointerDown: m,
631
636
  onPointerMove: u,
632
637
  children: /* @__PURE__ */ d(B.Track, { className: "h-1.5 w-full rounded-(--gryt-radius-full) bg-gryt-surface-raised select-none", children: [
633
638
  /* @__PURE__ */ o(
@@ -1168,7 +1173,7 @@ const ge = s(
1168
1173
  }
1169
1174
  );
1170
1175
  });
1171
- function pe({ className: a }) {
1176
+ function me({ className: a }) {
1172
1177
  const t = K(_);
1173
1178
  return t !== "bottom" && t !== "top" ? null : /* @__PURE__ */ o(
1174
1179
  "div",
@@ -1190,11 +1195,11 @@ const jo = {
1190
1195
  Viewport: ge,
1191
1196
  Popup: ue,
1192
1197
  Content: v.Content,
1193
- Grabber: pe,
1198
+ Grabber: me,
1194
1199
  Close: v.Close,
1195
1200
  Title: v.Title,
1196
1201
  Description: v.Description
1197
- }, me = s(
1202
+ }, pe = s(
1198
1203
  function({ className: t, sideOffset: e = 8, ...r }, i) {
1199
1204
  return /* @__PURE__ */ o(
1200
1205
  A.Positioner,
@@ -1250,7 +1255,7 @@ const jo = {
1250
1255
  Root: A.Root,
1251
1256
  Trigger: A.Trigger,
1252
1257
  Portal: A.Portal,
1253
- Positioner: me,
1258
+ Positioner: pe,
1254
1259
  Popup: be,
1255
1260
  Item: fe,
1256
1261
  Separator: xe
@@ -1852,7 +1857,7 @@ const Xe = s(
1852
1857
  Title: Ke,
1853
1858
  Description: We,
1854
1859
  Close: S.Close
1855
- }, pt = [
1860
+ }, mt = [
1856
1861
  "flex cursor-default items-center gap-2 rounded-(--gryt-radius-md)",
1857
1862
  "px-3 py-2 text-sm text-gryt-text outline-none select-none",
1858
1863
  // Base UI drives keyboard and pointer highlight through one attribute, so
@@ -1860,7 +1865,7 @@ const Xe = s(
1860
1865
  "data-highlighted:bg-gryt-surface-raised",
1861
1866
  "data-selected:text-gryt-accent-11",
1862
1867
  "data-disabled:cursor-not-allowed data-disabled:opacity-50"
1863
- ].join(" "), mt = [
1868
+ ].join(" "), pt = [
1864
1869
  dt,
1865
1870
  gt.medium,
1866
1871
  "border-gryt-border",
@@ -1870,7 +1875,7 @@ const Xe = s(
1870
1875
  g.Input,
1871
1876
  {
1872
1877
  ref: r,
1873
- className: n("gryt-combobox-input", mt, t),
1878
+ className: n("gryt-combobox-input", pt, t),
1874
1879
  ...e
1875
1880
  }
1876
1881
  );
@@ -1905,7 +1910,7 @@ const Xe = s(
1905
1910
  g.Item,
1906
1911
  {
1907
1912
  ref: r,
1908
- className: n("gryt-combobox-item", pt, t),
1913
+ className: n("gryt-combobox-item", mt, t),
1909
1914
  ...e
1910
1915
  }
1911
1916
  );
@@ -1944,16 +1949,16 @@ const Xe = s(
1944
1949
  Separator: g.Separator
1945
1950
  }, er = s(function({ className: t, ...e }, r) {
1946
1951
  return /* @__PURE__ */ o(
1947
- m.Input,
1952
+ p.Input,
1948
1953
  {
1949
1954
  ref: r,
1950
- className: n("gryt-autocomplete-input", mt, t),
1955
+ className: n("gryt-autocomplete-input", pt, t),
1951
1956
  ...e
1952
1957
  }
1953
1958
  );
1954
1959
  }), rr = s(function({ className: t, sideOffset: e = 6, ...r }, i) {
1955
1960
  return /* @__PURE__ */ o(
1956
- m.Positioner,
1961
+ p.Positioner,
1957
1962
  {
1958
1963
  ref: i,
1959
1964
  sideOffset: e,
@@ -1963,7 +1968,7 @@ const Xe = s(
1963
1968
  );
1964
1969
  }), or = s(function({ className: t, ...e }, r) {
1965
1970
  return /* @__PURE__ */ o(
1966
- m.Popup,
1971
+ p.Popup,
1967
1972
  {
1968
1973
  ref: r,
1969
1974
  className: n(
@@ -1977,16 +1982,16 @@ const Xe = s(
1977
1982
  );
1978
1983
  }), ar = s(function({ className: t, ...e }, r) {
1979
1984
  return /* @__PURE__ */ o(
1980
- m.Item,
1985
+ p.Item,
1981
1986
  {
1982
1987
  ref: r,
1983
- className: n("gryt-autocomplete-item", pt, t),
1988
+ className: n("gryt-autocomplete-item", mt, t),
1984
1989
  ...e
1985
1990
  }
1986
1991
  );
1987
1992
  }), nr = s(function({ className: t, ...e }, r) {
1988
1993
  return /* @__PURE__ */ o(
1989
- m.Empty,
1994
+ p.Empty,
1990
1995
  {
1991
1996
  ref: r,
1992
1997
  className: n(
@@ -1997,22 +2002,22 @@ const Xe = s(
1997
2002
  }
1998
2003
  );
1999
2004
  }), Wo = {
2000
- Root: m.Root,
2005
+ Root: p.Root,
2001
2006
  Input: er,
2002
- InputGroup: m.InputGroup,
2003
- Trigger: m.Trigger,
2004
- Icon: m.Icon,
2005
- Clear: m.Clear,
2006
- Value: m.Value,
2007
- Portal: m.Portal,
2007
+ InputGroup: p.InputGroup,
2008
+ Trigger: p.Trigger,
2009
+ Icon: p.Icon,
2010
+ Clear: p.Clear,
2011
+ Value: p.Value,
2012
+ Portal: p.Portal,
2008
2013
  Positioner: rr,
2009
2014
  Popup: or,
2010
- List: m.List,
2015
+ List: p.List,
2011
2016
  Item: ar,
2012
- Group: m.Group,
2013
- GroupLabel: m.GroupLabel,
2017
+ Group: p.Group,
2018
+ GroupLabel: p.GroupLabel,
2014
2019
  Empty: nr,
2015
- Separator: m.Separator
2020
+ Separator: p.Separator
2016
2021
  }, Qo = s(
2017
2022
  function({ className: t, ...e }, r) {
2018
2023
  return /* @__PURE__ */ o(
@@ -2166,7 +2171,7 @@ const Xe = s(
2166
2171
  ...e
2167
2172
  }
2168
2173
  );
2169
- }), pr = s(function({ className: t, ...e }, r) {
2174
+ }), mr = s(function({ className: t, ...e }, r) {
2170
2175
  return /* @__PURE__ */ o(
2171
2176
  h.Link,
2172
2177
  {
@@ -2191,7 +2196,7 @@ const Xe = s(
2191
2196
  Positioner: ur,
2192
2197
  Viewport: yr,
2193
2198
  Popup: gr,
2194
- Link: pr,
2199
+ Link: mr,
2195
2200
  Icon: h.Icon,
2196
2201
  Arrow: h.Arrow
2197
2202
  }, at = "flex h-9 w-9 shrink-0 items-center justify-center border-0 bg-transparent text-gryt-muted transition-colors hover:not-data-disabled:bg-white/8 hover:not-data-disabled:text-gryt-text motion-reduce:transition-none disabled:cursor-not-allowed disabled:opacity-50", ra = s(
@@ -2276,7 +2281,7 @@ const Xe = s(
2276
2281
  }
2277
2282
  );
2278
2283
  }
2279
- ), mr = s(
2284
+ ), pr = s(
2280
2285
  function({ className: t, sideOffset: e = 8, ...r }, i) {
2281
2286
  return /* @__PURE__ */ o(
2282
2287
  M.Positioner,
@@ -2308,7 +2313,7 @@ const Xe = s(
2308
2313
  Root: M.Root,
2309
2314
  Trigger: M.Trigger,
2310
2315
  Portal: M.Portal,
2311
- Positioner: mr,
2316
+ Positioner: pr,
2312
2317
  Popup: br,
2313
2318
  Arrow: M.Arrow
2314
2319
  }, fr = s(function({ className: t, ...e }, r) {
@@ -2358,9 +2363,9 @@ export {
2358
2363
  fo as Chip,
2359
2364
  Jo as Collapsible,
2360
2365
  Ko as Combobox,
2361
- po as Composer,
2366
+ mo as Composer,
2362
2367
  Fo as ContextMenu,
2363
- mo as ConversationItem,
2368
+ po as ConversationItem,
2364
2369
  Lo as Dialog,
2365
2370
  Co as Divider,
2366
2371
  jo as Drawer,
@@ -2403,8 +2408,8 @@ export {
2403
2408
  ua as alphaScale,
2404
2409
  ya as cloneGrytTheme,
2405
2410
  n as cn,
2406
- pa as contrast,
2407
- ma as createGrytTheme,
2411
+ ma as contrast,
2412
+ pa as createGrytTheme,
2408
2413
  ba as decodeGrytTheme,
2409
2414
  fa as encodeGrytTheme,
2410
2415
  xa as grytAlphaScales,