react-antd-xform 1.0.10 → 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/form/index.js +47 -0
- 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} +3 -2
- package/dist/form/{model.js → model/model.js} +4 -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} +20 -20
- package/dist/form-ui/{render-preview.d.ts → default-components/utils/render-preview.d.ts} +19 -19
- package/dist/form-ui/default-components/utils/render-preview.js +97 -0
- 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/index.js +0 -45
- package/dist/form-ui/render-preview.js +0 -116
- /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/{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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { useState } from "react";
|
|
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
|
+
function Form({
|
|
17
|
+
model: modelProp,
|
|
18
|
+
defaultValue,
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
style,
|
|
22
|
+
layout,
|
|
23
|
+
containerProps,
|
|
24
|
+
htmlIdPrefix: htmlIdPrefixProp,
|
|
25
|
+
variant,
|
|
26
|
+
isPreview,
|
|
27
|
+
...restEnvProps
|
|
28
|
+
}) {
|
|
29
|
+
const [_model] = useState(() => new FormModel(defaultValue));
|
|
30
|
+
const model = composeValue(modelProp, _model);
|
|
31
|
+
model.isPreview = isPreview;
|
|
32
|
+
const htmlIdPrefix = useHtmlIdPrefix(htmlIdPrefixProp);
|
|
33
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormEnvProvider, { htmlIdPrefix, variant, ...restEnvProps, isPreview, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ModelProvider, { value: model, children: /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { style, className, containerProps, ...layout, children }) }) });
|
|
34
|
+
}
|
|
35
|
+
Form.Array = FormArray;
|
|
36
|
+
Form.Check = FormCheck;
|
|
37
|
+
Form.Effect = FormEffect;
|
|
38
|
+
Form.Object = FormObject;
|
|
39
|
+
Form.Submit = FormSubmit;
|
|
40
|
+
Form.Layout = FormLayout;
|
|
41
|
+
Form.ItemView = FormItemView;
|
|
42
|
+
Form.ModelProvider = ModelProvider;
|
|
43
|
+
Form.ModelConsumer = FormModelConsumer;
|
|
44
|
+
Form.Reset = FormReset;
|
|
45
|
+
export {
|
|
46
|
+
Form
|
|
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;
|
|
@@ -16,6 +16,7 @@ export declare class FormModel<D extends {
|
|
|
16
16
|
readonly root: FormModel<any>;
|
|
17
17
|
readonly parent: FormModel<any>;
|
|
18
18
|
name: string;
|
|
19
|
+
isPreview: boolean;
|
|
19
20
|
/** 当前 Model 的类型,目前只有两种类型: rootModel 和 subModel */
|
|
20
21
|
_modelType: ModelType;
|
|
21
22
|
_values: D;
|
|
@@ -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
|
|
@@ -18,6 +18,7 @@ class IdGenerator {
|
|
|
18
18
|
class FormModel {
|
|
19
19
|
constructor(initValues, options = ROOT_MODEL_CREATE_OPTIONS) {
|
|
20
20
|
this.state = {};
|
|
21
|
+
this.isPreview = false;
|
|
21
22
|
this._fieldMap = /* @__PURE__ */ new Map();
|
|
22
23
|
this._valueShape = "auto";
|
|
23
24
|
this._checkMap = /* @__PURE__ */ new Map();
|
|
@@ -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 {
|
|
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,
|
|
@@ -40,82 +40,82 @@ const DEFAULT_VALUES = {
|
|
|
40
40
|
const COMPONENT_RULES = {
|
|
41
41
|
input: {
|
|
42
42
|
hocs: ["valueChange"],
|
|
43
|
-
renderPreview:
|
|
43
|
+
renderPreview: renderValueToPreview,
|
|
44
44
|
hasIntrinsicWidth: false
|
|
45
45
|
},
|
|
46
46
|
textArea: {
|
|
47
47
|
hocs: ["valueChange"],
|
|
48
|
-
renderPreview:
|
|
48
|
+
renderPreview: renderValueToPreview,
|
|
49
49
|
hasIntrinsicWidth: true
|
|
50
50
|
},
|
|
51
51
|
select: {
|
|
52
52
|
hocs: [],
|
|
53
|
-
renderPreview:
|
|
53
|
+
renderPreview: renderSelectToPreview,
|
|
54
54
|
hasIntrinsicWidth: true
|
|
55
55
|
},
|
|
56
56
|
singleSelect: {
|
|
57
57
|
hocs: [],
|
|
58
|
-
renderPreview:
|
|
58
|
+
renderPreview: renderSelectToPreview,
|
|
59
59
|
hasIntrinsicWidth: true
|
|
60
60
|
},
|
|
61
61
|
multiSelect: {
|
|
62
62
|
hocs: ["multiSelect"],
|
|
63
|
-
renderPreview:
|
|
63
|
+
renderPreview: renderSelectToPreview,
|
|
64
64
|
hasIntrinsicWidth: true
|
|
65
65
|
},
|
|
66
66
|
radio: {
|
|
67
67
|
hocs: ["valueChange"],
|
|
68
|
-
renderPreview:
|
|
68
|
+
renderPreview: renderValueToPreview,
|
|
69
69
|
hasIntrinsicWidth: false
|
|
70
70
|
},
|
|
71
71
|
checkbox: {
|
|
72
72
|
hocs: [],
|
|
73
|
-
renderPreview:
|
|
73
|
+
renderPreview: renderMultiplePreview,
|
|
74
74
|
hasIntrinsicWidth: false
|
|
75
75
|
},
|
|
76
76
|
inputNumber: {
|
|
77
77
|
hocs: ["valueChange"],
|
|
78
|
-
renderPreview:
|
|
78
|
+
renderPreview: renderValueToPreview,
|
|
79
79
|
hasIntrinsicWidth: false
|
|
80
80
|
},
|
|
81
81
|
slider: {
|
|
82
|
-
hocs: [
|
|
83
|
-
renderPreview:
|
|
82
|
+
hocs: [],
|
|
83
|
+
renderPreview: renderValueToPreview,
|
|
84
84
|
hasIntrinsicWidth: false
|
|
85
85
|
},
|
|
86
86
|
switch: {
|
|
87
87
|
hocs: ["valueChange"],
|
|
88
|
-
renderPreview:
|
|
88
|
+
renderPreview: renderBooleanPreview,
|
|
89
89
|
hasIntrinsicWidth: false
|
|
90
90
|
},
|
|
91
91
|
datePicker: {
|
|
92
92
|
hocs: ["dayjsDate"],
|
|
93
|
-
renderPreview:
|
|
93
|
+
renderPreview: renderDatePreview,
|
|
94
94
|
hasIntrinsicWidth: true
|
|
95
95
|
},
|
|
96
96
|
dateRangePicker: {
|
|
97
97
|
hocs: ["dayjsDateRange"],
|
|
98
|
-
renderPreview:
|
|
98
|
+
renderPreview: renderDateRangePreview,
|
|
99
99
|
hasIntrinsicWidth: true
|
|
100
100
|
},
|
|
101
101
|
timePicker: {
|
|
102
102
|
hocs: ["dayjsTime"],
|
|
103
|
-
renderPreview:
|
|
103
|
+
renderPreview: renderTimePreview,
|
|
104
104
|
hasIntrinsicWidth: true
|
|
105
105
|
},
|
|
106
106
|
timeRangePicker: {
|
|
107
107
|
hocs: ["dayjsTimeRange"],
|
|
108
|
-
renderPreview:
|
|
108
|
+
renderPreview: renderTimeRangePreview,
|
|
109
109
|
hasIntrinsicWidth: true
|
|
110
110
|
},
|
|
111
111
|
rate: {
|
|
112
112
|
hocs: [],
|
|
113
|
-
renderPreview:
|
|
113
|
+
renderPreview: renderRatePreview,
|
|
114
114
|
hasIntrinsicWidth: false
|
|
115
115
|
},
|
|
116
116
|
colorPicker: {
|
|
117
117
|
hocs: ["colorPicker"],
|
|
118
|
-
renderPreview:
|
|
118
|
+
renderPreview: renderColorPreview,
|
|
119
119
|
hasIntrinsicWidth: false
|
|
120
120
|
}
|
|
121
121
|
};
|