@praxical/ui 0.0.0-stage → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -2
  3. package/dist/activity-calendar.d.ts +13 -0
  4. package/dist/activity-calendar.js +7 -0
  5. package/dist/activity-heatmap.d.ts +14 -0
  6. package/dist/activity-heatmap.js +13 -0
  7. package/dist/chart-data.d.ts +9 -0
  8. package/dist/chart-data.js +9 -0
  9. package/dist/charts.d.ts +56 -0
  10. package/dist/charts.js +424 -0
  11. package/dist/chunk-7RMPDKZV.js +541 -0
  12. package/dist/chunk-7RTW3X7C.js +142 -0
  13. package/dist/chunk-EBF2F3LN.js +1523 -0
  14. package/dist/chunk-FCYIZANU.js +385 -0
  15. package/dist/chunk-HMO4VQZN.js +58 -0
  16. package/dist/chunk-II677WPC.js +177 -0
  17. package/dist/chunk-KZHUBPY6.js +102 -0
  18. package/dist/chunk-OLGZOPLD.js +166 -0
  19. package/dist/chunk-PDSV773E.js +52 -0
  20. package/dist/chunk-Q4ARHP76.js +457 -0
  21. package/dist/chunk-U5W7O3QV.js +22 -0
  22. package/dist/chunk-V6MXR4P2.js +275 -0
  23. package/dist/chunk-VZZDLRM5.js +152 -0
  24. package/dist/chunk-WEM2UQPR.js +110 -0
  25. package/dist/chunk-XFNDEA5M.js +104 -0
  26. package/dist/chunk-YKFAA7GU.js +72 -0
  27. package/dist/code-value.d.ts +13 -0
  28. package/dist/code-value.js +10 -0
  29. package/dist/code.d.ts +36 -0
  30. package/dist/code.js +198 -0
  31. package/dist/collection.d.ts +21 -0
  32. package/dist/collection.js +48 -0
  33. package/dist/content.d.ts +42 -0
  34. package/dist/content.js +122 -0
  35. package/dist/display.d.ts +58 -0
  36. package/dist/display.js +27 -0
  37. package/dist/feedback.d.ts +34 -0
  38. package/dist/feedback.js +184 -0
  39. package/dist/file-tree.d.ts +17 -0
  40. package/dist/file-tree.js +11 -0
  41. package/dist/forms.d.ts +69 -0
  42. package/dist/forms.js +273 -0
  43. package/dist/git-graph.d.ts +8 -0
  44. package/dist/git-graph.js +15 -0
  45. package/dist/git-layout.d.ts +24 -0
  46. package/dist/git-layout.js +7 -0
  47. package/dist/image-viewer.d.ts +18 -0
  48. package/dist/image-viewer.js +11 -0
  49. package/dist/index.d.ts +363 -0
  50. package/dist/index.js +98 -0
  51. package/dist/inputs.d.ts +112 -0
  52. package/dist/inputs.js +938 -0
  53. package/dist/layout.d.ts +56 -0
  54. package/dist/layout.js +180 -0
  55. package/dist/map-frame.d.ts +37 -0
  56. package/dist/map-frame.js +13 -0
  57. package/dist/media.d.ts +40 -0
  58. package/dist/media.js +19 -0
  59. package/dist/network-layout.d.ts +94 -0
  60. package/dist/network-layout.js +19 -0
  61. package/dist/network.d.ts +111 -0
  62. package/dist/network.js +354 -0
  63. package/dist/overlays.d.ts +95 -0
  64. package/dist/overlays.js +25 -0
  65. package/dist/patterns.d.ts +117 -0
  66. package/dist/patterns.js +387 -0
  67. package/dist/power-layout.d.ts +91 -0
  68. package/dist/power-layout.js +13 -0
  69. package/dist/power.d.ts +91 -0
  70. package/dist/power.js +353 -0
  71. package/dist/signal-context.d.ts +11 -0
  72. package/dist/signal-context.js +15 -0
  73. package/dist/strings-es-419.d.ts +13 -0
  74. package/dist/strings-es-419.js +357 -0
  75. package/dist/strings-fr.d.ts +15 -0
  76. package/dist/strings-fr.js +359 -0
  77. package/dist/strings-ja.d.ts +16 -0
  78. package/dist/strings-ja.js +357 -0
  79. package/dist/strings-pt-BR.d.ts +13 -0
  80. package/dist/strings-pt-BR.js +357 -0
  81. package/dist/strings.d.ts +394 -0
  82. package/dist/strings.js +15 -0
  83. package/dist/styles.css +2 -0
  84. package/dist/tab-bar.d.ts +20 -0
  85. package/dist/tab-bar.js +114 -0
  86. package/package.json +154 -3
@@ -0,0 +1,541 @@
1
+ 'use client';
2
+ import {
3
+ Badge,
4
+ Button,
5
+ Select,
6
+ SignalProvider
7
+ } from "./chunk-EBF2F3LN.js";
8
+ import {
9
+ useSignalStrings
10
+ } from "./chunk-U5W7O3QV.js";
11
+
12
+ // packages/ui/src/overlays.tsx
13
+ import { useEffect, useId, useRef, useState } from "react";
14
+ import { Menu as BaseMenu } from "@base-ui/react/menu";
15
+ import { ContextMenu as BaseContextMenu } from "@base-ui/react/context-menu";
16
+ import { Dialog as BaseDialog } from "@base-ui/react/dialog";
17
+ import { Popover as BasePopover } from "@base-ui/react/popover";
18
+ import { Autocomplete } from "@base-ui/react/autocomplete";
19
+ import { Bell, ChevronDown, Search, X, SmilePlus } from "lucide-react";
20
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
+ function SplitButton({
22
+ label,
23
+ onClick,
24
+ items,
25
+ variant = "primary",
26
+ disabled = false
27
+ }) {
28
+ const strings = useSignalStrings();
29
+ return /* @__PURE__ */ jsxs("div", { className: "signal-split-button", children: [
30
+ /* @__PURE__ */ jsx(Button, { variant, onClick, disabled, children: label }),
31
+ /* @__PURE__ */ jsxs(BaseMenu.Root, { children: [
32
+ /* @__PURE__ */ jsx(
33
+ BaseMenu.Trigger,
34
+ {
35
+ render: /* @__PURE__ */ jsx(
36
+ Button,
37
+ {
38
+ variant,
39
+ iconOnly: true,
40
+ "aria-label": strings.menu.options(label),
41
+ disabled
42
+ }
43
+ ),
44
+ children: /* @__PURE__ */ jsx(ChevronDown, {})
45
+ }
46
+ ),
47
+ /* @__PURE__ */ jsx(BaseMenu.Portal, { children: /* @__PURE__ */ jsx(SignalProvider, { className: "signal-portal", children: /* @__PURE__ */ jsx(
48
+ BaseMenu.Positioner,
49
+ {
50
+ className: "signal-positioner",
51
+ sideOffset: 4,
52
+ align: "end",
53
+ children: /* @__PURE__ */ jsx(BaseMenu.Popup, { className: "signal-popup", children: items.map((item) => /* @__PURE__ */ jsxs(
54
+ BaseMenu.Item,
55
+ {
56
+ className: "signal-option",
57
+ "data-tone": item.danger ? "danger" : void 0,
58
+ disabled: item.disabled,
59
+ onClick: item.onSelect,
60
+ children: [
61
+ item.icon,
62
+ /* @__PURE__ */ jsx("span", { children: item.label }),
63
+ item.shortcut && /* @__PURE__ */ jsx("kbd", { children: item.shortcut })
64
+ ]
65
+ },
66
+ item.id
67
+ )) })
68
+ }
69
+ ) }) })
70
+ ] })
71
+ ] });
72
+ }
73
+ function ContextMenu({
74
+ label,
75
+ children,
76
+ items
77
+ }) {
78
+ return /* @__PURE__ */ jsxs(BaseContextMenu.Root, { children: [
79
+ /* @__PURE__ */ jsx(
80
+ BaseContextMenu.Trigger,
81
+ {
82
+ className: "signal-context-target",
83
+ tabIndex: 0,
84
+ "aria-label": label,
85
+ children
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsx(BaseContextMenu.Portal, { children: /* @__PURE__ */ jsx(SignalProvider, { className: "signal-portal", children: /* @__PURE__ */ jsx(BaseContextMenu.Positioner, { className: "signal-positioner", children: /* @__PURE__ */ jsx(BaseContextMenu.Popup, { className: "signal-popup", children: items.map((item) => /* @__PURE__ */ jsxs(
89
+ BaseContextMenu.Item,
90
+ {
91
+ className: "signal-option",
92
+ "data-tone": item.danger ? "danger" : void 0,
93
+ disabled: item.disabled,
94
+ onClick: item.onSelect,
95
+ children: [
96
+ item.icon,
97
+ /* @__PURE__ */ jsx("span", { children: item.label }),
98
+ item.shortcut && /* @__PURE__ */ jsx("kbd", { children: item.shortcut })
99
+ ]
100
+ },
101
+ item.id
102
+ )) }) }) }) })
103
+ ] });
104
+ }
105
+ function CommandDialog({
106
+ items,
107
+ open,
108
+ onOpenChange,
109
+ shortcut = false,
110
+ label,
111
+ trigger
112
+ }) {
113
+ const strings = useSignalStrings();
114
+ const title = label ?? strings.command.label;
115
+ const [query, setQuery] = useState(""), id = useId(), input = useRef(null);
116
+ useEffect(() => {
117
+ if (!open) setQuery("");
118
+ }, [open]);
119
+ useEffect(() => {
120
+ if (!shortcut) return;
121
+ const key = (e) => {
122
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "k" && !e.defaultPrevented) {
123
+ e.preventDefault();
124
+ onOpenChange(!open);
125
+ }
126
+ };
127
+ document.addEventListener("keydown", key);
128
+ return () => document.removeEventListener("keydown", key);
129
+ }, [shortcut, open, onOpenChange]);
130
+ const matches = items.filter(
131
+ (i) => `${i.label} ${i.keywords ?? ""}`.toLowerCase().includes(query.toLowerCase())
132
+ );
133
+ return /* @__PURE__ */ jsxs(BaseDialog.Root, { open, onOpenChange, children: [
134
+ trigger !== false && /* @__PURE__ */ jsx(
135
+ BaseDialog.Trigger,
136
+ {
137
+ render: /* @__PURE__ */ jsx(Button, {}),
138
+ "aria-keyshortcuts": shortcut ? "Control+k Meta+k" : void 0,
139
+ children: trigger ?? /* @__PURE__ */ jsxs(Fragment, { children: [
140
+ /* @__PURE__ */ jsx(Search, {}),
141
+ title,
142
+ shortcut && /* @__PURE__ */ jsx("kbd", { children: strings.command.shortcut })
143
+ ] })
144
+ }
145
+ ),
146
+ /* @__PURE__ */ jsx(BaseDialog.Portal, { children: /* @__PURE__ */ jsxs(SignalProvider, { className: "signal-portal", children: [
147
+ /* @__PURE__ */ jsx(BaseDialog.Backdrop, { className: "signal-backdrop" }),
148
+ /* @__PURE__ */ jsxs(
149
+ BaseDialog.Popup,
150
+ {
151
+ className: "signal-dialog signal-command",
152
+ initialFocus: input,
153
+ children: [
154
+ /* @__PURE__ */ jsx(BaseDialog.Title, { children: title }),
155
+ /* @__PURE__ */ jsx(BaseDialog.Description, { children: strings.command.description }),
156
+ /* @__PURE__ */ jsx(
157
+ BaseDialog.Close,
158
+ {
159
+ render: /* @__PURE__ */ jsx(
160
+ Button,
161
+ {
162
+ className: "signal-dialog-close",
163
+ iconOnly: true,
164
+ "aria-label": strings.command.close
165
+ }
166
+ ),
167
+ children: /* @__PURE__ */ jsx(X, {})
168
+ }
169
+ ),
170
+ /* @__PURE__ */ jsxs(
171
+ Autocomplete.Root,
172
+ {
173
+ items: matches,
174
+ filter: null,
175
+ value: query,
176
+ onValueChange: setQuery,
177
+ inline: true,
178
+ autoHighlight: true,
179
+ itemToStringValue: (item) => item.label,
180
+ children: [
181
+ /* @__PURE__ */ jsx("label", { className: "signal-sr-only", htmlFor: id, children: strings.command.inputLabel }),
182
+ /* @__PURE__ */ jsxs("div", { className: "signal-search", children: [
183
+ /* @__PURE__ */ jsx(Search, { "aria-hidden": "true" }),
184
+ /* @__PURE__ */ jsx(
185
+ Autocomplete.Input,
186
+ {
187
+ ref: input,
188
+ id,
189
+ className: "signal-input",
190
+ placeholder: strings.command.placeholder
191
+ }
192
+ )
193
+ ] }),
194
+ /* @__PURE__ */ jsx(Autocomplete.Empty, { children: /* @__PURE__ */ jsx("div", { className: "signal-option", children: strings.command.empty }) }),
195
+ /* @__PURE__ */ jsx(Autocomplete.List, { className: "signal-command-list", children: (item) => /* @__PURE__ */ jsxs(
196
+ Autocomplete.Item,
197
+ {
198
+ value: item,
199
+ disabled: item.disabled,
200
+ className: "signal-option",
201
+ onClick: () => {
202
+ item.onSelect();
203
+ onOpenChange(false);
204
+ },
205
+ children: [
206
+ item.icon,
207
+ /* @__PURE__ */ jsx("span", { children: item.label }),
208
+ item.shortcut && /* @__PURE__ */ jsx("kbd", { children: item.shortcut })
209
+ ]
210
+ },
211
+ item.id
212
+ ) })
213
+ ]
214
+ }
215
+ )
216
+ ]
217
+ }
218
+ )
219
+ ] }) })
220
+ ] });
221
+ }
222
+ function NotificationDrawer({
223
+ items,
224
+ open,
225
+ onOpenChange,
226
+ onMarkRead,
227
+ onDismiss,
228
+ label
229
+ }) {
230
+ const strings = useSignalStrings();
231
+ const title = label ?? strings.inbox.label;
232
+ const unread = items.filter((i) => i.unread).length;
233
+ return /* @__PURE__ */ jsxs(BaseDialog.Root, { open, onOpenChange, children: [
234
+ /* @__PURE__ */ jsxs(BaseDialog.Trigger, { render: /* @__PURE__ */ jsx(Button, {}), children: [
235
+ /* @__PURE__ */ jsx(Bell, {}),
236
+ title,
237
+ unread > 0 && /* @__PURE__ */ jsx(Badge, { tone: "accent", children: strings.inbox.unreadBadge(unread) })
238
+ ] }),
239
+ /* @__PURE__ */ jsx(BaseDialog.Portal, { children: /* @__PURE__ */ jsxs(SignalProvider, { className: "signal-portal", children: [
240
+ /* @__PURE__ */ jsx(BaseDialog.Backdrop, { className: "signal-backdrop" }),
241
+ /* @__PURE__ */ jsxs(BaseDialog.Popup, { className: "signal-dialog signal-drawer", children: [
242
+ /* @__PURE__ */ jsxs("header", { children: [
243
+ /* @__PURE__ */ jsx(BaseDialog.Title, { children: title }),
244
+ /* @__PURE__ */ jsx(
245
+ BaseDialog.Close,
246
+ {
247
+ render: /* @__PURE__ */ jsx(Button, { iconOnly: true, "aria-label": strings.inbox.close }),
248
+ children: /* @__PURE__ */ jsx(X, {})
249
+ }
250
+ )
251
+ ] }),
252
+ /* @__PURE__ */ jsx(BaseDialog.Description, { children: strings.inbox.unreadCount(unread) }),
253
+ !items.length && /* @__PURE__ */ jsx("p", { className: "signal-inbox-empty", children: strings.inbox.empty }),
254
+ /* @__PURE__ */ jsx("ul", { className: "signal-inbox-list", children: items.map((item) => /* @__PURE__ */ jsxs("li", { "data-unread": item.unread || void 0, children: [
255
+ /* @__PURE__ */ jsxs("div", { children: [
256
+ /* @__PURE__ */ jsx("strong", { children: item.title }),
257
+ item.unread && /* @__PURE__ */ jsx(Badge, { tone: "accent", children: strings.inbox.unreadMark })
258
+ ] }),
259
+ /* @__PURE__ */ jsx("time", { dateTime: item.dateTime, children: item.time }),
260
+ item.body && /* @__PURE__ */ jsx("p", { children: item.body }),
261
+ /* @__PURE__ */ jsxs("div", { className: "signal-toolbar", children: [
262
+ item.action,
263
+ item.unread && onMarkRead && /* @__PURE__ */ jsx(Button, { onClick: () => onMarkRead(item.id), children: strings.inbox.markRead }),
264
+ onDismiss && /* @__PURE__ */ jsx(
265
+ Button,
266
+ {
267
+ variant: "ghost",
268
+ onClick: () => onDismiss(item.id),
269
+ children: strings.inbox.dismiss
270
+ }
271
+ )
272
+ ] })
273
+ ] }, item.id)) })
274
+ ] })
275
+ ] }) })
276
+ ] });
277
+ }
278
+ function SidePanel({
279
+ title,
280
+ trigger,
281
+ triggerLabel,
282
+ open,
283
+ onOpenChange,
284
+ children,
285
+ side = "right",
286
+ className = ""
287
+ }) {
288
+ const strings = useSignalStrings();
289
+ return /* @__PURE__ */ jsxs(BaseDialog.Root, { open, onOpenChange, children: [
290
+ /* @__PURE__ */ jsx(
291
+ BaseDialog.Trigger,
292
+ {
293
+ render: /* @__PURE__ */ jsx(Button, { className, "aria-label": triggerLabel ?? title }),
294
+ children: trigger
295
+ }
296
+ ),
297
+ /* @__PURE__ */ jsx(BaseDialog.Portal, { children: /* @__PURE__ */ jsxs(SignalProvider, { className: "signal-portal", children: [
298
+ /* @__PURE__ */ jsx(BaseDialog.Backdrop, { className: "signal-backdrop" }),
299
+ /* @__PURE__ */ jsxs(
300
+ BaseDialog.Popup,
301
+ {
302
+ className: "signal-dialog signal-drawer",
303
+ "data-side": side,
304
+ children: [
305
+ /* @__PURE__ */ jsxs("header", { children: [
306
+ /* @__PURE__ */ jsx(BaseDialog.Title, { children: title }),
307
+ /* @__PURE__ */ jsx(
308
+ BaseDialog.Close,
309
+ {
310
+ render: /* @__PURE__ */ jsx(
311
+ Button,
312
+ {
313
+ iconOnly: true,
314
+ "aria-label": strings.panel.close(title)
315
+ }
316
+ ),
317
+ children: /* @__PURE__ */ jsx(X, {})
318
+ }
319
+ )
320
+ ] }),
321
+ /* @__PURE__ */ jsx("div", { className: "signal-panel-body", children })
322
+ ]
323
+ }
324
+ )
325
+ ] }) })
326
+ ] });
327
+ }
328
+ function ContentPicker({
329
+ label,
330
+ trigger,
331
+ items,
332
+ onSelect,
333
+ grid = false,
334
+ compact = false
335
+ }) {
336
+ const strings = useSignalStrings();
337
+ const [open, setOpen] = useState(false), [query, setQuery] = useState(""), [category, setCategory] = useState("all");
338
+ const input = useRef(null), id = useId();
339
+ const categories = [
340
+ ...new Set(items.flatMap((i) => i.category ? [i.category] : []))
341
+ ];
342
+ const matches = items.filter(
343
+ (i) => (category === "all" || i.category === category) && `${i.label} ${i.keywords ?? ""}`.toLocaleLowerCase().includes(query.toLocaleLowerCase())
344
+ );
345
+ const renderItem = (item) => /* @__PURE__ */ jsxs(
346
+ Autocomplete.Item,
347
+ {
348
+ value: item,
349
+ disabled: item.disabled,
350
+ className: "signal-option",
351
+ "aria-label": item.label,
352
+ title: item.label,
353
+ onClick: () => {
354
+ onSelect(item);
355
+ setOpen(false);
356
+ setQuery("");
357
+ },
358
+ children: [
359
+ item.preview && /* @__PURE__ */ jsx("span", { className: "signal-content-preview", "aria-hidden": "true", children: item.preview }),
360
+ /* @__PURE__ */ jsxs("span", { className: grid ? "signal-sr-only" : void 0, children: [
361
+ item.label,
362
+ item.description && /* @__PURE__ */ jsx("small", { children: item.description })
363
+ ] })
364
+ ]
365
+ },
366
+ item.id
367
+ );
368
+ return /* @__PURE__ */ jsxs(
369
+ BasePopover.Root,
370
+ {
371
+ open,
372
+ onOpenChange: (v) => {
373
+ setOpen(v);
374
+ if (!v) setQuery("");
375
+ },
376
+ children: [
377
+ /* @__PURE__ */ jsx(
378
+ BasePopover.Trigger,
379
+ {
380
+ render: /* @__PURE__ */ jsx(Button, { iconOnly: compact, "aria-label": label }),
381
+ children: trigger
382
+ }
383
+ ),
384
+ /* @__PURE__ */ jsx(BasePopover.Portal, { children: /* @__PURE__ */ jsx(SignalProvider, { className: "signal-portal", children: /* @__PURE__ */ jsx(
385
+ BasePopover.Positioner,
386
+ {
387
+ className: "signal-positioner",
388
+ sideOffset: 6,
389
+ align: "start",
390
+ children: /* @__PURE__ */ jsxs(
391
+ BasePopover.Popup,
392
+ {
393
+ className: "signal-popup signal-content-picker",
394
+ initialFocus: input,
395
+ children: [
396
+ /* @__PURE__ */ jsx(BasePopover.Title, { children: label }),
397
+ categories.length > 1 && /* @__PURE__ */ jsx(
398
+ Select,
399
+ {
400
+ label: strings.picker.category,
401
+ value: category,
402
+ onValueChange: (v) => setCategory(v ?? "all"),
403
+ options: [
404
+ { value: "all", label: strings.picker.allCategories },
405
+ ...categories.map((c) => ({ value: c, label: c }))
406
+ ]
407
+ }
408
+ ),
409
+ /* @__PURE__ */ jsxs(
410
+ Autocomplete.Root,
411
+ {
412
+ items: matches,
413
+ filter: null,
414
+ value: query,
415
+ onValueChange: setQuery,
416
+ inline: true,
417
+ open: true,
418
+ autoHighlight: "always",
419
+ grid,
420
+ itemToStringValue: (i) => i.label,
421
+ children: [
422
+ /* @__PURE__ */ jsx("label", { className: "signal-sr-only", htmlFor: id, children: strings.picker.search(label) }),
423
+ /* @__PURE__ */ jsx(
424
+ Autocomplete.Input,
425
+ {
426
+ ref: input,
427
+ id,
428
+ className: "signal-input",
429
+ placeholder: strings.picker.placeholder
430
+ }
431
+ ),
432
+ /* @__PURE__ */ jsx(Autocomplete.Empty, { children: /* @__PURE__ */ jsx("div", { className: "signal-option", children: strings.picker.empty }) }),
433
+ /* @__PURE__ */ jsx(
434
+ Autocomplete.List,
435
+ {
436
+ className: "signal-content-options",
437
+ "data-grid": grid || void 0,
438
+ children: grid ? Array.from(
439
+ { length: Math.ceil(matches.length / 6) },
440
+ (_, row) => /* @__PURE__ */ jsx(
441
+ Autocomplete.Row,
442
+ {
443
+ className: "signal-content-grid-row",
444
+ children: matches.slice(row * 6, row * 6 + 6).map(renderItem)
445
+ },
446
+ row
447
+ )
448
+ ) : renderItem
449
+ }
450
+ )
451
+ ]
452
+ }
453
+ )
454
+ ]
455
+ }
456
+ )
457
+ }
458
+ ) }) })
459
+ ]
460
+ }
461
+ );
462
+ }
463
+ var commonEmoji = [
464
+ ["\u{1F600}", "Smile", "happy face"],
465
+ ["\u{1F602}", "Joy", "laugh tears"],
466
+ ["\u{1F979}", "Grateful", "tears touched"],
467
+ ["\u{1F60D}", "Love it", "heart eyes"],
468
+ ["\u{1F914}", "Thinking", "consider question"],
469
+ ["\u{1F60E}", "Cool", "sunglasses"],
470
+ ["\u{1F973}", "Celebration", "party"],
471
+ ["\u{1F622}", "Sad", "cry"],
472
+ ["\u{1F62E}", "Surprised", "wow"],
473
+ ["\u{1F634}", "Sleepy", "tired"],
474
+ ["\u{1FAE1}", "Salute", "respect"],
475
+ ["\u{1F92F}", "Mind blown", "amazing"],
476
+ ["\u{1F44D}", "Thumbs up", "yes approve"],
477
+ ["\u{1F44E}", "Thumbs down", "no disagree"],
478
+ ["\u{1F44F}", "Clapping", "applause"],
479
+ ["\u{1F64C}", "Raised hands", "hooray"],
480
+ ["\u{1F44B}", "Wave", "hello goodbye"],
481
+ ["\u{1F64F}", "Thanks", "please"],
482
+ ["\u2764\uFE0F", "Heart", "love"],
483
+ ["\u{1F499}", "Blue heart", "love"],
484
+ ["\u{1F525}", "Fire", "hot"],
485
+ ["\u2728", "Sparkles", "shine"],
486
+ ["\u{1F389}", "Party popper", "celebrate"],
487
+ ["\u{1F680}", "Rocket", "launch ship"],
488
+ ["\u2705", "Approved", "check done success"],
489
+ ["\u{1F440}", "Eyes", "looking review"],
490
+ ["\u{1F4A1}", "Idea", "light bulb"],
491
+ ["\u{1F4AF}", "Hundred", "perfect"],
492
+ ["\u{1F41B}", "Bug", "error"],
493
+ ["\u{1F6E0}\uFE0F", "Tools", "work fix"],
494
+ ["\u{1F4E6}", "Package", "release"],
495
+ ["\u{1F4DD}", "Notes", "write"],
496
+ ["\u{1F3AF}", "Target", "goal"],
497
+ ["\u2B50", "Star", "favorite"],
498
+ ["\u2615", "Coffee", "break"],
499
+ ["\u{1F331}", "Seedling", "growth"]
500
+ ].map(([emoji, label, keywords]) => ({
501
+ id: label.toLowerCase().replaceAll(" ", "-"),
502
+ emoji,
503
+ label,
504
+ keywords
505
+ }));
506
+ function EmojiPicker({
507
+ onSelect,
508
+ items = commonEmoji,
509
+ label
510
+ }) {
511
+ const strings = useSignalStrings();
512
+ const translated = items.map((item) => {
513
+ const text = strings.emoji[item.id];
514
+ return text ? { ...item, label: text.label, keywords: text.keywords } : item;
515
+ });
516
+ return /* @__PURE__ */ jsx(
517
+ ContentPicker,
518
+ {
519
+ label: label ?? strings.picker.addReaction,
520
+ trigger: /* @__PURE__ */ jsx(SmilePlus, {}),
521
+ grid: true,
522
+ compact: true,
523
+ items: translated.map((i) => ({ ...i, preview: i.emoji })),
524
+ onSelect: (item) => {
525
+ const emoji = items.find((i) => i.id === item.id);
526
+ if (emoji) onSelect(emoji);
527
+ }
528
+ }
529
+ );
530
+ }
531
+
532
+ export {
533
+ SplitButton,
534
+ ContextMenu,
535
+ CommandDialog,
536
+ NotificationDrawer,
537
+ SidePanel,
538
+ ContentPicker,
539
+ commonEmoji,
540
+ EmojiPicker
541
+ };
@@ -0,0 +1,142 @@
1
+ 'use client';
2
+ import {
3
+ Button
4
+ } from "./chunk-EBF2F3LN.js";
5
+ import {
6
+ useSignalStrings
7
+ } from "./chunk-U5W7O3QV.js";
8
+
9
+ // packages/ui/src/file-tree.tsx
10
+ import { useRef, useState } from "react";
11
+ import { ChevronRight, File, Folder, FolderOpen } from "lucide-react";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ function FileTree({
14
+ label,
15
+ nodes,
16
+ expanded,
17
+ defaultExpanded = [],
18
+ onExpandedChange,
19
+ selected,
20
+ onSelect
21
+ }) {
22
+ const strings = useSignalStrings();
23
+ const [localExpanded, setExpanded] = useState(defaultExpanded), [focused, setFocused] = useState();
24
+ const refs = useRef(/* @__PURE__ */ new Map()), typed = useRef({ text: "", time: 0 });
25
+ const open = new Set(expanded ?? localExpanded);
26
+ const visible = [];
27
+ function flatten(items, level, parent) {
28
+ items.forEach((node, i) => {
29
+ visible.push({
30
+ node,
31
+ level,
32
+ parent,
33
+ position: i + 1,
34
+ count: items.length
35
+ });
36
+ if (node.children && open.has(node.id))
37
+ flatten(node.children, level + 1, node.id);
38
+ });
39
+ }
40
+ flatten(nodes, 1);
41
+ const active = visible.some((r) => r.node.id === focused) ? focused : visible.some((r) => r.node.id === selected) ? selected : visible[0]?.node.id;
42
+ const expand = (id, next) => {
43
+ const ids = new Set(open);
44
+ if (next) ids.add(id);
45
+ else ids.delete(id);
46
+ const result = [...ids];
47
+ setExpanded(result);
48
+ onExpandedChange?.(result);
49
+ };
50
+ const focus = (index) => {
51
+ const row = visible[Math.max(0, Math.min(visible.length - 1, index))];
52
+ if (row) {
53
+ setFocused(row.node.id);
54
+ refs.current.get(row.node.id)?.focus();
55
+ }
56
+ };
57
+ if (!nodes.length)
58
+ return /* @__PURE__ */ jsx("p", { className: "signal-muted", children: strings.fileTree.empty });
59
+ return /* @__PURE__ */ jsx(
60
+ "div",
61
+ {
62
+ className: "signal-file-tree",
63
+ role: "tree",
64
+ "aria-label": label ?? strings.fileTree.label,
65
+ children: visible.map(({ node, level, position, count, parent }, index) => /* @__PURE__ */ jsxs(
66
+ Button,
67
+ {
68
+ ref: (el) => {
69
+ if (el) refs.current.set(node.id, el);
70
+ else refs.current.delete(node.id);
71
+ },
72
+ role: "treeitem",
73
+ className: "signal-tree-item",
74
+ style: { paddingInlineStart: 8 + (level - 1) * 18 },
75
+ "aria-level": level,
76
+ "aria-posinset": position,
77
+ "aria-setsize": count,
78
+ "aria-expanded": node.children ? open.has(node.id) : void 0,
79
+ "aria-selected": selected === node.id,
80
+ "aria-disabled": node.disabled || void 0,
81
+ tabIndex: active === node.id ? 0 : -1,
82
+ onFocus: () => setFocused(node.id),
83
+ onClick: () => {
84
+ if (node.disabled) return;
85
+ onSelect?.(node);
86
+ if (node.children) expand(node.id, !open.has(node.id));
87
+ },
88
+ onKeyDown: (e) => {
89
+ if (e.altKey || e.ctrlKey || e.metaKey) return;
90
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) {
91
+ e.preventDefault();
92
+ focus(
93
+ e.key === "Home" ? 0 : e.key === "End" ? visible.length - 1 : index + (e.key === "ArrowDown" ? 1 : -1)
94
+ );
95
+ } else if (e.key === "ArrowRight") {
96
+ e.preventDefault();
97
+ if (node.children && !node.disabled) {
98
+ if (!open.has(node.id)) expand(node.id, true);
99
+ else if (node.children.length) focus(index + 1);
100
+ }
101
+ } else if (e.key === "ArrowLeft") {
102
+ e.preventDefault();
103
+ if (node.children && open.has(node.id) && !node.disabled)
104
+ expand(node.id, false);
105
+ else if (parent)
106
+ focus(visible.findIndex((r) => r.node.id === parent));
107
+ } else if (e.key === " ") {
108
+ e.preventDefault();
109
+ if (!node.disabled) onSelect?.(node);
110
+ } else if (e.key.length === 1) {
111
+ const now = Date.now();
112
+ typed.current = {
113
+ text: now - typed.current.time > 700 ? e.key : typed.current.text + e.key,
114
+ time: now
115
+ };
116
+ const text = typed.current.text.toLocaleLowerCase();
117
+ const match = [
118
+ ...visible.slice(index + 1),
119
+ ...visible.slice(0, index + 1)
120
+ ].find((r) => r.node.name.toLocaleLowerCase().startsWith(text));
121
+ if (match) {
122
+ e.preventDefault();
123
+ focus(visible.indexOf(match));
124
+ }
125
+ }
126
+ },
127
+ children: [
128
+ /* @__PURE__ */ jsx("span", { className: "signal-tree-chevron", "aria-hidden": "true", children: node.children && /* @__PURE__ */ jsx(ChevronRight, { "data-open": open.has(node.id) || void 0 }) }),
129
+ node.children ? open.has(node.id) ? /* @__PURE__ */ jsx(FolderOpen, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Folder, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(File, { "aria-hidden": "true" }),
130
+ /* @__PURE__ */ jsx("span", { className: "signal-tree-name", children: node.name }),
131
+ node.detail && /* @__PURE__ */ jsx("small", { children: node.detail })
132
+ ]
133
+ },
134
+ node.id
135
+ ))
136
+ }
137
+ );
138
+ }
139
+
140
+ export {
141
+ FileTree
142
+ };