@formvk/react 0.1.0 → 1.0.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/CHANGELOG.md +16 -0
- package/README.md +60 -0
- package/dist/index.js +91 -295
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
- package/src/__tests__/expression.spec.tsx +0 -87
- package/src/__tests__/form.spec.tsx +0 -164
- package/src/__tests__/hooks.spec.tsx +0 -198
- package/src/__tests__/render.spec.tsx +0 -704
- package/src/__tests__/schema.spec.tsx +0 -598
- package/src/__tests__/shared.tsx +0 -44
- package/src/components/ExpressionScope.tsx +0 -16
- package/src/components/FormConsumer.tsx +0 -20
- package/src/components/FormProvider.tsx +0 -35
- package/src/components/ReactiveField.tsx +0 -161
- package/src/components/RecursionField.tsx +0 -113
- package/src/components/SchemaField.tsx +0 -195
- package/src/components/index.ts +0 -7
- package/src/hooks/index.ts +0 -6
- package/src/hooks/useAttach.ts +0 -20
- package/src/hooks/useField.ts +0 -8
- package/src/hooks/useFieldSchema.ts +0 -8
- package/src/hooks/useForm.ts +0 -8
- package/src/hooks/useFormEffects.ts +0 -19
- package/src/hooks/useParentForm.ts +0 -18
- package/src/index.ts +0 -5
- package/src/shared/connect.tsx +0 -72
- package/src/shared/context.ts +0 -15
- package/src/shared/createForm.ts +0 -10
- package/src/shared/index.ts +0 -2
- package/src/types/index.ts +0 -144
- package/src/utils/getRawComponent.ts +0 -12
- package/src/utils/slots.ts +0 -9
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -7
- package/vite.config.ts +0 -32
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createCoreForm","createForm$1","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__commonJSMin","mod","cb","__copyProps","from","keys","i","n","key","to","except","k","desc","__toESM","isNodeMode","target","FormContext","createContext","FieldContext","SchemaContext","SchemaExpressionScopeContext","SchemaOptionsContext","ExpressionScope","parentScope","useContext","merged","useMemo","lazyMerge","props","useForm","FormConsumer","observer","form","children","useAttach","useEffect","FormProvider","useField","getRawComponent","isStr","component","FormPath","components","toArray","value","isReactComponentLike","isFn","renderContent","isValidElement","content","createElement","mergeSlots","result","slots","appendToSlot","rendered","origin","name","each","normalizeProps","events","eventName","toReactEventProps","handler","ReactiveField","parent","options","incomingSlots","field","factoryProps","fieldProps","fieldType","mergedSlots","renderDecorator","inner","Decorator","decoratorProps","toJS","renderComponent","Component","originProps","originChange","originFocus","originBlur","args","isVoidField","componentProps","slotChildren","resolveEmptySlot","names","RecursionField","scope","fieldSchema","Schema","getBasePath","isValid","basePath","generateSlots","properties","renderMap","mapProperties","filterProperties","item","itemSchema","mapped","slotName","node","index","withSchema","commonFieldProps","joinPath","prefix","segment","collectSchemaPaths","fields","arrays","walkNode","path","walkChildren","items","rootPath","schema","toSchema","applyHotReload","prevPaths","prev","nextPaths","next","nextFields","pattern","SchemaField","reloadVersion","setReloadVersion","useState","prevSchemaRef","useRef","useLayoutEffect","version","createSchemaField","voidComponents","factoryOptions","arrayComponents","flatComponents","fragment","createFragment","prebound","BoundSchemaField","useFieldSchema","useFormEffects","effects","id","uid","useParentForm","findObjectParent","isObjectField","require_react_is_production_min","b","c","d","e","f","g","h","m","p","q","r","t","v","w","x","z","a","u","A","require_react_is_development","hasSymbol","REACT_ELEMENT_TYPE","REACT_PORTAL_TYPE","REACT_FRAGMENT_TYPE","REACT_STRICT_MODE_TYPE","REACT_PROFILER_TYPE","REACT_PROVIDER_TYPE","REACT_CONTEXT_TYPE","REACT_ASYNC_MODE_TYPE","REACT_CONCURRENT_MODE_TYPE","REACT_FORWARD_REF_TYPE","REACT_SUSPENSE_TYPE","REACT_SUSPENSE_LIST_TYPE","REACT_MEMO_TYPE","REACT_LAZY_TYPE","REACT_BLOCK_TYPE","REACT_FUNDAMENTAL_TYPE","REACT_RESPONDER_TYPE","REACT_SCOPE_TYPE","isValidElementType","type","typeOf","object","$$typeof","$$typeofType","AsyncMode","ConcurrentMode","ContextConsumer","ContextProvider","Element","ForwardRef","Fragment","Lazy","Memo","Portal","Profiler","StrictMode","Suspense","hasWarnedAboutDeprecatedIsAsyncMode","isAsyncMode","\"warn\"","isConcurrentMode","isContextConsumer","isContextProvider","isElement","isForwardRef","isFragment","isLazy","isMemo","isPortal","isProfiler","isStrictMode","isSuspense","require_react_is","module","import_hoist_non_react_statics_cjs","reactIs","REACT_STATICS","KNOWN_STATICS","FORWARD_REF_STATICS","\"$$typeof\"","MEMO_STATICS","TYPE_STATICS","getStatics","defineProperty","getOwnPropertyNames","getOwnPropertySymbols","getOwnPropertyDescriptor","getPrototypeOf","objectPrototype","hoistNonReactStatics","sourceComponent","inheritedComponent","targetComponent","blacklist","targetStatics","sourceStatics","descriptor","getComponentName","mapProps","transform","mapper","extractValue","extract","targetValue","originalValue","input","Connected","nextProps","mapReadPretty","Read","Current","readPrettyProps","connect","current","createForm"],"sources":["../src/shared/context.ts","../src/components/ExpressionScope.tsx","../src/hooks/useForm.ts","../src/components/FormConsumer.tsx","../src/hooks/useAttach.ts","../src/components/FormProvider.tsx","../src/hooks/useField.ts","../src/utils/getRawComponent.ts","../src/utils/slots.ts","../src/components/ReactiveField.tsx","../src/components/RecursionField.tsx","../src/components/SchemaField.tsx","../src/hooks/useFieldSchema.ts","../src/hooks/useFormEffects.ts","../src/hooks/useParentForm.ts","../../../node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js","../../../node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js","../../../node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js","../../../node_modules/.pnpm/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js","../src/shared/connect.tsx","../src/shared/createForm.ts"],"sourcesContent":["import type { Form, GeneralField } from '@formvk/core'\nimport type { Schema } from '@formvk/schema'\nimport { createContext } from 'react'\n\nimport type { ISchemaFieldRuntimeOptions } from '../types'\n\nexport const FormContext = createContext<Form | undefined>(undefined)\n\nexport const FieldContext = createContext<GeneralField | undefined>(undefined)\n\nexport const SchemaContext = createContext<Schema | undefined>(undefined)\n\nexport const SchemaExpressionScopeContext = createContext<Record<string, any> | undefined>(undefined)\n\nexport const SchemaOptionsContext = createContext<ISchemaFieldRuntimeOptions | undefined>(undefined)\n","import { lazyMerge } from '@formvk/shared'\nimport { useContext, useMemo } from 'react'\nimport type { PropsWithChildren } from 'react'\n\nimport { SchemaExpressionScopeContext } from '../shared/context'\nimport type { IExpressionScopeProps } from '../types'\n\n/** 表达式作用域:与外层 scope 惰性合并,内层同名变量优先,Provider 天然隔离兄弟分支。 */\nexport function ExpressionScope(props: PropsWithChildren<IExpressionScopeProps>) {\n const parentScope = useContext(SchemaExpressionScopeContext)\n const merged = useMemo(() => lazyMerge(parentScope ?? {}, props.value), [parentScope, props.value])\n\n return <SchemaExpressionScopeContext.Provider value={merged}>{props.children}</SchemaExpressionScopeContext.Provider>\n}\n\nExpressionScope.displayName = 'ExpressionScope'\n","import type { Form } from '@formvk/core'\nimport { useContext } from 'react'\n\nimport { FormContext } from '../shared/context'\n\nexport function useForm(): Form | undefined {\n return useContext(FormContext)\n}\n","import type { Form } from '@formvk/core'\nimport { observer } from '@formvk/reactive-react'\nimport type { ReactNode } from 'react'\n\nimport { useForm } from '../hooks/useForm'\nimport type { IFormConsumerRenderProps } from '../types'\n\nexport interface IFormConsumerProps {\n children?: (renderProps: IFormConsumerRenderProps) => ReactNode\n}\n\n/** render props 形式读取 form,内部由 observer 追踪响应式状态,form 变化后自动刷新。 */\nexport const FormConsumer = observer((props: IFormConsumerProps) => {\n const form = useForm()\n const { children } = props\n if (typeof children !== 'function') return null\n return children({ form: form as Form })\n})\n\nFormConsumer.displayName = 'FormConsumer'\n","import { useEffect } from 'react'\n\ninterface IRecycleTarget {\n onMount: () => void\n onUnmount: () => void\n}\n\n/**\n * 把字段生命周期挂到 React 组件生命周期上:\n * target 变化时旧实例 onUnmount、新实例 onMount,组件卸载时清理当前实例。\n */\nexport function useAttach<T extends IRecycleTarget>(target: T | undefined): T | undefined {\n useEffect(() => {\n target?.onMount()\n return () => {\n target?.onUnmount()\n }\n }, [target])\n return target\n}\n","import type { PropsWithChildren } from 'react'\n\nimport { useAttach } from '../hooks/useAttach'\nimport {\n FieldContext,\n FormContext,\n SchemaContext,\n SchemaExpressionScopeContext,\n SchemaOptionsContext,\n} from '../shared/context'\nimport type { IProviderProps } from '../types'\n\n/**\n * 挂载表单生命周期并注入 FormContext。\n * 同时把字段 / schema / scope / options 四个上下文重置为空,\n * 等价于 Vue 侧 useInjectionCleaner 的隔离效果,嵌套 FormProvider 不会串层。\n */\nexport function FormProvider(props: PropsWithChildren<IProviderProps>) {\n const { form, children } = props\n useAttach(form)\n\n return (\n <FormContext.Provider value={form}>\n <FieldContext.Provider value={undefined}>\n <SchemaContext.Provider value={undefined}>\n <SchemaExpressionScopeContext.Provider value={undefined}>\n <SchemaOptionsContext.Provider value={undefined}>{children}</SchemaOptionsContext.Provider>\n </SchemaExpressionScopeContext.Provider>\n </SchemaContext.Provider>\n </FieldContext.Provider>\n </FormContext.Provider>\n )\n}\n\nFormProvider.displayName = 'FormProvider'\n","import type { GeneralField } from '@formvk/core'\nimport { useContext } from 'react'\n\nimport { FieldContext } from '../shared/context'\n\nexport function useField<T = GeneralField>(): T | undefined {\n return useContext(FieldContext) as T | undefined\n}\n","import { FormPath, isStr } from '@formvk/shared'\n\n/**\n * 解析 schema 中的组件描述:字符串按路径从 components 中查找,组件类型直接使用。\n * React 侧不存在响应式代理包裹,无需 toRaw。\n */\nexport function getRawComponent(components: Record<string, any> | undefined, component: any): any {\n if (isStr(component)) {\n return FormPath.getIn(components, component) ?? component\n }\n return component\n}\n","import type { ReactNode } from 'react'\n\n/** 具名插槽映射,default 为默认插槽,对应 Vue 侧的 slots 对象。 */\nexport type SlotMap = Record<string, ReactNode>\n\nexport function toArray(value: ReactNode): ReactNode[] {\n if (Array.isArray(value)) return value\n return value === undefined || value === null ? [] : [value]\n}\n","import { isVoidField } from '@formvk/core'\nimport type { GeneralField, IFieldFactoryProps } from '@formvk/core'\nimport { toJS } from '@formvk/reactive'\nimport { observer } from '@formvk/reactive-react'\nimport { each, isFn, isStr } from '@formvk/shared'\nimport { createElement, isValidElement, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\n\nimport { useAttach } from '../hooks/useAttach'\nimport { useField } from '../hooks/useField'\nimport { useForm } from '../hooks/useForm'\nimport { FieldContext, SchemaOptionsContext } from '../shared/context'\nimport type { IReactiveFieldProps, ISchemaFieldRuntimeOptions } from '../types'\nimport { getRawComponent } from '../utils/getRawComponent'\nimport { toArray } from '../utils/slots'\nimport type { SlotMap } from '../utils/slots'\n\nfunction isReactComponentLike(value: any): boolean {\n if (!value) return false\n if (isFn(value)) return true\n return typeof value === 'object' && ('$$typeof' in value || isFn(value.render))\n}\n\nfunction renderContent(content: any): ReactNode {\n if (isValidElement(content) || isStr(content)) return content\n if (isReactComponentLike(content)) return createElement(content)\n return content\n}\n\n/** 合并 RecursionField 生成的具名插槽与 schema 上的 content 声明。 */\nfunction mergeSlots(slots: SlotMap, content: any): SlotMap {\n const result: SlotMap = { ...slots }\n\n if (!content) return result\n\n function appendToSlot(name: string, value: any) {\n const rendered = renderContent(value)\n const origin = result[name]\n result[name] = origin === undefined ? rendered : ([] as ReactNode[]).concat(toArray(origin), toArray(rendered))\n }\n\n if (isStr(content) || isValidElement(content) || isReactComponentLike(content)) {\n appendToSlot('default', content)\n } else if (typeof content === 'object') {\n // 普通对象视为具名插槽内容映射\n each(content, (value, key) => {\n appendToSlot(key, value)\n })\n }\n\n return result\n}\n\nfunction normalizeProps(origin: Record<string, any>) {\n const props: Record<string, any> = {}\n const events: Record<string, any> = {}\n each(origin, (value, key) => {\n if (key.startsWith('on')) {\n const eventName = `${key[2].toLowerCase()}${key.slice(3)}`\n events[eventName] = events[eventName] ?? value\n } else if (key.startsWith('@')) {\n events[key.slice(1)] = value\n } else {\n props[key] = value\n }\n })\n return { props, events }\n}\n\nfunction toReactEventProps(events: Record<string, any>) {\n const props: Record<string, any> = {}\n each(events, (handler, name) => {\n props[`on${name.charAt(0).toUpperCase()}${name.slice(1)}`] = handler\n })\n return props\n}\n\nexport const ReactiveField = observer((props: IReactiveFieldProps) => {\n const form = useForm()\n const parent = useField()\n const options = useContext(SchemaOptionsContext) as ISchemaFieldRuntimeOptions | undefined\n\n const { fieldType = 'Field', fieldProps, slots: incomingSlots, children } = props\n\n // 与 Vue 侧 watch(fieldProps) 重建对齐:fieldProps 引用变化即创建新字段,旧实例由 useAttach 卸载\n const field = useMemo(() => {\n const factoryProps = (fieldProps ?? {}) as IFieldFactoryProps<any, any>\n return (form as any)?.[`create${fieldType}`]?.({\n ...factoryProps,\n basePath: factoryProps.basePath ?? parent?.address,\n }) as GeneralField | undefined\n }, [form, fieldType, fieldProps, parent])\n\n useAttach(field)\n\n let content: ReactNode = null\n\n if (!field) {\n content = children ?? null\n } else if (field.display !== 'visible') {\n content = null\n } else {\n const mergedSlots = mergeSlots(incomingSlots ?? {}, field.content)\n\n function renderDecorator(inner: ReactNode) {\n if (!field!.decoratorType) return inner\n const Decorator = getRawComponent(options?.components, field!.decoratorType)\n const { props: decoratorProps, events } = normalizeProps(toJS((field!.decorator as any)[1]) || {})\n return createElement(Decorator, { ...decoratorProps, ...toReactEventProps(events) }, inner)\n }\n\n function renderComponent(): ReactNode {\n if (!field!.componentType) return mergedSlots.default ?? null\n\n const Component = getRawComponent(options?.components, field!.componentType)\n const { props: originProps, events } = normalizeProps(toJS((field!.component as any)[1]) || {})\n const originChange = events.change\n const originFocus = events.focus\n const originBlur = events.blur\n\n events.change = (...args: any[]) => {\n if (!isVoidField(field!)) field!.onInput(...args)\n originChange?.(...args)\n }\n events.focus = (...args: any[]) => {\n if (!isVoidField(field!)) field!.onFocus(...args)\n originFocus?.(...args)\n }\n events.blur = (...args: any[]) => {\n if (!isVoidField(field!)) field!.onBlur(...args)\n originBlur?.(...args)\n }\n\n const componentProps: Record<string, any> = {\n ...(isVoidField(field!)\n ? {}\n : {\n disabled: field!.pattern === 'disabled' || field!.pattern === 'readPretty',\n readOnly: field!.pattern === 'readOnly',\n }),\n ...originProps,\n ...(isVoidField(field!) ? {} : { value: field!.value }),\n ...toReactEventProps(events),\n }\n\n if (isStr(Component)) {\n // 原生标签不接收 slots 对象,所有具名插槽拍平成 children\n const slotChildren = Object.keys(mergedSlots).flatMap(name => toArray(mergedSlots[name]))\n return createElement(Component, componentProps, ...slotChildren)\n }\n // React 组件通过 props.slots 读取具名插槽,default 同时作为 children 透传\n return createElement(Component, { ...componentProps, slots: mergedSlots }, mergedSlots.default)\n }\n\n content = renderDecorator(renderComponent())\n }\n\n return <FieldContext.Provider value={field}>{content}</FieldContext.Provider>\n})\n\nReactiveField.displayName = 'ReactiveField'\n","import { Schema } from '@formvk/schema'\nimport { isFn, isValid, lazyMerge } from '@formvk/shared'\nimport { createElement, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\n\nimport { useField } from '../hooks/useField'\nimport { SchemaContext, SchemaExpressionScopeContext, SchemaOptionsContext } from '../shared/context'\nimport type { IRecursionFieldProps, ISchemaFieldRuntimeOptions, ISchemaFilter, ISchemaMapper } from '../types'\nimport { toArray } from '../utils/slots'\nimport type { SlotMap } from '../utils/slots'\nimport { ReactiveField } from './ReactiveField'\n\nfunction resolveEmptySlot(slots: SlotMap) {\n const names = Object.keys(slots)\n if (!names.length) return null\n const children = names.flatMap(name => toArray(slots[name]))\n // 无名根节点不创建字段,用 display: contents 的包裹层保持 DOM 结构与 Vue 侧一致\n return createElement('div', { style: { display: 'contents' } }, ...children)\n}\n\nexport function RecursionField(props: IRecursionFieldProps) {\n const parent = useField()\n const options = (useContext(SchemaOptionsContext) ?? {}) as ISchemaFieldRuntimeOptions\n const scope = useContext(SchemaExpressionScopeContext)\n\n // React 无响应式代理包裹,Schema 实例直接缓存即可(对应 Vue 侧去掉 markRaw)\n const fieldSchema = useMemo(\n () => (Schema.isSchemaInstance(props.schema) ? props.schema : new Schema(props.schema as any)),\n [props.schema]\n )\n\n const fieldProps = useMemo(\n () =>\n fieldSchema.toFieldProps({\n ...options,\n get scope() {\n return lazyMerge(options.scope as any, scope ?? {})\n },\n }),\n [fieldSchema, options, scope]\n )\n\n function getBasePath() {\n if (props.onlyRenderProperties) {\n return (\n props.basePath ?? (isValid(props.name) ? (parent?.address ?? '').concat(props.name as any) : parent?.address)\n )\n }\n return props.basePath ?? parent?.address\n }\n\n const basePath = getBasePath()\n\n function generateSlots(): SlotMap {\n if (props.onlyRenderSelf) return {}\n const properties = Schema.getOrderProperties(fieldSchema)\n if (!properties.length) return {}\n\n const renderMap: Record<string, ReactNode[]> = {}\n const mapProperties = props.mapProperties as ISchemaMapper | undefined\n const filterProperties = props.filterProperties as ISchemaFilter | undefined\n\n properties.forEach(({ schema: item, key: name }, index) => {\n let itemSchema = item\n if (isFn(mapProperties)) {\n const mapped = mapProperties(item, name)\n if (mapped) itemSchema = mapped as Schema\n }\n if (isFn(filterProperties)) {\n if (filterProperties(itemSchema, name) === false) return\n }\n const slotName = itemSchema.slot ?? 'default'\n const node = (\n <RecursionField key={`${index}-${String(name)}`} schema={itemSchema} name={name} basePath={basePath} />\n )\n ;(renderMap[slotName] ??= []).push(node)\n })\n\n return renderMap\n }\n\n const withSchema = (content: ReactNode) => (\n <SchemaContext.Provider value={fieldSchema}>{content}</SchemaContext.Provider>\n )\n\n if (!isValid(props.name)) {\n return withSchema(resolveEmptySlot(generateSlots()))\n }\n\n const commonFieldProps = {\n ...fieldProps,\n name: props.name,\n basePath,\n }\n\n if (fieldSchema.type === 'object') {\n if (props.onlyRenderProperties) return withSchema(resolveEmptySlot(generateSlots()))\n return withSchema(<ReactiveField fieldType=\"ObjectField\" fieldProps={commonFieldProps} slots={generateSlots()} />)\n }\n\n if (fieldSchema.type === 'array') {\n return withSchema(<ReactiveField fieldType=\"ArrayField\" fieldProps={commonFieldProps} />)\n }\n\n if (fieldSchema.type === 'void') {\n if (props.onlyRenderProperties) return withSchema(resolveEmptySlot(generateSlots()))\n return withSchema(<ReactiveField fieldType=\"VoidField\" fieldProps={commonFieldProps} slots={generateSlots()} />)\n }\n\n return withSchema(<ReactiveField fieldType=\"Field\" fieldProps={commonFieldProps} />)\n}\n\nRecursionField.displayName = 'RecursionField'\n","import type { Form } from '@formvk/core'\nimport { createFragment, Schema } from '@formvk/schema'\nimport type { AnyComponent, ISchema, SchemaKey } from '@formvk/schema'\nimport { FormPath, isValid } from '@formvk/shared'\nimport { useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { useField } from '../hooks/useField'\nimport { useForm } from '../hooks/useForm'\nimport { SchemaExpressionScopeContext, SchemaOptionsContext } from '../shared/context'\nimport type {\n InferArrayProps,\n InferFieldProps,\n InferVoidProps,\n ISchemaFieldFactoryOptions,\n ISchemaFieldProps,\n ISchemaFieldRuntimeOptions,\n SchemaFieldFactoryResult,\n SchemaReactComponents,\n} from '../types'\nimport { RecursionField } from './RecursionField'\n\ninterface ISchemaFieldInnerProps extends ISchemaFieldProps {\n /** createSchemaField 预绑定的 components 与 scope,直接使用 SchemaField 时不存在 */\n prebound?: ISchemaFieldRuntimeOptions\n}\n\nfunction joinPath(prefix: string, segment: SchemaKey | '*') {\n return prefix ? `${prefix}.${segment}` : String(segment)\n}\n\ninterface ISchemaPaths {\n /** 字段的绝对路径,数组元素下标使用 * 通配 */\n fields: string[]\n /** 数组子树的清理模式,覆盖任意下标 */\n arrays: string[]\n}\n\n/**\n * 收集 schema 声明的字段路径,用于热更新时定位需要销毁的字段。\n * 数组元素的下标是运行时产物,这里统一用 * 通配。\n */\nfunction collectSchemaPaths(schema: Schema, basePath: string, name?: SchemaKey): ISchemaPaths {\n const fields: string[] = []\n const arrays: string[] = []\n\n const walkNode = (node: Schema, path: string) => {\n if (node.type === 'array') arrays.push(joinPath(path, '*'))\n walkChildren(node, path)\n }\n\n const walkChildren = (node: Schema, prefix: string) => {\n const properties = node.properties ?? {}\n Object.keys(properties).forEach(key => {\n const path = joinPath(prefix, key)\n fields.push(path)\n walkNode(properties[key], path)\n })\n const items = node.items\n if (items) {\n const itemSchemas = Array.isArray(items) ? items : [items]\n itemSchemas.forEach(item => {\n if (item) walkChildren(item, joinPath(prefix, '*'))\n })\n }\n }\n\n if (isValid(name)) {\n const rootPath = joinPath(basePath, String(name))\n fields.push(rootPath)\n walkNode(schema, rootPath)\n } else {\n walkChildren(schema, basePath)\n }\n\n return { fields, arrays }\n}\n\nfunction toSchema(schema: ISchema | Schema): Schema {\n return Schema.isSchemaInstance(schema) ? schema : new Schema({ type: 'object', ...schema })\n}\n\n/**\n * 热更新:销毁旧 schema 声明的字段(保留值),字段会在本次渲染的 fieldProps 更新后重建。\n */\nfunction applyHotReload(form: Form, prev: Schema, next: Schema, basePath: string, name?: SchemaKey) {\n const prevPaths = collectSchemaPaths(prev, basePath, name)\n const nextPaths = collectSchemaPaths(next, basePath, name)\n const nextFields = new Set(nextPaths.fields)\n\n prevPaths.fields.forEach(path => {\n if (nextFields.has(path)) return\n form.deleteValuesIn(path)\n form.deleteInitialValuesIn(path)\n })\n\n const patterns = new Set<string>([...prevPaths.fields, ...nextPaths.fields, ...prevPaths.arrays, ...nextPaths.arrays])\n patterns.forEach(pattern => {\n form.clearFormGraph(pattern, false)\n })\n}\n\nexport function SchemaField(props: ISchemaFieldInnerProps) {\n const form = useForm()\n const parent = useField()\n\n const fieldSchema = useMemo(() => toSchema(props.schema), [props.schema])\n\n const options = useMemo<ISchemaFieldRuntimeOptions>(\n () => ({\n components: { ...props.prebound?.components, ...props.components },\n scope: { ...props.prebound?.scope, ...props.scope },\n }),\n [props.prebound, props.components, props.scope]\n )\n\n // 对齐 Vue watch(schema, { flush: 'pre' }):外部 store 的销毁不能放在渲染期\n // (destroy 会调度其他 observer 组件更新,触发 React 跨组件 setState 告警)。\n // 改为 layout effect 中清理旧字段,再通过 key 让 RecursionField 子树整体重挂载;\n // layout effect 在浏览器绘制前同步完成重渲染,无中间态闪烁,ref 守卫保证 StrictMode 双调用幂等。\n const [reloadVersion, setReloadVersion] = useState(0)\n const prevSchemaRef = useRef<Schema>(fieldSchema)\n const basePath = props.basePath ? FormPath.parse(props.basePath).toString() : (parent?.address?.toString() ?? '')\n\n useLayoutEffect(() => {\n if (!props.hotReload || !form || prevSchemaRef.current === fieldSchema) return\n const prev = prevSchemaRef.current\n prevSchemaRef.current = fieldSchema\n applyHotReload(form, prev, fieldSchema, basePath, props.name)\n setReloadVersion(version => version + 1)\n }, [props.hotReload, form, fieldSchema, basePath, props.name])\n\n return (\n <SchemaOptionsContext.Provider value={options}>\n <SchemaExpressionScopeContext.Provider value={options.scope}>\n <RecursionField\n key={reloadVersion}\n schema={fieldSchema}\n name={props.name}\n basePath={props.basePath}\n onlyRenderProperties={props.onlyRenderProperties}\n onlyRenderSelf={props.onlyRenderSelf}\n mapProperties={props.mapProperties}\n filterProperties={props.filterProperties}\n />\n </SchemaExpressionScopeContext.Provider>\n </SchemaOptionsContext.Provider>\n )\n}\n\nSchemaField.displayName = 'SchemaField'\n\n/**\n * 基于扁平组件映射与分类组件 map 创建 SchemaField + fragment:\n * - voidComponents / arrayComponents 只接收组件 map,分类名由工厂内部提取后传给 fragment\n * - 分类组件会自动合并进运行时组件映射,无需在 components 中重复注册\n * - 返回的 SchemaField 已预绑定拍平后的组件与 scope,props 仍可传扁平 map 覆盖同名组件\n * - fragment 包含 Field / Object / Array / Void / transform 与按组件名生成的动态构造器\n * 组件 props、字段值与 scope 类型全部自动推断,无需手写类型参数。\n */\nexport function createSchemaField<\n F extends SchemaReactComponents = SchemaReactComponents,\n V extends SchemaReactComponents = {},\n A extends SchemaReactComponents = {},\n Scope extends object = Record<string, any>,\n Decorator extends AnyComponent<InferVoidProps<V, A>> = AnyComponent<InferVoidProps<V, A>>,\n>(\n factoryOptions: ISchemaFieldFactoryOptions<F, V, A, Scope, Decorator> = {}\n): SchemaFieldFactoryResult<F, V, A, Scope, Decorator> {\n const voidComponents = factoryOptions.voidComponents ?? {}\n const arrayComponents = factoryOptions.arrayComponents ?? {}\n const flatComponents: SchemaReactComponents = {\n ...factoryOptions.components,\n ...voidComponents,\n ...arrayComponents,\n }\n\n const fragment = createFragment<InferFieldProps<F, V, A>, InferVoidProps<V, A>, InferArrayProps<A>, Scope, Decorator>(\n {\n patches: factoryOptions.patches,\n voidComponentNames: Object.keys(voidComponents),\n arrayComponentNames: Object.keys(arrayComponents),\n defaultDecorator: factoryOptions.defaultDecorator,\n }\n )\n\n const prebound: ISchemaFieldRuntimeOptions = {\n components: flatComponents,\n scope: factoryOptions.scope,\n }\n\n const BoundSchemaField = (props: ISchemaFieldProps) => <SchemaField {...props} prebound={prebound} />\n BoundSchemaField.displayName = 'SchemaField'\n\n return { SchemaField: BoundSchemaField as typeof SchemaField, fragment }\n}\n","import type { Schema } from '@formvk/schema'\nimport { useContext } from 'react'\n\nimport { SchemaContext } from '../shared/context'\n\nexport function useFieldSchema(): Schema | undefined {\n return useContext(SchemaContext)\n}\n","import type { Form } from '@formvk/core'\nimport { uid } from '@formvk/shared'\nimport { useEffect } from 'react'\n\nimport { useForm } from './useForm'\n\nexport function useFormEffects(effects?: (form: Form) => void): void {\n const form = useForm()\n\n useEffect(() => {\n if (!form || !effects) return\n const id = uid()\n form.addEffects(id, effects)\n return () => {\n // 捕获注册时的 form,避免 form 替换后清理到了新实例上\n form.removeEffects(id)\n }\n }, [form, effects])\n}\n","import { isObjectField } from '@formvk/core'\nimport type { Form, GeneralField, ObjectField } from '@formvk/core'\n\nimport { useField } from './useField'\nimport { useForm } from './useForm'\n\nexport function useParentForm(): Form | ObjectField | undefined {\n const field = useField()\n const form = useForm()\n\n function findObjectParent(target?: GeneralField): Form | ObjectField | undefined {\n if (!target) return form\n if (isObjectField(target)) return target\n return findObjectParent(target.parent)\n }\n\n return findObjectParent(field)\n}\n","/** @license React v16.13.1\n * react-is.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';var b=\"function\"===typeof Symbol&&Symbol.for,c=b?Symbol.for(\"react.element\"):60103,d=b?Symbol.for(\"react.portal\"):60106,e=b?Symbol.for(\"react.fragment\"):60107,f=b?Symbol.for(\"react.strict_mode\"):60108,g=b?Symbol.for(\"react.profiler\"):60114,h=b?Symbol.for(\"react.provider\"):60109,k=b?Symbol.for(\"react.context\"):60110,l=b?Symbol.for(\"react.async_mode\"):60111,m=b?Symbol.for(\"react.concurrent_mode\"):60111,n=b?Symbol.for(\"react.forward_ref\"):60112,p=b?Symbol.for(\"react.suspense\"):60113,q=b?\nSymbol.for(\"react.suspense_list\"):60120,r=b?Symbol.for(\"react.memo\"):60115,t=b?Symbol.for(\"react.lazy\"):60116,v=b?Symbol.for(\"react.block\"):60121,w=b?Symbol.for(\"react.fundamental\"):60117,x=b?Symbol.for(\"react.responder\"):60118,y=b?Symbol.for(\"react.scope\"):60119;\nfunction z(a){if(\"object\"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;\nexports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isAsyncMode=function(a){return A(a)||z(a)===l};exports.isConcurrentMode=A;exports.isContextConsumer=function(a){return z(a)===k};exports.isContextProvider=function(a){return z(a)===h};exports.isElement=function(a){return\"object\"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return z(a)===n};exports.isFragment=function(a){return z(a)===e};exports.isLazy=function(a){return z(a)===t};\nexports.isMemo=function(a){return z(a)===r};exports.isPortal=function(a){return z(a)===d};exports.isProfiler=function(a){return z(a)===g};exports.isStrictMode=function(a){return z(a)===f};exports.isSuspense=function(a){return z(a)===p};\nexports.isValidElementType=function(a){return\"string\"===typeof a||\"function\"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||\"object\"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};exports.typeOf=z;\n","/** @license React v16.13.1\n * react-is.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\n\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n'use strict';\n\n// The Symbol used to tag the ReactElement-like types. If there is no native Symbol\n// nor polyfill, then a plain number is used for performance.\nvar hasSymbol = typeof Symbol === 'function' && Symbol.for;\nvar REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;\nvar REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;\nvar REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;\nvar REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;\nvar REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;\nvar REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;\nvar REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary\n// (unstable) APIs that have been removed. Can we remove the symbols?\n\nvar REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;\nvar REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;\nvar REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;\nvar REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;\nvar REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;\nvar REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;\nvar REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;\nvar REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;\nvar REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;\nvar REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;\nvar REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;\n\nfunction isValidElementType(type) {\n return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.\n type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);\n}\n\nfunction typeOf(object) {\n if (typeof object === 'object' && object !== null) {\n var $$typeof = object.$$typeof;\n\n switch ($$typeof) {\n case REACT_ELEMENT_TYPE:\n var type = object.type;\n\n switch (type) {\n case REACT_ASYNC_MODE_TYPE:\n case REACT_CONCURRENT_MODE_TYPE:\n case REACT_FRAGMENT_TYPE:\n case REACT_PROFILER_TYPE:\n case REACT_STRICT_MODE_TYPE:\n case REACT_SUSPENSE_TYPE:\n return type;\n\n default:\n var $$typeofType = type && type.$$typeof;\n\n switch ($$typeofType) {\n case REACT_CONTEXT_TYPE:\n case REACT_FORWARD_REF_TYPE:\n case REACT_LAZY_TYPE:\n case REACT_MEMO_TYPE:\n case REACT_PROVIDER_TYPE:\n return $$typeofType;\n\n default:\n return $$typeof;\n }\n\n }\n\n case REACT_PORTAL_TYPE:\n return $$typeof;\n }\n }\n\n return undefined;\n} // AsyncMode is deprecated along with isAsyncMode\n\nvar AsyncMode = REACT_ASYNC_MODE_TYPE;\nvar ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;\nvar ContextConsumer = REACT_CONTEXT_TYPE;\nvar ContextProvider = REACT_PROVIDER_TYPE;\nvar Element = REACT_ELEMENT_TYPE;\nvar ForwardRef = REACT_FORWARD_REF_TYPE;\nvar Fragment = REACT_FRAGMENT_TYPE;\nvar Lazy = REACT_LAZY_TYPE;\nvar Memo = REACT_MEMO_TYPE;\nvar Portal = REACT_PORTAL_TYPE;\nvar Profiler = REACT_PROFILER_TYPE;\nvar StrictMode = REACT_STRICT_MODE_TYPE;\nvar Suspense = REACT_SUSPENSE_TYPE;\nvar hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated\n\nfunction isAsyncMode(object) {\n {\n if (!hasWarnedAboutDeprecatedIsAsyncMode) {\n hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint\n\n console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');\n }\n }\n\n return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;\n}\nfunction isConcurrentMode(object) {\n return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;\n}\nfunction isContextConsumer(object) {\n return typeOf(object) === REACT_CONTEXT_TYPE;\n}\nfunction isContextProvider(object) {\n return typeOf(object) === REACT_PROVIDER_TYPE;\n}\nfunction isElement(object) {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n}\nfunction isForwardRef(object) {\n return typeOf(object) === REACT_FORWARD_REF_TYPE;\n}\nfunction isFragment(object) {\n return typeOf(object) === REACT_FRAGMENT_TYPE;\n}\nfunction isLazy(object) {\n return typeOf(object) === REACT_LAZY_TYPE;\n}\nfunction isMemo(object) {\n return typeOf(object) === REACT_MEMO_TYPE;\n}\nfunction isPortal(object) {\n return typeOf(object) === REACT_PORTAL_TYPE;\n}\nfunction isProfiler(object) {\n return typeOf(object) === REACT_PROFILER_TYPE;\n}\nfunction isStrictMode(object) {\n return typeOf(object) === REACT_STRICT_MODE_TYPE;\n}\nfunction isSuspense(object) {\n return typeOf(object) === REACT_SUSPENSE_TYPE;\n}\n\nexports.AsyncMode = AsyncMode;\nexports.ConcurrentMode = ConcurrentMode;\nexports.ContextConsumer = ContextConsumer;\nexports.ContextProvider = ContextProvider;\nexports.Element = Element;\nexports.ForwardRef = ForwardRef;\nexports.Fragment = Fragment;\nexports.Lazy = Lazy;\nexports.Memo = Memo;\nexports.Portal = Portal;\nexports.Profiler = Profiler;\nexports.StrictMode = StrictMode;\nexports.Suspense = Suspense;\nexports.isAsyncMode = isAsyncMode;\nexports.isConcurrentMode = isConcurrentMode;\nexports.isContextConsumer = isContextConsumer;\nexports.isContextProvider = isContextProvider;\nexports.isElement = isElement;\nexports.isForwardRef = isForwardRef;\nexports.isFragment = isFragment;\nexports.isLazy = isLazy;\nexports.isMemo = isMemo;\nexports.isPortal = isPortal;\nexports.isProfiler = isProfiler;\nexports.isStrictMode = isStrictMode;\nexports.isSuspense = isSuspense;\nexports.isValidElementType = isValidElementType;\nexports.typeOf = typeOf;\n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-is.production.min.js');\n} else {\n module.exports = require('./cjs/react-is.development.js');\n}\n","'use strict';\n\nvar reactIs = require('react-is');\n\n/**\n * Copyright 2015, Yahoo! Inc.\n * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.\n */\nvar REACT_STATICS = {\n childContextTypes: true,\n contextType: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromError: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true\n};\nvar KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true\n};\nvar FORWARD_REF_STATICS = {\n '$$typeof': true,\n render: true,\n defaultProps: true,\n displayName: true,\n propTypes: true\n};\nvar MEMO_STATICS = {\n '$$typeof': true,\n compare: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n type: true\n};\nvar TYPE_STATICS = {};\nTYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;\nTYPE_STATICS[reactIs.Memo] = MEMO_STATICS;\n\nfunction getStatics(component) {\n // React v16.11 and below\n if (reactIs.isMemo(component)) {\n return MEMO_STATICS;\n } // React v16.12 and above\n\n\n return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;\n}\n\nvar defineProperty = Object.defineProperty;\nvar getOwnPropertyNames = Object.getOwnPropertyNames;\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\nvar getPrototypeOf = Object.getPrototypeOf;\nvar objectPrototype = Object.prototype;\nfunction hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {\n if (typeof sourceComponent !== 'string') {\n // don't hoist over string (html) components\n if (objectPrototype) {\n var inheritedComponent = getPrototypeOf(sourceComponent);\n\n if (inheritedComponent && inheritedComponent !== objectPrototype) {\n hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);\n }\n }\n\n var keys = getOwnPropertyNames(sourceComponent);\n\n if (getOwnPropertySymbols) {\n keys = keys.concat(getOwnPropertySymbols(sourceComponent));\n }\n\n var targetStatics = getStatics(targetComponent);\n var sourceStatics = getStatics(sourceComponent);\n\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n\n if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {\n var descriptor = getOwnPropertyDescriptor(sourceComponent, key);\n\n try {\n // Avoid failures from read-only properties\n defineProperty(targetComponent, key, descriptor);\n } catch (e) {}\n }\n }\n }\n\n return targetComponent;\n}\n\nmodule.exports = hoistNonReactStatics;\n","import { isVoidField } from '@formvk/core'\nimport type { GeneralField } from '@formvk/core'\nimport { observer } from '@formvk/reactive-react'\nimport { each, FormPath, isFn, isStr, isValid } from '@formvk/shared'\nimport hoistNonReactStatics from 'hoist-non-react-statics'\nimport { createElement } from 'react'\n\nimport { useField } from '../hooks/useField'\nimport type { IComponentMapper, IStateMapper, ReactComponent } from '../types'\n\nfunction getComponentName(component: ReactComponent): string | undefined {\n return component.displayName ?? component.name\n}\n\nexport function mapProps<T extends ReactComponent = ReactComponent>(...args: IStateMapper[]) {\n function transform(input: Record<string, any>, field: GeneralField) {\n return args.reduce((props, mapper) => {\n if (isFn(mapper)) {\n props = Object.assign(props, mapper(props, field))\n } else {\n each(mapper, (to, extract) => {\n const extractValue = FormPath.getIn(field, extract)\n const targetValue = isStr(to) ? to : extract\n const originalValue = FormPath.getIn(props, targetValue)\n if (extract === 'value') {\n if (to !== extract) {\n delete props.value\n }\n }\n if (isValid(originalValue) && !isValid(extractValue)) return\n FormPath.setIn(props, targetValue, extractValue)\n })\n }\n return props\n }, input)\n }\n\n return function (target: T): T {\n const Connected: ReactComponent = observer(props => {\n const field = useField()\n // 无字段上下文时原样透传,支持 connect 组件脱离表单单独使用\n const nextProps = field ? transform({ ...props }, field) : { ...props }\n return createElement(target, nextProps)\n })\n const name = getComponentName(target)\n Connected.displayName = name ? `Connected${name}` : 'ConnectedComponent'\n hoistNonReactStatics(Connected, target)\n return Connected as unknown as T\n }\n}\n\nexport function mapReadPretty(component: ReactComponent, readPrettyProps?: Record<string, any>) {\n return function <T extends ReactComponent>(target: T): T {\n const Read: ReactComponent = observer(props => {\n const field = useField()\n const Current = field && !isVoidField(field) && field.pattern === 'readPretty' ? component : target\n return createElement(Current, { ...readPrettyProps, ...props })\n })\n const name = getComponentName(target)\n Read.displayName = name ? `Read${name}` : 'ReadComponent'\n hoistNonReactStatics(Read, target)\n return Read as unknown as T\n }\n}\n\nexport function connect<T extends ReactComponent>(target: T, ...args: IComponentMapper[]): T {\n const Component = args.reduce<ReactComponent>((current, mapper) => mapper(current), target)\n const Connected: ReactComponent = props => createElement(Component, props)\n Connected.displayName = getComponentName(target)\n hoistNonReactStatics(Connected, target)\n return Connected as unknown as T\n}\n","import type { IFormProps } from '@formvk/core'\nimport { createForm as createCoreForm } from '@formvk/core'\n\n/**\n * React 侧表单工厂:core 的 Form 自身管理响应式状态,\n * React 不会自动代理普通对象,无需 Vue 侧的 markRaw 处理。\n */\nexport function createForm<T extends object = any>(options?: IFormProps<T>) {\n return createCoreForm<T>(options)\n}\n"],"ignoreList":[15,16,17,18],"mappings":";;;;;;;;;;;;;;;;;;A,aAMawB,IAAcC,EAAgC,KAAA,CAAS,GAEvDC,IAAeD,EAAwC,KAAA,CAAS,GAEhEE,IAAgBF,EAAkC,KAAA,CAAS,GAE3DG,IAA+BH,EAA+C,KAAA,CAAS,GAEvFI,IAAuBJ,EAAsD,KAAA,CAAS;;ACNnG,SAAgBK,EAAgB,GAAiD;CAC/E,IAAMC,IAAcC,EAAWJ,CAA4B,GACrDK,IAASC,QAAcC,EAAUJ,KAAe,CAAC,GAAGK,EAAM,KAAK,GAAG,CAACL,GAAaK,EAAM,KAAK,CAAC;CAElG,OAAO,kBAACR,EAA6B,UAA9B;EAAuC,OAAOK;EAAS,UAAAG,EAAM;CAAgD,CAAA;AACtH;AAEA,EAAgB,cAAc;;ACV9B,SAAgBC,IAA4B;CAC1C,OAAOL,E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M,GACpFwP,KAA4B,MAASrN,EAAc6B,GAAWnD,CAAK;CAGzE,OAFA,EAAU,cAAckO,EAAiB/O,CAAM,IAC/C,GAAAwN,EAAA,QAAA,CAAqBgC,GAAWxP,CAAM,GAC/BwP;AACT;;AChEA,SAAgBQ,GAAmC,GAAyB;CAC1E,OAAOvR,EAAkB0E,CAAO;AAClC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createCoreForm","createForm$1","hoistNonReactStatics","FormContext","createContext","FieldContext","SchemaContext","SchemaExpressionScopeContext","SchemaOptionsContext","ExpressionScope","parentScope","useContext","merged","useMemo","lazyMerge","props","useForm","FormConsumer","observer","form","children","useAttach","useEffect","target","FormProvider","useField","getRawComponent","isStr","component","FormPath","components","toArray","value","isReactComponentLike","isFn","renderContent","isValidElement","content","createElement","mergeSlots","result","slots","appendToSlot","rendered","origin","name","each","key","normalizeProps","events","eventName","toReactEventProps","handler","ReactiveField","parent","options","incomingSlots","field","factoryProps","fieldProps","fieldType","mergedSlots","renderDecorator","inner","Decorator","decoratorProps","toJS","renderComponent","Component","originProps","originChange","originFocus","originBlur","args","isVoidField","componentProps","slotChildren","resolveEmptySlot","names","RecursionField","scope","fieldSchema","Schema","getBasePath","isValid","basePath","generateSlots","properties","renderMap","mapProperties","filterProperties","item","itemSchema","mapped","slotName","node","index","withSchema","commonFieldProps","joinPath","prefix","segment","collectSchemaPaths","fields","arrays","walkNode","path","walkChildren","items","rootPath","schema","toSchema","applyHotReload","prevPaths","prev","nextPaths","next","nextFields","pattern","SchemaField","reloadVersion","setReloadVersion","useState","prevSchemaRef","useRef","useLayoutEffect","version","createSchemaField","voidComponents","factoryOptions","arrayComponents","flatComponents","fragment","createFragment","prebound","BoundSchemaField","useFieldSchema","useFormEffects","effects","id","uid","useParentForm","findObjectParent","isObjectField","getComponentName","mapProps","transform","mapper","extractValue","extract","targetValue","to","originalValue","input","Connected","nextProps","mapReadPretty","Read","Current","readPrettyProps","connect","current","createForm"],"sources":["../src/shared/context.ts","../src/components/ExpressionScope.tsx","../src/hooks/useForm.ts","../src/components/FormConsumer.tsx","../src/hooks/useAttach.ts","../src/components/FormProvider.tsx","../src/hooks/useField.ts","../src/utils/getRawComponent.ts","../src/utils/slots.ts","../src/components/ReactiveField.tsx","../src/components/RecursionField.tsx","../src/components/SchemaField.tsx","../src/hooks/useFieldSchema.ts","../src/hooks/useFormEffects.ts","../src/hooks/useParentForm.ts","../src/shared/connect.tsx","../src/shared/createForm.ts"],"sourcesContent":["import type { Form, GeneralField } from '@formvk/core'\nimport type { Schema } from '@formvk/schema'\nimport { createContext } from 'react'\n\nimport type { ISchemaFieldRuntimeOptions } from '../types'\n\nexport const FormContext = createContext<Form | undefined>(undefined)\n\nexport const FieldContext = createContext<GeneralField | undefined>(undefined)\n\nexport const SchemaContext = createContext<Schema | undefined>(undefined)\n\nexport const SchemaExpressionScopeContext = createContext<Record<string, any> | undefined>(undefined)\n\nexport const SchemaOptionsContext = createContext<ISchemaFieldRuntimeOptions | undefined>(undefined)\n","import { lazyMerge } from '@formvk/shared'\nimport { useContext, useMemo } from 'react'\nimport type { PropsWithChildren } from 'react'\n\nimport { SchemaExpressionScopeContext } from '../shared/context'\nimport type { IExpressionScopeProps } from '../types'\n\n/** 表达式作用域:与外层 scope 惰性合并,内层同名变量优先,Provider 天然隔离兄弟分支。 */\nexport function ExpressionScope(props: PropsWithChildren<IExpressionScopeProps>) {\n const parentScope = useContext(SchemaExpressionScopeContext)\n const merged = useMemo(() => lazyMerge(parentScope ?? {}, props.value), [parentScope, props.value])\n\n return <SchemaExpressionScopeContext.Provider value={merged}>{props.children}</SchemaExpressionScopeContext.Provider>\n}\n\nExpressionScope.displayName = 'ExpressionScope'\n","import type { Form } from '@formvk/core'\nimport { useContext } from 'react'\n\nimport { FormContext } from '../shared/context'\n\nexport function useForm(): Form | undefined {\n return useContext(FormContext)\n}\n","import type { Form } from '@formvk/core'\nimport { observer } from '@formvk/reactive-react'\nimport type { ReactNode } from 'react'\n\nimport { useForm } from '../hooks/useForm'\nimport type { IFormConsumerRenderProps } from '../types'\n\nexport interface IFormConsumerProps {\n children?: (renderProps: IFormConsumerRenderProps) => ReactNode\n}\n\n/** render props 形式读取 form,内部由 observer 追踪响应式状态,form 变化后自动刷新。 */\nexport const FormConsumer = observer((props: IFormConsumerProps) => {\n const form = useForm()\n const { children } = props\n if (typeof children !== 'function') return null\n return children({ form: form as Form })\n})\n\nFormConsumer.displayName = 'FormConsumer'\n","import { useEffect } from 'react'\n\ninterface IRecycleTarget {\n onMount: () => void\n onUnmount: () => void\n}\n\n/**\n * 把字段生命周期挂到 React 组件生命周期上:\n * target 变化时旧实例 onUnmount、新实例 onMount,组件卸载时清理当前实例。\n */\nexport function useAttach<T extends IRecycleTarget>(target: T | undefined): T | undefined {\n useEffect(() => {\n target?.onMount()\n return () => {\n target?.onUnmount()\n }\n }, [target])\n return target\n}\n","import type { PropsWithChildren } from 'react'\n\nimport { useAttach } from '../hooks/useAttach'\nimport {\n FieldContext,\n FormContext,\n SchemaContext,\n SchemaExpressionScopeContext,\n SchemaOptionsContext,\n} from '../shared/context'\nimport type { IProviderProps } from '../types'\n\n/**\n * 挂载表单生命周期并注入 FormContext。\n * 同时把字段 / schema / scope / options 四个上下文重置为空,\n * 等价于 Vue 侧 useInjectionCleaner 的隔离效果,嵌套 FormProvider 不会串层。\n */\nexport function FormProvider(props: PropsWithChildren<IProviderProps>) {\n const { form, children } = props\n useAttach(form)\n\n return (\n <FormContext.Provider value={form}>\n <FieldContext.Provider value={undefined}>\n <SchemaContext.Provider value={undefined}>\n <SchemaExpressionScopeContext.Provider value={undefined}>\n <SchemaOptionsContext.Provider value={undefined}>{children}</SchemaOptionsContext.Provider>\n </SchemaExpressionScopeContext.Provider>\n </SchemaContext.Provider>\n </FieldContext.Provider>\n </FormContext.Provider>\n )\n}\n\nFormProvider.displayName = 'FormProvider'\n","import type { GeneralField } from '@formvk/core'\nimport { useContext } from 'react'\n\nimport { FieldContext } from '../shared/context'\n\nexport function useField<T = GeneralField>(): T | undefined {\n return useContext(FieldContext) as T | undefined\n}\n","import { FormPath, isStr } from '@formvk/shared'\n\n/**\n * 解析 schema 中的组件描述:字符串按路径从 components 中查找,组件类型直接使用。\n * React 侧不存在响应式代理包裹,无需 toRaw。\n */\nexport function getRawComponent(components: Record<string, any> | undefined, component: any): any {\n if (isStr(component)) {\n return FormPath.getIn(components, component) ?? component\n }\n return component\n}\n","import type { ReactNode } from 'react'\n\n/** 具名插槽映射,default 为默认插槽,对应 Vue 侧的 slots 对象。 */\nexport type SlotMap = Record<string, ReactNode>\n\nexport function toArray(value: ReactNode): ReactNode[] {\n if (Array.isArray(value)) return value\n return value === undefined || value === null ? [] : [value]\n}\n","import { isVoidField } from '@formvk/core'\nimport type { GeneralField, IFieldFactoryProps } from '@formvk/core'\nimport { toJS } from '@formvk/reactive'\nimport { observer } from '@formvk/reactive-react'\nimport { each, isFn, isStr } from '@formvk/shared'\nimport { createElement, isValidElement, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\n\nimport { useAttach } from '../hooks/useAttach'\nimport { useField } from '../hooks/useField'\nimport { useForm } from '../hooks/useForm'\nimport { FieldContext, SchemaOptionsContext } from '../shared/context'\nimport type { IReactiveFieldProps, ISchemaFieldRuntimeOptions } from '../types'\nimport { getRawComponent } from '../utils/getRawComponent'\nimport { toArray } from '../utils/slots'\nimport type { SlotMap } from '../utils/slots'\n\nfunction isReactComponentLike(value: any): boolean {\n if (!value) return false\n if (isFn(value)) return true\n return typeof value === 'object' && ('$$typeof' in value || isFn(value.render))\n}\n\nfunction renderContent(content: any): ReactNode {\n if (isValidElement(content) || isStr(content)) return content\n if (isReactComponentLike(content)) return createElement(content)\n return content\n}\n\n/** 合并 RecursionField 生成的具名插槽与 schema 上的 content 声明。 */\nfunction mergeSlots(slots: SlotMap, content: any): SlotMap {\n const result: SlotMap = { ...slots }\n\n if (!content) return result\n\n function appendToSlot(name: string, value: any) {\n const rendered = renderContent(value)\n const origin = result[name]\n result[name] = origin === undefined ? rendered : ([] as ReactNode[]).concat(toArray(origin), toArray(rendered))\n }\n\n if (isStr(content) || isValidElement(content) || isReactComponentLike(content)) {\n appendToSlot('default', content)\n } else if (typeof content === 'object') {\n // 普通对象视为具名插槽内容映射\n each(content, (value, key) => {\n appendToSlot(key, value)\n })\n }\n\n return result\n}\n\nfunction normalizeProps(origin: Record<string, any>) {\n const props: Record<string, any> = {}\n const events: Record<string, any> = {}\n each(origin, (value, key) => {\n if (key.startsWith('on')) {\n const eventName = `${key[2].toLowerCase()}${key.slice(3)}`\n events[eventName] = events[eventName] ?? value\n } else if (key.startsWith('@')) {\n events[key.slice(1)] = value\n } else {\n props[key] = value\n }\n })\n return { props, events }\n}\n\nfunction toReactEventProps(events: Record<string, any>) {\n const props: Record<string, any> = {}\n each(events, (handler, name) => {\n props[`on${name.charAt(0).toUpperCase()}${name.slice(1)}`] = handler\n })\n return props\n}\n\nexport const ReactiveField = observer((props: IReactiveFieldProps) => {\n const form = useForm()\n const parent = useField()\n const options = useContext(SchemaOptionsContext) as ISchemaFieldRuntimeOptions | undefined\n\n const { fieldType = 'Field', fieldProps, slots: incomingSlots, children } = props\n\n // 与 Vue 侧 watch(fieldProps) 重建对齐:fieldProps 引用变化即创建新字段,旧实例由 useAttach 卸载\n const field = useMemo(() => {\n const factoryProps = (fieldProps ?? {}) as IFieldFactoryProps<any, any>\n return (form as any)?.[`create${fieldType}`]?.({\n ...factoryProps,\n basePath: factoryProps.basePath ?? parent?.address,\n }) as GeneralField | undefined\n }, [form, fieldType, fieldProps, parent])\n\n useAttach(field)\n\n let content: ReactNode = null\n\n if (!field) {\n content = children ?? null\n } else if (field.display !== 'visible') {\n content = null\n } else {\n const mergedSlots = mergeSlots(incomingSlots ?? {}, field.content)\n\n function renderDecorator(inner: ReactNode) {\n if (!field!.decoratorType) return inner\n const Decorator = getRawComponent(options?.components, field!.decoratorType)\n const { props: decoratorProps, events } = normalizeProps(toJS((field!.decorator as any)[1]) || {})\n return createElement(Decorator, { ...decoratorProps, ...toReactEventProps(events) }, inner)\n }\n\n function renderComponent(): ReactNode {\n if (!field!.componentType) return mergedSlots.default ?? null\n\n const Component = getRawComponent(options?.components, field!.componentType)\n const { props: originProps, events } = normalizeProps(toJS((field!.component as any)[1]) || {})\n const originChange = events.change\n const originFocus = events.focus\n const originBlur = events.blur\n\n events.change = (...args: any[]) => {\n if (!isVoidField(field!)) field!.onInput(...args)\n originChange?.(...args)\n }\n events.focus = (...args: any[]) => {\n if (!isVoidField(field!)) field!.onFocus(...args)\n originFocus?.(...args)\n }\n events.blur = (...args: any[]) => {\n if (!isVoidField(field!)) field!.onBlur(...args)\n originBlur?.(...args)\n }\n\n const componentProps: Record<string, any> = {\n ...(isVoidField(field!)\n ? {}\n : {\n disabled: field!.pattern === 'disabled' || field!.pattern === 'readPretty',\n readOnly: field!.pattern === 'readOnly',\n }),\n ...originProps,\n ...(isVoidField(field!) ? {} : { value: field!.value }),\n ...toReactEventProps(events),\n }\n\n if (isStr(Component)) {\n // 原生标签不接收 slots 对象,所有具名插槽拍平成 children\n const slotChildren = Object.keys(mergedSlots).flatMap(name => toArray(mergedSlots[name]))\n return createElement(Component, componentProps, ...slotChildren)\n }\n // React 组件通过 props.slots 读取具名插槽,default 同时作为 children 透传\n return createElement(Component, { ...componentProps, slots: mergedSlots }, mergedSlots.default)\n }\n\n content = renderDecorator(renderComponent())\n }\n\n return <FieldContext.Provider value={field}>{content}</FieldContext.Provider>\n})\n\nReactiveField.displayName = 'ReactiveField'\n","import { Schema } from '@formvk/schema'\nimport { isFn, isValid, lazyMerge } from '@formvk/shared'\nimport { createElement, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\n\nimport { useField } from '../hooks/useField'\nimport { SchemaContext, SchemaExpressionScopeContext, SchemaOptionsContext } from '../shared/context'\nimport type { IRecursionFieldProps, ISchemaFieldRuntimeOptions, ISchemaFilter, ISchemaMapper } from '../types'\nimport { toArray } from '../utils/slots'\nimport type { SlotMap } from '../utils/slots'\nimport { ReactiveField } from './ReactiveField'\n\nfunction resolveEmptySlot(slots: SlotMap) {\n const names = Object.keys(slots)\n if (!names.length) return null\n const children = names.flatMap(name => toArray(slots[name]))\n // 无名根节点不创建字段,用 display: contents 的包裹层保持 DOM 结构与 Vue 侧一致\n return createElement('div', { style: { display: 'contents' } }, ...children)\n}\n\nexport function RecursionField(props: IRecursionFieldProps) {\n const parent = useField()\n const options = (useContext(SchemaOptionsContext) ?? {}) as ISchemaFieldRuntimeOptions\n const scope = useContext(SchemaExpressionScopeContext)\n\n // React 无响应式代理包裹,Schema 实例直接缓存即可(对应 Vue 侧去掉 markRaw)\n const fieldSchema = useMemo(\n () => (Schema.isSchemaInstance(props.schema) ? props.schema : new Schema(props.schema as any)),\n [props.schema]\n )\n\n const fieldProps = useMemo(\n () =>\n fieldSchema.toFieldProps({\n ...options,\n get scope() {\n return lazyMerge(options.scope as any, scope ?? {})\n },\n }),\n [fieldSchema, options, scope]\n )\n\n function getBasePath() {\n if (props.onlyRenderProperties) {\n return (\n props.basePath ?? (isValid(props.name) ? (parent?.address ?? '').concat(props.name as any) : parent?.address)\n )\n }\n return props.basePath ?? parent?.address\n }\n\n const basePath = getBasePath()\n\n function generateSlots(): SlotMap {\n if (props.onlyRenderSelf) return {}\n const properties = Schema.getOrderProperties(fieldSchema)\n if (!properties.length) return {}\n\n const renderMap: Record<string, ReactNode[]> = {}\n const mapProperties = props.mapProperties as ISchemaMapper | undefined\n const filterProperties = props.filterProperties as ISchemaFilter | undefined\n\n properties.forEach(({ schema: item, key: name }, index) => {\n let itemSchema = item\n if (isFn(mapProperties)) {\n const mapped = mapProperties(item, name)\n if (mapped) itemSchema = mapped as Schema\n }\n if (isFn(filterProperties)) {\n if (filterProperties(itemSchema, name) === false) return\n }\n const slotName = itemSchema.slot ?? 'default'\n const node = (\n <RecursionField key={`${index}-${String(name)}`} schema={itemSchema} name={name} basePath={basePath} />\n )\n ;(renderMap[slotName] ??= []).push(node)\n })\n\n return renderMap\n }\n\n const withSchema = (content: ReactNode) => (\n <SchemaContext.Provider value={fieldSchema}>{content}</SchemaContext.Provider>\n )\n\n if (!isValid(props.name)) {\n return withSchema(resolveEmptySlot(generateSlots()))\n }\n\n const commonFieldProps = {\n ...fieldProps,\n name: props.name,\n basePath,\n }\n\n if (fieldSchema.type === 'object') {\n if (props.onlyRenderProperties) return withSchema(resolveEmptySlot(generateSlots()))\n return withSchema(<ReactiveField fieldType=\"ObjectField\" fieldProps={commonFieldProps} slots={generateSlots()} />)\n }\n\n if (fieldSchema.type === 'array') {\n return withSchema(<ReactiveField fieldType=\"ArrayField\" fieldProps={commonFieldProps} />)\n }\n\n if (fieldSchema.type === 'void') {\n if (props.onlyRenderProperties) return withSchema(resolveEmptySlot(generateSlots()))\n return withSchema(<ReactiveField fieldType=\"VoidField\" fieldProps={commonFieldProps} slots={generateSlots()} />)\n }\n\n return withSchema(<ReactiveField fieldType=\"Field\" fieldProps={commonFieldProps} />)\n}\n\nRecursionField.displayName = 'RecursionField'\n","import type { Form } from '@formvk/core'\nimport { createFragment, Schema } from '@formvk/schema'\nimport type { AnyComponent, ISchema, SchemaKey } from '@formvk/schema'\nimport { FormPath, isValid } from '@formvk/shared'\nimport { useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { useField } from '../hooks/useField'\nimport { useForm } from '../hooks/useForm'\nimport { SchemaExpressionScopeContext, SchemaOptionsContext } from '../shared/context'\nimport type {\n InferArrayProps,\n InferFieldProps,\n InferVoidProps,\n ISchemaFieldFactoryOptions,\n ISchemaFieldProps,\n ISchemaFieldRuntimeOptions,\n SchemaFieldFactoryResult,\n SchemaReactComponents,\n} from '../types'\nimport { RecursionField } from './RecursionField'\n\ninterface ISchemaFieldInnerProps extends ISchemaFieldProps {\n /** createSchemaField 预绑定的 components 与 scope,直接使用 SchemaField 时不存在 */\n prebound?: ISchemaFieldRuntimeOptions\n}\n\nfunction joinPath(prefix: string, segment: SchemaKey | '*') {\n return prefix ? `${prefix}.${segment}` : String(segment)\n}\n\ninterface ISchemaPaths {\n /** 字段的绝对路径,数组元素下标使用 * 通配 */\n fields: string[]\n /** 数组子树的清理模式,覆盖任意下标 */\n arrays: string[]\n}\n\n/**\n * 收集 schema 声明的字段路径,用于热更新时定位需要销毁的字段。\n * 数组元素的下标是运行时产物,这里统一用 * 通配。\n */\nfunction collectSchemaPaths(schema: Schema, basePath: string, name?: SchemaKey): ISchemaPaths {\n const fields: string[] = []\n const arrays: string[] = []\n\n const walkNode = (node: Schema, path: string) => {\n if (node.type === 'array') arrays.push(joinPath(path, '*'))\n walkChildren(node, path)\n }\n\n const walkChildren = (node: Schema, prefix: string) => {\n const properties = node.properties ?? {}\n Object.keys(properties).forEach(key => {\n const path = joinPath(prefix, key)\n fields.push(path)\n walkNode(properties[key], path)\n })\n const items = node.items\n if (items) {\n const itemSchemas = Array.isArray(items) ? items : [items]\n itemSchemas.forEach(item => {\n if (item) walkChildren(item, joinPath(prefix, '*'))\n })\n }\n }\n\n if (isValid(name)) {\n const rootPath = joinPath(basePath, String(name))\n fields.push(rootPath)\n walkNode(schema, rootPath)\n } else {\n walkChildren(schema, basePath)\n }\n\n return { fields, arrays }\n}\n\nfunction toSchema(schema: ISchema | Schema): Schema {\n return Schema.isSchemaInstance(schema) ? schema : new Schema({ type: 'object', ...schema })\n}\n\n/**\n * 热更新:销毁旧 schema 声明的字段(保留值),字段会在本次渲染的 fieldProps 更新后重建。\n */\nfunction applyHotReload(form: Form, prev: Schema, next: Schema, basePath: string, name?: SchemaKey) {\n const prevPaths = collectSchemaPaths(prev, basePath, name)\n const nextPaths = collectSchemaPaths(next, basePath, name)\n const nextFields = new Set(nextPaths.fields)\n\n prevPaths.fields.forEach(path => {\n if (nextFields.has(path)) return\n form.deleteValuesIn(path)\n form.deleteInitialValuesIn(path)\n })\n\n const patterns = new Set<string>([...prevPaths.fields, ...nextPaths.fields, ...prevPaths.arrays, ...nextPaths.arrays])\n patterns.forEach(pattern => {\n form.clearFormGraph(pattern, false)\n })\n}\n\nexport function SchemaField(props: ISchemaFieldInnerProps) {\n const form = useForm()\n const parent = useField()\n\n const fieldSchema = useMemo(() => toSchema(props.schema), [props.schema])\n\n const options = useMemo<ISchemaFieldRuntimeOptions>(\n () => ({\n components: { ...props.prebound?.components, ...props.components },\n scope: { ...props.prebound?.scope, ...props.scope },\n }),\n [props.prebound, props.components, props.scope]\n )\n\n // 对齐 Vue watch(schema, { flush: 'pre' }):外部 store 的销毁不能放在渲染期\n // (destroy 会调度其他 observer 组件更新,触发 React 跨组件 setState 告警)。\n // 改为 layout effect 中清理旧字段,再通过 key 让 RecursionField 子树整体重挂载;\n // layout effect 在浏览器绘制前同步完成重渲染,无中间态闪烁,ref 守卫保证 StrictMode 双调用幂等。\n const [reloadVersion, setReloadVersion] = useState(0)\n const prevSchemaRef = useRef<Schema>(fieldSchema)\n const basePath = props.basePath ? FormPath.parse(props.basePath).toString() : (parent?.address?.toString() ?? '')\n\n useLayoutEffect(() => {\n if (!props.hotReload || !form || prevSchemaRef.current === fieldSchema) return\n const prev = prevSchemaRef.current\n prevSchemaRef.current = fieldSchema\n applyHotReload(form, prev, fieldSchema, basePath, props.name)\n setReloadVersion(version => version + 1)\n }, [props.hotReload, form, fieldSchema, basePath, props.name])\n\n return (\n <SchemaOptionsContext.Provider value={options}>\n <SchemaExpressionScopeContext.Provider value={options.scope}>\n <RecursionField\n key={reloadVersion}\n schema={fieldSchema}\n name={props.name}\n basePath={props.basePath}\n onlyRenderProperties={props.onlyRenderProperties}\n onlyRenderSelf={props.onlyRenderSelf}\n mapProperties={props.mapProperties}\n filterProperties={props.filterProperties}\n />\n </SchemaExpressionScopeContext.Provider>\n </SchemaOptionsContext.Provider>\n )\n}\n\nSchemaField.displayName = 'SchemaField'\n\n/**\n * 基于扁平组件映射与分类组件 map 创建 SchemaField + fragment:\n * - voidComponents / arrayComponents 只接收组件 map,分类名由工厂内部提取后传给 fragment\n * - 分类组件会自动合并进运行时组件映射,无需在 components 中重复注册\n * - 返回的 SchemaField 已预绑定拍平后的组件与 scope,props 仍可传扁平 map 覆盖同名组件\n * - fragment 包含 Field / Object / Array / Void / transform 与按组件名生成的动态构造器\n * 组件 props、字段值与 scope 类型全部自动推断,无需手写类型参数。\n */\nexport function createSchemaField<\n F extends SchemaReactComponents = SchemaReactComponents,\n V extends SchemaReactComponents = {},\n A extends SchemaReactComponents = {},\n Scope extends object = Record<string, any>,\n Decorator extends AnyComponent<InferVoidProps<V, A>> = AnyComponent<InferVoidProps<V, A>>,\n>(\n factoryOptions: ISchemaFieldFactoryOptions<F, V, A, Scope, Decorator> = {}\n): SchemaFieldFactoryResult<F, V, A, Scope, Decorator> {\n const voidComponents = factoryOptions.voidComponents ?? {}\n const arrayComponents = factoryOptions.arrayComponents ?? {}\n const flatComponents: SchemaReactComponents = {\n ...factoryOptions.components,\n ...voidComponents,\n ...arrayComponents,\n }\n\n const fragment = createFragment<InferFieldProps<F, V, A>, InferVoidProps<V, A>, InferArrayProps<A>, Scope, Decorator>(\n {\n patches: factoryOptions.patches,\n voidComponentNames: Object.keys(voidComponents),\n arrayComponentNames: Object.keys(arrayComponents),\n defaultDecorator: factoryOptions.defaultDecorator,\n }\n )\n\n const prebound: ISchemaFieldRuntimeOptions = {\n components: flatComponents,\n scope: factoryOptions.scope,\n }\n\n const BoundSchemaField = (props: ISchemaFieldProps) => <SchemaField {...props} prebound={prebound} />\n BoundSchemaField.displayName = 'SchemaField'\n\n return { SchemaField: BoundSchemaField as typeof SchemaField, fragment }\n}\n","import type { Schema } from '@formvk/schema'\nimport { useContext } from 'react'\n\nimport { SchemaContext } from '../shared/context'\n\nexport function useFieldSchema(): Schema | undefined {\n return useContext(SchemaContext)\n}\n","import type { Form } from '@formvk/core'\nimport { uid } from '@formvk/shared'\nimport { useEffect } from 'react'\n\nimport { useForm } from './useForm'\n\nexport function useFormEffects(effects?: (form: Form) => void): void {\n const form = useForm()\n\n useEffect(() => {\n if (!form || !effects) return\n const id = uid()\n form.addEffects(id, effects)\n return () => {\n // 捕获注册时的 form,避免 form 替换后清理到了新实例上\n form.removeEffects(id)\n }\n }, [form, effects])\n}\n","import { isObjectField } from '@formvk/core'\nimport type { Form, GeneralField, ObjectField } from '@formvk/core'\n\nimport { useField } from './useField'\nimport { useForm } from './useForm'\n\nexport function useParentForm(): Form | ObjectField | undefined {\n const field = useField()\n const form = useForm()\n\n function findObjectParent(target?: GeneralField): Form | ObjectField | undefined {\n if (!target) return form\n if (isObjectField(target)) return target\n return findObjectParent(target.parent)\n }\n\n return findObjectParent(field)\n}\n","import { isVoidField } from '@formvk/core'\nimport type { GeneralField } from '@formvk/core'\nimport { observer } from '@formvk/reactive-react'\nimport { each, FormPath, isFn, isStr, isValid } from '@formvk/shared'\nimport hoistNonReactStatics from 'hoist-non-react-statics'\nimport { createElement } from 'react'\n\nimport { useField } from '../hooks/useField'\nimport type { IComponentMapper, IStateMapper, ReactComponent } from '../types'\n\nfunction getComponentName(component: ReactComponent): string | undefined {\n return component.displayName ?? component.name\n}\n\nexport function mapProps<T extends ReactComponent = ReactComponent>(...args: IStateMapper[]) {\n function transform(input: Record<string, any>, field: GeneralField) {\n return args.reduce((props, mapper) => {\n if (isFn(mapper)) {\n props = Object.assign(props, mapper(props, field))\n } else {\n each(mapper, (to, extract) => {\n const extractValue = FormPath.getIn(field, extract)\n const targetValue = isStr(to) ? to : extract\n const originalValue = FormPath.getIn(props, targetValue)\n if (extract === 'value') {\n if (to !== extract) {\n delete props.value\n }\n }\n if (isValid(originalValue) && !isValid(extractValue)) return\n FormPath.setIn(props, targetValue, extractValue)\n })\n }\n return props\n }, input)\n }\n\n return function (target: T): T {\n const Connected: ReactComponent = observer(props => {\n const field = useField()\n // 无字段上下文时原样透传,支持 connect 组件脱离表单单独使用\n const nextProps = field ? transform({ ...props }, field) : { ...props }\n return createElement(target, nextProps)\n })\n const name = getComponentName(target)\n Connected.displayName = name ? `Connected${name}` : 'ConnectedComponent'\n hoistNonReactStatics(Connected, target)\n return Connected as unknown as T\n }\n}\n\nexport function mapReadPretty(component: ReactComponent, readPrettyProps?: Record<string, any>) {\n return function <T extends ReactComponent>(target: T): T {\n const Read: ReactComponent = observer(props => {\n const field = useField()\n const Current = field && !isVoidField(field) && field.pattern === 'readPretty' ? component : target\n return createElement(Current, { ...readPrettyProps, ...props })\n })\n const name = getComponentName(target)\n Read.displayName = name ? `Read${name}` : 'ReadComponent'\n hoistNonReactStatics(Read, target)\n return Read as unknown as T\n }\n}\n\nexport function connect<T extends ReactComponent>(target: T, ...args: IComponentMapper[]): T {\n const Component = args.reduce<ReactComponent>((current, mapper) => mapper(current), target)\n const Connected: ReactComponent = props => createElement(Component, props)\n Connected.displayName = getComponentName(target)\n hoistNonReactStatics(Connected, target)\n return Connected as unknown as T\n}\n","import type { IFormProps } from '@formvk/core'\nimport { createForm as createCoreForm } from '@formvk/core'\n\n/**\n * React 侧表单工厂:core 的 Form 自身管理响应式状态,\n * React 不会自动代理普通对象,无需 Vue 侧的 markRaw 处理。\n */\nexport function createForm<T extends object = any>(options?: IFormProps<T>) {\n return createCoreForm<T>(options)\n}\n"],"mappings":";;;;;;;;;;AAMA,IAAaG,IAAcC,EAAgC,KAAA,CAAS,GAEvDC,IAAeD,EAAwC,KAAA,CAAS,GAEhEE,IAAgBF,EAAkC,KAAA,CAAS,GAE3DG,IAA+BH,EAA+C,KAAA,CAAS,GAEvFI,IAAuBJ,EAAsD,KAAA,CAAS;;ACNnG,SAAgBK,EAAgB,GAAiD;CAC/E,IAAMC,IAAcC,EAAWJ,CAA4B,GACrDK,IAASC,QAAcC,EAAUJ,KAAe,CAAC,GAAGK,EAAM,KAAK,GAAG,CAACL,GAAaK,EAAM,KAAK,CAAC;CAElG,OAAO,kBAACR,EAA6B,UAA9B;EAAuC,OAAOK;EAAS,UAAAG,EAAM;CAAgD,CAAA;AACtH;AAEA,EAAgB,cAAc;;ACV9B,SAAgBC,IAA4B;CAC1C,OAAOL,EAAWR,CAAW;AAC/B;;ACKA,IAAac,IAAeC,GAAU,M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AAM;EAGpC,OAFA,EAAK,cAAcsB,IAAO,OAAOA,MAAS,iBAC1C3C,EAAqB2J,GAAMtI,CAAM,GAC1BsI;CACT;AACF;AAEA,SAAgBG,GAAkC,GAAW,GAAGvF,GAA6B;CAC3F,IAAML,IAAYK,EAAK,QAAwB,GAAS,MAAW0E,EAAOc,CAAO,GAAG1I,CAAM,GACpFmI,KAA4B,MAASpH,EAAc8B,GAAWrD,CAAK;CAGzE,OAFA,EAAU,cAAciI,EAAiBzH,CAAM,GAC/CrB,EAAqBwJ,GAAWnI,CAAM,GAC/BmI;AACT;;AChEA,SAAgBQ,GAAmC,GAAyB;CAC1E,OAAOlK,EAAkBuD,CAAO;AAClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formvk/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Formvk React Bindings",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"form",
|
|
@@ -10,16 +10,20 @@
|
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "yiyunwan",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"CHANGELOG.md"
|
|
16
|
+
],
|
|
13
17
|
"type": "module",
|
|
14
18
|
"main": "dist/index.js",
|
|
15
19
|
"module": "dist/index.js",
|
|
16
20
|
"types": "dist/index.d.ts",
|
|
17
21
|
"dependencies": {
|
|
18
|
-
"@formvk/core": "
|
|
19
|
-
"@formvk/reactive": "
|
|
20
|
-
"@formvk/reactive-react": "
|
|
21
|
-
"@formvk/schema": "
|
|
22
|
-
"@formvk/shared": "
|
|
22
|
+
"@formvk/core": "~1.0.0",
|
|
23
|
+
"@formvk/reactive": "~1.0.0",
|
|
24
|
+
"@formvk/reactive-react": "~1.0.0",
|
|
25
|
+
"@formvk/schema": "~1.0.0",
|
|
26
|
+
"@formvk/shared": "~1.0.0",
|
|
23
27
|
"hoist-non-react-statics": "^3.3.2"
|
|
24
28
|
},
|
|
25
29
|
"devDependencies": {
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { reactive } from '@formvk/reactive'
|
|
2
|
-
import { act, cleanup } from '@testing-library/react'
|
|
3
|
-
import type { ReactNode } from 'react'
|
|
4
|
-
import { afterEach, describe, expect, test } from 'vitest'
|
|
5
|
-
|
|
6
|
-
import { ExpressionScope, SchemaField, createForm } from '..'
|
|
7
|
-
import { Input, mountWithForm } from './shared'
|
|
8
|
-
|
|
9
|
-
/** 与 Vue 侧一致:value 在组件闭包中捕获,组件本身只负责把 scope 注入上下文并透传子节点 */
|
|
10
|
-
function createScopeWrapper(value: any) {
|
|
11
|
-
function ScopeWrapper(props: { children?: ReactNode }) {
|
|
12
|
-
return <ExpressionScope value={value}>{props.children}</ExpressionScope>
|
|
13
|
-
}
|
|
14
|
-
ScopeWrapper.displayName = 'ScopeWrapper'
|
|
15
|
-
return ScopeWrapper
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function scopeSchema(expression: string) {
|
|
19
|
-
return {
|
|
20
|
-
type: 'object',
|
|
21
|
-
properties: {
|
|
22
|
-
v: {
|
|
23
|
-
type: 'void',
|
|
24
|
-
component: 'ScopeWrapper',
|
|
25
|
-
properties: {
|
|
26
|
-
target: {
|
|
27
|
-
type: 'string',
|
|
28
|
-
component: 'Input',
|
|
29
|
-
componentProps: { placeholder: expression },
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
afterEach(cleanup)
|
|
38
|
-
|
|
39
|
-
describe('ExpressionScope', () => {
|
|
40
|
-
test('内层 scope 与外层 SchemaField scope 叠加', () => {
|
|
41
|
-
const form = createForm()
|
|
42
|
-
const ScopeWrapper = createScopeWrapper({ $inner: 'inner' })
|
|
43
|
-
const view = mountWithForm(
|
|
44
|
-
form,
|
|
45
|
-
<SchemaField
|
|
46
|
-
components={{ Input, ScopeWrapper }}
|
|
47
|
-
scope={{ $outer: 'outer' }}
|
|
48
|
-
schema={scopeSchema('{{$inner + "-" + $outer}}')}
|
|
49
|
-
/>
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
expect(view.container.querySelector('[data-testid="target"]')!.getAttribute('placeholder')).toBe('inner-outer')
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('内外层同名变量时内层优先', () => {
|
|
56
|
-
const form = createForm()
|
|
57
|
-
const ScopeWrapper = createScopeWrapper({ $shared: 'inner' })
|
|
58
|
-
const view = mountWithForm(
|
|
59
|
-
form,
|
|
60
|
-
<SchemaField
|
|
61
|
-
components={{ Input, ScopeWrapper }}
|
|
62
|
-
scope={{ $shared: 'outer' }}
|
|
63
|
-
schema={scopeSchema('{{$shared}}')}
|
|
64
|
-
/>
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
expect(view.container.querySelector('[data-testid="target"]')!.getAttribute('placeholder')).toBe('inner')
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
test('ExpressionScope 值变化后表达式重新编译', async () => {
|
|
71
|
-
const form = createForm()
|
|
72
|
-
const innerScope = reactive({ $inner: 'v1' })
|
|
73
|
-
const ScopeWrapper = createScopeWrapper(innerScope)
|
|
74
|
-
const view = mountWithForm(
|
|
75
|
-
form,
|
|
76
|
-
<SchemaField components={{ Input, ScopeWrapper }} schema={scopeSchema('{{$inner}}')} />
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
expect(view.container.querySelector('[data-testid="target"]')!.getAttribute('placeholder')).toBe('v1')
|
|
80
|
-
|
|
81
|
-
await act(async () => {
|
|
82
|
-
innerScope.$inner = 'v2'
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
expect(view.container.querySelector('[data-testid="target"]')!.getAttribute('placeholder')).toBe('v2')
|
|
86
|
-
})
|
|
87
|
-
})
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { act, cleanup, render } from '@testing-library/react'
|
|
2
|
-
import { afterEach, describe, expect, test, vi } from 'vitest'
|
|
3
|
-
|
|
4
|
-
import { FormConsumer, FormProvider, SchemaField, createForm, useField, useParentForm } from '..'
|
|
5
|
-
import type { IFormConsumerRenderProps } from '..'
|
|
6
|
-
import { Input, mountWithForm } from './shared'
|
|
7
|
-
|
|
8
|
-
afterEach(cleanup)
|
|
9
|
-
|
|
10
|
-
function simpleSchema(name: string, component = 'Input') {
|
|
11
|
-
return {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
[name]: { type: 'string', component },
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function ParentName() {
|
|
20
|
-
const parent = useParentForm()
|
|
21
|
-
const field = useField()
|
|
22
|
-
return (
|
|
23
|
-
<div className="parent-name" data-testid={field?.path?.toString()}>
|
|
24
|
-
{parent?.displayName}
|
|
25
|
-
</div>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
ParentName.displayName = 'ParentName'
|
|
29
|
-
|
|
30
|
-
describe('FormProvider 与表单上下文', () => {
|
|
31
|
-
test('FormProvider 提供表单,挂载与卸载驱动 form 生命周期', () => {
|
|
32
|
-
const form = createForm()
|
|
33
|
-
const view = mountWithForm(form, <SchemaField components={{ Input }} schema={simpleSchema('a')} />)
|
|
34
|
-
|
|
35
|
-
const field = form.fields['a'] as any
|
|
36
|
-
expect(form.mounted).toBe(true)
|
|
37
|
-
expect(field.mounted).toBe(true)
|
|
38
|
-
|
|
39
|
-
view.unmount()
|
|
40
|
-
expect(form.unmounted).toBe(true)
|
|
41
|
-
expect(field.unmounted).toBe(true)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('useParentForm 在 object schema 内返回最近的 ObjectField,void / 根级返回 Form', () => {
|
|
45
|
-
const form = createForm()
|
|
46
|
-
const view = mountWithForm(
|
|
47
|
-
form,
|
|
48
|
-
<SchemaField
|
|
49
|
-
components={{ ParentName }}
|
|
50
|
-
schema={{
|
|
51
|
-
type: 'object',
|
|
52
|
-
properties: {
|
|
53
|
-
obj: {
|
|
54
|
-
type: 'object',
|
|
55
|
-
properties: {
|
|
56
|
-
inner: { type: 'string', component: 'ParentName' },
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
v: {
|
|
60
|
-
type: 'void',
|
|
61
|
-
properties: {
|
|
62
|
-
inner: { type: 'string', component: 'ParentName' },
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
root: { type: 'string', component: 'ParentName' },
|
|
66
|
-
},
|
|
67
|
-
}}
|
|
68
|
-
/>
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
expect(view.container.querySelector('[data-testid="obj.inner"]')!.textContent).toBe('ObjectField')
|
|
72
|
-
// Field.path 会剔除 void 节点,因此 void 下的字段 path 是 inner 而非 v.inner
|
|
73
|
-
expect(view.container.querySelector('[data-testid="inner"]')!.textContent).toBe('Form')
|
|
74
|
-
expect(view.container.querySelector('[data-testid="root"]')!.textContent).toBe('Form')
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('嵌套 FormProvider 的字段上下文被重置,不发生串层', () => {
|
|
78
|
-
const form = createForm()
|
|
79
|
-
const view = render(
|
|
80
|
-
<FormProvider form={form}>
|
|
81
|
-
<SchemaField components={{ Input }} schema={simpleSchema('parent')} />
|
|
82
|
-
<FormProvider form={form}>
|
|
83
|
-
<SchemaField components={{ Input }} schema={simpleSchema('inner')} />
|
|
84
|
-
</FormProvider>
|
|
85
|
-
</FormProvider>
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
expect(form.fields['parent']).toBeTruthy()
|
|
89
|
-
expect(form.fields['inner']).toBeTruthy()
|
|
90
|
-
expect(form.fields['parent.inner']).toBeUndefined()
|
|
91
|
-
expect(view.container.querySelector('[data-testid="parent"]')).toBeTruthy()
|
|
92
|
-
expect(view.container.querySelector('[data-testid="inner"]')).toBeTruthy()
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
test('FormConsumer render props 读到 form.values,setValuesIn 后自动更新', async () => {
|
|
96
|
-
const form = createForm({ values: { a: 'abc' } })
|
|
97
|
-
const view = render(
|
|
98
|
-
<FormProvider form={form}>
|
|
99
|
-
<SchemaField components={{ Input }} schema={simpleSchema('a')} />
|
|
100
|
-
<FormConsumer>
|
|
101
|
-
{({ form }: IFormConsumerRenderProps) => <div className="consumer">{JSON.stringify(form.values)}</div>}
|
|
102
|
-
</FormConsumer>
|
|
103
|
-
</FormProvider>
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
expect(view.container.querySelector('.consumer')!.textContent).toBe('{"a":"abc"}')
|
|
107
|
-
|
|
108
|
-
await act(async () => {
|
|
109
|
-
form.setValuesIn('a', 'xyz')
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
expect(view.container.querySelector('.consumer')!.textContent).toBe('{"a":"xyz"}')
|
|
113
|
-
expect(view.container.querySelector('input')!.value).toBe('xyz')
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test('form.display 置为 none 后字段值被清空并同步到 DOM', async () => {
|
|
117
|
-
const form = createForm({ values: { a: 'abc' } })
|
|
118
|
-
const view = render(
|
|
119
|
-
<FormProvider form={form}>
|
|
120
|
-
<SchemaField components={{ Input }} schema={simpleSchema('a')} />
|
|
121
|
-
<FormConsumer>
|
|
122
|
-
{({ form }: IFormConsumerRenderProps) => <div className="consumer">{JSON.stringify(form.values)}</div>}
|
|
123
|
-
</FormConsumer>
|
|
124
|
-
</FormProvider>
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
await act(async () => {
|
|
128
|
-
form.setDisplay('none')
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
expect(form.getValuesIn('a')).toBeUndefined()
|
|
132
|
-
expect(view.container.querySelector('.consumer')!.textContent).toBe('{}')
|
|
133
|
-
expect(view.container.querySelector('input')).toBeNull()
|
|
134
|
-
|
|
135
|
-
await act(async () => {
|
|
136
|
-
form.setDisplay('visible')
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
expect(form.getValuesIn('a')).toBe('abc')
|
|
140
|
-
expect(view.container.querySelector('input')!.value).toBe('abc')
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
test('卸载 FormProvider 时触发字段 onUnmount', () => {
|
|
144
|
-
const form = createForm()
|
|
145
|
-
const view = mountWithForm(form, <SchemaField components={{ Input }} schema={simpleSchema('a')} />)
|
|
146
|
-
|
|
147
|
-
const field = form.fields['a'] as any
|
|
148
|
-
const spy = vi.spyOn(field, 'onUnmount')
|
|
149
|
-
view.unmount()
|
|
150
|
-
|
|
151
|
-
expect(spy).toHaveBeenCalledTimes(1)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test('FormConsumer 无 render props 时渲染为空', () => {
|
|
155
|
-
const form = createForm()
|
|
156
|
-
const view = render(
|
|
157
|
-
<FormProvider form={form}>
|
|
158
|
-
<FormConsumer />
|
|
159
|
-
</FormProvider>
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
expect(view.container.textContent).toBe('')
|
|
163
|
-
})
|
|
164
|
-
})
|