@dbx-tools/ui 0.9.205 → 0.9.210
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 +24 -2
- package/index.auth.react.ts +2 -2
- package/index.branding.generated.ts +2 -2
- package/index.branding.react.ts +2 -2
- package/index.branding.ts +2 -2
- package/index.email.react.ts +2 -2
- package/index.react.ts +2 -2
- package/index.search.react.ts +2 -2
- package/index.table.react.ts +10 -0
- package/index.ts +3 -3
- package/package.json +11 -8
- package/src/table/react/data-table-state.ts +159 -0
- package/src/table/react/data-table.tsx +847 -0
- package/src/table/styles.css +286 -0
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# @dbx-tools/ui
|
|
2
2
|
|
|
3
3
|
Use this React package for the shared Databricks AppKit UI foundation, branding,
|
|
4
|
-
passwordless authentication, email surfaces, and
|
|
4
|
+
passwordless authentication, reusable data tables, email surfaces, and
|
|
5
|
+
Databricks AI Search controls.
|
|
5
6
|
Import only the subpaths that your browser application uses.
|
|
6
7
|
|
|
7
8
|
## Foundation
|
|
@@ -24,7 +25,7 @@ viewport variables in each browser event snapshot.
|
|
|
24
25
|
## Choose a UI package
|
|
25
26
|
|
|
26
27
|
- Use `@dbx-tools/ui` for common AppKit components, branding, authentication,
|
|
27
|
-
email, and search. Import its base stylesheet and any feature stylesheet.
|
|
28
|
+
data tables, email, and search. Import its base stylesheet and any feature stylesheet.
|
|
28
29
|
Authentication components call [@dbx-tools/auth-gate](../../node/auth-gate)
|
|
29
30
|
routes. Search components pair with [@dbx-tools/search](../../node/search)
|
|
30
31
|
and use AppKit's published `aiSearch` client configuration.
|
|
@@ -78,6 +79,26 @@ Search components consume
|
|
|
78
79
|
hook. Backend selection and workspace access remain in
|
|
79
80
|
[@dbx-tools/search](../../node/search).
|
|
80
81
|
|
|
82
|
+
## Data tables
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { DataTable, type ColumnDef } from "@dbx-tools/ui/table/react";
|
|
86
|
+
import "@dbx-tools/ui/table/styles.css";
|
|
87
|
+
|
|
88
|
+
const columns: ColumnDef<Row>[] = [
|
|
89
|
+
{ accessorKey: "name", header: "Name" },
|
|
90
|
+
{ accessorKey: "status", header: "Status" },
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
<DataTable id="jobs" data={rows} columns={columns} />;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`DataTable` uses TanStack Table for persisted sorting, filters, column
|
|
97
|
+
visibility, order, and sizes; lazy-rendered variable-height row scrolling;
|
|
98
|
+
header filters; and accessible row activation. State uses local storage by
|
|
99
|
+
default. Pass `persistence={{ storage: "session" }}` for tab-scoped state or
|
|
100
|
+
`persistence={false}` to disable browser storage.
|
|
101
|
+
|
|
81
102
|
## Package exports
|
|
82
103
|
|
|
83
104
|
- `./react`, `./styles.css`: common AppKit UI foundation.
|
|
@@ -85,3 +106,4 @@ hook. Backend selection and workspace access remain in
|
|
|
85
106
|
- `./auth/react`: passwordless sign-in and passkey management.
|
|
86
107
|
- `./email/react`, `./email/styles.css`: approval, preview, and compose UI.
|
|
87
108
|
- `./search/react`, `./search/styles.css`: Databricks AI Search controls and state.
|
|
109
|
+
- `./table/react`, `./table/styles.css`: reusable persisted and lazy-rendered data table.
|
package/index.auth.react.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export * as authGate from "./src/auth/react/auth-gate.tsx";
|
|
6
6
|
export * as passkeyManager from "./src/auth/react/passkey-manager.tsx";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export * as assets from "./src/branding/generated/assets.ts";
|
|
6
6
|
export { dbxToolsAssetSvg, dbxToolsAssetDataUrls } from "./src/branding/generated/assets.ts";
|
package/index.branding.react.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export * as brand from "./src/branding/react/brand.tsx";
|
|
6
6
|
export { BrandProvider, useBrand, BrandIcon, BrandLogo } from "./src/branding/react/brand.tsx";
|
package/index.branding.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export * as browser from "./src/branding/browser.ts";
|
|
6
6
|
export { resolveBrandAsset, brandCssVariables, applyBrandContext } from "./src/branding/browser.ts";
|
package/index.email.react.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export * as emailApprovalCard from "./src/email/react/email-approval-card.tsx";
|
|
6
6
|
export * as emailBody from "./src/email/react/email-body.tsx";
|
package/index.react.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export * as brandPicker from "./src/react/brand-picker.tsx";
|
|
6
6
|
export * as clipboard from "./src/react/clipboard.ts";
|
package/index.search.react.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export * as searchBox from "./src/search/react/search-box.tsx";
|
|
6
6
|
export * as searchResults from "./src/search/react/search-results.tsx";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the exporting modules in ./src.
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
|
+
|
|
5
|
+
export * as dataTableState from "./src/table/react/data-table-state.ts";
|
|
6
|
+
export * as dataTable from "./src/table/react/data-table.tsx";
|
|
7
|
+
export { defaultDataTablePersistedFields, readDataTableState, mergeDataTableColumnOrder, writeDataTableState, dataTableBrowserStorage } from "./src/table/react/data-table-state.ts";
|
|
8
|
+
export type { DataTableStorage, DataTablePersistedField, DataTableStateSnapshot, DataTablePersistence } from "./src/table/react/data-table-state.ts";
|
|
9
|
+
export { DataTable } from "./src/table/react/data-table.tsx";
|
|
10
|
+
export type { DataTableFilterOption, DataTableHeaderFilter, DataTableColumnMeta, DataTableInitialState, DataTableProps, ColumnDef, ColumnFiltersState, ColumnOrderState, ColumnSizingState, OnChangeFn, SortingState, VisibilityState } from "./src/table/react/data-table.tsx";
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// GENERATED by projen
|
|
1
|
+
// GENERATED by projen barrels - DO NOT EDIT.
|
|
2
2
|
// Regenerated from the exporting modules in ./src.
|
|
3
|
-
// Hand edits are overwritten on the next
|
|
3
|
+
// Hand edits are overwritten on the next generation; this file is read-only.
|
|
4
4
|
|
|
5
5
|
export const PACKAGE_IDENTIFIER = "@dbx-tools/ui";
|
|
6
|
-
export const PACKAGE_VERSION = "0.9.
|
|
6
|
+
export const PACKAGE_VERSION = "0.9.210";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbx-tools/ui",
|
|
3
|
-
"description": "AppKit React foundation with branding, authentication, email, and search surfaces",
|
|
3
|
+
"description": "AppKit React foundation with branding, authentication, data tables, email, and search surfaces",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/reggie-db/dbx-tools.git",
|
|
@@ -31,12 +31,13 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@better-auth/passkey": "1.7.6",
|
|
33
33
|
"@databricks/appkit-ui": "0.81.0",
|
|
34
|
-
"@dbx-tools/shared-appkit": "0.9.
|
|
35
|
-
"@dbx-tools/shared-auth": "0.9.
|
|
36
|
-
"@dbx-tools/shared-core": "0.9.
|
|
37
|
-
"@dbx-tools/shared-email": "0.9.
|
|
38
|
-
"@dbx-tools/shared-email-template": "0.9.
|
|
39
|
-
"@dbx-tools/shared-search": "0.9.
|
|
34
|
+
"@dbx-tools/shared-appkit": "0.9.210",
|
|
35
|
+
"@dbx-tools/shared-auth": "0.9.210",
|
|
36
|
+
"@dbx-tools/shared-core": "0.9.210",
|
|
37
|
+
"@dbx-tools/shared-email": "0.9.210",
|
|
38
|
+
"@dbx-tools/shared-email-template": "0.9.210",
|
|
39
|
+
"@dbx-tools/shared-search": "0.9.210",
|
|
40
|
+
"@tanstack/react-table": "^8.21.3",
|
|
40
41
|
"lucide-react": "^0.554.0",
|
|
41
42
|
"shiki": "^3.0.0",
|
|
42
43
|
"streamdown": "^2.5.0",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public"
|
|
49
50
|
},
|
|
50
|
-
"version": "0.9.
|
|
51
|
+
"version": "0.9.210",
|
|
51
52
|
"types": "index.ts",
|
|
52
53
|
"dbxToolsConfig": {
|
|
53
54
|
"tags": [
|
|
@@ -64,8 +65,10 @@
|
|
|
64
65
|
"./email/react": "./index.email.react.ts",
|
|
65
66
|
"./react": "./index.react.ts",
|
|
66
67
|
"./search/react": "./index.search.react.ts",
|
|
68
|
+
"./table/react": "./index.table.react.ts",
|
|
67
69
|
"./styles.css": "./src/styles.css",
|
|
68
70
|
"./email/styles.css": "./src/email/styles.css",
|
|
71
|
+
"./table/styles.css": "./src/table/styles.css",
|
|
69
72
|
"./search/styles.css": "./src/search/styles.css",
|
|
70
73
|
"./branding/styles.css": "./src/branding/styles.css",
|
|
71
74
|
"./branding/brand-bridge.css": "./src/branding/brand-bridge.css",
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { isRecord } from "@dbx-tools/shared-core";
|
|
2
|
+
import type {
|
|
3
|
+
ColumnFiltersState,
|
|
4
|
+
ColumnOrderState,
|
|
5
|
+
ColumnSizingState,
|
|
6
|
+
SortingState,
|
|
7
|
+
VisibilityState,
|
|
8
|
+
} from "@tanstack/react-table";
|
|
9
|
+
|
|
10
|
+
/** Browser storage used for persisted table state. */
|
|
11
|
+
export type DataTableStorage = "local" | "session";
|
|
12
|
+
|
|
13
|
+
/** Table state fields that can be persisted between visits. */
|
|
14
|
+
export type DataTablePersistedField =
|
|
15
|
+
"columnFilters" | "columnOrder" | "columnSizing" | "columnVisibility" | "sorting";
|
|
16
|
+
|
|
17
|
+
/** Persisted, JSON-safe table state. */
|
|
18
|
+
export interface DataTableStateSnapshot {
|
|
19
|
+
columnFilters: ColumnFiltersState;
|
|
20
|
+
columnOrder: ColumnOrderState;
|
|
21
|
+
columnSizing: ColumnSizingState;
|
|
22
|
+
columnVisibility: VisibilityState;
|
|
23
|
+
sorting: SortingState;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Browser persistence configuration. Local storage and all fields are the defaults. */
|
|
27
|
+
export interface DataTablePersistence {
|
|
28
|
+
/** Override the generated `dbx-tools.data-table.<id>.v1` key. */
|
|
29
|
+
key?: string;
|
|
30
|
+
/** Select local or tab-scoped session storage. */
|
|
31
|
+
storage?: DataTableStorage;
|
|
32
|
+
/** Limit which state fields are saved. */
|
|
33
|
+
include?: readonly DataTablePersistedField[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface StorageReader {
|
|
37
|
+
getItem(key: string): string | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface StorageWriter extends StorageReader {
|
|
41
|
+
removeItem(key: string): void;
|
|
42
|
+
setItem(key: string, value: string): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Default set of table fields saved between visits. */
|
|
46
|
+
export const defaultDataTablePersistedFields: readonly DataTablePersistedField[] = [
|
|
47
|
+
"columnFilters",
|
|
48
|
+
"columnOrder",
|
|
49
|
+
"columnSizing",
|
|
50
|
+
"columnVisibility",
|
|
51
|
+
"sorting",
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
function stringArray(value: unknown): string[] | undefined {
|
|
55
|
+
if (!Array.isArray(value)) return undefined;
|
|
56
|
+
return value.filter((entry): entry is string => typeof entry === "string");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function booleanRecord(value: unknown): VisibilityState | undefined {
|
|
60
|
+
if (!isRecord(value)) return undefined;
|
|
61
|
+
return Object.fromEntries(
|
|
62
|
+
Object.entries(value).filter(
|
|
63
|
+
(entry): entry is [string, boolean] => typeof entry[1] === "boolean",
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function numberRecord(value: unknown): ColumnSizingState | undefined {
|
|
69
|
+
if (!isRecord(value)) return undefined;
|
|
70
|
+
return Object.fromEntries(
|
|
71
|
+
Object.entries(value).filter(
|
|
72
|
+
(entry): entry is [string, number] =>
|
|
73
|
+
typeof entry[1] === "number" && Number.isFinite(entry[1]) && entry[1] > 0,
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function sortingState(value: unknown): SortingState | undefined {
|
|
79
|
+
if (!Array.isArray(value)) return undefined;
|
|
80
|
+
return value.flatMap((entry) =>
|
|
81
|
+
isRecord(entry) && typeof entry.id === "string" && typeof entry.desc === "boolean"
|
|
82
|
+
? [{ id: entry.id, desc: entry.desc }]
|
|
83
|
+
: [],
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function filterState(value: unknown): ColumnFiltersState | undefined {
|
|
88
|
+
if (!Array.isArray(value)) return undefined;
|
|
89
|
+
return value.flatMap((entry) =>
|
|
90
|
+
isRecord(entry) && typeof entry.id === "string" && "value" in entry
|
|
91
|
+
? [{ id: entry.id, value: entry.value }]
|
|
92
|
+
: [],
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Read and validate a persisted table snapshot. */
|
|
97
|
+
export function readDataTableState(
|
|
98
|
+
storage: StorageReader | undefined,
|
|
99
|
+
key: string,
|
|
100
|
+
): Partial<DataTableStateSnapshot> {
|
|
101
|
+
if (!storage) return {};
|
|
102
|
+
try {
|
|
103
|
+
const serialized = storage.getItem(key);
|
|
104
|
+
if (!serialized) return {};
|
|
105
|
+
const value: unknown = JSON.parse(serialized);
|
|
106
|
+
if (!isRecord(value)) return {};
|
|
107
|
+
const columnFilters = filterState(value.columnFilters);
|
|
108
|
+
const columnOrder = stringArray(value.columnOrder);
|
|
109
|
+
const columnSizing = numberRecord(value.columnSizing);
|
|
110
|
+
const columnVisibility = booleanRecord(value.columnVisibility);
|
|
111
|
+
const sorting = sortingState(value.sorting);
|
|
112
|
+
return {
|
|
113
|
+
...(columnFilters ? { columnFilters } : {}),
|
|
114
|
+
...(columnOrder ? { columnOrder } : {}),
|
|
115
|
+
...(columnSizing ? { columnSizing } : {}),
|
|
116
|
+
...(columnVisibility ? { columnVisibility } : {}),
|
|
117
|
+
...(sorting ? { sorting } : {}),
|
|
118
|
+
};
|
|
119
|
+
} catch {
|
|
120
|
+
return {};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Keep saved column order for known columns and append newly introduced columns. */
|
|
125
|
+
export function mergeDataTableColumnOrder(
|
|
126
|
+
saved: ColumnOrderState,
|
|
127
|
+
available: ColumnOrderState,
|
|
128
|
+
): ColumnOrderState {
|
|
129
|
+
const known = saved.filter((id) => available.includes(id));
|
|
130
|
+
return [...known, ...available.filter((id) => !known.includes(id))];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Write selected table fields without breaking interaction when storage is unavailable. */
|
|
134
|
+
export function writeDataTableState(
|
|
135
|
+
storage: StorageWriter | undefined,
|
|
136
|
+
key: string,
|
|
137
|
+
value: DataTableStateSnapshot,
|
|
138
|
+
include: readonly DataTablePersistedField[],
|
|
139
|
+
): void {
|
|
140
|
+
if (!storage) return;
|
|
141
|
+
try {
|
|
142
|
+
storage.setItem(
|
|
143
|
+
key,
|
|
144
|
+
JSON.stringify(Object.fromEntries(include.map((field) => [field, value[field]]))),
|
|
145
|
+
);
|
|
146
|
+
} catch {
|
|
147
|
+
// Table interaction stays available when browser storage is unavailable.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Resolve browser storage without throwing in SSR or privacy-restricted contexts. */
|
|
152
|
+
export function dataTableBrowserStorage(kind: DataTableStorage): StorageWriter | undefined {
|
|
153
|
+
if (typeof window === "undefined") return undefined;
|
|
154
|
+
try {
|
|
155
|
+
return kind === "session" ? window.sessionStorage : window.localStorage;
|
|
156
|
+
} catch {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
}
|