Comparing version 3.10.1 to 4.0.0-alpha.0
@@ -10,3 +10,3 @@ declare type Error = any; | ||
getField(name: string): Field; | ||
getInitialValue(name: string, props: Record<string, any>): any; | ||
getInitialValue(name: string): any; | ||
getProps(name: string, props: Record<string, any>): Record<string, any>; | ||
@@ -13,0 +13,0 @@ getSubfields(name?: string): string[]; |
@@ -38,4 +38,4 @@ "use strict"; | ||
// `props`. | ||
getInitialValue(name, props) { | ||
return invariant_1.default(false, '%s have not implemented `getInitialValue` method (args=%o).', this.constructor.name, { name, props }); | ||
getInitialValue(name) { | ||
return invariant_1.default(false, '%s have not implemented `getInitialValue` method (args=%o).', this.constructor.name, { name }); | ||
} | ||
@@ -42,0 +42,0 @@ // Get props defined in schema for a field `name`. There are no required nor |
@@ -11,8 +11,8 @@ "use strict"; | ||
function AutoField(rawProps) { | ||
var _a, _b; | ||
var _a; | ||
const [props, uniforms] = useField_1.useField(rawProps.name, rawProps); | ||
const componentDetector = react_1.useContext(context); | ||
const component = (_a = props.component) !== null && _a !== void 0 ? _a : componentDetector(props, uniforms); | ||
const component = componentDetector(props, uniforms); | ||
invariant_1.default(component, 'AutoField received no component for: %s', props.name); | ||
return 'options' in component && ((_b = component.options) === null || _b === void 0 ? void 0 : _b.kind) === 'leaf' | ||
return 'options' in component && ((_a = component.options) === null || _a === void 0 ? void 0 : _a.kind) === 'leaf' | ||
? react_1.createElement(component.Component, props) | ||
@@ -19,0 +19,0 @@ : react_1.createElement(component, rawProps); |
@@ -28,3 +28,3 @@ "use strict"; | ||
// These props are provided by useField directly. | ||
'changed', 'error', 'errorMessage', 'field', 'fieldType', 'fields', 'initialCount', 'name', 'onChange', 'transform', 'value', | ||
'changed', 'error', 'errorMessage', 'field', 'fieldType', 'fields', 'name', 'onChange', 'transform', 'value', | ||
// These props are provided by useField through context.state. | ||
@@ -31,0 +31,0 @@ 'disabled', 'label', 'placeholder', 'showInlineError', |
import React, { ComponentType } from 'react'; | ||
import { BaseForm, BaseFormProps, BaseFormState } from './BaseForm'; | ||
export declare type QuickFormProps<Model> = BaseFormProps<Model> & { | ||
/** | ||
* @deprecated | ||
*/ | ||
autoField?: ComponentType<{ | ||
name: string; | ||
}>; | ||
errorsField?: ComponentType; | ||
@@ -11,0 +5,0 @@ submitField?: ComponentType; |
@@ -12,3 +12,4 @@ "use strict"; | ||
const _props = super.getNativeFormProps(); | ||
const { autoField: AutoField = this.getAutoField(), errorsField: ErrorsField = this.getErrorsField(), submitField: SubmitField = this.getSubmitField() } = _props, props = tslib_1.__rest(_props, ["autoField", "errorsField", "submitField"]); | ||
const { errorsField: ErrorsField = this.getErrorsField(), submitField: SubmitField = this.getSubmitField() } = _props, props = tslib_1.__rest(_props, ["errorsField", "submitField"]); | ||
const AutoField = this.getAutoField(); | ||
if (!props.children) { | ||
@@ -15,0 +16,0 @@ props.children = this.getContextSchema() |
@@ -73,3 +73,2 @@ import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
fields: never; | ||
initialCount: never; | ||
label: never; | ||
@@ -76,0 +75,0 @@ name: never; |
@@ -58,3 +58,3 @@ "use strict"; | ||
if (value === undefined) { | ||
value = context.schema.getInitialValue(name, props); | ||
value = context.schema.getInitialValue(name); | ||
initialValue = value; | ||
@@ -61,0 +61,0 @@ } |
@@ -10,3 +10,3 @@ declare type Error = any; | ||
getField(name: string): Field; | ||
getInitialValue(name: string, props: Record<string, any>): any; | ||
getInitialValue(name: string): any; | ||
getProps(name: string, props: Record<string, any>): Record<string, any>; | ||
@@ -13,0 +13,0 @@ getSubfields(name?: string): string[]; |
@@ -34,4 +34,4 @@ import invariant from 'invariant'; | ||
// `props`. | ||
getInitialValue(name, props) { | ||
return invariant(false, '%s have not implemented `getInitialValue` method (args=%o).', this.constructor.name, { name, props }); | ||
getInitialValue(name) { | ||
return invariant(false, '%s have not implemented `getInitialValue` method (args=%o).', this.constructor.name, { name }); | ||
} | ||
@@ -38,0 +38,0 @@ // Get props defined in schema for a field `name`. There are no required nor |
@@ -7,8 +7,8 @@ import invariant from 'invariant'; | ||
function AutoField(rawProps) { | ||
var _a, _b; | ||
var _a; | ||
const [props, uniforms] = useField(rawProps.name, rawProps); | ||
const componentDetector = useContext(context); | ||
const component = (_a = props.component) !== null && _a !== void 0 ? _a : componentDetector(props, uniforms); | ||
const component = componentDetector(props, uniforms); | ||
invariant(component, 'AutoField received no component for: %s', props.name); | ||
return 'options' in component && ((_b = component.options) === null || _b === void 0 ? void 0 : _b.kind) === 'leaf' | ||
return 'options' in component && ((_a = component.options) === null || _a === void 0 ? void 0 : _a.kind) === 'leaf' | ||
? createElement(component.Component, props) | ||
@@ -15,0 +15,0 @@ : createElement(component, rawProps); |
@@ -25,3 +25,3 @@ const registered = []; | ||
// These props are provided by useField directly. | ||
'changed', 'error', 'errorMessage', 'field', 'fieldType', 'fields', 'initialCount', 'name', 'onChange', 'transform', 'value', | ||
'changed', 'error', 'errorMessage', 'field', 'fieldType', 'fields', 'name', 'onChange', 'transform', 'value', | ||
// These props are provided by useField through context.state. | ||
@@ -28,0 +28,0 @@ 'disabled', 'label', 'placeholder', 'showInlineError', |
import React, { ComponentType } from 'react'; | ||
import { BaseForm, BaseFormProps, BaseFormState } from './BaseForm'; | ||
export declare type QuickFormProps<Model> = BaseFormProps<Model> & { | ||
/** | ||
* @deprecated | ||
*/ | ||
autoField?: ComponentType<{ | ||
name: string; | ||
}>; | ||
errorsField?: ComponentType; | ||
@@ -11,0 +5,0 @@ submitField?: ComponentType; |
@@ -9,3 +9,4 @@ import { __rest } from "tslib"; | ||
const _props = super.getNativeFormProps(); | ||
const { autoField: AutoField = this.getAutoField(), errorsField: ErrorsField = this.getErrorsField(), submitField: SubmitField = this.getSubmitField() } = _props, props = __rest(_props, ["autoField", "errorsField", "submitField"]); | ||
const { errorsField: ErrorsField = this.getErrorsField(), submitField: SubmitField = this.getSubmitField() } = _props, props = __rest(_props, ["errorsField", "submitField"]); | ||
const AutoField = this.getAutoField(); | ||
if (!props.children) { | ||
@@ -12,0 +13,0 @@ props.children = this.getContextSchema() |
@@ -73,3 +73,2 @@ import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
fields: never; | ||
initialCount: never; | ||
label: never; | ||
@@ -76,0 +75,0 @@ name: never; |
@@ -54,3 +54,3 @@ import get from 'lodash/get'; | ||
if (value === undefined) { | ||
value = context.schema.getInitialValue(name, props); | ||
value = context.schema.getInitialValue(name); | ||
initialValue = value; | ||
@@ -57,0 +57,0 @@ } |
{ | ||
"name": "uniforms", | ||
"version": "3.10.1", | ||
"version": "4.0.0-alpha.0", | ||
"license": "MIT", | ||
@@ -44,3 +44,3 @@ "main": "./cjs/index.js", | ||
}, | ||
"gitHead": "37fa8c1e482cb9c3e8bd6e6395258634366b5d8a" | ||
"gitHead": "94084d3c005b7338d27ed206b67a5a43abba357e" | ||
} |
@@ -78,3 +78,3 @@ import invariant from 'invariant'; | ||
// `props`. | ||
getInitialValue(name: string, props: Record<string, any>): any { | ||
getInitialValue(name: string): any { | ||
return invariant( | ||
@@ -84,3 +84,3 @@ false, | ||
this.constructor.name, | ||
{ name, props }, | ||
{ name }, | ||
); | ||
@@ -87,0 +87,0 @@ } |
@@ -43,3 +43,2 @@ import { FilterDOMProps } from '.'; | ||
'fields', | ||
'initialCount', | ||
'name', | ||
@@ -46,0 +45,0 @@ 'onChange', |
@@ -95,3 +95,2 @@ import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
fields: never; | ||
initialCount: never; | ||
label: never; | ||
@@ -98,0 +97,0 @@ name: never; |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
220326
5121
2