@knkcs/anker 0.0.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 (39) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +129 -0
  3. package/dist/atoms/index.d.ts +536 -0
  4. package/dist/atoms/index.js +845 -0
  5. package/dist/atoms/index.js.map +1 -0
  6. package/dist/avatar-DhqkKdqc.d.ts +29 -0
  7. package/dist/chunk-4D3EY2W2.js +1628 -0
  8. package/dist/chunk-4D3EY2W2.js.map +1 -0
  9. package/dist/chunk-4T32UC26.js +81 -0
  10. package/dist/chunk-4T32UC26.js.map +1 -0
  11. package/dist/chunk-FGKGX4UF.js +36 -0
  12. package/dist/chunk-FGKGX4UF.js.map +1 -0
  13. package/dist/chunk-PZCL4M6I.js +62 -0
  14. package/dist/chunk-PZCL4M6I.js.map +1 -0
  15. package/dist/chunk-QSCNXHMU.js +32 -0
  16. package/dist/chunk-QSCNXHMU.js.map +1 -0
  17. package/dist/chunk-RJPEVNMJ.js +23 -0
  18. package/dist/chunk-RJPEVNMJ.js.map +1 -0
  19. package/dist/chunk-YXTW5OAJ.js +303 -0
  20. package/dist/chunk-YXTW5OAJ.js.map +1 -0
  21. package/dist/components/index.d.ts +413 -0
  22. package/dist/components/index.js +982 -0
  23. package/dist/components/index.js.map +1 -0
  24. package/dist/feedback/index.d.ts +27 -0
  25. package/dist/feedback/index.js +100 -0
  26. package/dist/feedback/index.js.map +1 -0
  27. package/dist/forms/index.d.ts +272 -0
  28. package/dist/forms/index.js +947 -0
  29. package/dist/forms/index.js.map +1 -0
  30. package/dist/number-input-D2X0rWOg.d.ts +18 -0
  31. package/dist/primitives/index.d.ts +396 -0
  32. package/dist/primitives/index.js +478 -0
  33. package/dist/primitives/index.js.map +1 -0
  34. package/dist/search-input-C_Cl2OEx.d.ts +17 -0
  35. package/dist/switch-B0o6G2XE.d.ts +28 -0
  36. package/dist/theme/index.d.ts +496 -0
  37. package/dist/theme/index.js +3 -0
  38. package/dist/theme/index.js.map +1 -0
  39. package/package.json +96 -0
@@ -0,0 +1,982 @@
1
+ import { Skeleton } from '../chunk-FGKGX4UF.js';
2
+ import { Tooltip } from '../chunk-QSCNXHMU.js';
3
+ import { Switch } from '../chunk-RJPEVNMJ.js';
4
+ import { createContext, Timeline, TreeView, Card as Card$1, Heading, Box, Flex, Grid, GridItem, Text, Menu, Portal, HStack, IconButton, Button, Table, Drawer, Spacer, ButtonGroup, Collapsible, Dialog, Separator, useSlotRecipe, chakra, Checkbox } from '@chakra-ui/react';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+ import React2, { createContext as createContext$1, Children, useCallback, useContext } from 'react';
7
+ import { Ellipsis, ChevronLeft, ChevronRight, ArrowUp, ArrowDown, ArrowUpDown, X, ChevronDown, Check } from 'lucide-react';
8
+ import { useReactTable, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
9
+
10
+ var Card = ({
11
+ ref,
12
+ maxW = "full",
13
+ title,
14
+ header,
15
+ footer,
16
+ children,
17
+ ...props
18
+ }) => {
19
+ return /* @__PURE__ */ jsxs(
20
+ Card$1.Root,
21
+ {
22
+ ref,
23
+ bg: "bg-surface",
24
+ w: "full",
25
+ height: "full",
26
+ maxW,
27
+ margin: "0 auto",
28
+ overflow: "hidden",
29
+ ...props,
30
+ children: [
31
+ (header || title) && /* @__PURE__ */ jsx(Card$1.Header, { children: header ?? /* @__PURE__ */ jsx(Heading, { size: "md", children: title }) }),
32
+ /* @__PURE__ */ jsx(Card$1.Body, { overflow: "hidden", children }),
33
+ footer && /* @__PURE__ */ jsx(Card$1.Footer, { children: footer })
34
+ ]
35
+ }
36
+ );
37
+ };
38
+ Card.displayName = "Card";
39
+ var CardList = ({
40
+ children,
41
+ headers,
42
+ hasComponentLeft,
43
+ hasMenu,
44
+ columnCount = 12,
45
+ emptyState
46
+ }) => {
47
+ const colSpan = Math.floor(columnCount / headers.length);
48
+ const isEmpty = Children.count(children) === 0;
49
+ return /* @__PURE__ */ jsxs(Box, { role: "grid", "aria-colcount": headers.length, children: [
50
+ /* @__PURE__ */ jsxs(Flex, { pb: 2, px: hasComponentLeft ? 0 : 6, children: [
51
+ hasComponentLeft && /* @__PURE__ */ jsx(Box, { minWidth: 75, px: 6 }),
52
+ /* @__PURE__ */ jsx(
53
+ Grid,
54
+ {
55
+ w: "100%",
56
+ templateRows: "repeat(1, 1fr)",
57
+ templateColumns: `repeat(${columnCount}, 1fr)`,
58
+ gap: 4,
59
+ fontWeight: "semibold",
60
+ color: "muted",
61
+ children: headers.map((header) => /* @__PURE__ */ jsx(GridItem, { colSpan, role: "columnheader", children: header }, header))
62
+ }
63
+ ),
64
+ hasMenu && /* @__PURE__ */ jsx(Box, { minWidth: "80px", px: 6 })
65
+ ] }),
66
+ /* @__PURE__ */ jsx(Flex, { direction: "column", gap: "3", children: isEmpty && emptyState ? emptyState : children })
67
+ ] });
68
+ };
69
+ CardList.displayName = "CardList";
70
+ var CardListData = ({
71
+ children,
72
+ ...restProps
73
+ }) => {
74
+ const textContent = typeof children === "string" || typeof children === "number" ? String(children) : null;
75
+ return /* @__PURE__ */ jsx(Tooltip, { content: textContent ?? "", disabled: !textContent, children: /* @__PURE__ */ jsx(Text, { lineClamp: 1, color: "muted", ...restProps, children }) });
76
+ };
77
+ CardListData.displayName = "CardListData";
78
+ var CardListItem = ({
79
+ isActive,
80
+ handleItemClick,
81
+ handleItemDoubleClick,
82
+ menuItems,
83
+ componentLeft,
84
+ children,
85
+ columnCount = 12
86
+ }) => {
87
+ const colSpan = Math.floor(columnCount / Children.count(children));
88
+ return /* @__PURE__ */ jsxs(
89
+ Flex,
90
+ {
91
+ role: "row",
92
+ boxShadow: isActive ? "0 0 0 2px var(--chakra-colors-accent)" : "sm",
93
+ bg: "bg-surface",
94
+ borderRadius: "lg",
95
+ alignItems: "stretch",
96
+ overflow: "hidden",
97
+ transition: "all 200ms ease",
98
+ children: [
99
+ /* @__PURE__ */ jsxs(
100
+ Flex,
101
+ {
102
+ width: "100%",
103
+ transition: "all 200ms ease",
104
+ _hover: { bg: "bg-subtle", cursor: "pointer" },
105
+ alignItems: "stretch",
106
+ overflow: "hidden",
107
+ onClick: handleItemClick,
108
+ onDoubleClick: handleItemDoubleClick,
109
+ children: [
110
+ componentLeft && /* @__PURE__ */ jsx(
111
+ Box,
112
+ {
113
+ width: 75,
114
+ px: 6,
115
+ display: "flex",
116
+ justifyContent: "center",
117
+ alignItems: "center",
118
+ children: componentLeft
119
+ }
120
+ ),
121
+ /* @__PURE__ */ jsx(
122
+ Grid,
123
+ {
124
+ px: componentLeft === void 0 ? 6 : 0,
125
+ py: 4,
126
+ width: "100%",
127
+ templateRows: "repeat(1, 1fr)",
128
+ templateColumns: `repeat(${columnCount}, 1fr)`,
129
+ gap: 4,
130
+ children: Children.map(children, (child, index) => /* @__PURE__ */ jsx(
131
+ GridItem,
132
+ {
133
+ colSpan,
134
+ display: "flex",
135
+ alignItems: "center",
136
+ children: child
137
+ },
138
+ index
139
+ ))
140
+ }
141
+ )
142
+ ]
143
+ }
144
+ ),
145
+ menuItems && /* @__PURE__ */ jsxs(Menu.Root, { children: [
146
+ /* @__PURE__ */ jsx(
147
+ Menu.Trigger,
148
+ {
149
+ width: "80px",
150
+ px: 6,
151
+ display: "flex",
152
+ bg: "accent",
153
+ color: "on-accent",
154
+ alignItems: "center",
155
+ justifyContent: "center",
156
+ _hover: { opacity: 0.9 },
157
+ children: /* @__PURE__ */ jsx(Ellipsis, { size: 20 })
158
+ }
159
+ ),
160
+ /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, { children: /* @__PURE__ */ jsx(Menu.Content, { children: menuItems.map((menuItem) => /* @__PURE__ */ jsxs(
161
+ Menu.Item,
162
+ {
163
+ onClick: menuItem.onClick,
164
+ color: menuItem.color,
165
+ value: menuItem.value ?? menuItem.label,
166
+ children: [
167
+ menuItem.icon,
168
+ menuItem.label
169
+ ]
170
+ },
171
+ menuItem.label
172
+ )) }) }) })
173
+ ] })
174
+ ]
175
+ }
176
+ );
177
+ };
178
+ CardListItem.displayName = "CardListItem";
179
+ var Pagination = (props) => {
180
+ const {
181
+ page,
182
+ total,
183
+ pageSize = 10,
184
+ onPageChange,
185
+ maxVisiblePages = 5,
186
+ previousLabel = "Previous page",
187
+ nextLabel = "Next page"
188
+ } = props;
189
+ const totalPages = Math.max(1, Math.ceil(total / pageSize));
190
+ const currentPage = Math.min(Math.max(1, page), totalPages);
191
+ const pages = getVisiblePages(currentPage, totalPages, maxVisiblePages);
192
+ return /* @__PURE__ */ jsxs(HStack, { gap: 1, children: [
193
+ /* @__PURE__ */ jsx(
194
+ IconButton,
195
+ {
196
+ variant: "ghost",
197
+ size: "sm",
198
+ "aria-label": previousLabel,
199
+ disabled: currentPage <= 1,
200
+ onClick: () => onPageChange(currentPage - 1),
201
+ children: /* @__PURE__ */ jsx(ChevronLeft, { size: 16 })
202
+ }
203
+ ),
204
+ pages.map(
205
+ (p) => p === "ellipsis-start" || p === "ellipsis-end" ? /* @__PURE__ */ jsx(Text, { px: 2, color: "muted", fontSize: "sm", children: "\u2026" }, p) : /* @__PURE__ */ jsx(
206
+ Button,
207
+ {
208
+ variant: p === currentPage ? "solid" : "ghost",
209
+ colorPalette: p === currentPage ? "primary" : void 0,
210
+ size: "sm",
211
+ minW: "36px",
212
+ onClick: () => onPageChange(p),
213
+ "aria-current": p === currentPage ? "page" : void 0,
214
+ children: p
215
+ },
216
+ p
217
+ )
218
+ ),
219
+ /* @__PURE__ */ jsx(
220
+ IconButton,
221
+ {
222
+ variant: "ghost",
223
+ size: "sm",
224
+ "aria-label": nextLabel,
225
+ disabled: currentPage >= totalPages,
226
+ onClick: () => onPageChange(currentPage + 1),
227
+ children: /* @__PURE__ */ jsx(ChevronRight, { size: 16 })
228
+ }
229
+ )
230
+ ] });
231
+ };
232
+ Pagination.displayName = "Pagination";
233
+ function getVisiblePages(current, total, max) {
234
+ if (total <= max) {
235
+ return Array.from({ length: total }, (_, i) => i + 1);
236
+ }
237
+ const pages = [];
238
+ const half = Math.floor((max - 2) / 2);
239
+ let start = Math.max(2, current - half);
240
+ let end = Math.min(total - 1, current + half);
241
+ if (current - half <= 2) {
242
+ end = Math.min(total - 1, max - 1);
243
+ }
244
+ if (current + half >= total - 1) {
245
+ start = Math.max(2, total - max + 2);
246
+ }
247
+ pages.push(1);
248
+ if (start > 2) pages.push("ellipsis-start");
249
+ for (let i = start; i <= end; i++) {
250
+ pages.push(i);
251
+ }
252
+ if (end < total - 1) pages.push("ellipsis-end");
253
+ pages.push(total);
254
+ return pages;
255
+ }
256
+ var LOADING_ROW_COUNT = 5;
257
+ function DataTableInner(props) {
258
+ const {
259
+ columns,
260
+ data,
261
+ selectable = false,
262
+ rowSelection,
263
+ onRowSelectionChange,
264
+ sorting,
265
+ onSortingChange,
266
+ onRowClick,
267
+ loading = false,
268
+ emptyState,
269
+ total,
270
+ page,
271
+ pageSize,
272
+ onPageChange,
273
+ variant = "line"
274
+ } = props;
275
+ const selectionColumn = {
276
+ id: "_select",
277
+ header: ({ table: table2 }) => /* @__PURE__ */ jsxs(
278
+ Checkbox.Root,
279
+ {
280
+ checked: table2.getIsAllPageRowsSelected() ? true : table2.getIsSomePageRowsSelected() ? "indeterminate" : false,
281
+ onCheckedChange: (details) => table2.toggleAllPageRowsSelected(!!details.checked),
282
+ "aria-label": "Select all rows",
283
+ size: "sm",
284
+ children: [
285
+ /* @__PURE__ */ jsx(Checkbox.HiddenInput, {}),
286
+ /* @__PURE__ */ jsx(Checkbox.Control, {})
287
+ ]
288
+ }
289
+ ),
290
+ cell: ({ row }) => /* @__PURE__ */ jsxs(
291
+ Checkbox.Root,
292
+ {
293
+ checked: row.getIsSelected(),
294
+ onCheckedChange: (details) => row.toggleSelected(!!details.checked),
295
+ "aria-label": `Select row ${String(row.index + 1)}`,
296
+ size: "sm",
297
+ onClick: (e) => e.stopPropagation(),
298
+ children: [
299
+ /* @__PURE__ */ jsx(Checkbox.HiddenInput, {}),
300
+ /* @__PURE__ */ jsx(Checkbox.Control, {})
301
+ ]
302
+ }
303
+ ),
304
+ enableSorting: false
305
+ };
306
+ const allColumns = selectable ? [selectionColumn, ...columns] : columns;
307
+ const table = useReactTable({
308
+ data,
309
+ columns: allColumns,
310
+ state: {
311
+ ...sorting !== void 0 ? { sorting } : {},
312
+ ...rowSelection !== void 0 ? { rowSelection } : {}
313
+ },
314
+ onSortingChange,
315
+ onRowSelectionChange,
316
+ getCoreRowModel: getCoreRowModel(),
317
+ getSortedRowModel: getSortedRowModel(),
318
+ enableRowSelection: selectable,
319
+ manualSorting: onSortingChange !== void 0
320
+ });
321
+ const hasPagination = total !== void 0 && page !== void 0 && pageSize !== void 0 && onPageChange !== void 0;
322
+ const isEmpty = !loading && data.length === 0;
323
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
324
+ /* @__PURE__ */ jsx(Box, { overflowX: "auto", children: /* @__PURE__ */ jsxs(Table.Root, { variant, children: [
325
+ /* @__PURE__ */ jsx(Table.Header, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(Table.Row, { children: headerGroup.headers.map((header) => {
326
+ const canSort = header.column.getCanSort();
327
+ const sorted = header.column.getIsSorted();
328
+ return /* @__PURE__ */ jsx(
329
+ Table.ColumnHeader,
330
+ {
331
+ cursor: canSort ? "pointer" : void 0,
332
+ onClick: canSort ? header.column.getToggleSortingHandler() : void 0,
333
+ "aria-sort": sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : canSort ? "none" : void 0,
334
+ userSelect: canSort ? "none" : void 0,
335
+ children: /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 1, children: [
336
+ header.isPlaceholder ? null : flexRender(
337
+ header.column.columnDef.header,
338
+ header.getContext()
339
+ ),
340
+ canSort && sorted === "asc" && /* @__PURE__ */ jsx(ArrowUp, { size: 14, "aria-hidden": "true" }),
341
+ canSort && sorted === "desc" && /* @__PURE__ */ jsx(ArrowDown, { size: 14, "aria-hidden": "true" }),
342
+ canSort && !sorted && /* @__PURE__ */ jsx(ArrowUpDown, { size: 14, "aria-hidden": "true" })
343
+ ] })
344
+ },
345
+ header.id
346
+ );
347
+ }) }, headerGroup.id)) }),
348
+ /* @__PURE__ */ jsxs(Table.Body, { children: [
349
+ loading && Array.from({ length: LOADING_ROW_COUNT }).map((_, rowIdx) => /* @__PURE__ */ jsx(Table.Row, { "aria-hidden": "true", children: allColumns.map((_2, colIdx) => /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Skeleton, { height: "4", borderRadius: "sm" }) }, `loading-cell-${String(colIdx)}`)) }, `loading-${String(rowIdx)}`)),
350
+ !loading && table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(
351
+ Table.Row,
352
+ {
353
+ "data-selected": row.getIsSelected() || void 0,
354
+ cursor: onRowClick ? "pointer" : void 0,
355
+ onClick: onRowClick ? () => onRowClick(row.original) : void 0,
356
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(Table.Cell, { children: flexRender(
357
+ cell.column.columnDef.cell,
358
+ cell.getContext()
359
+ ) }, cell.id))
360
+ },
361
+ row.id
362
+ )),
363
+ isEmpty && /* @__PURE__ */ jsx(Table.Row, { children: /* @__PURE__ */ jsx(
364
+ Table.Cell,
365
+ {
366
+ colSpan: allColumns.length,
367
+ textAlign: "center",
368
+ py: 8,
369
+ children: emptyState ?? /* @__PURE__ */ jsx(Text, { color: "muted", fontSize: "sm", children: "No data available" })
370
+ }
371
+ ) })
372
+ ] })
373
+ ] }) }),
374
+ hasPagination && /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
375
+ Pagination,
376
+ {
377
+ page,
378
+ total,
379
+ pageSize,
380
+ onPageChange
381
+ }
382
+ ) })
383
+ ] });
384
+ }
385
+ var DataTable = DataTableInner;
386
+ DataTable.displayName = "DataTable";
387
+ var DrawerRoot = ({
388
+ children,
389
+ title,
390
+ footerText,
391
+ saveLabel = "Save",
392
+ closeLabel = "Close",
393
+ saveButtonDisabled = false,
394
+ loading = false,
395
+ additionalButtons,
396
+ onSave,
397
+ open,
398
+ onClose,
399
+ ...rest
400
+ }) => {
401
+ return /* @__PURE__ */ jsx(
402
+ Drawer.Root,
403
+ {
404
+ ...rest,
405
+ open,
406
+ onOpenChange: (details) => {
407
+ if (!details.open) {
408
+ onClose();
409
+ }
410
+ },
411
+ children: /* @__PURE__ */ jsxs(Portal, { children: [
412
+ /* @__PURE__ */ jsx(Drawer.Backdrop, {}),
413
+ /* @__PURE__ */ jsx(Drawer.Positioner, { children: /* @__PURE__ */ jsxs(Drawer.Content, { children: [
414
+ /* @__PURE__ */ jsx(Drawer.CloseTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
415
+ Button,
416
+ {
417
+ variant: "ghost",
418
+ size: "sm",
419
+ position: "absolute",
420
+ top: 2,
421
+ insetInlineEnd: 2,
422
+ "aria-label": closeLabel,
423
+ children: /* @__PURE__ */ jsx(X, { size: 16 })
424
+ }
425
+ ) }),
426
+ /* @__PURE__ */ jsx(
427
+ Drawer.Header,
428
+ {
429
+ bg: "bg-surface",
430
+ borderBottom: "1px solid",
431
+ borderColor: "border",
432
+ children: /* @__PURE__ */ jsx(Drawer.Title, { children: title })
433
+ }
434
+ ),
435
+ /* @__PURE__ */ jsx(Drawer.Body, { children }),
436
+ /* @__PURE__ */ jsxs(
437
+ Drawer.Footer,
438
+ {
439
+ fontSize: "sm",
440
+ bg: "bg-subtle",
441
+ borderTop: "1px solid",
442
+ borderColor: "border",
443
+ children: [
444
+ footerText,
445
+ /* @__PURE__ */ jsx(Spacer, {}),
446
+ /* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
447
+ additionalButtons,
448
+ onSave && /* @__PURE__ */ jsx(
449
+ Button,
450
+ {
451
+ size: "sm",
452
+ variant: "solid",
453
+ colorPalette: "primary",
454
+ onClick: onSave,
455
+ disabled: saveButtonDisabled || loading,
456
+ loading,
457
+ children: saveLabel
458
+ }
459
+ )
460
+ ] })
461
+ ]
462
+ }
463
+ )
464
+ ] }) })
465
+ ] })
466
+ }
467
+ );
468
+ };
469
+ DrawerRoot.displayName = "DrawerRoot";
470
+ var FactBox = (props) => {
471
+ const {
472
+ name,
473
+ actions,
474
+ collapsible = true,
475
+ collapseLabel = "Collapse",
476
+ expandLabel = "Expand",
477
+ ...rest
478
+ } = props;
479
+ const [show, setShow] = React2.useState(true);
480
+ const handleToggle = () => {
481
+ setShow(!show);
482
+ };
483
+ return /* @__PURE__ */ jsxs(Box, { w: "full", children: [
484
+ collapsible ? /* @__PURE__ */ jsx(
485
+ Flex,
486
+ {
487
+ flexDirection: "column",
488
+ mx: "auto",
489
+ borderBottom: "1px solid",
490
+ borderColor: "border",
491
+ children: /* @__PURE__ */ jsxs(
492
+ Box,
493
+ {
494
+ display: { md: "flex" },
495
+ alignItems: { md: "center" },
496
+ justifyContent: { md: "space-between" },
497
+ children: [
498
+ /* @__PURE__ */ jsx(Box, { minW: 0, flex: "1 1 0%", children: /* @__PURE__ */ jsxs(HStack, { children: [
499
+ /* @__PURE__ */ jsx(
500
+ IconButton,
501
+ {
502
+ "aria-label": show ? collapseLabel : expandLabel,
503
+ variant: "ghost",
504
+ size: "sm",
505
+ onClick: (e) => {
506
+ e.preventDefault();
507
+ handleToggle();
508
+ },
509
+ children: show ? /* @__PURE__ */ jsx(ChevronDown, { size: 16 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 16 })
510
+ }
511
+ ),
512
+ typeof name === "string" ? /* @__PURE__ */ jsx(Text, { children: name }) : name
513
+ ] }) }),
514
+ actions ? /* @__PURE__ */ jsx(Flex, { flexShrink: 0, marginInlineStart: { md: 4 }, children: /* @__PURE__ */ jsx(ButtonGroup, { children: actions.map(
515
+ (action) => action.type === "button" ? /* @__PURE__ */ jsx(
516
+ IconButton,
517
+ {
518
+ "aria-label": action.ariaLabel,
519
+ size: "md",
520
+ variant: "ghost",
521
+ onClick: action.onClick,
522
+ children: action.icon
523
+ },
524
+ action.id
525
+ ) : /* @__PURE__ */ jsxs(Menu.Root, { children: [
526
+ /* @__PURE__ */ jsx(Menu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
527
+ IconButton,
528
+ {
529
+ "aria-label": action.ariaLabel,
530
+ size: "md",
531
+ variant: "ghost",
532
+ children: action.icon
533
+ }
534
+ ) }),
535
+ /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, { children: /* @__PURE__ */ jsx(Menu.Content, { children: action.items?.map((item) => /* @__PURE__ */ jsxs(
536
+ Menu.Item,
537
+ {
538
+ onSelect: item.onSelect,
539
+ "aria-label": item.ariaLabel,
540
+ value: `action-${item.id}`,
541
+ children: [
542
+ item.icon,
543
+ item.ariaLabel
544
+ ]
545
+ },
546
+ item.id
547
+ )) }) }) })
548
+ ] }, action.id)
549
+ ) }) }) : null
550
+ ]
551
+ }
552
+ )
553
+ }
554
+ ) : null,
555
+ /* @__PURE__ */ jsx(Collapsible.Root, { open: show, children: /* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsx(Card, { ...rest, children: rest.children }) }) })
556
+ ] });
557
+ };
558
+ FactBox.displayName = "FactBox";
559
+ var LabeledSwitch = ({
560
+ ref,
561
+ ...props
562
+ }) => {
563
+ const { name, label, ...rest } = props;
564
+ return /* @__PURE__ */ jsxs(Box, { children: [
565
+ /* @__PURE__ */ jsx(Text, { asChild: true, children: /* @__PURE__ */ jsx(Flex, { children: label }) }),
566
+ /* @__PURE__ */ jsx(Switch, { id: name, ref, ...rest })
567
+ ] });
568
+ };
569
+ LabeledSwitch.displayName = "LabeledSwitch";
570
+ var Modal = ({
571
+ open,
572
+ onClose,
573
+ header,
574
+ children,
575
+ footer,
576
+ size = "xl",
577
+ closeLabel = "Close",
578
+ saveLabel = "Save",
579
+ cancelLabel = "Cancel",
580
+ onSave,
581
+ saveDisabled = false,
582
+ loading = false,
583
+ ...rest
584
+ }) => {
585
+ const defaultFooter = onSave ? /* @__PURE__ */ jsxs(Flex, { gap: 3, justify: "flex-end", w: "full", children: [
586
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: onClose, children: cancelLabel }),
587
+ /* @__PURE__ */ jsx(
588
+ Button,
589
+ {
590
+ variant: "solid",
591
+ colorPalette: "primary",
592
+ onClick: onSave,
593
+ disabled: saveDisabled || loading,
594
+ loading,
595
+ children: saveLabel
596
+ }
597
+ )
598
+ ] }) : null;
599
+ const footerContent = footer !== void 0 ? footer : defaultFooter;
600
+ return /* @__PURE__ */ jsx(
601
+ Dialog.Root,
602
+ {
603
+ ...rest,
604
+ open,
605
+ size,
606
+ onOpenChange: (details) => {
607
+ if (!details.open) {
608
+ onClose();
609
+ }
610
+ },
611
+ children: /* @__PURE__ */ jsxs(Portal, { children: [
612
+ /* @__PURE__ */ jsx(Dialog.Backdrop, {}),
613
+ /* @__PURE__ */ jsx(Dialog.Positioner, { children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
614
+ /* @__PURE__ */ jsxs(Dialog.Header, { children: [
615
+ header,
616
+ /* @__PURE__ */ jsx(Spacer, {}),
617
+ /* @__PURE__ */ jsx(Dialog.CloseTrigger, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", size: "sm", "aria-label": closeLabel, children: /* @__PURE__ */ jsx(X, { size: 16 }) }) })
618
+ ] }),
619
+ /* @__PURE__ */ jsx(Separator, {}),
620
+ /* @__PURE__ */ jsx(Dialog.Body, { children }),
621
+ footerContent && /* @__PURE__ */ jsxs(Fragment, { children: [
622
+ /* @__PURE__ */ jsx(Separator, {}),
623
+ /* @__PURE__ */ jsx(Dialog.Footer, { children: footerContent })
624
+ ] })
625
+ ] }) })
626
+ ] })
627
+ }
628
+ );
629
+ };
630
+ Modal.displayName = "Modal";
631
+ var [StepperProvider, useStepperContext] = createContext({
632
+ name: "StepperContext",
633
+ errorMessage: "useStepperContext: `context` is undefined. Seems you forgot to wrap stepper components in `<Stepper />`"
634
+ });
635
+ function useStepper(props) {
636
+ const { step, onChange } = props;
637
+ const [activeIndex, setIndex] = React2.useState(-1);
638
+ const stepsRef = React2.useRef([]);
639
+ const registerStep = React2.useCallback((name) => {
640
+ const newSteps = [...stepsRef.current];
641
+ if (newSteps.indexOf(name) === -1) {
642
+ newSteps.push(name);
643
+ }
644
+ stepsRef.current = newSteps;
645
+ }, []);
646
+ const unregisterStep = React2.useCallback((name) => {
647
+ stepsRef.current = stepsRef.current.filter((step2) => step2 !== name);
648
+ }, []);
649
+ const setStep = useCallback((name) => {
650
+ const i = stepsRef.current.indexOf(name);
651
+ if (i !== -1) {
652
+ setIndex(i);
653
+ }
654
+ }, []);
655
+ const nextStep = () => {
656
+ setIndex(activeIndex + 1);
657
+ };
658
+ const prevStep = () => {
659
+ setIndex(activeIndex - 1);
660
+ };
661
+ React2.useEffect(() => {
662
+ if (typeof step === "string") {
663
+ setStep(step);
664
+ } else if (typeof step === "number") {
665
+ setIndex(step);
666
+ } else if (activeIndex === -1) {
667
+ setIndex(0);
668
+ }
669
+ }, [step, activeIndex, setStep]);
670
+ React2.useEffect(() => {
671
+ onChange?.(activeIndex);
672
+ }, [activeIndex, onChange]);
673
+ const context = {
674
+ stepsRef,
675
+ activeStep: stepsRef.current[activeIndex],
676
+ activeIndex,
677
+ isFirstStep: activeIndex === 0,
678
+ isLastStep: activeIndex === stepsRef.current.length - 1,
679
+ isCompleted: activeIndex >= stepsRef.current.length,
680
+ setIndex,
681
+ setStep,
682
+ nextStep,
683
+ prevStep,
684
+ registerStep,
685
+ unregisterStep
686
+ };
687
+ return context;
688
+ }
689
+ function useStep(props) {
690
+ const { name, isActive, isCompleted } = props;
691
+ const { registerStep, unregisterStep, activeStep } = useStepperContext();
692
+ React2.useEffect(() => {
693
+ if (!name) {
694
+ return;
695
+ }
696
+ registerStep(name);
697
+ return () => {
698
+ unregisterStep(name);
699
+ };
700
+ }, [name, registerStep, unregisterStep]);
701
+ return {
702
+ isActive: name ? activeStep === name : isActive,
703
+ isCompleted
704
+ };
705
+ }
706
+ function useStepperPrevButton({ label = "Back" } = {}) {
707
+ const { isFirstStep, prevStep } = useStepperContext();
708
+ return {
709
+ disabled: isFirstStep,
710
+ onClick: prevStep,
711
+ children: label
712
+ };
713
+ }
714
+ function useStepperNextButton({
715
+ label = "Next",
716
+ submitLabel = "Submit"
717
+ } = {}) {
718
+ const { isLastStep, isCompleted, nextStep } = useStepperContext();
719
+ return {
720
+ disabled: isCompleted,
721
+ onClick: nextStep,
722
+ children: isLastStep ? submitLabel : label
723
+ };
724
+ }
725
+ function getChildOfType(children, type) {
726
+ return React2.Children.toArray(children).find(
727
+ (item) => item.type === type
728
+ );
729
+ }
730
+ function getChildrenOfType(children, type) {
731
+ return React2.Children.toArray(children).filter(
732
+ (item) => Array.isArray(type) ? type.some((component) => component === item.type) : item.type === type
733
+ );
734
+ }
735
+ var dataAttr = (condition) => condition ? "" : void 0;
736
+ var cx = (...classes) => classes.filter(Boolean).join(" ");
737
+ var StylesContext = createContext$1({});
738
+ var useStyles = () => useContext(StylesContext);
739
+ var Stepper = ({
740
+ ref,
741
+ ...props
742
+ }) => {
743
+ const { orientation, children, ...containerProps } = props;
744
+ return /* @__PURE__ */ jsx(StepperContainer, { ref, orientation, ...containerProps, children: /* @__PURE__ */ jsx(StepperSteps, { orientation, children }) });
745
+ };
746
+ var StepperContainer = ({
747
+ ref,
748
+ ...props
749
+ }) => {
750
+ const {
751
+ children,
752
+ orientation = "horizontal",
753
+ variant,
754
+ size,
755
+ onChange,
756
+ ...rest
757
+ } = props;
758
+ const context = useStepper(props);
759
+ const recipe = useSlotRecipe({ key: "stepper" });
760
+ const styles = recipe({ variant, size, orientation });
761
+ return /* @__PURE__ */ jsx(StylesContext.Provider, { value: styles, children: /* @__PURE__ */ jsx(StepperProvider, { value: context, children: /* @__PURE__ */ jsx(
762
+ chakra.div,
763
+ {
764
+ ref,
765
+ css: styles.container,
766
+ ...rest,
767
+ className: cx("stepper", props.className),
768
+ children
769
+ }
770
+ ) }) });
771
+ };
772
+ var StepperSteps = (props) => {
773
+ const {
774
+ children,
775
+ orientation = "horizontal",
776
+ stepComponent,
777
+ ...rest
778
+ } = props;
779
+ const styles = useStyles();
780
+ const { activeIndex } = useStepperContext();
781
+ const isVertical = orientation === "vertical";
782
+ const Step = stepComponent || StepperStep;
783
+ const steps = getChildrenOfType(children, Step);
784
+ const elements = steps.reduce((memo, step, i, arr) => {
785
+ memo.push(
786
+ /* @__PURE__ */ jsx(
787
+ Step,
788
+ {
789
+ ...step.props,
790
+ icon: step.props.icon || i + 1,
791
+ isActive: activeIndex === i,
792
+ isCompleted: step.props.isCompleted || activeIndex > i
793
+ },
794
+ step.key
795
+ )
796
+ );
797
+ if (isVertical) {
798
+ memo.push(
799
+ /* @__PURE__ */ jsx(StepperContent, { open: activeIndex === i, children: step.props.children }, `content-${step.key}`)
800
+ );
801
+ }
802
+ if (i < arr.length - 1) {
803
+ memo.push(
804
+ /* @__PURE__ */ jsx(
805
+ StepperSeparator,
806
+ {
807
+ isActive: i < activeIndex
808
+ },
809
+ `separator-${step.key}`
810
+ )
811
+ );
812
+ }
813
+ return memo;
814
+ }, []);
815
+ const completed = getChildOfType(children, StepperCompleted);
816
+ const content = activeIndex >= steps.length ? completed : !isVertical ? /* @__PURE__ */ jsx(StepperContent, { children: steps[activeIndex]?.props?.children }) : null;
817
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
818
+ /* @__PURE__ */ jsx(
819
+ chakra.div,
820
+ {
821
+ css: styles.steps,
822
+ ...rest,
823
+ className: cx("stepper__steps", props.className),
824
+ children: elements
825
+ }
826
+ ),
827
+ content
828
+ ] });
829
+ };
830
+ StepperSteps.displayName = "StepperSteps";
831
+ var StepperContent = (props) => {
832
+ const { children, open = true, ...rest } = props;
833
+ const styles = useStyles();
834
+ return /* @__PURE__ */ jsx(
835
+ chakra.div,
836
+ {
837
+ css: styles.content,
838
+ ...rest,
839
+ className: cx("stepper__content", props.className),
840
+ children: /* @__PURE__ */ jsx(Collapsible.Root, { open, children: /* @__PURE__ */ jsx(Collapsible.Content, { children }) })
841
+ }
842
+ );
843
+ };
844
+ StepperContent.displayName = "StepperContent";
845
+ var StepperIcon = (props) => {
846
+ const { icon, isActive, isCompleted, className, ...rest } = props;
847
+ const styles = useStyles();
848
+ const content = isCompleted ? /* @__PURE__ */ jsx(Check, { size: 14 }) : icon;
849
+ return /* @__PURE__ */ jsx(
850
+ chakra.div,
851
+ {
852
+ css: styles.icon,
853
+ ...rest,
854
+ className: cx("stepper__icon", className),
855
+ "data-active": dataAttr(isActive),
856
+ children: content
857
+ }
858
+ );
859
+ };
860
+ StepperIcon.displayName = "StepperIcon";
861
+ var StepperStep = (props) => {
862
+ const { title, icon, isActive, isCompleted, ...rest } = props;
863
+ const step = useStep(props);
864
+ const styles = useStyles();
865
+ return /* @__PURE__ */ jsxs(
866
+ chakra.div,
867
+ {
868
+ ...rest,
869
+ css: styles.step,
870
+ "data-active": dataAttr(step.isActive),
871
+ "data-completed": dataAttr(step.isCompleted),
872
+ "aria-current": step.isActive ? "step" : void 0,
873
+ className: cx("stepper__step", props.className),
874
+ children: [
875
+ /* @__PURE__ */ jsx(StepperIcon, { icon, isActive, isCompleted }),
876
+ title && /* @__PURE__ */ jsx(StepperStepTitle, { children: title })
877
+ ]
878
+ }
879
+ );
880
+ };
881
+ StepperStep.displayName = "StepperStep";
882
+ var StepperSeparator = (props) => {
883
+ const { isActive, ...rest } = props;
884
+ const styles = useStyles();
885
+ return /* @__PURE__ */ jsx(
886
+ chakra.div,
887
+ {
888
+ ...rest,
889
+ "data-active": dataAttr(isActive),
890
+ className: cx("stepper__separator", props.className),
891
+ css: styles.separator
892
+ }
893
+ );
894
+ };
895
+ StepperSeparator.displayName = "StepperSeparator";
896
+ var StepperStepTitle = (props) => {
897
+ const styles = useStyles();
898
+ return /* @__PURE__ */ jsx(
899
+ chakra.p,
900
+ {
901
+ ...props,
902
+ css: styles.title,
903
+ className: cx("stepper__title", props.className)
904
+ }
905
+ );
906
+ };
907
+ StepperStepTitle.displayName = "StepperStepTitle";
908
+ var StepperCompleted = (props) => {
909
+ const styles = useStyles();
910
+ return /* @__PURE__ */ jsx(
911
+ chakra.div,
912
+ {
913
+ css: styles.completed,
914
+ ...props,
915
+ className: cx("stepper__completed", props.className)
916
+ }
917
+ );
918
+ };
919
+ StepperCompleted.displayName = "StepperCompleted";
920
+ var TimelineRoot = Timeline.Root;
921
+ TimelineRoot.displayName = "TimelineRoot";
922
+ var TimelineItem = Timeline.Item;
923
+ TimelineItem.displayName = "TimelineItem";
924
+ var TimelineConnector = Timeline.Connector;
925
+ TimelineConnector.displayName = "TimelineConnector";
926
+ var TimelineSeparator = Timeline.Separator;
927
+ TimelineSeparator.displayName = "TimelineSeparator";
928
+ var TimelineIndicator = Timeline.Indicator;
929
+ TimelineIndicator.displayName = "TimelineIndicator";
930
+ var TimelineContent = Timeline.Content;
931
+ TimelineContent.displayName = "TimelineContent";
932
+ var TimelineTitle = Timeline.Title;
933
+ TimelineTitle.displayName = "TimelineTitle";
934
+ var TimelineDescription = Timeline.Description;
935
+ TimelineDescription.displayName = "TimelineDescription";
936
+ var TreeViewRoot = TreeView.Root;
937
+ TreeViewRoot.displayName = "TreeViewRoot";
938
+ var TreeViewTree = TreeView.Tree;
939
+ TreeViewTree.displayName = "TreeViewTree";
940
+ var TreeViewBranch = TreeView.Branch;
941
+ TreeViewBranch.displayName = "TreeViewBranch";
942
+ var TreeViewBranchContent = TreeView.BranchContent;
943
+ TreeViewBranchContent.displayName = "TreeViewBranchContent";
944
+ var TreeViewBranchControl = TreeView.BranchControl;
945
+ TreeViewBranchControl.displayName = "TreeViewBranchControl";
946
+ var TreeViewBranchTrigger = TreeView.BranchTrigger;
947
+ TreeViewBranchTrigger.displayName = "TreeViewBranchTrigger";
948
+ var TreeViewBranchText = TreeView.BranchText;
949
+ TreeViewBranchText.displayName = "TreeViewBranchText";
950
+ var TreeViewBranchIndicator = TreeView.BranchIndicator;
951
+ TreeViewBranchIndicator.displayName = "TreeViewBranchIndicator";
952
+ var TreeViewItem = TreeView.Item;
953
+ TreeViewItem.displayName = "TreeViewItem";
954
+ var TreeViewItemText = TreeView.ItemText;
955
+ TreeViewItemText.displayName = "TreeViewItemText";
956
+ var TreeViewItemIndicator = TreeView.ItemIndicator;
957
+ TreeViewItemIndicator.displayName = "TreeViewItemIndicator";
958
+ var TreeViewNode = TreeView.Node;
959
+ var TreeViewLabel = TreeView.Label;
960
+ TreeViewLabel.displayName = "TreeViewLabel";
961
+ var Widget = ({
962
+ heading,
963
+ subHeading,
964
+ icon,
965
+ children
966
+ }) => {
967
+ return /* @__PURE__ */ jsx(Card$1.Root, { height: "100%", maxW: "auto", overflow: "hidden", bg: "bg-surface", children: /* @__PURE__ */ jsxs(Card$1.Body, { children: [
968
+ /* @__PURE__ */ jsxs(Box, { mb: "6", children: [
969
+ /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
970
+ /* @__PURE__ */ jsx(Text, { fontWeight: "semibold", children: heading }),
971
+ /* @__PURE__ */ jsx(Box, { color: "subtle", children: icon })
972
+ ] }),
973
+ subHeading && /* @__PURE__ */ jsx(Text, { fontWeight: "medium", fontSize: "xs", color: "muted", children: subHeading })
974
+ ] }),
975
+ children
976
+ ] }) });
977
+ };
978
+ Widget.displayName = "Widget";
979
+
980
+ export { Card, CardList, CardListData, CardListItem, DataTable, DrawerRoot, FactBox, LabeledSwitch, Modal, Pagination, Stepper, StepperCompleted, StepperContainer, StepperContent, StepperIcon, StepperProvider, StepperSeparator, StepperStep, StepperStepTitle, StepperSteps, CardList as Table, CardListData as TableData, CardListItem as TableItem, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineRoot, TimelineSeparator, TimelineTitle, TreeViewBranch, TreeViewBranchContent, TreeViewBranchControl, TreeViewBranchIndicator, TreeViewBranchText, TreeViewBranchTrigger, TreeViewItem, TreeViewItemIndicator, TreeViewItemText, TreeViewLabel, TreeViewNode, TreeViewRoot, TreeViewTree, Widget, useStep, useStepper, useStepperContext, useStepperNextButton, useStepperPrevButton };
981
+ //# sourceMappingURL=index.js.map
982
+ //# sourceMappingURL=index.js.map