react-form-with-constraints
Advanced tools
Comparing version 0.14.3-beta.1 to 0.14.3-beta.2
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { FieldFeedbacksChildContext } from './FieldFeedbacks'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import { InputElement } from './InputElement'; | ||
@@ -30,3 +30,3 @@ export declare enum Status { | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation>; | ||
emitValidateFieldEvent(input: InputElement): Promise<FieldFeedbackValidation[]>; | ||
@@ -33,0 +33,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | Promise<FieldFeedbackValidation>): void; |
@@ -1,1 +0,1 @@ | ||
export declare function clearArray<T>(array: T[]): void; | ||
export default function clearArray<T>(array: T[]): void; |
import * as React from 'react'; | ||
export declare function deepForEach(children: React.ReactNode, fn: (child: React.ReactElement<any>) => void): void; | ||
export default function deepForEach(children: React.ReactNode, fn: (child: React.ReactElement<any>) => void): void; |
declare type Args = any[]; | ||
declare type Listener<ListenerReturnType = void> = (...args: Args) => ListenerReturnType | Promise<ListenerReturnType>; | ||
export declare class EventEmitter<ListenerReturnType = void> { | ||
export default class EventEmitter<ListenerReturnType = void> { | ||
listeners: Map<string, Listener<ListenerReturnType>[]>; | ||
@@ -5,0 +5,0 @@ emit(eventName: string, ...args: Args): Promise<ListenerReturnType[]>; |
@@ -1,5 +0,5 @@ | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
import { TextInput, HTMLInput } from './InputElement'; | ||
export declare class Field { | ||
export default class Field { | ||
readonly name: string; | ||
@@ -6,0 +6,0 @@ readonly validations: FieldFeedbackValidation[]; |
@@ -6,6 +6,6 @@ import * as React from 'react'; | ||
import { InputElement } from './InputElement'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import { Field } from './Field'; | ||
import { Nullable } from './Nullable'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
import Field from './Field'; | ||
import Nullable from './Nullable'; | ||
declare type WhenString = 'valid' | '*' | 'badInput' | 'patternMismatch' | 'rangeOverflow' | 'rangeUnderflow' | 'stepMismatch' | 'tooLong' | 'tooShort' | 'typeMismatch' | 'valueMissing'; | ||
@@ -12,0 +12,0 @@ declare type WhenFn = (value: string) => boolean; |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { InputElement } from './InputElement'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { Nullable } from './Nullable'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import Nullable from './Nullable'; | ||
export interface FieldFeedbacksProps { | ||
@@ -18,3 +18,3 @@ for?: string; | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
emitValidateFieldEvent(input: InputElement): Promise<(FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined)[]>; | ||
@@ -21,0 +21,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | Promise<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined> | undefined): void; |
@@ -1,2 +0,2 @@ | ||
export declare enum FieldFeedbackType { | ||
declare enum FieldFeedbackType { | ||
Error = "error", | ||
@@ -7,1 +7,2 @@ Warning = "warning", | ||
} | ||
export default FieldFeedbackType; |
@@ -5,3 +5,3 @@ import * as React from 'react'; | ||
import { FieldFeedbackClasses } from './FieldFeedback'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
export interface FieldFeedbackWhenValidBaseProps { | ||
@@ -8,0 +8,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { Field } from './Field'; | ||
import { EventEmitter } from './EventEmitter'; | ||
import Field from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
export declare enum FieldEvent { | ||
@@ -4,0 +4,0 @@ Added = "FIELD_ADDED", |
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> { | ||
} | ||
export declare function flattenDeep<T>(arrayOfArrays: RecursiveArray<T>): T[]; | ||
export default function flattenDeep<T>(arrayOfArrays: RecursiveArray<T>): T[]; | ||
export {}; |
import * as React from 'react'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
import { IHTMLInput, InputElement } from './InputElement'; | ||
import { FieldsStore } from './FieldsStore'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
export interface FormWithConstraintsChildContext { | ||
@@ -15,3 +15,3 @@ form: FormWithConstraints; | ||
new (...args: any[]): { | ||
fieldDidResetEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldDidResetEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldDidResetEvent(field: Field): Promise<void[]>; | ||
@@ -23,3 +23,3 @@ addFieldDidResetEventListener(listener: (field: Field) => void): void; | ||
new (...args: any[]): { | ||
fieldWillValidateEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldWillValidateEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldWillValidateEvent(fieldName: string): Promise<void[]>; | ||
@@ -31,3 +31,3 @@ addFieldWillValidateEventListener(listener: (fieldName: string) => void): void; | ||
new (...args: any[]): { | ||
fieldDidValidateEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldDidValidateEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldDidValidateEvent(field: Field): Promise<void[]>; | ||
@@ -39,3 +39,3 @@ addFieldDidValidateEventListener(listener: (field: Field) => void): void; | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
emitValidateFieldEvent(input: InputElement): Promise<(FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined)[]>; | ||
@@ -42,0 +42,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | Promise<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined> | undefined): void; |
export * from './FormWithConstraints'; | ||
export * from './FieldFeedbacks'; | ||
export * from './FieldFeedback'; | ||
export * from './FieldFeedbackType'; | ||
export { default as FieldFeedbackType } from './FieldFeedbackType'; | ||
export * from './FieldFeedbackWhenValid'; | ||
export * from './Async'; | ||
export * from './Field'; | ||
export { default as Field } from './Field'; | ||
export * from './FieldsStore'; | ||
export * from './EventEmitter'; | ||
export { default as EventEmitter } from './EventEmitter'; | ||
export * from './withValidateFieldEventEmitter'; | ||
@@ -14,6 +14,6 @@ export * from './withFieldWillValidateEventEmitter'; | ||
export * from './withFieldDidResetEventEmitter'; | ||
export * from './FieldFeedbackValidation'; | ||
export { default as FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
export * from './InputElement'; | ||
export * from './Constructor'; | ||
export { default as Constructor } from './Constructor'; | ||
export * from './Input'; | ||
export * from './deepForEach'; | ||
export { default as deepForEach } from './deepForEach'; |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> { | ||
@@ -5,0 +5,0 @@ innerRef?: React.Ref<HTMLInputElement>; |
@@ -1,1 +0,1 @@ | ||
export declare function notUndefined<T>(value: T | undefined): value is T; | ||
export default function notUndefined<T>(value: T | undefined): value is T; |
@@ -288,2 +288,3 @@ (function (global, factory) { | ||
var FieldFeedbackType; | ||
(function (FieldFeedbackType) { | ||
@@ -294,3 +295,4 @@ FieldFeedbackType["Error"] = "error"; | ||
FieldFeedbackType["WhenValid"] = "whenValid"; | ||
})(exports.FieldFeedbackType || (exports.FieldFeedbackType = {})); | ||
})(FieldFeedbackType || (FieldFeedbackType = {})); | ||
var FieldFeedbackType$1 = FieldFeedbackType; | ||
@@ -327,9 +329,9 @@ function clearArray(array) { | ||
Field.prototype.hasErrors = function (fieldFeedbacksKey) { | ||
return this.hasFeedbacksOfType(exports.FieldFeedbackType.Error, fieldFeedbacksKey); | ||
return this.hasFeedbacksOfType(FieldFeedbackType$1.Error, fieldFeedbacksKey); | ||
}; | ||
Field.prototype.hasWarnings = function (fieldFeedbacksKey) { | ||
return this.hasFeedbacksOfType(exports.FieldFeedbackType.Warning, fieldFeedbacksKey); | ||
return this.hasFeedbacksOfType(FieldFeedbackType$1.Warning, fieldFeedbacksKey); | ||
}; | ||
Field.prototype.hasInfos = function (fieldFeedbacksKey) { | ||
return this.hasFeedbacksOfType(exports.FieldFeedbackType.Info, fieldFeedbacksKey); | ||
return this.hasFeedbacksOfType(FieldFeedbackType$1.Info, fieldFeedbacksKey); | ||
}; | ||
@@ -930,10 +932,10 @@ Field.prototype.hasFeedbacks = function (fieldFeedbacksKey) { | ||
var error = props.error, warning = props.warning, info = props.info, when = props.when; | ||
var type = exports.FieldFeedbackType.Error; | ||
var type = FieldFeedbackType$1.Error; | ||
if (when === 'valid') | ||
type = exports.FieldFeedbackType.WhenValid; | ||
type = FieldFeedbackType$1.WhenValid; | ||
else if (warning) | ||
type = exports.FieldFeedbackType.Warning; | ||
type = FieldFeedbackType$1.Warning; | ||
else if (info) | ||
type = exports.FieldFeedbackType.Info; | ||
if (type === exports.FieldFeedbackType.WhenValid && (error || warning || info)) { | ||
type = FieldFeedbackType$1.Info; | ||
if (type === FieldFeedbackType$1.WhenValid && (error || warning || info)) { | ||
throw new Error('Cannot have an attribute (error, warning...) with FieldFeedback when="valid"'); | ||
@@ -973,3 +975,3 @@ } | ||
var classNames = className !== undefined ? className + " " + fieldFeedbackClassName : fieldFeedbackClassName; | ||
if (validation.type === exports.FieldFeedbackType.WhenValid) { | ||
if (validation.type === FieldFeedbackType$1.WhenValid) { | ||
return (React.createElement(FieldFeedbackWhenValid, __assign({ "data-feedback": this.key, style: style, className: classNames }, otherProps), children)); | ||
@@ -1102,2 +1104,3 @@ } | ||
exports.FieldFeedback = FieldFeedback; | ||
exports.FieldFeedbackType = FieldFeedbackType$1; | ||
exports.FieldFeedbackWhenValid = FieldFeedbackWhenValid; | ||
@@ -1104,0 +1107,0 @@ exports.FieldFeedbacks = FieldFeedbacks; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t((e=e||self).ReactFormWithConstraints={},e.React,e.PropTypes)}(this,function(u,p,e){"use strict";var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function r(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var h=function(){return(h=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function v(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]])}return i}function d(a,s,o,l){return new(o=o||Promise)(function(e,t){function i(e){try{r(l.next(e))}catch(e){t(e)}}function n(e){try{r(l.throw(e))}catch(e){t(e)}}function r(t){t.done?e(t.value):new o(function(e){e(t.value)}).then(i,n)}r((l=l.apply(a,s||[])).next())})}function c(i,n){var r,a,s,e,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,a&&(s=2&t[0]?a.return:t[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch(a=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return o.label++,{value:t[1],done:!1};case 5:o.label++,a=t[1],t=[0];continue;case 7:t=o.ops.pop(),o.trys.pop();continue;default:if(!(s=0<(s=o.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){o=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){o.label=t[1];break}if(6===t[0]&&o.label<s[1]){o.label=s[1],s=t;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(t);break}s[2]&&o.ops.pop(),o.trys.pop();continue}t=n.call(i,o)}catch(e){t=[6,e],a=0}finally{r=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function i(){for(var e=0,t=0,i=arguments.length;t<i;t++)e+=arguments[t].length;var n=Array(e),r=0;for(t=0;t<i;t++)for(var a=arguments[t],s=0,o=a.length;s<o;s++,r++)n[r]=a[s];return n}var a=(t.prototype.emit=function(o){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return d(this,void 0,void 0,function(){var t,i,n,r,a,s;return c(this,function(e){switch(e.label){case 0:if(t=this.listeners.get(o),i=new Array,void 0===t)return[3,4];console.assert(0<t.length,"No listener for event '"+o+"'"),n=0,e.label=1;case 1:return n<t.length?(r=t[n],s=(a=i).push,[4,r.apply(void 0,l)]):[3,4];case 2:s.apply(a,[e.sent()]),e.label=3;case 3:return n++,[3,1];case 4:return[2,i]}})})},t.prototype.addListener=function(e,t){this.listeners.has(e)||this.listeners.set(e,[]);var i=this.listeners.get(e);console.assert(-1===i.indexOf(t),"Listener already added for event '"+e+"'"),i.push(t)},t.prototype.removeListener=function(e,t){var i=this.listeners.get(e);console.assert(void 0!==i,"Unknown event '"+e+"'");var n=i.lastIndexOf(t);console.assert(-1<n,"Listener not found for event '"+e+"'"),i.splice(n,1),0===i.length&&this.listeners.delete(e)},t);function t(){this.listeners=new Map}var s="VALIDATE_FIELD_EVENT";function o(e){return r(t,i=e),t.prototype.emitValidateFieldEvent=function(e){return this.validateFieldEventEmitter.emit(s,e)},t.prototype.addValidateFieldEventListener=function(e){this.validateFieldEventEmitter.addListener(s,e)},t.prototype.removeValidateFieldEventListener=function(e){this.validateFieldEventEmitter.removeListener(s,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.validateFieldEventEmitter=new a,e}var i}var l="FIELD_WILL_VALIDATE_EVENT";function f(e){return r(t,i=e),t.prototype.emitFieldWillValidateEvent=function(e){return this.fieldWillValidateEventEmitter.emit(l,e)},t.prototype.addFieldWillValidateEventListener=function(e){this.fieldWillValidateEventEmitter.addListener(l,e)},t.prototype.removeFieldWillValidateEventListener=function(e){this.fieldWillValidateEventEmitter.removeListener(l,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.fieldWillValidateEventEmitter=new a,e}var i}var y="FIELD_DID_VALIDATE_EVENT";function m(e){return r(t,i=e),t.prototype.emitFieldDidValidateEvent=function(e){return this.fieldDidValidateEventEmitter.emit(y,e)},t.prototype.addFieldDidValidateEventListener=function(e){this.fieldDidValidateEventEmitter.addListener(y,e)},t.prototype.removeFieldDidValidateEventListener=function(e){this.fieldDidValidateEventEmitter.removeListener(y,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.fieldDidValidateEventEmitter=new a,e}var i}var F="FIELD_DID_RESET_EVENT";function E(e){return r(t,i=e),t.prototype.emitFieldDidResetEvent=function(e){return this.fieldDidResetEventEmitter.emit(F,e)},t.prototype.addFieldDidResetEventListener=function(e){this.fieldDidResetEventEmitter.addListener(F,e)},t.prototype.removeFieldDidResetEventListener=function(e){this.fieldDidResetEventEmitter.removeListener(F,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.fieldDidResetEventEmitter=new a,e}var i}var b=function(e){this.badInput=e.badInput,this.customError=e.customError,this.patternMismatch=e.patternMismatch,this.rangeOverflow=e.rangeOverflow,this.rangeUnderflow=e.rangeUnderflow,this.stepMismatch=e.stepMismatch,this.tooLong=e.tooLong,this.tooShort=e.tooShort,this.typeMismatch=e.typeMismatch,this.valid=e.valid,this.valueMissing=e.valueMissing};function g(e){return void 0===e.props}var k,w=function(e){g(e)?(e=e,this.name=e.name,this.type=e.type,this.value=e.value,this.validity=new b(e.validity),this.validationMessage=e.validationMessage):(e=e,this.name=e.props.name,this.type=void 0,this.value=e.props.value,this.validity=void 0,this.validationMessage=void 0)};(k=u.FieldFeedbackType||(u.FieldFeedbackType={})).Error="error",k.Warning="warning",k.Info="info",k.WhenValid="whenValid";var V,D=(L.prototype.addOrReplaceValidation=function(t){var e=this.validations.findIndex(function(e){return e.key===t.key});-1<e?this.validations[e]=t:this.validations.push(t)},L.prototype.clearValidations=function(){!function(e){for(;e.length;)e.pop()}(this.validations)},L.prototype.hasFeedbacksOfType=function(t,i){return this.validations.some(function(e){return(void 0===i||e.key.startsWith(i+"."))&&e.type===t&&!0===e.show})},L.prototype.hasErrors=function(e){return this.hasFeedbacksOfType(u.FieldFeedbackType.Error,e)},L.prototype.hasWarnings=function(e){return this.hasFeedbacksOfType(u.FieldFeedbackType.Warning,e)},L.prototype.hasInfos=function(e){return this.hasFeedbacksOfType(u.FieldFeedbackType.Info,e)},L.prototype.hasFeedbacks=function(e){return this.hasErrors(e)||this.hasWarnings(e)||this.hasInfos(e)},L.prototype.isValid=function(){return!this.hasErrors()},L);function L(e){this.name=e,this.validations=[]}(V=u.FieldEvent||(u.FieldEvent={})).Added="FIELD_ADDED",V.Removed="FIELD_REMOVED";var x,R=(r(S,x=a),S.prototype.getField=function(t){var e=this.fields.filter(function(e){return e.name===t});return 1===e.length?e[0]:void 0},S.prototype.addField=function(t){var e=this.fields.filter(function(e){return e.name===t});if(console.assert(0===e.length||1===e.length,"Cannot have more than 1 field matching '"+t+"'"),0===e.length){var i=new D(t);this.fields.push(i),this.emit(u.FieldEvent.Added,i)}},S.prototype.removeField=function(t){var e=this.fields.filter(function(e){return e.name===t}),i=this.fields.indexOf(e[0]);-1<i&&(this.fields.splice(i,1),this.emit(u.FieldEvent.Removed,t))},S.prototype.isValid=function(){return this.fields.every(function(e){return e.isValid()})},S.prototype.hasFeedbacks=function(){return this.fields.some(function(e){return e.hasFeedbacks()})},S);function S(){var e=null!==x&&x.apply(this,arguments)||this;return e.fields=new Array,e}function O(e){return e.reduce(function(e,t){return e.concat(Array.isArray(t)?O(t):t)},[])}function W(e){return void 0!==e}var I,M=(r(T,I=p.PureComponent),T);function T(){return null!==I&&I.apply(this,arguments)||this}var N,_=(r(C,N=E(f(m(o(M))))),C.prototype.getChildContext=function(){return{form:this}},C.prototype.computeFieldFeedbacksKey=function(){return""+this.fieldFeedbacksKeyCounter++},C.prototype.validateFields=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._validateFields.apply(this,i([!0],e))},C.prototype.validateForm=function(){return this.validateFieldsWithoutFeedback()},C.prototype.validateFieldsWithoutFeedback=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._validateFields.apply(this,i([!1],e))},C.prototype._validateFields=function(s){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];return d(this,void 0,void 0,function(){var t,i,n,r,a;return c(this,function(e){switch(e.label){case 0:t=new Array,i=this.normalizeInputs.apply(this,o),n=0,e.label=1;case 1:return n<i.length?(r=i[n],[4,this.validateField(s,new w(r))]):[3,4];case 2:void 0!==(a=e.sent())&&(a.element=r,t.push(a)),e.label=3;case 3:return n++,[3,1];case 4:return[2,t]}})})},C.prototype.validateField=function(r,a){return d(this,void 0,void 0,function(){var t,i,n;return c(this,function(e){switch(e.label){case 0:return t=a.name,void 0!==(i=this.fieldsStore.getField(t))?[3,1]:[3,3];case 1:return!r&&i.hasFeedbacks()?[3,3]:(i.clearValidations(),this.emitFieldWillValidateEvent(t),[4,this.emitValidateFieldEvent(a)]);case 2:n=e.sent(),console.assert(JSON.stringify(O(n).filter(W))===JSON.stringify(i.validations),"FieldsStore does not match emitValidateFieldEvent() result, did the user changed the input rapidly?"),this.emitFieldDidValidateEvent(i),e.label=3;case 3:return[2,i]}})})},C.prototype.normalizeInputs=function(){for(var e,r=this,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return 0===t.length?(e=(e=Array.from(this.form.querySelectorAll("[name]"))).filter(function(e){return void 0!==e.validity})).filter(function(e){return"checkbox"!==e.type&&"radio"!==e.type}).map(function(e){return e.name}).forEach(function(e,t,i){if(i.indexOf(e)!==t)throw new Error("Multiple elements matching '[name=\""+e+"\"]' inside the form")}):e=t.map(function(e){if("string"!=typeof e)return e;var t='[name="'+e+'"]',i=Array.from(r.form.querySelectorAll(t));if(0<i.filter(function(e){return void 0===e.validity}).length)throw new Error("'"+t+"' should match an <input>, <select> or <textarea>");if(1<i.filter(function(e){return"checkbox"!==e.type&&"radio"!==e.type}).length)throw new Error("Multiple elements matching '"+t+"' inside the form");var n=i[0];if(void 0===n)throw new Error("Could not find field '"+t+"' inside the form");return n}),e},C.prototype.isValid=function(){return this.fieldsStore.isValid()},C.prototype.hasFeedbacks=function(){return this.fieldsStore.hasFeedbacks()},C.prototype.reset=function(){return this.resetFields()},C.prototype.resetFields=function(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];return d(this,void 0,void 0,function(){var t,i,n,r,a;return c(this,function(e){switch(e.label){case 0:t=new Array,i=this.normalizeInputs.apply(this,s),n=0,e.label=1;case 1:return n<i.length?(r=i[n],[4,this.resetField(new w(r))]):[3,4];case 2:void 0!==(a=e.sent())&&t.push(a),e.label=3;case 3:return n++,[3,1];case 4:return[2,t]}})})},C.prototype.resetField=function(n){return d(this,void 0,void 0,function(){var t,i;return c(this,function(e){switch(e.label){case 0:return t=n.name,void 0!==(i=this.fieldsStore.getField(t))?[3,1]:[3,3];case 1:return i.clearValidations(),[4,this.emitFieldDidResetEvent(i)];case 2:e.sent(),e.label=3;case 3:return[2,i]}})})},C.prototype.render=function(){var t=this;return p.createElement("form",h({ref:function(e){return t.form=e}},this.props))},C.childContextTypes={form:e.instanceOf(C).isRequired},C);function C(){var e=null!==N&&N.apply(this,arguments)||this;return e.form=null,e.fieldsStore=new R,e.fieldFeedbacksKeyCounter=0,e}var A,P=(r(j,A=p.PureComponent),j);function j(){return null!==A&&A.apply(this,arguments)||this}var q,U,K=(r(z,q=o(P)),z.prototype.getChildContext=function(){return{fieldFeedbacks:this}},z.prototype.computeFieldFeedbackKey=function(){return this.key+"."+this.fieldFeedbackKeyCounter++},z.prototype.addFieldFeedback=function(){return this.computeFieldFeedbackKey()},z.prototype.componentDidMount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks;t.fieldsStore.addField(this.fieldName),(i||t).addValidateFieldEventListener(this.validate)},z.prototype.componentWillUnmount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks;t.fieldsStore.removeField(this.fieldName),(i||t).removeValidateFieldEventListener(this.validate)},z.prototype._validate=function(t){return d(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return[4,this.emitValidateFieldEvent(t)];case 1:return[2,O(e.sent())]}})})},z.prototype.render=function(){var e=this.props.children;return void 0!==e?e:null},z.defaultProps={stop:"first-error"},z.contextTypes={form:e.instanceOf(_).isRequired,fieldFeedbacks:e.instanceOf(z)},z.childContextTypes={fieldFeedbacks:e.instanceOf(z).isRequired},z);function z(e,t){var i=q.call(this,e,t)||this;i.fieldFeedbackKeyCounter=0,i.validate=function(s){return d(i,void 0,void 0,function(){var t,i,n,r,a;return c(this,function(e){switch(e.label){case 0:return(t=this.context,i=t.form,n=t.fieldFeedbacks,s.name!==this.fieldName)?[3,3]:(a=i.fieldsStore.getField(this.fieldName),n&&("first"===n.props.stop&&a.hasFeedbacks(n.key)||"first-error"===n.props.stop&&a.hasErrors(n.key)||"first-warning"===n.props.stop&&a.hasWarnings(n.key)||"first-info"===n.props.stop&&a.hasInfos(n.key))?[3,3]:[3,1]);case 1:return[4,this._validate(s)];case 2:r=e.sent(),e.label=3;case 3:return[2,r]}})})};var n=t.form,r=t.fieldFeedbacks;if(i.key=r?r.computeFieldFeedbackKey():n.computeFieldFeedbacksKey(),r){if(i.fieldName=r.fieldName,void 0!==e.for)throw new Error("FieldFeedbacks cannot have a parent and a 'for' prop")}else{if(void 0===e.for)throw new Error("FieldFeedbacks cannot be without parent and without 'for' prop");i.fieldName=e.for}return i}(U=u.Status||(u.Status={}))[U.None=0]="None",U[U.Pending=1]="Pending",U[U.Rejected=2]="Rejected",U[U.Resolved=3]="Resolved";var J,G=(r(H,J=p.PureComponent),H);function H(){return null!==J&&J.apply(this,arguments)||this}var B,Q=(r(X,B=o(G)),X.prototype.getChildContext=function(){return{async:this}},X.prototype.componentDidMount=function(){this.context.fieldFeedbacks.addValidateFieldEventListener(this.validate)},X.prototype.componentWillUnmount=function(){this.context.fieldFeedbacks.removeValidateFieldEventListener(this.validate)},X.prototype._validate=function(n){return d(this,void 0,void 0,function(){var t,i;return c(this,function(e){switch(e.label){case 0:this.setState({status:u.Status.Pending}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.props.promise(n.value)];case 2:return t=e.sent(),this.setState({status:u.Status.Resolved,value:t}),[3,4];case 3:return i=e.sent(),this.setState({status:u.Status.Rejected,value:i}),[3,4];case 4:return[2,this.emitValidateFieldEvent(n)]}})})},X.prototype.render=function(){var e=this.props,t=this.state,i=null;switch(t.status){case u.Status.None:break;case u.Status.Pending:e.pending&&(i=e.pending);break;case u.Status.Resolved:e.then&&(i=e.then(t.value));break;case u.Status.Rejected:e.catch&&(i=e.catch(t.value));break;default:console.assert(!1,"Unknown status: '"+t.status+"'")}return i},X.contextTypes={form:e.instanceOf(_).isRequired,fieldFeedbacks:e.instanceOf(K).isRequired},X.childContextTypes={async:e.instanceOf(X).isRequired},X);function X(){var s=null!==B&&B.apply(this,arguments)||this;return s.state={status:u.Status.None},s.validate=function(e){var t,i=s.context,n=i.form,r=i.fieldFeedbacks,a=n.fieldsStore.getField(e.name);return"first"===r.props.stop&&a.hasFeedbacks(r.key)||"first-error"===r.props.stop&&a.hasErrors(r.key)||"first-warning"===r.props.stop&&a.hasWarnings(r.key)||"first-info"===r.props.stop&&a.hasInfos(r.key)?s.setState({status:u.Status.None}):t=s._validate(e),t},s}var Y,Z=(r($,Y=p.Component),$.prototype.componentDidMount=function(){this.context.form.addFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.addFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.addFieldDidResetEventListener(this.fieldDidReset)},$.prototype.componentWillUnmount=function(){this.context.form.removeFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.removeFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.removeFieldDidResetEventListener(this.fieldDidReset)},$.prototype.render=function(){var e=this.props,t=e.style,i=v(e,["style"]);return this.state.fieldIsValid?p.createElement("span",h({},i,{style:h({display:"block"},t)})):null},$.contextTypes={form:e.instanceOf(_).isRequired,fieldFeedbacks:e.instanceOf(K).isRequired},$);function $(){var t=null!==Y&&Y.apply(this,arguments)||this;return t.state={fieldIsValid:void 0},t.fieldWillValidate=function(e){e===t.context.fieldFeedbacks.fieldName&&t.setState({fieldIsValid:void 0})},t.fieldDidValidate=function(e){e.name===t.context.fieldFeedbacks.fieldName&&t.setState({fieldIsValid:e.isValid()})},t.fieldDidReset=function(e){e.name===t.context.fieldFeedbacks.fieldName&&t.setState({fieldIsValid:void 0})},t}var ee,te=(r(ie,ee=p.Component),ie.prototype.componentDidMount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks,n=e.async;n?n.addValidateFieldEventListener(this.validate):i.addValidateFieldEventListener(this.validate),t.addFieldDidResetEventListener(this.fieldDidReset)},ie.prototype.componentWillUnmount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks,n=e.async;n?n.removeValidateFieldEventListener(this.validate):i.removeValidateFieldEventListener(this.validate),t.removeFieldDidResetEventListener(this.fieldDidReset)},ie.prototype.render=function(){var e=this.props,t=(e.when,e.error,e.warning,e.info,e.className),i=e.classes,n=e.style,r=e.children,a=v(e,["when","error","warning","info","className","classes","style","children"]),s=this.state,o=s.validation,l=s.validationMessage,d=i[o.type],c=void 0!==t?t+" "+d:d;if(o.type===u.FieldFeedbackType.WhenValid)return p.createElement(Z,h({"data-feedback":this.key,style:n,className:c},a),r);if(o.show){var f=void 0!==r?r:l;return p.createElement("span",h({"data-feedback":this.key,className:c,style:h({display:"block"},n)},a),f)}return null},ie.defaultProps={when:function(){return!0},classes:{error:"error",warning:"warning",info:"info",whenValid:"when-valid"}},ie.contextTypes={form:e.instanceOf(_).isRequired,fieldFeedbacks:e.instanceOf(K).isRequired,async:e.instanceOf(Q)},ie);function ie(e,t){var l=ee.call(this,e,t)||this;l.validate=function(e){var t=l.props.when,i=l.context,n=i.form,r=i.fieldFeedbacks,a=n.fieldsStore.getField(e.name),s=h({},l.state.validation);if("first"===r.props.stop&&a.hasFeedbacks(r.key)||"first-error"===r.props.stop&&a.hasErrors(r.key)||"first-warning"===r.props.stop&&a.hasWarnings(r.key)||"first-info"===r.props.stop&&a.hasInfos(r.key))s.show=void 0;else if(s.show=!1,"function"==typeof t)s.show=t(e.value);else{if("string"!=typeof t)throw new TypeError("Invalid FieldFeedback 'when' type: "+typeof t);if("valid"===t)s.show=void 0;else{var o=e.validity;o.valid||("*"===t||o.badInput&&"badInput"===t||o.patternMismatch&&"patternMismatch"===t||o.rangeOverflow&&"rangeOverflow"===t||o.rangeUnderflow&&"rangeUnderflow"===t||o.stepMismatch&&"stepMismatch"===t||o.tooLong&&"tooLong"===t||o.tooShort&&"tooShort"===t||o.typeMismatch&&"typeMismatch"===t||o.valueMissing&&"valueMissing"===t)&&(s.show=!0)}}return a.addOrReplaceValidation(s),l.setState({validation:s,validationMessage:e.validationMessage}),s},l.fieldDidReset=function(e){e.name===l.context.fieldFeedbacks.fieldName&&l.setState(function(e){return{validation:h(h({},e.validation),{show:void 0}),validationMessage:""}})},l.key=t.fieldFeedbacks.addFieldFeedback();var i=e.error,n=e.warning,r=e.info,a=e.when,s=u.FieldFeedbackType.Error;if("valid"===a?s=u.FieldFeedbackType.WhenValid:n?s=u.FieldFeedbackType.Warning:r&&(s=u.FieldFeedbackType.Info),s===u.FieldFeedbackType.WhenValid&&(i||n||r))throw new Error('Cannot have an attribute (error, warning...) with FieldFeedback when="valid"');return l.state={validation:{key:l.key,type:s,show:void 0},validationMessage:""},l}var ne,re=(r(ae,ne=p.Component),ae.prototype.componentDidMount=function(){this.context.form.addFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.addFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.addFieldDidResetEventListener(this.fieldDidReset)},ae.prototype.componentWillUnmount=function(){this.context.form.removeFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.removeFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.removeFieldDidResetEventListener(this.fieldDidReset)},ae.prototype.fieldValidationStates=function(){var e=this.state.field,t=[];return void 0!==e&&("pending"===e?t.push("isPending"):(e.hasErrors()&&t.push("hasErrors"),e.hasWarnings()&&t.push("hasWarnings"),e.hasInfos()&&t.push("hasInfos"),e.isValid()&&t.push("isValid"))),t},ae.prototype.render=function(){var e=this.props,t=e.innerRef,i=e.className,n=e.classes,r=v(e,["innerRef","className","classes"]),a=this.fieldValidationStates(),s=i;return a.forEach(function(e){var t=n[e];void 0!==t&&(void 0!==s?s+=" "+t:s=t)}),p.createElement("input",h({ref:t},r,{className:s}))},ae.contextTypes={form:e.instanceOf(_).isRequired},ae.defaultProps={classes:{isPending:"is-pending",hasErrors:"has-errors",hasWarnings:"has-warnings",hasInfos:"has-infos",isValid:"is-valid"}},ae);function ae(){var t=null!==ne&&ne.apply(this,arguments)||this;return t.state={field:void 0},t.fieldWillValidate=function(e){e===t.props.name&&t.setState({field:"pending"})},t.fieldDidValidate=function(e){e.name===t.props.name&&t.setState({field:e})},t.fieldDidReset=function(e){e.name===t.props.name&&t.setState({field:void 0})},t}u.Async=Q,u.EventEmitter=a,u.Field=D,u.FieldDidResetEvent=F,u.FieldDidValidateEvent=y,u.FieldFeedback=te,u.FieldFeedbackWhenValid=Z,u.FieldFeedbacks=K,u.FieldWillValidateEvent=l,u.FieldsStore=R,u.FormWithConstraints=_,u.IValidityState=b,u.Input=re,u.InputElement=w,u.ValidateFieldEvent=s,u.deepForEach=function i(e,n){p.Children.forEach(e,function(e){var t=e;t.props&&t.props.children&&"object"==typeof t.props.children&&i(t.props.children,n),n(t)})},u.isHTMLInput=g,u.withFieldDidResetEventEmitter=E,u.withFieldDidValidateEventEmitter=m,u.withFieldWillValidateEventEmitter=f,u.withValidateFieldEventEmitter=o,Object.defineProperty(u,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t((e=e||self).ReactFormWithConstraints={},e.React,e.PropTypes)}(this,function(o,u,e){"use strict";var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function r(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var p=function(){return(p=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function h(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]])}return i}function d(a,s,o,l){return new(o=o||Promise)(function(e,t){function i(e){try{r(l.next(e))}catch(e){t(e)}}function n(e){try{r(l.throw(e))}catch(e){t(e)}}function r(t){t.done?e(t.value):new o(function(e){e(t.value)}).then(i,n)}r((l=l.apply(a,s||[])).next())})}function c(i,n){var r,a,s,e,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,a&&(s=2&t[0]?a.return:t[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch(a=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return o.label++,{value:t[1],done:!1};case 5:o.label++,a=t[1],t=[0];continue;case 7:t=o.ops.pop(),o.trys.pop();continue;default:if(!(s=0<(s=o.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){o=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){o.label=t[1];break}if(6===t[0]&&o.label<s[1]){o.label=s[1],s=t;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(t);break}s[2]&&o.ops.pop(),o.trys.pop();continue}t=n.call(i,o)}catch(e){t=[6,e],a=0}finally{r=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function i(){for(var e=0,t=0,i=arguments.length;t<i;t++)e+=arguments[t].length;var n=Array(e),r=0;for(t=0;t<i;t++)for(var a=arguments[t],s=0,o=a.length;s<o;s++,r++)n[r]=a[s];return n}var a=(t.prototype.emit=function(o){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return d(this,void 0,void 0,function(){var t,i,n,r,a,s;return c(this,function(e){switch(e.label){case 0:if(t=this.listeners.get(o),i=new Array,void 0===t)return[3,4];console.assert(0<t.length,"No listener for event '"+o+"'"),n=0,e.label=1;case 1:return n<t.length?(r=t[n],s=(a=i).push,[4,r.apply(void 0,l)]):[3,4];case 2:s.apply(a,[e.sent()]),e.label=3;case 3:return n++,[3,1];case 4:return[2,i]}})})},t.prototype.addListener=function(e,t){this.listeners.has(e)||this.listeners.set(e,[]);var i=this.listeners.get(e);console.assert(-1===i.indexOf(t),"Listener already added for event '"+e+"'"),i.push(t)},t.prototype.removeListener=function(e,t){var i=this.listeners.get(e);console.assert(void 0!==i,"Unknown event '"+e+"'");var n=i.lastIndexOf(t);console.assert(-1<n,"Listener not found for event '"+e+"'"),i.splice(n,1),0===i.length&&this.listeners.delete(e)},t);function t(){this.listeners=new Map}var s="VALIDATE_FIELD_EVENT";function l(e){return r(t,i=e),t.prototype.emitValidateFieldEvent=function(e){return this.validateFieldEventEmitter.emit(s,e)},t.prototype.addValidateFieldEventListener=function(e){this.validateFieldEventEmitter.addListener(s,e)},t.prototype.removeValidateFieldEventListener=function(e){this.validateFieldEventEmitter.removeListener(s,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.validateFieldEventEmitter=new a,e}var i}var f="FIELD_WILL_VALIDATE_EVENT";function v(e){return r(t,i=e),t.prototype.emitFieldWillValidateEvent=function(e){return this.fieldWillValidateEventEmitter.emit(f,e)},t.prototype.addFieldWillValidateEventListener=function(e){this.fieldWillValidateEventEmitter.addListener(f,e)},t.prototype.removeFieldWillValidateEventListener=function(e){this.fieldWillValidateEventEmitter.removeListener(f,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.fieldWillValidateEventEmitter=new a,e}var i}var y="FIELD_DID_VALIDATE_EVENT";function m(e){return r(t,i=e),t.prototype.emitFieldDidValidateEvent=function(e){return this.fieldDidValidateEventEmitter.emit(y,e)},t.prototype.addFieldDidValidateEventListener=function(e){this.fieldDidValidateEventEmitter.addListener(y,e)},t.prototype.removeFieldDidValidateEventListener=function(e){this.fieldDidValidateEventEmitter.removeListener(y,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.fieldDidValidateEventEmitter=new a,e}var i}var F="FIELD_DID_RESET_EVENT";function E(e){return r(t,i=e),t.prototype.emitFieldDidResetEvent=function(e){return this.fieldDidResetEventEmitter.emit(F,e)},t.prototype.addFieldDidResetEventListener=function(e){this.fieldDidResetEventEmitter.addListener(F,e)},t.prototype.removeFieldDidResetEventListener=function(e){this.fieldDidResetEventEmitter.removeListener(F,e)},t;function t(){var e=null!==i&&i.apply(this,arguments)||this;return e.fieldDidResetEventEmitter=new a,e}var i}var b=function(e){this.badInput=e.badInput,this.customError=e.customError,this.patternMismatch=e.patternMismatch,this.rangeOverflow=e.rangeOverflow,this.rangeUnderflow=e.rangeUnderflow,this.stepMismatch=e.stepMismatch,this.tooLong=e.tooLong,this.tooShort=e.tooShort,this.typeMismatch=e.typeMismatch,this.valid=e.valid,this.valueMissing=e.valueMissing};function g(e){return void 0===e.props}var w,V,k=function(e){g(e)?(e=e,this.name=e.name,this.type=e.type,this.value=e.value,this.validity=new b(e.validity),this.validationMessage=e.validationMessage):(e=e,this.name=e.props.name,this.type=void 0,this.value=e.props.value,this.validity=void 0,this.validationMessage=void 0)};(V=w=w||{}).Error="error",V.Warning="warning",V.Info="info",V.WhenValid="whenValid";var D=w;var L,x=(R.prototype.addOrReplaceValidation=function(t){var e=this.validations.findIndex(function(e){return e.key===t.key});-1<e?this.validations[e]=t:this.validations.push(t)},R.prototype.clearValidations=function(){!function(e){for(;e.length;)e.pop()}(this.validations)},R.prototype.hasFeedbacksOfType=function(t,i){return this.validations.some(function(e){return(void 0===i||e.key.startsWith(i+"."))&&e.type===t&&!0===e.show})},R.prototype.hasErrors=function(e){return this.hasFeedbacksOfType(D.Error,e)},R.prototype.hasWarnings=function(e){return this.hasFeedbacksOfType(D.Warning,e)},R.prototype.hasInfos=function(e){return this.hasFeedbacksOfType(D.Info,e)},R.prototype.hasFeedbacks=function(e){return this.hasErrors(e)||this.hasWarnings(e)||this.hasInfos(e)},R.prototype.isValid=function(){return!this.hasErrors()},R);function R(e){this.name=e,this.validations=[]}(L=o.FieldEvent||(o.FieldEvent={})).Added="FIELD_ADDED",L.Removed="FIELD_REMOVED";var S,O=(r(W,S=a),W.prototype.getField=function(t){var e=this.fields.filter(function(e){return e.name===t});return 1===e.length?e[0]:void 0},W.prototype.addField=function(t){var e=this.fields.filter(function(e){return e.name===t});if(console.assert(0===e.length||1===e.length,"Cannot have more than 1 field matching '"+t+"'"),0===e.length){var i=new x(t);this.fields.push(i),this.emit(o.FieldEvent.Added,i)}},W.prototype.removeField=function(t){var e=this.fields.filter(function(e){return e.name===t}),i=this.fields.indexOf(e[0]);-1<i&&(this.fields.splice(i,1),this.emit(o.FieldEvent.Removed,t))},W.prototype.isValid=function(){return this.fields.every(function(e){return e.isValid()})},W.prototype.hasFeedbacks=function(){return this.fields.some(function(e){return e.hasFeedbacks()})},W);function W(){var e=null!==S&&S.apply(this,arguments)||this;return e.fields=new Array,e}function I(e){return e.reduce(function(e,t){return e.concat(Array.isArray(t)?I(t):t)},[])}function M(e){return void 0!==e}var N,_=(r(C,N=u.PureComponent),C);function C(){return null!==N&&N.apply(this,arguments)||this}var T,A=(r(P,T=E(v(m(l(_))))),P.prototype.getChildContext=function(){return{form:this}},P.prototype.computeFieldFeedbacksKey=function(){return""+this.fieldFeedbacksKeyCounter++},P.prototype.validateFields=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._validateFields.apply(this,i([!0],e))},P.prototype.validateForm=function(){return this.validateFieldsWithoutFeedback()},P.prototype.validateFieldsWithoutFeedback=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._validateFields.apply(this,i([!1],e))},P.prototype._validateFields=function(s){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];return d(this,void 0,void 0,function(){var t,i,n,r,a;return c(this,function(e){switch(e.label){case 0:t=new Array,i=this.normalizeInputs.apply(this,o),n=0,e.label=1;case 1:return n<i.length?(r=i[n],[4,this.validateField(s,new k(r))]):[3,4];case 2:void 0!==(a=e.sent())&&(a.element=r,t.push(a)),e.label=3;case 3:return n++,[3,1];case 4:return[2,t]}})})},P.prototype.validateField=function(r,a){return d(this,void 0,void 0,function(){var t,i,n;return c(this,function(e){switch(e.label){case 0:return t=a.name,void 0!==(i=this.fieldsStore.getField(t))?[3,1]:[3,3];case 1:return!r&&i.hasFeedbacks()?[3,3]:(i.clearValidations(),this.emitFieldWillValidateEvent(t),[4,this.emitValidateFieldEvent(a)]);case 2:n=e.sent(),console.assert(JSON.stringify(I(n).filter(M))===JSON.stringify(i.validations),"FieldsStore does not match emitValidateFieldEvent() result, did the user changed the input rapidly?"),this.emitFieldDidValidateEvent(i),e.label=3;case 3:return[2,i]}})})},P.prototype.normalizeInputs=function(){for(var e,r=this,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return 0===t.length?(e=(e=Array.from(this.form.querySelectorAll("[name]"))).filter(function(e){return void 0!==e.validity})).filter(function(e){return"checkbox"!==e.type&&"radio"!==e.type}).map(function(e){return e.name}).forEach(function(e,t,i){if(i.indexOf(e)!==t)throw new Error("Multiple elements matching '[name=\""+e+"\"]' inside the form")}):e=t.map(function(e){if("string"!=typeof e)return e;var t='[name="'+e+'"]',i=Array.from(r.form.querySelectorAll(t));if(0<i.filter(function(e){return void 0===e.validity}).length)throw new Error("'"+t+"' should match an <input>, <select> or <textarea>");if(1<i.filter(function(e){return"checkbox"!==e.type&&"radio"!==e.type}).length)throw new Error("Multiple elements matching '"+t+"' inside the form");var n=i[0];if(void 0===n)throw new Error("Could not find field '"+t+"' inside the form");return n}),e},P.prototype.isValid=function(){return this.fieldsStore.isValid()},P.prototype.hasFeedbacks=function(){return this.fieldsStore.hasFeedbacks()},P.prototype.reset=function(){return this.resetFields()},P.prototype.resetFields=function(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];return d(this,void 0,void 0,function(){var t,i,n,r,a;return c(this,function(e){switch(e.label){case 0:t=new Array,i=this.normalizeInputs.apply(this,s),n=0,e.label=1;case 1:return n<i.length?(r=i[n],[4,this.resetField(new k(r))]):[3,4];case 2:void 0!==(a=e.sent())&&t.push(a),e.label=3;case 3:return n++,[3,1];case 4:return[2,t]}})})},P.prototype.resetField=function(n){return d(this,void 0,void 0,function(){var t,i;return c(this,function(e){switch(e.label){case 0:return t=n.name,void 0!==(i=this.fieldsStore.getField(t))?[3,1]:[3,3];case 1:return i.clearValidations(),[4,this.emitFieldDidResetEvent(i)];case 2:e.sent(),e.label=3;case 3:return[2,i]}})})},P.prototype.render=function(){var t=this;return u.createElement("form",p({ref:function(e){return t.form=e}},this.props))},P.childContextTypes={form:e.instanceOf(P).isRequired},P);function P(){var e=null!==T&&T.apply(this,arguments)||this;return e.form=null,e.fieldsStore=new O,e.fieldFeedbacksKeyCounter=0,e}var j,q=(r(U,j=u.PureComponent),U);function U(){return null!==j&&j.apply(this,arguments)||this}var K,z,J=(r(G,K=l(q)),G.prototype.getChildContext=function(){return{fieldFeedbacks:this}},G.prototype.computeFieldFeedbackKey=function(){return this.key+"."+this.fieldFeedbackKeyCounter++},G.prototype.addFieldFeedback=function(){return this.computeFieldFeedbackKey()},G.prototype.componentDidMount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks;t.fieldsStore.addField(this.fieldName),(i||t).addValidateFieldEventListener(this.validate)},G.prototype.componentWillUnmount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks;t.fieldsStore.removeField(this.fieldName),(i||t).removeValidateFieldEventListener(this.validate)},G.prototype._validate=function(t){return d(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return[4,this.emitValidateFieldEvent(t)];case 1:return[2,I(e.sent())]}})})},G.prototype.render=function(){var e=this.props.children;return void 0!==e?e:null},G.defaultProps={stop:"first-error"},G.contextTypes={form:e.instanceOf(A).isRequired,fieldFeedbacks:e.instanceOf(G)},G.childContextTypes={fieldFeedbacks:e.instanceOf(G).isRequired},G);function G(e,t){var i=K.call(this,e,t)||this;i.fieldFeedbackKeyCounter=0,i.validate=function(s){return d(i,void 0,void 0,function(){var t,i,n,r,a;return c(this,function(e){switch(e.label){case 0:return(t=this.context,i=t.form,n=t.fieldFeedbacks,s.name!==this.fieldName)?[3,3]:(a=i.fieldsStore.getField(this.fieldName),n&&("first"===n.props.stop&&a.hasFeedbacks(n.key)||"first-error"===n.props.stop&&a.hasErrors(n.key)||"first-warning"===n.props.stop&&a.hasWarnings(n.key)||"first-info"===n.props.stop&&a.hasInfos(n.key))?[3,3]:[3,1]);case 1:return[4,this._validate(s)];case 2:r=e.sent(),e.label=3;case 3:return[2,r]}})})};var n=t.form,r=t.fieldFeedbacks;if(i.key=r?r.computeFieldFeedbackKey():n.computeFieldFeedbacksKey(),r){if(i.fieldName=r.fieldName,void 0!==e.for)throw new Error("FieldFeedbacks cannot have a parent and a 'for' prop")}else{if(void 0===e.for)throw new Error("FieldFeedbacks cannot be without parent and without 'for' prop");i.fieldName=e.for}return i}(z=o.Status||(o.Status={}))[z.None=0]="None",z[z.Pending=1]="Pending",z[z.Rejected=2]="Rejected",z[z.Resolved=3]="Resolved";var H,B=(r(Q,H=u.PureComponent),Q);function Q(){return null!==H&&H.apply(this,arguments)||this}var X,Y=(r(Z,X=l(B)),Z.prototype.getChildContext=function(){return{async:this}},Z.prototype.componentDidMount=function(){this.context.fieldFeedbacks.addValidateFieldEventListener(this.validate)},Z.prototype.componentWillUnmount=function(){this.context.fieldFeedbacks.removeValidateFieldEventListener(this.validate)},Z.prototype._validate=function(n){return d(this,void 0,void 0,function(){var t,i;return c(this,function(e){switch(e.label){case 0:this.setState({status:o.Status.Pending}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.props.promise(n.value)];case 2:return t=e.sent(),this.setState({status:o.Status.Resolved,value:t}),[3,4];case 3:return i=e.sent(),this.setState({status:o.Status.Rejected,value:i}),[3,4];case 4:return[2,this.emitValidateFieldEvent(n)]}})})},Z.prototype.render=function(){var e=this.props,t=this.state,i=null;switch(t.status){case o.Status.None:break;case o.Status.Pending:e.pending&&(i=e.pending);break;case o.Status.Resolved:e.then&&(i=e.then(t.value));break;case o.Status.Rejected:e.catch&&(i=e.catch(t.value));break;default:console.assert(!1,"Unknown status: '"+t.status+"'")}return i},Z.contextTypes={form:e.instanceOf(A).isRequired,fieldFeedbacks:e.instanceOf(J).isRequired},Z.childContextTypes={async:e.instanceOf(Z).isRequired},Z);function Z(){var s=null!==X&&X.apply(this,arguments)||this;return s.state={status:o.Status.None},s.validate=function(e){var t,i=s.context,n=i.form,r=i.fieldFeedbacks,a=n.fieldsStore.getField(e.name);return"first"===r.props.stop&&a.hasFeedbacks(r.key)||"first-error"===r.props.stop&&a.hasErrors(r.key)||"first-warning"===r.props.stop&&a.hasWarnings(r.key)||"first-info"===r.props.stop&&a.hasInfos(r.key)?s.setState({status:o.Status.None}):t=s._validate(e),t},s}var $,ee=(r(te,$=u.Component),te.prototype.componentDidMount=function(){this.context.form.addFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.addFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.addFieldDidResetEventListener(this.fieldDidReset)},te.prototype.componentWillUnmount=function(){this.context.form.removeFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.removeFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.removeFieldDidResetEventListener(this.fieldDidReset)},te.prototype.render=function(){var e=this.props,t=e.style,i=h(e,["style"]);return this.state.fieldIsValid?u.createElement("span",p({},i,{style:p({display:"block"},t)})):null},te.contextTypes={form:e.instanceOf(A).isRequired,fieldFeedbacks:e.instanceOf(J).isRequired},te);function te(){var t=null!==$&&$.apply(this,arguments)||this;return t.state={fieldIsValid:void 0},t.fieldWillValidate=function(e){e===t.context.fieldFeedbacks.fieldName&&t.setState({fieldIsValid:void 0})},t.fieldDidValidate=function(e){e.name===t.context.fieldFeedbacks.fieldName&&t.setState({fieldIsValid:e.isValid()})},t.fieldDidReset=function(e){e.name===t.context.fieldFeedbacks.fieldName&&t.setState({fieldIsValid:void 0})},t}var ie,ne=(r(re,ie=u.Component),re.prototype.componentDidMount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks,n=e.async;n?n.addValidateFieldEventListener(this.validate):i.addValidateFieldEventListener(this.validate),t.addFieldDidResetEventListener(this.fieldDidReset)},re.prototype.componentWillUnmount=function(){var e=this.context,t=e.form,i=e.fieldFeedbacks,n=e.async;n?n.removeValidateFieldEventListener(this.validate):i.removeValidateFieldEventListener(this.validate),t.removeFieldDidResetEventListener(this.fieldDidReset)},re.prototype.render=function(){var e=this.props,t=(e.when,e.error,e.warning,e.info,e.className),i=e.classes,n=e.style,r=e.children,a=h(e,["when","error","warning","info","className","classes","style","children"]),s=this.state,o=s.validation,l=s.validationMessage,d=i[o.type],c=void 0!==t?t+" "+d:d;if(o.type===D.WhenValid)return u.createElement(ee,p({"data-feedback":this.key,style:n,className:c},a),r);if(o.show){var f=void 0!==r?r:l;return u.createElement("span",p({"data-feedback":this.key,className:c,style:p({display:"block"},n)},a),f)}return null},re.defaultProps={when:function(){return!0},classes:{error:"error",warning:"warning",info:"info",whenValid:"when-valid"}},re.contextTypes={form:e.instanceOf(A).isRequired,fieldFeedbacks:e.instanceOf(J).isRequired,async:e.instanceOf(Y)},re);function re(e,t){var l=ie.call(this,e,t)||this;l.validate=function(e){var t=l.props.when,i=l.context,n=i.form,r=i.fieldFeedbacks,a=n.fieldsStore.getField(e.name),s=p({},l.state.validation);if("first"===r.props.stop&&a.hasFeedbacks(r.key)||"first-error"===r.props.stop&&a.hasErrors(r.key)||"first-warning"===r.props.stop&&a.hasWarnings(r.key)||"first-info"===r.props.stop&&a.hasInfos(r.key))s.show=void 0;else if(s.show=!1,"function"==typeof t)s.show=t(e.value);else{if("string"!=typeof t)throw new TypeError("Invalid FieldFeedback 'when' type: "+typeof t);if("valid"===t)s.show=void 0;else{var o=e.validity;o.valid||("*"===t||o.badInput&&"badInput"===t||o.patternMismatch&&"patternMismatch"===t||o.rangeOverflow&&"rangeOverflow"===t||o.rangeUnderflow&&"rangeUnderflow"===t||o.stepMismatch&&"stepMismatch"===t||o.tooLong&&"tooLong"===t||o.tooShort&&"tooShort"===t||o.typeMismatch&&"typeMismatch"===t||o.valueMissing&&"valueMissing"===t)&&(s.show=!0)}}return a.addOrReplaceValidation(s),l.setState({validation:s,validationMessage:e.validationMessage}),s},l.fieldDidReset=function(e){e.name===l.context.fieldFeedbacks.fieldName&&l.setState(function(e){return{validation:p(p({},e.validation),{show:void 0}),validationMessage:""}})},l.key=t.fieldFeedbacks.addFieldFeedback();var i=e.error,n=e.warning,r=e.info,a=e.when,s=D.Error;if("valid"===a?s=D.WhenValid:n?s=D.Warning:r&&(s=D.Info),s===D.WhenValid&&(i||n||r))throw new Error('Cannot have an attribute (error, warning...) with FieldFeedback when="valid"');return l.state={validation:{key:l.key,type:s,show:void 0},validationMessage:""},l}var ae,se=(r(oe,ae=u.Component),oe.prototype.componentDidMount=function(){this.context.form.addFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.addFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.addFieldDidResetEventListener(this.fieldDidReset)},oe.prototype.componentWillUnmount=function(){this.context.form.removeFieldWillValidateEventListener(this.fieldWillValidate),this.context.form.removeFieldDidValidateEventListener(this.fieldDidValidate),this.context.form.removeFieldDidResetEventListener(this.fieldDidReset)},oe.prototype.fieldValidationStates=function(){var e=this.state.field,t=[];return void 0!==e&&("pending"===e?t.push("isPending"):(e.hasErrors()&&t.push("hasErrors"),e.hasWarnings()&&t.push("hasWarnings"),e.hasInfos()&&t.push("hasInfos"),e.isValid()&&t.push("isValid"))),t},oe.prototype.render=function(){var e=this.props,t=e.innerRef,i=e.className,n=e.classes,r=h(e,["innerRef","className","classes"]),a=this.fieldValidationStates(),s=i;return a.forEach(function(e){var t=n[e];void 0!==t&&(void 0!==s?s+=" "+t:s=t)}),u.createElement("input",p({ref:t},r,{className:s}))},oe.contextTypes={form:e.instanceOf(A).isRequired},oe.defaultProps={classes:{isPending:"is-pending",hasErrors:"has-errors",hasWarnings:"has-warnings",hasInfos:"has-infos",isValid:"is-valid"}},oe);function oe(){var t=null!==ae&&ae.apply(this,arguments)||this;return t.state={field:void 0},t.fieldWillValidate=function(e){e===t.props.name&&t.setState({field:"pending"})},t.fieldDidValidate=function(e){e.name===t.props.name&&t.setState({field:e})},t.fieldDidReset=function(e){e.name===t.props.name&&t.setState({field:void 0})},t}o.Async=Y,o.EventEmitter=a,o.Field=x,o.FieldDidResetEvent=F,o.FieldDidValidateEvent=y,o.FieldFeedback=ne,o.FieldFeedbackType=D,o.FieldFeedbackWhenValid=ee,o.FieldFeedbacks=J,o.FieldWillValidateEvent=f,o.FieldsStore=O,o.FormWithConstraints=A,o.IValidityState=b,o.Input=se,o.InputElement=k,o.ValidateFieldEvent=s,o.deepForEach=function i(e,n){u.Children.forEach(e,function(e){var t=e;t.props&&t.props.children&&"object"==typeof t.props.children&&i(t.props.children,n),n(t)})},o.isHTMLInput=g,o.withFieldDidResetEventEmitter=E,o.withFieldDidValidateEventEmitter=m,o.withFieldWillValidateEventEmitter=v,o.withValidateFieldEventEmitter=l,Object.defineProperty(o,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=react-form-with-constraints.production.min.js.map |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import { Field } from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
import Field from './Field'; | ||
export declare const FieldDidResetEvent = "FIELD_DID_RESET_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withFieldDidResetEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import { Field } from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
import Field from './Field'; | ||
export declare const FieldDidValidateEvent = "FIELD_DID_VALIDATE_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withFieldDidValidateEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -1,3 +0,3 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
export declare const FieldWillValidateEvent = "FIELD_WILL_VALIDATE_EVENT"; | ||
@@ -4,0 +4,0 @@ export declare function withFieldWillValidateEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import EventEmitter from './EventEmitter'; | ||
import { InputElement } from './InputElement'; | ||
import { Constructor } from './Constructor'; | ||
import Constructor from './Constructor'; | ||
export declare const ValidateFieldEvent = "VALIDATE_FIELD_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withValidateFieldEventEmitter<ListenerReturnType, TBase extends Constructor<{}>>(Base: TBase): { |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { FieldFeedbacksChildContext } from './FieldFeedbacks'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import { InputElement } from './InputElement'; | ||
@@ -30,3 +30,3 @@ export declare enum Status { | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation>; | ||
emitValidateFieldEvent(input: InputElement): Promise<FieldFeedbackValidation[]>; | ||
@@ -33,0 +33,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | Promise<FieldFeedbackValidation>): void; |
@@ -1,1 +0,1 @@ | ||
export declare function clearArray<T>(array: T[]): void; | ||
export default function clearArray<T>(array: T[]): void; |
@@ -8,2 +8,2 @@ "use strict"; | ||
} | ||
exports.clearArray = clearArray; | ||
exports.default = clearArray; |
@@ -1,1 +0,2 @@ | ||
export declare type Constructor<T> = new (...args: any[]) => T; | ||
declare type Constructor<T> = new (...args: any[]) => T; | ||
export default Constructor; |
import * as React from 'react'; | ||
export declare function deepForEach(children: React.ReactNode, fn: (child: React.ReactElement<any>) => void): void; | ||
export default function deepForEach(children: React.ReactNode, fn: (child: React.ReactElement<any>) => void): void; |
@@ -13,2 +13,2 @@ "use strict"; | ||
} | ||
exports.deepForEach = deepForEach; | ||
exports.default = deepForEach; |
declare type Args = any[]; | ||
declare type Listener<ListenerReturnType = void> = (...args: Args) => ListenerReturnType | Promise<ListenerReturnType>; | ||
export declare class EventEmitter<ListenerReturnType = void> { | ||
export default class EventEmitter<ListenerReturnType = void> { | ||
listeners: Map<string, Listener<ListenerReturnType>[]>; | ||
@@ -5,0 +5,0 @@ emit(eventName: string, ...args: Args): Promise<ListenerReturnType[]>; |
@@ -89,2 +89,2 @@ "use strict"; | ||
}()); | ||
exports.EventEmitter = EventEmitter; | ||
exports.default = EventEmitter; |
@@ -1,5 +0,5 @@ | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
import { TextInput, HTMLInput } from './InputElement'; | ||
export declare class Field { | ||
export default class Field { | ||
readonly name: string; | ||
@@ -6,0 +6,0 @@ readonly validations: FieldFeedbackValidation[]; |
@@ -18,3 +18,3 @@ "use strict"; | ||
Field.prototype.clearValidations = function () { | ||
clearArray_1.clearArray(this.validations); | ||
clearArray_1.default(this.validations); | ||
}; | ||
@@ -30,9 +30,9 @@ Field.prototype.hasFeedbacksOfType = function (type, fieldFeedbacksKey) { | ||
Field.prototype.hasErrors = function (fieldFeedbacksKey) { | ||
return this.hasFeedbacksOfType(FieldFeedbackType_1.FieldFeedbackType.Error, fieldFeedbacksKey); | ||
return this.hasFeedbacksOfType(FieldFeedbackType_1.default.Error, fieldFeedbacksKey); | ||
}; | ||
Field.prototype.hasWarnings = function (fieldFeedbacksKey) { | ||
return this.hasFeedbacksOfType(FieldFeedbackType_1.FieldFeedbackType.Warning, fieldFeedbacksKey); | ||
return this.hasFeedbacksOfType(FieldFeedbackType_1.default.Warning, fieldFeedbacksKey); | ||
}; | ||
Field.prototype.hasInfos = function (fieldFeedbacksKey) { | ||
return this.hasFeedbacksOfType(FieldFeedbackType_1.FieldFeedbackType.Info, fieldFeedbacksKey); | ||
return this.hasFeedbacksOfType(FieldFeedbackType_1.default.Info, fieldFeedbacksKey); | ||
}; | ||
@@ -49,2 +49,2 @@ Field.prototype.hasFeedbacks = function (fieldFeedbacksKey) { | ||
}()); | ||
exports.Field = Field; | ||
exports.default = Field; |
@@ -6,6 +6,6 @@ import * as React from 'react'; | ||
import { InputElement } from './InputElement'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import { Field } from './Field'; | ||
import { Nullable } from './Nullable'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
import Field from './Field'; | ||
import Nullable from './Nullable'; | ||
declare type WhenString = 'valid' | '*' | 'badInput' | 'patternMismatch' | 'rangeOverflow' | 'rangeUnderflow' | 'stepMismatch' | 'tooLong' | 'tooShort' | 'typeMismatch' | 'valueMissing'; | ||
@@ -12,0 +12,0 @@ declare type WhenFn = (value: string) => boolean; |
@@ -110,10 +110,10 @@ "use strict"; | ||
var error = props.error, warning = props.warning, info = props.info, when = props.when; | ||
var type = FieldFeedbackType_1.FieldFeedbackType.Error; | ||
var type = FieldFeedbackType_1.default.Error; | ||
if (when === 'valid') | ||
type = FieldFeedbackType_1.FieldFeedbackType.WhenValid; | ||
type = FieldFeedbackType_1.default.WhenValid; | ||
else if (warning) | ||
type = FieldFeedbackType_1.FieldFeedbackType.Warning; | ||
type = FieldFeedbackType_1.default.Warning; | ||
else if (info) | ||
type = FieldFeedbackType_1.FieldFeedbackType.Info; | ||
if (type === FieldFeedbackType_1.FieldFeedbackType.WhenValid && (error || warning || info)) { | ||
type = FieldFeedbackType_1.default.Info; | ||
if (type === FieldFeedbackType_1.default.WhenValid && (error || warning || info)) { | ||
throw new Error('Cannot have an attribute (error, warning...) with FieldFeedback when="valid"'); | ||
@@ -153,3 +153,3 @@ } | ||
var classNames = className !== undefined ? className + " " + fieldFeedbackClassName : fieldFeedbackClassName; | ||
if (validation.type === FieldFeedbackType_1.FieldFeedbackType.WhenValid) { | ||
if (validation.type === FieldFeedbackType_1.default.WhenValid) { | ||
return (React.createElement(FieldFeedbackWhenValid_1.FieldFeedbackWhenValid, __assign({ "data-feedback": this.key, style: style, className: classNames }, otherProps), children)); | ||
@@ -156,0 +156,0 @@ } |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { InputElement } from './InputElement'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { Nullable } from './Nullable'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import Nullable from './Nullable'; | ||
export interface FieldFeedbacksProps { | ||
@@ -18,3 +18,3 @@ for?: string; | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
emitValidateFieldEvent(input: InputElement): Promise<(FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined)[]>; | ||
@@ -21,0 +21,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | Promise<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined> | undefined): void; |
@@ -141,3 +141,3 @@ "use strict"; | ||
arrayOfArrays = _a.sent(); | ||
validations = flattenDeep_1.flattenDeep(arrayOfArrays); | ||
validations = flattenDeep_1.default(arrayOfArrays); | ||
return [2, validations]; | ||
@@ -144,0 +144,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare enum FieldFeedbackType { | ||
declare enum FieldFeedbackType { | ||
Error = "error", | ||
@@ -7,1 +7,2 @@ Warning = "warning", | ||
} | ||
export default FieldFeedbackType; |
@@ -9,2 +9,3 @@ "use strict"; | ||
FieldFeedbackType["WhenValid"] = "whenValid"; | ||
})(FieldFeedbackType = exports.FieldFeedbackType || (exports.FieldFeedbackType = {})); | ||
})(FieldFeedbackType || (FieldFeedbackType = {})); | ||
exports.default = FieldFeedbackType; |
@@ -1,3 +0,3 @@ | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
export interface FieldFeedbackValidation { | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
export default interface FieldFeedbackValidation { | ||
readonly key: string; | ||
@@ -4,0 +4,0 @@ readonly type: FieldFeedbackType; |
@@ -5,3 +5,3 @@ import * as React from 'react'; | ||
import { FieldFeedbackClasses } from './FieldFeedback'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
export interface FieldFeedbackWhenValidBaseProps { | ||
@@ -8,0 +8,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { Field } from './Field'; | ||
import { EventEmitter } from './EventEmitter'; | ||
import Field from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
export declare enum FieldEvent { | ||
@@ -4,0 +4,0 @@ Added = "FIELD_ADDED", |
@@ -37,3 +37,3 @@ "use strict"; | ||
if (fields.length === 0) { | ||
var newField = new Field_1.Field(fieldName); | ||
var newField = new Field_1.default(fieldName); | ||
this.fields.push(newField); | ||
@@ -60,3 +60,3 @@ this.emit(FieldEvent.Added, newField); | ||
return FieldsStore; | ||
}(EventEmitter_1.EventEmitter)); | ||
}(EventEmitter_1.default)); | ||
exports.FieldsStore = FieldsStore; |
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> { | ||
} | ||
export declare function flattenDeep<T>(arrayOfArrays: RecursiveArray<T>): T[]; | ||
export default function flattenDeep<T>(arrayOfArrays: RecursiveArray<T>): T[]; | ||
export {}; |
@@ -6,2 +6,2 @@ "use strict"; | ||
} | ||
exports.flattenDeep = flattenDeep; | ||
exports.default = flattenDeep; |
import * as React from 'react'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
import { IHTMLInput, InputElement } from './InputElement'; | ||
import { FieldsStore } from './FieldsStore'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
export interface FormWithConstraintsChildContext { | ||
@@ -15,3 +15,3 @@ form: FormWithConstraints; | ||
new (...args: any[]): { | ||
fieldDidResetEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldDidResetEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldDidResetEvent(field: Field): Promise<void[]>; | ||
@@ -23,3 +23,3 @@ addFieldDidResetEventListener(listener: (field: Field) => void): void; | ||
new (...args: any[]): { | ||
fieldWillValidateEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldWillValidateEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldWillValidateEvent(fieldName: string): Promise<void[]>; | ||
@@ -31,3 +31,3 @@ addFieldWillValidateEventListener(listener: (fieldName: string) => void): void; | ||
new (...args: any[]): { | ||
fieldDidValidateEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldDidValidateEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldDidValidateEvent(field: Field): Promise<void[]>; | ||
@@ -39,3 +39,3 @@ addFieldDidValidateEventListener(listener: (field: Field) => void): void; | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
emitValidateFieldEvent(input: InputElement): Promise<(FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined)[]>; | ||
@@ -42,0 +42,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | Promise<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined> | undefined): void; |
export * from './FormWithConstraints'; | ||
export * from './FieldFeedbacks'; | ||
export * from './FieldFeedback'; | ||
export * from './FieldFeedbackType'; | ||
export { default as FieldFeedbackType } from './FieldFeedbackType'; | ||
export * from './FieldFeedbackWhenValid'; | ||
export * from './Async'; | ||
export * from './Field'; | ||
export { default as Field } from './Field'; | ||
export * from './FieldsStore'; | ||
export * from './EventEmitter'; | ||
export { default as EventEmitter } from './EventEmitter'; | ||
export * from './withValidateFieldEventEmitter'; | ||
@@ -14,6 +14,6 @@ export * from './withFieldWillValidateEventEmitter'; | ||
export * from './withFieldDidResetEventEmitter'; | ||
export * from './FieldFeedbackValidation'; | ||
export { default as FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
export * from './InputElement'; | ||
export * from './Constructor'; | ||
export { default as Constructor } from './Constructor'; | ||
export * from './Input'; | ||
export * from './deepForEach'; | ||
export { default as deepForEach } from './deepForEach'; |
@@ -9,8 +9,11 @@ "use strict"; | ||
__export(require("./FieldFeedback")); | ||
__export(require("./FieldFeedbackType")); | ||
var FieldFeedbackType_1 = require("./FieldFeedbackType"); | ||
exports.FieldFeedbackType = FieldFeedbackType_1.default; | ||
__export(require("./FieldFeedbackWhenValid")); | ||
__export(require("./Async")); | ||
__export(require("./Field")); | ||
var Field_1 = require("./Field"); | ||
exports.Field = Field_1.default; | ||
__export(require("./FieldsStore")); | ||
__export(require("./EventEmitter")); | ||
var EventEmitter_1 = require("./EventEmitter"); | ||
exports.EventEmitter = EventEmitter_1.default; | ||
__export(require("./withValidateFieldEventEmitter")); | ||
@@ -20,6 +23,5 @@ __export(require("./withFieldWillValidateEventEmitter")); | ||
__export(require("./withFieldDidResetEventEmitter")); | ||
__export(require("./FieldFeedbackValidation")); | ||
__export(require("./InputElement")); | ||
__export(require("./Constructor")); | ||
__export(require("./Input")); | ||
__export(require("./deepForEach")); | ||
var deepForEach_1 = require("./deepForEach"); | ||
exports.deepForEach = deepForEach_1.default; |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> { | ||
@@ -5,0 +5,0 @@ innerRef?: React.Ref<HTMLInputElement>; |
@@ -1,1 +0,1 @@ | ||
export declare function notUndefined<T>(value: T | undefined): value is T; | ||
export default function notUndefined<T>(value: T | undefined): value is T; |
@@ -6,2 +6,2 @@ "use strict"; | ||
} | ||
exports.notUndefined = notUndefined; | ||
exports.default = notUndefined; |
@@ -1,3 +0,4 @@ | ||
export declare type Nullable<T> = { | ||
declare type Nullable<T> = { | ||
[P in keyof T]: T[P] | null; | ||
}; | ||
export default Nullable; |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import { Field } from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
import Field from './Field'; | ||
export declare const FieldDidResetEvent = "FIELD_DID_RESET_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withFieldDidResetEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -23,3 +23,3 @@ "use strict"; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.fieldDidResetEventEmitter = new EventEmitter_1.EventEmitter(); | ||
_this.fieldDidResetEventEmitter = new EventEmitter_1.default(); | ||
return _this; | ||
@@ -26,0 +26,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import { Field } from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
import Field from './Field'; | ||
export declare const FieldDidValidateEvent = "FIELD_DID_VALIDATE_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withFieldDidValidateEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -23,3 +23,3 @@ "use strict"; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.fieldDidValidateEventEmitter = new EventEmitter_1.EventEmitter(); | ||
_this.fieldDidValidateEventEmitter = new EventEmitter_1.default(); | ||
return _this; | ||
@@ -26,0 +26,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
export declare const FieldWillValidateEvent = "FIELD_WILL_VALIDATE_EVENT"; | ||
@@ -4,0 +4,0 @@ export declare function withFieldWillValidateEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -23,3 +23,3 @@ "use strict"; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.fieldWillValidateEventEmitter = new EventEmitter_1.EventEmitter(); | ||
_this.fieldWillValidateEventEmitter = new EventEmitter_1.default(); | ||
return _this; | ||
@@ -26,0 +26,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import EventEmitter from './EventEmitter'; | ||
import { InputElement } from './InputElement'; | ||
import { Constructor } from './Constructor'; | ||
import Constructor from './Constructor'; | ||
export declare const ValidateFieldEvent = "VALIDATE_FIELD_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withValidateFieldEventEmitter<ListenerReturnType, TBase extends Constructor<{}>>(Base: TBase): { |
@@ -23,3 +23,3 @@ "use strict"; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.validateFieldEventEmitter = new EventEmitter_1.EventEmitter(); | ||
_this.validateFieldEventEmitter = new EventEmitter_1.default(); | ||
return _this; | ||
@@ -26,0 +26,0 @@ } |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { FieldFeedbacksChildContext } from './FieldFeedbacks'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import { InputElement } from './InputElement'; | ||
@@ -30,3 +30,3 @@ export declare enum Status { | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation>; | ||
emitValidateFieldEvent(input: InputElement): Promise<FieldFeedbackValidation[]>; | ||
@@ -33,0 +33,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | Promise<FieldFeedbackValidation>): void; |
@@ -1,1 +0,1 @@ | ||
export declare function clearArray<T>(array: T[]): void; | ||
export default function clearArray<T>(array: T[]): void; |
@@ -1,2 +0,2 @@ | ||
export function clearArray(array) { | ||
export default function clearArray(array) { | ||
while (array.length) { | ||
@@ -3,0 +3,0 @@ array.pop(); |
@@ -1,1 +0,2 @@ | ||
export declare type Constructor<T> = new (...args: any[]) => T; | ||
declare type Constructor<T> = new (...args: any[]) => T; | ||
export default Constructor; |
import * as React from 'react'; | ||
export declare function deepForEach(children: React.ReactNode, fn: (child: React.ReactElement<any>) => void): void; | ||
export default function deepForEach(children: React.ReactNode, fn: (child: React.ReactElement<any>) => void): void; |
import * as React from 'react'; | ||
export function deepForEach(children, fn) { | ||
export default function deepForEach(children, fn) { | ||
React.Children.forEach(children, child => { | ||
@@ -4,0 +4,0 @@ const element = child; |
declare type Args = any[]; | ||
declare type Listener<ListenerReturnType = void> = (...args: Args) => ListenerReturnType | Promise<ListenerReturnType>; | ||
export declare class EventEmitter<ListenerReturnType = void> { | ||
export default class EventEmitter<ListenerReturnType = void> { | ||
listeners: Map<string, Listener<ListenerReturnType>[]>; | ||
@@ -5,0 +5,0 @@ emit(eventName: string, ...args: Args): Promise<ListenerReturnType[]>; |
@@ -1,2 +0,2 @@ | ||
export class EventEmitter { | ||
export default class EventEmitter { | ||
constructor() { | ||
@@ -3,0 +3,0 @@ this.listeners = new Map(); |
@@ -1,5 +0,5 @@ | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
import { TextInput, HTMLInput } from './InputElement'; | ||
export declare class Field { | ||
export default class Field { | ||
readonly name: string; | ||
@@ -6,0 +6,0 @@ readonly validations: FieldFeedbackValidation[]; |
@@ -1,4 +0,4 @@ | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import { clearArray } from './clearArray'; | ||
export class Field { | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
import clearArray from './clearArray'; | ||
export default class Field { | ||
constructor(name) { | ||
@@ -5,0 +5,0 @@ this.name = name; |
@@ -6,6 +6,6 @@ import * as React from 'react'; | ||
import { InputElement } from './InputElement'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import { Field } from './Field'; | ||
import { Nullable } from './Nullable'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
import Field from './Field'; | ||
import Nullable from './Nullable'; | ||
declare type WhenString = 'valid' | '*' | 'badInput' | 'patternMismatch' | 'rangeOverflow' | 'rangeUnderflow' | 'stepMismatch' | 'tooLong' | 'tooShort' | 'typeMismatch' | 'valueMissing'; | ||
@@ -12,0 +12,0 @@ declare type WhenFn = (value: string) => boolean; |
@@ -7,3 +7,3 @@ import * as React from 'react'; | ||
import { FieldFeedbackWhenValid } from './FieldFeedbackWhenValid'; | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
export class FieldFeedback extends React.Component { | ||
@@ -10,0 +10,0 @@ constructor(props, context) { |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { InputElement } from './InputElement'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import { Nullable } from './Nullable'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
import Nullable from './Nullable'; | ||
export interface FieldFeedbacksProps { | ||
@@ -18,3 +18,3 @@ for?: string; | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
emitValidateFieldEvent(input: InputElement): Promise<(FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined)[]>; | ||
@@ -21,0 +21,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | Promise<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined> | undefined): void; |
@@ -5,3 +5,3 @@ import * as React from 'react'; | ||
import { withValidateFieldEventEmitter } from './withValidateFieldEventEmitter'; | ||
import { flattenDeep } from './flattenDeep'; | ||
import flattenDeep from './flattenDeep'; | ||
class FieldFeedbacksComponent extends React.PureComponent { | ||
@@ -8,0 +8,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare enum FieldFeedbackType { | ||
declare enum FieldFeedbackType { | ||
Error = "error", | ||
@@ -7,1 +7,2 @@ Warning = "warning", | ||
} | ||
export default FieldFeedbackType; |
@@ -1,2 +0,2 @@ | ||
export var FieldFeedbackType; | ||
var FieldFeedbackType; | ||
(function (FieldFeedbackType) { | ||
@@ -8,1 +8,2 @@ FieldFeedbackType["Error"] = "error"; | ||
})(FieldFeedbackType || (FieldFeedbackType = {})); | ||
export default FieldFeedbackType; |
@@ -1,3 +0,3 @@ | ||
import { FieldFeedbackType } from './FieldFeedbackType'; | ||
export interface FieldFeedbackValidation { | ||
import FieldFeedbackType from './FieldFeedbackType'; | ||
export default interface FieldFeedbackValidation { | ||
readonly key: string; | ||
@@ -4,0 +4,0 @@ readonly type: FieldFeedbackType; |
@@ -5,3 +5,3 @@ import * as React from 'react'; | ||
import { FieldFeedbackClasses } from './FieldFeedback'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
export interface FieldFeedbackWhenValidBaseProps { | ||
@@ -8,0 +8,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { Field } from './Field'; | ||
import { EventEmitter } from './EventEmitter'; | ||
import Field from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
export declare enum FieldEvent { | ||
@@ -4,0 +4,0 @@ Added = "FIELD_ADDED", |
@@ -1,3 +0,3 @@ | ||
import { Field } from './Field'; | ||
import { EventEmitter } from './EventEmitter'; | ||
import Field from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
export var FieldEvent; | ||
@@ -4,0 +4,0 @@ (function (FieldEvent) { |
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> { | ||
} | ||
export declare function flattenDeep<T>(arrayOfArrays: RecursiveArray<T>): T[]; | ||
export default function flattenDeep<T>(arrayOfArrays: RecursiveArray<T>): T[]; | ||
export {}; |
@@ -1,3 +0,3 @@ | ||
export function flattenDeep(arrayOfArrays) { | ||
export default function flattenDeep(arrayOfArrays) { | ||
return arrayOfArrays.reduce((prev, curr) => prev.concat(Array.isArray(curr) ? flattenDeep(curr) : curr), []); | ||
} |
import * as React from 'react'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
import { IHTMLInput, InputElement } from './InputElement'; | ||
import { FieldsStore } from './FieldsStore'; | ||
import { FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
import FieldFeedbackValidation from './FieldFeedbackValidation'; | ||
export interface FormWithConstraintsChildContext { | ||
@@ -15,3 +15,3 @@ form: FormWithConstraints; | ||
new (...args: any[]): { | ||
fieldDidResetEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldDidResetEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldDidResetEvent(field: Field): Promise<void[]>; | ||
@@ -23,3 +23,3 @@ addFieldDidResetEventListener(listener: (field: Field) => void): void; | ||
new (...args: any[]): { | ||
fieldWillValidateEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldWillValidateEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldWillValidateEvent(fieldName: string): Promise<void[]>; | ||
@@ -31,3 +31,3 @@ addFieldWillValidateEventListener(listener: (fieldName: string) => void): void; | ||
new (...args: any[]): { | ||
fieldDidValidateEventEmitter: import("./EventEmitter").EventEmitter<void>; | ||
fieldDidValidateEventEmitter: import("./EventEmitter").default<void>; | ||
emitFieldDidValidateEvent(field: Field): Promise<void[]>; | ||
@@ -39,3 +39,3 @@ addFieldDidValidateEventListener(listener: (field: Field) => void): void; | ||
new (...args: any[]): { | ||
validateFieldEventEmitter: import("./EventEmitter").EventEmitter<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
validateFieldEventEmitter: import("./EventEmitter").default<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined>; | ||
emitValidateFieldEvent(input: InputElement): Promise<(FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined)[]>; | ||
@@ -42,0 +42,0 @@ addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | Promise<FieldFeedbackValidation | (FieldFeedbackValidation | undefined)[] | undefined> | undefined): void; |
@@ -9,4 +9,4 @@ import * as React from 'react'; | ||
import { FieldsStore } from './FieldsStore'; | ||
import { flattenDeep } from './flattenDeep'; | ||
import { notUndefined } from './notUndefined'; | ||
import flattenDeep from './flattenDeep'; | ||
import notUndefined from './notUndefined'; | ||
class FormWithConstraintsComponent extends React.PureComponent { | ||
@@ -13,0 +13,0 @@ } |
export * from './FormWithConstraints'; | ||
export * from './FieldFeedbacks'; | ||
export * from './FieldFeedback'; | ||
export * from './FieldFeedbackType'; | ||
export { default as FieldFeedbackType } from './FieldFeedbackType'; | ||
export * from './FieldFeedbackWhenValid'; | ||
export * from './Async'; | ||
export * from './Field'; | ||
export { default as Field } from './Field'; | ||
export * from './FieldsStore'; | ||
export * from './EventEmitter'; | ||
export { default as EventEmitter } from './EventEmitter'; | ||
export * from './withValidateFieldEventEmitter'; | ||
@@ -14,6 +14,6 @@ export * from './withFieldWillValidateEventEmitter'; | ||
export * from './withFieldDidResetEventEmitter'; | ||
export * from './FieldFeedbackValidation'; | ||
export { default as FieldFeedbackValidation } from './FieldFeedbackValidation'; | ||
export * from './InputElement'; | ||
export * from './Constructor'; | ||
export { default as Constructor } from './Constructor'; | ||
export * from './Input'; | ||
export * from './deepForEach'; | ||
export { default as deepForEach } from './deepForEach'; |
export * from './FormWithConstraints'; | ||
export * from './FieldFeedbacks'; | ||
export * from './FieldFeedback'; | ||
export * from './FieldFeedbackType'; | ||
export { default as FieldFeedbackType } from './FieldFeedbackType'; | ||
export * from './FieldFeedbackWhenValid'; | ||
export * from './Async'; | ||
export * from './Field'; | ||
export { default as Field } from './Field'; | ||
export * from './FieldsStore'; | ||
export * from './EventEmitter'; | ||
export { default as EventEmitter } from './EventEmitter'; | ||
export * from './withValidateFieldEventEmitter'; | ||
@@ -14,6 +14,4 @@ export * from './withFieldWillValidateEventEmitter'; | ||
export * from './withFieldDidResetEventEmitter'; | ||
export * from './FieldFeedbackValidation'; | ||
export * from './InputElement'; | ||
export * from './Constructor'; | ||
export * from './Input'; | ||
export * from './deepForEach'; | ||
export { default as deepForEach } from './deepForEach'; |
import * as React from 'react'; | ||
import { FormWithConstraintsChildContext } from './FormWithConstraints'; | ||
import { Field } from './Field'; | ||
import Field from './Field'; | ||
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> { | ||
@@ -5,0 +5,0 @@ innerRef?: React.Ref<HTMLInputElement>; |
@@ -1,1 +0,1 @@ | ||
export declare function notUndefined<T>(value: T | undefined): value is T; | ||
export default function notUndefined<T>(value: T | undefined): value is T; |
@@ -1,3 +0,3 @@ | ||
export function notUndefined(value) { | ||
export default function notUndefined(value) { | ||
return value !== undefined; | ||
} |
@@ -1,3 +0,4 @@ | ||
export declare type Nullable<T> = { | ||
declare type Nullable<T> = { | ||
[P in keyof T]: T[P] | null; | ||
}; | ||
export default Nullable; |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import { Field } from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
import Field from './Field'; | ||
export declare const FieldDidResetEvent = "FIELD_DID_RESET_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withFieldDidResetEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -1,2 +0,2 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import EventEmitter from './EventEmitter'; | ||
export const FieldDidResetEvent = 'FIELD_DID_RESET_EVENT'; | ||
@@ -3,0 +3,0 @@ export function withFieldDidResetEventEmitter(Base) { |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import { Field } from './Field'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
import Field from './Field'; | ||
export declare const FieldDidValidateEvent = "FIELD_DID_VALIDATE_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withFieldDidValidateEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -1,2 +0,2 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import EventEmitter from './EventEmitter'; | ||
export const FieldDidValidateEvent = 'FIELD_DID_VALIDATE_EVENT'; | ||
@@ -3,0 +3,0 @@ export function withFieldDidValidateEventEmitter(Base) { |
@@ -1,3 +0,3 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import { Constructor } from './Constructor'; | ||
import EventEmitter from './EventEmitter'; | ||
import Constructor from './Constructor'; | ||
export declare const FieldWillValidateEvent = "FIELD_WILL_VALIDATE_EVENT"; | ||
@@ -4,0 +4,0 @@ export declare function withFieldWillValidateEventEmitter<TBase extends Constructor<{}>>(Base: TBase): { |
@@ -1,2 +0,2 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import EventEmitter from './EventEmitter'; | ||
export const FieldWillValidateEvent = 'FIELD_WILL_VALIDATE_EVENT'; | ||
@@ -3,0 +3,0 @@ export function withFieldWillValidateEventEmitter(Base) { |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import EventEmitter from './EventEmitter'; | ||
import { InputElement } from './InputElement'; | ||
import { Constructor } from './Constructor'; | ||
import Constructor from './Constructor'; | ||
export declare const ValidateFieldEvent = "VALIDATE_FIELD_EVENT"; | ||
@@ -5,0 +5,0 @@ export declare function withValidateFieldEventEmitter<ListenerReturnType, TBase extends Constructor<{}>>(Base: TBase): { |
@@ -1,2 +0,2 @@ | ||
import { EventEmitter } from './EventEmitter'; | ||
import EventEmitter from './EventEmitter'; | ||
export const ValidateFieldEvent = 'VALIDATE_FIELD_EVENT'; | ||
@@ -3,0 +3,0 @@ export function withValidateFieldEventEmitter(Base) { |
{ | ||
"name": "react-form-with-constraints", | ||
"version": "0.14.3-beta.1", | ||
"version": "0.14.3-beta.2", | ||
"repository": { | ||
@@ -71,3 +71,3 @@ "type": "git", | ||
}, | ||
"gitHead": "1a7cde990822fb6612ecf7df8f743c3905121975" | ||
"gitHead": "cb28942f207177aa8fcd2e568981902a6d6add85" | ||
} |
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
4770
266029
120