@fldr/ui 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -448
- package/ai/component-registry.json +25 -13
- package/ai/component-registry.md +2 -2
- package/dist/.build-complete +1 -1
- package/dist/blocks-source/auth-card/auth-card.test.tsx +20 -14
- package/dist/blocks-source/auth-card/auth-card.tsx +73 -55
- package/dist/blocks-source/file-table/file-table.tsx +197 -150
- package/dist/blocks-source/share-dialog/share-dialog.test.tsx +9 -3
- package/dist/blocks-source/share-dialog/share-dialog.tsx +50 -35
- package/dist/blocks.d.ts +21 -4
- package/dist/blocks.js +246 -195
- package/dist/{button-DzavLWXm.d.ts → button-CS82eT0x.d.ts} +1 -1
- package/dist/chunks/{checkbox-eifiwbw34xwsikvf.js → checkbox-d5epe4dl78bzy4f8.js} +8 -8
- package/dist/chunks/highlighter-kb7huz24pcziin6d.js +57 -0
- package/dist/chunks/{layer-dialog-m8qb0wzfg3k7406a.js → layer-dialog-mnaw06pxom8q771w.js} +3 -2
- package/dist/chunks/{table-ngl1b5yc8mcur662.js → table-bdye068ekayq3u1n.js} +1 -1
- package/dist/chunks/table-f8vl74hdx3bzqqbf.js +448 -0
- package/dist/code/server.js +1 -1
- package/dist/code.js +4 -131
- package/dist/components/banner.d.ts +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/input-group.d.ts +2 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/layer-dialog.js +1 -1
- package/dist/components/link.d.ts +2 -67
- package/dist/components/sidebar.d.ts +2 -1
- package/dist/components/table.d.ts +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/toast.d.ts +1 -1
- package/dist/components/toolbar.d.ts +1 -1
- package/dist/form.d.ts +207 -0
- package/dist/form.js +317 -0
- package/dist/hotkeys.d.ts +135 -0
- package/dist/hotkeys.js +206 -0
- package/dist/index-9LwQy84o.d.ts +1 -0
- package/dist/index-B7iG0qDU.d.ts +1 -0
- package/dist/{index-B6JNUfG9.d.ts → index-BMXHK-3k.d.ts} +2 -2
- package/dist/{index-B6Wo_iiN.d.ts → index-B_ug9XY7.d.ts} +1 -1
- package/dist/{index-RP_rt8vB.d.ts → index-Bh9kuAvN.d.ts} +1 -1
- package/dist/{index-DjSGDESy.d.ts → index-CAUjUp2G.d.ts} +1 -1
- package/dist/{index-NnHba-T1.d.ts → index-DK28YxxP.d.ts} +2 -2
- package/dist/{index-aahL-0Zw.d.ts → index-DOVlARA6.d.ts} +2 -2
- package/dist/index-DTj6M6kA.d.ts +1 -0
- package/dist/index.d.ts +14 -12
- package/dist/index.js +3 -4
- package/dist/{input-group-8gEtPiKw.d.ts → input-group-Swzit45o.d.ts} +1 -1
- package/dist/link-CoVXE5W2.d.ts +68 -0
- package/dist/query.d.ts +156 -0
- package/dist/query.js +204 -0
- package/dist/router.d.ts +95 -0
- package/dist/router.js +146 -0
- package/dist/skeleton.d.ts +3 -0
- package/dist/skeleton.js +4 -0
- package/dist/styles/kumo-binding.css +10 -0
- package/dist/styles/kumo-standalone.css +1 -1
- package/dist/styles/theme-fldr.css +18 -18
- package/dist/table.d.ts +245 -0
- package/dist/table.js +3 -0
- package/dist/theming.d.ts +4 -4
- package/dist/theming.js +2 -2
- package/package.json +41 -1
- package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +0 -1364
- package/dist/index-DL1-uSuH.d.ts +0 -1
- /package/dist/{index-BkTAB4wj.d.ts → sidebar-BkTAB4wj.d.ts} +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createHighlighter } from "@tanstack/highlight/core";
|
|
3
|
+
import { css } from "@tanstack/highlight/languages/css";
|
|
4
|
+
import { diff } from "@tanstack/highlight/languages/diff";
|
|
5
|
+
import { graphql } from "@tanstack/highlight/languages/graphql";
|
|
6
|
+
import { html } from "@tanstack/highlight/languages/html";
|
|
7
|
+
import { js } from "@tanstack/highlight/languages/js";
|
|
8
|
+
import { json } from "@tanstack/highlight/languages/json";
|
|
9
|
+
import { jsx } from "@tanstack/highlight/languages/jsx";
|
|
10
|
+
import { markdown } from "@tanstack/highlight/languages/markdown";
|
|
11
|
+
import { python } from "@tanstack/highlight/languages/python";
|
|
12
|
+
import { shell } from "@tanstack/highlight/languages/shell";
|
|
13
|
+
import { sql } from "@tanstack/highlight/languages/sql";
|
|
14
|
+
import { toml } from "@tanstack/highlight/languages/toml";
|
|
15
|
+
import { ts } from "@tanstack/highlight/languages/ts";
|
|
16
|
+
import { tsx } from "@tanstack/highlight/languages/tsx";
|
|
17
|
+
import { yaml } from "@tanstack/highlight/languages/yaml";
|
|
18
|
+
//#region src/code/highlighter.ts
|
|
19
|
+
/**
|
|
20
|
+
* Kumo's shared highlighter. TanStack Highlight is synchronous, so there is
|
|
21
|
+
* no provider or loading state: grammars are plain imports, created once.
|
|
22
|
+
* Unknown languages render as escaped plain text.
|
|
23
|
+
*/
|
|
24
|
+
const highlighter = createHighlighter({ languages: [
|
|
25
|
+
css,
|
|
26
|
+
diff,
|
|
27
|
+
graphql,
|
|
28
|
+
html,
|
|
29
|
+
js,
|
|
30
|
+
json,
|
|
31
|
+
jsx,
|
|
32
|
+
markdown,
|
|
33
|
+
python,
|
|
34
|
+
shell,
|
|
35
|
+
sql,
|
|
36
|
+
toml,
|
|
37
|
+
ts,
|
|
38
|
+
tsx,
|
|
39
|
+
yaml
|
|
40
|
+
] });
|
|
41
|
+
/** Highlight code to an HTML string (`<pre class="th-code">…</pre>`). Safe to call during SSR. */
|
|
42
|
+
function highlightCode(code, lang, options = {}) {
|
|
43
|
+
return highlighter.highlightToHtml(code, {
|
|
44
|
+
lang,
|
|
45
|
+
lineNumbers: options.lineNumbers,
|
|
46
|
+
decorations: options.highlightLines?.map((line) => ({
|
|
47
|
+
lines: line,
|
|
48
|
+
className: "line-highlighted"
|
|
49
|
+
}))
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** Resolve a language name or alias (`ts`, `bash`, `yml`) to the highlighter's canonical name. */
|
|
53
|
+
function normalizeLanguage(lang) {
|
|
54
|
+
return highlighter.normalizeLanguage(lang);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { normalizeLanguage as n, highlightCode as t };
|
|
@@ -203,7 +203,8 @@ function LayerDialogContent({ children, closeLabel, container: containerProp, si
|
|
|
203
203
|
render: isAlert ? /* @__PURE__ */ jsx("div", { role: "alertdialog" }) : /* @__PURE__ */ jsx("div", {}),
|
|
204
204
|
className: cn("fixed inset-x-0 bottom-0 flex max-h-[85dvh] min-h-0 w-full max-w-none [transform:translate3d(0,var(--drawer-swipe-movement-y,0px),0)] transform-gpu overflow-visible transition-[transform,opacity] duration-[450ms] ease-[cubic-bezier(0.32,0.72,0,1)] will-change-transform outline-none data-[ending-style]:[transform:translate3d(0,100%,0)] data-[ending-style]:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-[starting-style]:[transform:translate3d(0,100%,0)] data-[swiping]:duration-0 data-[swiping]:select-none motion-reduce:transition-none sm:static sm:max-h-full sm:[transform:translate3d(0,0,0)] sm:duration-200 sm:data-[ending-style]:[transform:translate3d(0,8px,0)] sm:data-[ending-style]:opacity-0 sm:data-[ending-style]:duration-200 sm:data-[starting-style]:[transform:translate3d(0,8px,0)] sm:data-[starting-style]:opacity-0", sizeConfig.classes),
|
|
205
205
|
children: /* @__PURE__ */ jsxs(LayerCard, {
|
|
206
|
-
|
|
206
|
+
"data-chinless": actions.element ? void 0 : "",
|
|
207
|
+
className: cn("group/layer-dialog flex max-h-[85dvh] min-h-0 w-full flex-col overflow-hidden rounded-none bg-kumo-elevated p-1.5 shadow-[0_20px_25px_-5px_rgb(0_0_0/0.03),0_8px_10px_-6px_rgb(0_0_0/0.03)] max-sm:border-t max-sm:border-kumo-hairline max-sm:shadow-xs max-sm:ring-0 sm:max-h-full sm:rounded-xl", !actions.element && "bg-kumo-base p-0"),
|
|
207
208
|
children: [!isDesktop && !isAlert && /* @__PURE__ */ jsx("div", {
|
|
208
209
|
"aria-hidden": true,
|
|
209
210
|
className: "flex justify-center pt-1.5 pb-3",
|
|
@@ -272,7 +273,7 @@ function LayerDialogBody({ children }) {
|
|
|
272
273
|
children
|
|
273
274
|
});
|
|
274
275
|
return /* @__PURE__ */ jsxs(LayerCard.Primary, {
|
|
275
|
-
className: "min-h-0 flex-1 gap-0 p-0",
|
|
276
|
+
className: "min-h-0 flex-1 gap-0 p-0 group-data-[chinless]/layer-dialog:rounded-none group-data-[chinless]/layer-dialog:shadow-none group-data-[chinless]/layer-dialog:ring-0",
|
|
276
277
|
children: [
|
|
277
278
|
/* @__PURE__ */ jsxs("div", {
|
|
278
279
|
className: "z-10 flex shrink-0 items-start justify-between gap-4 rounded-t-lg bg-kumo-base px-4 py-4 sm:px-4.5",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { t as cn } from "./vendor-styling-gs32v7xt5znc8kg0.js";
|
|
3
3
|
import { t as resolveVariant } from "./resolve-variant-l6x5ksfrjtu4m66l.js";
|
|
4
|
-
import { t as Checkbox } from "./checkbox-
|
|
4
|
+
import { t as Checkbox } from "./checkbox-d5epe4dl78bzy4f8.js";
|
|
5
5
|
import { forwardRef } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/table/table.tsx
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./vendor-styling-gs32v7xt5znc8kg0.js";
|
|
3
|
+
import { t as Button } from "./button-hzvowfkbathmx8yg.js";
|
|
4
|
+
import { t as Checkbox } from "./checkbox-d5epe4dl78bzy4f8.js";
|
|
5
|
+
import { t as InputGroup } from "./input-group-h9fepskc84e1h11n.js";
|
|
6
|
+
import { t as DropdownMenu } from "./dropdown-e5zk0ez21busnt0b.js";
|
|
7
|
+
import { t as Pagination } from "./pagination-n96r3xdok9nc3pu5.js";
|
|
8
|
+
import { r as Table } from "./table-bdye068ekayq3u1n.js";
|
|
9
|
+
import { SkeletonBox } from "../skeleton.js";
|
|
10
|
+
import { useRef, useState } from "react";
|
|
11
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { CaretDownIcon, CaretUpIcon, MagnifyingGlassIcon, SlidersHorizontalIcon, XIcon } from "@phosphor-icons/react";
|
|
13
|
+
import { columnFilteringFeature, columnVisibilityFeature, createColumnHelper, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, filterFn_includesString, functionalUpdate, globalFilteringFeature, metaHelper, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_basic, sortFn_datetime, sortFn_text, tableFeatures, useTable } from "@tanstack/react-table";
|
|
14
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
15
|
+
import { useDebouncer } from "@tanstack/react-pacer";
|
|
16
|
+
//#region src/table/data-table.tsx
|
|
17
|
+
/** The TanStack features every DataTable registers. */
|
|
18
|
+
const dataTableFeatures = tableFeatures({
|
|
19
|
+
rowSortingFeature,
|
|
20
|
+
sortedRowModel: createSortedRowModel(),
|
|
21
|
+
sortFns: {
|
|
22
|
+
alphanumeric: sortFn_alphanumeric,
|
|
23
|
+
basic: sortFn_basic,
|
|
24
|
+
datetime: sortFn_datetime,
|
|
25
|
+
text: sortFn_text
|
|
26
|
+
},
|
|
27
|
+
rowSelectionFeature,
|
|
28
|
+
columnVisibilityFeature,
|
|
29
|
+
columnFilteringFeature,
|
|
30
|
+
globalFilteringFeature,
|
|
31
|
+
filteredRowModel: createFilteredRowModel(),
|
|
32
|
+
filterFns: { includesString: filterFn_includesString },
|
|
33
|
+
rowPaginationFeature,
|
|
34
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
35
|
+
columnMeta: metaHelper()
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Column helper bound to DataTable's features, so apps only pass the row type.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const col = createColumnHelper<Receipt>();
|
|
43
|
+
* const columns = col.columns([
|
|
44
|
+
* selectColumn<Receipt>(),
|
|
45
|
+
* col.accessor("vendor", { header: "Vendor" }),
|
|
46
|
+
* ]);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function createColumnHelper$1() {
|
|
50
|
+
return createColumnHelper();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a table instance with DataTable's features. Use it when you need the
|
|
54
|
+
* instance yourself (toolbar, controlled state, server data); otherwise pass
|
|
55
|
+
* `columns` and `data` straight to `DataTable`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* const table = useDataTable({ columns, data, getRowId: (r) => r.id, pageSize: 50 });
|
|
60
|
+
* return <DataTable table={table} />;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
function useDataTable({ pageSize, ...options }) {
|
|
64
|
+
return useTable({
|
|
65
|
+
features: dataTableFeatures,
|
|
66
|
+
globalFilterFn: "includesString",
|
|
67
|
+
manualPagination: pageSize === void 0,
|
|
68
|
+
...options,
|
|
69
|
+
initialState: {
|
|
70
|
+
...pageSize !== void 0 && { pagination: {
|
|
71
|
+
pageIndex: 0,
|
|
72
|
+
pageSize
|
|
73
|
+
} },
|
|
74
|
+
...options.initialState
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const CHECKBOX_HIT_AREA = "relative before:absolute before:-inset-3 before:content-['']";
|
|
79
|
+
/**
|
|
80
|
+
* Checkbox column for row selection: a select-all box in the header and one
|
|
81
|
+
* per row. Clicks on it never reach `onRowClick`.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const columns = col.columns([selectColumn<Receipt>({ rowLabel: (r) => `Select ${r.vendor}` }), ...]);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
function selectColumn({ rowLabel = () => "Select row", allLabel = "Select all rows" } = {}) {
|
|
89
|
+
return {
|
|
90
|
+
id: "select",
|
|
91
|
+
enableSorting: false,
|
|
92
|
+
enableHiding: false,
|
|
93
|
+
enableGlobalFilter: false,
|
|
94
|
+
meta: { className: "w-10 leading-none" },
|
|
95
|
+
header: ({ table }) => /* @__PURE__ */ jsx(Checkbox, {
|
|
96
|
+
"aria-label": allLabel,
|
|
97
|
+
checked: table.getIsAllRowsSelected(),
|
|
98
|
+
indeterminate: table.getIsSomeRowsSelected(),
|
|
99
|
+
onCheckedChange: (checked) => table.toggleAllRowsSelected(checked),
|
|
100
|
+
className: CHECKBOX_HIT_AREA
|
|
101
|
+
}),
|
|
102
|
+
cell: ({ row }) => /* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "inline-flex",
|
|
104
|
+
onClick: (e) => e.stopPropagation(),
|
|
105
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
106
|
+
"aria-label": rowLabel(row.original),
|
|
107
|
+
checked: row.getIsSelected(),
|
|
108
|
+
disabled: !row.getCanSelect(),
|
|
109
|
+
onCheckedChange: (checked) => row.toggleSelected(checked),
|
|
110
|
+
className: CHECKBOX_HIT_AREA
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const DEFAULT_LABELS$1 = {
|
|
116
|
+
selected: (count) => `${count} selected`,
|
|
117
|
+
clearSelection: "Clear selection",
|
|
118
|
+
noResults: "No results",
|
|
119
|
+
loading: "Loading"
|
|
120
|
+
};
|
|
121
|
+
const sortAria = (sorted) => sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : void 0;
|
|
122
|
+
/**
|
|
123
|
+
* DataTable — a TanStack Table rendered with Kumo table styles: sortable
|
|
124
|
+
* headers, row selection with a bulk-action bar, global filter, pagination or
|
|
125
|
+
* virtualization, loading and empty states.
|
|
126
|
+
*
|
|
127
|
+
* Pass `columns` + `data` (plus any table options), or a `table` from
|
|
128
|
+
* `useDataTable` for full control.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```tsx
|
|
132
|
+
* <DataTable
|
|
133
|
+
* columns={columns}
|
|
134
|
+
* data={receipts}
|
|
135
|
+
* getRowId={(r) => r.id}
|
|
136
|
+
* toolbar={(table) => <DataTableToolbar table={table} />}
|
|
137
|
+
* bulkActions={(rows) => <Button size="sm">Export {rows.length}</Button>}
|
|
138
|
+
* onRowClick={(row) => open(row.original)}
|
|
139
|
+
* />
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
function DataTable(props) {
|
|
143
|
+
if (props.table) return /* @__PURE__ */ jsx(DataTableView, {
|
|
144
|
+
...props,
|
|
145
|
+
table: props.table
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ jsx(OwnedDataTable, { ...props });
|
|
148
|
+
}
|
|
149
|
+
function OwnedDataTable({ toolbar, bulkActions, onRowClick, loading, loadingRows, empty, stickyHeader, height, virtualize, pagination, labels, className, table: _table, ...options }) {
|
|
150
|
+
const table = useDataTable(options);
|
|
151
|
+
return /* @__PURE__ */ jsx(DataTableView, {
|
|
152
|
+
table,
|
|
153
|
+
toolbar,
|
|
154
|
+
bulkActions,
|
|
155
|
+
onRowClick,
|
|
156
|
+
loading,
|
|
157
|
+
loadingRows,
|
|
158
|
+
empty,
|
|
159
|
+
stickyHeader,
|
|
160
|
+
height,
|
|
161
|
+
virtualize,
|
|
162
|
+
pagination,
|
|
163
|
+
labels,
|
|
164
|
+
className
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function DataTableView({ table, toolbar, bulkActions, onRowClick, loading, loadingRows = 5, empty, stickyHeader, height, virtualize, pagination, labels: labelsProp, className }) {
|
|
168
|
+
const labels = {
|
|
169
|
+
...DEFAULT_LABELS$1,
|
|
170
|
+
...labelsProp
|
|
171
|
+
};
|
|
172
|
+
const scrollRef = useRef(null);
|
|
173
|
+
const rows = table.getRowModel().rows;
|
|
174
|
+
const virtual = virtualize ? {
|
|
175
|
+
estimateSize: 40,
|
|
176
|
+
overscan: 8,
|
|
177
|
+
...virtualize === true ? {} : virtualize
|
|
178
|
+
} : void 0;
|
|
179
|
+
const scrollHeight = height ?? (virtual ? 480 : void 0);
|
|
180
|
+
const virtualizer = useVirtualizer({
|
|
181
|
+
enabled: !!virtual && !loading,
|
|
182
|
+
count: rows.length,
|
|
183
|
+
getScrollElement: () => scrollRef.current,
|
|
184
|
+
estimateSize: () => virtual?.estimateSize ?? 40,
|
|
185
|
+
overscan: virtual?.overscan ?? 8,
|
|
186
|
+
getItemKey: (index) => rows[index]?.id ?? index,
|
|
187
|
+
initialRect: {
|
|
188
|
+
width: 0,
|
|
189
|
+
height: typeof scrollHeight === "number" ? scrollHeight : 480
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
const items = virtual ? virtualizer.getVirtualItems() : [];
|
|
193
|
+
const visibleRows = virtual ? items.map((item) => rows[item.index]) : rows;
|
|
194
|
+
const padTop = virtual ? items[0]?.start ?? 0 : 0;
|
|
195
|
+
const padBottom = virtual ? virtualizer.getTotalSize() - (items.at(-1)?.end ?? 0) : 0;
|
|
196
|
+
const columnCount = table.getVisibleLeafColumns().length;
|
|
197
|
+
const selectedCount = table.getSelectedRowIds().length;
|
|
198
|
+
const showPagination = !virtual && (pagination ?? (!table.options.manualPagination || table.options.rowCount !== void 0));
|
|
199
|
+
const { pageIndex, pageSize } = table.state.pagination;
|
|
200
|
+
const bulk = typeof bulkActions === "function" ? bulkActions(table.getSelectedRowModel().rows, table) : bulkActions;
|
|
201
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
202
|
+
className: cn("w-full", className),
|
|
203
|
+
children: [
|
|
204
|
+
toolbar?.(table),
|
|
205
|
+
selectedCount > 0 && /* @__PURE__ */ jsxs("div", {
|
|
206
|
+
role: "toolbar",
|
|
207
|
+
"aria-label": labels.selected(selectedCount),
|
|
208
|
+
className: "flex items-center gap-2 bg-kumo-tint px-3 py-1.5",
|
|
209
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
210
|
+
className: "text-sm font-medium text-kumo-default",
|
|
211
|
+
children: labels.selected(selectedCount)
|
|
212
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
213
|
+
className: "ml-auto flex items-center gap-1.5",
|
|
214
|
+
children: [bulk, /* @__PURE__ */ jsx(Button, {
|
|
215
|
+
variant: "ghost",
|
|
216
|
+
size: "sm",
|
|
217
|
+
shape: "square",
|
|
218
|
+
icon: /* @__PURE__ */ jsx(XIcon, {}),
|
|
219
|
+
"aria-label": labels.clearSelection,
|
|
220
|
+
onClick: () => table.setRowSelection({})
|
|
221
|
+
})]
|
|
222
|
+
})]
|
|
223
|
+
}),
|
|
224
|
+
/* @__PURE__ */ jsx("div", {
|
|
225
|
+
ref: scrollRef,
|
|
226
|
+
className: cn(scrollHeight !== void 0 && "overflow-auto"),
|
|
227
|
+
style: { height: scrollHeight },
|
|
228
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
229
|
+
"aria-busy": loading || void 0,
|
|
230
|
+
children: [/* @__PURE__ */ jsx(Table.Header, {
|
|
231
|
+
variant: "compact",
|
|
232
|
+
sticky: stickyHeader || !!virtual || void 0,
|
|
233
|
+
children: table.getHeaderGroups().map((group) => /* @__PURE__ */ jsx(Table.Row, { children: group.headers.map((header) => {
|
|
234
|
+
const { column } = header;
|
|
235
|
+
const meta = column.columnDef.meta;
|
|
236
|
+
const sorted = column.getIsSorted();
|
|
237
|
+
const Caret = sorted === "desc" ? CaretDownIcon : CaretUpIcon;
|
|
238
|
+
const content = header.isPlaceholder ? null : /* @__PURE__ */ jsx(table.FlexRender, { header });
|
|
239
|
+
return /* @__PURE__ */ jsx(Table.Head, {
|
|
240
|
+
colSpan: header.colSpan,
|
|
241
|
+
"aria-sort": sortAria(sorted),
|
|
242
|
+
className: cn("font-medium", meta?.className, meta?.headerClassName),
|
|
243
|
+
children: column.getCanSort() && !header.isPlaceholder ? /* @__PURE__ */ jsxs("button", {
|
|
244
|
+
type: "button",
|
|
245
|
+
className: "inline-flex cursor-pointer items-center gap-1 text-kumo-subtle hover:text-kumo-default",
|
|
246
|
+
onClick: column.getToggleSortingHandler(),
|
|
247
|
+
children: [content, sorted && /* @__PURE__ */ jsx(Caret, {
|
|
248
|
+
size: 12,
|
|
249
|
+
weight: "bold",
|
|
250
|
+
"aria-hidden": true
|
|
251
|
+
})]
|
|
252
|
+
}) : content
|
|
253
|
+
}, header.id);
|
|
254
|
+
}) }, group.id))
|
|
255
|
+
}), /* @__PURE__ */ jsx(Table.Body, { children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ jsx(Table.Row, {
|
|
256
|
+
className: ROW,
|
|
257
|
+
"aria-label": labels.loading,
|
|
258
|
+
children: Array.from({ length: columnCount }, (_, j) => /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(SkeletonBox, {
|
|
259
|
+
width: "60%",
|
|
260
|
+
height: "0.75em"
|
|
261
|
+
}) }, j))
|
|
262
|
+
}, i)) : rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
263
|
+
colSpan: columnCount,
|
|
264
|
+
className: "py-8 text-center text-kumo-subtle",
|
|
265
|
+
children: empty ?? labels.noResults
|
|
266
|
+
}) }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
267
|
+
padTop > 0 && /* @__PURE__ */ jsx("tr", {
|
|
268
|
+
"aria-hidden": true,
|
|
269
|
+
style: { height: padTop }
|
|
270
|
+
}),
|
|
271
|
+
visibleRows.map((row) => {
|
|
272
|
+
const isSelected = row.getIsSelected();
|
|
273
|
+
return /* @__PURE__ */ jsx(Table.Row, {
|
|
274
|
+
variant: isSelected ? "selected" : "default",
|
|
275
|
+
"aria-selected": isSelected || void 0,
|
|
276
|
+
className: cn(ROW, !isSelected && "even:bg-kumo-base hover:bg-kumo-tint even:hover:bg-kumo-tint", onRowClick && "cursor-pointer"),
|
|
277
|
+
style: virtual ? { height: virtual.estimateSize } : void 0,
|
|
278
|
+
onClick: onRowClick && (() => onRowClick(row)),
|
|
279
|
+
children: row.getVisibleCells().map((cell) => {
|
|
280
|
+
const meta = cell.column.columnDef.meta;
|
|
281
|
+
return /* @__PURE__ */ jsx(Table.Cell, {
|
|
282
|
+
className: cn(meta?.className, meta?.cellClassName),
|
|
283
|
+
children: /* @__PURE__ */ jsx(table.FlexRender, { cell })
|
|
284
|
+
}, cell.id);
|
|
285
|
+
})
|
|
286
|
+
}, row.id);
|
|
287
|
+
}),
|
|
288
|
+
padBottom > 0 && /* @__PURE__ */ jsx("tr", {
|
|
289
|
+
"aria-hidden": true,
|
|
290
|
+
style: { height: padBottom }
|
|
291
|
+
})
|
|
292
|
+
] }) })]
|
|
293
|
+
})
|
|
294
|
+
}),
|
|
295
|
+
showPagination && !loading && /* @__PURE__ */ jsxs(Pagination, {
|
|
296
|
+
page: pageIndex + 1,
|
|
297
|
+
setPage: (page) => table.setPageIndex(page - 1),
|
|
298
|
+
perPage: pageSize,
|
|
299
|
+
totalCount: table.getRowCount(),
|
|
300
|
+
className: "px-3 py-2",
|
|
301
|
+
children: [/* @__PURE__ */ jsx(Pagination.Info, {}), /* @__PURE__ */ jsx(Pagination.Controls, {})]
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/** Hairline divider between body rows; the last row has none. */
|
|
307
|
+
const ROW = "border-b border-kumo-hairline last:border-0";
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/table/search-input.tsx
|
|
310
|
+
/**
|
|
311
|
+
* SearchInput — text field with a search icon and clear button that reports
|
|
312
|
+
* its value debounced (via TanStack Pacer). Escape clears it. Works anywhere,
|
|
313
|
+
* not just in tables.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```tsx
|
|
317
|
+
* <SearchInput placeholder="Search receipts" onValueChange={setQuery} />
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
function SearchInput({ value, defaultValue = "", onValueChange, wait = 250, placeholder, "aria-label": ariaLabel, clearLabel = "Clear search", size = "sm", autoFocus, className }) {
|
|
321
|
+
const [text, setText] = useState(value ?? defaultValue);
|
|
322
|
+
const [emitted, setEmitted] = useState(value ?? defaultValue);
|
|
323
|
+
const [prevValue, setPrevValue] = useState(value);
|
|
324
|
+
if (value !== prevValue) {
|
|
325
|
+
setPrevValue(value);
|
|
326
|
+
if (value !== void 0 && value !== emitted) setText(value);
|
|
327
|
+
}
|
|
328
|
+
const emit = (next) => {
|
|
329
|
+
setEmitted(next);
|
|
330
|
+
onValueChange?.(next);
|
|
331
|
+
};
|
|
332
|
+
const debouncer = useDebouncer(emit, { wait });
|
|
333
|
+
const clear = () => {
|
|
334
|
+
debouncer.cancel();
|
|
335
|
+
setText("");
|
|
336
|
+
emit("");
|
|
337
|
+
};
|
|
338
|
+
return /* @__PURE__ */ jsxs(InputGroup, {
|
|
339
|
+
size,
|
|
340
|
+
className,
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ jsx(InputGroup.Addon, { children: /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "aria-hidden": true }) }),
|
|
343
|
+
/* @__PURE__ */ jsx(InputGroup.Input, {
|
|
344
|
+
role: "searchbox",
|
|
345
|
+
enterKeyHint: "search",
|
|
346
|
+
autoFocus,
|
|
347
|
+
value: text,
|
|
348
|
+
placeholder,
|
|
349
|
+
"aria-label": ariaLabel ?? placeholder ?? "Search",
|
|
350
|
+
onChange: (e) => {
|
|
351
|
+
setText(e.target.value);
|
|
352
|
+
debouncer.maybeExecute(e.target.value);
|
|
353
|
+
},
|
|
354
|
+
onKeyDown: (e) => {
|
|
355
|
+
if (e.key === "Escape" && text) {
|
|
356
|
+
e.preventDefault();
|
|
357
|
+
clear();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}),
|
|
361
|
+
text && /* @__PURE__ */ jsx(InputGroup.Addon, {
|
|
362
|
+
align: "end",
|
|
363
|
+
children: /* @__PURE__ */ jsx(InputGroup.Button, {
|
|
364
|
+
variant: "ghost",
|
|
365
|
+
shape: "square",
|
|
366
|
+
"aria-label": clearLabel,
|
|
367
|
+
icon: /* @__PURE__ */ jsx(XIcon, {}),
|
|
368
|
+
onClick: clear
|
|
369
|
+
})
|
|
370
|
+
})
|
|
371
|
+
]
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/table/toolbar.tsx
|
|
376
|
+
const DEFAULT_LABELS = {
|
|
377
|
+
search: "Search",
|
|
378
|
+
columns: "Columns"
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* DataTableToolbar — global search, column visibility menu and a slot for
|
|
382
|
+
* actions, wired to a DataTable instance.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```tsx
|
|
386
|
+
* <DataTable
|
|
387
|
+
* columns={columns}
|
|
388
|
+
* data={data}
|
|
389
|
+
* toolbar={(table) => (
|
|
390
|
+
* <DataTableToolbar table={table}>
|
|
391
|
+
* <Button size="sm">New folder</Button>
|
|
392
|
+
* </DataTableToolbar>
|
|
393
|
+
* )}
|
|
394
|
+
* />
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
function DataTableToolbar({ table, search = true, columnVisibility = true, children, labels: labelsProp, className }) {
|
|
398
|
+
const labels = {
|
|
399
|
+
...DEFAULT_LABELS,
|
|
400
|
+
...labelsProp
|
|
401
|
+
};
|
|
402
|
+
const globalFilter = table.state.globalFilter;
|
|
403
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
404
|
+
className: cn("flex items-center gap-2 py-2", className),
|
|
405
|
+
children: [search && /* @__PURE__ */ jsx(SearchInput, {
|
|
406
|
+
placeholder: labels.search,
|
|
407
|
+
value: typeof globalFilter === "string" ? globalFilter : "",
|
|
408
|
+
onValueChange: (value) => table.setGlobalFilter(value),
|
|
409
|
+
className: "max-w-xs"
|
|
410
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
411
|
+
className: "ml-auto flex items-center gap-1.5",
|
|
412
|
+
children: [children, columnVisibility && /* @__PURE__ */ jsx(ColumnVisibilityMenu, {
|
|
413
|
+
table,
|
|
414
|
+
label: labels.columns
|
|
415
|
+
})]
|
|
416
|
+
})]
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Dropdown of checkbox items that show and hide a table's hideable columns.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```tsx
|
|
424
|
+
* <ColumnVisibilityMenu table={table} label="Columns" />
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
function ColumnVisibilityMenu({ table, label = DEFAULT_LABELS.columns }) {
|
|
428
|
+
const columns = table.getAllLeafColumns().filter((c) => c.getCanHide());
|
|
429
|
+
if (columns.length === 0) return null;
|
|
430
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, { render: /* @__PURE__ */ jsx(Button, {
|
|
431
|
+
variant: "ghost",
|
|
432
|
+
size: "sm",
|
|
433
|
+
icon: /* @__PURE__ */ jsx(SlidersHorizontalIcon, {}),
|
|
434
|
+
children: label
|
|
435
|
+
}) }), /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
436
|
+
align: "end",
|
|
437
|
+
children: columns.map((column) => {
|
|
438
|
+
const { header, meta } = column.columnDef;
|
|
439
|
+
return /* @__PURE__ */ jsx(DropdownMenu.CheckboxItem, {
|
|
440
|
+
checked: column.getIsVisible(),
|
|
441
|
+
onCheckedChange: (visible) => column.toggleVisibility(visible),
|
|
442
|
+
children: meta?.label ?? (typeof header === "string" ? header : column.id)
|
|
443
|
+
}, column.id);
|
|
444
|
+
})
|
|
445
|
+
})] });
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
export { DataTable as a, selectColumn as c, SearchInput as i, useDataTable as l, ColumnVisibilityMenu as n, createColumnHelper$1 as o, DataTableToolbar as r, dataTableFeatures as s, functionalUpdate as t };
|
package/dist/code/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as normalizeLanguage, t as highlightCode } from "../chunks/highlighter-
|
|
1
|
+
import { n as normalizeLanguage, t as highlightCode } from "../chunks/highlighter-kb7huz24pcziin6d.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/code/server.tsx
|
|
4
4
|
function CodeBlock({ html, className }) {
|
package/dist/code.js
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
import { t as cn } from "./chunks/vendor-styling-gs32v7xt5znc8kg0.js";
|
|
3
3
|
import { t as Button } from "./chunks/button-hzvowfkbathmx8yg.js";
|
|
4
4
|
import { t as useCopyFeedback } from "./chunks/use-copy-feedback-gl55ghst0csvpv4j.js";
|
|
5
|
-
import { n as normalizeLanguage, t as highlightCode } from "./chunks/highlighter-
|
|
5
|
+
import { n as normalizeLanguage, t as highlightCode } from "./chunks/highlighter-kb7huz24pcziin6d.js";
|
|
6
6
|
import { useCallback, useMemo } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
9
|
+
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
10
|
+
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
8
11
|
//#region src/code/code-highlighted.tsx
|
|
9
12
|
/**
|
|
10
13
|
* Syntax-highlighted code block, powered by TanStack Highlight.
|
|
@@ -68,136 +71,6 @@ function CodeHighlighted({ code, lang, variant = "default", showLineNumbers = fa
|
|
|
68
71
|
}
|
|
69
72
|
CodeHighlighted.displayName = "CodeHighlighted";
|
|
70
73
|
//#endregion
|
|
71
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/theme.js
|
|
72
|
-
const themeTokenClasses = [
|
|
73
|
-
"token",
|
|
74
|
-
"attr",
|
|
75
|
-
"code-inline",
|
|
76
|
-
"command",
|
|
77
|
-
"comment",
|
|
78
|
-
"deleted",
|
|
79
|
-
"function",
|
|
80
|
-
"heading",
|
|
81
|
-
"inserted",
|
|
82
|
-
"keyword",
|
|
83
|
-
"link",
|
|
84
|
-
"literal",
|
|
85
|
-
"meta",
|
|
86
|
-
"number",
|
|
87
|
-
"operator",
|
|
88
|
-
"property",
|
|
89
|
-
"selector",
|
|
90
|
-
"string",
|
|
91
|
-
"tag",
|
|
92
|
-
"type",
|
|
93
|
-
"variable"
|
|
94
|
-
];
|
|
95
|
-
function createThemeCss(options) {
|
|
96
|
-
const themeCss = (options.themes || [...options.light ? [{
|
|
97
|
-
selector: options.lightSelector || ":root",
|
|
98
|
-
theme: options.light
|
|
99
|
-
}] : [], ...options.dark ? [{
|
|
100
|
-
selector: options.darkSelector || ".dark",
|
|
101
|
-
theme: options.dark
|
|
102
|
-
}] : []]).map(({ selector, theme }) => createThemeRule(selector, theme)).join("\n\n");
|
|
103
|
-
if (options.includeBaseStyles === false) return themeCss;
|
|
104
|
-
return `${themeCss}\n\n${createThemeBaseCss(options)}`;
|
|
105
|
-
}
|
|
106
|
-
function createThemeRule(selector, theme) {
|
|
107
|
-
return `${selector} {
|
|
108
|
-
${[
|
|
109
|
-
` --th-background: ${theme.background};`,
|
|
110
|
-
` --th-token: ${theme.tokens.token || theme.foreground};`,
|
|
111
|
-
...themeTokenClasses.filter((className) => className !== "token").map((className) => ` --th-${className}: ${theme.tokens[className]};`)
|
|
112
|
-
].join("\n")}
|
|
113
|
-
}`;
|
|
114
|
-
}
|
|
115
|
-
function createThemeBaseCss(options = {}) {
|
|
116
|
-
const codeBlockSelector = options.codeBlockSelector || "pre.th-code";
|
|
117
|
-
const lineNumbersSelector = options.lineNumbersSelector || ".th-code--line-numbers";
|
|
118
|
-
return `${codeBlockSelector} {
|
|
119
|
-
overflow-x: auto;
|
|
120
|
-
padding: 1rem;
|
|
121
|
-
background: var(--th-background);
|
|
122
|
-
color: var(--th-token);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
${themeTokenClasses.map((token) => `.th-${token} { color: var(--th-${token}); }`).join("\n")}
|
|
126
|
-
.th-line { display: inline-block; min-width: 100%; width: max-content; }
|
|
127
|
-
${lineNumbersSelector} code { counter-reset: th-line; }
|
|
128
|
-
${lineNumbersSelector} .th-line::before {
|
|
129
|
-
display: inline-block;
|
|
130
|
-
width: 2.5em;
|
|
131
|
-
padding-right: 1em;
|
|
132
|
-
color: var(--th-comment);
|
|
133
|
-
content: attr(data-line);
|
|
134
|
-
text-align: right;
|
|
135
|
-
user-select: none;
|
|
136
|
-
}`;
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/themes/github-dark.js
|
|
140
|
-
const githubDarkTheme = {
|
|
141
|
-
background: "#0d1117",
|
|
142
|
-
foreground: "#c9d1d9",
|
|
143
|
-
name: "github-dark",
|
|
144
|
-
type: "dark",
|
|
145
|
-
tokens: {
|
|
146
|
-
attr: "#79c0ff",
|
|
147
|
-
"code-inline": "#ffa657",
|
|
148
|
-
command: "#d2a8ff",
|
|
149
|
-
comment: "#8b949e",
|
|
150
|
-
deleted: "#ff7b72",
|
|
151
|
-
function: "#d2a8ff",
|
|
152
|
-
heading: "#79c0ff",
|
|
153
|
-
inserted: "#7ee787",
|
|
154
|
-
keyword: "#ff7b72",
|
|
155
|
-
link: "#58a6ff",
|
|
156
|
-
literal: "#79c0ff",
|
|
157
|
-
meta: "#8b949e",
|
|
158
|
-
number: "#79c0ff",
|
|
159
|
-
operator: "#d2a8ff",
|
|
160
|
-
property: "#79c0ff",
|
|
161
|
-
selector: "#7ee787",
|
|
162
|
-
string: "#a5d6ff",
|
|
163
|
-
tag: "#7ee787",
|
|
164
|
-
token: "#c9d1d9",
|
|
165
|
-
type: "#ffa657",
|
|
166
|
-
variable: "#ffa657"
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region ../../node_modules/.pnpm/@tanstack+highlight@1.2.12/node_modules/@tanstack/highlight/dist/themes/github-light.js
|
|
171
|
-
const githubLightTheme = {
|
|
172
|
-
background: "#ffffff",
|
|
173
|
-
foreground: "#24292f",
|
|
174
|
-
name: "github-light",
|
|
175
|
-
type: "light",
|
|
176
|
-
tokens: {
|
|
177
|
-
attr: "#0550ae",
|
|
178
|
-
"code-inline": "#953800",
|
|
179
|
-
command: "#8250df",
|
|
180
|
-
comment: "#6e7781",
|
|
181
|
-
deleted: "#cf222e",
|
|
182
|
-
function: "#8250df",
|
|
183
|
-
heading: "#0550ae",
|
|
184
|
-
inserted: "#1a7f37",
|
|
185
|
-
keyword: "#cf222e",
|
|
186
|
-
link: "#0969da",
|
|
187
|
-
literal: "#0550ae",
|
|
188
|
-
meta: "#57606a",
|
|
189
|
-
number: "#0550ae",
|
|
190
|
-
operator: "#8250df",
|
|
191
|
-
property: "#0550ae",
|
|
192
|
-
selector: "#116329",
|
|
193
|
-
string: "#0a7f64",
|
|
194
|
-
tag: "#116329",
|
|
195
|
-
token: "#24292f",
|
|
196
|
-
type: "#953800",
|
|
197
|
-
variable: "#953800"
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
//#endregion
|
|
201
74
|
//#region src/code/theme.ts
|
|
202
75
|
/**
|
|
203
76
|
* CSS for code token colors, switched by Kumo's `data-mode`. Pass other
|