diff --git a/packages/fieldy/fieldy-react/package.json b/packages/fieldy/fieldy-react/package.json index ac02c3c12..ea2237dac 100644 --- a/packages/fieldy/fieldy-react/package.json +++ b/packages/fieldy/fieldy-react/package.json @@ -1,6 +1,6 @@ { "name": "@rxdrag/react-fieldy", - "version": "0.6.2", + "version": "0.6.5", "type": "module", "module": "index.ts", "files": [ @@ -18,11 +18,11 @@ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" }, "devDependencies": { + "@rxdrag/eslint-config-custom": "workspace:*", + "@rxdrag/tsconfig": "workspace:*", "@types/react": "^18.2.22", "@types/react-dom": "^18.2.7", - "eslint": "^7.32.0", - "@rxdrag/eslint-config-custom": "workspace:*", - "@rxdrag/tsconfig": "workspace:*" + "eslint": "^7.32.0" }, "peerDependencies": { "react": "^18.2.0", @@ -33,9 +33,9 @@ "dependencies": { "@reduxjs/toolkit": "^1.9.3", "@rxdrag/fieldy": "workspace:*", + "@rxdrag/fieldy-yup-validation": "workspace:*", "@rxdrag/react-shared": "workspace:*", "@rxdrag/shared": "workspace:*", - "@rxdrag/fieldy-yup-validation": "workspace:*", "@types/react": "^18.2.22", "@types/react-dom": "^18.2.7", "lodash": "^4.17.21", diff --git a/packages/fieldy/fieldy-react/src/components/ArrayField/ArrayField.tsx b/packages/fieldy/fieldy-react/src/components/ArrayField/ArrayField.tsx index 385a1511b..22064d35e 100644 --- a/packages/fieldy/fieldy-react/src/components/ArrayField/ArrayField.tsx +++ b/packages/fieldy/fieldy-react/src/components/ArrayField/ArrayField.tsx @@ -1,9 +1,8 @@ import React from "react" -import { memo } from "react" import { Field } from "../Field" //动态增加字段用这个,否则不要碰它 -export const ArrayField = memo(( +export const ArrayField = ( props: { name: string, value?: unknown[], @@ -20,4 +19,4 @@ export const ArrayField = memo(( ) -}) \ No newline at end of file +} \ No newline at end of file diff --git a/packages/fieldy/fieldy-react/src/components/Field/index.tsx b/packages/fieldy/fieldy-react/src/components/Field/index.tsx index e5e28dced..2bbb602e7 100644 --- a/packages/fieldy/fieldy-react/src/components/Field/index.tsx +++ b/packages/fieldy/fieldy-react/src/components/Field/index.tsx @@ -1,11 +1,11 @@ import React from "react" -import { memo } from "react" import { XField } from "../XField" import { useCreateFieldSchema } from "../XField/hooks/useCreateFieldSchema" import { FieldType } from "@rxdrag/fieldy" +import { IYupValidateSchema } from "@rxdrag/fieldy-yup-validation" //动态增加字段用这个,否则不要碰它 -export const Field = memo(( +export const Field = ( props: { //数组时会使用number name: string | number, @@ -14,13 +14,16 @@ export const Field = memo(( defaultValue?: unknown, children?: React.ReactNode, type?: FieldType, + rules?: IYupValidateSchema, } ) => { - const { name, value, initialValue, defaultValue, children, type } = props + const { name, value, initialValue, defaultValue, children, type, rules } = props const fieldMeta = useCreateFieldSchema(name, type) + fieldMeta.validateRules = rules + return ( {children} ) -}) \ No newline at end of file +} \ No newline at end of file diff --git a/packages/fieldy/fieldy-react/src/components/ObjectField/index.tsx b/packages/fieldy/fieldy-react/src/components/ObjectField/index.tsx index b8d99f872..055ba41ad 100644 --- a/packages/fieldy/fieldy-react/src/components/ObjectField/index.tsx +++ b/packages/fieldy/fieldy-react/src/components/ObjectField/index.tsx @@ -1,8 +1,8 @@ -import React, { memo } from "react" +import React from "react" import { Field } from "../Field" //动态增加字段用这个,否则不要碰它 -export const ObjectField = memo(( +export const ObjectField = ( props: { name: string | number, initialValue?: unknown, @@ -18,4 +18,4 @@ export const ObjectField = memo(( {children} ) -}) +} diff --git a/packages/fieldy/fieldy/src/classes/FieldImpl.ts b/packages/fieldy/fieldy/src/classes/FieldImpl.ts index b89f5c040..4bac3adea 100644 --- a/packages/fieldy/fieldy/src/classes/FieldImpl.ts +++ b/packages/fieldy/fieldy/src/classes/FieldImpl.ts @@ -1,4 +1,4 @@ -import { ErrorListener, FieldState, IField, IFieldSchema, IFieldyEngine, IForm, Listener, SuccessListener, Unsubscribe, ValidateResult, ValidateStatus, ValueChangeListener } from "../interfaces/fieldy"; +import { ErrorListener, FieldState, IField, IFieldSchema, IFieldyEngine, IForm, Listener, SuccessListener, Unsubscribe, ValidateStatus, ValueChangeListener } from "../interfaces/fieldy"; import { PropExpression } from "./PropExpression"; import { ValidationSubscriber } from "./ValidationSubscriber"; import { IValidateSchema, IValidationError } from "../interfaces";