redux-freeform 5.6.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/redux-freeform.cjs.js +60 -26
- package/dist/redux-freeform.esm.js +60 -26
- package/dist/redux-freeform.umd.js +60 -26
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof win
|
|
|
12
12
|
var dayjs_min = {exports: {}};
|
|
13
13
|
|
|
14
14
|
(function (module, exports) {
|
|
15
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date"
|
|
15
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
|
|
16
16
|
}(dayjs_min));
|
|
17
17
|
|
|
18
18
|
var dayjs = dayjs_min.exports;
|
|
@@ -20,7 +20,7 @@ var dayjs = dayjs_min.exports;
|
|
|
20
20
|
var customParseFormat$1 = {exports: {}};
|
|
21
21
|
|
|
22
22
|
(function (module, exports) {
|
|
23
|
-
!function(t
|
|
23
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
|
|
24
24
|
}(customParseFormat$1));
|
|
25
25
|
|
|
26
26
|
var customParseFormat = customParseFormat$1.exports;
|
|
@@ -485,7 +485,7 @@ const runValidator = (validator, value, form) => {
|
|
|
485
485
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
486
486
|
};
|
|
487
487
|
|
|
488
|
-
const
|
|
488
|
+
const runFormValidators = (fieldName, form, validators) => {
|
|
489
489
|
return validators
|
|
490
490
|
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
491
491
|
.filter(x => x !== null);
|
|
@@ -493,12 +493,32 @@ const _computeErrors = (fieldName, form, validators) => {
|
|
|
493
493
|
|
|
494
494
|
const computeConstraints = (fieldName, form) => {
|
|
495
495
|
const constraints = form[fieldName].constraints;
|
|
496
|
-
return
|
|
496
|
+
return runFormValidators(fieldName, form, constraints);
|
|
497
497
|
};
|
|
498
498
|
|
|
499
499
|
const computeErrors = (fieldName, form) => {
|
|
500
500
|
const validators = form[fieldName].validators;
|
|
501
|
-
return
|
|
501
|
+
return runFormValidators(fieldName, form, validators);
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
const computeErrorEntries = (formState) => {
|
|
505
|
+
const fields = Object.entries(formState);
|
|
506
|
+
for (let entry of fields) {
|
|
507
|
+
let fieldName = entry[0];
|
|
508
|
+
let errors = computeErrors(fieldName, formState);
|
|
509
|
+
formState[fieldName].errors = errors;
|
|
510
|
+
formState[fieldName].hasErrors = errors.length > 0;
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
const computeDirtyEntries = (formState, changedFieldName) => {
|
|
515
|
+
const fields = Object.entries(formState);
|
|
516
|
+
for (let entry of fields) {
|
|
517
|
+
let fieldName = entry[0];
|
|
518
|
+
let field = entry[1];
|
|
519
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
520
|
+
formState[fieldName].dirty = dirty;
|
|
521
|
+
}
|
|
502
522
|
};
|
|
503
523
|
|
|
504
524
|
var obj;
|
|
@@ -1654,6 +1674,7 @@ const createInitialState = formConfig => {
|
|
|
1654
1674
|
initialForm[formKey].errors = errors;
|
|
1655
1675
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
1656
1676
|
}
|
|
1677
|
+
|
|
1657
1678
|
return initialForm;
|
|
1658
1679
|
};
|
|
1659
1680
|
|
|
@@ -1672,6 +1693,18 @@ const addValidator = fieldName => validator => ({
|
|
|
1672
1693
|
payload: { fieldName, validator }
|
|
1673
1694
|
});
|
|
1674
1695
|
|
|
1696
|
+
const REMOVE_VALIDATOR = "field/REMOVE_VALIDATOR";
|
|
1697
|
+
const removeValidator = fieldName => validator => ({
|
|
1698
|
+
type: REMOVE_VALIDATOR,
|
|
1699
|
+
payload: { fieldName, validator }
|
|
1700
|
+
});
|
|
1701
|
+
|
|
1702
|
+
const CLEAR_FIELD_VALIDATORS = "field/CLEAR_FIELD_VALIDATORS";
|
|
1703
|
+
const clearFieldValidators = fieldName => () => ({
|
|
1704
|
+
type: CLEAR_FIELD_VALIDATORS,
|
|
1705
|
+
payload: { fieldName }
|
|
1706
|
+
});
|
|
1707
|
+
|
|
1675
1708
|
const createFormReducer = formConfig => (
|
|
1676
1709
|
state = createInitialState(formConfig),
|
|
1677
1710
|
action
|
|
@@ -1690,16 +1723,8 @@ const createFormReducer = formConfig => (
|
|
|
1690
1723
|
return draftState;
|
|
1691
1724
|
}
|
|
1692
1725
|
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
let fieldName = entry[0];
|
|
1696
|
-
let field = entry[1];
|
|
1697
|
-
let errors = computeErrors(fieldName, draftState);
|
|
1698
|
-
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
1699
|
-
draftState[fieldName].errors = errors;
|
|
1700
|
-
draftState[fieldName].dirty = dirty;
|
|
1701
|
-
draftState[fieldName].hasErrors = errors.length > 0;
|
|
1702
|
-
}
|
|
1726
|
+
computeDirtyEntries(draftState, changedFieldName);
|
|
1727
|
+
computeErrorEntries(draftState);
|
|
1703
1728
|
});
|
|
1704
1729
|
case CLEAR:
|
|
1705
1730
|
return createInitialState(formConfig);
|
|
@@ -1709,16 +1734,23 @@ const createFormReducer = formConfig => (
|
|
|
1709
1734
|
|
|
1710
1735
|
return produce(state, draftState => {
|
|
1711
1736
|
draftState[fieldWithOverride].validators.push(newValidator);
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1737
|
+
computeErrorEntries(draftState);
|
|
1738
|
+
});
|
|
1739
|
+
case REMOVE_VALIDATOR:
|
|
1740
|
+
const fieldToOverride = action.payload.fieldName;
|
|
1741
|
+
const targetValidator = action.payload.validator;
|
|
1742
|
+
|
|
1743
|
+
return produce(state, draftState => {
|
|
1744
|
+
let fieldValidators = draftState[fieldToOverride].validators;
|
|
1745
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(validator => validator.type !== targetValidator.type);
|
|
1746
|
+
computeErrorEntries(draftState);
|
|
1747
|
+
});
|
|
1748
|
+
case CLEAR_FIELD_VALIDATORS:
|
|
1749
|
+
const fieldToClear = action.payload.fieldName;
|
|
1750
|
+
|
|
1751
|
+
return produce(state, draftState => {
|
|
1752
|
+
draftState[fieldToClear].validators = [];
|
|
1753
|
+
computeErrorEntries(draftState);
|
|
1722
1754
|
});
|
|
1723
1755
|
default:
|
|
1724
1756
|
return state;
|
|
@@ -1739,7 +1771,9 @@ const createMapDispatchToProps = formConfig => {
|
|
|
1739
1771
|
for (let fieldName of keys) {
|
|
1740
1772
|
dispatchObj.fields[fieldName] = {
|
|
1741
1773
|
set: value => dispatch(set(fieldName)(value)),
|
|
1742
|
-
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
1774
|
+
addValidator: validator => dispatch(addValidator(fieldName)(validator)),
|
|
1775
|
+
removeValidator: validator => dispatch(removeValidator(fieldName)(validator)),
|
|
1776
|
+
clear: () => dispatch(clearFieldValidators(fieldName)())
|
|
1743
1777
|
};
|
|
1744
1778
|
}
|
|
1745
1779
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -8,7 +8,7 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof win
|
|
|
8
8
|
var dayjs_min = {exports: {}};
|
|
9
9
|
|
|
10
10
|
(function (module, exports) {
|
|
11
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date"
|
|
11
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
|
|
12
12
|
}(dayjs_min));
|
|
13
13
|
|
|
14
14
|
var dayjs = dayjs_min.exports;
|
|
@@ -16,7 +16,7 @@ var dayjs = dayjs_min.exports;
|
|
|
16
16
|
var customParseFormat$1 = {exports: {}};
|
|
17
17
|
|
|
18
18
|
(function (module, exports) {
|
|
19
|
-
!function(t
|
|
19
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
|
|
20
20
|
}(customParseFormat$1));
|
|
21
21
|
|
|
22
22
|
var customParseFormat = customParseFormat$1.exports;
|
|
@@ -481,7 +481,7 @@ const runValidator = (validator, value, form) => {
|
|
|
481
481
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
482
482
|
};
|
|
483
483
|
|
|
484
|
-
const
|
|
484
|
+
const runFormValidators = (fieldName, form, validators) => {
|
|
485
485
|
return validators
|
|
486
486
|
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
487
487
|
.filter(x => x !== null);
|
|
@@ -489,12 +489,32 @@ const _computeErrors = (fieldName, form, validators) => {
|
|
|
489
489
|
|
|
490
490
|
const computeConstraints = (fieldName, form) => {
|
|
491
491
|
const constraints = form[fieldName].constraints;
|
|
492
|
-
return
|
|
492
|
+
return runFormValidators(fieldName, form, constraints);
|
|
493
493
|
};
|
|
494
494
|
|
|
495
495
|
const computeErrors = (fieldName, form) => {
|
|
496
496
|
const validators = form[fieldName].validators;
|
|
497
|
-
return
|
|
497
|
+
return runFormValidators(fieldName, form, validators);
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
const computeErrorEntries = (formState) => {
|
|
501
|
+
const fields = Object.entries(formState);
|
|
502
|
+
for (let entry of fields) {
|
|
503
|
+
let fieldName = entry[0];
|
|
504
|
+
let errors = computeErrors(fieldName, formState);
|
|
505
|
+
formState[fieldName].errors = errors;
|
|
506
|
+
formState[fieldName].hasErrors = errors.length > 0;
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const computeDirtyEntries = (formState, changedFieldName) => {
|
|
511
|
+
const fields = Object.entries(formState);
|
|
512
|
+
for (let entry of fields) {
|
|
513
|
+
let fieldName = entry[0];
|
|
514
|
+
let field = entry[1];
|
|
515
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
516
|
+
formState[fieldName].dirty = dirty;
|
|
517
|
+
}
|
|
498
518
|
};
|
|
499
519
|
|
|
500
520
|
var obj;
|
|
@@ -1650,6 +1670,7 @@ const createInitialState = formConfig => {
|
|
|
1650
1670
|
initialForm[formKey].errors = errors;
|
|
1651
1671
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
1652
1672
|
}
|
|
1673
|
+
|
|
1653
1674
|
return initialForm;
|
|
1654
1675
|
};
|
|
1655
1676
|
|
|
@@ -1668,6 +1689,18 @@ const addValidator = fieldName => validator => ({
|
|
|
1668
1689
|
payload: { fieldName, validator }
|
|
1669
1690
|
});
|
|
1670
1691
|
|
|
1692
|
+
const REMOVE_VALIDATOR = "field/REMOVE_VALIDATOR";
|
|
1693
|
+
const removeValidator = fieldName => validator => ({
|
|
1694
|
+
type: REMOVE_VALIDATOR,
|
|
1695
|
+
payload: { fieldName, validator }
|
|
1696
|
+
});
|
|
1697
|
+
|
|
1698
|
+
const CLEAR_FIELD_VALIDATORS = "field/CLEAR_FIELD_VALIDATORS";
|
|
1699
|
+
const clearFieldValidators = fieldName => () => ({
|
|
1700
|
+
type: CLEAR_FIELD_VALIDATORS,
|
|
1701
|
+
payload: { fieldName }
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1671
1704
|
const createFormReducer = formConfig => (
|
|
1672
1705
|
state = createInitialState(formConfig),
|
|
1673
1706
|
action
|
|
@@ -1686,16 +1719,8 @@ const createFormReducer = formConfig => (
|
|
|
1686
1719
|
return draftState;
|
|
1687
1720
|
}
|
|
1688
1721
|
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
let fieldName = entry[0];
|
|
1692
|
-
let field = entry[1];
|
|
1693
|
-
let errors = computeErrors(fieldName, draftState);
|
|
1694
|
-
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
1695
|
-
draftState[fieldName].errors = errors;
|
|
1696
|
-
draftState[fieldName].dirty = dirty;
|
|
1697
|
-
draftState[fieldName].hasErrors = errors.length > 0;
|
|
1698
|
-
}
|
|
1722
|
+
computeDirtyEntries(draftState, changedFieldName);
|
|
1723
|
+
computeErrorEntries(draftState);
|
|
1699
1724
|
});
|
|
1700
1725
|
case CLEAR:
|
|
1701
1726
|
return createInitialState(formConfig);
|
|
@@ -1705,16 +1730,23 @@ const createFormReducer = formConfig => (
|
|
|
1705
1730
|
|
|
1706
1731
|
return produce(state, draftState => {
|
|
1707
1732
|
draftState[fieldWithOverride].validators.push(newValidator);
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1733
|
+
computeErrorEntries(draftState);
|
|
1734
|
+
});
|
|
1735
|
+
case REMOVE_VALIDATOR:
|
|
1736
|
+
const fieldToOverride = action.payload.fieldName;
|
|
1737
|
+
const targetValidator = action.payload.validator;
|
|
1738
|
+
|
|
1739
|
+
return produce(state, draftState => {
|
|
1740
|
+
let fieldValidators = draftState[fieldToOverride].validators;
|
|
1741
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(validator => validator.type !== targetValidator.type);
|
|
1742
|
+
computeErrorEntries(draftState);
|
|
1743
|
+
});
|
|
1744
|
+
case CLEAR_FIELD_VALIDATORS:
|
|
1745
|
+
const fieldToClear = action.payload.fieldName;
|
|
1746
|
+
|
|
1747
|
+
return produce(state, draftState => {
|
|
1748
|
+
draftState[fieldToClear].validators = [];
|
|
1749
|
+
computeErrorEntries(draftState);
|
|
1718
1750
|
});
|
|
1719
1751
|
default:
|
|
1720
1752
|
return state;
|
|
@@ -1735,7 +1767,9 @@ const createMapDispatchToProps = formConfig => {
|
|
|
1735
1767
|
for (let fieldName of keys) {
|
|
1736
1768
|
dispatchObj.fields[fieldName] = {
|
|
1737
1769
|
set: value => dispatch(set(fieldName)(value)),
|
|
1738
|
-
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
1770
|
+
addValidator: validator => dispatch(addValidator(fieldName)(validator)),
|
|
1771
|
+
removeValidator: validator => dispatch(removeValidator(fieldName)(validator)),
|
|
1772
|
+
clear: () => dispatch(clearFieldValidators(fieldName)())
|
|
1739
1773
|
};
|
|
1740
1774
|
}
|
|
1741
1775
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
var dayjs_min = {exports: {}};
|
|
15
15
|
|
|
16
16
|
(function (module, exports) {
|
|
17
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date"
|
|
17
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
|
|
18
18
|
}(dayjs_min));
|
|
19
19
|
|
|
20
20
|
var dayjs = dayjs_min.exports;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
var customParseFormat$1 = {exports: {}};
|
|
23
23
|
|
|
24
24
|
(function (module, exports) {
|
|
25
|
-
!function(t
|
|
25
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
|
|
26
26
|
}(customParseFormat$1));
|
|
27
27
|
|
|
28
28
|
var customParseFormat = customParseFormat$1.exports;
|
|
@@ -487,7 +487,7 @@
|
|
|
487
487
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
488
488
|
};
|
|
489
489
|
|
|
490
|
-
const
|
|
490
|
+
const runFormValidators = (fieldName, form, validators) => {
|
|
491
491
|
return validators
|
|
492
492
|
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
493
493
|
.filter(x => x !== null);
|
|
@@ -495,12 +495,32 @@
|
|
|
495
495
|
|
|
496
496
|
const computeConstraints = (fieldName, form) => {
|
|
497
497
|
const constraints = form[fieldName].constraints;
|
|
498
|
-
return
|
|
498
|
+
return runFormValidators(fieldName, form, constraints);
|
|
499
499
|
};
|
|
500
500
|
|
|
501
501
|
const computeErrors = (fieldName, form) => {
|
|
502
502
|
const validators = form[fieldName].validators;
|
|
503
|
-
return
|
|
503
|
+
return runFormValidators(fieldName, form, validators);
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
const computeErrorEntries = (formState) => {
|
|
507
|
+
const fields = Object.entries(formState);
|
|
508
|
+
for (let entry of fields) {
|
|
509
|
+
let fieldName = entry[0];
|
|
510
|
+
let errors = computeErrors(fieldName, formState);
|
|
511
|
+
formState[fieldName].errors = errors;
|
|
512
|
+
formState[fieldName].hasErrors = errors.length > 0;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
const computeDirtyEntries = (formState, changedFieldName) => {
|
|
517
|
+
const fields = Object.entries(formState);
|
|
518
|
+
for (let entry of fields) {
|
|
519
|
+
let fieldName = entry[0];
|
|
520
|
+
let field = entry[1];
|
|
521
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
522
|
+
formState[fieldName].dirty = dirty;
|
|
523
|
+
}
|
|
504
524
|
};
|
|
505
525
|
|
|
506
526
|
var obj;
|
|
@@ -1656,6 +1676,7 @@
|
|
|
1656
1676
|
initialForm[formKey].errors = errors;
|
|
1657
1677
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
1658
1678
|
}
|
|
1679
|
+
|
|
1659
1680
|
return initialForm;
|
|
1660
1681
|
};
|
|
1661
1682
|
|
|
@@ -1674,6 +1695,18 @@
|
|
|
1674
1695
|
payload: { fieldName, validator }
|
|
1675
1696
|
});
|
|
1676
1697
|
|
|
1698
|
+
const REMOVE_VALIDATOR = "field/REMOVE_VALIDATOR";
|
|
1699
|
+
const removeValidator = fieldName => validator => ({
|
|
1700
|
+
type: REMOVE_VALIDATOR,
|
|
1701
|
+
payload: { fieldName, validator }
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
const CLEAR_FIELD_VALIDATORS = "field/CLEAR_FIELD_VALIDATORS";
|
|
1705
|
+
const clearFieldValidators = fieldName => () => ({
|
|
1706
|
+
type: CLEAR_FIELD_VALIDATORS,
|
|
1707
|
+
payload: { fieldName }
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1677
1710
|
const createFormReducer = formConfig => (
|
|
1678
1711
|
state = createInitialState(formConfig),
|
|
1679
1712
|
action
|
|
@@ -1692,16 +1725,8 @@
|
|
|
1692
1725
|
return draftState;
|
|
1693
1726
|
}
|
|
1694
1727
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
let fieldName = entry[0];
|
|
1698
|
-
let field = entry[1];
|
|
1699
|
-
let errors = computeErrors(fieldName, draftState);
|
|
1700
|
-
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
1701
|
-
draftState[fieldName].errors = errors;
|
|
1702
|
-
draftState[fieldName].dirty = dirty;
|
|
1703
|
-
draftState[fieldName].hasErrors = errors.length > 0;
|
|
1704
|
-
}
|
|
1728
|
+
computeDirtyEntries(draftState, changedFieldName);
|
|
1729
|
+
computeErrorEntries(draftState);
|
|
1705
1730
|
});
|
|
1706
1731
|
case CLEAR:
|
|
1707
1732
|
return createInitialState(formConfig);
|
|
@@ -1711,16 +1736,23 @@
|
|
|
1711
1736
|
|
|
1712
1737
|
return produce(state, draftState => {
|
|
1713
1738
|
draftState[fieldWithOverride].validators.push(newValidator);
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1739
|
+
computeErrorEntries(draftState);
|
|
1740
|
+
});
|
|
1741
|
+
case REMOVE_VALIDATOR:
|
|
1742
|
+
const fieldToOverride = action.payload.fieldName;
|
|
1743
|
+
const targetValidator = action.payload.validator;
|
|
1744
|
+
|
|
1745
|
+
return produce(state, draftState => {
|
|
1746
|
+
let fieldValidators = draftState[fieldToOverride].validators;
|
|
1747
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(validator => validator.type !== targetValidator.type);
|
|
1748
|
+
computeErrorEntries(draftState);
|
|
1749
|
+
});
|
|
1750
|
+
case CLEAR_FIELD_VALIDATORS:
|
|
1751
|
+
const fieldToClear = action.payload.fieldName;
|
|
1752
|
+
|
|
1753
|
+
return produce(state, draftState => {
|
|
1754
|
+
draftState[fieldToClear].validators = [];
|
|
1755
|
+
computeErrorEntries(draftState);
|
|
1724
1756
|
});
|
|
1725
1757
|
default:
|
|
1726
1758
|
return state;
|
|
@@ -1741,7 +1773,9 @@
|
|
|
1741
1773
|
for (let fieldName of keys) {
|
|
1742
1774
|
dispatchObj.fields[fieldName] = {
|
|
1743
1775
|
set: value => dispatch(set(fieldName)(value)),
|
|
1744
|
-
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
1776
|
+
addValidator: validator => dispatch(addValidator(fieldName)(validator)),
|
|
1777
|
+
removeValidator: validator => dispatch(removeValidator(fieldName)(validator)),
|
|
1778
|
+
clear: () => dispatch(clearFieldValidators(fieldName)())
|
|
1745
1779
|
};
|
|
1746
1780
|
}
|
|
1747
1781
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
package/package.json
CHANGED