@rebasepro/ui 0.2.3 → 0.2.4
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/dist/components/Button.d.ts +2 -2
- package/dist/components/ErrorBoundary.d.ts +25 -3
- package/dist/components/VirtualTable/VirtualTable.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableCell.d.ts +6 -6
- package/dist/components/VirtualTable/VirtualTableHeader.d.ts +8 -8
- package/dist/components/VirtualTable/VirtualTableHeaderRow.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +11 -11
- package/dist/components/VirtualTable/VirtualTableRow.d.ts +1 -1
- package/dist/components/VirtualTable/types.d.ts +9 -9
- package/dist/hooks/useDebounceCallback.d.ts +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +135 -76
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +130 -71
- package/dist/index.umd.js.map +1 -1
- package/dist/util/debounce.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/BooleanSwitch.tsx +1 -1
- package/src/components/Button.tsx +11 -11
- package/src/components/ErrorBoundary.tsx +171 -18
- package/src/components/IconButton.tsx +4 -4
- package/src/components/MultiSelect.tsx +6 -6
- package/src/components/SearchBar.tsx +1 -1
- package/src/components/TextareaAutosize.tsx +2 -2
- package/src/components/VirtualTable/VirtualTable.tsx +8 -8
- package/src/components/VirtualTable/VirtualTableCell.tsx +6 -6
- package/src/components/VirtualTable/VirtualTableHeader.tsx +15 -15
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +6 -6
- package/src/components/VirtualTable/VirtualTableProps.tsx +11 -11
- package/src/components/VirtualTable/VirtualTableRow.tsx +2 -2
- package/src/components/VirtualTable/types.tsx +9 -9
- package/src/hooks/useDebounceCallback.tsx +2 -1
- package/src/index.css +1 -1
- package/src/util/debounce.ts +2 -1
- package/src/scripts/migrateIconImports.ts +0 -108
- package/src/scripts/test.ts +0 -6
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { FilterFormFieldProps } from "./VirtualTableHeader";
|
|
5
5
|
|
|
6
|
-
export type OnRowClickParams<T extends Record<string,
|
|
6
|
+
export type OnRowClickParams<T extends Record<string, unknown>> = {
|
|
7
7
|
rowData: T;
|
|
8
8
|
rowIndex: number;
|
|
9
9
|
event: React.SyntheticEvent
|
|
@@ -13,7 +13,7 @@ export type OnRowClickParams<T extends Record<string, any>> = {
|
|
|
13
13
|
* @see Table
|
|
14
14
|
* @group Components
|
|
15
15
|
*/
|
|
16
|
-
export interface VirtualTableProps<T extends Record<string,
|
|
16
|
+
export interface VirtualTableProps<T extends Record<string, unknown>> {
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Array of arbitrary data
|
|
@@ -77,13 +77,13 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
77
77
|
/**
|
|
78
78
|
* In case this table should have some filters set by default
|
|
79
79
|
*/
|
|
80
|
-
filter?: VirtualTableFilterValues<
|
|
80
|
+
filter?: VirtualTableFilterValues<string>;
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Callback used when filters are updated
|
|
84
84
|
* @param filter
|
|
85
85
|
*/
|
|
86
|
-
onFilterUpdate?: (filter?: VirtualTableFilterValues<
|
|
86
|
+
onFilterUpdate?: (filter?: VirtualTableFilterValues<string> | undefined) => void;
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* Callback when the table is scrolled
|
|
@@ -137,7 +137,7 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
137
137
|
* Callback to create a filter field, displayed in the header as a dropdown
|
|
138
138
|
* @param props
|
|
139
139
|
*/
|
|
140
|
-
createFilterField?: (props: FilterFormFieldProps<
|
|
140
|
+
createFilterField?: (props: FilterFormFieldProps<unknown>) => React.ReactNode;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* Class name applied to the table
|
|
@@ -174,11 +174,11 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
174
174
|
/**
|
|
175
175
|
* Extra data passed to the cell renderer
|
|
176
176
|
*/
|
|
177
|
-
extraData?:
|
|
177
|
+
extraData?: unknown;
|
|
178
178
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
export type CellRendererParams<T =
|
|
181
|
+
export type CellRendererParams<T = unknown> = {
|
|
182
182
|
column: VirtualTableColumn;
|
|
183
183
|
columns: VirtualTableColumn[];
|
|
184
184
|
columnIndex: number;
|
|
@@ -189,18 +189,18 @@ export type CellRendererParams<T = any> = {
|
|
|
189
189
|
// Sortable props for dnd-kit integration
|
|
190
190
|
sortableNodeRef?: (node: HTMLElement | null) => void;
|
|
191
191
|
sortableStyle?: React.CSSProperties;
|
|
192
|
-
sortableAttributes?: Record<string,
|
|
192
|
+
sortableAttributes?: Record<string, unknown>;
|
|
193
193
|
isDragging?: boolean;
|
|
194
194
|
isDraggable?: boolean;
|
|
195
195
|
frozen?: boolean;
|
|
196
|
-
extraData?:
|
|
196
|
+
extraData?: unknown;
|
|
197
197
|
};
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
200
|
* @see Table
|
|
201
201
|
* @group Components
|
|
202
202
|
*/
|
|
203
|
-
export interface VirtualTableColumn<CustomProps =
|
|
203
|
+
export interface VirtualTableColumn<CustomProps = unknown> {
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
* Data key for the cell value, could be "a.b.c"
|
|
@@ -284,7 +284,7 @@ export type VirtualTableSort = "asc" | "desc" | undefined;
|
|
|
284
284
|
* @see Table
|
|
285
285
|
* @group Components
|
|
286
286
|
*/
|
|
287
|
-
export type VirtualTableFilterValues<Key extends string> = Partial<Record<Key, [VirtualTableWhereFilterOp,
|
|
287
|
+
export type VirtualTableFilterValues<Key extends string> = Partial<Record<Key, [VirtualTableWhereFilterOp, unknown]>>;
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* Filter conditions in a `Query.where()` clause are specified using the
|
|
@@ -4,8 +4,8 @@ import { deepEqual as equal } from "fast-equals"
|
|
|
4
4
|
|
|
5
5
|
import { VirtualTableRowProps } from "./types";
|
|
6
6
|
import { cls } from "../../util/cls";
|
|
7
|
-
export const VirtualTableRow = React.memo<VirtualTableRowProps<
|
|
8
|
-
function VirtualTableRow<T
|
|
7
|
+
export const VirtualTableRow = React.memo<VirtualTableRowProps<Record<string, unknown>>>(
|
|
8
|
+
function VirtualTableRow<T extends Record<string, unknown>>({
|
|
9
9
|
rowData,
|
|
10
10
|
rowIndex,
|
|
11
11
|
children,
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
} from "./VirtualTableProps";
|
|
10
10
|
import { FilterFormFieldProps } from "./VirtualTableHeader";
|
|
11
11
|
|
|
12
|
-
export type VirtualTableRowProps<T
|
|
13
|
-
style:
|
|
12
|
+
export type VirtualTableRowProps<T extends Record<string, unknown>> = {
|
|
13
|
+
style: React.CSSProperties,
|
|
14
14
|
rowHeight: number,
|
|
15
15
|
rowData: T;
|
|
16
16
|
rowIndex: number;
|
|
17
|
-
onRowClick?: (props: OnRowClickParams<
|
|
17
|
+
onRowClick?: (props: OnRowClickParams<Record<string, unknown>>) => void;
|
|
18
18
|
children: React.ReactNode[];
|
|
19
19
|
columns: VirtualTableColumn[];
|
|
20
20
|
hoverRow?: boolean;
|
|
@@ -28,20 +28,20 @@ export type VirtualTableContextProps<T> = {
|
|
|
28
28
|
columns: VirtualTableColumn[];
|
|
29
29
|
cellRenderer: React.ComponentType<CellRendererParams<T>>;
|
|
30
30
|
currentSort: "asc" | "desc" | undefined;
|
|
31
|
-
filter?: VirtualTableFilterValues<
|
|
32
|
-
onRowClick?: (props: OnRowClickParams<
|
|
33
|
-
onColumnSort: (key: string) =>
|
|
31
|
+
filter?: VirtualTableFilterValues<string>;
|
|
32
|
+
onRowClick?: (props: OnRowClickParams<Record<string, unknown>>) => void;
|
|
33
|
+
onColumnSort: (key: string) => void;
|
|
34
34
|
onColumnResize: (params: OnVirtualTableColumnResizeParams) => void;
|
|
35
35
|
onColumnResizeEnd: (params: OnVirtualTableColumnResizeParams) => void;
|
|
36
|
-
onFilterUpdate: (column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp,
|
|
36
|
+
onFilterUpdate: (column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp, unknown]) => void;
|
|
37
37
|
sortByProperty?: string;
|
|
38
38
|
customView?: React.ReactNode,
|
|
39
39
|
hoverRow: boolean;
|
|
40
|
-
createFilterField?: (props: FilterFormFieldProps<
|
|
40
|
+
createFilterField?: (props: FilterFormFieldProps<unknown>) => React.ReactNode;
|
|
41
41
|
rowClassName?: (rowData: T) => string | undefined;
|
|
42
42
|
endAdornment?: React.ReactNode;
|
|
43
43
|
AddColumnComponent?: React.ComponentType;
|
|
44
44
|
onColumnsOrderChange?: (columns: VirtualTableColumn[]) => void;
|
|
45
45
|
draggingColumnId?: string | null;
|
|
46
|
-
extraData?:
|
|
46
|
+
extraData?: unknown;
|
|
47
47
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useRef } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
export function useDebounceCallback<T extends (...args: any[]) => unknown>(
|
|
4
5
|
callback?: T,
|
|
5
6
|
delay?: number
|
|
6
7
|
): T {
|
package/src/index.css
CHANGED
package/src/util/debounce.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @ignore
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
export function debounce<T extends (...args: any[]) => unknown>(func: T, wait = 166) {
|
|
5
6
|
let timeout: ReturnType<typeof setTimeout>;
|
|
6
7
|
|
|
7
8
|
function debounced(...args: Parameters<T>) {
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Migrates `XxxIcon` imports from `@rebasepro/ui` to `lucide-react`.
|
|
4
|
-
* Non-icon imports remain in `@rebasepro/ui`.
|
|
5
|
-
*/
|
|
6
|
-
import fs from "fs";
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { execSync } from "child_process";
|
|
9
|
-
|
|
10
|
-
// Get all files that import XxxIcon from @rebasepro/ui
|
|
11
|
-
const files = execSync(
|
|
12
|
-
`grep -rln "from \\"@rebasepro/ui\\"" --include="*.tsx" --include="*.ts" packages/ app/ 2>/dev/null | grep -v node_modules | grep -v dist`,
|
|
13
|
-
{ cwd: "/Users/francesco/rebase", encoding: "utf-8" }
|
|
14
|
-
).trim().split("\n").filter(Boolean);
|
|
15
|
-
|
|
16
|
-
// Icons that are NOT from lucide-react (our own components)
|
|
17
|
-
const OUR_ICONS = new Set(["Icon", "IconButton", "HandleIcon", "GitHubIcon", "LabelWithIcon"]);
|
|
18
|
-
// Non-icon things that happen to end with Icon
|
|
19
|
-
const NOT_LUCIDE = new Set(["BrowserTitleAndIcon", "PopupIcon", "AIIcon", "DefaultIcon", "ViewModeIcon", "CircularProgressCenter"]);
|
|
20
|
-
|
|
21
|
-
const ICON_PATTERN = /^[A-Z][a-zA-Z0-9]*Icon$/;
|
|
22
|
-
|
|
23
|
-
let updated = 0;
|
|
24
|
-
|
|
25
|
-
for (const relFile of files) {
|
|
26
|
-
const filePath = path.join("/Users/francesco/rebase", relFile);
|
|
27
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
28
|
-
|
|
29
|
-
// Find all import lines from @rebasepro/ui
|
|
30
|
-
const importRegex = /import\s*\{([^}]+)\}\s*from\s*["']@rebasepro\/ui["'];?/g;
|
|
31
|
-
let match;
|
|
32
|
-
let newContent = content;
|
|
33
|
-
|
|
34
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
35
|
-
const fullImport = match[0];
|
|
36
|
-
const importList = match[1];
|
|
37
|
-
|
|
38
|
-
// Parse individual imports (handle type imports too)
|
|
39
|
-
const imports = importList.split(",").map(s => s.trim()).filter(Boolean);
|
|
40
|
-
|
|
41
|
-
const lucideImports = [];
|
|
42
|
-
const uiImports = [];
|
|
43
|
-
|
|
44
|
-
for (const imp of imports) {
|
|
45
|
-
// Handle "type Foo" imports
|
|
46
|
-
const isType = imp.startsWith("type ");
|
|
47
|
-
const name = isType ? imp.replace("type ", "").trim() : imp.trim();
|
|
48
|
-
|
|
49
|
-
if (ICON_PATTERN.test(name) && !OUR_ICONS.has(name) && !NOT_LUCIDE.has(name)) {
|
|
50
|
-
lucideImports.push(imp);
|
|
51
|
-
} else {
|
|
52
|
-
uiImports.push(imp);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (lucideImports.length === 0) continue;
|
|
57
|
-
|
|
58
|
-
// Build replacement
|
|
59
|
-
let replacement = "";
|
|
60
|
-
if (uiImports.length > 0) {
|
|
61
|
-
replacement += `import { ${uiImports.join(", ")} } from "@rebasepro/ui";\n`;
|
|
62
|
-
}
|
|
63
|
-
replacement += `import { ${lucideImports.join(", ")} } from "lucide-react";`;
|
|
64
|
-
|
|
65
|
-
newContent = newContent.replace(fullImport, replacement);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (newContent !== content) {
|
|
69
|
-
// Check if lucide-react import already exists and merge
|
|
70
|
-
const existingLucideMatch = newContent.match(/import\s*\{([^}]+)\}\s*from\s*["']lucide-react["'];?/g);
|
|
71
|
-
if (existingLucideMatch && existingLucideMatch.length > 1) {
|
|
72
|
-
// Merge multiple lucide-react imports into one
|
|
73
|
-
const allLucideImports = [];
|
|
74
|
-
for (const m of existingLucideMatch) {
|
|
75
|
-
const inner = m.match(/\{([^}]+)\}/)?.[1];
|
|
76
|
-
if (inner) {
|
|
77
|
-
allLucideImports.push(...inner.split(",").map(s => s.trim()).filter(Boolean));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Remove all lucide imports
|
|
81
|
-
for (const m of existingLucideMatch) {
|
|
82
|
-
newContent = newContent.replace(m + "\n", "");
|
|
83
|
-
newContent = newContent.replace(m, "");
|
|
84
|
-
}
|
|
85
|
-
// Add single merged import after the first @rebasepro/ui import or at the top imports area
|
|
86
|
-
const uiImportMatch = newContent.match(/import\s*\{[^}]+\}\s*from\s*["']@rebasepro\/ui["'];?\n/);
|
|
87
|
-
if (uiImportMatch) {
|
|
88
|
-
newContent = newContent.replace(
|
|
89
|
-
uiImportMatch[0],
|
|
90
|
-
uiImportMatch[0] + `import { ${[...new Set(allLucideImports)].join(", ")} } from "lucide-react";\n`
|
|
91
|
-
);
|
|
92
|
-
} else {
|
|
93
|
-
// Put at top after other imports
|
|
94
|
-
const lastImport = newContent.lastIndexOf("import ");
|
|
95
|
-
const lineEnd = newContent.indexOf("\n", lastImport);
|
|
96
|
-
newContent = newContent.slice(0, lineEnd + 1) +
|
|
97
|
-
`import { ${[...new Set(allLucideImports)].join(", ")} } from "lucide-react";\n` +
|
|
98
|
-
newContent.slice(lineEnd + 1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
fs.writeFileSync(filePath, newContent);
|
|
103
|
-
console.log(`✓ ${relFile}`);
|
|
104
|
-
updated++;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
console.log(`\nDone: ${updated} files updated`);
|
package/src/scripts/test.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as LucideIcons from "lucide-react";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
|
|
4
|
-
const keys = Object.keys(LucideIcons).filter(k => k !== "createLucideIcon" && k !== "default" && k !== "icons" && k !== "LucideIcon" && k !== "Icon");
|
|
5
|
-
console.log(`Found ${keys.length} icons`);
|
|
6
|
-
fs.writeFileSync("/tmp/lucide_keys.json", JSON.stringify(keys));
|