react-antd-xform 1.0.11 → 1.0.12-beta.1
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/form/context/formEnvContext.d.ts +1 -1
- package/dist/form/context/modelContext.d.ts +1 -1
- package/dist/form/extend/form-array.d.ts +2 -2
- package/dist/form/extend/form-array.js +2 -2
- package/dist/form/extend/form-check.d.ts +2 -2
- package/dist/form/extend/form-check.js +1 -1
- package/dist/form/extend/form-effect.d.ts +2 -2
- package/dist/form/extend/form-effect.js +1 -1
- package/dist/form/extend/form-layout.d.ts +1 -1
- package/dist/form/extend/form-layout.js +1 -1
- package/dist/form/extend/form-model-consumer.d.ts +1 -1
- package/dist/form/extend/form-reset.js +2 -2
- package/dist/form/extend/form-submit.js +1 -1
- package/dist/form/form/index.d.ts +34 -0
- package/dist/form/{index.js → form/index.js} +15 -15
- package/dist/form/{form-item.d.ts → form-item/index.d.ts} +4 -1
- package/dist/form/{form-item.js → form-item/index.js} +14 -11
- package/dist/form/{array-helper.d.ts → helpers/array-helper.d.ts} +2 -2
- package/dist/form/{array-helper.js → helpers/array-helper.js} +4 -4
- package/dist/form/index.d.ts +9 -33
- package/dist/form/{model-utils.d.ts → model/model-utils.d.ts} +1 -1
- package/dist/form/{model-utils.js → model/model-utils.js} +2 -2
- package/dist/form/{model.d.ts → model/model.d.ts} +2 -2
- package/dist/form/{model.js → model/model.js} +3 -3
- package/dist/form/{type.d.ts → types/index.d.ts} +2 -2
- package/dist/form/{common-utils.d.ts → utils/common-utils.d.ts} +2 -2
- package/dist/form/{common-utils.js → utils/common-utils.js} +2 -2
- package/dist/form-ui/{default-component.d.ts → default-components/index.d.ts} +2 -2
- package/dist/form-ui/{default-component.js → default-components/index.js} +4 -4
- package/dist/form-ui/{render-preview.js → default-components/utils/render-preview.js} +2 -2
- package/dist/form-ui/{common-utils.js → default-components/utils/value-change.js} +4 -4
- package/dist/form-ui/extend/array-table/index.d.ts +9 -0
- package/dist/form-ui/extend/array-table/index.js +149 -0
- package/dist/form-ui/extend/array-table/utils/calculateArrayTableData.d.ts +5 -0
- package/dist/form-ui/extend/array-table/utils/calculateArrayTableData.js +160 -0
- package/dist/form-ui/extend/array-table/utils/columm-utils.d.ts +17 -0
- package/dist/form-ui/extend/array-table/utils/columm-utils.js +52 -0
- package/dist/form-ui/extend/array-table/utils/tree-utils.d.ts +7 -0
- package/dist/form-ui/extend/array-table/utils/tree-utils.js +30 -0
- package/dist/form-ui/index.d.ts +2 -0
- package/dist/form-ui/types/index.d.ts +9 -0
- package/dist/index.d.ts +2 -9
- package/dist/index.js +7 -5
- package/package.json +1 -1
- /package/dist/form/{enum.d.ts → types/enum.d.ts} +0 -0
- /package/dist/form/{enum.js → types/enum.js} +0 -0
- /package/dist/form-ui/{render-preview.d.ts → default-components/utils/render-preview.d.ts} +0 -0
- /package/dist/form-ui/{common-utils.d.ts → default-components/utils/value-change.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { FormEnvContextType } from '../
|
|
2
|
+
import { FormEnvContextType } from '../types';
|
|
3
3
|
export declare const useFormEnv: () => FormEnvContextType;
|
|
4
4
|
export declare function FormEnvProvider({ children, ...override }: FormEnvContextType & {
|
|
5
5
|
children: React.ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FormModel } from '../model';
|
|
2
|
-
import { FormArrayLayoutInput } from '../
|
|
1
|
+
import { FormModel } from '../model/model';
|
|
2
|
+
import { FormArrayLayoutInput } from '../types';
|
|
3
3
|
export interface FormArrayProps<T> {
|
|
4
4
|
use?: boolean;
|
|
5
5
|
arrayModel?: FormModel<T[]>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
2
|
import "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/index.js";
|
|
3
3
|
import { useModel, ModelProvider } from "../context/modelContext.js";
|
|
4
|
-
import { range } from "../common-utils.js";
|
|
5
|
-
import { arrayHelpers } from "../array-helper.js";
|
|
4
|
+
import { range } from "../utils/common-utils.js";
|
|
5
|
+
import { arrayHelpers } from "../helpers/array-helper.js";
|
|
6
6
|
import { observer } from "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/observer.js";
|
|
7
7
|
const defaultArrayLayout = ({
|
|
8
8
|
arrayModel,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Check } from '../model';
|
|
2
|
-
import { CheckConfig, Watchable } from '../
|
|
1
|
+
import { Check } from '../model/model';
|
|
2
|
+
import { CheckConfig, Watchable } from '../types';
|
|
3
3
|
export interface FormCheckProps<T = any> extends CheckConfig<T> {
|
|
4
4
|
name?: string;
|
|
5
5
|
check?: Check<T>;
|
|
@@ -3,7 +3,7 @@ import { reaction } from "mobx";
|
|
|
3
3
|
import "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/index.js";
|
|
4
4
|
import { useModel } from "../context/modelContext.js";
|
|
5
5
|
import { useFormEnv } from "../context/formEnvContext.js";
|
|
6
|
-
import { composeValue, convertWatchableToExpression } from "../common-utils.js";
|
|
6
|
+
import { composeValue, convertWatchableToExpression } from "../utils/common-utils.js";
|
|
7
7
|
import { observer } from "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/observer.js";
|
|
8
8
|
const FormCheck = observer(function FormCheck2({
|
|
9
9
|
name,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IEqualsComparer } from 'mobx';
|
|
2
|
-
import { Watchable } from '../
|
|
3
|
-
import { FormModel } from '../model';
|
|
2
|
+
import { Watchable } from '../types';
|
|
3
|
+
import { FormModel } from '../model/model';
|
|
4
4
|
export interface FormEffectProps<T = any> {
|
|
5
5
|
watch: Watchable<T>;
|
|
6
6
|
effect(value: T, detail: {
|
|
@@ -2,7 +2,7 @@ import { useRef, useEffect } from "react";
|
|
|
2
2
|
import "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/index.js";
|
|
3
3
|
import { reaction } from "mobx";
|
|
4
4
|
import { useModel } from "../context/modelContext.js";
|
|
5
|
-
import { convertWatchableToExpression } from "../common-utils.js";
|
|
5
|
+
import { convertWatchableToExpression } from "../utils/common-utils.js";
|
|
6
6
|
import { observer } from "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/observer.js";
|
|
7
7
|
const FormEffect = observer(function FormEffect2({
|
|
8
8
|
watch,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FormLayoutProps } from '../
|
|
1
|
+
import { FormLayoutProps } from '../types';
|
|
2
2
|
export declare function FormLayout({ children, className, style, labelPosition, labelWidth, formItemGap, controlWidth, defaultLabelTopPosition, inlineError, containerProps, }: FormLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
2
|
import cx from "../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
|
|
3
3
|
import styled from "styled-components";
|
|
4
|
-
import { asCSSLength } from "../common-utils.js";
|
|
4
|
+
import { asCSSLength } from "../utils/common-utils.js";
|
|
5
5
|
const FormLayoutContainer = styled.div`
|
|
6
6
|
--label-width: auto;
|
|
7
7
|
--control-width: auto;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
2
|
import { action } from "mobx";
|
|
3
|
-
import { modelUtils } from "../model-utils.js";
|
|
3
|
+
import { modelUtils } from "../model/model-utils.js";
|
|
4
4
|
import { useModel } from "../context/modelContext.js";
|
|
5
5
|
import { useFormEnv } from "../context/formEnvContext.js";
|
|
6
6
|
function FormReset({
|
|
7
7
|
ButtonComponent,
|
|
8
|
-
children = "
|
|
8
|
+
children = "重置",
|
|
9
9
|
...props
|
|
10
10
|
}) {
|
|
11
11
|
const model = useModel();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
|
-
import { modelUtils } from "../model-utils.js";
|
|
2
|
+
import { modelUtils } from "../model/model-utils.js";
|
|
3
3
|
import { useModel } from "../context/modelContext.js";
|
|
4
4
|
import { useFormEnv } from "../context/formEnvContext.js";
|
|
5
5
|
function FormSubmit({
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormProps } from '../types';
|
|
3
|
+
import { FormModel } from '../model/model';
|
|
4
|
+
import { FormItemView } from '../form-item';
|
|
5
|
+
import { FormReset } from '../extend/form-reset';
|
|
6
|
+
import { FormLayout } from '../extend/form-layout';
|
|
7
|
+
import { FormSubmit } from '../extend/form-submit';
|
|
8
|
+
export declare function Form({ model: modelProp, defaultValue, children, className, style, layout, containerProps, htmlIdPrefix: htmlIdPrefixProp, variant, isPreview, ...restEnvProps }: FormProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare namespace Form {
|
|
10
|
+
var Array: (<T extends unknown>({ name, children, layout, arrayModel: arrayModelProp, use, }: import("@/form/extend/form-array").FormArrayProps<T>) => import("react/jsx-runtime").JSX.Element) & {
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
var Check: (<T = any>({ name, check: checkProp, validate, watch, validateOnMount, renderError, deps, }: import("@/form/extend/form-check").FormCheckProps<T>) => any) & {
|
|
14
|
+
displayName: string;
|
|
15
|
+
};
|
|
16
|
+
var Effect: (<T = any>({ watch, effect, fireImmediately, deps, equals, }: import("@/form/extend/form-effect").FormEffectProps<T>) => React.ReactElement) & {
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
19
|
+
var Object: (({ name, children, use }: {
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
name: string;
|
|
22
|
+
use?: boolean;
|
|
23
|
+
}) => import("react/jsx-runtime").JSX.Element) & {
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
26
|
+
var Submit: typeof FormSubmit;
|
|
27
|
+
var Layout: typeof FormLayout;
|
|
28
|
+
var ItemView: typeof FormItemView;
|
|
29
|
+
var ModelProvider: React.Provider<FormModel<any>>;
|
|
30
|
+
var ModelConsumer: (({ children }: React.ConsumerProps<FormModel<any>>) => React.ReactElement) & {
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
33
|
+
var Reset: typeof FormReset;
|
|
34
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { FormModel } from "
|
|
4
|
-
import { FormItemView } from "
|
|
5
|
-
import { ModelProvider } from "
|
|
6
|
-
import { FormEnvProvider } from "
|
|
7
|
-
import { composeValue, useHtmlIdPrefix } from "
|
|
8
|
-
import { FormArray } from "
|
|
9
|
-
import { FormCheck } from "
|
|
10
|
-
import { FormReset } from "
|
|
11
|
-
import { FormLayout } from "
|
|
12
|
-
import { FormSubmit } from "
|
|
13
|
-
import { FormEffect } from "
|
|
14
|
-
import { FormObject } from "
|
|
15
|
-
import { FormModelConsumer } from "
|
|
3
|
+
import { FormModel } from "../model/model.js";
|
|
4
|
+
import { FormItemView } from "../form-item/index.js";
|
|
5
|
+
import { ModelProvider } from "../context/modelContext.js";
|
|
6
|
+
import { FormEnvProvider } from "../context/formEnvContext.js";
|
|
7
|
+
import { composeValue, useHtmlIdPrefix } from "../utils/common-utils.js";
|
|
8
|
+
import { FormArray } from "../extend/form-array.js";
|
|
9
|
+
import { FormCheck } from "../extend/form-check.js";
|
|
10
|
+
import { FormReset } from "../extend/form-reset.js";
|
|
11
|
+
import { FormLayout } from "../extend/form-layout.js";
|
|
12
|
+
import { FormSubmit } from "../extend/form-submit.js";
|
|
13
|
+
import { FormEffect } from "../extend/form-effect.js";
|
|
14
|
+
import { FormObject } from "../extend/form-object.js";
|
|
15
|
+
import { FormModelConsumer } from "../extend/form-model-consumer.js";
|
|
16
16
|
function Form({
|
|
17
17
|
model: modelProp,
|
|
18
18
|
defaultValue,
|
|
@@ -41,7 +41,7 @@ Form.Layout = FormLayout;
|
|
|
41
41
|
Form.ItemView = FormItemView;
|
|
42
42
|
Form.ModelProvider = ModelProvider;
|
|
43
43
|
Form.ModelConsumer = FormModelConsumer;
|
|
44
|
-
Form.
|
|
44
|
+
Form.Reset = FormReset;
|
|
45
45
|
export {
|
|
46
46
|
Form
|
|
47
47
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormItemCreationOptions, FormItemProps, FormItemViewProps } from '
|
|
1
|
+
import { FormItemCreationOptions, FormItemProps, FormItemViewProps } from '../types';
|
|
2
2
|
export declare function FormItemView({ htmlId, label, help, tip, asterisk, error, children, className, style, labelWidth, controlWidth, rightNode, labelStyle, controlStyle, }: FormItemViewProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare function createFormItem(inputOptions: FormItemCreationOptions): {
|
|
4
4
|
({ defaultValue: defaultValueProp, isEmpty, renderPreview, componentProps: componentPropsProp, name, field: fieldProp, ...props }: Omit<FormItemProps, "component">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,3 +13,6 @@ export declare const AnonymousFormItem: {
|
|
|
13
13
|
displayName: string;
|
|
14
14
|
};
|
|
15
15
|
export declare function FormItem({ use, component, ...props }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare namespace FormItem {
|
|
17
|
+
var register: (options: FormItemCreationOptions) => void;
|
|
18
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
2
|
import React, { useLayoutEffect, useEffect } from "react";
|
|
3
|
-
import cx from "
|
|
4
|
-
import "
|
|
5
|
-
import stringifyObject from "
|
|
3
|
+
import cx from "../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
|
|
4
|
+
import "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/index.js";
|
|
5
|
+
import stringifyObject from "../../node_modules/.pnpm/stringify-object@5.0.0/node_modules/stringify-object/index.js";
|
|
6
6
|
import { toJS, reaction, runInAction } from "mobx";
|
|
7
|
-
import { FieldType } from "
|
|
8
|
-
import { isFalsyOrEmptyArray, composeValue, pick, asCSSLength } from "
|
|
9
|
-
import { Field } from "
|
|
10
|
-
import { useModel } from "
|
|
11
|
-
import { useFormEnv } from "
|
|
12
|
-
import { ALL_COMPONENTS } from "
|
|
13
|
-
import { observer } from "
|
|
7
|
+
import { FieldType } from "../types/enum.js";
|
|
8
|
+
import { isFalsyOrEmptyArray, composeValue, pick, asCSSLength } from "../utils/common-utils.js";
|
|
9
|
+
import { Field } from "../model/model.js";
|
|
10
|
+
import { useModel } from "../context/modelContext.js";
|
|
11
|
+
import { useFormEnv } from "../context/formEnvContext.js";
|
|
12
|
+
import { ALL_COMPONENTS } from "../../form-ui/default-components/index.js";
|
|
13
|
+
import { observer } from "../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/observer.js";
|
|
14
14
|
function processCreationOptions(options) {
|
|
15
15
|
const render = options.render ?? ((props) => React.createElement(options.component, props));
|
|
16
16
|
return {
|
|
@@ -266,6 +266,9 @@ function FormItem({
|
|
|
266
266
|
} });
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
+
FormItem.register = (options) => {
|
|
270
|
+
COMPONENT_DICT[options.name] = createFormItem(options);
|
|
271
|
+
};
|
|
269
272
|
export {
|
|
270
273
|
AnonymousFormItem,
|
|
271
274
|
FormItem,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FormModel } from '
|
|
2
|
-
import { FormArrayLayoutInput } from '
|
|
1
|
+
import { FormModel } from '../model/model';
|
|
2
|
+
import { FormArrayLayoutInput } from '../types';
|
|
3
3
|
export declare const arrayHelpers: {
|
|
4
4
|
append: (arrayModel: FormModel<unknown[]>, itemFactory?: any) => void;
|
|
5
5
|
delete: (arrayModel: FormModel<unknown[]>, itemIndex: number) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
2
|
import { action } from "mobx";
|
|
3
|
-
import invariant from "
|
|
4
|
-
import { Form } from "
|
|
5
|
-
import { composeValue } from "
|
|
3
|
+
import invariant from "../../node_modules/.pnpm/invariant@2.2.4/node_modules/invariant/browser.js";
|
|
4
|
+
import { Form } from "../form/index.js";
|
|
5
|
+
import { composeValue } from "../utils/common-utils.js";
|
|
6
6
|
function invariantArrayShapeIsAutoOrArray(arrayModel) {
|
|
7
7
|
invariant(arrayModel._valueShape === "auto" || arrayModel._valueShape === "array", 'arrayModel._valueShape should be "auto" or "array"');
|
|
8
8
|
}
|
package/dist/form/index.d.ts
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
displayName: string;
|
|
11
|
-
};
|
|
12
|
-
var Check: (<T = any>({ name, check: checkProp, validate, watch, validateOnMount, renderError, deps, }: import("./extend/form-check").FormCheckProps<T>) => any) & {
|
|
13
|
-
displayName: string;
|
|
14
|
-
};
|
|
15
|
-
var Effect: (<T = any>({ watch, effect, fireImmediately, deps, equals, }: import("./extend/form-effect").FormEffectProps<T>) => React.ReactElement) & {
|
|
16
|
-
displayName: string;
|
|
17
|
-
};
|
|
18
|
-
var Object: (({ name, children, use }: {
|
|
19
|
-
children: React.ReactNode;
|
|
20
|
-
name: string;
|
|
21
|
-
use?: boolean;
|
|
22
|
-
}) => import("react/jsx-runtime").JSX.Element) & {
|
|
23
|
-
displayName: string;
|
|
24
|
-
};
|
|
25
|
-
var Submit: typeof FormSubmit;
|
|
26
|
-
var Layout: typeof FormLayout;
|
|
27
|
-
var ItemView: typeof FormItemView;
|
|
28
|
-
var ModelProvider: React.Provider<FormModel<any>>;
|
|
29
|
-
var ModelConsumer: (({ children }: React.ConsumerProps<FormModel<any>>) => React.ReactElement) & {
|
|
30
|
-
displayName: string;
|
|
31
|
-
};
|
|
32
|
-
var FormReset: typeof import("./extend/form-reset").FormReset;
|
|
33
|
-
}
|
|
1
|
+
export { Form } from './form';
|
|
2
|
+
export { useModel } from './context/modelContext';
|
|
3
|
+
export { FormEnvProvider, useFormEnv } from './context/formEnvContext';
|
|
4
|
+
export { FormItem, createFormItem } from './form-item';
|
|
5
|
+
export { FormModel } from './model/model';
|
|
6
|
+
export { arrayHelpers } from './helpers/array-helper';
|
|
7
|
+
export { AsyncValue } from './helpers/AsyncValue';
|
|
8
|
+
export { modelUtils } from './model/model-utils';
|
|
9
|
+
export type { FieldConfig, CheckConfig, FormEnvContextType, FormLayoutParams, FormProps, FormLayoutProps, FormItemComponentProps, FormItemCreationOptions, BaseOptionType, DefaultOptionType, FormItemProps, FormItemViewProps, SubmitExtraOptions, SubmitOptions, FormArrayLayoutInput, Watchable, } from './types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Field, FormModel } from './model';
|
|
2
|
-
import { FieldValidateTrigger, FormEnvContextType, SubmitOptions } from '
|
|
2
|
+
import { FieldValidateTrigger, FormEnvContextType, SubmitOptions } from '../types';
|
|
3
3
|
export declare const modelUtils: {
|
|
4
4
|
clearError: <T>(model: FormModel<T>) => void;
|
|
5
5
|
scrollToFirstError(errorFields: Field[]): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { action, runInAction, observable, toJS } from "mobx";
|
|
2
|
-
import { FieldType } from "
|
|
3
|
-
import { observableSetIn } from "
|
|
2
|
+
import { FieldType } from "../types/enum.js";
|
|
3
|
+
import { observableSetIn } from "../utils/common-utils.js";
|
|
4
4
|
const modelUtils = {
|
|
5
5
|
clearError: action(function(model) {
|
|
6
6
|
model.iterateFields((field) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModelType, FieldType } from '
|
|
2
|
-
import { XName, ResolveXName, ValueShape, FieldConfig, CheckConfig, FieldState, FieldCreateOptions, FieldValidateTrigger, FormModelCreateOptions } from '
|
|
1
|
+
import { ModelType, FieldType } from '../types/enum';
|
|
2
|
+
import { XName, ResolveXName, ValueShape, FieldConfig, CheckConfig, FieldState, FieldCreateOptions, FieldValidateTrigger, FormModelCreateOptions } from '../types';
|
|
3
3
|
declare class IdGenerator {
|
|
4
4
|
private _nextId;
|
|
5
5
|
private prefix;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import invariant from "
|
|
1
|
+
import invariant from "../../node_modules/.pnpm/invariant@2.2.4/node_modules/invariant/browser.js";
|
|
2
2
|
import { makeObservable, action, computed, observable, toJS } from "mobx";
|
|
3
|
-
import { ModelType, FieldType } from "
|
|
4
|
-
import { composeValue, observableGetIn, keyToValueShape, splitToPath, observableSetIn } from "
|
|
3
|
+
import { ModelType, FieldType } from "../types/enum.js";
|
|
4
|
+
import { composeValue, observableGetIn, keyToValueShape, splitToPath, observableSetIn } from "../utils/common-utils.js";
|
|
5
5
|
const EMPTY_PATH = [];
|
|
6
6
|
const ROOT_MODEL_CREATE_OPTIONS = {
|
|
7
7
|
modelType: ModelType.rootModel
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { Field, FormModel } from '
|
|
2
|
+
import { Field, FormModel } from '../model/model';
|
|
3
3
|
import { FieldType, ModelType } from './enum';
|
|
4
|
-
import { AsyncValue } from '
|
|
4
|
+
import { AsyncValue } from '../helpers/AsyncValue';
|
|
5
5
|
export declare const Variants: readonly ["outlined", "borderless", "filled", "underlined"];
|
|
6
6
|
export type Variant = (typeof Variants)[number];
|
|
7
7
|
type valueOf<T> = T[keyof T];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Watchable } from '
|
|
2
|
-
import { FormModel } from '
|
|
1
|
+
import { Watchable } from '../types';
|
|
2
|
+
import { FormModel } from '../model/model';
|
|
3
3
|
export declare function keyToValueShape(key: string): "array" | "object";
|
|
4
4
|
export declare function splitToPath(name: number | string): string[];
|
|
5
5
|
/** 合并两个值,如果第一个不为 undefined,则使用第一个值,否则使用第二个值 */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import * as mobx from "mobx";
|
|
3
3
|
import { toJS } from "mobx";
|
|
4
|
-
import { Field, FormModel } from "
|
|
5
|
-
import { AsyncValue } from "
|
|
4
|
+
import { Field, FormModel } from "../model/model.js";
|
|
5
|
+
import { AsyncValue } from "../helpers/AsyncValue.js";
|
|
6
6
|
function isNumericKey(key) {
|
|
7
7
|
return String(Number.parseInt(key)) === key;
|
|
8
8
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isEmptyValue } from './
|
|
1
|
+
import { isEmptyValue } from './utils/value-change';
|
|
2
2
|
declare const ALL_COMPONENTS: {
|
|
3
3
|
name: "input" | "textArea" | "select" | "singleSelect" | "multiSelect" | "radio" | "checkbox" | "inputNumber" | "slider" | "switch" | "datePicker" | "dateRangePicker" | "timePicker" | "timeRangePicker" | "rate" | "colorPicker";
|
|
4
4
|
component: any;
|
|
5
5
|
defaultValue: any;
|
|
6
6
|
isEmpty: typeof isEmptyValue;
|
|
7
7
|
hasIntrinsicWidth: boolean;
|
|
8
|
-
renderPreview: (props: import('
|
|
8
|
+
renderPreview: (props: import('../../form/types').FormItemComponentProps) => import('react').ReactNode;
|
|
9
9
|
}[];
|
|
10
10
|
export { ALL_COMPONENTS };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withInjectedProps, withDayjsTransformAntdTimeRange, withDayjsTransformAntdTime, withDayjsTransformAntdDateRangePicker, withDayjsTransformAntdDate, withValueChangeHandler, isEmptyValue, withColorPickerHandler } from "./
|
|
3
|
-
import { renderColorPreview, renderRatePreview, renderTimeRangePreview, renderTimePreview, renderDateRangePreview, renderDatePreview, renderBooleanPreview, renderValueToPreview, renderMultiplePreview, renderSelectToPreview } from "./render-preview.js";
|
|
1
|
+
import { TimePicker, DatePicker, Checkbox, Radio, Input, ColorPicker, Rate, Switch, Slider, InputNumber, Select } from "antd";
|
|
2
|
+
import { withInjectedProps, withDayjsTransformAntdTimeRange, withDayjsTransformAntdTime, withDayjsTransformAntdDateRangePicker, withDayjsTransformAntdDate, withValueChangeHandler, isEmptyValue, withColorPickerHandler } from "./utils/value-change.js";
|
|
3
|
+
import { renderColorPreview, renderRatePreview, renderTimeRangePreview, renderTimePreview, renderDateRangePreview, renderDatePreview, renderBooleanPreview, renderValueToPreview, renderMultiplePreview, renderSelectToPreview } from "./utils/render-preview.js";
|
|
4
4
|
const COMPONENT_MAP = {
|
|
5
5
|
input: Input,
|
|
6
6
|
textArea: Input.TextArea,
|
|
@@ -79,7 +79,7 @@ const COMPONENT_RULES = {
|
|
|
79
79
|
hasIntrinsicWidth: false
|
|
80
80
|
},
|
|
81
81
|
slider: {
|
|
82
|
-
hocs: [
|
|
82
|
+
hocs: [],
|
|
83
83
|
renderPreview: renderValueToPreview,
|
|
84
84
|
hasIntrinsicWidth: false
|
|
85
85
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "
|
|
2
|
-
import dayjs from "
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
|
+
import dayjs from "../../../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js";
|
|
3
3
|
const renderValueToPreview = (props) => {
|
|
4
4
|
const {
|
|
5
5
|
value
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
2
|
import React, { useMemo, useCallback } from "react";
|
|
3
|
-
import dayjs from "
|
|
4
|
-
import weekYear from "
|
|
5
|
-
import weekOfYear from "
|
|
3
|
+
import dayjs from "../../../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js";
|
|
4
|
+
import weekYear from "../../../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/weekYear.js";
|
|
5
|
+
import weekOfYear from "../../../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/plugin/weekOfYear.js";
|
|
6
6
|
dayjs.extend(weekOfYear);
|
|
7
7
|
dayjs.extend(weekYear);
|
|
8
8
|
if (!dayjs.__patchedForAntd__) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormArrayLayoutInput } from '../../../form';
|
|
2
|
+
import { ArrayTableOptions } from '../../types';
|
|
3
|
+
export declare const TableRowOperations: (({ operations, arrayModel, itemIndex }: any) => import("react/jsx-runtime").JSX.Element) & {
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function arrayTable({ orderColumn, style, className, operations, operationColumn, tableImplementation: Table, tableProps, }?: ArrayTableOptions): (input: FormArrayLayoutInput) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace arrayTable {
|
|
8
|
+
var Group: (_props: any) => any;
|
|
9
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { action } from "mobx";
|
|
4
|
+
import "../../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/index.js";
|
|
5
|
+
import { Table, Popconfirm, Button } from "antd";
|
|
6
|
+
import { enhanceTableColumns } from "./utils/columm-utils.js";
|
|
7
|
+
import { calculateArrayTableData } from "./utils/calculateArrayTableData.js";
|
|
8
|
+
import { observer } from "../../../node_modules/.pnpm/mobx-react-lite@4.1.0_mobx@6.13.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/mobx-react-lite/es/observer.js";
|
|
9
|
+
import { Form } from "../../../form/form/index.js";
|
|
10
|
+
import { useFormEnv } from "../../../form/context/formEnvContext.js";
|
|
11
|
+
import { arrayHelpers } from "../../../form/helpers/array-helper.js";
|
|
12
|
+
const AntdTableRow = (props) => {
|
|
13
|
+
const {
|
|
14
|
+
children,
|
|
15
|
+
...restProps
|
|
16
|
+
} = props;
|
|
17
|
+
if (!props["data-row-type"] || props["data-row-type"] !== "data") {
|
|
18
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { ...restProps, children });
|
|
19
|
+
}
|
|
20
|
+
const {
|
|
21
|
+
record
|
|
22
|
+
} = props;
|
|
23
|
+
const {
|
|
24
|
+
hiddenItems,
|
|
25
|
+
effects,
|
|
26
|
+
checks,
|
|
27
|
+
itemIndex
|
|
28
|
+
} = record;
|
|
29
|
+
const hiddenItemsElements = hiddenItems.map((item) => React.cloneElement(item, {
|
|
30
|
+
renderHiddenFormItemView: false
|
|
31
|
+
}));
|
|
32
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Form.Object, { name: String(itemIndex), children: [
|
|
33
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("tr", { ...restProps, children }),
|
|
34
|
+
effects,
|
|
35
|
+
checks,
|
|
36
|
+
hiddenItemsElements
|
|
37
|
+
] });
|
|
38
|
+
};
|
|
39
|
+
function resolveOperationConfig(rowIndex, config, defaultConfig) {
|
|
40
|
+
if (typeof config === "function") {
|
|
41
|
+
return resolveOperationConfig(rowIndex, config(rowIndex), defaultConfig);
|
|
42
|
+
}
|
|
43
|
+
if (typeof config === "boolean") {
|
|
44
|
+
return {
|
|
45
|
+
...defaultConfig,
|
|
46
|
+
show: Boolean(config)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
...defaultConfig,
|
|
51
|
+
show: defaultConfig.show || Boolean(config),
|
|
52
|
+
...config
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const TableRowOperations = observer(({
|
|
56
|
+
operations,
|
|
57
|
+
arrayModel,
|
|
58
|
+
itemIndex
|
|
59
|
+
}) => {
|
|
60
|
+
const {
|
|
61
|
+
isPreview
|
|
62
|
+
} = useFormEnv();
|
|
63
|
+
if (isPreview) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const delete_ = resolveOperationConfig(itemIndex, operations == null ? void 0 : operations.delete, {
|
|
67
|
+
show: false,
|
|
68
|
+
disabled: false,
|
|
69
|
+
label: "删除",
|
|
70
|
+
confirm: true
|
|
71
|
+
});
|
|
72
|
+
const move = resolveOperationConfig(itemIndex, operations == null ? void 0 : operations.move, {
|
|
73
|
+
show: false,
|
|
74
|
+
disabled: false
|
|
75
|
+
});
|
|
76
|
+
const moveUp = resolveOperationConfig(itemIndex, operations == null ? void 0 : operations.moveUp, {
|
|
77
|
+
...move,
|
|
78
|
+
label: "上移"
|
|
79
|
+
});
|
|
80
|
+
const moveDown = resolveOperationConfig(itemIndex, operations == null ? void 0 : operations.moveDown, {
|
|
81
|
+
...move,
|
|
82
|
+
label: "下移"
|
|
83
|
+
});
|
|
84
|
+
const buttons = [["moveUp", moveUp, arrayHelpers.moveUp], ["moveDown", moveDown, arrayHelpers.moveDown], ["delete", delete_, arrayHelpers.delete]];
|
|
85
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: buttons.map(([key, config, handler]) => {
|
|
86
|
+
if (!config.show) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const callback = action(() => handler(arrayModel, itemIndex));
|
|
90
|
+
if (key === "delete" && config.confirm) {
|
|
91
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Popconfirm, { title: "确定要删除么?", onConfirm: callback, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "link", disabled: config.disabled, children: config.label }) }, key);
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "link", disabled: config.disabled, onClick: callback, children: config.label }, key);
|
|
94
|
+
}) });
|
|
95
|
+
});
|
|
96
|
+
function arrayTable({
|
|
97
|
+
orderColumn,
|
|
98
|
+
style,
|
|
99
|
+
className,
|
|
100
|
+
operations,
|
|
101
|
+
operationColumn,
|
|
102
|
+
tableImplementation: Table$1 = Table,
|
|
103
|
+
tableProps
|
|
104
|
+
} = {}) {
|
|
105
|
+
return (input) => {
|
|
106
|
+
const {
|
|
107
|
+
arrayModel
|
|
108
|
+
} = input;
|
|
109
|
+
const {
|
|
110
|
+
columns,
|
|
111
|
+
dataSource
|
|
112
|
+
} = calculateArrayTableData(input);
|
|
113
|
+
const {
|
|
114
|
+
components,
|
|
115
|
+
...restTableProps
|
|
116
|
+
} = tableProps || {};
|
|
117
|
+
const enhancedColumns = enhanceTableColumns(columns, {
|
|
118
|
+
orderColumn,
|
|
119
|
+
operationColumn,
|
|
120
|
+
operations,
|
|
121
|
+
arrayModel
|
|
122
|
+
});
|
|
123
|
+
const processedDataSource = dataSource.map((item) => ({
|
|
124
|
+
...item,
|
|
125
|
+
"data-row-type": "data"
|
|
126
|
+
}));
|
|
127
|
+
const tableComponents = {
|
|
128
|
+
body: {
|
|
129
|
+
row: (props) => {
|
|
130
|
+
const record = processedDataSource.find((item) => item.rowKey === props["data-row-key"]);
|
|
131
|
+
return React.createElement(AntdTableRow, {
|
|
132
|
+
...props,
|
|
133
|
+
record,
|
|
134
|
+
"data-row-type": record ? "data" : "other"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
...components
|
|
139
|
+
};
|
|
140
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Table$1, { className, style, rowKey: "rowKey", columns: enhancedColumns, dataSource: processedDataSource, scroll: {
|
|
141
|
+
x: true
|
|
142
|
+
}, components: tableComponents, ...restTableProps });
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
arrayTable.Group = (_props) => null;
|
|
146
|
+
export {
|
|
147
|
+
TableRowOperations,
|
|
148
|
+
arrayTable
|
|
149
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import cx from "../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
|
|
4
|
+
import { arrayTable } from "../index.js";
|
|
5
|
+
import { collectNodes, isLeafNode } from "./tree-utils.js";
|
|
6
|
+
import { arrayHelpers } from "../../../../form/helpers/array-helper.js";
|
|
7
|
+
import { FormItem } from "../../../../form/form-item/index.js";
|
|
8
|
+
import { Form } from "../../../../form/form/index.js";
|
|
9
|
+
const range = (n) => {
|
|
10
|
+
const result = [];
|
|
11
|
+
for (let i = 0; i < n; i++) {
|
|
12
|
+
result.push(i);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
function extractFormItemJSXElements(node, startColIndex = 0) {
|
|
17
|
+
if (node == null) {
|
|
18
|
+
return {
|
|
19
|
+
result: [],
|
|
20
|
+
flatCount: 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (node.type == React.Fragment) {
|
|
24
|
+
return extractFormItemJSXElements(node.props.children, startColIndex);
|
|
25
|
+
}
|
|
26
|
+
let flatCount = 0;
|
|
27
|
+
const result = [];
|
|
28
|
+
const array = React.Children.toArray(node);
|
|
29
|
+
for (const item of array) {
|
|
30
|
+
if ((item == null ? void 0 : item.type) === FormItem || (item == null ? void 0 : item.type) === Form.ItemView) {
|
|
31
|
+
result.push({
|
|
32
|
+
...item,
|
|
33
|
+
colIndex: startColIndex + flatCount
|
|
34
|
+
});
|
|
35
|
+
flatCount += 1;
|
|
36
|
+
} else if ((item == null ? void 0 : item.type) === arrayTable.Group) {
|
|
37
|
+
const subRet = extractFormItemJSXElements(item.props.children, startColIndex + flatCount);
|
|
38
|
+
result.push({
|
|
39
|
+
...item,
|
|
40
|
+
children: subRet.result
|
|
41
|
+
});
|
|
42
|
+
flatCount += subRet.flatCount;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
result,
|
|
47
|
+
flatCount
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function extractFormEffectJSXElements(node) {
|
|
51
|
+
const isFormEffectJSXElement = (item) => {
|
|
52
|
+
var _a;
|
|
53
|
+
return (item == null ? void 0 : item.type) === Form.Effect || ((_a = item == null ? void 0 : item.props) == null ? void 0 : _a["x-effect"]);
|
|
54
|
+
};
|
|
55
|
+
if (node == null) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
if (node.type == React.Fragment) {
|
|
59
|
+
return React.Children.toArray(node.props.children).filter(isFormEffectJSXElement);
|
|
60
|
+
} else {
|
|
61
|
+
return React.Children.toArray(node).filter(isFormEffectJSXElement);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function extractFormCheckJSXElements(node) {
|
|
65
|
+
const isFormCheckJSXElement = (item) => (item == null ? void 0 : item.type) === Form.Check;
|
|
66
|
+
if (node == null) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
if (node.type == React.Fragment) {
|
|
70
|
+
return React.Children.toArray(node.props.children).filter(isFormCheckJSXElement);
|
|
71
|
+
} else {
|
|
72
|
+
return React.Children.toArray(node).filter(isFormCheckJSXElement);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function extractHiddenJSXElements(node) {
|
|
76
|
+
const isHiddenItemJSXElement = (item) => item.props.component === "hidden";
|
|
77
|
+
if (node == null) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
if (node.type == React.Fragment) {
|
|
81
|
+
return React.Children.toArray(node.props.children).filter(isHiddenItemJSXElement);
|
|
82
|
+
} else {
|
|
83
|
+
return React.Children.toArray(node).filter(isHiddenItemJSXElement);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function calculateArrayTableData({
|
|
87
|
+
itemContent,
|
|
88
|
+
itemCount,
|
|
89
|
+
arrayModel
|
|
90
|
+
}) {
|
|
91
|
+
const dataSource = range(itemCount).map((itemIndex) => {
|
|
92
|
+
const renderedContent = itemContent(itemIndex, arrayModel.getSubModel(itemIndex));
|
|
93
|
+
const formItems = extractFormItemJSXElements(renderedContent).result;
|
|
94
|
+
const flattenFormItems = collectNodes(formItems, "leaf-only");
|
|
95
|
+
const effects = extractFormEffectJSXElements(renderedContent);
|
|
96
|
+
const checks = extractFormCheckJSXElements(renderedContent);
|
|
97
|
+
const hiddenItems = extractHiddenJSXElements(renderedContent);
|
|
98
|
+
return {
|
|
99
|
+
rowKey: arrayHelpers.getKey(arrayModel, itemIndex),
|
|
100
|
+
itemIndex,
|
|
101
|
+
formItems,
|
|
102
|
+
flattenFormItems,
|
|
103
|
+
effects,
|
|
104
|
+
checks,
|
|
105
|
+
hiddenItems
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
let columnsShape;
|
|
109
|
+
if (dataSource.length > 0) {
|
|
110
|
+
columnsShape = dataSource[0].formItems;
|
|
111
|
+
} else {
|
|
112
|
+
columnsShape = extractFormItemJSXElements(itemContent(0, arrayModel.getSubModel(0))).result;
|
|
113
|
+
}
|
|
114
|
+
function convertColumn(item) {
|
|
115
|
+
if (item.props.component === "hidden") {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
// Antd Table列定义
|
|
120
|
+
key: `col_${item.colIndex}`,
|
|
121
|
+
dataIndex: `col_${item.colIndex}`,
|
|
122
|
+
render: (value, record) => {
|
|
123
|
+
const formItem = record.flattenFormItems[item.colIndex];
|
|
124
|
+
return React.cloneElement(formItem, {
|
|
125
|
+
className: cx(formItem.className, "minimal")
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
title: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
129
|
+
(item.props.asterisk ?? item.props.required) && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "required-indicator" }),
|
|
130
|
+
item.props.label
|
|
131
|
+
] }),
|
|
132
|
+
width: item.props.width,
|
|
133
|
+
fixed: item.props.lock ? "left" : void 0,
|
|
134
|
+
align: item.props.align,
|
|
135
|
+
...item.props["x-column"] ?? item.props["x-table-column"]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function convertGroup(group) {
|
|
139
|
+
return {
|
|
140
|
+
key: group.props.name,
|
|
141
|
+
title: group.props.label || group.props.name,
|
|
142
|
+
children: convert(group.children),
|
|
143
|
+
width: group.props.width,
|
|
144
|
+
fixed: group.props.lock ? "left" : void 0,
|
|
145
|
+
align: group.props.align,
|
|
146
|
+
...group.props["x-column"] ?? group.props["x-table-column"]
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const convert = (nodes) => {
|
|
150
|
+
return nodes.map((n) => isLeafNode(n) ? convertColumn(n) : convertGroup(n)).filter(Boolean);
|
|
151
|
+
};
|
|
152
|
+
const columns = convert(columnsShape);
|
|
153
|
+
return {
|
|
154
|
+
dataSource,
|
|
155
|
+
columns
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
calculateArrayTableData
|
|
160
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建序号列配置
|
|
3
|
+
*/
|
|
4
|
+
export declare function createOrderColumn(orderColumn: any): any;
|
|
5
|
+
/**
|
|
6
|
+
* 创建操作列配置
|
|
7
|
+
*/
|
|
8
|
+
export declare function createOperationColumn(operationColumn: any, operations: any, arrayModel: any): any;
|
|
9
|
+
/**
|
|
10
|
+
* 增强表格列配置 - 添加序号列和操作列
|
|
11
|
+
*/
|
|
12
|
+
export declare function enhanceTableColumns(originalColumns: any[], options: {
|
|
13
|
+
orderColumn?: any;
|
|
14
|
+
operationColumn?: any;
|
|
15
|
+
operations?: any;
|
|
16
|
+
arrayModel: any;
|
|
17
|
+
}): any[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { TableRowOperations } from "../index.js";
|
|
3
|
+
function createOrderColumn(orderColumn) {
|
|
4
|
+
if (!orderColumn) return null;
|
|
5
|
+
return {
|
|
6
|
+
key: "order",
|
|
7
|
+
title: "#",
|
|
8
|
+
width: 50,
|
|
9
|
+
fixed: "left",
|
|
10
|
+
align: "right",
|
|
11
|
+
...orderColumn,
|
|
12
|
+
render: (_, record) => {
|
|
13
|
+
return record.itemIndex + 1;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function createOperationColumn(operationColumn, operations, arrayModel) {
|
|
18
|
+
if (!operationColumn && !operations) return null;
|
|
19
|
+
return {
|
|
20
|
+
key: "operations",
|
|
21
|
+
title: "",
|
|
22
|
+
width: 120,
|
|
23
|
+
fixed: "right",
|
|
24
|
+
...operationColumn,
|
|
25
|
+
render: (_, record) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: {
|
|
26
|
+
padding: "8px"
|
|
27
|
+
}, children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableRowOperations, { arrayModel, itemIndex: record.itemIndex, operations }) })
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function enhanceTableColumns(originalColumns, options) {
|
|
31
|
+
const {
|
|
32
|
+
orderColumn,
|
|
33
|
+
operationColumn,
|
|
34
|
+
operations,
|
|
35
|
+
arrayModel
|
|
36
|
+
} = options;
|
|
37
|
+
const enhancedColumns = [...originalColumns];
|
|
38
|
+
const orderCol = createOrderColumn(orderColumn);
|
|
39
|
+
if (orderCol) {
|
|
40
|
+
enhancedColumns.unshift(orderCol);
|
|
41
|
+
}
|
|
42
|
+
const operationCol = createOperationColumn(operationColumn, operations, arrayModel);
|
|
43
|
+
if (operationCol) {
|
|
44
|
+
enhancedColumns.push(operationCol);
|
|
45
|
+
}
|
|
46
|
+
return enhancedColumns;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
createOperationColumn,
|
|
50
|
+
createOrderColumn,
|
|
51
|
+
enhanceTableColumns
|
|
52
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface AbstractTreeNode {
|
|
2
|
+
children?: AbstractTreeNode[];
|
|
3
|
+
}
|
|
4
|
+
/** 判断是否为叶子节点 */
|
|
5
|
+
export declare function isLeafNode<T extends AbstractTreeNode>(node: T): boolean;
|
|
6
|
+
/** 遍历所有节点,并将节点收集到一个数组中 */
|
|
7
|
+
export declare function collectNodes<T extends AbstractTreeNode>(nodes: T[], order?: 'pre' | 'post' | 'leaf-only'): T[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function isLeafNode(node) {
|
|
2
|
+
return !node.children || node.children.length === 0;
|
|
3
|
+
}
|
|
4
|
+
function collectNodes(nodes, order = "pre") {
|
|
5
|
+
const result = [];
|
|
6
|
+
function dfs(nodes2) {
|
|
7
|
+
if (!nodes2) return;
|
|
8
|
+
for (const node of nodes2) {
|
|
9
|
+
if (isLeafNode(node)) {
|
|
10
|
+
result.push(node);
|
|
11
|
+
} else {
|
|
12
|
+
if (order === "pre") {
|
|
13
|
+
result.push(node);
|
|
14
|
+
dfs(node.children);
|
|
15
|
+
} else if (order === "post") {
|
|
16
|
+
dfs(node.children);
|
|
17
|
+
result.push(node);
|
|
18
|
+
} else {
|
|
19
|
+
dfs(node.children);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
dfs(nodes);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
collectNodes,
|
|
29
|
+
isLeafNode
|
|
30
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { FormEnvProvider, useFormEnv } from './form/context/formEnvContext';
|
|
4
|
-
import { FormItem, createFormItem } from './form/form-item';
|
|
5
|
-
import { FormModel } from './form/model';
|
|
6
|
-
import { arrayHelpers } from './form/array-helper';
|
|
7
|
-
import { AsyncValue } from './form/helpers/AsyncValue';
|
|
8
|
-
import { modelUtils } from './form/model-utils';
|
|
9
|
-
export { Form, FormEnvProvider, useFormEnv, useModel, FormItem, createFormItem, FormModel, arrayHelpers, AsyncValue, modelUtils, };
|
|
1
|
+
export * from './form';
|
|
2
|
+
export * from './form-ui';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Form } from "./form/index.js";
|
|
1
|
+
import { Form } from "./form/form/index.js";
|
|
2
2
|
import { useModel } from "./form/context/modelContext.js";
|
|
3
3
|
import { FormEnvProvider, useFormEnv } from "./form/context/formEnvContext.js";
|
|
4
|
-
import { FormItem, createFormItem } from "./form/form-item.js";
|
|
5
|
-
import { FormModel } from "./form/model.js";
|
|
6
|
-
import { arrayHelpers } from "./form/array-helper.js";
|
|
4
|
+
import { FormItem, createFormItem } from "./form/form-item/index.js";
|
|
5
|
+
import { FormModel } from "./form/model/model.js";
|
|
6
|
+
import { arrayHelpers } from "./form/helpers/array-helper.js";
|
|
7
7
|
import { AsyncValue } from "./form/helpers/AsyncValue.js";
|
|
8
|
-
import { modelUtils } from "./form/model-utils.js";
|
|
8
|
+
import { modelUtils } from "./form/model/model-utils.js";
|
|
9
|
+
import { arrayTable } from "./form-ui/extend/array-table/index.js";
|
|
9
10
|
export {
|
|
10
11
|
AsyncValue,
|
|
11
12
|
Form,
|
|
@@ -13,6 +14,7 @@ export {
|
|
|
13
14
|
FormItem,
|
|
14
15
|
FormModel,
|
|
15
16
|
arrayHelpers,
|
|
17
|
+
arrayTable,
|
|
16
18
|
createFormItem,
|
|
17
19
|
modelUtils,
|
|
18
20
|
useFormEnv,
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|