@wordrhyme/auto-crud 0.4.3 → 0.5.0
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/LICENSE +21 -0
- package/dist/index.cjs +14 -5
- package/dist/index.d.cts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.js +14 -5
- package/package.json +35 -37
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pixpilot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -4635,9 +4635,14 @@ function buildTableOverrides(fields, legacyOverrides) {
|
|
|
4635
4635
|
}
|
|
4636
4636
|
/**
|
|
4637
4637
|
* 从统一配置生成表单 overrides
|
|
4638
|
+
* Critical #2: 支持 denyFields 隐藏敏感字段
|
|
4638
4639
|
*/
|
|
4639
|
-
function buildFormOverrides(fields, legacyOverrides) {
|
|
4640
|
+
function buildFormOverrides(fields, legacyOverrides, denyFields) {
|
|
4640
4641
|
const result = { ...legacyOverrides };
|
|
4642
|
+
if (denyFields) for (const field of denyFields) result[field] = {
|
|
4643
|
+
...result[field],
|
|
4644
|
+
"x-hidden": true
|
|
4645
|
+
};
|
|
4641
4646
|
if (fields) for (const [key, config] of Object.entries(fields)) result[key] = {
|
|
4642
4647
|
...result[key],
|
|
4643
4648
|
...config.label && { title: config.label },
|
|
@@ -4723,12 +4728,14 @@ function renderFieldValue(value, type) {
|
|
|
4723
4728
|
/**
|
|
4724
4729
|
* ViewModal 组件 - 详情查看弹窗
|
|
4725
4730
|
*/
|
|
4726
|
-
function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldConfig }) {
|
|
4731
|
+
function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldConfig, denyFields }) {
|
|
4727
4732
|
if (!data) return null;
|
|
4728
4733
|
const shape = schema.shape;
|
|
4734
|
+
const denySet = new Set(denyFields ?? []);
|
|
4729
4735
|
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
4730
4736
|
className: "grid gap-4 py-4",
|
|
4731
4737
|
children: Object.entries(shape).filter(([key]) => {
|
|
4738
|
+
if (denySet.has(key)) return false;
|
|
4732
4739
|
return !(fieldConfig?.[key])?.hidden;
|
|
4733
4740
|
}).map(([key, fieldSchema]) => {
|
|
4734
4741
|
const parsed = parseZodField(fieldSchema);
|
|
@@ -4772,9 +4779,10 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
4772
4779
|
delete: permissions?.can?.delete ?? true,
|
|
4773
4780
|
export: permissions?.can?.export ?? true
|
|
4774
4781
|
};
|
|
4782
|
+
const denyFields = permissions?.deny;
|
|
4775
4783
|
const tableOverrides = buildTableOverrides(fields, tableConfig?.overrides);
|
|
4776
|
-
const formOverrides = buildFormOverrides(fields, formConfig?.overrides);
|
|
4777
|
-
const hiddenColumns = buildHiddenColumns(fields, tableConfig?.hidden,
|
|
4784
|
+
const formOverrides = buildFormOverrides(fields, formConfig?.overrides, denyFields);
|
|
4785
|
+
const hiddenColumns = buildHiddenColumns(fields, tableConfig?.hidden, denyFields);
|
|
4778
4786
|
const batchFields = buildBatchUpdateFields(schema, tableConfig?.batchFields, fields);
|
|
4779
4787
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4780
4788
|
className: "space-y-4",
|
|
@@ -4841,7 +4849,8 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
4841
4849
|
variant: resource.modal.variant,
|
|
4842
4850
|
data: resource.modal.selected,
|
|
4843
4851
|
schema,
|
|
4844
|
-
fields
|
|
4852
|
+
fields,
|
|
4853
|
+
denyFields
|
|
4845
4854
|
}),
|
|
4846
4855
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.AlertDialog, {
|
|
4847
4856
|
open: resource.modal.deleteOpen,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime2 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";
|
|
@@ -243,7 +243,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
243
243
|
enableExport,
|
|
244
244
|
enableDelete,
|
|
245
245
|
extraActions
|
|
246
|
-
}: AutoTableActionBarProps<TData>):
|
|
246
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/lib/schema-bridge/types.d.ts
|
|
249
249
|
/**
|
|
@@ -386,7 +386,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
386
386
|
actionBarExtra,
|
|
387
387
|
initialSorting,
|
|
388
388
|
enableExport
|
|
389
|
-
}: AutoTableProps<T>):
|
|
389
|
+
}: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
|
|
390
390
|
//#endregion
|
|
391
391
|
//#region src/components/auto-crud/auto-crud-table.d.ts
|
|
392
392
|
/**
|
|
@@ -513,7 +513,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
513
513
|
form: formConfig,
|
|
514
514
|
slots,
|
|
515
515
|
permissions
|
|
516
|
-
}: AutoCrudTableProps<TSchema>):
|
|
516
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
|
|
517
517
|
//#endregion
|
|
518
518
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
519
519
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -545,7 +545,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
545
545
|
labelAlign,
|
|
546
546
|
labelWidth,
|
|
547
547
|
showSubmitButton
|
|
548
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
548
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
|
|
549
549
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
550
550
|
ref?: React.Ref<AutoFormRef>;
|
|
551
551
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -759,12 +759,12 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
759
759
|
variant: z.ZodEnum<{
|
|
760
760
|
number: "number";
|
|
761
761
|
boolean: "boolean";
|
|
762
|
-
text: "text";
|
|
763
|
-
range: "range";
|
|
764
762
|
date: "date";
|
|
765
|
-
|
|
763
|
+
text: "text";
|
|
766
764
|
select: "select";
|
|
767
765
|
multiSelect: "multiSelect";
|
|
766
|
+
dateRange: "dateRange";
|
|
767
|
+
range: "range";
|
|
768
768
|
}>;
|
|
769
769
|
operator: z.ZodEnum<{
|
|
770
770
|
iLike: "iLike";
|
|
@@ -840,7 +840,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
840
840
|
shallow,
|
|
841
841
|
filters: externalFilters,
|
|
842
842
|
onFiltersChange
|
|
843
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
843
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
|
|
844
844
|
//#endregion
|
|
845
845
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
846
846
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -875,7 +875,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
875
875
|
title,
|
|
876
876
|
labelAlign,
|
|
877
877
|
labelWidth
|
|
878
|
-
}: CrudFormModalProps<T>):
|
|
878
|
+
}: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
|
|
879
879
|
//#endregion
|
|
880
880
|
//#region src/components/data-table/data-table.d.ts
|
|
881
881
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -888,7 +888,7 @@ declare function DataTable<TData>({
|
|
|
888
888
|
children,
|
|
889
889
|
className,
|
|
890
890
|
...props
|
|
891
|
-
}: DataTableProps<TData>):
|
|
891
|
+
}: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
892
892
|
//#endregion
|
|
893
893
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
894
894
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -899,7 +899,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
899
899
|
children,
|
|
900
900
|
className,
|
|
901
901
|
...props
|
|
902
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
902
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
903
903
|
//#endregion
|
|
904
904
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
905
905
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -911,7 +911,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
911
911
|
label,
|
|
912
912
|
className,
|
|
913
913
|
...props
|
|
914
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
914
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
|
|
915
915
|
//#endregion
|
|
916
916
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
917
917
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -925,7 +925,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
925
925
|
title,
|
|
926
926
|
options,
|
|
927
927
|
multiple
|
|
928
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
928
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
|
|
929
929
|
//#endregion
|
|
930
930
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
931
931
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -937,7 +937,7 @@ declare function DataTablePagination<TData>({
|
|
|
937
937
|
pageSizeOptions,
|
|
938
938
|
className,
|
|
939
939
|
...props
|
|
940
|
-
}: DataTablePaginationProps<TData>):
|
|
940
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
941
941
|
//#endregion
|
|
942
942
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
943
943
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -948,7 +948,7 @@ declare function DataTableToolbar<TData>({
|
|
|
948
948
|
children,
|
|
949
949
|
className,
|
|
950
950
|
...props
|
|
951
|
-
}: DataTableToolbarProps<TData>):
|
|
951
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
952
952
|
//#endregion
|
|
953
953
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
954
954
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -959,7 +959,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
959
959
|
table,
|
|
960
960
|
disabled,
|
|
961
961
|
...props
|
|
962
|
-
}: DataTableViewOptionsProps<TData>):
|
|
962
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
963
963
|
//#endregion
|
|
964
964
|
//#region src/hooks/use-data-table.d.ts
|
|
965
965
|
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_runtime4 from "react/jsx-runtime";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { ISchema } from "@formily/json-schema";
|
|
9
9
|
|
|
@@ -243,7 +243,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
243
243
|
enableExport,
|
|
244
244
|
enableDelete,
|
|
245
245
|
extraActions
|
|
246
|
-
}: AutoTableActionBarProps<TData>):
|
|
246
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/lib/schema-bridge/types.d.ts
|
|
249
249
|
/**
|
|
@@ -386,7 +386,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
386
386
|
actionBarExtra,
|
|
387
387
|
initialSorting,
|
|
388
388
|
enableExport
|
|
389
|
-
}: AutoTableProps<T>):
|
|
389
|
+
}: AutoTableProps<T>): react_jsx_runtime4.JSX.Element;
|
|
390
390
|
//#endregion
|
|
391
391
|
//#region src/components/auto-crud/auto-crud-table.d.ts
|
|
392
392
|
/**
|
|
@@ -513,7 +513,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
513
513
|
form: formConfig,
|
|
514
514
|
slots,
|
|
515
515
|
permissions
|
|
516
|
-
}: AutoCrudTableProps<TSchema>):
|
|
516
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime4.JSX.Element;
|
|
517
517
|
//#endregion
|
|
518
518
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
519
519
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -545,7 +545,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
545
545
|
labelAlign,
|
|
546
546
|
labelWidth,
|
|
547
547
|
showSubmitButton
|
|
548
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
548
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime4.JSX.Element;
|
|
549
549
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
550
550
|
ref?: React.Ref<AutoFormRef>;
|
|
551
551
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -759,12 +759,12 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
759
759
|
variant: z.ZodEnum<{
|
|
760
760
|
number: "number";
|
|
761
761
|
boolean: "boolean";
|
|
762
|
-
text: "text";
|
|
763
|
-
range: "range";
|
|
764
762
|
date: "date";
|
|
765
|
-
|
|
763
|
+
text: "text";
|
|
766
764
|
select: "select";
|
|
767
765
|
multiSelect: "multiSelect";
|
|
766
|
+
dateRange: "dateRange";
|
|
767
|
+
range: "range";
|
|
768
768
|
}>;
|
|
769
769
|
operator: z.ZodEnum<{
|
|
770
770
|
iLike: "iLike";
|
|
@@ -840,7 +840,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
840
840
|
shallow,
|
|
841
841
|
filters: externalFilters,
|
|
842
842
|
onFiltersChange
|
|
843
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
843
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime4.JSX.Element | null;
|
|
844
844
|
//#endregion
|
|
845
845
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
846
846
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -875,7 +875,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
875
875
|
title,
|
|
876
876
|
labelAlign,
|
|
877
877
|
labelWidth
|
|
878
|
-
}: CrudFormModalProps<T>):
|
|
878
|
+
}: CrudFormModalProps<T>): react_jsx_runtime4.JSX.Element;
|
|
879
879
|
//#endregion
|
|
880
880
|
//#region src/components/data-table/data-table.d.ts
|
|
881
881
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -888,7 +888,7 @@ declare function DataTable<TData>({
|
|
|
888
888
|
children,
|
|
889
889
|
className,
|
|
890
890
|
...props
|
|
891
|
-
}: DataTableProps<TData>):
|
|
891
|
+
}: DataTableProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
892
892
|
//#endregion
|
|
893
893
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
894
894
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -899,7 +899,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
899
899
|
children,
|
|
900
900
|
className,
|
|
901
901
|
...props
|
|
902
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
902
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
903
903
|
//#endregion
|
|
904
904
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
905
905
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -911,7 +911,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
911
911
|
label,
|
|
912
912
|
className,
|
|
913
913
|
...props
|
|
914
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
914
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
|
|
915
915
|
//#endregion
|
|
916
916
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
917
917
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -925,7 +925,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
925
925
|
title,
|
|
926
926
|
options,
|
|
927
927
|
multiple
|
|
928
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
928
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
|
|
929
929
|
//#endregion
|
|
930
930
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
931
931
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -937,7 +937,7 @@ declare function DataTablePagination<TData>({
|
|
|
937
937
|
pageSizeOptions,
|
|
938
938
|
className,
|
|
939
939
|
...props
|
|
940
|
-
}: DataTablePaginationProps<TData>):
|
|
940
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
941
941
|
//#endregion
|
|
942
942
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
943
943
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -948,7 +948,7 @@ declare function DataTableToolbar<TData>({
|
|
|
948
948
|
children,
|
|
949
949
|
className,
|
|
950
950
|
...props
|
|
951
|
-
}: DataTableToolbarProps<TData>):
|
|
951
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
952
952
|
//#endregion
|
|
953
953
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
954
954
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -959,7 +959,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
959
959
|
table,
|
|
960
960
|
disabled,
|
|
961
961
|
...props
|
|
962
|
-
}: DataTableViewOptionsProps<TData>):
|
|
962
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
963
963
|
//#endregion
|
|
964
964
|
//#region src/hooks/use-data-table.d.ts
|
|
965
965
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
package/dist/index.js
CHANGED
|
@@ -4593,9 +4593,14 @@ function buildTableOverrides(fields, legacyOverrides) {
|
|
|
4593
4593
|
}
|
|
4594
4594
|
/**
|
|
4595
4595
|
* 从统一配置生成表单 overrides
|
|
4596
|
+
* Critical #2: 支持 denyFields 隐藏敏感字段
|
|
4596
4597
|
*/
|
|
4597
|
-
function buildFormOverrides(fields, legacyOverrides) {
|
|
4598
|
+
function buildFormOverrides(fields, legacyOverrides, denyFields) {
|
|
4598
4599
|
const result = { ...legacyOverrides };
|
|
4600
|
+
if (denyFields) for (const field of denyFields) result[field] = {
|
|
4601
|
+
...result[field],
|
|
4602
|
+
"x-hidden": true
|
|
4603
|
+
};
|
|
4599
4604
|
if (fields) for (const [key, config] of Object.entries(fields)) result[key] = {
|
|
4600
4605
|
...result[key],
|
|
4601
4606
|
...config.label && { title: config.label },
|
|
@@ -4681,12 +4686,14 @@ function renderFieldValue(value, type) {
|
|
|
4681
4686
|
/**
|
|
4682
4687
|
* ViewModal 组件 - 详情查看弹窗
|
|
4683
4688
|
*/
|
|
4684
|
-
function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldConfig }) {
|
|
4689
|
+
function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldConfig, denyFields }) {
|
|
4685
4690
|
if (!data) return null;
|
|
4686
4691
|
const shape = schema.shape;
|
|
4692
|
+
const denySet = new Set(denyFields ?? []);
|
|
4687
4693
|
const content = /* @__PURE__ */ jsx("dl", {
|
|
4688
4694
|
className: "grid gap-4 py-4",
|
|
4689
4695
|
children: Object.entries(shape).filter(([key]) => {
|
|
4696
|
+
if (denySet.has(key)) return false;
|
|
4690
4697
|
return !(fieldConfig?.[key])?.hidden;
|
|
4691
4698
|
}).map(([key, fieldSchema]) => {
|
|
4692
4699
|
const parsed = parseZodField(fieldSchema);
|
|
@@ -4730,9 +4737,10 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
4730
4737
|
delete: permissions?.can?.delete ?? true,
|
|
4731
4738
|
export: permissions?.can?.export ?? true
|
|
4732
4739
|
};
|
|
4740
|
+
const denyFields = permissions?.deny;
|
|
4733
4741
|
const tableOverrides = buildTableOverrides(fields, tableConfig?.overrides);
|
|
4734
|
-
const formOverrides = buildFormOverrides(fields, formConfig?.overrides);
|
|
4735
|
-
const hiddenColumns = buildHiddenColumns(fields, tableConfig?.hidden,
|
|
4742
|
+
const formOverrides = buildFormOverrides(fields, formConfig?.overrides, denyFields);
|
|
4743
|
+
const hiddenColumns = buildHiddenColumns(fields, tableConfig?.hidden, denyFields);
|
|
4736
4744
|
const batchFields = buildBatchUpdateFields(schema, tableConfig?.batchFields, fields);
|
|
4737
4745
|
return /* @__PURE__ */ jsxs("div", {
|
|
4738
4746
|
className: "space-y-4",
|
|
@@ -4799,7 +4807,8 @@ function AutoCrudTable({ title, description, schema, resource, fields, table: ta
|
|
|
4799
4807
|
variant: resource.modal.variant,
|
|
4800
4808
|
data: resource.modal.selected,
|
|
4801
4809
|
schema,
|
|
4802
|
-
fields
|
|
4810
|
+
fields,
|
|
4811
|
+
denyFields
|
|
4803
4812
|
}),
|
|
4804
4813
|
/* @__PURE__ */ jsx(AlertDialog, {
|
|
4805
4814
|
open: resource.modal.deleteOpen,
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@10.25.0",
|
|
4
|
+
"version": "0.5.0",
|
|
6
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
7
6
|
"author": "wordrhyme",
|
|
8
7
|
"license": "MIT",
|
|
@@ -27,20 +26,6 @@
|
|
|
27
26
|
"publishConfig": {
|
|
28
27
|
"access": "public"
|
|
29
28
|
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"prepublishOnly": "pnpm run clean && pnpm run build",
|
|
32
|
-
"clean": "git clean -xdf .cache .turbo dist",
|
|
33
|
-
"clean:all": "git clean -xdf .cache .turbo dist node_modules",
|
|
34
|
-
"build": "tsdown",
|
|
35
|
-
"build:watch": "tsdown --watch",
|
|
36
|
-
"test": "vitest --run --passWithNoTests",
|
|
37
|
-
"test:watch": "vitest --watch",
|
|
38
|
-
"test:ui": "vitest --ui",
|
|
39
|
-
"test:coverage": "vitest --coverage",
|
|
40
|
-
"typecheck": "tsc --noEmit",
|
|
41
|
-
"lint": "eslint",
|
|
42
|
-
"format": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore"
|
|
43
|
-
},
|
|
44
29
|
"peerDependencies": {
|
|
45
30
|
"react": "^18.0.0 || ^19.0.0",
|
|
46
31
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
@@ -56,9 +41,6 @@
|
|
|
56
41
|
"@formily/json-schema": "^2.3.7",
|
|
57
42
|
"@formily/react": "^2.3.7",
|
|
58
43
|
"@formily/reactive": "^2.3.7",
|
|
59
|
-
"@pixpilot/formily-shadcn": "workspace:*",
|
|
60
|
-
"@pixpilot/shadcn": "workspace:*",
|
|
61
|
-
"@pixpilot/shadcn-ui": "workspace:*",
|
|
62
44
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
63
45
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
64
46
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
@@ -77,30 +59,46 @@
|
|
|
77
59
|
"@tanstack/react-table": "^8.21.3",
|
|
78
60
|
"@tanstack/react-virtual": "^3.13.18",
|
|
79
61
|
"class-variance-authority": "^0.7.1",
|
|
80
|
-
"clsx": "
|
|
62
|
+
"clsx": "^2.1.1",
|
|
81
63
|
"cmdk": "^1.1.1",
|
|
82
|
-
"lucide-react": "
|
|
64
|
+
"lucide-react": "0.553.0",
|
|
83
65
|
"nanoid": "^5.1.6",
|
|
84
|
-
"tailwind-merge": "
|
|
85
|
-
"vaul": "^1.1.2"
|
|
66
|
+
"tailwind-merge": "^3.4.0",
|
|
67
|
+
"vaul": "^1.1.2",
|
|
68
|
+
"@pixpilot/formily-shadcn": "0.44.3",
|
|
69
|
+
"@pixpilot/shadcn-ui": "0.47.0",
|
|
70
|
+
"@pixpilot/shadcn": "0.9.0"
|
|
86
71
|
},
|
|
87
72
|
"devDependencies": {
|
|
88
|
-
"@internal/eslint-config": "workspace:*",
|
|
89
|
-
"@internal/prettier-config": "workspace:*",
|
|
90
|
-
"@internal/tsconfig": "workspace:*",
|
|
91
|
-
"@internal/tsdown-config": "workspace:*",
|
|
92
|
-
"@internal/vitest-config": "workspace:*",
|
|
93
73
|
"@tanstack/react-query": "^5.90.15",
|
|
94
74
|
"@trpc/server": "^11.0.0",
|
|
95
|
-
"@types/node": "
|
|
96
|
-
"@types/react": "
|
|
97
|
-
"@types/react-dom": "
|
|
75
|
+
"@types/node": "^22.19.3",
|
|
76
|
+
"@types/react": "^19.2.7",
|
|
77
|
+
"@types/react-dom": "^19.2.3",
|
|
98
78
|
"drizzle-orm": "^0.45.1",
|
|
99
|
-
"eslint": "
|
|
100
|
-
"react": "
|
|
101
|
-
"react-dom": "
|
|
102
|
-
"tsdown": "
|
|
103
|
-
"typescript": "
|
|
79
|
+
"eslint": "^9.39.2",
|
|
80
|
+
"react": "19.2.4",
|
|
81
|
+
"react-dom": "19.2.4",
|
|
82
|
+
"tsdown": "^0.15.12",
|
|
83
|
+
"typescript": "^5.9.3",
|
|
84
|
+
"@internal/eslint-config": "0.3.0",
|
|
85
|
+
"@internal/tsconfig": "0.1.0",
|
|
86
|
+
"@internal/prettier-config": "0.0.1",
|
|
87
|
+
"@internal/tsdown-config": "0.1.0",
|
|
88
|
+
"@internal/vitest-config": "0.1.0"
|
|
104
89
|
},
|
|
105
|
-
"prettier": "@internal/prettier-config"
|
|
90
|
+
"prettier": "@internal/prettier-config",
|
|
91
|
+
"scripts": {
|
|
92
|
+
"clean": "git clean -xdf .cache .turbo dist",
|
|
93
|
+
"clean:all": "git clean -xdf .cache .turbo dist node_modules",
|
|
94
|
+
"build": "tsdown",
|
|
95
|
+
"build:watch": "tsdown --watch",
|
|
96
|
+
"test": "vitest --run --passWithNoTests",
|
|
97
|
+
"test:watch": "vitest --watch",
|
|
98
|
+
"test:ui": "vitest --ui",
|
|
99
|
+
"test:coverage": "vitest --coverage",
|
|
100
|
+
"typecheck": "tsc --noEmit",
|
|
101
|
+
"lint": "eslint",
|
|
102
|
+
"format": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore"
|
|
103
|
+
}
|
|
106
104
|
}
|