@devalok/shilp-sutra 0.43.0 → 0.44.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 (90) hide show
  1. package/MIGRATION.md +46 -0
  2. package/dist/_chunks/chat.js +163 -162
  3. package/dist/_chunks/chat.js.map +1 -1
  4. package/dist/_chunks/mention-suggestion.js +34 -32
  5. package/dist/_chunks/mention-suggestion.js.map +1 -1
  6. package/dist/_chunks/oauth-button.js +102 -97
  7. package/dist/_chunks/oauth-button.js.map +1 -1
  8. package/dist/_chunks/tree-view.js +1 -1
  9. package/dist/_chunks/tree-view.js.map +1 -1
  10. package/dist/ai/command-bar.js.map +1 -1
  11. package/dist/composed/command-palette.js +3 -3
  12. package/dist/composed/command-palette.js.map +1 -1
  13. package/dist/composed/content-card.d.ts +6 -0
  14. package/dist/composed/content-card.d.ts.map +1 -1
  15. package/dist/composed/content-card.js.map +1 -1
  16. package/dist/composed/extensions/file-attachment.d.ts.map +1 -1
  17. package/dist/composed/file-preview/audio-preview.d.ts.map +1 -1
  18. package/dist/composed/file-preview.d.ts.map +1 -1
  19. package/dist/composed/file-preview.js +146 -142
  20. package/dist/composed/file-preview.js.map +1 -1
  21. package/dist/composed/filter-bar.js +5 -2
  22. package/dist/composed/filter-bar.js.map +1 -1
  23. package/dist/composed/master-detail.js +1 -1
  24. package/dist/composed/master-detail.js.map +1 -1
  25. package/dist/composed/page-header.js +1 -1
  26. package/dist/composed/page-header.js.map +1 -1
  27. package/dist/composed/rich-chat-input/attachment-strip.d.ts.map +1 -1
  28. package/dist/composed/rich-chat-input/audio-player.d.ts.map +1 -1
  29. package/dist/composed/rich-chat-input/schedule-send.d.ts.map +1 -1
  30. package/dist/composed/rich-chat-input.js +595 -586
  31. package/dist/composed/rich-chat-input.js.map +1 -1
  32. package/dist/composed/rich-text-editor.d.ts.map +1 -1
  33. package/dist/composed/rich-text-editor.js +164 -162
  34. package/dist/composed/rich-text-editor.js.map +1 -1
  35. package/dist/hooks/index.d.ts +2 -2
  36. package/dist/hooks/index.d.ts.map +1 -1
  37. package/dist/shell/notification-center.d.ts.map +1 -1
  38. package/dist/shell/notification-center.js +101 -97
  39. package/dist/shell/notification-center.js.map +1 -1
  40. package/dist/shell/sidebar.d.ts.map +1 -1
  41. package/dist/shell/sidebar.js +137 -122
  42. package/dist/shell/sidebar.js.map +1 -1
  43. package/dist/shell/top-bar.d.ts.map +1 -1
  44. package/dist/shell/top-bar.js +86 -83
  45. package/dist/shell/top-bar.js.map +1 -1
  46. package/dist/tokens/semantic.css +1 -0
  47. package/dist/ui/avatar.js +1 -1
  48. package/dist/ui/avatar.js.map +1 -1
  49. package/dist/ui/breadcrumb.js +2 -2
  50. package/dist/ui/breadcrumb.js.map +1 -1
  51. package/dist/ui/button.js.map +1 -1
  52. package/dist/ui/card.d.ts +82 -7
  53. package/dist/ui/card.d.ts.map +1 -1
  54. package/dist/ui/card.js +74 -108
  55. package/dist/ui/card.js.map +1 -1
  56. package/dist/ui/chat/message.d.ts.map +1 -1
  57. package/dist/ui/combobox.js +2 -2
  58. package/dist/ui/combobox.js.map +1 -1
  59. package/dist/ui/dropdown-menu.js +9 -3
  60. package/dist/ui/dropdown-menu.js.map +1 -1
  61. package/dist/ui/index.d.ts +2 -1
  62. package/dist/ui/index.d.ts.map +1 -1
  63. package/dist/ui/index.js +58 -57
  64. package/dist/ui/index.js.map +1 -1
  65. package/dist/ui/menubar.js +9 -3
  66. package/dist/ui/menubar.js.map +1 -1
  67. package/dist/ui/oauth-button/oauth-button.d.ts.map +1 -1
  68. package/dist/ui/select.js +5 -2
  69. package/dist/ui/select.js.map +1 -1
  70. package/dist/ui/sidebar.js +73 -73
  71. package/dist/ui/sidebar.js.map +1 -1
  72. package/dist/ui/stat-card.d.ts +8 -5
  73. package/dist/ui/stat-card.d.ts.map +1 -1
  74. package/dist/ui/stat-card.js +168 -150
  75. package/dist/ui/stat-card.js.map +1 -1
  76. package/dist/ui/tabs.d.ts.map +1 -1
  77. package/dist/ui/tabs.js +5 -2
  78. package/dist/ui/tabs.js.map +1 -1
  79. package/dist/ui/truncated-text.d.ts +37 -0
  80. package/dist/ui/truncated-text.d.ts.map +1 -0
  81. package/dist/ui/truncated-text.js +53 -0
  82. package/dist/ui/truncated-text.js.map +1 -0
  83. package/docs/components/ui/card.md +13 -4
  84. package/docs/components/ui/stat-card.md +7 -2
  85. package/docs/components/ui/truncated-text.md +49 -0
  86. package/llms-full.txt +70 -7
  87. package/make-kit/components/card.md +14 -4
  88. package/package.json +1 -1
  89. package/skill/SKILL.md +1 -1
  90. package/skill/references/components-full.md +70 -7
@@ -2,11 +2,12 @@
2
2
  import { cn as e } from "../ui/lib/utils.js";
3
3
  import { t } from "./normalize-icon.js";
4
4
  import { Button as n } from "../ui/button.js";
5
- import * as r from "react";
6
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
7
- import { IconBrandApple as o, IconBrandDiscord as s, IconBrandFacebook as c, IconBrandGithub as l, IconBrandGitlab as u, IconBrandGoogleFilled as d, IconBrandLinkedin as f, IconBrandSlack as p, IconBrandWindows as m, IconBrandXFilled as h, IconFingerprint as g, IconKey as _, IconMail as v } from "@tabler/icons-react";
5
+ import { TruncatedText as r } from "../ui/truncated-text.js";
6
+ import * as i from "react";
7
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
8
+ import { IconBrandApple as s, IconBrandDiscord as c, IconBrandFacebook as l, IconBrandGithub as u, IconBrandGitlab as d, IconBrandGoogleFilled as f, IconBrandLinkedin as p, IconBrandSlack as m, IconBrandWindows as h, IconBrandXFilled as g, IconFingerprint as _, IconKey as v, IconMail as y } from "@tabler/icons-react";
8
9
  //#region src/ui/oauth-button/oauth-button.tsx
9
- var y = {
10
+ var b = {
10
11
  google: "Google",
11
12
  apple: "Apple",
12
13
  github: "GitHub",
@@ -20,45 +21,45 @@ var y = {
20
21
  sso: "SSO",
21
22
  email: "email",
22
23
  passkey: "a passkey"
23
- }, b = {
24
- google: d,
25
- apple: o,
26
- github: l,
27
- microsoft: m,
28
- x: h,
29
- linkedin: f,
30
- facebook: c,
31
- discord: s,
32
- slack: p,
33
- gitlab: u,
34
- sso: _,
35
- email: v,
36
- passkey: g
24
+ }, x = {
25
+ google: f,
26
+ apple: s,
27
+ github: u,
28
+ microsoft: h,
29
+ x: g,
30
+ linkedin: p,
31
+ facebook: l,
32
+ discord: c,
33
+ slack: m,
34
+ gitlab: d,
35
+ sso: v,
36
+ email: y,
37
+ passkey: _
37
38
  };
38
- function x(e) {
39
- return e === "passkey" ? "Passkey" : y[e];
39
+ function S(e) {
40
+ return e === "passkey" ? "Passkey" : b[e];
40
41
  }
41
- function S(e, t, n) {
42
- if (n) return x(e);
43
- let r = y[e];
42
+ function C(e, t, n) {
43
+ if (n) return S(e);
44
+ let r = b[e];
44
45
  switch (t) {
45
46
  case "signin": return `Sign in with ${r}`;
46
47
  case "signup": return `Sign up with ${r}`;
47
48
  default: return `Continue with ${r}`;
48
49
  }
49
50
  }
50
- var C = { passkey: {
51
+ var w = { passkey: {
51
52
  continue: "Continue with a passkey",
52
53
  signin: "Sign in with a passkey",
53
54
  signup: "Create a passkey"
54
55
  } };
55
- function w(e, t, n) {
56
- return n ? x(e) : C[e]?.[t] ?? S(e, t, n);
56
+ function T(e, t, n) {
57
+ return n ? S(e) : w[e]?.[t] ?? C(e, t, n);
57
58
  }
58
- function T(e, t) {
59
- return C[e]?.[t] ?? S(e, t, !1);
59
+ function E(e, t) {
60
+ return w[e]?.[t] ?? C(e, t, !1);
60
61
  }
61
- var E = {
62
+ var D = {
62
63
  xs: 14,
63
64
  sm: 16,
64
65
  md: 18,
@@ -71,7 +72,7 @@ var E = {
71
72
  "icon-sm": 16,
72
73
  "icon-md": 18,
73
74
  "icon-lg": 20
74
- }, D = {
75
+ }, O = {
75
76
  xs: "icon-xs",
76
77
  sm: "icon-sm",
77
78
  md: "icon-md",
@@ -79,18 +80,18 @@ var E = {
79
80
  "compact-xs": "icon-xs",
80
81
  "compact-sm": "icon-sm",
81
82
  "compact-md": "icon-md"
82
- }, O = r.forwardRef(({ provider: r, intent: o = "continue", variant: s, appearance: c, icon: l, iconOnly: u = !1, compact: d = !1, lastUsed: f = !1, lastUsedSlot: p, lastUsedLabel: m = "Last used", helperText: h, children: g, className: _, size: v, fullWidth: y = !1, ...x }, S) => {
83
- let C = v ?? "md", O = b[r], k = E[C] ?? 18, A = t(l) ?? /* @__PURE__ */ i(O, {
83
+ }, k = i.forwardRef(({ provider: r, intent: i = "continue", variant: s, appearance: c, icon: l, iconOnly: u = !1, compact: d = !1, lastUsed: f = !1, lastUsedSlot: p, lastUsedLabel: m = "Last used", helperText: h, children: g, className: _, size: v, fullWidth: y = !1, ...b }, S) => {
84
+ let C = v ?? "md", w = x[r], k = D[C] ?? 18, A = t(l) ?? /* @__PURE__ */ a(w, {
84
85
  size: k,
85
86
  "aria-hidden": !0
86
- }), j = g ?? w(r, o, d), M = s ?? (c === "outline" ? "outline" : "solid"), N = T(r, o), P = u || d || f ? `${N}${f ? " (last used)" : ""}` : void 0, F = /* @__PURE__ */ i("span", {
87
- className: "pointer-events-none inline-flex items-center rounded-pill bg-accent-9 text-accent-fg px-2 py-1 text-[9px] leading-none font-semibold uppercase tracking-wide shadow-overlay",
87
+ }), j = g ?? T(r, i, d), M = s ?? (c === "outline" ? "outline" : "solid"), N = E(r, i), P = u || d || f ? `${N}${f ? " (last used)" : ""}` : void 0, F = /* @__PURE__ */ a("span", {
88
+ className: "pointer-events-none inline-flex items-center rounded-pill bg-accent-9 text-accent-fg px-2 py-1 text-ds-2xs leading-none font-semibold uppercase tracking-wide shadow-overlay",
88
89
  children: m
89
- }), I = (typeof p == "function" ? p({ label: m }) : p) ?? F, L = /* @__PURE__ */ i(n, {
90
+ }), I = (typeof p == "function" ? p({ label: m }) : p) ?? F, L = /* @__PURE__ */ a(n, {
90
91
  ref: S,
91
92
  variant: M,
92
93
  color: "neutral",
93
- size: u ? D[C] ?? "icon-md" : C,
94
+ size: u ? O[C] ?? "icon-md" : C,
94
95
  fullWidth: y && !u,
95
96
  startIcon: u ? void 0 : A,
96
97
  "aria-label": P,
@@ -98,130 +99,134 @@ var E = {
98
99
  "data-oauth-variant": M,
99
100
  "data-last-used": f || void 0,
100
101
  className: _,
101
- ...x,
102
+ ...b,
102
103
  children: u ? A : j
103
104
  }), R = f && !u;
104
- return !R && !h ? L : /* @__PURE__ */ a("div", {
105
+ return !R && !h ? L : /* @__PURE__ */ o("div", {
105
106
  className: e("relative inline-flex flex-col", y && "w-full"),
106
107
  children: [
107
108
  L,
108
- R ? /* @__PURE__ */ i("span", {
109
+ R ? /* @__PURE__ */ a("span", {
109
110
  "aria-hidden": "true",
110
111
  "data-last-used-badge": "",
111
112
  className: "pointer-events-none absolute -top-[10px] -right-2 z-10",
112
113
  children: I
113
114
  }) : null,
114
- h ? /* @__PURE__ */ i("span", {
115
+ h ? /* @__PURE__ */ a("span", {
115
116
  className: "mt-ds-02 text-ds-sm text-surface-fg-subtle",
116
117
  children: h
117
118
  }) : null
118
119
  ]
119
120
  });
120
121
  });
121
- O.displayName = "OAuthButton";
122
- var k = r.forwardRef(({ orientation: t = "vertical", gap: n = "ds-03", fullWidth: a = !0, reorderLastUsedFirst: o = !1, className: s, children: c, ...l }, u) => {
123
- let d = n === "ds-02" ? "gap-ds-02" : n === "ds-04" ? "gap-ds-04" : "gap-ds-03", f = t === "vertical" && a, p = r.useMemo(() => {
122
+ k.displayName = "OAuthButton";
123
+ var A = i.forwardRef(({ orientation: t = "vertical", gap: n = "ds-03", fullWidth: r = !0, reorderLastUsedFirst: o = !1, className: s, children: c, ...l }, u) => {
124
+ let d = n === "ds-02" ? "gap-ds-02" : n === "ds-04" ? "gap-ds-04" : "gap-ds-03", f = t === "vertical" && r, p = i.useMemo(() => {
124
125
  if (!o) return c;
125
- let e = r.Children.toArray(c), t = e.findIndex((e) => r.isValidElement(e) && e.props?.lastUsed);
126
+ let e = i.Children.toArray(c), t = e.findIndex((e) => i.isValidElement(e) && e.props?.lastUsed);
126
127
  if (t <= 0) return c;
127
- let n = [...e], [i] = n.splice(t, 1);
128
- return n.unshift(i), n;
128
+ let n = [...e], [r] = n.splice(t, 1);
129
+ return n.unshift(r), n;
129
130
  }, [c, o]);
130
- return /* @__PURE__ */ i("div", {
131
+ return /* @__PURE__ */ a("div", {
131
132
  ref: u,
132
133
  className: e("flex", t === "vertical" ? "flex-col" : "flex-row flex-wrap items-center", d, f && "w-full [&>*]:w-full [&_button]:w-full", s),
133
134
  ...l,
134
135
  children: p
135
136
  });
136
137
  });
137
- k.displayName = "OAuthGroup";
138
- var A = r.forwardRef(({ label: t = "or", className: n, ...r }, o) => /* @__PURE__ */ a("div", {
139
- ref: o,
138
+ A.displayName = "OAuthGroup";
139
+ var j = i.forwardRef(({ label: t = "or", className: n, ...r }, i) => /* @__PURE__ */ o("div", {
140
+ ref: i,
140
141
  role: "separator",
141
142
  "aria-orientation": "horizontal",
142
143
  className: e("flex items-center gap-ds-03", n),
143
144
  ...r,
144
145
  children: [
145
- /* @__PURE__ */ i("hr", {
146
+ /* @__PURE__ */ a("hr", {
146
147
  "aria-hidden": "true",
147
148
  className: "flex-1 border-t border-surface-border-subtle"
148
149
  }),
149
- /* @__PURE__ */ i("span", {
150
+ /* @__PURE__ */ a("span", {
150
151
  className: "text-ds-sm text-surface-fg-subtle uppercase tracking-wide",
151
152
  children: t
152
153
  }),
153
- /* @__PURE__ */ i("hr", {
154
+ /* @__PURE__ */ a("hr", {
154
155
  "aria-hidden": "true",
155
156
  className: "flex-1 border-t border-surface-border-subtle"
156
157
  })
157
158
  ]
158
159
  }));
159
- A.displayName = "OAuthDivider";
160
- var j = r.forwardRef(({ provider: r, accountLabel: o, connected: s, onAction: c, onActionAsync: l, actionLabel: u, disabled: d, icon: f, className: p, ...m }, h) => {
161
- let g = b[r], _ = y[r], v = u ?? (s ? "Disconnect" : `Connect ${_}`);
162
- return /* @__PURE__ */ a("div", {
163
- ref: h,
164
- className: e("flex items-center justify-between gap-ds-04 py-ds-04 px-ds-04 rounded-surface border border-surface-border bg-surface-raised", p),
165
- "data-provider": r,
166
- "data-connected": s ? "true" : "false",
167
- ...m,
168
- children: [/* @__PURE__ */ a("div", {
160
+ j.displayName = "OAuthDivider";
161
+ var M = i.forwardRef(({ provider: i, accountLabel: s, connected: c, onAction: l, onActionAsync: u, actionLabel: d, disabled: f, icon: p, className: m, ...h }, g) => {
162
+ let _ = x[i], v = b[i], y = d ?? (c ? "Disconnect" : `Connect ${v}`);
163
+ return /* @__PURE__ */ o("div", {
164
+ ref: g,
165
+ className: e("flex items-center justify-between gap-ds-04 py-ds-04 px-ds-04 rounded-surface border border-surface-border bg-surface-raised", m),
166
+ "data-provider": i,
167
+ "data-connected": c ? "true" : "false",
168
+ ...h,
169
+ children: [/* @__PURE__ */ o("div", {
169
170
  className: "flex items-center gap-ds-03 min-w-0",
170
- children: [t(f) ?? /* @__PURE__ */ i(g, {
171
+ children: [t(p) ?? /* @__PURE__ */ a(_, {
171
172
  size: 24,
172
173
  "aria-hidden": !0
173
- }), /* @__PURE__ */ a("div", {
174
+ }), /* @__PURE__ */ o("div", {
174
175
  className: "flex flex-col min-w-0",
175
- children: [/* @__PURE__ */ i("span", {
176
- className: "text-ds-md font-semibold text-surface-fg truncate",
177
- children: _
178
- }), o ? /* @__PURE__ */ i("span", {
176
+ children: [/* @__PURE__ */ a(r, {
177
+ className: "text-ds-md font-semibold text-surface-fg",
178
+ children: v
179
+ }), s ? typeof s == "string" ? /* @__PURE__ */ a(r, {
180
+ mode: "middle",
181
+ className: "text-ds-sm text-surface-fg-muted",
182
+ children: s
183
+ }) : /* @__PURE__ */ a("span", {
179
184
  className: "text-ds-sm text-surface-fg-muted truncate",
180
- children: o
181
- }) : s ? /* @__PURE__ */ i("span", {
185
+ children: s
186
+ }) : c ? /* @__PURE__ */ a("span", {
182
187
  className: "text-ds-sm text-success-11",
183
188
  children: "Connected"
184
- }) : /* @__PURE__ */ i("span", {
189
+ }) : /* @__PURE__ */ a("span", {
185
190
  className: "text-ds-sm text-surface-fg-subtle",
186
191
  children: "Not connected"
187
192
  })]
188
193
  })]
189
- }), /* @__PURE__ */ i(n, {
194
+ }), /* @__PURE__ */ a(n, {
190
195
  size: "sm",
191
- variant: s ? "soft" : "solid",
192
- color: s ? "neutral" : "accent",
193
- disabled: d,
194
- onClick: c,
195
- onClickAsync: l,
196
- children: v
196
+ variant: c ? "soft" : "solid",
197
+ color: c ? "neutral" : "accent",
198
+ disabled: f,
199
+ onClick: l,
200
+ onClickAsync: u,
201
+ children: y
197
202
  })]
198
203
  });
199
204
  });
200
- j.displayName = "OAuthConnectionRow";
201
- var M = r.forwardRef(({ provider: e, size: t = 18, ...n }, r) => {
202
- let a = b[e];
203
- return /* @__PURE__ */ i(a, {
205
+ M.displayName = "OAuthConnectionRow";
206
+ var N = i.forwardRef(({ provider: e, size: t = 18, ...n }, r) => {
207
+ let i = x[e];
208
+ return /* @__PURE__ */ a(i, {
204
209
  ref: r,
205
210
  size: t,
206
211
  "aria-hidden": !0,
207
212
  ...n
208
213
  });
209
214
  });
210
- M.displayName = "OAuthGlyph";
211
- function N(e, t = "continue", n = !1) {
212
- return w(e, t, n);
215
+ N.displayName = "OAuthGlyph";
216
+ function P(e, t = "continue", n = !1) {
217
+ return T(e, t, n);
213
218
  }
214
- function P(e) {
215
- return x(e);
219
+ function F(e) {
220
+ return S(e);
216
221
  }
217
- var F = {
218
- Button: O,
219
- Group: k,
220
- Divider: A,
221
- ConnectionRow: j,
222
- Glyph: M,
223
- getLabel: N,
224
- getName: P
222
+ var I = {
223
+ Button: k,
224
+ Group: A,
225
+ Divider: j,
226
+ ConnectionRow: M,
227
+ Glyph: N,
228
+ getLabel: P,
229
+ getName: F
225
230
  };
226
231
  //#endregion
227
- export { M as a, P as c, A as i, O as n, k as o, j as r, N as s, F as t };
232
+ export { N as a, F as c, j as i, k as n, A as o, M as r, P as s, I as t };
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-button.js","names":[],"sources":["../../src/ui/oauth-button/oauth-button.tsx"],"sourcesContent":["'use client'\n\nimport {\n IconBrandApple,\n IconBrandDiscord,\n IconBrandFacebook,\n IconBrandGithub,\n IconBrandGitlab,\n IconBrandGoogleFilled,\n IconBrandLinkedin,\n IconBrandSlack,\n IconBrandWindows,\n IconBrandXFilled,\n IconFingerprint,\n IconKey,\n IconMail,\n} from '@tabler/icons-react'\nimport * as React from 'react'\n\nimport { Button, type ButtonProps } from '../button'\nimport type { IconInput } from '../lib/icon-input'\nimport { normalizeIcon } from '../lib/normalize-icon'\nimport { cn } from '../lib/utils'\n\n// ── Types ───────────────────────────────────────────────────────\n\nexport type OAuthProvider =\n | 'google'\n | 'apple'\n | 'github'\n | 'microsoft'\n | 'x'\n | 'linkedin'\n | 'facebook'\n | 'discord'\n | 'slack'\n | 'gitlab'\n | 'sso'\n | 'email'\n | 'passkey'\n\nexport type OAuthIntent = 'continue' | 'signin' | 'signup'\n\n/**\n * Visual treatment — 1:1 with Button's variant axis. OAuthButton is a thin\n * wrapper over Button, so every variant renders pixel-for-pixel identical\n * to a regular Button at the same variant + size. Brand identity lives in\n * the glyph (override via `icon` for a brand-multicolour SVG), not the\n * button surface.\n *\n * - `solid` (default) | `soft` | `outline` | `ghost`\n */\nexport type OAuthVariant = 'solid' | 'soft' | 'outline' | 'ghost'\n\n/** @deprecated Use `OAuthVariant`. brand/dark map to solid; outline passes through. */\nexport type OAuthAppearance = 'brand' | 'outline' | 'dark'\n\n// ── Static metadata ─────────────────────────────────────────────\n\nconst providerDisplay: Record<OAuthProvider, string> = {\n google: 'Google',\n apple: 'Apple',\n github: 'GitHub',\n microsoft: 'Microsoft',\n x: 'X',\n linkedin: 'LinkedIn',\n facebook: 'Facebook',\n discord: 'Discord',\n slack: 'Slack',\n gitlab: 'GitLab',\n sso: 'SSO',\n email: 'email',\n passkey: 'a passkey',\n}\n\n// Default glyph per provider — sourced from Tabler (already a peer dep).\n// Consumer can override with the `icon` prop to drop in a brand-multicolour SVG.\nconst providerIcon: Record<OAuthProvider, React.ComponentType<{ size?: number | string; 'aria-hidden'?: boolean }>> = {\n google: IconBrandGoogleFilled,\n apple: IconBrandApple,\n github: IconBrandGithub,\n microsoft: IconBrandWindows,\n x: IconBrandXFilled,\n linkedin: IconBrandLinkedin,\n facebook: IconBrandFacebook,\n discord: IconBrandDiscord,\n slack: IconBrandSlack,\n gitlab: IconBrandGitlab,\n sso: IconKey,\n email: IconMail,\n passkey: IconFingerprint,\n}\n\nfunction providerName(provider: OAuthProvider): string {\n // Display name for `compact` mode — drops the \"a\" article on passkey.\n return provider === 'passkey' ? 'Passkey' : providerDisplay[provider]\n}\n\nfunction defaultLabel(provider: OAuthProvider, intent: OAuthIntent, compact: boolean): string {\n if (compact) return providerName(provider)\n const name = providerDisplay[provider]\n switch (intent) {\n case 'signin':\n return `Sign in with ${name}`\n case 'signup':\n return `Sign up with ${name}`\n case 'continue':\n default:\n return `Continue with ${name}`\n }\n}\n\nconst providerCopyOverride: Partial<Record<OAuthProvider, Partial<Record<OAuthIntent, string>>>> = {\n passkey: {\n continue: 'Continue with a passkey',\n signin: 'Sign in with a passkey',\n signup: 'Create a passkey',\n },\n}\n\nfunction resolveLabel(provider: OAuthProvider, intent: OAuthIntent, compact: boolean): string {\n if (compact) return providerName(provider)\n return providerCopyOverride[provider]?.[intent] ?? defaultLabel(provider, intent, compact)\n}\n\n/** Long-form name used for aria-label even when compact label is rendered. */\nfunction resolveAriaName(provider: OAuthProvider, intent: OAuthIntent): string {\n return providerCopyOverride[provider]?.[intent] ?? defaultLabel(provider, intent, false)\n}\n\n// **Visual treatment:** OAuthButton is a thin wrapper over `<Button>` — every\n// height, padding, radius, border, hover, focus, active, and disabled state is\n// the DS Button's. We do NOT inject per-provider hex backgrounds: brand\n// identity lives in the glyph (Tabler default; consumer can pass a real\n// multicolour SVG via `icon`). This guarantees pixel-for-pixel consistency\n// with every other button in the system at every variant.\n\nconst ICON_PX: Record<string, number> = {\n xs: 14,\n sm: 16,\n md: 18,\n lg: 20,\n 'compact-xs': 14,\n 'compact-sm': 14,\n 'compact-md': 16,\n icon: 18,\n 'icon-xs': 14,\n 'icon-sm': 16,\n 'icon-md': 18,\n 'icon-lg': 20,\n}\n\nconst ICON_ONLY_SIZE: Record<string, NonNullable<ButtonProps['size']>> = {\n xs: 'icon-xs',\n sm: 'icon-sm',\n md: 'icon-md',\n lg: 'icon-lg',\n 'compact-xs': 'icon-xs',\n 'compact-sm': 'icon-sm',\n 'compact-md': 'icon-md',\n}\n\n// ── Component ───────────────────────────────────────────────────\n\n/**\n * Props for `OAuthButton` — a brand-aware sign-in button for OAuth providers.\n *\n * Composes on top of `<Button>`, inheriting `size`, `loading`, `onClickAsync`,\n * `fullWidth`, and async state machinery. The provider's icon, label, and\n * brand-coloured styling are derived from the `provider` prop.\n *\n * **Provider** (required): includes 10 social providers + 3 generic\n * identifiers (`sso` enterprise, `email` magic-link, `passkey` WebAuthn).\n *\n * **Intent**: drives the verb in the label.\n * - `continue` (default) — \"Continue with Google\" — works on login and signup.\n * - `signin` — \"Sign in with Google\".\n * - `signup` — \"Sign up with Google\".\n *\n * **Appearance**: visual treatment.\n * - `brand` (default) — provider's brand background colour.\n * - `outline` — DS-neutral outline with monochrome glyph. Best for uniform rows.\n * - `dark` — unified Apple-style across all providers for visual consistency.\n *\n * **icon**: override the default Tabler glyph (e.g. drop in the provider's\n * official multicolour SVG downloaded from their brand page).\n *\n * **iconOnly**: render a square icon button. Provider name kept in `aria-label`.\n *\n * **lastUsed**: shows a small \"Last used\" pill above the button — high-converting\n * UX hint. Consumer tracks which provider the user picked previously.\n *\n * **helperText**: optional reassurance copy rendered below the button.\n *\n * @example\n * <OAuthButton provider=\"google\" intent=\"continue\" fullWidth onClickAsync={signInWithGoogle} />\n *\n * @example\n * // True brand-multicolour glyph:\n * <OAuthButton provider=\"google\" icon={<GoogleGSvg />} />\n *\n * @example\n * <OAuthGroup>\n * <OAuthButton provider=\"google\" appearance=\"dark\" />\n * <OAuthButton provider=\"apple\" appearance=\"dark\" />\n * <OAuthButton provider=\"github\" appearance=\"dark\" />\n * </OAuthGroup>\n */\nexport interface OAuthButtonProps\n extends Omit<\n ButtonProps,\n 'variant' | 'color' | 'startIcon' | 'endIcon' | 'shape' | 'children'\n > {\n /** OAuth provider this button represents */\n provider: OAuthProvider\n /** Verb in the default label. Default: `continue` */\n intent?: OAuthIntent\n /**\n * Visual treatment. Default: `solid`. Mirrors Button's variant axis with\n * an extra `dark` for row coherence across providers.\n */\n variant?: OAuthVariant\n /** @deprecated Use `variant`. `appearance=\"brand\"` maps to `variant=\"solid\"`. */\n appearance?: OAuthAppearance\n /** Override the default glyph (e.g. brand-multicolour SVG). Accepts any `IconInput`. */\n icon?: IconInput\n /** Render a compact icon-only button (provider name kept in aria-label) */\n iconOnly?: boolean\n /**\n * Short label — renders just the provider name (\"Google\") instead of the\n * full \"Continue with Google\". Use under an explicit \"Or sign in with\"\n * divider where the verb is already established. aria-label still gets the\n * full long form for screen readers.\n */\n compact?: boolean\n /**\n * Show \"Last used\" hint — a small pill anchored to the top-right corner of\n * the button (sits ON the corner, half outside the button bounds).\n */\n lastUsed?: boolean\n /**\n * Customise the \"Last used\" badge. Pass a ReactNode to replace the entire\n * pill (use this for custom copy, icons, or styling), or a render fn that\n * receives the default props for tweaks. Only rendered when `lastUsed` is\n * also set so the wrapper / aria augmentation logic stays consistent.\n *\n * @example\n * <OAuthButton provider=\"google\" lastUsed lastUsedSlot={<MyBadge />} />\n */\n lastUsedSlot?: React.ReactNode | ((defaults: { label: string }) => React.ReactNode)\n /** Override the visible badge label text. Default: \"Last used\". */\n lastUsedLabel?: string\n /** Reassurance copy rendered below the button */\n helperText?: React.ReactNode\n /** Override the default label entirely (i18n / custom copy) */\n children?: React.ReactNode\n}\n\nconst OAuthButton = React.forwardRef<HTMLButtonElement, OAuthButtonProps>(\n (\n {\n provider,\n intent = 'continue',\n variant: variantProp,\n appearance,\n icon,\n iconOnly = false,\n compact = false,\n lastUsed = false,\n lastUsedSlot,\n lastUsedLabel = 'Last used',\n helperText,\n children,\n className,\n size: sizeProp,\n fullWidth = false,\n ...buttonProps\n },\n ref,\n ) => {\n const size: NonNullable<ButtonProps['size']> = sizeProp ?? 'md'\n const DefaultGlyph = providerIcon[provider]\n const iconPx = ICON_PX[size] ?? 18\n const glyphNode = normalizeIcon(icon) ?? <DefaultGlyph size={iconPx} aria-hidden />\n const label = children ?? resolveLabel(provider, intent, compact)\n\n // Resolve final variant. `appearance` is a deprecated alias mapped to\n // the closest DS variant — brand/dark both collapse to solid since\n // OAuthButton no longer injects per-provider brand colours.\n const variant: OAuthVariant =\n variantProp ??\n (appearance === 'outline' ? 'outline' : 'solid')\n\n // aria-label always carries the long-form name so screen readers stay\n // informative even when the visual label is compact or icon-only.\n const longName = resolveAriaName(provider, intent)\n const ariaLabelForButton = iconOnly || compact || lastUsed\n ? `${longName}${lastUsed ? ' (last used)' : ''}`\n : undefined\n\n // \"Last used\" badge — sits ON the top-right corner of the button,\n // overlapping the button edge for the classic \"notification badge\"\n // look. Rendered as a SIBLING to Button (not a child) because Button's\n // `overflow-hidden` would clip a child poking outside the corner.\n //\n // Composable: pass `lastUsedSlot` (ReactNode or render fn) to replace\n // the default pill. `lastUsedLabel` swaps just the text inside it.\n // aria-label augments the accessible name with \"(last used)\".\n const defaultBadge = (\n <span className=\"pointer-events-none inline-flex items-center rounded-pill bg-accent-9 text-accent-fg px-2 py-1 text-[9px] leading-none font-semibold uppercase tracking-wide shadow-overlay\">\n {lastUsedLabel}\n </span>\n )\n const customBadge =\n typeof lastUsedSlot === 'function' ? lastUsedSlot({ label: lastUsedLabel }) : lastUsedSlot\n const renderedBadge = customBadge ?? defaultBadge\n\n const buttonEl = (\n <Button\n ref={ref}\n variant={variant}\n color=\"neutral\"\n size={iconOnly ? ICON_ONLY_SIZE[size] ?? 'icon-md' : size}\n fullWidth={fullWidth && !iconOnly}\n startIcon={iconOnly ? undefined : (glyphNode as React.ReactElement)}\n aria-label={ariaLabelForButton}\n data-provider={provider}\n data-oauth-variant={variant}\n data-last-used={lastUsed || undefined}\n className={className}\n {...buttonProps}\n >\n {iconOnly ? glyphNode : label}\n </Button>\n )\n\n const showBadge = lastUsed && !iconOnly\n if (!showBadge && !helperText) return buttonEl\n\n return (\n <div className={cn('relative inline-flex flex-col', fullWidth && 'w-full')}>\n {buttonEl}\n {showBadge ? (\n <span\n aria-hidden=\"true\"\n data-last-used-badge=\"\"\n className=\"pointer-events-none absolute -top-[10px] -right-2 z-10\"\n >\n {renderedBadge}\n </span>\n ) : null}\n {helperText ? (\n <span className=\"mt-ds-02 text-ds-sm text-surface-fg-subtle\">{helperText}</span>\n ) : null}\n </div>\n )\n },\n)\nOAuthButton.displayName = 'OAuthButton'\n\nexport { OAuthButton }\n\n// ── OAuthGroup ─────────────────────────────────────────────────\n\nexport interface OAuthGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Layout. `vertical` (default) stacks full-width buttons. */\n orientation?: 'vertical' | 'horizontal'\n /** Gap token between buttons. Default: `ds-03` */\n gap?: 'ds-02' | 'ds-03' | 'ds-04'\n /** Stretch children to fill width (vertical only). Default: true */\n fullWidth?: boolean\n /**\n * Move any child with `lastUsed` to position 0. Stripe-style ordering — the\n * provider the user picked last time becomes the top option, which gives a\n * stronger conversion lift than a \"Last used\" badge does on its own.\n * Default: false (preserve source order).\n */\n reorderLastUsedFirst?: boolean\n}\n\n/**\n * Stacked layout wrapper for OAuth buttons with consistent spacing. Defaults to\n * vertical, full-width children — the dominant sign-in pattern. For an icon-only\n * row, set `orientation=\"horizontal\"` and use `<OAuthButton iconOnly />`.\n */\nconst OAuthGroup = React.forwardRef<HTMLDivElement, OAuthGroupProps>(\n (\n {\n orientation = 'vertical',\n gap = 'ds-03',\n fullWidth = true,\n reorderLastUsedFirst = false,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const gapClass =\n gap === 'ds-02' ? 'gap-ds-02' : gap === 'ds-04' ? 'gap-ds-04' : 'gap-ds-03'\n const stretch = orientation === 'vertical' && fullWidth\n\n const ordered = React.useMemo(() => {\n if (!reorderLastUsedFirst) return children\n const arr = React.Children.toArray(children)\n const lastUsedIdx = arr.findIndex(\n (c) => React.isValidElement(c) && (c.props as { lastUsed?: boolean })?.lastUsed,\n )\n if (lastUsedIdx <= 0) return children\n const next = [...arr]\n const [pulled] = next.splice(lastUsedIdx, 1)\n next.unshift(pulled)\n return next\n }, [children, reorderLastUsedFirst])\n\n return (\n <div\n ref={ref}\n className={cn(\n 'flex',\n orientation === 'vertical' ? 'flex-col' : 'flex-row flex-wrap items-center',\n gapClass,\n // Force both the direct wrapper AND the leaf <button> to stretch.\n // OAuthButton's outer wrapper picks up [&>*]:w-full; the button itself\n // sits two layers deep when a helperText wrapper exists, so\n // [&_button]:w-full covers both cases (wrapped + unwrapped) without\n // affecting unrelated descendants — only Buttons live inside.\n stretch && 'w-full [&>*]:w-full [&_button]:w-full',\n className,\n )}\n {...props}\n >\n {ordered}\n </div>\n )\n },\n)\nOAuthGroup.displayName = 'OAuthGroup'\n\nexport { OAuthGroup }\n\n// ── OAuthDivider ───────────────────────────────────────────────\n\nexport interface OAuthDividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Text between the rules. Default: \"or\" */\n label?: React.ReactNode\n}\n\nconst OAuthDivider = React.forwardRef<HTMLDivElement, OAuthDividerProps>(\n ({ label = 'or', className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"separator\"\n aria-orientation=\"horizontal\"\n className={cn('flex items-center gap-ds-03', className)}\n {...props}\n >\n <hr aria-hidden=\"true\" className=\"flex-1 border-t border-surface-border-subtle\" />\n <span className=\"text-ds-sm text-surface-fg-subtle uppercase tracking-wide\">{label}</span>\n <hr aria-hidden=\"true\" className=\"flex-1 border-t border-surface-border-subtle\" />\n </div>\n ),\n)\nOAuthDivider.displayName = 'OAuthDivider'\n\nexport { OAuthDivider }\n\n// ── OAuthConnectionRow (settings page — linked state) ──────────\n\nexport interface OAuthConnectionRowProps extends React.HTMLAttributes<HTMLDivElement> {\n provider: OAuthProvider\n /** Optional account identifier shown next to the provider name (e.g. email) */\n accountLabel?: React.ReactNode\n /** Whether the provider is currently linked */\n connected: boolean\n /** Click handler for the connect/disconnect action */\n onAction?: (e: React.MouseEvent<HTMLButtonElement>) => void\n /** Promise-returning click handler — uses Button's async state machine */\n onActionAsync?: (e: React.MouseEvent<HTMLButtonElement>) => Promise<void>\n /** Override the action label */\n actionLabel?: React.ReactNode\n /** Disable the action button */\n disabled?: boolean\n /** Override the default glyph. Accepts any `IconInput`. */\n icon?: IconInput\n}\n\n/**\n * Settings-page row representing a linked OAuth provider. Different surface\n * from sign-in: this is an existing connection the user can disconnect or\n * (re-)connect. Renders glyph + provider name + optional account label + a\n * connect/disconnect button.\n */\nconst OAuthConnectionRow = React.forwardRef<HTMLDivElement, OAuthConnectionRowProps>(\n (\n {\n provider,\n accountLabel,\n connected,\n onAction,\n onActionAsync,\n actionLabel,\n disabled,\n icon,\n className,\n ...props\n },\n ref,\n ) => {\n const DefaultGlyph = providerIcon[provider]\n const name = providerDisplay[provider]\n const resolvedLabel = actionLabel ?? (connected ? 'Disconnect' : `Connect ${name}`)\n\n return (\n <div\n ref={ref}\n className={cn(\n 'flex items-center justify-between gap-ds-04 py-ds-04 px-ds-04 rounded-surface border border-surface-border bg-surface-raised',\n className,\n )}\n data-provider={provider}\n data-connected={connected ? 'true' : 'false'}\n {...props}\n >\n <div className=\"flex items-center gap-ds-03 min-w-0\">\n {normalizeIcon(icon) ?? <DefaultGlyph size={24} aria-hidden />}\n <div className=\"flex flex-col min-w-0\">\n <span className=\"text-ds-md font-semibold text-surface-fg truncate\">{name}</span>\n {accountLabel ? (\n <span className=\"text-ds-sm text-surface-fg-muted truncate\">{accountLabel}</span>\n ) : connected ? (\n <span className=\"text-ds-sm text-success-11\">Connected</span>\n ) : (\n <span className=\"text-ds-sm text-surface-fg-subtle\">Not connected</span>\n )}\n </div>\n </div>\n <Button\n size=\"sm\"\n variant={connected ? 'soft' : 'solid'}\n color={connected ? 'neutral' : 'accent'}\n disabled={disabled}\n onClick={onAction}\n onClickAsync={onActionAsync}\n >\n {resolvedLabel}\n </Button>\n </div>\n )\n },\n)\nOAuthConnectionRow.displayName = 'OAuthConnectionRow'\n\nexport { OAuthConnectionRow }\n\n// ── OAuthGlyph (atomic glyph render) ───────────────────────────\n\nexport interface OAuthGlyphProps extends Omit<React.SVGAttributes<SVGElement>, 'children'> {\n provider: OAuthProvider\n /** Glyph pixel size. Default 18. */\n size?: number\n}\n\n/**\n * Render just the provider glyph — useful when building a custom OAuth\n * trigger (e.g. an icon-button inside a Tooltip, or a provider chip on a\n * profile card). Defaults to the Tabler glyph; the icon prop on\n * `OAuthButton` is the right escape hatch for the brand multi-colour mark.\n */\nconst OAuthGlyph = React.forwardRef<SVGSVGElement, OAuthGlyphProps>(\n ({ provider, size = 18, ...props }, ref) => {\n const Cmp = providerIcon[provider] as React.ComponentType<{\n size?: number\n 'aria-hidden'?: boolean\n ref?: React.Ref<SVGSVGElement>\n }>\n return <Cmp ref={ref} size={size} aria-hidden {...(props as Record<string, unknown>)} />\n },\n)\nOAuthGlyph.displayName = 'OAuthGlyph'\n\nexport { OAuthGlyph }\n\n// ── Static helpers (composable building blocks) ────────────────\n\n/**\n * Resolve the visible label for a provider × intent combo. Useful when\n * rendering OAuth UIs outside of `OAuthButton` (e.g. a Confirm dialog\n * \"Disconnect from Google?\" title).\n */\nexport function getOAuthLabel(provider: OAuthProvider, intent: OAuthIntent = 'continue', compact = false): string {\n return resolveLabel(provider, intent, compact)\n}\n\n/** Display name for a provider, ready for sentence interpolation. */\nexport function getOAuthName(provider: OAuthProvider): string {\n return providerName(provider)\n}\n\n// ── Compound namespace ─────────────────────────────────────────\n\n/**\n * Namespaced API — drop-in alternative to importing each piece separately.\n *\n * @example\n * import { OAuth } from '@devalok/shilp-sutra/ui/oauth-button'\n *\n * <OAuth.Group reorderLastUsedFirst>\n * <OAuth.Button provider=\"google\" lastUsed />\n * <OAuth.Button provider=\"passkey\" />\n * <OAuth.Divider />\n * <OAuth.Button provider=\"sso\" variant=\"ghost\" />\n * </OAuth.Group>\n */\nexport const OAuth = {\n Button: OAuthButton,\n Group: OAuthGroup,\n Divider: OAuthDivider,\n ConnectionRow: OAuthConnectionRow,\n Glyph: OAuthGlyph,\n getLabel: getOAuthLabel,\n getName: getOAuthName,\n} as const\n"],"mappings":";;;;;;;AA2DA,IAAM,IAAiD;CACrD,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,GAAG;CACH,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO;CACP,QAAQ;CACR,KAAK;CACL,OAAO;CACP,SAAS;CACV,EAIK,IAAgH;CACpH,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,GAAG;CACH,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO;CACP,QAAQ;CACR,KAAK;CACL,OAAO;CACP,SAAS;CACV;AAED,SAAS,EAAa,GAAiC;AAErD,QAAO,MAAa,YAAY,YAAY,EAAgB;;AAG9D,SAAS,EAAa,GAAyB,GAAqB,GAA0B;AAC5F,KAAI,EAAS,QAAO,EAAa,EAAS;CAC1C,IAAM,IAAO,EAAgB;AAC7B,SAAQ,GAAR;EACE,KAAK,SACH,QAAO,gBAAgB;EACzB,KAAK,SACH,QAAO,gBAAgB;EAEzB,QACE,QAAO,iBAAiB;;;AAI9B,IAAM,IAA6F,EACjG,SAAS;CACP,UAAU;CACV,QAAQ;CACR,QAAQ;CACT,EACF;AAED,SAAS,EAAa,GAAyB,GAAqB,GAA0B;AAE5F,QADI,IAAgB,EAAa,EAAS,GACnC,EAAqB,KAAY,MAAW,EAAa,GAAU,GAAQ,EAAQ;;AAI5F,SAAS,EAAgB,GAAyB,GAA6B;AAC7E,QAAO,EAAqB,KAAY,MAAW,EAAa,GAAU,GAAQ,GAAM;;AAU1F,IAAM,IAAkC;CACtC,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,cAAc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AAS;CACV"}
1
+ {"version":3,"file":"oauth-button.js","names":[],"sources":["../../src/ui/oauth-button/oauth-button.tsx"],"sourcesContent":["'use client'\n\nimport {\n IconBrandApple,\n IconBrandDiscord,\n IconBrandFacebook,\n IconBrandGithub,\n IconBrandGitlab,\n IconBrandGoogleFilled,\n IconBrandLinkedin,\n IconBrandSlack,\n IconBrandWindows,\n IconBrandXFilled,\n IconFingerprint,\n IconKey,\n IconMail,\n} from '@tabler/icons-react'\nimport * as React from 'react'\n\nimport { Button, type ButtonProps } from '../button'\nimport type { IconInput } from '../lib/icon-input'\nimport { normalizeIcon } from '../lib/normalize-icon'\nimport { cn } from '../lib/utils'\nimport { TruncatedText } from '../truncated-text'\n\n// ── Types ───────────────────────────────────────────────────────\n\nexport type OAuthProvider =\n | 'google'\n | 'apple'\n | 'github'\n | 'microsoft'\n | 'x'\n | 'linkedin'\n | 'facebook'\n | 'discord'\n | 'slack'\n | 'gitlab'\n | 'sso'\n | 'email'\n | 'passkey'\n\nexport type OAuthIntent = 'continue' | 'signin' | 'signup'\n\n/**\n * Visual treatment — 1:1 with Button's variant axis. OAuthButton is a thin\n * wrapper over Button, so every variant renders pixel-for-pixel identical\n * to a regular Button at the same variant + size. Brand identity lives in\n * the glyph (override via `icon` for a brand-multicolour SVG), not the\n * button surface.\n *\n * - `solid` (default) | `soft` | `outline` | `ghost`\n */\nexport type OAuthVariant = 'solid' | 'soft' | 'outline' | 'ghost'\n\n/** @deprecated Use `OAuthVariant`. brand/dark map to solid; outline passes through. */\nexport type OAuthAppearance = 'brand' | 'outline' | 'dark'\n\n// ── Static metadata ─────────────────────────────────────────────\n\nconst providerDisplay: Record<OAuthProvider, string> = {\n google: 'Google',\n apple: 'Apple',\n github: 'GitHub',\n microsoft: 'Microsoft',\n x: 'X',\n linkedin: 'LinkedIn',\n facebook: 'Facebook',\n discord: 'Discord',\n slack: 'Slack',\n gitlab: 'GitLab',\n sso: 'SSO',\n email: 'email',\n passkey: 'a passkey',\n}\n\n// Default glyph per provider — sourced from Tabler (already a peer dep).\n// Consumer can override with the `icon` prop to drop in a brand-multicolour SVG.\nconst providerIcon: Record<OAuthProvider, React.ComponentType<{ size?: number | string; 'aria-hidden'?: boolean }>> = {\n google: IconBrandGoogleFilled,\n apple: IconBrandApple,\n github: IconBrandGithub,\n microsoft: IconBrandWindows,\n x: IconBrandXFilled,\n linkedin: IconBrandLinkedin,\n facebook: IconBrandFacebook,\n discord: IconBrandDiscord,\n slack: IconBrandSlack,\n gitlab: IconBrandGitlab,\n sso: IconKey,\n email: IconMail,\n passkey: IconFingerprint,\n}\n\nfunction providerName(provider: OAuthProvider): string {\n // Display name for `compact` mode — drops the \"a\" article on passkey.\n return provider === 'passkey' ? 'Passkey' : providerDisplay[provider]\n}\n\nfunction defaultLabel(provider: OAuthProvider, intent: OAuthIntent, compact: boolean): string {\n if (compact) return providerName(provider)\n const name = providerDisplay[provider]\n switch (intent) {\n case 'signin':\n return `Sign in with ${name}`\n case 'signup':\n return `Sign up with ${name}`\n case 'continue':\n default:\n return `Continue with ${name}`\n }\n}\n\nconst providerCopyOverride: Partial<Record<OAuthProvider, Partial<Record<OAuthIntent, string>>>> = {\n passkey: {\n continue: 'Continue with a passkey',\n signin: 'Sign in with a passkey',\n signup: 'Create a passkey',\n },\n}\n\nfunction resolveLabel(provider: OAuthProvider, intent: OAuthIntent, compact: boolean): string {\n if (compact) return providerName(provider)\n return providerCopyOverride[provider]?.[intent] ?? defaultLabel(provider, intent, compact)\n}\n\n/** Long-form name used for aria-label even when compact label is rendered. */\nfunction resolveAriaName(provider: OAuthProvider, intent: OAuthIntent): string {\n return providerCopyOverride[provider]?.[intent] ?? defaultLabel(provider, intent, false)\n}\n\n// **Visual treatment:** OAuthButton is a thin wrapper over `<Button>` — every\n// height, padding, radius, border, hover, focus, active, and disabled state is\n// the DS Button's. We do NOT inject per-provider hex backgrounds: brand\n// identity lives in the glyph (Tabler default; consumer can pass a real\n// multicolour SVG via `icon`). This guarantees pixel-for-pixel consistency\n// with every other button in the system at every variant.\n\nconst ICON_PX: Record<string, number> = {\n xs: 14,\n sm: 16,\n md: 18,\n lg: 20,\n 'compact-xs': 14,\n 'compact-sm': 14,\n 'compact-md': 16,\n icon: 18,\n 'icon-xs': 14,\n 'icon-sm': 16,\n 'icon-md': 18,\n 'icon-lg': 20,\n}\n\nconst ICON_ONLY_SIZE: Record<string, NonNullable<ButtonProps['size']>> = {\n xs: 'icon-xs',\n sm: 'icon-sm',\n md: 'icon-md',\n lg: 'icon-lg',\n 'compact-xs': 'icon-xs',\n 'compact-sm': 'icon-sm',\n 'compact-md': 'icon-md',\n}\n\n// ── Component ───────────────────────────────────────────────────\n\n/**\n * Props for `OAuthButton` — a brand-aware sign-in button for OAuth providers.\n *\n * Composes on top of `<Button>`, inheriting `size`, `loading`, `onClickAsync`,\n * `fullWidth`, and async state machinery. The provider's icon, label, and\n * brand-coloured styling are derived from the `provider` prop.\n *\n * **Provider** (required): includes 10 social providers + 3 generic\n * identifiers (`sso` enterprise, `email` magic-link, `passkey` WebAuthn).\n *\n * **Intent**: drives the verb in the label.\n * - `continue` (default) — \"Continue with Google\" — works on login and signup.\n * - `signin` — \"Sign in with Google\".\n * - `signup` — \"Sign up with Google\".\n *\n * **Appearance**: visual treatment.\n * - `brand` (default) — provider's brand background colour.\n * - `outline` — DS-neutral outline with monochrome glyph. Best for uniform rows.\n * - `dark` — unified Apple-style across all providers for visual consistency.\n *\n * **icon**: override the default Tabler glyph (e.g. drop in the provider's\n * official multicolour SVG downloaded from their brand page).\n *\n * **iconOnly**: render a square icon button. Provider name kept in `aria-label`.\n *\n * **lastUsed**: shows a small \"Last used\" pill above the button — high-converting\n * UX hint. Consumer tracks which provider the user picked previously.\n *\n * **helperText**: optional reassurance copy rendered below the button.\n *\n * @example\n * <OAuthButton provider=\"google\" intent=\"continue\" fullWidth onClickAsync={signInWithGoogle} />\n *\n * @example\n * // True brand-multicolour glyph:\n * <OAuthButton provider=\"google\" icon={<GoogleGSvg />} />\n *\n * @example\n * <OAuthGroup>\n * <OAuthButton provider=\"google\" appearance=\"dark\" />\n * <OAuthButton provider=\"apple\" appearance=\"dark\" />\n * <OAuthButton provider=\"github\" appearance=\"dark\" />\n * </OAuthGroup>\n */\nexport interface OAuthButtonProps\n extends Omit<\n ButtonProps,\n 'variant' | 'color' | 'startIcon' | 'endIcon' | 'shape' | 'children'\n > {\n /** OAuth provider this button represents */\n provider: OAuthProvider\n /** Verb in the default label. Default: `continue` */\n intent?: OAuthIntent\n /**\n * Visual treatment. Default: `solid`. Mirrors Button's variant axis with\n * an extra `dark` for row coherence across providers.\n */\n variant?: OAuthVariant\n /** @deprecated Use `variant`. `appearance=\"brand\"` maps to `variant=\"solid\"`. */\n appearance?: OAuthAppearance\n /** Override the default glyph (e.g. brand-multicolour SVG). Accepts any `IconInput`. */\n icon?: IconInput\n /** Render a compact icon-only button (provider name kept in aria-label) */\n iconOnly?: boolean\n /**\n * Short label — renders just the provider name (\"Google\") instead of the\n * full \"Continue with Google\". Use under an explicit \"Or sign in with\"\n * divider where the verb is already established. aria-label still gets the\n * full long form for screen readers.\n */\n compact?: boolean\n /**\n * Show \"Last used\" hint — a small pill anchored to the top-right corner of\n * the button (sits ON the corner, half outside the button bounds).\n */\n lastUsed?: boolean\n /**\n * Customise the \"Last used\" badge. Pass a ReactNode to replace the entire\n * pill (use this for custom copy, icons, or styling), or a render fn that\n * receives the default props for tweaks. Only rendered when `lastUsed` is\n * also set so the wrapper / aria augmentation logic stays consistent.\n *\n * @example\n * <OAuthButton provider=\"google\" lastUsed lastUsedSlot={<MyBadge />} />\n */\n lastUsedSlot?: React.ReactNode | ((defaults: { label: string }) => React.ReactNode)\n /** Override the visible badge label text. Default: \"Last used\". */\n lastUsedLabel?: string\n /** Reassurance copy rendered below the button */\n helperText?: React.ReactNode\n /** Override the default label entirely (i18n / custom copy) */\n children?: React.ReactNode\n}\n\nconst OAuthButton = React.forwardRef<HTMLButtonElement, OAuthButtonProps>(\n (\n {\n provider,\n intent = 'continue',\n variant: variantProp,\n appearance,\n icon,\n iconOnly = false,\n compact = false,\n lastUsed = false,\n lastUsedSlot,\n lastUsedLabel = 'Last used',\n helperText,\n children,\n className,\n size: sizeProp,\n fullWidth = false,\n ...buttonProps\n },\n ref,\n ) => {\n const size: NonNullable<ButtonProps['size']> = sizeProp ?? 'md'\n const DefaultGlyph = providerIcon[provider]\n const iconPx = ICON_PX[size] ?? 18\n const glyphNode = normalizeIcon(icon) ?? <DefaultGlyph size={iconPx} aria-hidden />\n const label = children ?? resolveLabel(provider, intent, compact)\n\n // Resolve final variant. `appearance` is a deprecated alias mapped to\n // the closest DS variant — brand/dark both collapse to solid since\n // OAuthButton no longer injects per-provider brand colours.\n const variant: OAuthVariant =\n variantProp ??\n (appearance === 'outline' ? 'outline' : 'solid')\n\n // aria-label always carries the long-form name so screen readers stay\n // informative even when the visual label is compact or icon-only.\n const longName = resolveAriaName(provider, intent)\n const ariaLabelForButton = iconOnly || compact || lastUsed\n ? `${longName}${lastUsed ? ' (last used)' : ''}`\n : undefined\n\n // \"Last used\" badge — sits ON the top-right corner of the button,\n // overlapping the button edge for the classic \"notification badge\"\n // look. Rendered as a SIBLING to Button (not a child) because Button's\n // `overflow-hidden` would clip a child poking outside the corner.\n //\n // Composable: pass `lastUsedSlot` (ReactNode or render fn) to replace\n // the default pill. `lastUsedLabel` swaps just the text inside it.\n // aria-label augments the accessible name with \"(last used)\".\n // intentional: a 9px corner pill, smaller than Badge's smallest size (xs).\n // Not worth a sub-xs Badge size for one call site — kept as a documented exception.\n const defaultBadge = (\n <span className=\"pointer-events-none inline-flex items-center rounded-pill bg-accent-9 text-accent-fg px-2 py-1 text-ds-2xs leading-none font-semibold uppercase tracking-wide shadow-overlay\">\n {lastUsedLabel}\n </span>\n )\n const customBadge =\n typeof lastUsedSlot === 'function' ? lastUsedSlot({ label: lastUsedLabel }) : lastUsedSlot\n const renderedBadge = customBadge ?? defaultBadge\n\n const buttonEl = (\n <Button\n ref={ref}\n variant={variant}\n color=\"neutral\"\n size={iconOnly ? ICON_ONLY_SIZE[size] ?? 'icon-md' : size}\n fullWidth={fullWidth && !iconOnly}\n startIcon={iconOnly ? undefined : (glyphNode as React.ReactElement)}\n aria-label={ariaLabelForButton}\n data-provider={provider}\n data-oauth-variant={variant}\n data-last-used={lastUsed || undefined}\n className={className}\n {...buttonProps}\n >\n {iconOnly ? glyphNode : label}\n </Button>\n )\n\n const showBadge = lastUsed && !iconOnly\n if (!showBadge && !helperText) return buttonEl\n\n return (\n <div className={cn('relative inline-flex flex-col', fullWidth && 'w-full')}>\n {buttonEl}\n {showBadge ? (\n <span\n aria-hidden=\"true\"\n data-last-used-badge=\"\"\n className=\"pointer-events-none absolute -top-[10px] -right-2 z-10\"\n >\n {renderedBadge}\n </span>\n ) : null}\n {helperText ? (\n <span className=\"mt-ds-02 text-ds-sm text-surface-fg-subtle\">{helperText}</span>\n ) : null}\n </div>\n )\n },\n)\nOAuthButton.displayName = 'OAuthButton'\n\nexport { OAuthButton }\n\n// ── OAuthGroup ─────────────────────────────────────────────────\n\nexport interface OAuthGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Layout. `vertical` (default) stacks full-width buttons. */\n orientation?: 'vertical' | 'horizontal'\n /** Gap token between buttons. Default: `ds-03` */\n gap?: 'ds-02' | 'ds-03' | 'ds-04'\n /** Stretch children to fill width (vertical only). Default: true */\n fullWidth?: boolean\n /**\n * Move any child with `lastUsed` to position 0. Stripe-style ordering — the\n * provider the user picked last time becomes the top option, which gives a\n * stronger conversion lift than a \"Last used\" badge does on its own.\n * Default: false (preserve source order).\n */\n reorderLastUsedFirst?: boolean\n}\n\n/**\n * Stacked layout wrapper for OAuth buttons with consistent spacing. Defaults to\n * vertical, full-width children — the dominant sign-in pattern. For an icon-only\n * row, set `orientation=\"horizontal\"` and use `<OAuthButton iconOnly />`.\n */\nconst OAuthGroup = React.forwardRef<HTMLDivElement, OAuthGroupProps>(\n (\n {\n orientation = 'vertical',\n gap = 'ds-03',\n fullWidth = true,\n reorderLastUsedFirst = false,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const gapClass =\n gap === 'ds-02' ? 'gap-ds-02' : gap === 'ds-04' ? 'gap-ds-04' : 'gap-ds-03'\n const stretch = orientation === 'vertical' && fullWidth\n\n const ordered = React.useMemo(() => {\n if (!reorderLastUsedFirst) return children\n const arr = React.Children.toArray(children)\n const lastUsedIdx = arr.findIndex(\n (c) => React.isValidElement(c) && (c.props as { lastUsed?: boolean })?.lastUsed,\n )\n if (lastUsedIdx <= 0) return children\n const next = [...arr]\n const [pulled] = next.splice(lastUsedIdx, 1)\n next.unshift(pulled)\n return next\n }, [children, reorderLastUsedFirst])\n\n return (\n <div\n ref={ref}\n className={cn(\n 'flex',\n orientation === 'vertical' ? 'flex-col' : 'flex-row flex-wrap items-center',\n gapClass,\n // Force both the direct wrapper AND the leaf <button> to stretch.\n // OAuthButton's outer wrapper picks up [&>*]:w-full; the button itself\n // sits two layers deep when a helperText wrapper exists, so\n // [&_button]:w-full covers both cases (wrapped + unwrapped) without\n // affecting unrelated descendants — only Buttons live inside.\n stretch && 'w-full [&>*]:w-full [&_button]:w-full',\n className,\n )}\n {...props}\n >\n {ordered}\n </div>\n )\n },\n)\nOAuthGroup.displayName = 'OAuthGroup'\n\nexport { OAuthGroup }\n\n// ── OAuthDivider ───────────────────────────────────────────────\n\nexport interface OAuthDividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Text between the rules. Default: \"or\" */\n label?: React.ReactNode\n}\n\nconst OAuthDivider = React.forwardRef<HTMLDivElement, OAuthDividerProps>(\n ({ label = 'or', className, ...props }, ref) => (\n <div\n ref={ref}\n role=\"separator\"\n aria-orientation=\"horizontal\"\n className={cn('flex items-center gap-ds-03', className)}\n {...props}\n >\n <hr aria-hidden=\"true\" className=\"flex-1 border-t border-surface-border-subtle\" />\n <span className=\"text-ds-sm text-surface-fg-subtle uppercase tracking-wide\">{label}</span>\n <hr aria-hidden=\"true\" className=\"flex-1 border-t border-surface-border-subtle\" />\n </div>\n ),\n)\nOAuthDivider.displayName = 'OAuthDivider'\n\nexport { OAuthDivider }\n\n// ── OAuthConnectionRow (settings page — linked state) ──────────\n\nexport interface OAuthConnectionRowProps extends React.HTMLAttributes<HTMLDivElement> {\n provider: OAuthProvider\n /** Optional account identifier shown next to the provider name (e.g. email) */\n accountLabel?: React.ReactNode\n /** Whether the provider is currently linked */\n connected: boolean\n /** Click handler for the connect/disconnect action */\n onAction?: (e: React.MouseEvent<HTMLButtonElement>) => void\n /** Promise-returning click handler — uses Button's async state machine */\n onActionAsync?: (e: React.MouseEvent<HTMLButtonElement>) => Promise<void>\n /** Override the action label */\n actionLabel?: React.ReactNode\n /** Disable the action button */\n disabled?: boolean\n /** Override the default glyph. Accepts any `IconInput`. */\n icon?: IconInput\n}\n\n/**\n * Settings-page row representing a linked OAuth provider. Different surface\n * from sign-in: this is an existing connection the user can disconnect or\n * (re-)connect. Renders glyph + provider name + optional account label + a\n * connect/disconnect button.\n */\nconst OAuthConnectionRow = React.forwardRef<HTMLDivElement, OAuthConnectionRowProps>(\n (\n {\n provider,\n accountLabel,\n connected,\n onAction,\n onActionAsync,\n actionLabel,\n disabled,\n icon,\n className,\n ...props\n },\n ref,\n ) => {\n const DefaultGlyph = providerIcon[provider]\n const name = providerDisplay[provider]\n const resolvedLabel = actionLabel ?? (connected ? 'Disconnect' : `Connect ${name}`)\n\n return (\n <div\n ref={ref}\n className={cn(\n 'flex items-center justify-between gap-ds-04 py-ds-04 px-ds-04 rounded-surface border border-surface-border bg-surface-raised',\n className,\n )}\n data-provider={provider}\n data-connected={connected ? 'true' : 'false'}\n {...props}\n >\n <div className=\"flex items-center gap-ds-03 min-w-0\">\n {normalizeIcon(icon) ?? <DefaultGlyph size={24} aria-hidden />}\n <div className=\"flex flex-col min-w-0\">\n <TruncatedText className=\"text-ds-md font-semibold text-surface-fg\">{name}</TruncatedText>\n {accountLabel ? (\n // Account labels are usually an email — middle-truncate to keep the domain.\n // Only a string can be measured/truncated; fall back to a plain clip otherwise.\n typeof accountLabel === 'string' ? (\n <TruncatedText mode=\"middle\" className=\"text-ds-sm text-surface-fg-muted\">\n {accountLabel}\n </TruncatedText>\n ) : (\n <span className=\"text-ds-sm text-surface-fg-muted truncate\">{accountLabel}</span>\n )\n ) : connected ? (\n <span className=\"text-ds-sm text-success-11\">Connected</span>\n ) : (\n <span className=\"text-ds-sm text-surface-fg-subtle\">Not connected</span>\n )}\n </div>\n </div>\n <Button\n size=\"sm\"\n variant={connected ? 'soft' : 'solid'}\n color={connected ? 'neutral' : 'accent'}\n disabled={disabled}\n onClick={onAction}\n onClickAsync={onActionAsync}\n >\n {resolvedLabel}\n </Button>\n </div>\n )\n },\n)\nOAuthConnectionRow.displayName = 'OAuthConnectionRow'\n\nexport { OAuthConnectionRow }\n\n// ── OAuthGlyph (atomic glyph render) ───────────────────────────\n\nexport interface OAuthGlyphProps extends Omit<React.SVGAttributes<SVGElement>, 'children'> {\n provider: OAuthProvider\n /** Glyph pixel size. Default 18. */\n size?: number\n}\n\n/**\n * Render just the provider glyph — useful when building a custom OAuth\n * trigger (e.g. an icon-button inside a Tooltip, or a provider chip on a\n * profile card). Defaults to the Tabler glyph; the icon prop on\n * `OAuthButton` is the right escape hatch for the brand multi-colour mark.\n */\nconst OAuthGlyph = React.forwardRef<SVGSVGElement, OAuthGlyphProps>(\n ({ provider, size = 18, ...props }, ref) => {\n const Cmp = providerIcon[provider] as React.ComponentType<{\n size?: number\n 'aria-hidden'?: boolean\n ref?: React.Ref<SVGSVGElement>\n }>\n return <Cmp ref={ref} size={size} aria-hidden {...(props as Record<string, unknown>)} />\n },\n)\nOAuthGlyph.displayName = 'OAuthGlyph'\n\nexport { OAuthGlyph }\n\n// ── Static helpers (composable building blocks) ────────────────\n\n/**\n * Resolve the visible label for a provider × intent combo. Useful when\n * rendering OAuth UIs outside of `OAuthButton` (e.g. a Confirm dialog\n * \"Disconnect from Google?\" title).\n */\nexport function getOAuthLabel(provider: OAuthProvider, intent: OAuthIntent = 'continue', compact = false): string {\n return resolveLabel(provider, intent, compact)\n}\n\n/** Display name for a provider, ready for sentence interpolation. */\nexport function getOAuthName(provider: OAuthProvider): string {\n return providerName(provider)\n}\n\n// ── Compound namespace ─────────────────────────────────────────\n\n/**\n * Namespaced API — drop-in alternative to importing each piece separately.\n *\n * @example\n * import { OAuth } from '@devalok/shilp-sutra/ui/oauth-button'\n *\n * <OAuth.Group reorderLastUsedFirst>\n * <OAuth.Button provider=\"google\" lastUsed />\n * <OAuth.Button provider=\"passkey\" />\n * <OAuth.Divider />\n * <OAuth.Button provider=\"sso\" variant=\"ghost\" />\n * </OAuth.Group>\n */\nexport const OAuth = {\n Button: OAuthButton,\n Group: OAuthGroup,\n Divider: OAuthDivider,\n ConnectionRow: OAuthConnectionRow,\n Glyph: OAuthGlyph,\n getLabel: getOAuthLabel,\n getName: getOAuthName,\n} as const\n"],"mappings":";;;;;;;;AA4DA,IAAM,IAAiD;CACrD,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,GAAG;CACH,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO;CACP,QAAQ;CACR,KAAK;CACL,OAAO;CACP,SAAS;CACV,EAIK,IAAgH;CACpH,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,GAAG;CACH,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO;CACP,QAAQ;CACR,KAAK;CACL,OAAO;CACP,SAAS;CACV;AAED,SAAS,EAAa,GAAiC;AAErD,QAAO,MAAa,YAAY,YAAY,EAAgB;;AAG9D,SAAS,EAAa,GAAyB,GAAqB,GAA0B;AAC5F,KAAI,EAAS,QAAO,EAAa,EAAS;CAC1C,IAAM,IAAO,EAAgB;AAC7B,SAAQ,GAAR;EACE,KAAK,SACH,QAAO,gBAAgB;EACzB,KAAK,SACH,QAAO,gBAAgB;EAEzB,QACE,QAAO,iBAAiB;;;AAI9B,IAAM,IAA6F,EACjG,SAAS;CAC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AAM,YACtB,EAAE,aAAU,UAAO,IAAI,GAAG,KAAS,MAAQ;CAC1C,IAAM,IAAM,EAAa;AAKzB,QAAO,kBAAC,GAAD;EAAU;EAAW;EAAM,eAAA;EAAY,GAAK;EAAqC,CAAA;EAE3F;AACD,EAAW,cAAc;AAWzB,SAAgB,EAAc,GAAyB,IAAsB,YAAY,IAAU,IAAe;AAChH,QAAO,EAAa,GAAU,GAAQ,EAAQ;;AAIhD,SAAgB,EAAa,GAAiC;AAC5D,QAAO,EAAa,EAAS;;AAkB/B,IAAa,IAAQ;CACnB,QAAQ;CACR,OAAO;CACP,SAAS;CACT,eAAe;CACf,OAAO;CACP,UAAU;CACV,SAAS;CACV"}
@@ -211,7 +211,7 @@ var _ = a.forwardRef(({ itemId: o, label: s, icon: d, secondaryLabel: f, actions
211
211
  })
212
212
  }),
213
213
  /* @__PURE__ */ c("span", {
214
- className: "truncate text-ds-sm",
214
+ className: "min-w-0 truncate text-ds-sm",
215
215
  children: s
216
216
  }),
217
217
  f && /* @__PURE__ */ c("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"tree-view.js","names":[],"sources":["../../src/ui/tree-view/use-tree.ts","../../src/ui/tree-view/tree-view.tsx","../../src/ui/tree-view/tree-item.tsx"],"sourcesContent":["import { useCallback,useState } from 'react'\n\nimport type { IconInput } from '../lib/icon-input'\n\nexport interface TreeNode {\n id: string\n label: string\n icon?: IconInput\n children?: TreeNode[]\n disabled?: boolean\n}\n\ninterface UseTreeOptions {\n defaultExpanded?: string[]\n defaultSelected?: string[]\n multiSelect?: boolean\n onSelect?: (selectedIds: string[]) => void\n onExpand?: (expandedIds: string[]) => void\n}\n\nexport function useTree(options: UseTreeOptions = {}) {\n const { defaultExpanded, defaultSelected, multiSelect, onSelect, onExpand } = options\n\n const [expanded, setExpanded] = useState<Set<string>>(\n new Set(defaultExpanded ?? []),\n )\n const [selected, setSelected] = useState<Set<string>>(\n new Set(defaultSelected ?? []),\n )\n\n const toggle = useCallback(\n (id: string) => {\n setExpanded((prev) => {\n const next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n onExpand?.(Array.from(next))\n return next\n })\n },\n [onExpand],\n )\n\n const select = useCallback(\n (id: string, event?: React.MouseEvent) => {\n setSelected((prev) => {\n let next: Set<string>\n if (multiSelect && event?.ctrlKey) {\n next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n } else {\n next = new Set([id])\n }\n onSelect?.(Array.from(next))\n return next\n })\n },\n [multiSelect, onSelect],\n )\n\n return {\n expanded,\n selected,\n toggle,\n select,\n isExpanded: (id: string) => expanded.has(id),\n isSelected: (id: string) => selected.has(id),\n expandAll: (ids: string[]) => setExpanded(new Set(ids)),\n collapseAll: () => setExpanded(new Set()),\n }\n}\n","'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils'\nimport { TreeItem } from './tree-item'\nimport { type TreeNode,useTree } from './use-tree'\n\n// ─── Context ────────────────────────────────────────────────────────\ninterface TreeContextValue {\n tree: ReturnType<typeof useTree>\n checkboxes: boolean\n}\n\nconst TreeContext = React.createContext<TreeContextValue | null>(null)\n\nexport function useTreeContext() {\n const ctx = React.useContext(TreeContext)\n if (!ctx) {\n throw new Error('TreeItem must be used within a <TreeView>')\n }\n return ctx\n}\n\n// ─── Props ──────────────────────────────────────────────────────────\nexport interface TreeViewProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onSelect'> {\n /** Data-driven mode: pass items array */\n items?: TreeNode[]\n /** Initially expanded node IDs */\n defaultExpanded?: string[]\n /** Initially selected node IDs */\n defaultSelected?: string[]\n /** Enable multi-select */\n multiSelect?: boolean\n /** Show checkboxes before each item */\n checkboxes?: boolean\n /** Called when selection changes */\n onSelect?: (ids: string[]) => void\n /** Called when expansion changes */\n onExpand?: (ids: string[]) => void\n className?: string\n /** Declarative mode: render TreeItem children directly */\n children?: React.ReactNode\n}\n\n// ─── Render nodes recursively (data-driven mode) ───────────────────\nfunction renderNodes(nodes: TreeNode[], depth: number = 0): React.ReactNode {\n return nodes.map((node) => (\n <TreeItem\n key={node.id}\n itemId={node.id}\n label={node.label}\n icon={node.icon}\n disabled={node.disabled}\n depth={depth}\n >\n {node.children && node.children.length > 0\n ? renderNodes(node.children, depth + 1)\n : undefined}\n </TreeItem>\n ))\n}\n\n// ─── Helper: collect all visible item IDs ───────────────────────────\nfunction getVisibleItemElements(container: HTMLElement): HTMLElement[] {\n return Array.from(\n container.querySelectorAll<HTMLElement>('[data-tree-item]'),\n ).filter((el) => {\n // Items inside collapsed groups should not be focusable\n let parent = el.parentElement\n while (parent && parent !== container) {\n if (parent.getAttribute('role') === 'group') {\n const grid = parent.parentElement\n if (grid && grid.classList.contains('grid-rows-[0fr]')) {\n return false\n }\n }\n parent = parent.parentElement\n }\n return true\n })\n}\n\n// ─── Component ──────────────────────────────────────────────────────\nconst TreeView = React.forwardRef<HTMLUListElement, TreeViewProps>(\n (\n {\n items,\n defaultExpanded,\n defaultSelected,\n multiSelect = false,\n checkboxes = false,\n onSelect,\n onExpand,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const tree = useTree({\n defaultExpanded,\n defaultSelected,\n multiSelect,\n onSelect,\n onExpand,\n })\n\n const innerRef = React.useRef<HTMLUListElement>(null)\n const containerRef = (ref as React.RefObject<HTMLUListElement>) ?? innerRef\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLUListElement>) => {\n const container = containerRef.current\n if (!container) return\n\n const visibleItems = getVisibleItemElements(container)\n const currentIndex = visibleItems.findIndex(\n (el) => el === document.activeElement,\n )\n\n switch (e.key) {\n case 'ArrowDown': {\n e.preventDefault()\n const next = visibleItems[currentIndex + 1]\n next?.focus()\n break\n }\n case 'ArrowUp': {\n e.preventDefault()\n const prev = visibleItems[currentIndex - 1]\n prev?.focus()\n break\n }\n case 'ArrowRight': {\n // Handled in TreeItem for expand; if already expanded, move to first child\n const current = visibleItems[currentIndex]\n if (current) {\n const itemId = current.getAttribute('data-tree-item')\n if (itemId && tree.isExpanded(itemId)) {\n e.preventDefault()\n const nextItem = visibleItems[currentIndex + 1]\n nextItem?.focus()\n }\n }\n break\n }\n case 'ArrowLeft': {\n // Handled in TreeItem for collapse; if already collapsed or leaf, move to parent\n const current = visibleItems[currentIndex]\n if (current) {\n const itemId = current.getAttribute('data-tree-item')\n const treeItem = current.closest('[role=\"treeitem\"]')\n const parentGroup = treeItem?.parentElement?.closest(\n '[role=\"treeitem\"]',\n )\n if (itemId && !tree.isExpanded(itemId) && parentGroup) {\n e.preventDefault()\n const parentRow = parentGroup.querySelector<HTMLElement>(\n '[data-tree-item]',\n )\n parentRow?.focus()\n }\n }\n break\n }\n case 'Home': {\n e.preventDefault()\n visibleItems[0]?.focus()\n break\n }\n case 'End': {\n e.preventDefault()\n visibleItems[visibleItems.length - 1]?.focus()\n break\n }\n }\n }\n\n const ctxValue = React.useMemo<TreeContextValue>(\n () => ({ tree, checkboxes }),\n [tree, checkboxes],\n )\n\n const content = items ? renderNodes(items) : children\n\n return (\n <TreeContext.Provider value={ctxValue}>\n <ul\n ref={containerRef}\n role=\"tree\"\n aria-multiselectable={multiSelect || undefined}\n onKeyDown={handleKeyDown}\n className={cn('m-0 list-none p-0', className)}\n {...props}\n >\n {content}\n </ul>\n </TreeContext.Provider>\n )\n },\n)\nTreeView.displayName = 'TreeView'\n\nexport { TreeView }\n","'use client'\n\nimport { IconChevronRight } from '@tabler/icons-react'\nimport * as React from 'react'\n\nimport { Checkbox } from '../checkbox'\nimport { Icon } from '../icon'\nimport { IconProvider } from '../icon-context'\nimport type { IconInput } from '../lib/icon-input'\nimport { normalizeIcon } from '../lib/normalize-icon'\nimport { cn } from '../lib/utils'\nimport { useTreeContext } from './tree-view'\n\nexport interface TreeItemProps {\n /** Unique identifier for this tree item */\n itemId: string\n /** Primary label content */\n label: React.ReactNode\n /** Optional icon rendered before the label. Accepts any `IconInput`. */\n icon?: IconInput\n /** Secondary label rendered after the primary label */\n secondaryLabel?: React.ReactNode\n /** Action buttons rendered at the end of the row */\n actions?: React.ReactNode\n /** Whether this item is disabled */\n disabled?: boolean\n /** Nested tree items */\n children?: React.ReactNode\n /** Depth level (used internally) */\n depth?: number\n /** Additional CSS class names */\n className?: string\n}\n\nconst TreeItem = React.forwardRef<HTMLLIElement, TreeItemProps>(\n (\n {\n itemId,\n label,\n icon,\n secondaryLabel,\n actions,\n disabled = false,\n children,\n depth = 0,\n className,\n },\n ref,\n ) => {\n const ctx = useTreeContext()\n const hasChildren = React.Children.count(children) > 0\n const isExpanded = ctx.tree.isExpanded(itemId)\n const isSelected = ctx.tree.isSelected(itemId)\n\n const handleRowClick = (e: React.MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n ctx.tree.select(itemId, e)\n }\n\n const handleChevronClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n if (disabled) return\n ctx.tree.toggle(itemId)\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n ctx.tree.select(itemId)\n }\n if (e.key === 'ArrowRight' && hasChildren && !isExpanded) {\n e.preventDefault()\n e.stopPropagation()\n ctx.tree.toggle(itemId)\n }\n if (e.key === 'ArrowLeft' && hasChildren && isExpanded) {\n e.preventDefault()\n e.stopPropagation()\n ctx.tree.toggle(itemId)\n }\n }\n\n // Compute indeterminate state for checkbox mode\n const checkboxState = React.useMemo(() => {\n if (!ctx.checkboxes || !hasChildren) {\n return { checked: isSelected, indeterminate: false }\n }\n // Collect all descendant IDs\n const descendants: string[] = []\n const collectIds = (nodes: React.ReactNode) => {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<TreeItemProps>(child) && child.props.itemId) {\n descendants.push(child.props.itemId)\n if (child.props.children) {\n collectIds(child.props.children)\n }\n }\n })\n }\n collectIds(children)\n const selectedCount = descendants.filter((id) =>\n ctx.tree.isSelected(id),\n ).length\n if (selectedCount === 0 && !isSelected) {\n return { checked: false, indeterminate: false }\n }\n if (selectedCount === descendants.length) {\n return { checked: true, indeterminate: false }\n }\n return { checked: false, indeterminate: true }\n }, [ctx.checkboxes, hasChildren, children, isSelected, ctx.tree])\n\n return (\n <li\n ref={ref}\n role=\"treeitem\"\n aria-expanded={hasChildren ? isExpanded : undefined}\n aria-selected={isSelected}\n aria-level={depth + 1}\n aria-disabled={disabled || undefined}\n className=\"list-none\"\n >\n {/* Row */}\n <div\n role=\"presentation\"\n data-tree-item={itemId}\n tabIndex={disabled ? -1 : 0}\n onClick={handleRowClick}\n onKeyDown={handleKeyDown}\n style={{ paddingLeft: `calc(${depth} * var(--spacing-ds-05b) + var(--spacing-ds-03))` }}\n className={cn(\n 'flex items-center gap-ds-02 py-ds-02 px-ds-02 rounded-control cursor-pointer transition-colors duration-fast-01',\n 'hover:bg-surface-raised',\n 'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9',\n isSelected &&\n 'bg-accent-3 text-accent-11',\n disabled && 'opacity-action-disabled cursor-not-allowed pointer-events-none',\n className,\n )}\n >\n {/* Expand chevron */}\n {hasChildren ? (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n onClick={handleChevronClick}\n className=\"flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer\"\n >\n <Icon\n icon={IconChevronRight}\n size=\"sm\"\n className={cn(\n 'transition-transform duration-moderate-02',\n isExpanded && 'rotate-90',\n )}\n />\n </button>\n ) : (\n <span className=\"inline-block w-4 shrink-0\" aria-hidden=\"true\" />\n )}\n\n {/* Checkbox (optional) */}\n {ctx.checkboxes && (\n <Checkbox\n checked={checkboxState.checked}\n indeterminate={checkboxState.indeterminate}\n disabled={disabled}\n tabIndex={-1}\n onClick={(e) => e.stopPropagation()}\n onCheckedChange={() => {\n if (!disabled) ctx.tree.select(itemId)\n }}\n className=\"shrink-0\"\n />\n )}\n\n {/* Icon */}\n {icon && (\n <span className=\"flex shrink-0 items-center text-surface-fg-subtle\">\n <IconProvider size=\"sm\">{normalizeIcon(icon)}</IconProvider>\n </span>\n )}\n\n {/* Label */}\n <span className=\"truncate text-ds-sm\">{label}</span>\n\n {/* Secondary label */}\n {secondaryLabel && (\n <span className=\"ml-auto truncate text-ds-xs text-surface-fg-muted\">\n {secondaryLabel}\n </span>\n )}\n\n {/* Actions */}\n {actions && (\n <span\n className=\"ml-auto flex shrink-0 items-center gap-ds-01\"\n onClick={(e) => e.stopPropagation()}\n role=\"presentation\"\n >\n {actions}\n </span>\n )}\n </div>\n\n {/* Children (collapsible) */}\n {hasChildren && (\n <div\n role=\"group\"\n className={cn(\n 'grid transition-[grid-template-rows] duration-moderate-02 ease-productive-standard',\n isExpanded ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',\n )}\n >\n <ul role=\"group\" className=\"overflow-hidden m-0 p-0\">\n {React.Children.map(children, (child) => {\n if (React.isValidElement<TreeItemProps>(child)) {\n return React.cloneElement(child, {\n depth: depth + 1,\n })\n }\n return child\n })}\n </ul>\n </div>\n )}\n </li>\n )\n },\n)\nTreeItem.displayName = 'TreeItem'\n\nexport { TreeItem }\n"],"mappings":";;;;;;;;;;AAoBA,SAAgB,EAAQ,IAA0B,EAAE,EAAE;CACpD,IAAM,EAAE,oBAAiB,oBAAiB,gBAAa,aAAU,gBAAa,GAExE,CAAC,GAAU,KAAe,EAC9B,IAAI,IAAI,KAAmB,EAAE,CAAC,CAC/B,EACK,CAAC,GAAU,KAAe,EAC9B,IAAI,IAAI,KAAmB,EAAE,CAAC,CAC/B;AAiCD,QAAO;EACL;EACA;EACA,QAlCa,GACZ,MAAe;AACd,MAAa,MAAS;IACpB,IAAM,IAAO,IAAI,IAAI,EAAK;AAI1B,WAHI,EAAK,IAAI,EAAG,GAAE,EAAK,OAAO,EAAG,GAC5B,EAAK,IAAI,EAAG,EACjB,IAAW,MAAM,KAAK,EAAK,CAAC,EACrB;KACP;KAEJ,CAAC,EAAS,CACX;EAwBC,QAtBa,GACZ,GAAY,MAA6B;AACxC,MAAa,MAAS;IACp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,CAAA;IAIT,kBAAC,QAAD;KAAM,WAAU;eAAuB;KAAa,CAAA;IAGnD,KACC,kBAAC,QAAD;KAAM,WAAU;eACb;KACI,CAAA;IAIR,KACC,kBAAC,QAAD;KACE,WAAU;KACV,UAAU,MAAM,EAAE,iBAAiB;KACnC,MAAK;eAEJ;KACI,CAAA;IAEL;MAGL,KACC,kBAAC,OAAD;GACE,MAAK;GACL,WAAW,EACT,sFACA,IAAa,oBAAoB,kBAClC;aAED,kBAAC,MAAD;IAAI,MAAK;IAAQ,WAAU;cACxB,EAAM,SAAS,IAAI,IAAW,MACzB,EAAM,eAA8B,EAAM,GACrC,EAAM,aAAa,GAAO,EAC/B,OAAO,IAAQ,GAChB,CAAC,GAEG,EACP;IACC,CAAA;GACD,CAAA,CAEL;;EAGV;AACD,EAAS,cAAc"}
1
+ {"version":3,"file":"tree-view.js","names":[],"sources":["../../src/ui/tree-view/use-tree.ts","../../src/ui/tree-view/tree-view.tsx","../../src/ui/tree-view/tree-item.tsx"],"sourcesContent":["import { useCallback,useState } from 'react'\n\nimport type { IconInput } from '../lib/icon-input'\n\nexport interface TreeNode {\n id: string\n label: string\n icon?: IconInput\n children?: TreeNode[]\n disabled?: boolean\n}\n\ninterface UseTreeOptions {\n defaultExpanded?: string[]\n defaultSelected?: string[]\n multiSelect?: boolean\n onSelect?: (selectedIds: string[]) => void\n onExpand?: (expandedIds: string[]) => void\n}\n\nexport function useTree(options: UseTreeOptions = {}) {\n const { defaultExpanded, defaultSelected, multiSelect, onSelect, onExpand } = options\n\n const [expanded, setExpanded] = useState<Set<string>>(\n new Set(defaultExpanded ?? []),\n )\n const [selected, setSelected] = useState<Set<string>>(\n new Set(defaultSelected ?? []),\n )\n\n const toggle = useCallback(\n (id: string) => {\n setExpanded((prev) => {\n const next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n onExpand?.(Array.from(next))\n return next\n })\n },\n [onExpand],\n )\n\n const select = useCallback(\n (id: string, event?: React.MouseEvent) => {\n setSelected((prev) => {\n let next: Set<string>\n if (multiSelect && event?.ctrlKey) {\n next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n } else {\n next = new Set([id])\n }\n onSelect?.(Array.from(next))\n return next\n })\n },\n [multiSelect, onSelect],\n )\n\n return {\n expanded,\n selected,\n toggle,\n select,\n isExpanded: (id: string) => expanded.has(id),\n isSelected: (id: string) => selected.has(id),\n expandAll: (ids: string[]) => setExpanded(new Set(ids)),\n collapseAll: () => setExpanded(new Set()),\n }\n}\n","'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils'\nimport { TreeItem } from './tree-item'\nimport { type TreeNode,useTree } from './use-tree'\n\n// ─── Context ────────────────────────────────────────────────────────\ninterface TreeContextValue {\n tree: ReturnType<typeof useTree>\n checkboxes: boolean\n}\n\nconst TreeContext = React.createContext<TreeContextValue | null>(null)\n\nexport function useTreeContext() {\n const ctx = React.useContext(TreeContext)\n if (!ctx) {\n throw new Error('TreeItem must be used within a <TreeView>')\n }\n return ctx\n}\n\n// ─── Props ──────────────────────────────────────────────────────────\nexport interface TreeViewProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onSelect'> {\n /** Data-driven mode: pass items array */\n items?: TreeNode[]\n /** Initially expanded node IDs */\n defaultExpanded?: string[]\n /** Initially selected node IDs */\n defaultSelected?: string[]\n /** Enable multi-select */\n multiSelect?: boolean\n /** Show checkboxes before each item */\n checkboxes?: boolean\n /** Called when selection changes */\n onSelect?: (ids: string[]) => void\n /** Called when expansion changes */\n onExpand?: (ids: string[]) => void\n className?: string\n /** Declarative mode: render TreeItem children directly */\n children?: React.ReactNode\n}\n\n// ─── Render nodes recursively (data-driven mode) ───────────────────\nfunction renderNodes(nodes: TreeNode[], depth: number = 0): React.ReactNode {\n return nodes.map((node) => (\n <TreeItem\n key={node.id}\n itemId={node.id}\n label={node.label}\n icon={node.icon}\n disabled={node.disabled}\n depth={depth}\n >\n {node.children && node.children.length > 0\n ? renderNodes(node.children, depth + 1)\n : undefined}\n </TreeItem>\n ))\n}\n\n// ─── Helper: collect all visible item IDs ───────────────────────────\nfunction getVisibleItemElements(container: HTMLElement): HTMLElement[] {\n return Array.from(\n container.querySelectorAll<HTMLElement>('[data-tree-item]'),\n ).filter((el) => {\n // Items inside collapsed groups should not be focusable\n let parent = el.parentElement\n while (parent && parent !== container) {\n if (parent.getAttribute('role') === 'group') {\n const grid = parent.parentElement\n if (grid && grid.classList.contains('grid-rows-[0fr]')) {\n return false\n }\n }\n parent = parent.parentElement\n }\n return true\n })\n}\n\n// ─── Component ──────────────────────────────────────────────────────\nconst TreeView = React.forwardRef<HTMLUListElement, TreeViewProps>(\n (\n {\n items,\n defaultExpanded,\n defaultSelected,\n multiSelect = false,\n checkboxes = false,\n onSelect,\n onExpand,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const tree = useTree({\n defaultExpanded,\n defaultSelected,\n multiSelect,\n onSelect,\n onExpand,\n })\n\n const innerRef = React.useRef<HTMLUListElement>(null)\n const containerRef = (ref as React.RefObject<HTMLUListElement>) ?? innerRef\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLUListElement>) => {\n const container = containerRef.current\n if (!container) return\n\n const visibleItems = getVisibleItemElements(container)\n const currentIndex = visibleItems.findIndex(\n (el) => el === document.activeElement,\n )\n\n switch (e.key) {\n case 'ArrowDown': {\n e.preventDefault()\n const next = visibleItems[currentIndex + 1]\n next?.focus()\n break\n }\n case 'ArrowUp': {\n e.preventDefault()\n const prev = visibleItems[currentIndex - 1]\n prev?.focus()\n break\n }\n case 'ArrowRight': {\n // Handled in TreeItem for expand; if already expanded, move to first child\n const current = visibleItems[currentIndex]\n if (current) {\n const itemId = current.getAttribute('data-tree-item')\n if (itemId && tree.isExpanded(itemId)) {\n e.preventDefault()\n const nextItem = visibleItems[currentIndex + 1]\n nextItem?.focus()\n }\n }\n break\n }\n case 'ArrowLeft': {\n // Handled in TreeItem for collapse; if already collapsed or leaf, move to parent\n const current = visibleItems[currentIndex]\n if (current) {\n const itemId = current.getAttribute('data-tree-item')\n const treeItem = current.closest('[role=\"treeitem\"]')\n const parentGroup = treeItem?.parentElement?.closest(\n '[role=\"treeitem\"]',\n )\n if (itemId && !tree.isExpanded(itemId) && parentGroup) {\n e.preventDefault()\n const parentRow = parentGroup.querySelector<HTMLElement>(\n '[data-tree-item]',\n )\n parentRow?.focus()\n }\n }\n break\n }\n case 'Home': {\n e.preventDefault()\n visibleItems[0]?.focus()\n break\n }\n case 'End': {\n e.preventDefault()\n visibleItems[visibleItems.length - 1]?.focus()\n break\n }\n }\n }\n\n const ctxValue = React.useMemo<TreeContextValue>(\n () => ({ tree, checkboxes }),\n [tree, checkboxes],\n )\n\n const content = items ? renderNodes(items) : children\n\n return (\n <TreeContext.Provider value={ctxValue}>\n <ul\n ref={containerRef}\n role=\"tree\"\n aria-multiselectable={multiSelect || undefined}\n onKeyDown={handleKeyDown}\n className={cn('m-0 list-none p-0', className)}\n {...props}\n >\n {content}\n </ul>\n </TreeContext.Provider>\n )\n },\n)\nTreeView.displayName = 'TreeView'\n\nexport { TreeView }\n","'use client'\n\nimport { IconChevronRight } from '@tabler/icons-react'\nimport * as React from 'react'\n\nimport { Checkbox } from '../checkbox'\nimport { Icon } from '../icon'\nimport { IconProvider } from '../icon-context'\nimport type { IconInput } from '../lib/icon-input'\nimport { normalizeIcon } from '../lib/normalize-icon'\nimport { cn } from '../lib/utils'\nimport { useTreeContext } from './tree-view'\n\nexport interface TreeItemProps {\n /** Unique identifier for this tree item */\n itemId: string\n /** Primary label content */\n label: React.ReactNode\n /** Optional icon rendered before the label. Accepts any `IconInput`. */\n icon?: IconInput\n /** Secondary label rendered after the primary label */\n secondaryLabel?: React.ReactNode\n /** Action buttons rendered at the end of the row */\n actions?: React.ReactNode\n /** Whether this item is disabled */\n disabled?: boolean\n /** Nested tree items */\n children?: React.ReactNode\n /** Depth level (used internally) */\n depth?: number\n /** Additional CSS class names */\n className?: string\n}\n\nconst TreeItem = React.forwardRef<HTMLLIElement, TreeItemProps>(\n (\n {\n itemId,\n label,\n icon,\n secondaryLabel,\n actions,\n disabled = false,\n children,\n depth = 0,\n className,\n },\n ref,\n ) => {\n const ctx = useTreeContext()\n const hasChildren = React.Children.count(children) > 0\n const isExpanded = ctx.tree.isExpanded(itemId)\n const isSelected = ctx.tree.isSelected(itemId)\n\n const handleRowClick = (e: React.MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n ctx.tree.select(itemId, e)\n }\n\n const handleChevronClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n if (disabled) return\n ctx.tree.toggle(itemId)\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n ctx.tree.select(itemId)\n }\n if (e.key === 'ArrowRight' && hasChildren && !isExpanded) {\n e.preventDefault()\n e.stopPropagation()\n ctx.tree.toggle(itemId)\n }\n if (e.key === 'ArrowLeft' && hasChildren && isExpanded) {\n e.preventDefault()\n e.stopPropagation()\n ctx.tree.toggle(itemId)\n }\n }\n\n // Compute indeterminate state for checkbox mode\n const checkboxState = React.useMemo(() => {\n if (!ctx.checkboxes || !hasChildren) {\n return { checked: isSelected, indeterminate: false }\n }\n // Collect all descendant IDs\n const descendants: string[] = []\n const collectIds = (nodes: React.ReactNode) => {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<TreeItemProps>(child) && child.props.itemId) {\n descendants.push(child.props.itemId)\n if (child.props.children) {\n collectIds(child.props.children)\n }\n }\n })\n }\n collectIds(children)\n const selectedCount = descendants.filter((id) =>\n ctx.tree.isSelected(id),\n ).length\n if (selectedCount === 0 && !isSelected) {\n return { checked: false, indeterminate: false }\n }\n if (selectedCount === descendants.length) {\n return { checked: true, indeterminate: false }\n }\n return { checked: false, indeterminate: true }\n }, [ctx.checkboxes, hasChildren, children, isSelected, ctx.tree])\n\n return (\n <li\n ref={ref}\n role=\"treeitem\"\n aria-expanded={hasChildren ? isExpanded : undefined}\n aria-selected={isSelected}\n aria-level={depth + 1}\n aria-disabled={disabled || undefined}\n className=\"list-none\"\n >\n {/* Row */}\n <div\n role=\"presentation\"\n data-tree-item={itemId}\n tabIndex={disabled ? -1 : 0}\n onClick={handleRowClick}\n onKeyDown={handleKeyDown}\n style={{ paddingLeft: `calc(${depth} * var(--spacing-ds-05b) + var(--spacing-ds-03))` }}\n className={cn(\n 'flex items-center gap-ds-02 py-ds-02 px-ds-02 rounded-control cursor-pointer transition-colors duration-fast-01',\n 'hover:bg-surface-raised',\n 'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9',\n isSelected &&\n 'bg-accent-3 text-accent-11',\n disabled && 'opacity-action-disabled cursor-not-allowed pointer-events-none',\n className,\n )}\n >\n {/* Expand chevron */}\n {hasChildren ? (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n onClick={handleChevronClick}\n className=\"flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer\"\n >\n <Icon\n icon={IconChevronRight}\n size=\"sm\"\n className={cn(\n 'transition-transform duration-moderate-02',\n isExpanded && 'rotate-90',\n )}\n />\n </button>\n ) : (\n <span className=\"inline-block w-4 shrink-0\" aria-hidden=\"true\" />\n )}\n\n {/* Checkbox (optional) */}\n {ctx.checkboxes && (\n <Checkbox\n checked={checkboxState.checked}\n indeterminate={checkboxState.indeterminate}\n disabled={disabled}\n tabIndex={-1}\n onClick={(e) => e.stopPropagation()}\n onCheckedChange={() => {\n if (!disabled) ctx.tree.select(itemId)\n }}\n className=\"shrink-0\"\n />\n )}\n\n {/* Icon */}\n {icon && (\n <span className=\"flex shrink-0 items-center text-surface-fg-subtle\">\n <IconProvider size=\"sm\">{normalizeIcon(icon)}</IconProvider>\n </span>\n )}\n\n {/* Label */}\n <span className=\"min-w-0 truncate text-ds-sm\">{label}</span>\n\n {/* Secondary label */}\n {secondaryLabel && (\n <span className=\"ml-auto truncate text-ds-xs text-surface-fg-muted\">\n {secondaryLabel}\n </span>\n )}\n\n {/* Actions */}\n {actions && (\n <span\n className=\"ml-auto flex shrink-0 items-center gap-ds-01\"\n onClick={(e) => e.stopPropagation()}\n role=\"presentation\"\n >\n {actions}\n </span>\n )}\n </div>\n\n {/* Children (collapsible) */}\n {hasChildren && (\n <div\n role=\"group\"\n className={cn(\n 'grid transition-[grid-template-rows] duration-moderate-02 ease-productive-standard',\n isExpanded ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',\n )}\n >\n <ul role=\"group\" className=\"overflow-hidden m-0 p-0\">\n {React.Children.map(children, (child) => {\n if (React.isValidElement<TreeItemProps>(child)) {\n return React.cloneElement(child, {\n depth: depth + 1,\n })\n }\n return child\n })}\n </ul>\n </div>\n )}\n </li>\n )\n },\n)\nTreeItem.displayName = 'TreeItem'\n\nexport { TreeItem }\n"],"mappings":";;;;;;;;;;AAoBA,SAAgB,EAAQ,IAA0B,EAAE,EAAE;CACpD,IAAM,EAAE,oBAAiB,oBAAiB,gBAAa,aAAU,gBAAa,GAExE,CAAC,GAAU,KAAe,EAC9B,IAAI,IAAI,KAAmB,EAAE,CAAC,CAC/B,EACK,CAAC,GAAU,KAAe,EAC9B,IAAI,IAAI,KAAmB,EAAE,CAAC,CAC/B;AAiCD,QAAO;EACL;EACA;EACA,QAlCa,GACZ,MAAe;AACd,MAAa,MAAS;IACpB,IAAM,IAAO,IAAI,IAAI,EAAK;AAI1B,WAHI,EAAK,IAAI,EAAG,GAAE,EAAK,OAAO,EAAG,GAC5B,EAAK,IAAI,EAAG,EACjB,IAAW,MAAM,KAAK,EAAK,CAAC,EACrB;KACP;KAEJ,CAAC,EAAS,CACX;EAwBC,QAtBa,GACZ,GAAY,MAA6B;AACxC,MAAa,MAAS;IACpB,IAAI;AASJ,WARI,KAAe,GAAO,WACxB,IAAO,IAAI,IAAI,EAAK,EAChB,EAAK,IAAI,EAAG,GAAE,EAAK,OAAO,EAAG,GAC5B,EAAK,IAAI,EAAG,IAEjB,I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