Comparing version 3.0.0-rc.8 to 3.0.0
@@ -29,2 +29,3 @@ "use strict"; | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
AutoForm.prototype.getModel = function (mode) { | ||
@@ -31,0 +32,0 @@ return this.state.model; |
@@ -42,2 +42,3 @@ "use strict"; | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
BaseForm.prototype.componentDidUpdate = function (prevProps, prevState, snapshot) { }; | ||
@@ -44,0 +45,0 @@ BaseForm.prototype.componentWillUnmount = function () { |
import { ComponentType } from 'react'; | ||
import { connectField } from './connectField'; | ||
import { Override } from './types'; | ||
import { Context, Override } from './types'; | ||
import { useField } from './useField'; | ||
@@ -10,7 +10,8 @@ declare type AutoFieldProps = Override<Record<string, unknown>, { | ||
declare type Component = ComponentType<any> | ReturnType<typeof connectField>; | ||
declare type ComponentDetector = (props: ReturnType<typeof useField>[0]) => Component; | ||
declare type ComponentDetector = (props: ReturnType<typeof useField>[0], uniforms: Context<unknown>) => Component; | ||
export declare function createAutoField(defaultComponentDetector: ComponentDetector): { | ||
AutoField: (originalProps: AutoFieldProps) => import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
AutoFieldContext: import("react").Context<ComponentDetector>; | ||
(rawProps: AutoFieldProps): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
componentDetectorContext: import("react").Context<ComponentDetector>; | ||
defaultComponentDetector: ComponentDetector; | ||
}; | ||
export {}; |
@@ -10,14 +10,16 @@ "use strict"; | ||
var context = react_1.createContext(defaultComponentDetector); | ||
function AutoField(originalProps) { | ||
function AutoField(rawProps) { | ||
var _a, _b; | ||
var props = useField_1.useField(originalProps.name, originalProps)[0]; | ||
var _c = useField_1.useField(rawProps.name, rawProps), props = _c[0], uniforms = _c[1]; | ||
var componentDetector = react_1.useContext(context); | ||
var component = (_a = props.component) !== null && _a !== void 0 ? _a : componentDetector(props); | ||
var component = (_a = props.component) !== null && _a !== void 0 ? _a : 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' | ||
? react_1.createElement(component.Component, props) | ||
: react_1.createElement(component, originalProps); | ||
: react_1.createElement(component, rawProps); | ||
} | ||
return { AutoField: AutoField, AutoFieldContext: context }; | ||
AutoField.componentDetectorContext = context; | ||
AutoField.defaultComponentDetector = defaultComponentDetector; | ||
return AutoField; | ||
} | ||
exports.createAutoField = createAutoField; |
import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
import { Bridge } from './Bridge'; | ||
export declare type ChangedMap<T> = T extends {} ? { | ||
export declare type ChangedMap<T> = T extends object ? { | ||
[P in keyof T]?: ChangedMap<T[P]>; | ||
@@ -26,5 +26,5 @@ } : Record<string, void>; | ||
export declare type DeepPartial<T> = { | ||
[P in keyof T]?: T[P] extends {} ? DeepPartial<T[P]> : T[P]; | ||
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; | ||
}; | ||
export declare type FieldProps<Value, Base, Extension = {}> = Override<Base, GuaranteedProps<Value> & Extension>; | ||
export declare type FieldProps<Value, Base, Extension = object> = Override<Base, GuaranteedProps<Value> & Extension>; | ||
export interface FilterDOMProps { | ||
@@ -48,3 +48,3 @@ } | ||
}; | ||
export declare type HTMLFieldProps<Value, Element, Extension = {}> = FieldProps<Value, HTMLProps<Element>, Extension>; | ||
export declare type HTMLFieldProps<Value, Element, Extension = object> = FieldProps<Value, HTMLProps<Element>, Extension>; | ||
export declare type ModelTransformMode = 'form' | 'submit' | 'validate'; | ||
@@ -51,0 +51,0 @@ export declare type Override<T, U> = U & Omit<T, keyof U>; |
@@ -23,2 +23,3 @@ import clone from 'lodash/clone'; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
getModel(mode) { | ||
@@ -25,0 +26,0 @@ return this.state.model; |
@@ -33,2 +33,3 @@ import clone from 'lodash/clone'; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
componentDidUpdate(prevProps, prevState, snapshot) { } | ||
@@ -35,0 +36,0 @@ componentWillUnmount() { |
import { ComponentType } from 'react'; | ||
import { connectField } from './connectField'; | ||
import { Override } from './types'; | ||
import { Context, Override } from './types'; | ||
import { useField } from './useField'; | ||
@@ -10,7 +10,8 @@ declare type AutoFieldProps = Override<Record<string, unknown>, { | ||
declare type Component = ComponentType<any> | ReturnType<typeof connectField>; | ||
declare type ComponentDetector = (props: ReturnType<typeof useField>[0]) => Component; | ||
declare type ComponentDetector = (props: ReturnType<typeof useField>[0], uniforms: Context<unknown>) => Component; | ||
export declare function createAutoField(defaultComponentDetector: ComponentDetector): { | ||
AutoField: (originalProps: AutoFieldProps) => import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
AutoFieldContext: import("react").Context<ComponentDetector>; | ||
(rawProps: AutoFieldProps): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
componentDetectorContext: import("react").Context<ComponentDetector>; | ||
defaultComponentDetector: ComponentDetector; | ||
}; | ||
export {}; |
@@ -6,13 +6,15 @@ import invariant from 'invariant'; | ||
const context = createContext(defaultComponentDetector); | ||
function AutoField(originalProps) { | ||
function AutoField(rawProps) { | ||
var _a, _b; | ||
const props = useField(originalProps.name, originalProps)[0]; | ||
const [props, uniforms] = useField(rawProps.name, rawProps); | ||
const componentDetector = useContext(context); | ||
const component = (_a = props.component) !== null && _a !== void 0 ? _a : componentDetector(props); | ||
const component = (_a = props.component) !== null && _a !== void 0 ? _a : 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' | ||
? createElement(component.Component, props) | ||
: createElement(component, originalProps); | ||
: createElement(component, rawProps); | ||
} | ||
return { AutoField, AutoFieldContext: context }; | ||
AutoField.componentDetectorContext = context; | ||
AutoField.defaultComponentDetector = defaultComponentDetector; | ||
return AutoField; | ||
} |
import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
import { Bridge } from './Bridge'; | ||
export declare type ChangedMap<T> = T extends {} ? { | ||
export declare type ChangedMap<T> = T extends object ? { | ||
[P in keyof T]?: ChangedMap<T[P]>; | ||
@@ -26,5 +26,5 @@ } : Record<string, void>; | ||
export declare type DeepPartial<T> = { | ||
[P in keyof T]?: T[P] extends {} ? DeepPartial<T[P]> : T[P]; | ||
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; | ||
}; | ||
export declare type FieldProps<Value, Base, Extension = {}> = Override<Base, GuaranteedProps<Value> & Extension>; | ||
export declare type FieldProps<Value, Base, Extension = object> = Override<Base, GuaranteedProps<Value> & Extension>; | ||
export interface FilterDOMProps { | ||
@@ -48,3 +48,3 @@ } | ||
}; | ||
export declare type HTMLFieldProps<Value, Element, Extension = {}> = FieldProps<Value, HTMLProps<Element>, Extension>; | ||
export declare type HTMLFieldProps<Value, Element, Extension = object> = FieldProps<Value, HTMLProps<Element>, Extension>; | ||
export declare type ModelTransformMode = 'form' | 'submit' | 'validate'; | ||
@@ -51,0 +51,0 @@ export declare type Override<T, U> = U & Omit<T, keyof U>; |
{ | ||
"name": "uniforms", | ||
"version": "3.0.0-rc.8", | ||
"version": "3.0.0", | ||
"license": "MIT", | ||
@@ -35,3 +35,3 @@ "main": "es5/index.js", | ||
}, | ||
"gitHead": "218bdd0f64c660d1ddfb22d45ff3916e03c5a31e" | ||
"gitHead": "c6748de4f87536440f05024e4d826b64e27d1d73" | ||
} |
@@ -5,3 +5,3 @@ import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
export type ChangedMap<T> = T extends {} | ||
export type ChangedMap<T> = T extends object | ||
? { [P in keyof T]?: ChangedMap<T[P]> } | ||
@@ -31,6 +31,6 @@ : Record<string, void>; | ||
export type DeepPartial<T> = { | ||
[P in keyof T]?: T[P] extends {} ? DeepPartial<T[P]> : T[P]; | ||
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; | ||
}; | ||
export type FieldProps<Value, Base, Extension = {}> = Override< | ||
export type FieldProps<Value, Base, Extension = object> = Override< | ||
Base, | ||
@@ -60,3 +60,3 @@ GuaranteedProps<Value> & Extension | ||
export type HTMLFieldProps<Value, Element, Extension = {}> = FieldProps< | ||
export type HTMLFieldProps<Value, Element, Extension = object> = FieldProps< | ||
Value, | ||
@@ -63,0 +63,0 @@ HTMLProps<Element>, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
193729
4411
1