Comparing version 3.6.1 to 3.6.2
import React, { ComponentType } from 'react'; | ||
import { BaseForm, BaseFormProps, BaseFormState } from './BaseForm'; | ||
export declare type QuickFormProps<Model> = BaseFormProps<Model> & { | ||
/** | ||
* @deprecated | ||
*/ | ||
autoField?: ComponentType<{ | ||
@@ -5,0 +8,0 @@ name: string; |
@@ -27,2 +27,5 @@ "use strict"; | ||
const context = useForm_1.useForm(); | ||
const usesInitialValue = (options === null || options === void 0 ? void 0 : options.initialValue) !== false; | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const onChangeCalled = usesInitialValue ? react_1.useRef(false) : { current: false }; | ||
const name = joinName_1.joinName((options === null || options === void 0 ? void 0 : options.absoluteName) ? '' : context.name, fieldName); | ||
@@ -45,2 +48,3 @@ const state = mapValues_1.default(context.state, (prev, key) => { | ||
const onChange = react_1.useCallback((value, key = name) => { | ||
onChangeCalled.current = true; | ||
context.onChange(key, value); | ||
@@ -53,10 +57,12 @@ }, | ||
let value = (_a = props.value) !== null && _a !== void 0 ? _a : valueFromModel; | ||
if (value === undefined) { | ||
value = context.schema.getInitialValue(name, props); | ||
initialValue = value; | ||
} | ||
else if (props.value !== undefined && props.value !== valueFromModel) { | ||
initialValue = props.value; | ||
} | ||
if ((options === null || options === void 0 ? void 0 : options.initialValue) !== false) { | ||
if (usesInitialValue) { | ||
if (!onChangeCalled.current) { | ||
if (value === undefined) { | ||
value = context.schema.getInitialValue(name, props); | ||
initialValue = value; | ||
} | ||
else if (props.value !== undefined && props.value !== valueFromModel) { | ||
initialValue = props.value; | ||
} | ||
} | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
@@ -63,0 +69,0 @@ react_1.useEffect(() => { |
import React, { ComponentType } from 'react'; | ||
import { BaseForm, BaseFormProps, BaseFormState } from './BaseForm'; | ||
export declare type QuickFormProps<Model> = BaseFormProps<Model> & { | ||
/** | ||
* @deprecated | ||
*/ | ||
autoField?: ComponentType<{ | ||
@@ -5,0 +8,0 @@ name: string; |
import get from 'lodash/get'; | ||
import mapValues from 'lodash/mapValues'; | ||
import { useCallback, useEffect, useMemo } from 'react'; | ||
import { useCallback, useEffect, useMemo, useRef } from 'react'; | ||
import { joinName } from './joinName'; | ||
@@ -23,2 +23,5 @@ import { useForm } from './useForm'; | ||
const context = useForm(); | ||
const usesInitialValue = (options === null || options === void 0 ? void 0 : options.initialValue) !== false; | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const onChangeCalled = usesInitialValue ? useRef(false) : { current: false }; | ||
const name = joinName((options === null || options === void 0 ? void 0 : options.absoluteName) ? '' : context.name, fieldName); | ||
@@ -41,2 +44,3 @@ const state = mapValues(context.state, (prev, key) => { | ||
const onChange = useCallback((value, key = name) => { | ||
onChangeCalled.current = true; | ||
context.onChange(key, value); | ||
@@ -49,10 +53,12 @@ }, | ||
let value = (_a = props.value) !== null && _a !== void 0 ? _a : valueFromModel; | ||
if (value === undefined) { | ||
value = context.schema.getInitialValue(name, props); | ||
initialValue = value; | ||
} | ||
else if (props.value !== undefined && props.value !== valueFromModel) { | ||
initialValue = props.value; | ||
} | ||
if ((options === null || options === void 0 ? void 0 : options.initialValue) !== false) { | ||
if (usesInitialValue) { | ||
if (!onChangeCalled.current) { | ||
if (value === undefined) { | ||
value = context.schema.getInitialValue(name, props); | ||
initialValue = value; | ||
} | ||
else if (props.value !== undefined && props.value !== valueFromModel) { | ||
initialValue = props.value; | ||
} | ||
} | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
@@ -59,0 +65,0 @@ useEffect(() => { |
{ | ||
"name": "uniforms", | ||
"version": "3.6.1", | ||
"version": "3.6.2", | ||
"license": "MIT", | ||
@@ -44,3 +44,3 @@ "main": "./cjs/index.js", | ||
}, | ||
"gitHead": "a36891aa6aa9bb10c40bf5709085fbe82ac4ae92" | ||
"gitHead": "36b3671537cf11e7610b9ca8b40f0bbaa508b8e1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
197576
4655
0