@wordrhyme/auto-crud 1.1.3 → 1.1.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/index.cjs +61 -19
- package/dist/index.d.cts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.js +61 -19
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2774,32 +2774,65 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2774
2774
|
const [expanded, setExpanded] = react.useState(false);
|
|
2775
2775
|
const [visibleCount, setVisibleCount] = react.useState(null);
|
|
2776
2776
|
const containerRef = react.useRef(null);
|
|
2777
|
+
const hasLeading = leading != null;
|
|
2778
|
+
const filterMeasureKey = react.useMemo(() => filters.map((filter) => [
|
|
2779
|
+
filter.id,
|
|
2780
|
+
filter.operator,
|
|
2781
|
+
Array.isArray(filter.value) ? filter.value.join(",") : String(filter.value ?? "")
|
|
2782
|
+
].join(":")).join("|"), [filters]);
|
|
2777
2783
|
const calcVisibleCount = react.useCallback(() => {
|
|
2778
2784
|
const el = containerRef.current;
|
|
2779
2785
|
if (!el) return;
|
|
2780
|
-
const items = el.querySelectorAll("[data-filter-item]");
|
|
2781
|
-
if (items.length === 0)
|
|
2786
|
+
const items = Array.from(el.querySelectorAll("[data-filter-item]"));
|
|
2787
|
+
if (items.length === 0) {
|
|
2788
|
+
setVisibleCount(null);
|
|
2789
|
+
return;
|
|
2790
|
+
}
|
|
2782
2791
|
const restoreList = [];
|
|
2783
|
-
el.querySelectorAll(".hidden").forEach((node) => {
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
restoreList.push(htmlNode);
|
|
2792
|
+
el.querySelectorAll("[data-filter-item].hidden, [data-filter-toggle].hidden").forEach((node) => {
|
|
2793
|
+
node.classList.remove("hidden");
|
|
2794
|
+
restoreList.push(node);
|
|
2787
2795
|
});
|
|
2788
|
-
el.
|
|
2789
|
-
el.
|
|
2790
|
-
const
|
|
2796
|
+
const availableWidth = el.getBoundingClientRect().width;
|
|
2797
|
+
const previousFlex = el.style.flex;
|
|
2798
|
+
const previousWidth = el.style.width;
|
|
2799
|
+
el.style.flex = `0 0 ${availableWidth}px`;
|
|
2800
|
+
el.style.width = `${availableWidth}px`;
|
|
2801
|
+
el.getBoundingClientRect();
|
|
2802
|
+
const computedStyle = window.getComputedStyle(el);
|
|
2803
|
+
const gap = Number.parseFloat(computedStyle.columnGap) || Number.parseFloat(computedStyle.gap) || 0;
|
|
2804
|
+
const leadingEl = el.querySelector("[data-filter-leading]");
|
|
2805
|
+
const toggle = el.querySelector("[data-filter-toggle]");
|
|
2806
|
+
const reset = el.querySelector("[data-filter-reset]");
|
|
2807
|
+
const addWidth = (current, next) => {
|
|
2808
|
+
if (next <= 0) return current;
|
|
2809
|
+
if (current === 0) return next;
|
|
2810
|
+
return current + gap + next;
|
|
2811
|
+
};
|
|
2812
|
+
const leadingWidth = leadingEl?.offsetWidth ?? 0;
|
|
2813
|
+
const itemWidths = items.map((item) => item.offsetWidth);
|
|
2814
|
+
const toggleWidth = toggle?.offsetWidth ?? 0;
|
|
2815
|
+
const resetWidth = reset?.offsetWidth ?? 0;
|
|
2816
|
+
if (itemWidths.reduce((width, itemWidth) => addWidth(width, itemWidth), addWidth(leadingWidth, resetWidth)) <= availableWidth) {
|
|
2817
|
+
el.style.flex = previousFlex;
|
|
2818
|
+
el.style.width = previousWidth;
|
|
2819
|
+
restoreList.forEach((node) => node.classList.add("hidden"));
|
|
2820
|
+
setVisibleCount(null);
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
const trailingWidth = addWidth(addWidth(0, toggleWidth), resetWidth);
|
|
2824
|
+
let usedWidth = leadingWidth;
|
|
2791
2825
|
let count = 0;
|
|
2792
|
-
for (const
|
|
2793
|
-
|
|
2826
|
+
for (const itemWidth of itemWidths) {
|
|
2827
|
+
const nextWidth = addWidth(usedWidth, itemWidth);
|
|
2828
|
+
if (addWidth(nextWidth, trailingWidth) > availableWidth) break;
|
|
2829
|
+
usedWidth = nextWidth;
|
|
2794
2830
|
count++;
|
|
2795
2831
|
}
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
if (btn.offsetTop > firstTop) count--;
|
|
2799
|
-
}
|
|
2800
|
-
el.style.flex = "";
|
|
2832
|
+
el.style.flex = previousFlex;
|
|
2833
|
+
el.style.width = previousWidth;
|
|
2801
2834
|
restoreList.forEach((node) => node.classList.add("hidden"));
|
|
2802
|
-
setVisibleCount(count
|
|
2835
|
+
setVisibleCount(count);
|
|
2803
2836
|
}, []);
|
|
2804
2837
|
react.useLayoutEffect(() => {
|
|
2805
2838
|
if (!mounted) return;
|
|
@@ -2807,6 +2840,9 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2807
2840
|
}, [
|
|
2808
2841
|
mounted,
|
|
2809
2842
|
filterColumns.length,
|
|
2843
|
+
hasLeading,
|
|
2844
|
+
hasFilters,
|
|
2845
|
+
filterMeasureKey,
|
|
2810
2846
|
calcVisibleCount
|
|
2811
2847
|
]);
|
|
2812
2848
|
react.useEffect(() => {
|
|
@@ -2829,6 +2865,7 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2829
2865
|
}, [
|
|
2830
2866
|
mounted,
|
|
2831
2867
|
filterColumns.length,
|
|
2868
|
+
hasLeading,
|
|
2832
2869
|
calcVisibleCount
|
|
2833
2870
|
]);
|
|
2834
2871
|
if (!mounted) return null;
|
|
@@ -2836,7 +2873,11 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2836
2873
|
ref: containerRef,
|
|
2837
2874
|
className: "flex flex-1 flex-wrap items-center gap-2 min-w-0",
|
|
2838
2875
|
children: [
|
|
2839
|
-
leading,
|
|
2876
|
+
leading != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2877
|
+
className: "shrink-0",
|
|
2878
|
+
"data-filter-leading": true,
|
|
2879
|
+
children: leading
|
|
2880
|
+
}) : null,
|
|
2840
2881
|
filterColumns.map((column, index) => {
|
|
2841
2882
|
const meta = column.columnDef.meta;
|
|
2842
2883
|
const value = getFilterValue(column.id);
|
|
@@ -2900,6 +2941,7 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2900
2941
|
children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronUp, { className: "size-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "size-4" })
|
|
2901
2942
|
}),
|
|
2902
2943
|
hasFilters && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Button, {
|
|
2944
|
+
"data-filter-reset": true,
|
|
2903
2945
|
variant: "outline",
|
|
2904
2946
|
size: "sm",
|
|
2905
2947
|
className: "h-8 border-dashed shrink-0",
|
|
@@ -4814,7 +4856,7 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
|
|
|
4814
4856
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4815
4857
|
className: "flex w-full items-start justify-between gap-2 p-1",
|
|
4816
4858
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4817
|
-
className: "flex flex-1 items-start gap-2
|
|
4859
|
+
className: "flex min-h-[40px] min-w-0 flex-1 items-start gap-2",
|
|
4818
4860
|
"data-filter-parent": true,
|
|
4819
4861
|
children: [
|
|
4820
4862
|
currentMode !== "simple" && searchInput,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
4
4
|
import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
@@ -361,7 +361,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
361
361
|
enableDelete,
|
|
362
362
|
extraActions,
|
|
363
363
|
actions
|
|
364
|
-
}: AutoTableActionBarProps<TData>):
|
|
364
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
365
365
|
//#endregion
|
|
366
366
|
//#region src/lib/schema-bridge/types.d.ts
|
|
367
367
|
/**
|
|
@@ -529,7 +529,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
529
529
|
showDefaultExport,
|
|
530
530
|
onSelectedCountChange,
|
|
531
531
|
getSelectedRows
|
|
532
|
-
}: AutoTableProps<T>):
|
|
532
|
+
}: AutoTableProps<T>): react_jsx_runtime0.JSX.Element;
|
|
533
533
|
//#endregion
|
|
534
534
|
//#region src/i18n/locale.d.ts
|
|
535
535
|
/**
|
|
@@ -874,7 +874,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
874
874
|
toolbarActions,
|
|
875
875
|
locale: localeProp,
|
|
876
876
|
onCreate
|
|
877
|
-
}: AutoCrudTableProps<TSchema>):
|
|
877
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime0.JSX.Element;
|
|
878
878
|
//#endregion
|
|
879
879
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
880
880
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -906,7 +906,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
906
906
|
labelAlign,
|
|
907
907
|
labelWidth,
|
|
908
908
|
showSubmitButton
|
|
909
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
909
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime0.JSX.Element;
|
|
910
910
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
911
911
|
ref?: React.Ref<AutoFormRef>;
|
|
912
912
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1207,7 +1207,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1207
1207
|
filters: externalFilters,
|
|
1208
1208
|
onFiltersChange,
|
|
1209
1209
|
leading
|
|
1210
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1210
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime0.JSX.Element | null;
|
|
1211
1211
|
//#endregion
|
|
1212
1212
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1213
1213
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1249,7 +1249,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1249
1249
|
labelAlign,
|
|
1250
1250
|
labelWidth,
|
|
1251
1251
|
className
|
|
1252
|
-
}: CrudFormModalProps<T>):
|
|
1252
|
+
}: CrudFormModalProps<T>): react_jsx_runtime0.JSX.Element;
|
|
1253
1253
|
//#endregion
|
|
1254
1254
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1255
1255
|
interface ImportDialogProps {
|
|
@@ -1271,7 +1271,7 @@ declare function ImportDialog({
|
|
|
1271
1271
|
columns,
|
|
1272
1272
|
title,
|
|
1273
1273
|
locale
|
|
1274
|
-
}: ImportDialogProps):
|
|
1274
|
+
}: ImportDialogProps): react_jsx_runtime0.JSX.Element;
|
|
1275
1275
|
//#endregion
|
|
1276
1276
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1277
1277
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1291,7 +1291,7 @@ declare function ExportDialog({
|
|
|
1291
1291
|
selectedCount,
|
|
1292
1292
|
onExport,
|
|
1293
1293
|
canExportFiltered
|
|
1294
|
-
}: ExportDialogProps):
|
|
1294
|
+
}: ExportDialogProps): react_jsx_runtime0.JSX.Element;
|
|
1295
1295
|
//#endregion
|
|
1296
1296
|
//#region src/components/data-table/data-table.d.ts
|
|
1297
1297
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1304,7 +1304,7 @@ declare function DataTable<TData>({
|
|
|
1304
1304
|
children,
|
|
1305
1305
|
className,
|
|
1306
1306
|
...props
|
|
1307
|
-
}: DataTableProps<TData>):
|
|
1307
|
+
}: DataTableProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1308
1308
|
//#endregion
|
|
1309
1309
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1310
1310
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1315,7 +1315,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1315
1315
|
children,
|
|
1316
1316
|
className,
|
|
1317
1317
|
...props
|
|
1318
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1318
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1319
1319
|
//#endregion
|
|
1320
1320
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1321
1321
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1327,7 +1327,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1327
1327
|
label,
|
|
1328
1328
|
className,
|
|
1329
1329
|
...props
|
|
1330
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1330
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime0.JSX.Element;
|
|
1331
1331
|
//#endregion
|
|
1332
1332
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1333
1333
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1341,7 +1341,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1341
1341
|
title,
|
|
1342
1342
|
options,
|
|
1343
1343
|
multiple
|
|
1344
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1344
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime0.JSX.Element;
|
|
1345
1345
|
//#endregion
|
|
1346
1346
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1347
1347
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1353,7 +1353,7 @@ declare function DataTablePagination<TData>({
|
|
|
1353
1353
|
pageSizeOptions,
|
|
1354
1354
|
className,
|
|
1355
1355
|
...props
|
|
1356
|
-
}: DataTablePaginationProps<TData>):
|
|
1356
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1357
1357
|
//#endregion
|
|
1358
1358
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1359
1359
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1364,7 +1364,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1364
1364
|
children,
|
|
1365
1365
|
className,
|
|
1366
1366
|
...props
|
|
1367
|
-
}: DataTableToolbarProps<TData>):
|
|
1367
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1368
1368
|
//#endregion
|
|
1369
1369
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1370
1370
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1375,7 +1375,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1375
1375
|
table,
|
|
1376
1376
|
disabled,
|
|
1377
1377
|
...props
|
|
1378
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1378
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1379
1379
|
//#endregion
|
|
1380
1380
|
//#region src/hooks/use-data-table.d.ts
|
|
1381
1381
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
|
3
3
|
import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
4
4
|
import { DropdownMenuTrigger, PopoverContent } from "@pixpilot/shadcn";
|
|
5
5
|
import { ClassValue } from "clsx";
|
|
6
|
-
import * as
|
|
6
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { ISchema } from "@formily/json-schema";
|
|
9
9
|
|
|
@@ -361,7 +361,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
361
361
|
enableDelete,
|
|
362
362
|
extraActions,
|
|
363
363
|
actions
|
|
364
|
-
}: AutoTableActionBarProps<TData>):
|
|
364
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
365
365
|
//#endregion
|
|
366
366
|
//#region src/lib/schema-bridge/types.d.ts
|
|
367
367
|
/**
|
|
@@ -529,7 +529,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
529
529
|
showDefaultExport,
|
|
530
530
|
onSelectedCountChange,
|
|
531
531
|
getSelectedRows
|
|
532
|
-
}: AutoTableProps<T>):
|
|
532
|
+
}: AutoTableProps<T>): react_jsx_runtime0.JSX.Element;
|
|
533
533
|
//#endregion
|
|
534
534
|
//#region src/i18n/locale.d.ts
|
|
535
535
|
/**
|
|
@@ -874,7 +874,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
874
874
|
toolbarActions,
|
|
875
875
|
locale: localeProp,
|
|
876
876
|
onCreate
|
|
877
|
-
}: AutoCrudTableProps<TSchema>):
|
|
877
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime0.JSX.Element;
|
|
878
878
|
//#endregion
|
|
879
879
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
880
880
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -906,7 +906,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
906
906
|
labelAlign,
|
|
907
907
|
labelWidth,
|
|
908
908
|
showSubmitButton
|
|
909
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
909
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime0.JSX.Element;
|
|
910
910
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
911
911
|
ref?: React.Ref<AutoFormRef>;
|
|
912
912
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1207,7 +1207,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1207
1207
|
filters: externalFilters,
|
|
1208
1208
|
onFiltersChange,
|
|
1209
1209
|
leading
|
|
1210
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1210
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime0.JSX.Element | null;
|
|
1211
1211
|
//#endregion
|
|
1212
1212
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1213
1213
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1249,7 +1249,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1249
1249
|
labelAlign,
|
|
1250
1250
|
labelWidth,
|
|
1251
1251
|
className
|
|
1252
|
-
}: CrudFormModalProps<T>):
|
|
1252
|
+
}: CrudFormModalProps<T>): react_jsx_runtime0.JSX.Element;
|
|
1253
1253
|
//#endregion
|
|
1254
1254
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1255
1255
|
interface ImportDialogProps {
|
|
@@ -1271,7 +1271,7 @@ declare function ImportDialog({
|
|
|
1271
1271
|
columns,
|
|
1272
1272
|
title,
|
|
1273
1273
|
locale
|
|
1274
|
-
}: ImportDialogProps):
|
|
1274
|
+
}: ImportDialogProps): react_jsx_runtime0.JSX.Element;
|
|
1275
1275
|
//#endregion
|
|
1276
1276
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1277
1277
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1291,7 +1291,7 @@ declare function ExportDialog({
|
|
|
1291
1291
|
selectedCount,
|
|
1292
1292
|
onExport,
|
|
1293
1293
|
canExportFiltered
|
|
1294
|
-
}: ExportDialogProps):
|
|
1294
|
+
}: ExportDialogProps): react_jsx_runtime0.JSX.Element;
|
|
1295
1295
|
//#endregion
|
|
1296
1296
|
//#region src/components/data-table/data-table.d.ts
|
|
1297
1297
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1304,7 +1304,7 @@ declare function DataTable<TData>({
|
|
|
1304
1304
|
children,
|
|
1305
1305
|
className,
|
|
1306
1306
|
...props
|
|
1307
|
-
}: DataTableProps<TData>):
|
|
1307
|
+
}: DataTableProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1308
1308
|
//#endregion
|
|
1309
1309
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1310
1310
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1315,7 +1315,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1315
1315
|
children,
|
|
1316
1316
|
className,
|
|
1317
1317
|
...props
|
|
1318
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1318
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1319
1319
|
//#endregion
|
|
1320
1320
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1321
1321
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1327,7 +1327,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1327
1327
|
label,
|
|
1328
1328
|
className,
|
|
1329
1329
|
...props
|
|
1330
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1330
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime0.JSX.Element;
|
|
1331
1331
|
//#endregion
|
|
1332
1332
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1333
1333
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1341,7 +1341,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1341
1341
|
title,
|
|
1342
1342
|
options,
|
|
1343
1343
|
multiple
|
|
1344
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1344
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime0.JSX.Element;
|
|
1345
1345
|
//#endregion
|
|
1346
1346
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1347
1347
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1353,7 +1353,7 @@ declare function DataTablePagination<TData>({
|
|
|
1353
1353
|
pageSizeOptions,
|
|
1354
1354
|
className,
|
|
1355
1355
|
...props
|
|
1356
|
-
}: DataTablePaginationProps<TData>):
|
|
1356
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1357
1357
|
//#endregion
|
|
1358
1358
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1359
1359
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1364,7 +1364,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1364
1364
|
children,
|
|
1365
1365
|
className,
|
|
1366
1366
|
...props
|
|
1367
|
-
}: DataTableToolbarProps<TData>):
|
|
1367
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1368
1368
|
//#endregion
|
|
1369
1369
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1370
1370
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1375,7 +1375,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1375
1375
|
table,
|
|
1376
1376
|
disabled,
|
|
1377
1377
|
...props
|
|
1378
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1378
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
1379
1379
|
//#endregion
|
|
1380
1380
|
//#region src/hooks/use-data-table.d.ts
|
|
1381
1381
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
package/dist/index.js
CHANGED
|
@@ -2731,32 +2731,65 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2731
2731
|
const [expanded, setExpanded] = React.useState(false);
|
|
2732
2732
|
const [visibleCount, setVisibleCount] = React.useState(null);
|
|
2733
2733
|
const containerRef = React.useRef(null);
|
|
2734
|
+
const hasLeading = leading != null;
|
|
2735
|
+
const filterMeasureKey = React.useMemo(() => filters.map((filter) => [
|
|
2736
|
+
filter.id,
|
|
2737
|
+
filter.operator,
|
|
2738
|
+
Array.isArray(filter.value) ? filter.value.join(",") : String(filter.value ?? "")
|
|
2739
|
+
].join(":")).join("|"), [filters]);
|
|
2734
2740
|
const calcVisibleCount = React.useCallback(() => {
|
|
2735
2741
|
const el = containerRef.current;
|
|
2736
2742
|
if (!el) return;
|
|
2737
|
-
const items = el.querySelectorAll("[data-filter-item]");
|
|
2738
|
-
if (items.length === 0)
|
|
2743
|
+
const items = Array.from(el.querySelectorAll("[data-filter-item]"));
|
|
2744
|
+
if (items.length === 0) {
|
|
2745
|
+
setVisibleCount(null);
|
|
2746
|
+
return;
|
|
2747
|
+
}
|
|
2739
2748
|
const restoreList = [];
|
|
2740
|
-
el.querySelectorAll(".hidden").forEach((node) => {
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
restoreList.push(htmlNode);
|
|
2749
|
+
el.querySelectorAll("[data-filter-item].hidden, [data-filter-toggle].hidden").forEach((node) => {
|
|
2750
|
+
node.classList.remove("hidden");
|
|
2751
|
+
restoreList.push(node);
|
|
2744
2752
|
});
|
|
2745
|
-
el.
|
|
2746
|
-
el.
|
|
2747
|
-
const
|
|
2753
|
+
const availableWidth = el.getBoundingClientRect().width;
|
|
2754
|
+
const previousFlex = el.style.flex;
|
|
2755
|
+
const previousWidth = el.style.width;
|
|
2756
|
+
el.style.flex = `0 0 ${availableWidth}px`;
|
|
2757
|
+
el.style.width = `${availableWidth}px`;
|
|
2758
|
+
el.getBoundingClientRect();
|
|
2759
|
+
const computedStyle = window.getComputedStyle(el);
|
|
2760
|
+
const gap = Number.parseFloat(computedStyle.columnGap) || Number.parseFloat(computedStyle.gap) || 0;
|
|
2761
|
+
const leadingEl = el.querySelector("[data-filter-leading]");
|
|
2762
|
+
const toggle = el.querySelector("[data-filter-toggle]");
|
|
2763
|
+
const reset = el.querySelector("[data-filter-reset]");
|
|
2764
|
+
const addWidth = (current, next) => {
|
|
2765
|
+
if (next <= 0) return current;
|
|
2766
|
+
if (current === 0) return next;
|
|
2767
|
+
return current + gap + next;
|
|
2768
|
+
};
|
|
2769
|
+
const leadingWidth = leadingEl?.offsetWidth ?? 0;
|
|
2770
|
+
const itemWidths = items.map((item) => item.offsetWidth);
|
|
2771
|
+
const toggleWidth = toggle?.offsetWidth ?? 0;
|
|
2772
|
+
const resetWidth = reset?.offsetWidth ?? 0;
|
|
2773
|
+
if (itemWidths.reduce((width, itemWidth) => addWidth(width, itemWidth), addWidth(leadingWidth, resetWidth)) <= availableWidth) {
|
|
2774
|
+
el.style.flex = previousFlex;
|
|
2775
|
+
el.style.width = previousWidth;
|
|
2776
|
+
restoreList.forEach((node) => node.classList.add("hidden"));
|
|
2777
|
+
setVisibleCount(null);
|
|
2778
|
+
return;
|
|
2779
|
+
}
|
|
2780
|
+
const trailingWidth = addWidth(addWidth(0, toggleWidth), resetWidth);
|
|
2781
|
+
let usedWidth = leadingWidth;
|
|
2748
2782
|
let count = 0;
|
|
2749
|
-
for (const
|
|
2750
|
-
|
|
2783
|
+
for (const itemWidth of itemWidths) {
|
|
2784
|
+
const nextWidth = addWidth(usedWidth, itemWidth);
|
|
2785
|
+
if (addWidth(nextWidth, trailingWidth) > availableWidth) break;
|
|
2786
|
+
usedWidth = nextWidth;
|
|
2751
2787
|
count++;
|
|
2752
2788
|
}
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
if (btn.offsetTop > firstTop) count--;
|
|
2756
|
-
}
|
|
2757
|
-
el.style.flex = "";
|
|
2789
|
+
el.style.flex = previousFlex;
|
|
2790
|
+
el.style.width = previousWidth;
|
|
2758
2791
|
restoreList.forEach((node) => node.classList.add("hidden"));
|
|
2759
|
-
setVisibleCount(count
|
|
2792
|
+
setVisibleCount(count);
|
|
2760
2793
|
}, []);
|
|
2761
2794
|
React.useLayoutEffect(() => {
|
|
2762
2795
|
if (!mounted) return;
|
|
@@ -2764,6 +2797,9 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2764
2797
|
}, [
|
|
2765
2798
|
mounted,
|
|
2766
2799
|
filterColumns.length,
|
|
2800
|
+
hasLeading,
|
|
2801
|
+
hasFilters,
|
|
2802
|
+
filterMeasureKey,
|
|
2767
2803
|
calcVisibleCount
|
|
2768
2804
|
]);
|
|
2769
2805
|
React.useEffect(() => {
|
|
@@ -2786,6 +2822,7 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2786
2822
|
}, [
|
|
2787
2823
|
mounted,
|
|
2788
2824
|
filterColumns.length,
|
|
2825
|
+
hasLeading,
|
|
2789
2826
|
calcVisibleCount
|
|
2790
2827
|
]);
|
|
2791
2828
|
if (!mounted) return null;
|
|
@@ -2793,7 +2830,11 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2793
2830
|
ref: containerRef,
|
|
2794
2831
|
className: "flex flex-1 flex-wrap items-center gap-2 min-w-0",
|
|
2795
2832
|
children: [
|
|
2796
|
-
leading,
|
|
2833
|
+
leading != null ? /* @__PURE__ */ jsx("div", {
|
|
2834
|
+
className: "shrink-0",
|
|
2835
|
+
"data-filter-leading": true,
|
|
2836
|
+
children: leading
|
|
2837
|
+
}) : null,
|
|
2797
2838
|
filterColumns.map((column, index) => {
|
|
2798
2839
|
const meta = column.columnDef.meta;
|
|
2799
2840
|
const value = getFilterValue(column.id);
|
|
@@ -2857,6 +2898,7 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2857
2898
|
children: expanded ? /* @__PURE__ */ jsx(ChevronUp, { className: "size-4" }) : /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" })
|
|
2858
2899
|
}),
|
|
2859
2900
|
hasFilters && /* @__PURE__ */ jsxs(Button, {
|
|
2901
|
+
"data-filter-reset": true,
|
|
2860
2902
|
variant: "outline",
|
|
2861
2903
|
size: "sm",
|
|
2862
2904
|
className: "h-8 border-dashed shrink-0",
|
|
@@ -4771,7 +4813,7 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
|
|
|
4771
4813
|
/* @__PURE__ */ jsxs("div", {
|
|
4772
4814
|
className: "flex w-full items-start justify-between gap-2 p-1",
|
|
4773
4815
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
4774
|
-
className: "flex flex-1 items-start gap-2
|
|
4816
|
+
className: "flex min-h-[40px] min-w-0 flex-1 items-start gap-2",
|
|
4775
4817
|
"data-filter-parent": true,
|
|
4776
4818
|
children: [
|
|
4777
4819
|
currentMode !== "simple" && searchInput,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.4",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"tailwind-merge": "^3.5.0",
|
|
67
67
|
"vaul": "^1.1.2",
|
|
68
68
|
"@pixpilot/formily-shadcn": "1.11.20",
|
|
69
|
-
"@pixpilot/shadcn
|
|
70
|
-
"@pixpilot/shadcn": "1.
|
|
69
|
+
"@pixpilot/shadcn": "1.2.7",
|
|
70
|
+
"@pixpilot/shadcn-ui": "1.21.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@tanstack/react-query": "^5.90.15",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
"react-dom": "19.2.4",
|
|
83
83
|
"tsdown": "^0.15.12",
|
|
84
84
|
"typescript": "^5.9.3",
|
|
85
|
+
"@internal/prettier-config": "0.0.1",
|
|
85
86
|
"@internal/eslint-config": "0.3.0",
|
|
86
87
|
"@internal/tsconfig": "0.1.0",
|
|
87
88
|
"@internal/tsdown-config": "0.1.0",
|
|
88
|
-
"@internal/prettier-config": "0.0.1",
|
|
89
89
|
"@internal/vitest-config": "0.1.0"
|
|
90
90
|
},
|
|
91
91
|
"prettier": "@internal/prettier-config",
|