@wordrhyme/auto-crud 1.12.2 → 1.13.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/dist/index.d.cts CHANGED
@@ -1101,6 +1101,52 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
1101
1101
  exportTableRef
1102
1102
  }: AutoTableProps<T>): react_jsx_runtime8.JSX.Element;
1103
1103
  //#endregion
1104
+ //#region src/components/auto-crud/auto-form.d.ts
1105
+ type AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> = {
1106
+ schema: T;
1107
+ initialValues?: Partial<z.infer<T>>;
1108
+ /** 统一字段配置,推荐用于描述 auto-crud 字段级表单行为 */
1109
+ fields?: Fields;
1110
+ /** Formily 字段 schema 覆盖配置,保留兼容旧 API */
1111
+ overrides?: FormSchemaOverrides;
1112
+ /** Formily schema expression/reaction scope */
1113
+ scope?: JsonSchemaFormScope;
1114
+ loading?: boolean;
1115
+ gridColumns?: number;
1116
+ /** Label 对齐方式 */
1117
+ labelAlign?: 'left' | 'top' | 'right';
1118
+ /** Label 宽度(labelAlign 为 left 或 right 时有效) */
1119
+ labelWidth?: number | string;
1120
+ /** 是否显示提交按钮(默认 true) */
1121
+ showSubmitButton?: boolean;
1122
+ } & ({
1123
+ mode: 'view';
1124
+ onSubmit?: never;
1125
+ } | {
1126
+ mode?: 'create' | 'edit';
1127
+ onSubmit: (values: z.infer<T>) => void | Promise<void>;
1128
+ });
1129
+ interface AutoFormRef {
1130
+ submit: () => Promise<void>;
1131
+ }
1132
+ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1133
+ schema: zodSchema,
1134
+ initialValues,
1135
+ onSubmit,
1136
+ fields,
1137
+ overrides,
1138
+ scope: scopeProp,
1139
+ mode,
1140
+ loading,
1141
+ gridColumns,
1142
+ labelAlign,
1143
+ labelWidth,
1144
+ showSubmitButton
1145
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime8.JSX.Element;
1146
+ declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1147
+ ref?: React.Ref<AutoFormRef>;
1148
+ }) => ReturnType<typeof AutoFormInner>;
1149
+ //#endregion
1104
1150
  //#region src/lib/row-action-dialog.d.ts
1105
1151
  interface RowActionDialogProps {
1106
1152
  open: boolean;
@@ -1486,6 +1532,10 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
1486
1532
  scope?: JsonSchemaFormScope;
1487
1533
  /** 表单列数 */
1488
1534
  columns?: number;
1535
+ /** 标签布局:top 为上下布局,left/right 为左右布局并指定标签文字对齐 */
1536
+ labelAlign?: AutoFormProps<TSchema>['labelAlign'];
1537
+ /** 左右布局时的标签宽度,数字单位为 px,也支持 CSS 宽度字符串 */
1538
+ labelWidth?: AutoFormProps<TSchema>['labelWidth'];
1489
1539
  /** 弹窗自定义容器类名(支持控制大小、最大高度等) */
1490
1540
  className?: string;
1491
1541
  };
@@ -1564,48 +1614,6 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
1564
1614
  onExport
1565
1615
  }: AutoCrudTableProps<TSchema>): react_jsx_runtime8.JSX.Element;
1566
1616
  //#endregion
1567
- //#region src/components/auto-crud/auto-form.d.ts
1568
- interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
1569
- schema: T;
1570
- initialValues?: Partial<z.infer<T>>;
1571
- onSubmit: (values: z.infer<T>) => void | Promise<void>;
1572
- /** 统一字段配置,推荐用于描述 auto-crud 字段级表单行为 */
1573
- fields?: Fields;
1574
- /** Formily 字段 schema 覆盖配置,保留兼容旧 API */
1575
- overrides?: FormSchemaOverrides;
1576
- /** Formily schema expression/reaction scope */
1577
- scope?: JsonSchemaFormScope;
1578
- mode?: 'create' | 'edit';
1579
- loading?: boolean;
1580
- gridColumns?: number;
1581
- /** Label 对齐方式 */
1582
- labelAlign?: 'left' | 'top' | 'right';
1583
- /** Label 宽度(labelAlign 为 left 时有效) */
1584
- labelWidth?: number | string;
1585
- /** 是否显示提交按钮(默认 true) */
1586
- showSubmitButton?: boolean;
1587
- }
1588
- interface AutoFormRef {
1589
- submit: () => Promise<void>;
1590
- }
1591
- declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1592
- schema: zodSchema,
1593
- initialValues,
1594
- onSubmit,
1595
- fields,
1596
- overrides,
1597
- scope: scopeProp,
1598
- mode,
1599
- loading,
1600
- gridColumns,
1601
- labelAlign,
1602
- labelWidth,
1603
- showSubmitButton
1604
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime8.JSX.Element;
1605
- declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1606
- ref?: React.Ref<AutoFormRef>;
1607
- }) => ReturnType<typeof AutoFormInner>;
1608
- //#endregion
1609
1617
  //#region src/components/auto-crud/auto-table-simple-filters.d.ts
1610
1618
  interface AutoTableSimpleFiltersProps<TData> {
1611
1619
  table: Table<TData>;
@@ -1629,10 +1637,8 @@ type ModalVariant = 'dialog' | 'sheet';
1629
1637
  interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
1630
1638
  open: boolean;
1631
1639
  onOpenChange: (open: boolean) => void;
1632
- mode: 'create' | 'edit';
1633
1640
  schema: T;
1634
1641
  initialValues?: Partial<z.infer<T>>;
1635
- onSubmit: (values: z.infer<T>) => void | Promise<void>;
1636
1642
  loading?: boolean;
1637
1643
  variant?: ModalVariant;
1638
1644
  overrides?: FormSchemaOverrides;
@@ -1641,12 +1647,19 @@ interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
1641
1647
  locale?: AutoCrudLocale['formModal'];
1642
1648
  gridColumns?: number;
1643
1649
  /** Label 对齐方式 */
1644
- labelAlign?: 'left' | 'top' | 'right';
1645
- /** Label 宽度(labelAlign 为 left 时有效) */
1646
- labelWidth?: number | string;
1650
+ labelAlign?: AutoFormProps<T>['labelAlign'];
1651
+ /** Label 宽度(labelAlign 为 left 或 right 时有效) */
1652
+ labelWidth?: AutoFormProps<T>['labelWidth'];
1647
1653
  /** 弹窗自定义样式 */
1648
1654
  className?: string;
1649
1655
  }
1656
+ type CrudFormModalMode<T extends z.ZodObject<z.ZodRawShape>> = {
1657
+ mode: 'view';
1658
+ onSubmit?: never;
1659
+ } | {
1660
+ mode: 'create' | 'edit';
1661
+ onSubmit: NonNullable<AutoFormProps<T>['onSubmit']>;
1662
+ };
1650
1663
  declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1651
1664
  open,
1652
1665
  onOpenChange,
@@ -1664,7 +1677,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1664
1677
  labelAlign,
1665
1678
  labelWidth,
1666
1679
  className
1667
- }: CrudFormModalProps<T>): react_jsx_runtime8.JSX.Element;
1680
+ }: CrudFormModalProps<T> & CrudFormModalMode<T>): react_jsx_runtime8.JSX.Element;
1668
1681
  //#endregion
1669
1682
  //#region src/components/auto-crud/import-dialog.d.ts
1670
1683
  interface ImportDialogProps {
package/dist/index.d.ts CHANGED
@@ -1101,6 +1101,52 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
1101
1101
  exportTableRef
1102
1102
  }: AutoTableProps<T>): react_jsx_runtime8.JSX.Element;
1103
1103
  //#endregion
1104
+ //#region src/components/auto-crud/auto-form.d.ts
1105
+ type AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> = {
1106
+ schema: T;
1107
+ initialValues?: Partial<z.infer<T>>;
1108
+ /** 统一字段配置,推荐用于描述 auto-crud 字段级表单行为 */
1109
+ fields?: Fields;
1110
+ /** Formily 字段 schema 覆盖配置,保留兼容旧 API */
1111
+ overrides?: FormSchemaOverrides;
1112
+ /** Formily schema expression/reaction scope */
1113
+ scope?: JsonSchemaFormScope;
1114
+ loading?: boolean;
1115
+ gridColumns?: number;
1116
+ /** Label 对齐方式 */
1117
+ labelAlign?: 'left' | 'top' | 'right';
1118
+ /** Label 宽度(labelAlign 为 left 或 right 时有效) */
1119
+ labelWidth?: number | string;
1120
+ /** 是否显示提交按钮(默认 true) */
1121
+ showSubmitButton?: boolean;
1122
+ } & ({
1123
+ mode: 'view';
1124
+ onSubmit?: never;
1125
+ } | {
1126
+ mode?: 'create' | 'edit';
1127
+ onSubmit: (values: z.infer<T>) => void | Promise<void>;
1128
+ });
1129
+ interface AutoFormRef {
1130
+ submit: () => Promise<void>;
1131
+ }
1132
+ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1133
+ schema: zodSchema,
1134
+ initialValues,
1135
+ onSubmit,
1136
+ fields,
1137
+ overrides,
1138
+ scope: scopeProp,
1139
+ mode,
1140
+ loading,
1141
+ gridColumns,
1142
+ labelAlign,
1143
+ labelWidth,
1144
+ showSubmitButton
1145
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime8.JSX.Element;
1146
+ declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1147
+ ref?: React.Ref<AutoFormRef>;
1148
+ }) => ReturnType<typeof AutoFormInner>;
1149
+ //#endregion
1104
1150
  //#region src/lib/row-action-dialog.d.ts
1105
1151
  interface RowActionDialogProps {
1106
1152
  open: boolean;
@@ -1486,6 +1532,10 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
1486
1532
  scope?: JsonSchemaFormScope;
1487
1533
  /** 表单列数 */
1488
1534
  columns?: number;
1535
+ /** 标签布局:top 为上下布局,left/right 为左右布局并指定标签文字对齐 */
1536
+ labelAlign?: AutoFormProps<TSchema>['labelAlign'];
1537
+ /** 左右布局时的标签宽度,数字单位为 px,也支持 CSS 宽度字符串 */
1538
+ labelWidth?: AutoFormProps<TSchema>['labelWidth'];
1489
1539
  /** 弹窗自定义容器类名(支持控制大小、最大高度等) */
1490
1540
  className?: string;
1491
1541
  };
@@ -1564,48 +1614,6 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
1564
1614
  onExport
1565
1615
  }: AutoCrudTableProps<TSchema>): react_jsx_runtime8.JSX.Element;
1566
1616
  //#endregion
1567
- //#region src/components/auto-crud/auto-form.d.ts
1568
- interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
1569
- schema: T;
1570
- initialValues?: Partial<z.infer<T>>;
1571
- onSubmit: (values: z.infer<T>) => void | Promise<void>;
1572
- /** 统一字段配置,推荐用于描述 auto-crud 字段级表单行为 */
1573
- fields?: Fields;
1574
- /** Formily 字段 schema 覆盖配置,保留兼容旧 API */
1575
- overrides?: FormSchemaOverrides;
1576
- /** Formily schema expression/reaction scope */
1577
- scope?: JsonSchemaFormScope;
1578
- mode?: 'create' | 'edit';
1579
- loading?: boolean;
1580
- gridColumns?: number;
1581
- /** Label 对齐方式 */
1582
- labelAlign?: 'left' | 'top' | 'right';
1583
- /** Label 宽度(labelAlign 为 left 时有效) */
1584
- labelWidth?: number | string;
1585
- /** 是否显示提交按钮(默认 true) */
1586
- showSubmitButton?: boolean;
1587
- }
1588
- interface AutoFormRef {
1589
- submit: () => Promise<void>;
1590
- }
1591
- declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1592
- schema: zodSchema,
1593
- initialValues,
1594
- onSubmit,
1595
- fields,
1596
- overrides,
1597
- scope: scopeProp,
1598
- mode,
1599
- loading,
1600
- gridColumns,
1601
- labelAlign,
1602
- labelWidth,
1603
- showSubmitButton
1604
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime8.JSX.Element;
1605
- declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1606
- ref?: React.Ref<AutoFormRef>;
1607
- }) => ReturnType<typeof AutoFormInner>;
1608
- //#endregion
1609
1617
  //#region src/components/auto-crud/auto-table-simple-filters.d.ts
1610
1618
  interface AutoTableSimpleFiltersProps<TData> {
1611
1619
  table: Table<TData>;
@@ -1629,10 +1637,8 @@ type ModalVariant = 'dialog' | 'sheet';
1629
1637
  interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
1630
1638
  open: boolean;
1631
1639
  onOpenChange: (open: boolean) => void;
1632
- mode: 'create' | 'edit';
1633
1640
  schema: T;
1634
1641
  initialValues?: Partial<z.infer<T>>;
1635
- onSubmit: (values: z.infer<T>) => void | Promise<void>;
1636
1642
  loading?: boolean;
1637
1643
  variant?: ModalVariant;
1638
1644
  overrides?: FormSchemaOverrides;
@@ -1641,12 +1647,19 @@ interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
1641
1647
  locale?: AutoCrudLocale['formModal'];
1642
1648
  gridColumns?: number;
1643
1649
  /** Label 对齐方式 */
1644
- labelAlign?: 'left' | 'top' | 'right';
1645
- /** Label 宽度(labelAlign 为 left 时有效) */
1646
- labelWidth?: number | string;
1650
+ labelAlign?: AutoFormProps<T>['labelAlign'];
1651
+ /** Label 宽度(labelAlign 为 left 或 right 时有效) */
1652
+ labelWidth?: AutoFormProps<T>['labelWidth'];
1647
1653
  /** 弹窗自定义样式 */
1648
1654
  className?: string;
1649
1655
  }
1656
+ type CrudFormModalMode<T extends z.ZodObject<z.ZodRawShape>> = {
1657
+ mode: 'view';
1658
+ onSubmit?: never;
1659
+ } | {
1660
+ mode: 'create' | 'edit';
1661
+ onSubmit: NonNullable<AutoFormProps<T>['onSubmit']>;
1662
+ };
1650
1663
  declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1651
1664
  open,
1652
1665
  onOpenChange,
@@ -1664,7 +1677,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1664
1677
  labelAlign,
1665
1678
  labelWidth,
1666
1679
  className
1667
- }: CrudFormModalProps<T>): react_jsx_runtime8.JSX.Element;
1680
+ }: CrudFormModalProps<T> & CrudFormModalMode<T>): react_jsx_runtime8.JSX.Element;
1668
1681
  //#endregion
1669
1682
  //#region src/components/auto-crud/import-dialog.d.ts
1670
1683
  interface ImportDialogProps {