Comparing version 3.0.0-alpha.5 to 3.0.0-rc.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AutoForm = exports.Auto = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -33,4 +34,4 @@ var clone_1 = tslib_1.__importDefault(require("lodash/clone")); | ||
var _this = this; | ||
_super.prototype.onChange.call(this, key, value); | ||
this.setState(function (state) { return ({ model: setWith_1.default(clone_1.default(state.model), key, value, clone_1.default) }); }, function () { | ||
_super.prototype.onChange.call(_this, key, value); | ||
if (_this.props.onChangeModel) | ||
@@ -37,0 +38,0 @@ _this.props.onChangeModel(_this.state.model); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseForm = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ var react_1 = tslib_1.__importStar(require("react")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Bridge = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ var invariant_1 = tslib_1.__importDefault(require("invariant")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.changedKeys = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ var isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.connectField = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ var react_1 = tslib_1.__importDefault(require("react")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.context = void 0; | ||
var react_1 = require("react"); | ||
exports.context = react_1.createContext(null); |
@@ -1,7 +0,9 @@ | ||
declare function filter<T extends object>(props: T): Partial<T>; | ||
declare function register(...props: string[]): void; | ||
import { FilterDOMProps } from '.'; | ||
declare type FilterDOMPropsKeys = keyof FilterDOMProps; | ||
declare function filter<T extends object>(props: T): Pick<T, Exclude<keyof T, "disabled" | "label" | "changed" | "error" | "errorMessage" | "field" | "fieldType" | "fields" | "name" | "onChange" | "placeholder" | "showInlineError" | "value" | "allowedValues" | "component" | "initialCount" | "transform">>; | ||
declare function register(...props: FilterDOMPropsKeys[]): void; | ||
export declare const filterDOMProps: typeof filter & { | ||
register: typeof register; | ||
registered: readonly string[]; | ||
registered: readonly ("disabled" | "label" | "changed" | "error" | "errorMessage" | "field" | "fieldType" | "fields" | "name" | "onChange" | "placeholder" | "showInlineError" | "value" | "allowedValues" | "component" | "initialCount" | "transform")[]; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.filterDOMProps = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -7,25 +8,3 @@ var pickBy_1 = tslib_1.__importDefault(require("lodash/pickBy")); | ||
var sortedIndexOf_1 = tslib_1.__importDefault(require("lodash/sortedIndexOf")); | ||
var registered = [ | ||
// These props are provided by useField directly. | ||
'changed', | ||
'error', | ||
'errorMessage', | ||
'field', | ||
'fieldType', | ||
'fields', | ||
'initialCount', | ||
'name', | ||
'onChange', | ||
'transform', | ||
'value', | ||
// These props are provided by useField through context.state. | ||
'disabled', | ||
'label', | ||
'placeholder', | ||
'showInlineError', | ||
// This is used by AutoField. | ||
'component', | ||
// These is used by AutoField and bridges. | ||
'allowedValues', | ||
].sort(); | ||
var registered = []; | ||
function filter(props) { | ||
@@ -52,1 +31,10 @@ return pickBy_1.default(props, filterOne); | ||
}); | ||
register( | ||
// These props are provided by useField directly. | ||
'changed', 'error', 'errorMessage', 'field', 'fieldType', 'fields', 'initialCount', 'name', 'onChange', 'transform', 'value', | ||
// These props are provided by useField through context.state. | ||
'disabled', 'label', 'placeholder', 'showInlineError', | ||
// This is used by AutoField. | ||
'component', | ||
// These is used by AutoField and bridges. | ||
'allowedValues'); |
@@ -16,3 +16,4 @@ "use strict"; | ||
tslib_1.__exportStar(require("./randomIds"), exports); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
tslib_1.__exportStar(require("./useField"), exports); | ||
tslib_1.__exportStar(require("./useForm"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.joinName = void 0; | ||
function joinName() { | ||
@@ -4,0 +5,0 @@ var parts = []; |
@@ -14,7 +14,7 @@ import React, { ComponentType } from 'react'; | ||
getNativeFormProps(): Record<string, any>; | ||
getAutoField(): React.ComponentType<{ | ||
getAutoField(): ComponentType<{ | ||
name: string; | ||
}>; | ||
getErrorsField(): React.ComponentType<{}>; | ||
getSubmitField(): React.ComponentType<{}>; | ||
getErrorsField(): ComponentType; | ||
getSubmitField(): ComponentType; | ||
componentDidMount(): void; | ||
@@ -84,7 +84,7 @@ componentDidUpdate(prevProps: Props, prevState: State, snapshot: never): void; | ||
getNativeFormProps(): Record<string, any>; | ||
getAutoField(): React.ComponentType<{ | ||
getAutoField(): ComponentType<{ | ||
name: string; | ||
}>; | ||
getErrorsField(): React.ComponentType<{}>; | ||
getSubmitField(): React.ComponentType<{}>; | ||
getErrorsField(): ComponentType; | ||
getSubmitField(): ComponentType; | ||
componentDidMount(): void; | ||
@@ -91,0 +91,0 @@ componentDidUpdate(prevProps: Props, prevState: State, snapshot: never): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.QuickForm = exports.Quick = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ var react_1 = tslib_1.__importDefault(require("react")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.randomIds = void 0; | ||
// Workaround for SSR | ||
@@ -4,0 +5,0 @@ // https://github.com/vazco/uniforms/issues/40 |
@@ -1,2 +0,2 @@ | ||
import { SyntheticEvent } from 'react'; | ||
import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
import { Bridge } from './Bridge'; | ||
@@ -28,2 +28,5 @@ export declare type ChangedMap<T> = T extends {} ? { | ||
}; | ||
export declare type FieldProps<Value, Base, Extension = {}> = Override<Base, GuaranteedProps<Value> & Extension>; | ||
export interface FilterDOMProps { | ||
} | ||
export declare type GuaranteedProps<Value> = { | ||
@@ -38,3 +41,3 @@ changed: boolean; | ||
id: string; | ||
label: string; | ||
label: ReactNode; | ||
name: string; | ||
@@ -46,2 +49,3 @@ onChange(value?: Value, name?: string): void; | ||
}; | ||
export declare type HTMLFieldProps<Value, Element, Extension = {}> = FieldProps<Value, HTMLProps<Element>, Extension>; | ||
export declare type ModelTransformMode = 'form' | 'submit' | 'validate'; | ||
@@ -51,1 +55,22 @@ export declare type Override<T, U> = U & Omit<T, keyof U>; | ||
export declare type ValidateMode = 'onChange' | 'onChangeAfterSubmit' | 'onSubmit'; | ||
declare module '.' { | ||
interface FilterDOMProps { | ||
allowedValues: never; | ||
changed: never; | ||
component: never; | ||
disabled: never; | ||
error: never; | ||
errorMessage: never; | ||
field: never; | ||
fieldType: never; | ||
fields: never; | ||
initialCount: never; | ||
label: never; | ||
name: never; | ||
onChange: never; | ||
placeholder: never; | ||
showInlineError: never; | ||
transform: never; | ||
value: never; | ||
} | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useField = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ var get_1 = tslib_1.__importDefault(require("lodash/get")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useForm = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ var invariant_1 = tslib_1.__importDefault(require("invariant")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ValidatedForm = exports.Validated = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -101,4 +102,4 @@ var clone_1 = tslib_1.__importDefault(require("lodash/clone")); | ||
return then(_this.props.onValidate(model, error), function (error) { | ||
var _a; | ||
if (error === void 0) { error = null; } | ||
var _a; | ||
// Do not copy the error from props to the state. | ||
@@ -105,0 +106,0 @@ error = _this.props.error === error ? null : error; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ValidatedQuickForm = void 0; | ||
var BaseForm_1 = require("./BaseForm"); | ||
@@ -4,0 +5,0 @@ var QuickForm_1 = require("./QuickForm"); |
@@ -27,4 +27,4 @@ import clone from 'lodash/clone'; | ||
onChange(key, value) { | ||
super.onChange(key, value); | ||
this.setState(state => ({ model: setWith(clone(state.model), key, value, clone) }), () => { | ||
super.onChange(key, value); | ||
if (this.props.onChangeModel) | ||
@@ -31,0 +31,0 @@ this.props.onChangeModel(this.state.model); |
@@ -1,7 +0,9 @@ | ||
declare function filter<T extends object>(props: T): Partial<T>; | ||
declare function register(...props: string[]): void; | ||
import { FilterDOMProps } from '.'; | ||
declare type FilterDOMPropsKeys = keyof FilterDOMProps; | ||
declare function filter<T extends object>(props: T): Pick<T, Exclude<keyof T, "disabled" | "label" | "changed" | "error" | "errorMessage" | "field" | "fieldType" | "fields" | "name" | "onChange" | "placeholder" | "showInlineError" | "value" | "allowedValues" | "component" | "initialCount" | "transform">>; | ||
declare function register(...props: FilterDOMPropsKeys[]): void; | ||
export declare const filterDOMProps: typeof filter & { | ||
register: typeof register; | ||
registered: readonly string[]; | ||
registered: readonly ("disabled" | "label" | "changed" | "error" | "errorMessage" | "field" | "fieldType" | "fields" | "name" | "onChange" | "placeholder" | "showInlineError" | "value" | "allowedValues" | "component" | "initialCount" | "transform")[]; | ||
}; | ||
export {}; |
import pickBy from 'lodash/pickBy'; | ||
import sortedIndex from 'lodash/sortedIndex'; | ||
import sortedIndexOf from 'lodash/sortedIndexOf'; | ||
const registered = [ | ||
// These props are provided by useField directly. | ||
'changed', | ||
'error', | ||
'errorMessage', | ||
'field', | ||
'fieldType', | ||
'fields', | ||
'initialCount', | ||
'name', | ||
'onChange', | ||
'transform', | ||
'value', | ||
// These props are provided by useField through context.state. | ||
'disabled', | ||
'label', | ||
'placeholder', | ||
'showInlineError', | ||
// This is used by AutoField. | ||
'component', | ||
// These is used by AutoField and bridges. | ||
'allowedValues', | ||
].sort(); | ||
const registered = []; | ||
function filter(props) { | ||
@@ -44,1 +22,10 @@ return pickBy(props, filterOne); | ||
}); | ||
register( | ||
// These props are provided by useField directly. | ||
'changed', 'error', 'errorMessage', 'field', 'fieldType', 'fields', 'initialCount', 'name', 'onChange', 'transform', 'value', | ||
// These props are provided by useField through context.state. | ||
'disabled', 'label', 'placeholder', 'showInlineError', | ||
// This is used by AutoField. | ||
'component', | ||
// These is used by AutoField and bridges. | ||
'allowedValues'); |
@@ -13,3 +13,4 @@ export * from './AutoForm'; | ||
export * from './randomIds'; | ||
export * from './types'; | ||
export * from './useField'; | ||
export * from './useForm'; |
@@ -14,7 +14,7 @@ import React, { ComponentType } from 'react'; | ||
getNativeFormProps(): Record<string, any>; | ||
getAutoField(): React.ComponentType<{ | ||
getAutoField(): ComponentType<{ | ||
name: string; | ||
}>; | ||
getErrorsField(): React.ComponentType<{}>; | ||
getSubmitField(): React.ComponentType<{}>; | ||
getErrorsField(): ComponentType; | ||
getSubmitField(): ComponentType; | ||
componentDidMount(): void; | ||
@@ -84,7 +84,7 @@ componentDidUpdate(prevProps: Props, prevState: State, snapshot: never): void; | ||
getNativeFormProps(): Record<string, any>; | ||
getAutoField(): React.ComponentType<{ | ||
getAutoField(): ComponentType<{ | ||
name: string; | ||
}>; | ||
getErrorsField(): React.ComponentType<{}>; | ||
getSubmitField(): React.ComponentType<{}>; | ||
getErrorsField(): ComponentType; | ||
getSubmitField(): ComponentType; | ||
componentDidMount(): void; | ||
@@ -91,0 +91,0 @@ componentDidUpdate(prevProps: Props, prevState: State, snapshot: never): void; |
@@ -1,2 +0,2 @@ | ||
import { SyntheticEvent } from 'react'; | ||
import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
import { Bridge } from './Bridge'; | ||
@@ -28,2 +28,5 @@ export declare type ChangedMap<T> = T extends {} ? { | ||
}; | ||
export declare type FieldProps<Value, Base, Extension = {}> = Override<Base, GuaranteedProps<Value> & Extension>; | ||
export interface FilterDOMProps { | ||
} | ||
export declare type GuaranteedProps<Value> = { | ||
@@ -38,3 +41,3 @@ changed: boolean; | ||
id: string; | ||
label: string; | ||
label: ReactNode; | ||
name: string; | ||
@@ -46,2 +49,3 @@ onChange(value?: Value, name?: string): void; | ||
}; | ||
export declare type HTMLFieldProps<Value, Element, Extension = {}> = FieldProps<Value, HTMLProps<Element>, Extension>; | ||
export declare type ModelTransformMode = 'form' | 'submit' | 'validate'; | ||
@@ -51,1 +55,22 @@ export declare type Override<T, U> = U & Omit<T, keyof U>; | ||
export declare type ValidateMode = 'onChange' | 'onChangeAfterSubmit' | 'onSubmit'; | ||
declare module '.' { | ||
interface FilterDOMProps { | ||
allowedValues: never; | ||
changed: never; | ||
component: never; | ||
disabled: never; | ||
error: never; | ||
errorMessage: never; | ||
field: never; | ||
fieldType: never; | ||
fields: never; | ||
initialCount: never; | ||
label: never; | ||
name: never; | ||
onChange: never; | ||
placeholder: never; | ||
showInlineError: never; | ||
transform: never; | ||
value: never; | ||
} | ||
} |
{ | ||
"name": "uniforms", | ||
"version": "3.0.0-alpha.5", | ||
"version": "3.0.0-rc.0", | ||
"license": "MIT", | ||
@@ -35,3 +35,3 @@ "main": "es5/index.js", | ||
}, | ||
"gitHead": "dc48cb023e00503430cc3879c9bf28fac2e1257c" | ||
"gitHead": "446ab9bd202f14644854afc628bd68b0eef0ecef" | ||
} |
@@ -5,3 +5,30 @@ import pickBy from 'lodash/pickBy'; | ||
const registered = [ | ||
import { FilterDOMProps } from '.'; | ||
type FilterDOMPropsKeys = keyof FilterDOMProps; | ||
const registered: FilterDOMPropsKeys[] = []; | ||
function filter<T extends object>(props: T) { | ||
return pickBy(props, filterOne) as Omit<T, FilterDOMPropsKeys>; | ||
} | ||
function filterOne(value: unknown, prop: string) { | ||
return sortedIndexOf(registered, prop) === -1; | ||
} | ||
function register(...props: FilterDOMPropsKeys[]) { | ||
props.forEach(prop => { | ||
if (sortedIndexOf(registered, prop) === -1) { | ||
registered.splice(sortedIndex(registered, prop), 0, prop); | ||
} | ||
}); | ||
} | ||
export const filterDOMProps = Object.assign(filter, { | ||
register, | ||
registered: registered as readonly FilterDOMPropsKeys[], | ||
}); | ||
register( | ||
// These props are provided by useField directly. | ||
@@ -31,23 +58,2 @@ 'changed', | ||
'allowedValues', | ||
].sort(); | ||
function filter<T extends object>(props: T) { | ||
return pickBy(props, filterOne); | ||
} | ||
function filterOne(value: unknown, prop: string) { | ||
return sortedIndexOf(registered, prop) === -1; | ||
} | ||
function register(...props: string[]) { | ||
props.forEach(prop => { | ||
if (sortedIndexOf(registered, prop) === -1) { | ||
registered.splice(sortedIndex(registered, prop), 0, prop); | ||
} | ||
}); | ||
} | ||
export const filterDOMProps = Object.assign(filter, { | ||
register, | ||
registered: registered as readonly string[], | ||
}); | ||
); |
@@ -1,2 +0,2 @@ | ||
import { SyntheticEvent } from 'react'; | ||
import { HTMLProps, ReactNode, SyntheticEvent } from 'react'; | ||
@@ -33,2 +33,10 @@ import { Bridge } from './Bridge'; | ||
export type FieldProps<Value, Base, Extension = {}> = Override< | ||
Base, | ||
GuaranteedProps<Value> & Extension | ||
>; | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface FilterDOMProps {} | ||
export type GuaranteedProps<Value> = { | ||
@@ -43,3 +51,3 @@ changed: boolean; | ||
id: string; | ||
label: string; | ||
label: ReactNode; | ||
name: string; | ||
@@ -52,2 +60,8 @@ onChange(value?: Value, name?: string): void; | ||
export type HTMLFieldProps<Value, Element, Extension = {}> = FieldProps< | ||
Value, | ||
HTMLProps<Element>, | ||
Extension | ||
>; | ||
export type ModelTransformMode = 'form' | 'submit' | 'validate'; | ||
@@ -60,1 +74,25 @@ | ||
export type ValidateMode = 'onChange' | 'onChangeAfterSubmit' | 'onSubmit'; | ||
// Explicit declaration to allow users extend it directly. | ||
// Would it be possible not to use `declare` here? | ||
declare module '.' { | ||
interface FilterDOMProps { | ||
allowedValues: never; | ||
changed: never; | ||
component: never; | ||
disabled: never; | ||
error: never; | ||
errorMessage: never; | ||
field: never; | ||
fieldType: never; | ||
fields: never; | ||
initialCount: never; | ||
label: never; | ||
name: never; | ||
onChange: never; | ||
placeholder: never; | ||
showInlineError: never; | ||
transform: never; | ||
value: never; | ||
} | ||
} |
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
180630
83
4196