redux-freeform 5.7.0 → 5.8.0-beta.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/CHANGELOG.md +0 -0
- package/dist/redux-freeform.cjs.js +52 -45
- package/dist/redux-freeform.esm.js +52 -45
- package/dist/redux-freeform.umd.js +52 -45
- package/package.json +31 -25
package/CHANGELOG.md
ADDED
|
File without changes
|
|
@@ -2,44 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
6
|
-
value,
|
|
7
|
-
...rest
|
|
8
|
-
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
5
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (value, ...rest) =>
|
|
6
|
+
value === "" ? emptyCase : validatorFn(value, ...rest);
|
|
9
7
|
|
|
10
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
11
9
|
|
|
10
|
+
function getDefaultExportFromCjs (x) {
|
|
11
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
12
|
+
}
|
|
13
|
+
|
|
12
14
|
var dayjs_min = {exports: {}};
|
|
13
15
|
|
|
16
|
+
dayjs_min.exports;
|
|
17
|
+
|
|
14
18
|
(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"
|
|
16
|
-
}(dayjs_min));
|
|
19
|
+
!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",$="Invalid Date",l=/^(\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("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={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}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},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=g;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(l);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()===$)},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),$=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)},l=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,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"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":""),$=(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],l=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 $&&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,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||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||$;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].substr(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},l={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||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[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}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[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=v[D],w.Ls=v,w.p={},w}));
|
|
20
|
+
} (dayjs_min, dayjs_min.exports));
|
|
17
21
|
|
|
18
|
-
var
|
|
22
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
23
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
19
24
|
|
|
20
25
|
var customParseFormat$1 = {exports: {}};
|
|
21
26
|
|
|
27
|
+
customParseFormat$1.exports;
|
|
28
|
+
|
|
22
29
|
(function (module, exports) {
|
|
23
|
-
!function(e
|
|
24
|
-
}(customParseFormat$1));
|
|
30
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={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"},e=/(\[[^[]*\])|([-:/.()\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(t){return (t=+t)+(t>68?1900:2e3)};var a=function(t){return function(e){this[t]=+e;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(t){(this.zone||(this.zone={})).offset=function(t){if(!t)return 0;if("Z"===t)return 0;var e=t.match(/([+-]|\d\d)/g),n=60*e[1]+(+e[2]||0);return 0===n?0:"+"===e[0]?-n:n}(t);}],u=function(t){var e=o[t];return e&&(e.indexOf?e:e.s.concat(e.f))},h=function(t,e){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(t.indexOf(r(i,0,e))>-1){n=i>12;break}}else n=t===(e?"pm":"PM");return n},d={A:[i,function(t){this.afternoon=h(t,!1);}],a:[i,function(t){this.afternoon=h(t,!0);}],S:[/\d/,function(t){this.milliseconds=100*+t;}],SS:[n,function(t){this.milliseconds=10*+t;}],SSS:[/\d{3}/,function(t){this.milliseconds=+t;}],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(t){var e=o.ordinal,n=t.match(/\d+/);if(this.day=n[0],e)for(var r=1;r<=31;r+=1)e(r).replace(/\[|\]/g,"")===t&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(t){var e=u("months"),n=(u("monthsShort")||e.map((function(t){return t.substr(0,3)}))).indexOf(t)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(t){var e=u("months").indexOf(t)+1;if(e<1)throw new Error;this.month=e%12||e;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(t){this.year=s(t);}],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(e,n,r){var o=r&&r.toUpperCase();return n||i[r]||t[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,e,n){return e||n.slice(1)}))}))).match(e),a=s.length,f=0;f<a;f+=1){var u=s[f],h=d[u],c=h&&h[0],l=h&&h[1];s[f]=l?{regex:c,parser:l}:u.replace(/^\[|\]$/g,"");}return function(t){for(var e={},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,u=t.substr(r),h=o.exec(u)[0];f.call(e,h),t=t.replace(h,"");}}return function(t){var e=t.afternoon;if(void 0!==e){var n=t.hours;e?n<12&&(t.hours+=12):12===n&&(t.hours=0),delete t.afternoon;}}(e),e}}return function(t,e,n){n.p.customParseFormat=!0,t&&t.parseTwoDigitYear&&(s=t.parseTwoDigitYear);var r=e.prototype,i=r.parse;r.parse=function(t){var e=t.date,r=t.utc,s=t.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],u=!0===s[3],h=f||u,d=s[2];u&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(t,e,n){try{if(["x","X"].indexOf(e)>-1)return new Date(("X"===e?1e3:1)*t);var r=c(e)(t),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,u=r.seconds,h=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=u||0,g=h||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(t){return new Date("")}}(e,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),h&&e!=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,t);};}}));
|
|
31
|
+
} (customParseFormat$1, customParseFormat$1.exports));
|
|
25
32
|
|
|
26
|
-
var
|
|
33
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
34
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
27
35
|
|
|
28
36
|
var isSameOrBefore$1 = {exports: {}};
|
|
29
37
|
|
|
38
|
+
isSameOrBefore$1.exports;
|
|
39
|
+
|
|
30
40
|
(function (module, exports) {
|
|
31
|
-
!function(e,i){module.exports=i();}(commonjsGlobal,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
32
|
-
}(isSameOrBefore$1));
|
|
41
|
+
!function(e,i){module.exports=i();}(commonjsGlobal,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
42
|
+
} (isSameOrBefore$1, isSameOrBefore$1.exports));
|
|
33
43
|
|
|
34
|
-
var
|
|
44
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
45
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
35
46
|
|
|
36
47
|
var isSameOrAfter$1 = {exports: {}};
|
|
37
48
|
|
|
49
|
+
isSameOrAfter$1.exports;
|
|
50
|
+
|
|
38
51
|
(function (module, exports) {
|
|
39
|
-
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
40
|
-
}(isSameOrAfter$1));
|
|
52
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
53
|
+
} (isSameOrAfter$1, isSameOrAfter$1.exports));
|
|
41
54
|
|
|
42
|
-
var
|
|
55
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
56
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
43
57
|
|
|
44
58
|
/* eslint-disable no-unused-vars */
|
|
45
59
|
|
|
@@ -107,8 +121,7 @@ validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
|
107
121
|
return Number(value) < args[0];
|
|
108
122
|
};
|
|
109
123
|
|
|
110
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
111
|
-
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
124
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO = "validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
112
125
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
113
126
|
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
114
127
|
const numberLessThanOrEqualTo = createValidator(
|
|
@@ -174,11 +187,7 @@ const validateWhenErrorMessage = type =>
|
|
|
174
187
|
|
|
175
188
|
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
176
189
|
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
177
|
-
const validateWhen = (
|
|
178
|
-
dependentValidator,
|
|
179
|
-
primaryValidator,
|
|
180
|
-
optionalFieldName
|
|
181
|
-
) => ({
|
|
190
|
+
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
182
191
|
type: VALIDATE_WHEN,
|
|
183
192
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
184
193
|
error: dependentValidator.error
|
|
@@ -214,11 +223,7 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
214
223
|
);
|
|
215
224
|
|
|
216
225
|
return primaryPredicatePassed
|
|
217
|
-
? validatorFns[dependentValidator.type](
|
|
218
|
-
value,
|
|
219
|
-
dependentValidator.args,
|
|
220
|
-
form
|
|
221
|
-
)
|
|
226
|
+
? validatorFns[dependentValidator.type](value, dependentValidator.args, form)
|
|
222
227
|
: true;
|
|
223
228
|
};
|
|
224
229
|
|
|
@@ -277,9 +282,7 @@ validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
|
277
282
|
);
|
|
278
283
|
}
|
|
279
284
|
if (max < min) {
|
|
280
|
-
throw new Error(
|
|
281
|
-
"hasLength validator was passed a min greater than the max"
|
|
282
|
-
);
|
|
285
|
+
throw new Error("hasLength validator was passed a min greater than the max");
|
|
283
286
|
}
|
|
284
287
|
const valueLength = value.length;
|
|
285
288
|
return max >= valueLength && valueLength >= min;
|
|
@@ -343,10 +346,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
343
346
|
|
|
344
347
|
const IS_VALID_MONTH = "validator/IS_VALID_MONTH";
|
|
345
348
|
const IS_VALID_MONTH_ERROR = "error/IS_VALID_MONTH";
|
|
346
|
-
const isValidMonth = createValidator(
|
|
347
|
-
IS_VALID_MONTH,
|
|
348
|
-
IS_VALID_MONTH_ERROR
|
|
349
|
-
);
|
|
349
|
+
const isValidMonth = createValidator(IS_VALID_MONTH, IS_VALID_MONTH_ERROR);
|
|
350
350
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
351
351
|
if (value === "") {
|
|
352
352
|
return true;
|
|
@@ -358,11 +358,11 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
358
358
|
// Only works with two digit months (01, 02, 03, etc)
|
|
359
359
|
const monthStartPosition = parseInt(args[0]);
|
|
360
360
|
const monthEndPosition = monthStartPosition + 2;
|
|
361
|
-
if (monthStartPosition
|
|
361
|
+
if (isNaN(monthStartPosition)) {
|
|
362
362
|
throw new Error("Month start position has to be a valid integer string");
|
|
363
363
|
}
|
|
364
364
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
365
|
-
if (month
|
|
365
|
+
if (isNaN(month)) {
|
|
366
366
|
return false;
|
|
367
367
|
}
|
|
368
368
|
return month >= 1 && month <= 12;
|
|
@@ -501,7 +501,7 @@ const computeErrors = (fieldName, form) => {
|
|
|
501
501
|
return runFormValidators(fieldName, form, validators);
|
|
502
502
|
};
|
|
503
503
|
|
|
504
|
-
const computeErrorEntries =
|
|
504
|
+
const computeErrorEntries = formState => {
|
|
505
505
|
const fields = Object.entries(formState);
|
|
506
506
|
for (let entry of fields) {
|
|
507
507
|
let fieldName = entry[0];
|
|
@@ -1710,7 +1710,7 @@ const createFormReducer = formConfig => (
|
|
|
1710
1710
|
action
|
|
1711
1711
|
) => {
|
|
1712
1712
|
switch (action.type) {
|
|
1713
|
-
case SET:
|
|
1713
|
+
case SET: {
|
|
1714
1714
|
const changedFieldName = action.payload.fieldName;
|
|
1715
1715
|
const newRawValue = action.payload.value;
|
|
1716
1716
|
|
|
@@ -1726,32 +1726,38 @@ const createFormReducer = formConfig => (
|
|
|
1726
1726
|
computeDirtyEntries(draftState, changedFieldName);
|
|
1727
1727
|
computeErrorEntries(draftState);
|
|
1728
1728
|
});
|
|
1729
|
+
}
|
|
1729
1730
|
case CLEAR:
|
|
1730
1731
|
return createInitialState(formConfig);
|
|
1731
|
-
case ADD_VALIDATOR:
|
|
1732
|
+
case ADD_VALIDATOR: {
|
|
1732
1733
|
const fieldWithOverride = action.payload.fieldName;
|
|
1733
1734
|
const newValidator = action.payload.validator;
|
|
1734
|
-
|
|
1735
|
+
|
|
1735
1736
|
return produce(state, draftState => {
|
|
1736
1737
|
draftState[fieldWithOverride].validators.push(newValidator);
|
|
1737
1738
|
computeErrorEntries(draftState);
|
|
1738
1739
|
});
|
|
1739
|
-
|
|
1740
|
+
}
|
|
1741
|
+
case REMOVE_VALIDATOR: {
|
|
1740
1742
|
const fieldToOverride = action.payload.fieldName;
|
|
1741
1743
|
const targetValidator = action.payload.validator;
|
|
1742
1744
|
|
|
1743
1745
|
return produce(state, draftState => {
|
|
1744
1746
|
let fieldValidators = draftState[fieldToOverride].validators;
|
|
1745
|
-
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
1747
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
1748
|
+
validator => validator.type !== targetValidator.type
|
|
1749
|
+
);
|
|
1746
1750
|
computeErrorEntries(draftState);
|
|
1747
1751
|
});
|
|
1748
|
-
|
|
1752
|
+
}
|
|
1753
|
+
case CLEAR_FIELD_VALIDATORS: {
|
|
1749
1754
|
const fieldToClear = action.payload.fieldName;
|
|
1750
1755
|
|
|
1751
1756
|
return produce(state, draftState => {
|
|
1752
1757
|
draftState[fieldToClear].validators = [];
|
|
1753
1758
|
computeErrorEntries(draftState);
|
|
1754
1759
|
});
|
|
1760
|
+
}
|
|
1755
1761
|
default:
|
|
1756
1762
|
return state;
|
|
1757
1763
|
}
|
|
@@ -1772,7 +1778,8 @@ const createMapDispatchToProps = formConfig => {
|
|
|
1772
1778
|
dispatchObj.fields[fieldName] = {
|
|
1773
1779
|
set: value => dispatch(set(fieldName)(value)),
|
|
1774
1780
|
addValidator: validator => dispatch(addValidator(fieldName)(validator)),
|
|
1775
|
-
removeValidator: validator =>
|
|
1781
|
+
removeValidator: validator =>
|
|
1782
|
+
dispatch(removeValidator(fieldName)(validator)),
|
|
1776
1783
|
clear: () => dispatch(clearFieldValidators(fieldName)())
|
|
1777
1784
|
};
|
|
1778
1785
|
}
|
|
@@ -1,41 +1,55 @@
|
|
|
1
|
-
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
2
|
-
value,
|
|
3
|
-
...rest
|
|
4
|
-
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
1
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (value, ...rest) =>
|
|
2
|
+
value === "" ? emptyCase : validatorFn(value, ...rest);
|
|
5
3
|
|
|
6
4
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
7
5
|
|
|
6
|
+
function getDefaultExportFromCjs (x) {
|
|
7
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
|
+
}
|
|
9
|
+
|
|
8
10
|
var dayjs_min = {exports: {}};
|
|
9
11
|
|
|
12
|
+
dayjs_min.exports;
|
|
13
|
+
|
|
10
14
|
(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"
|
|
12
|
-
}(dayjs_min));
|
|
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",$="Invalid Date",l=/^(\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("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={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}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},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=g;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(l);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()===$)},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),$=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)},l=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,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"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":""),$=(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],l=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 $&&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,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||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||$;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].substr(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},l={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||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[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}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[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=v[D],w.Ls=v,w.p={},w}));
|
|
16
|
+
} (dayjs_min, dayjs_min.exports));
|
|
13
17
|
|
|
14
|
-
var
|
|
18
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
19
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
15
20
|
|
|
16
21
|
var customParseFormat$1 = {exports: {}};
|
|
17
22
|
|
|
23
|
+
customParseFormat$1.exports;
|
|
24
|
+
|
|
18
25
|
(function (module, exports) {
|
|
19
|
-
!function(e
|
|
20
|
-
}(customParseFormat$1));
|
|
26
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={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"},e=/(\[[^[]*\])|([-:/.()\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(t){return (t=+t)+(t>68?1900:2e3)};var a=function(t){return function(e){this[t]=+e;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(t){(this.zone||(this.zone={})).offset=function(t){if(!t)return 0;if("Z"===t)return 0;var e=t.match(/([+-]|\d\d)/g),n=60*e[1]+(+e[2]||0);return 0===n?0:"+"===e[0]?-n:n}(t);}],u=function(t){var e=o[t];return e&&(e.indexOf?e:e.s.concat(e.f))},h=function(t,e){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(t.indexOf(r(i,0,e))>-1){n=i>12;break}}else n=t===(e?"pm":"PM");return n},d={A:[i,function(t){this.afternoon=h(t,!1);}],a:[i,function(t){this.afternoon=h(t,!0);}],S:[/\d/,function(t){this.milliseconds=100*+t;}],SS:[n,function(t){this.milliseconds=10*+t;}],SSS:[/\d{3}/,function(t){this.milliseconds=+t;}],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(t){var e=o.ordinal,n=t.match(/\d+/);if(this.day=n[0],e)for(var r=1;r<=31;r+=1)e(r).replace(/\[|\]/g,"")===t&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(t){var e=u("months"),n=(u("monthsShort")||e.map((function(t){return t.substr(0,3)}))).indexOf(t)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(t){var e=u("months").indexOf(t)+1;if(e<1)throw new Error;this.month=e%12||e;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(t){this.year=s(t);}],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(e,n,r){var o=r&&r.toUpperCase();return n||i[r]||t[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,e,n){return e||n.slice(1)}))}))).match(e),a=s.length,f=0;f<a;f+=1){var u=s[f],h=d[u],c=h&&h[0],l=h&&h[1];s[f]=l?{regex:c,parser:l}:u.replace(/^\[|\]$/g,"");}return function(t){for(var e={},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,u=t.substr(r),h=o.exec(u)[0];f.call(e,h),t=t.replace(h,"");}}return function(t){var e=t.afternoon;if(void 0!==e){var n=t.hours;e?n<12&&(t.hours+=12):12===n&&(t.hours=0),delete t.afternoon;}}(e),e}}return function(t,e,n){n.p.customParseFormat=!0,t&&t.parseTwoDigitYear&&(s=t.parseTwoDigitYear);var r=e.prototype,i=r.parse;r.parse=function(t){var e=t.date,r=t.utc,s=t.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],u=!0===s[3],h=f||u,d=s[2];u&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(t,e,n){try{if(["x","X"].indexOf(e)>-1)return new Date(("X"===e?1e3:1)*t);var r=c(e)(t),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,u=r.seconds,h=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=u||0,g=h||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(t){return new Date("")}}(e,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),h&&e!=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,t);};}}));
|
|
27
|
+
} (customParseFormat$1, customParseFormat$1.exports));
|
|
21
28
|
|
|
22
|
-
var
|
|
29
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
30
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
23
31
|
|
|
24
32
|
var isSameOrBefore$1 = {exports: {}};
|
|
25
33
|
|
|
34
|
+
isSameOrBefore$1.exports;
|
|
35
|
+
|
|
26
36
|
(function (module, exports) {
|
|
27
|
-
!function(e,i){module.exports=i();}(commonjsGlobal,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
28
|
-
}(isSameOrBefore$1));
|
|
37
|
+
!function(e,i){module.exports=i();}(commonjsGlobal,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
38
|
+
} (isSameOrBefore$1, isSameOrBefore$1.exports));
|
|
29
39
|
|
|
30
|
-
var
|
|
40
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
41
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
31
42
|
|
|
32
43
|
var isSameOrAfter$1 = {exports: {}};
|
|
33
44
|
|
|
45
|
+
isSameOrAfter$1.exports;
|
|
46
|
+
|
|
34
47
|
(function (module, exports) {
|
|
35
|
-
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
36
|
-
}(isSameOrAfter$1));
|
|
48
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
49
|
+
} (isSameOrAfter$1, isSameOrAfter$1.exports));
|
|
37
50
|
|
|
38
|
-
var
|
|
51
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
52
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
39
53
|
|
|
40
54
|
/* eslint-disable no-unused-vars */
|
|
41
55
|
|
|
@@ -103,8 +117,7 @@ validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
|
103
117
|
return Number(value) < args[0];
|
|
104
118
|
};
|
|
105
119
|
|
|
106
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
107
|
-
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
120
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO = "validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
108
121
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
109
122
|
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
110
123
|
const numberLessThanOrEqualTo = createValidator(
|
|
@@ -170,11 +183,7 @@ const validateWhenErrorMessage = type =>
|
|
|
170
183
|
|
|
171
184
|
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
172
185
|
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
173
|
-
const validateWhen = (
|
|
174
|
-
dependentValidator,
|
|
175
|
-
primaryValidator,
|
|
176
|
-
optionalFieldName
|
|
177
|
-
) => ({
|
|
186
|
+
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
178
187
|
type: VALIDATE_WHEN,
|
|
179
188
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
180
189
|
error: dependentValidator.error
|
|
@@ -210,11 +219,7 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
210
219
|
);
|
|
211
220
|
|
|
212
221
|
return primaryPredicatePassed
|
|
213
|
-
? validatorFns[dependentValidator.type](
|
|
214
|
-
value,
|
|
215
|
-
dependentValidator.args,
|
|
216
|
-
form
|
|
217
|
-
)
|
|
222
|
+
? validatorFns[dependentValidator.type](value, dependentValidator.args, form)
|
|
218
223
|
: true;
|
|
219
224
|
};
|
|
220
225
|
|
|
@@ -273,9 +278,7 @@ validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
|
273
278
|
);
|
|
274
279
|
}
|
|
275
280
|
if (max < min) {
|
|
276
|
-
throw new Error(
|
|
277
|
-
"hasLength validator was passed a min greater than the max"
|
|
278
|
-
);
|
|
281
|
+
throw new Error("hasLength validator was passed a min greater than the max");
|
|
279
282
|
}
|
|
280
283
|
const valueLength = value.length;
|
|
281
284
|
return max >= valueLength && valueLength >= min;
|
|
@@ -339,10 +342,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
339
342
|
|
|
340
343
|
const IS_VALID_MONTH = "validator/IS_VALID_MONTH";
|
|
341
344
|
const IS_VALID_MONTH_ERROR = "error/IS_VALID_MONTH";
|
|
342
|
-
const isValidMonth = createValidator(
|
|
343
|
-
IS_VALID_MONTH,
|
|
344
|
-
IS_VALID_MONTH_ERROR
|
|
345
|
-
);
|
|
345
|
+
const isValidMonth = createValidator(IS_VALID_MONTH, IS_VALID_MONTH_ERROR);
|
|
346
346
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
347
347
|
if (value === "") {
|
|
348
348
|
return true;
|
|
@@ -354,11 +354,11 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
354
354
|
// Only works with two digit months (01, 02, 03, etc)
|
|
355
355
|
const monthStartPosition = parseInt(args[0]);
|
|
356
356
|
const monthEndPosition = monthStartPosition + 2;
|
|
357
|
-
if (monthStartPosition
|
|
357
|
+
if (isNaN(monthStartPosition)) {
|
|
358
358
|
throw new Error("Month start position has to be a valid integer string");
|
|
359
359
|
}
|
|
360
360
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
361
|
-
if (month
|
|
361
|
+
if (isNaN(month)) {
|
|
362
362
|
return false;
|
|
363
363
|
}
|
|
364
364
|
return month >= 1 && month <= 12;
|
|
@@ -497,7 +497,7 @@ const computeErrors = (fieldName, form) => {
|
|
|
497
497
|
return runFormValidators(fieldName, form, validators);
|
|
498
498
|
};
|
|
499
499
|
|
|
500
|
-
const computeErrorEntries =
|
|
500
|
+
const computeErrorEntries = formState => {
|
|
501
501
|
const fields = Object.entries(formState);
|
|
502
502
|
for (let entry of fields) {
|
|
503
503
|
let fieldName = entry[0];
|
|
@@ -1706,7 +1706,7 @@ const createFormReducer = formConfig => (
|
|
|
1706
1706
|
action
|
|
1707
1707
|
) => {
|
|
1708
1708
|
switch (action.type) {
|
|
1709
|
-
case SET:
|
|
1709
|
+
case SET: {
|
|
1710
1710
|
const changedFieldName = action.payload.fieldName;
|
|
1711
1711
|
const newRawValue = action.payload.value;
|
|
1712
1712
|
|
|
@@ -1722,32 +1722,38 @@ const createFormReducer = formConfig => (
|
|
|
1722
1722
|
computeDirtyEntries(draftState, changedFieldName);
|
|
1723
1723
|
computeErrorEntries(draftState);
|
|
1724
1724
|
});
|
|
1725
|
+
}
|
|
1725
1726
|
case CLEAR:
|
|
1726
1727
|
return createInitialState(formConfig);
|
|
1727
|
-
case ADD_VALIDATOR:
|
|
1728
|
+
case ADD_VALIDATOR: {
|
|
1728
1729
|
const fieldWithOverride = action.payload.fieldName;
|
|
1729
1730
|
const newValidator = action.payload.validator;
|
|
1730
|
-
|
|
1731
|
+
|
|
1731
1732
|
return produce(state, draftState => {
|
|
1732
1733
|
draftState[fieldWithOverride].validators.push(newValidator);
|
|
1733
1734
|
computeErrorEntries(draftState);
|
|
1734
1735
|
});
|
|
1735
|
-
|
|
1736
|
+
}
|
|
1737
|
+
case REMOVE_VALIDATOR: {
|
|
1736
1738
|
const fieldToOverride = action.payload.fieldName;
|
|
1737
1739
|
const targetValidator = action.payload.validator;
|
|
1738
1740
|
|
|
1739
1741
|
return produce(state, draftState => {
|
|
1740
1742
|
let fieldValidators = draftState[fieldToOverride].validators;
|
|
1741
|
-
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
1743
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
1744
|
+
validator => validator.type !== targetValidator.type
|
|
1745
|
+
);
|
|
1742
1746
|
computeErrorEntries(draftState);
|
|
1743
1747
|
});
|
|
1744
|
-
|
|
1748
|
+
}
|
|
1749
|
+
case CLEAR_FIELD_VALIDATORS: {
|
|
1745
1750
|
const fieldToClear = action.payload.fieldName;
|
|
1746
1751
|
|
|
1747
1752
|
return produce(state, draftState => {
|
|
1748
1753
|
draftState[fieldToClear].validators = [];
|
|
1749
1754
|
computeErrorEntries(draftState);
|
|
1750
1755
|
});
|
|
1756
|
+
}
|
|
1751
1757
|
default:
|
|
1752
1758
|
return state;
|
|
1753
1759
|
}
|
|
@@ -1768,7 +1774,8 @@ const createMapDispatchToProps = formConfig => {
|
|
|
1768
1774
|
dispatchObj.fields[fieldName] = {
|
|
1769
1775
|
set: value => dispatch(set(fieldName)(value)),
|
|
1770
1776
|
addValidator: validator => dispatch(addValidator(fieldName)(validator)),
|
|
1771
|
-
removeValidator: validator =>
|
|
1777
|
+
removeValidator: validator =>
|
|
1778
|
+
dispatch(removeValidator(fieldName)(validator)),
|
|
1772
1779
|
clear: () => dispatch(clearFieldValidators(fieldName)())
|
|
1773
1780
|
};
|
|
1774
1781
|
}
|
|
@@ -4,44 +4,58 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["redux-freeform"] = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
8
|
-
value,
|
|
9
|
-
...rest
|
|
10
|
-
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
7
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (value, ...rest) =>
|
|
8
|
+
value === "" ? emptyCase : validatorFn(value, ...rest);
|
|
11
9
|
|
|
12
10
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
13
11
|
|
|
12
|
+
function getDefaultExportFromCjs (x) {
|
|
13
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
14
|
+
}
|
|
15
|
+
|
|
14
16
|
var dayjs_min = {exports: {}};
|
|
15
17
|
|
|
18
|
+
dayjs_min.exports;
|
|
19
|
+
|
|
16
20
|
(function (module, exports) {
|
|
17
|
-
|
|
18
|
-
}(dayjs_min));
|
|
21
|
+
!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",$="Invalid Date",l=/^(\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("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={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}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},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=g;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(l);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()===$)},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),$=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)},l=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,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"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":""),$=(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],l=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 $&&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,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||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||$;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].substr(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},l={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||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[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}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[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=v[D],w.Ls=v,w.p={},w}));
|
|
22
|
+
} (dayjs_min, dayjs_min.exports));
|
|
19
23
|
|
|
20
|
-
var
|
|
24
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
25
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
21
26
|
|
|
22
27
|
var customParseFormat$1 = {exports: {}};
|
|
23
28
|
|
|
29
|
+
customParseFormat$1.exports;
|
|
30
|
+
|
|
24
31
|
(function (module, exports) {
|
|
25
|
-
|
|
26
|
-
}(customParseFormat$1));
|
|
32
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={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"},e=/(\[[^[]*\])|([-:/.()\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(t){return (t=+t)+(t>68?1900:2e3)};var a=function(t){return function(e){this[t]=+e;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(t){(this.zone||(this.zone={})).offset=function(t){if(!t)return 0;if("Z"===t)return 0;var e=t.match(/([+-]|\d\d)/g),n=60*e[1]+(+e[2]||0);return 0===n?0:"+"===e[0]?-n:n}(t);}],u=function(t){var e=o[t];return e&&(e.indexOf?e:e.s.concat(e.f))},h=function(t,e){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(t.indexOf(r(i,0,e))>-1){n=i>12;break}}else n=t===(e?"pm":"PM");return n},d={A:[i,function(t){this.afternoon=h(t,!1);}],a:[i,function(t){this.afternoon=h(t,!0);}],S:[/\d/,function(t){this.milliseconds=100*+t;}],SS:[n,function(t){this.milliseconds=10*+t;}],SSS:[/\d{3}/,function(t){this.milliseconds=+t;}],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(t){var e=o.ordinal,n=t.match(/\d+/);if(this.day=n[0],e)for(var r=1;r<=31;r+=1)e(r).replace(/\[|\]/g,"")===t&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(t){var e=u("months"),n=(u("monthsShort")||e.map((function(t){return t.substr(0,3)}))).indexOf(t)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(t){var e=u("months").indexOf(t)+1;if(e<1)throw new Error;this.month=e%12||e;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(t){this.year=s(t);}],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(e,n,r){var o=r&&r.toUpperCase();return n||i[r]||t[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,e,n){return e||n.slice(1)}))}))).match(e),a=s.length,f=0;f<a;f+=1){var u=s[f],h=d[u],c=h&&h[0],l=h&&h[1];s[f]=l?{regex:c,parser:l}:u.replace(/^\[|\]$/g,"");}return function(t){for(var e={},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,u=t.substr(r),h=o.exec(u)[0];f.call(e,h),t=t.replace(h,"");}}return function(t){var e=t.afternoon;if(void 0!==e){var n=t.hours;e?n<12&&(t.hours+=12):12===n&&(t.hours=0),delete t.afternoon;}}(e),e}}return function(t,e,n){n.p.customParseFormat=!0,t&&t.parseTwoDigitYear&&(s=t.parseTwoDigitYear);var r=e.prototype,i=r.parse;r.parse=function(t){var e=t.date,r=t.utc,s=t.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],u=!0===s[3],h=f||u,d=s[2];u&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(t,e,n){try{if(["x","X"].indexOf(e)>-1)return new Date(("X"===e?1e3:1)*t);var r=c(e)(t),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,u=r.seconds,h=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=u||0,g=h||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(t){return new Date("")}}(e,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),h&&e!=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,t);};}}));
|
|
33
|
+
} (customParseFormat$1, customParseFormat$1.exports));
|
|
27
34
|
|
|
28
|
-
var
|
|
35
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
36
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
29
37
|
|
|
30
38
|
var isSameOrBefore$1 = {exports: {}};
|
|
31
39
|
|
|
40
|
+
isSameOrBefore$1.exports;
|
|
41
|
+
|
|
32
42
|
(function (module, exports) {
|
|
33
|
-
|
|
34
|
-
}(isSameOrBefore$1));
|
|
43
|
+
!function(e,i){module.exports=i();}(commonjsGlobal,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
44
|
+
} (isSameOrBefore$1, isSameOrBefore$1.exports));
|
|
35
45
|
|
|
36
|
-
var
|
|
46
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
47
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
37
48
|
|
|
38
49
|
var isSameOrAfter$1 = {exports: {}};
|
|
39
50
|
|
|
51
|
+
isSameOrAfter$1.exports;
|
|
52
|
+
|
|
40
53
|
(function (module, exports) {
|
|
41
|
-
|
|
42
|
-
}(isSameOrAfter$1));
|
|
54
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
55
|
+
} (isSameOrAfter$1, isSameOrAfter$1.exports));
|
|
43
56
|
|
|
44
|
-
var
|
|
57
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
58
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
45
59
|
|
|
46
60
|
/* eslint-disable no-unused-vars */
|
|
47
61
|
|
|
@@ -109,8 +123,7 @@
|
|
|
109
123
|
return Number(value) < args[0];
|
|
110
124
|
};
|
|
111
125
|
|
|
112
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
113
|
-
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
126
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO = "validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
114
127
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
115
128
|
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
116
129
|
const numberLessThanOrEqualTo = createValidator(
|
|
@@ -176,11 +189,7 @@
|
|
|
176
189
|
|
|
177
190
|
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
178
191
|
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
179
|
-
const validateWhen = (
|
|
180
|
-
dependentValidator,
|
|
181
|
-
primaryValidator,
|
|
182
|
-
optionalFieldName
|
|
183
|
-
) => ({
|
|
192
|
+
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
184
193
|
type: VALIDATE_WHEN,
|
|
185
194
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
186
195
|
error: dependentValidator.error
|
|
@@ -216,11 +225,7 @@
|
|
|
216
225
|
);
|
|
217
226
|
|
|
218
227
|
return primaryPredicatePassed
|
|
219
|
-
? validatorFns[dependentValidator.type](
|
|
220
|
-
value,
|
|
221
|
-
dependentValidator.args,
|
|
222
|
-
form
|
|
223
|
-
)
|
|
228
|
+
? validatorFns[dependentValidator.type](value, dependentValidator.args, form)
|
|
224
229
|
: true;
|
|
225
230
|
};
|
|
226
231
|
|
|
@@ -279,9 +284,7 @@
|
|
|
279
284
|
);
|
|
280
285
|
}
|
|
281
286
|
if (max < min) {
|
|
282
|
-
throw new Error(
|
|
283
|
-
"hasLength validator was passed a min greater than the max"
|
|
284
|
-
);
|
|
287
|
+
throw new Error("hasLength validator was passed a min greater than the max");
|
|
285
288
|
}
|
|
286
289
|
const valueLength = value.length;
|
|
287
290
|
return max >= valueLength && valueLength >= min;
|
|
@@ -345,10 +348,7 @@
|
|
|
345
348
|
|
|
346
349
|
const IS_VALID_MONTH = "validator/IS_VALID_MONTH";
|
|
347
350
|
const IS_VALID_MONTH_ERROR = "error/IS_VALID_MONTH";
|
|
348
|
-
const isValidMonth = createValidator(
|
|
349
|
-
IS_VALID_MONTH,
|
|
350
|
-
IS_VALID_MONTH_ERROR
|
|
351
|
-
);
|
|
351
|
+
const isValidMonth = createValidator(IS_VALID_MONTH, IS_VALID_MONTH_ERROR);
|
|
352
352
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
353
353
|
if (value === "") {
|
|
354
354
|
return true;
|
|
@@ -360,11 +360,11 @@
|
|
|
360
360
|
// Only works with two digit months (01, 02, 03, etc)
|
|
361
361
|
const monthStartPosition = parseInt(args[0]);
|
|
362
362
|
const monthEndPosition = monthStartPosition + 2;
|
|
363
|
-
if (monthStartPosition
|
|
363
|
+
if (isNaN(monthStartPosition)) {
|
|
364
364
|
throw new Error("Month start position has to be a valid integer string");
|
|
365
365
|
}
|
|
366
366
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
367
|
-
if (month
|
|
367
|
+
if (isNaN(month)) {
|
|
368
368
|
return false;
|
|
369
369
|
}
|
|
370
370
|
return month >= 1 && month <= 12;
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
return runFormValidators(fieldName, form, validators);
|
|
504
504
|
};
|
|
505
505
|
|
|
506
|
-
const computeErrorEntries =
|
|
506
|
+
const computeErrorEntries = formState => {
|
|
507
507
|
const fields = Object.entries(formState);
|
|
508
508
|
for (let entry of fields) {
|
|
509
509
|
let fieldName = entry[0];
|
|
@@ -1712,7 +1712,7 @@
|
|
|
1712
1712
|
action
|
|
1713
1713
|
) => {
|
|
1714
1714
|
switch (action.type) {
|
|
1715
|
-
case SET:
|
|
1715
|
+
case SET: {
|
|
1716
1716
|
const changedFieldName = action.payload.fieldName;
|
|
1717
1717
|
const newRawValue = action.payload.value;
|
|
1718
1718
|
|
|
@@ -1728,32 +1728,38 @@
|
|
|
1728
1728
|
computeDirtyEntries(draftState, changedFieldName);
|
|
1729
1729
|
computeErrorEntries(draftState);
|
|
1730
1730
|
});
|
|
1731
|
+
}
|
|
1731
1732
|
case CLEAR:
|
|
1732
1733
|
return createInitialState(formConfig);
|
|
1733
|
-
case ADD_VALIDATOR:
|
|
1734
|
+
case ADD_VALIDATOR: {
|
|
1734
1735
|
const fieldWithOverride = action.payload.fieldName;
|
|
1735
1736
|
const newValidator = action.payload.validator;
|
|
1736
|
-
|
|
1737
|
+
|
|
1737
1738
|
return produce(state, draftState => {
|
|
1738
1739
|
draftState[fieldWithOverride].validators.push(newValidator);
|
|
1739
1740
|
computeErrorEntries(draftState);
|
|
1740
1741
|
});
|
|
1741
|
-
|
|
1742
|
+
}
|
|
1743
|
+
case REMOVE_VALIDATOR: {
|
|
1742
1744
|
const fieldToOverride = action.payload.fieldName;
|
|
1743
1745
|
const targetValidator = action.payload.validator;
|
|
1744
1746
|
|
|
1745
1747
|
return produce(state, draftState => {
|
|
1746
1748
|
let fieldValidators = draftState[fieldToOverride].validators;
|
|
1747
|
-
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
1749
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
1750
|
+
validator => validator.type !== targetValidator.type
|
|
1751
|
+
);
|
|
1748
1752
|
computeErrorEntries(draftState);
|
|
1749
1753
|
});
|
|
1750
|
-
|
|
1754
|
+
}
|
|
1755
|
+
case CLEAR_FIELD_VALIDATORS: {
|
|
1751
1756
|
const fieldToClear = action.payload.fieldName;
|
|
1752
1757
|
|
|
1753
1758
|
return produce(state, draftState => {
|
|
1754
1759
|
draftState[fieldToClear].validators = [];
|
|
1755
1760
|
computeErrorEntries(draftState);
|
|
1756
1761
|
});
|
|
1762
|
+
}
|
|
1757
1763
|
default:
|
|
1758
1764
|
return state;
|
|
1759
1765
|
}
|
|
@@ -1774,7 +1780,8 @@
|
|
|
1774
1780
|
dispatchObj.fields[fieldName] = {
|
|
1775
1781
|
set: value => dispatch(set(fieldName)(value)),
|
|
1776
1782
|
addValidator: validator => dispatch(addValidator(fieldName)(validator)),
|
|
1777
|
-
removeValidator: validator =>
|
|
1783
|
+
removeValidator: validator =>
|
|
1784
|
+
dispatch(removeValidator(fieldName)(validator)),
|
|
1778
1785
|
clear: () => dispatch(clearFieldValidators(fieldName)())
|
|
1779
1786
|
};
|
|
1780
1787
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redux-freeform",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0-beta.0",
|
|
4
4
|
"description": "A small Redux form library that supports purely functional apps, without magic",
|
|
5
5
|
"main": "dist/redux-freeform.cjs.js",
|
|
6
6
|
"module": "dist/redux-freeform.esm.js",
|
|
@@ -12,29 +12,40 @@
|
|
|
12
12
|
"dev": "rollup -c -w",
|
|
13
13
|
"build": "rollup -c",
|
|
14
14
|
"test": "nyc ava",
|
|
15
|
+
"format": "prettier --write \"{src,examples,website,test}/**/*.js\" && eslint --fix",
|
|
16
|
+
"format-check": "prettier --check \"{src,examples,website,test}/**/*.js\"",
|
|
17
|
+
"lint": "eslint ./ --ext .js,.jsx,.ts,.tsx",
|
|
15
18
|
"coverage": "echo 'to be implemented'"
|
|
16
19
|
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"acorn": "^6.4.1",
|
|
22
|
+
"dayjs": "^1.10.7",
|
|
23
|
+
"immer": "^3.1.3"
|
|
24
|
+
},
|
|
17
25
|
"devDependencies": {
|
|
18
|
-
"@babel
|
|
19
|
-
"@babel/
|
|
20
|
-
"@babel/
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"eslint
|
|
31
|
-
"eslint-
|
|
26
|
+
"@ava/babel": "^2.0.0",
|
|
27
|
+
"@babel/core": "^7.21.8",
|
|
28
|
+
"@babel/eslint-parser": "^7.21.8",
|
|
29
|
+
"@babel/preset-env": "^7.21.5",
|
|
30
|
+
"@babel/preset-react": "^7.18.6",
|
|
31
|
+
"@babel/register": "^7.21.0",
|
|
32
|
+
"@rollup/plugin-commonjs": "^24.1.0",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
34
|
+
"ava": "^3.15.0",
|
|
35
|
+
"ava-fast-check": "^4.0.2",
|
|
36
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
37
|
+
"coveralls": "^3.1.0",
|
|
38
|
+
"eslint": "^8.39.0",
|
|
39
|
+
"eslint-config-prettier": "^8.8.0",
|
|
40
|
+
"eslint-plugin-jsx": "^0.1.0",
|
|
41
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
42
|
+
"eslint-plugin-react": "^7.32.2",
|
|
32
43
|
"esm": "^3.2.25",
|
|
33
|
-
"fast-check": "^
|
|
34
|
-
"nyc": "^
|
|
35
|
-
"prettier": "^
|
|
36
|
-
"prettier-eslint": "^
|
|
37
|
-
"rollup": "2.
|
|
44
|
+
"fast-check": "^2.25.0",
|
|
45
|
+
"nyc": "^15.1.0",
|
|
46
|
+
"prettier": "^2.8.8",
|
|
47
|
+
"prettier-eslint": "^15.0.1",
|
|
48
|
+
"rollup": "2.79.1"
|
|
38
49
|
},
|
|
39
50
|
"resolutions": {
|
|
40
51
|
"acorn": "^6.4.1",
|
|
@@ -65,10 +76,5 @@
|
|
|
65
76
|
],
|
|
66
77
|
"sourceMap": false,
|
|
67
78
|
"instrument": false
|
|
68
|
-
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"acorn": "^6.4.1",
|
|
71
|
-
"dayjs": "^1.10.7",
|
|
72
|
-
"immer": "^3.1.3"
|
|
73
79
|
}
|
|
74
80
|
}
|