@rinzai/zen 0.8.6 → 0.10.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.
Files changed (168) hide show
  1. package/dist/animated-number/index.d.ts +6 -2
  2. package/dist/animated-number/index.d.ts.map +1 -1
  3. package/dist/animated-number/index.js +69 -17
  4. package/dist/breadcrumbs/index.d.ts +15 -0
  5. package/dist/breadcrumbs/index.d.ts.map +1 -0
  6. package/dist/breadcrumbs/index.js +39 -0
  7. package/dist/calendar-heatmap/index.d.ts +25 -0
  8. package/dist/calendar-heatmap/index.d.ts.map +1 -0
  9. package/dist/calendar-heatmap/index.js +48 -0
  10. package/dist/card/index.d.ts +3 -1
  11. package/dist/card/index.d.ts.map +1 -1
  12. package/dist/card/index.js +3 -2
  13. package/dist/chart/allocation.d.ts +30 -0
  14. package/dist/chart/allocation.d.ts.map +1 -0
  15. package/dist/chart/allocation.js +69 -0
  16. package/dist/chart/donut.d.ts.map +1 -1
  17. package/dist/chart/donut.js +72 -70
  18. package/dist/chart/index.d.ts +1 -0
  19. package/dist/chart/index.d.ts.map +1 -1
  20. package/dist/chart/index.js +182 -178
  21. package/dist/code-block/index.d.ts +1 -1
  22. package/dist/code-block/index.d.ts.map +1 -1
  23. package/dist/code-block/index.js +31 -22
  24. package/dist/code-input/index.d.ts +20 -0
  25. package/dist/code-input/index.d.ts.map +1 -0
  26. package/dist/code-input/index.js +44 -0
  27. package/dist/collapse/index.d.ts +3 -2
  28. package/dist/collapse/index.d.ts.map +1 -1
  29. package/dist/collapse/index.js +1 -1
  30. package/dist/command-palette/index.d.ts +37 -0
  31. package/dist/command-palette/index.d.ts.map +1 -0
  32. package/dist/command-palette/index.js +120 -0
  33. package/dist/date-picker/index.d.ts +10 -2
  34. package/dist/date-picker/index.d.ts.map +1 -1
  35. package/dist/date-picker/index.js +43 -21
  36. package/dist/dialog/index.d.ts +13 -3
  37. package/dist/dialog/index.d.ts.map +1 -1
  38. package/dist/dialog/index.js +84 -44
  39. package/dist/editable-cell/index.d.ts +2 -1
  40. package/dist/editable-cell/index.d.ts.map +1 -1
  41. package/dist/editable-cell/index.js +24 -17
  42. package/dist/empty-state/index.d.ts +14 -0
  43. package/dist/empty-state/index.d.ts.map +1 -0
  44. package/dist/empty-state/index.js +31 -0
  45. package/dist/file-drop/index.d.ts +18 -0
  46. package/dist/file-drop/index.d.ts.map +1 -0
  47. package/dist/file-drop/index.js +49 -0
  48. package/dist/filter-bar/index.d.ts +21 -0
  49. package/dist/filter-bar/index.d.ts.map +1 -0
  50. package/dist/filter-bar/index.js +90 -0
  51. package/dist/icon-picker/index.d.ts +38 -0
  52. package/dist/icon-picker/index.d.ts.map +1 -0
  53. package/dist/icon-picker/index.js +112 -0
  54. package/dist/icons/arrow-left.js +23 -0
  55. package/dist/icons/micro/arrow-trending-down.d.ts +3 -0
  56. package/dist/icons/micro/arrow-trending-down.d.ts.map +1 -0
  57. package/dist/icons/micro/arrow-trending-down.js +21 -0
  58. package/dist/icons/micro/arrow-trending-up.d.ts +3 -0
  59. package/dist/icons/micro/arrow-trending-up.d.ts.map +1 -0
  60. package/dist/icons/micro/arrow-trending-up.js +21 -0
  61. package/dist/index.d.ts +30 -6
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/kbd/index.d.ts +4 -0
  64. package/dist/kbd/index.d.ts.map +1 -0
  65. package/dist/kbd/index.js +12 -0
  66. package/dist/keypad/index.d.ts +20 -0
  67. package/dist/keypad/index.d.ts.map +1 -0
  68. package/dist/keypad/index.js +42 -0
  69. package/dist/lib.js +92 -65
  70. package/dist/load-more/index.d.ts +19 -0
  71. package/dist/load-more/index.d.ts.map +1 -0
  72. package/dist/load-more/index.js +37 -0
  73. package/dist/menu/index.d.ts +22 -3
  74. package/dist/menu/index.d.ts.map +1 -1
  75. package/dist/menu/index.js +132 -45
  76. package/dist/meter/index.d.ts +3 -1
  77. package/dist/meter/index.d.ts.map +1 -1
  78. package/dist/meter/index.js +19 -14
  79. package/dist/money-input/index.d.ts +3 -3
  80. package/dist/page-transition/index.d.ts +10 -0
  81. package/dist/page-transition/index.d.ts.map +1 -0
  82. package/dist/page-transition/index.js +16 -0
  83. package/dist/pagination/index.d.ts +26 -0
  84. package/dist/pagination/index.d.ts.map +1 -0
  85. package/dist/pagination/index.js +62 -0
  86. package/dist/progress-ring/index.d.ts +4 -1
  87. package/dist/progress-ring/index.d.ts.map +1 -1
  88. package/dist/progress-ring/index.js +47 -38
  89. package/dist/range-slider/index.d.ts +26 -0
  90. package/dist/range-slider/index.d.ts.map +1 -0
  91. package/dist/range-slider/index.js +44 -0
  92. package/dist/repeat-picker/index.d.ts +22 -0
  93. package/dist/repeat-picker/index.d.ts.map +1 -0
  94. package/dist/repeat-picker/index.js +115 -0
  95. package/dist/skeleton/index.d.ts +12 -2
  96. package/dist/skeleton/index.d.ts.map +1 -1
  97. package/dist/skeleton/index.js +11 -5
  98. package/dist/slider/index.d.ts +2 -0
  99. package/dist/slider/index.d.ts.map +1 -1
  100. package/dist/slider/index.js +19 -18
  101. package/dist/sortable/index.d.ts +33 -0
  102. package/dist/sortable/index.d.ts.map +1 -0
  103. package/dist/sortable/index.js +147 -0
  104. package/dist/sparkline/index.d.ts +15 -0
  105. package/dist/sparkline/index.d.ts.map +1 -0
  106. package/dist/sparkline/index.js +56 -0
  107. package/dist/stepper/index.d.ts +19 -0
  108. package/dist/stepper/index.d.ts.map +1 -0
  109. package/dist/stepper/index.js +53 -0
  110. package/dist/table/index.d.ts +11 -2
  111. package/dist/table/index.d.ts.map +1 -1
  112. package/dist/table/index.js +117 -53
  113. package/dist/table/selection.d.ts +55 -0
  114. package/dist/table/selection.d.ts.map +1 -0
  115. package/dist/table/selection.js +83 -0
  116. package/dist/table/swipe.d.ts +18 -0
  117. package/dist/table/swipe.d.ts.map +1 -0
  118. package/dist/table/swipe.js +53 -0
  119. package/dist/table-of-contents/index.d.ts +1 -0
  120. package/dist/table-of-contents/index.d.ts.map +1 -1
  121. package/dist/table-of-contents/index.js +25 -23
  122. package/dist/tabs/index.d.ts.map +1 -1
  123. package/dist/tabs/index.js +101 -51
  124. package/dist/tag-input/index.d.ts +19 -0
  125. package/dist/tag-input/index.d.ts.map +1 -0
  126. package/dist/tag-input/index.js +61 -0
  127. package/dist/theme-toggle/index.js +6 -6
  128. package/dist/theme.css +340 -8
  129. package/dist/timeline/index.d.ts +18 -0
  130. package/dist/timeline/index.d.ts.map +1 -0
  131. package/dist/timeline/index.js +45 -0
  132. package/dist/toast/index.js +25 -25
  133. package/dist/toggle/index.d.ts.map +1 -1
  134. package/dist/toggle/index.js +1 -1
  135. package/dist/tree/index.d.ts.map +1 -1
  136. package/dist/tree/index.js +68 -67
  137. package/dist/trend/index.d.ts +19 -0
  138. package/dist/trend/index.d.ts.map +1 -0
  139. package/dist/trend/index.js +27 -0
  140. package/dist/utils/date.d.ts +34 -0
  141. package/dist/utils/date.d.ts.map +1 -1
  142. package/dist/utils/date.js +45 -12
  143. package/dist/utils/indicator.d.ts.map +1 -1
  144. package/dist/utils/indicator.js +1 -1
  145. package/dist/utils/money.d.ts +3 -1
  146. package/dist/utils/money.d.ts.map +1 -1
  147. package/dist/utils/money.js +24 -1
  148. package/dist/utils/motion.d.ts +3 -0
  149. package/dist/utils/motion.d.ts.map +1 -0
  150. package/dist/utils/motion.js +7 -0
  151. package/dist/utils/repeat.d.ts +17 -0
  152. package/dist/utils/repeat.d.ts.map +1 -0
  153. package/dist/utils/repeat.js +38 -0
  154. package/dist/utils/section-link.d.ts +9 -0
  155. package/dist/utils/section-link.d.ts.map +1 -0
  156. package/dist/utils/section-link.js +10 -0
  157. package/dist/utils/swipe.d.ts +29 -0
  158. package/dist/utils/swipe.d.ts.map +1 -0
  159. package/dist/utils/swipe.js +85 -0
  160. package/dist/utils/theme-wave.d.ts.map +1 -1
  161. package/dist/utils/theme-wave.js +72 -71
  162. package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
  163. package/dist/utils/useAnchoredPopup.js +3 -4
  164. package/dist/utils/useSeen.d.ts +4 -0
  165. package/dist/utils/useSeen.d.ts.map +1 -0
  166. package/dist/utils/useSeen.js +17 -0
  167. package/dist/zen.css +1 -1
  168. package/package.json +3 -1
@@ -1,37 +1,39 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import { useEffect as t, useState as n } from "react";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ import { followSectionLink as t } from "../utils/section-link.js";
4
+ import { useEffect as n, useState as r } from "react";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
6
  //#region packages/table-of-contents/index.tsx
6
- function a({ items: a, title: o = "On this page", className: s }) {
7
- let [c, l] = n();
8
- return t(() => {
7
+ function o({ items: o, title: s = "On this page", className: c }) {
8
+ let [l, u] = r();
9
+ return n(() => {
9
10
  if (typeof IntersectionObserver > "u") return;
10
- let e = a.map((e) => document.getElementById(e.id)).filter((e) => !!e), t = /* @__PURE__ */ new Set(), n = new IntersectionObserver((e) => {
11
+ let e = o.map((e) => document.getElementById(e.id)).filter((e) => !!e), t = /* @__PURE__ */ new Set(), n = new IntersectionObserver((e) => {
11
12
  for (let n of e) n.isIntersecting ? t.add(n.target.id) : t.delete(n.target.id);
12
- let n = a.find((e) => t.has(e.id));
13
- n && l(n.id);
13
+ let n = o.find((e) => t.has(e.id));
14
+ n && u(n.id);
14
15
  }, { rootMargin: "0px 0px -65% 0px" });
15
16
  return e.forEach((e) => n.observe(e)), () => n.disconnect();
16
- }, [a]), a.length ? /* @__PURE__ */ i("nav", {
17
- "aria-label": o,
18
- className: e("zen__toc flex flex-col gap-3", s),
19
- children: [/* @__PURE__ */ r("p", {
17
+ }, [o]), o.length ? /* @__PURE__ */ a("nav", {
18
+ "aria-label": s || "On this page",
19
+ className: e("zen__toc flex flex-col gap-3", c),
20
+ children: [s && /* @__PURE__ */ i("p", {
20
21
  className: "text-muted-foreground text-2xs mt-0! tracking-widest uppercase",
21
- children: o
22
- }), /* @__PURE__ */ r("ul", {
22
+ children: s
23
+ }), /* @__PURE__ */ i("ul", {
23
24
  className: "border-tint/[0.07] flex flex-col gap-2 border-l text-sm",
24
- children: a.map((t) => /* @__PURE__ */ r("li", {
25
- className: e("-ml-px", t.depth === 2 && "pl-3"),
26
- children: /* @__PURE__ */ r("a", {
27
- href: `#${t.id}`,
28
- "aria-current": t.id === c ? "location" : void 0,
29
- className: e("text-muted-foreground hover:text-foreground block border-l border-transparent pl-3 transition-colors", "aria-[current=location]:border-primary aria-[current=location]:text-foreground"),
30
- children: t.label
25
+ children: o.map((n) => /* @__PURE__ */ i("li", {
26
+ className: e("-ml-px", n.depth === 2 && "pl-3"),
27
+ children: /* @__PURE__ */ i("a", {
28
+ href: `#${n.id}`,
29
+ onClick: t,
30
+ "aria-current": n.id === l ? "location" : void 0,
31
+ className: e("text-muted-foreground hover:text-foreground block border-l border-transparent pl-3 transition-colors pointer-coarse:py-1.5", "aria-[current=location]:border-primary aria-[current=location]:text-foreground"),
32
+ children: n.label
31
33
  })
32
- }, t.id))
34
+ }, n.id))
33
35
  })]
34
36
  }) : null;
35
37
  }
36
38
  //#endregion
37
- export { a as default };
39
+ export { o as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tabs/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAqE,MAAM,OAAO,CAAC;AAgB1G,6GAA6G;AAC7G,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,YAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,+BAetG;AAID;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,OAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,+BAiC5F;AAiCD,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,+BA0BnE;AAED,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,aAAa,sCAgBpE;AAED,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,KAAK,CAAC;IACvD,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACrE,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxD,KAAK,EAAE,MAAM,CAAC;CACjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tabs/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EACH,cAAc,EASjB,MAAM,OAAO,CAAC;AAsBf,6GAA6G;AAC7G,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,YAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,+BAuBtG;AAID;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,OAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,+BAiC5F;AAiCD,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,+BA0BnE;AAED,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,aAAa,sCA6BpE;AA4DD,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,KAAK,CAAC;IACvD,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACrE,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxD,KAAK,EAAE,MAAM,CAAC;CACjB"}
@@ -1,37 +1,48 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import { PILL as t } from "../utils/styles.js";
4
- import { useIndicator as n } from "../utils/indicator.js";
5
- import r, { PillIndicator as i } from "../pills/index.js";
6
- import { createContext as a, useContext as o, useId as s, useRef as c, useState as l } from "react";
7
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
3
+ import { reducedMotion as t } from "../utils/motion.js";
4
+ import { PILL as n } from "../utils/styles.js";
5
+ import { useIndicator as r } from "../utils/indicator.js";
6
+ import i, { PillIndicator as a } from "../pills/index.js";
7
+ import { createContext as o, useContext as s, useEffect as c, useId as l, useLayoutEffect as u, useRef as d, useState as f } from "react";
8
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
9
  //#region packages/tabs/index.tsx
9
- var f = a(null);
10
- function p(e) {
11
- let t = o(f);
10
+ var h = typeof window > "u" ? c : u, g = o(null);
11
+ function _(e) {
12
+ let t = s(g);
12
13
  if (!t) throw Error(`<${e}> must be inside <Tabs>`);
13
14
  return t;
14
15
  }
15
- function m({ value: t, defaultValue: n = "", onValueChange: r, className: i, ...a }) {
16
- let [o, c] = l(n), d = t ?? o, p = s();
17
- return /* @__PURE__ */ u(f.Provider, {
16
+ function v({ value: t, defaultValue: n = "", onValueChange: r, className: i, ...a }) {
17
+ let [o, s] = f(n), c = t ?? o, [u, m] = f({ value: c });
18
+ u.value !== c && m({
19
+ value: c,
20
+ before: u.value
21
+ });
22
+ let h = d(null), _ = (e) => {
23
+ let t = h.current;
24
+ return h.current = e, t;
25
+ }, v = l();
26
+ return /* @__PURE__ */ p(g.Provider, {
18
27
  value: {
19
- value: d,
28
+ value: c,
29
+ before: u.before,
30
+ show: _,
20
31
  select: (e) => {
21
- t === void 0 && c(e), r?.(e);
32
+ t === void 0 && s(e), r?.(e);
22
33
  },
23
- idFor: (e, t) => `${p}-${e}-${t.replace(/\s+/g, "-")}`
34
+ idFor: (e, t) => `${v}-${e}-${t.replace(/\s+/g, "-")}`
24
35
  },
25
- children: /* @__PURE__ */ u("div", {
26
- className: e("zen__tabs flex flex-col gap-4", i),
36
+ children: /* @__PURE__ */ p("div", {
37
+ className: e("zen__tabs relative flex flex-col gap-4", i),
27
38
  ...a
28
39
  })
29
40
  });
30
41
  }
31
- var h = a("underline");
32
- function g({ variant: e = "underline", className: t, children: n, ...a }) {
33
- p("TabList");
34
- let o = c(null), s = (e) => {
42
+ var y = o("underline");
43
+ function b({ variant: e = "underline", className: t, children: n, ...r }) {
44
+ _("TabList");
45
+ let o = d(null), s = (e) => {
35
46
  let t = Array.from(o.current?.querySelectorAll("[role=\"tab\"]:not(:disabled)") ?? []), n = t.indexOf(document.activeElement);
36
47
  if (n === -1) return;
37
48
  let r = {
@@ -44,75 +55,114 @@ function g({ variant: e = "underline", className: t, children: n, ...a }) {
44
55
  e.preventDefault();
45
56
  let i = t[(r + t.length) % t.length];
46
57
  i.focus(), i.click();
47
- }, l = /* @__PURE__ */ u(h.Provider, {
58
+ }, c = /* @__PURE__ */ p(y.Provider, {
48
59
  value: e,
49
60
  children: n
50
61
  });
51
- return e === "pills" ? /* @__PURE__ */ d(r, {
62
+ return e === "pills" ? /* @__PURE__ */ m(i, {
52
63
  ref: o,
53
64
  role: "tablist",
54
65
  onKeyDown: s,
55
66
  className: t,
56
- ...a,
57
- children: [l, /* @__PURE__ */ u(i, {})]
58
- }) : /* @__PURE__ */ u(_, {
67
+ ...r,
68
+ children: [c, /* @__PURE__ */ p(a, {})]
69
+ }) : /* @__PURE__ */ p(x, {
59
70
  ref: o,
60
71
  role: "tablist",
61
72
  onKeyDown: s,
62
73
  className: t,
63
- ...a,
64
- children: l
74
+ ...r,
75
+ children: c
65
76
  });
66
77
  }
67
- function _({ ref: t, className: r, children: i, ...a }) {
68
- let o = c(null), s = n(o, "[role=\"tab\"][aria-selected=\"true\"]");
69
- return /* @__PURE__ */ d("div", {
78
+ function x({ ref: t, className: n, children: i, ...a }) {
79
+ let o = d(null), s = r(o, "[role=\"tab\"][aria-selected=\"true\"]");
80
+ return /* @__PURE__ */ m("div", {
70
81
  ref: (e) => {
71
82
  o.current = e, typeof t == "function" ? t(e) : t && (t.current = e);
72
83
  },
73
- className: e("border-border relative flex gap-1 border-b", r),
84
+ className: e("border-border relative flex gap-1 border-b", n),
74
85
  ...a,
75
- children: [i, s ? /* @__PURE__ */ u("span", {
86
+ children: [i, s ? /* @__PURE__ */ p("span", {
76
87
  "aria-hidden": !0,
77
88
  className: "zen__tab-bar bg-primary absolute bottom-[-1px] left-0 h-0.5 transition-[translate,width] duration-150 ease-in-out",
78
89
  style: {
79
90
  width: s.w,
80
91
  translate: `${s.x}px 0`
81
92
  }
82
- }, "measured") : /* @__PURE__ */ u("span", {
93
+ }, "measured") : /* @__PURE__ */ p("span", {
83
94
  "aria-hidden": !0,
84
95
  "data-pending": !0,
85
96
  className: "zen__tab-bar hidden"
86
97
  }, "pending")]
87
98
  });
88
99
  }
89
- function v({ value: n, className: r, onClick: i, ...a }) {
90
- let { value: s, select: c, idFor: l } = p("Tab"), d = o(h), f = s === n;
91
- return /* @__PURE__ */ u("button", {
100
+ function S({ value: t, className: r, onClick: i, ...a }) {
101
+ let { value: o, select: c, idFor: l } = _("Tab"), u = s(y), d = o === t;
102
+ return /* @__PURE__ */ p("button", {
92
103
  type: "button",
93
104
  role: "tab",
94
- id: l("tab", n),
95
- "aria-selected": f,
96
- "aria-controls": l("panel", n),
97
- tabIndex: f ? 0 : -1,
98
- "data-active": f || void 0,
105
+ id: l("tab", t),
106
+ "aria-selected": d,
107
+ "aria-controls": l("panel", t),
108
+ tabIndex: d ? 0 : -1,
109
+ "data-active": d || void 0,
99
110
  onClick: (e) => {
100
- c(n), i?.(e);
111
+ c(t), i?.(e);
101
112
  },
102
- className: e(d === "pills" ? t : "focus-visible:ring-ring text-muted-foreground hover:text-foreground data-active:text-foreground cursor-pointer px-3 py-2 text-sm whitespace-nowrap outline-hidden select-none focus-visible:ring-1 disabled:cursor-not-allowed", r),
113
+ className: e(u === "pills" ? n : "focus-visible:ring-ring text-muted-foreground hover:text-foreground data-active:text-foreground cursor-pointer px-3 py-2 text-sm whitespace-nowrap outline-hidden select-none focus-visible:ring-1 disabled:cursor-not-allowed", r),
103
114
  ...a
104
115
  });
105
116
  }
106
- function y({ value: t, className: n, ...r }) {
107
- let { value: i, idFor: a } = p("TabPanel");
108
- return i === t ? /* @__PURE__ */ u("div", {
117
+ function C({ value: n, className: r, ...i }) {
118
+ let { value: a, before: o, show: s, idFor: c } = _("TabPanel"), l = a === n;
119
+ return h(() => {
120
+ if (!l) return;
121
+ let e = document.getElementById(c("panel", n)), r = s(e);
122
+ if (!e || o === void 0 || o === n) return;
123
+ let i = document.getElementById(c("tab", n)), a = document.getElementById(c("tab", o));
124
+ if (!i || !a) return;
125
+ let u = !!(i.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);
126
+ e.dataset.enter = u ? "end" : "start", t() || T(e, r, u);
127
+ }, [l, o]), l ? /* @__PURE__ */ p("div", {
109
128
  role: "tabpanel",
110
- id: a("panel", t),
111
- "aria-labelledby": a("tab", t),
129
+ id: c("panel", n),
130
+ "aria-labelledby": c("tab", n),
112
131
  tabIndex: 0,
113
- className: e("focus-visible:outline-ring/50 outline-hidden focus-visible:outline-2 focus-visible:outline-offset-4", n),
114
- ...r
132
+ className: e("zen__tab-panel focus-visible:outline-ring/50 outline-hidden focus-visible:outline-2 focus-visible:outline-offset-4", r),
133
+ ...i
115
134
  }) : null;
116
135
  }
136
+ var w = {
137
+ duration: 300,
138
+ easing: "cubic-bezier(0.33, 1, 0.68, 1)"
139
+ };
140
+ function T(e, t, n) {
141
+ let r = e.closest(".zen__tabs");
142
+ if (!e.animate) return;
143
+ let i = n === (getComputedStyle(e).direction !== "rtl") ? 1 : -1, a = e.offsetWidth, o = Math.min(a * .25, 208), s = e.offsetHeight, c = s;
144
+ if (t && !t.isConnected && r) {
145
+ let n = e.getBoundingClientRect(), l = r.getBoundingClientRect();
146
+ t.removeAttribute("id"), t.setAttribute("aria-hidden", "true"), t.inert = !0, t.getAnimations().forEach((e) => e.cancel()), Object.assign(t.style, {
147
+ position: "absolute",
148
+ top: `${n.top - l.top}px`,
149
+ left: `${n.left - l.left}px`,
150
+ width: `${a}px`,
151
+ pointerEvents: "none"
152
+ }), r.append(t), c = t.offsetHeight;
153
+ let u = Math.max(0, c - s), d = t.animate({
154
+ translate: ["0 0", `${-i * o}px 0`],
155
+ opacity: [1, 0],
156
+ clipPath: ["inset(0 0 0 0)", i > 0 ? `inset(0 0 ${u}px ${o}px)` : `inset(0 ${o}px ${u}px 0)`]
157
+ }, w);
158
+ d.onfinish = d.oncancel = () => t.remove();
159
+ }
160
+ let l = Math.max(0, s - c);
161
+ e.animate({
162
+ translate: [`${i * o}px 0`, "0 0"],
163
+ opacity: [0, 1],
164
+ clipPath: [i > 0 ? `inset(0 ${o}px ${l}px 0)` : `inset(0 0 ${l}px ${o}px)`, "inset(0 0 0 0)"]
165
+ }, w);
166
+ }
117
167
  //#endregion
118
- export { v as Tab, g as TabList, y as TabPanel, m as default };
168
+ export { S as Tab, b as TabList, C as TabPanel, v as default };
@@ -0,0 +1,19 @@
1
+ import { ComponentProps } from 'react';
2
+ /**
3
+ * A field of short values (tags, emails, labels): typing one and pressing
4
+ * Enter or a comma adds it, pasting a list adds each, Backspace in the empty
5
+ * field takes the last one back. Each is removed with its ×. Values are
6
+ * trimmed and kept once. Past about three rows the tags scroll, under a
7
+ * typing line that stays in view (a max-h-* class sets the field's height).
8
+ */
9
+ export default function TagInput({ value: controlled, defaultValue, onValueChange, validate, removeLabel, className, disabled, ...rest }: TagInputProps): import('react').JSX.Element;
10
+ export interface TagInputProps extends Omit<ComponentProps<'input'>, 'value' | 'defaultValue'> {
11
+ value?: string[];
12
+ defaultValue?: string[];
13
+ onValueChange?: (value: string[]) => void;
14
+ /** Whether an entry may be added (e.g. looks like an email). */
15
+ validate?: (entry: string) => boolean;
16
+ /** The × button's label, for screen readers. */
17
+ removeLabel?: (tag: string) => string;
18
+ }
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tag-input/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAkB,cAAc,EAAoD,MAAM,OAAO,CAAC;AAEzG;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC7B,KAAK,EAAE,UAAU,EACjB,YAAiB,EACjB,aAAa,EACb,QAAQ,EACR,WAAsC,EACtC,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,aAAa,+BAgGf;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAC1F,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,gDAAgD;IAChD,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACzC"}
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ import { cx as e } from "../utils/cx.js";
3
+ import { FIELD as t } from "../utils/styles.js";
4
+ import { useFieldProps as n } from "../field/index.js";
5
+ import r from "../icons/micro/x-mark.js";
6
+ import { useLayoutEffect as i, useRef as a, useState as o } from "react";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
+ //#region packages/tag-input/index.tsx
9
+ function l({ value: l, defaultValue: u = [], onValueChange: d, validate: f, removeLabel: p = (e) => `Remove ${e}`, className: m, disabled: h, ...g }) {
10
+ let [_, v] = o(u), y = l ?? _, [b, x] = o(""), S = n(g), C = a(null), w = y.length;
11
+ i(() => {
12
+ let e = C.current;
13
+ e?.parentElement?.contains(document.activeElement) && (e.scrollTop = e.scrollHeight);
14
+ }, [w]);
15
+ let T = (e) => {
16
+ l === void 0 && v(e), d?.(e);
17
+ }, E = (e) => {
18
+ let t = [...y];
19
+ for (let n of e.map((e) => e.trim())) n && !t.includes(n) && (f?.(n) ?? !0) && t.push(n);
20
+ t.length !== y.length && T(t);
21
+ };
22
+ return /* @__PURE__ */ c("div", {
23
+ className: e("zen__tag-input", t, "flex h-auto max-h-36 min-h-10 w-full cursor-text flex-col gap-1.5 py-1.5", "has-[input:focus-visible]:border-glow/60 has-[input:focus-visible]:bg-tint/[0.05] has-[input:focus-visible]:shadow-glow-focus has-[input:focus-visible]:[--glow-border-color:transparent]", h && "cursor-not-allowed opacity-50", m),
24
+ onClick: (e) => e.currentTarget.querySelector("input")?.focus(),
25
+ children: [w > 0 && /* @__PURE__ */ s("div", {
26
+ ref: C,
27
+ className: "flex min-h-0 flex-wrap gap-1.5 overflow-y-auto",
28
+ children: y.map((e) => /* @__PURE__ */ c("span", {
29
+ className: "zen__tag bg-primary/12 text-foreground inline-flex items-center gap-1 rounded-md py-0.5 pr-1 pl-2 text-xs shadow-[inset_0_0_0_1px_oklch(var(--primary)/0.25)]",
30
+ children: [e, /* @__PURE__ */ s("button", {
31
+ type: "button",
32
+ disabled: h,
33
+ "aria-label": p(e),
34
+ onClick: () => T(y.filter((t) => t !== e)),
35
+ className: "text-muted-foreground hover:text-foreground hover:bg-tint/10 focus-visible:ring-ring/50 touch-target grid size-4 cursor-pointer place-items-center rounded-sm outline-hidden focus-visible:ring-2",
36
+ children: /* @__PURE__ */ s(r, { className: "size-3" })
37
+ })]
38
+ }, e))
39
+ }), /* @__PURE__ */ s("input", {
40
+ ...g,
41
+ ...S,
42
+ disabled: h,
43
+ value: b,
44
+ onChange: (e) => x(e.target.value),
45
+ onKeyDown: (e) => {
46
+ g.onKeyDown?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing) && ((e.key === "Enter" || e.key === ",") && b.trim() ? (e.preventDefault(), E([b]), x("")) : e.key === "Backspace" && !b && y.length && (e.preventDefault(), x(y[y.length - 1]), T(y.slice(0, -1))));
47
+ },
48
+ onBlur: (e) => {
49
+ g.onBlur?.(e), b.trim() && (E([b]), x(""));
50
+ },
51
+ onPaste: (e) => {
52
+ g.onPaste?.(e);
53
+ let t = e.clipboardData.getData("text");
54
+ !e.defaultPrevented && /[,\n]/.test(t) && (e.preventDefault(), E(t.split(/[,\n]/)));
55
+ },
56
+ className: "h-7 w-full shrink-0 bg-transparent outline-hidden placeholder:text-[color:oklch(var(--muted-foreground)/var(--zen-placeholder))]"
57
+ })]
58
+ });
59
+ }
60
+ //#endregion
61
+ export { l as default };
@@ -4,12 +4,12 @@ import t from "../icons/micro/moon.js";
4
4
  import n from "../icons/micro/sun.js";
5
5
  import { prepareThemeWave as r, themeWave as i } from "../utils/theme-wave.js";
6
6
  import { useSyncExternalStore as a } from "react";
7
- import { jsx as o } from "react/jsx-runtime";
8
- import { flushSync as s } from "react-dom";
7
+ import { flushSync as o } from "react-dom";
8
+ import { jsx as s } from "react/jsx-runtime";
9
9
  //#region packages/theme-toggle/index.tsx
10
10
  var c = (e = "theme") => `try{var t=localStorage.getItem(${JSON.stringify(e)}),r=document.documentElement;if(t==='light'||t==='dark'){r.classList.remove('light','dark');r.classList.add(t)}}catch(e){}`;
11
11
  function l({ storageKey: e = "theme" }) {
12
- return /* @__PURE__ */ o("script", { dangerouslySetInnerHTML: { __html: c(e) } });
12
+ return /* @__PURE__ */ s("script", { dangerouslySetInnerHTML: { __html: c(e) } });
13
13
  }
14
14
  var u = /* @__PURE__ */ new Set();
15
15
  function d(e) {
@@ -25,7 +25,7 @@ function d(e) {
25
25
  var f = () => document.documentElement.classList.contains("light") ? "light" : "dark";
26
26
  function p({ value: c, onChange: l, target: p, storageKey: m = "theme", className: h }) {
27
27
  let g = a(d, f, () => "dark"), _ = c ?? g, v = _ === "dark" ? "light" : "dark";
28
- return /* @__PURE__ */ o("button", {
28
+ return /* @__PURE__ */ s("button", {
29
29
  type: "button",
30
30
  "aria-label": `Switch to ${v} theme`,
31
31
  onPointerEnter: r,
@@ -38,12 +38,12 @@ function p({ value: c, onChange: l, target: p, storageKey: m = "theme", classNam
38
38
  localStorage.setItem(m, v);
39
39
  } catch {}
40
40
  }
41
- s(() => {
41
+ o(() => {
42
42
  l?.(v), u.forEach((e) => e());
43
43
  });
44
44
  }, e.currentTarget, p?.current),
45
45
  className: e("zen__theme-toggle text-muted-foreground hover:bg-tint/[0.06] hover:text-foreground focus-visible:ring-ring/50 grid size-9 cursor-pointer place-items-center rounded-lg outline-hidden focus-visible:ring-2", h),
46
- children: o(_ === "dark" ? t : n, { className: "size-4" })
46
+ children: s(_ === "dark" ? t : n, { className: "size-4" })
47
47
  });
48
48
  }
49
49
  //#endregion