@esvndev/es-react-config-setting 1.0.80 → 1.0.82
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/index.js +95 -1803
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -1802
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useRef, useState, useEffect } from 'react';
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import ReactDOM from 'react-dom';
|
|
6
7
|
|
|
@@ -60,7 +61,7 @@ function getValue(nameSpace, obj) {
|
|
|
60
61
|
// eslint-disable-next-line
|
|
61
62
|
var value = obj;
|
|
62
63
|
var splits = nameSpace.replace(/\[/g, '.').replace(/\]/g, '').split('.');
|
|
63
|
-
for (var i = 0; i < splits.length && !isUndefined
|
|
64
|
+
for (var i = 0; i < splits.length && !isUndefined(value); i++) {
|
|
64
65
|
value = value[splits[i]];
|
|
65
66
|
}
|
|
66
67
|
return value;
|
|
@@ -89,7 +90,7 @@ function setValue(nameSpace, value, obj) {
|
|
|
89
90
|
if (i + 1 === length) {
|
|
90
91
|
fromObj[key] = value === undefined ? {} : value;
|
|
91
92
|
}
|
|
92
|
-
else if (isNullOrUndefined
|
|
93
|
+
else if (isNullOrUndefined(fromObj[key])) {
|
|
93
94
|
fromObj[key] = {};
|
|
94
95
|
}
|
|
95
96
|
fromObj = fromObj[key];
|
|
@@ -120,9 +121,9 @@ var containerObject = typeof window !== "undefined" ? window : {};
|
|
|
120
121
|
* @private
|
|
121
122
|
*/
|
|
122
123
|
// eslint-disable-next-line
|
|
123
|
-
function isObject$
|
|
124
|
+
function isObject$1(obj) {
|
|
124
125
|
var objCon = {};
|
|
125
|
-
return (!isNullOrUndefined
|
|
126
|
+
return (!isNullOrUndefined(obj) && obj.constructor === objCon.constructor);
|
|
126
127
|
}
|
|
127
128
|
/**
|
|
128
129
|
* Merge the source object into destination object.
|
|
@@ -133,15 +134,15 @@ function isObject$2(obj) {
|
|
|
133
134
|
* @private
|
|
134
135
|
*/
|
|
135
136
|
function merge(source, destination) {
|
|
136
|
-
if (!isNullOrUndefined
|
|
137
|
+
if (!isNullOrUndefined(destination)) {
|
|
137
138
|
var temrObj = source;
|
|
138
139
|
var tempProp = destination;
|
|
139
140
|
var keys = Object.keys(destination);
|
|
140
141
|
var deepmerge = 'deepMerge';
|
|
141
142
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
142
143
|
var key = keys_1[_i];
|
|
143
|
-
if (!isNullOrUndefined
|
|
144
|
-
(isObject$
|
|
144
|
+
if (!isNullOrUndefined(temrObj[deepmerge]) && (temrObj[deepmerge].indexOf(key) !== -1) &&
|
|
145
|
+
(isObject$1(tempProp[key]) || Array.isArray(tempProp[key]))) {
|
|
145
146
|
extend(temrObj[key], temrObj[key], tempProp[key], true);
|
|
146
147
|
}
|
|
147
148
|
else {
|
|
@@ -180,8 +181,8 @@ function extend(copied, first, second, deep) {
|
|
|
180
181
|
Array.isArray(copy) && Array.isArray(src) && (copy.length !== src.length);
|
|
181
182
|
// eslint-disable-next-line
|
|
182
183
|
var blazorEventExtend = true;
|
|
183
|
-
if (deep && blazorEventExtend && (isObject$
|
|
184
|
-
if (isObject$
|
|
184
|
+
if (deep && blazorEventExtend && (isObject$1(copy) || Array.isArray(copy))) {
|
|
185
|
+
if (isObject$1(copy)) {
|
|
185
186
|
clone = src ? src : {};
|
|
186
187
|
// eslint-disable-next-line
|
|
187
188
|
if (Array.isArray(clone) && clone.hasOwnProperty('isComplexArray')) {
|
|
@@ -215,7 +216,7 @@ function extend(copied, first, second, deep) {
|
|
|
215
216
|
* @returns {boolean} ?
|
|
216
217
|
* @private
|
|
217
218
|
*/
|
|
218
|
-
function isNullOrUndefined
|
|
219
|
+
function isNullOrUndefined(value) {
|
|
219
220
|
return value === undefined || value === null;
|
|
220
221
|
}
|
|
221
222
|
/**
|
|
@@ -225,7 +226,7 @@ function isNullOrUndefined$1(value) {
|
|
|
225
226
|
* @returns {boolean} ?
|
|
226
227
|
* @private
|
|
227
228
|
*/
|
|
228
|
-
function isUndefined
|
|
229
|
+
function isUndefined(value) {
|
|
229
230
|
return ('undefined' === typeof value);
|
|
230
231
|
}
|
|
231
232
|
/**
|
|
@@ -477,9 +478,9 @@ var ParserBase = /** @class */ (function () {
|
|
|
477
478
|
ParserBase.getCurrentNumericOptions = function (curObj, numberSystem, needSymbols, blazorMode) {
|
|
478
479
|
var ret = {};
|
|
479
480
|
var cur = this.getDefaultNumberingSystem(curObj);
|
|
480
|
-
if (!isUndefined
|
|
481
|
+
if (!isUndefined(cur.nSystem) || blazorMode) {
|
|
481
482
|
var digits = blazorMode ? getValue('obj.mapperDigits', cur) : getValue(cur.nSystem + '._digits', numberSystem);
|
|
482
|
-
if (!isUndefined
|
|
483
|
+
if (!isUndefined(digits)) {
|
|
483
484
|
ret.numericPair = this.reverseObject(digits, latnNumberSystem);
|
|
484
485
|
ret.numberParseRegex = new RegExp(this.constructRegex(digits), 'g');
|
|
485
486
|
ret.numericRegex = '[' + digits[0] + '-' + digits[9] + ']';
|
|
@@ -505,12 +506,12 @@ var ParserBase = /** @class */ (function () {
|
|
|
505
506
|
ParserBase.getNumberMapper = function (curObj, numberSystem, isNumber) {
|
|
506
507
|
var ret = { mapper: {} };
|
|
507
508
|
var cur = this.getDefaultNumberingSystem(curObj);
|
|
508
|
-
if (!isUndefined
|
|
509
|
+
if (!isUndefined(cur.nSystem)) {
|
|
509
510
|
ret.numberSystem = cur.nSystem;
|
|
510
511
|
ret.numberSymbols = getValue('symbols-numberSystem-' + cur.nSystem, cur.obj);
|
|
511
512
|
ret.timeSeparator = getValue('timeSeparator', ret.numberSymbols);
|
|
512
513
|
var digits = getValue(cur.nSystem + '._digits', numberSystem);
|
|
513
|
-
if (!isUndefined
|
|
514
|
+
if (!isUndefined(digits)) {
|
|
514
515
|
for (var _i = 0, latnNumberSystem_1 = latnNumberSystem; _i < latnNumberSystem_1.length; _i++) {
|
|
515
516
|
var i = latnNumberSystem_1[_i];
|
|
516
517
|
// eslint-disable-next-line
|
|
@@ -936,7 +937,7 @@ var DateFormat = /** @class */ (function () {
|
|
|
936
937
|
var resPattern = option.format ||
|
|
937
938
|
IntlBase.getResultantPattern(option.skeleton, dependable.dateObject, option.type, false, '');
|
|
938
939
|
formatOptions.dateSeperator = IntlBase.getDateSeparator(dependable.dateObject);
|
|
939
|
-
if (isUndefined
|
|
940
|
+
if (isUndefined(resPattern)) {
|
|
940
941
|
throwError('Format options or type given must be invalid');
|
|
941
942
|
}
|
|
942
943
|
else {
|
|
@@ -1081,7 +1082,7 @@ var DateFormat = /** @class */ (function () {
|
|
|
1081
1082
|
var dec = value.getFullYear() < 0 ? 0 : 1;
|
|
1082
1083
|
// eslint-disable-next-line
|
|
1083
1084
|
var retu = options.era[dec];
|
|
1084
|
-
if (isNullOrUndefined
|
|
1085
|
+
if (isNullOrUndefined(retu)) {
|
|
1085
1086
|
// eslint-disable-next-line
|
|
1086
1087
|
retu = options.era[dec ? 0 : 1];
|
|
1087
1088
|
}
|
|
@@ -1222,10 +1223,10 @@ var NumberFormat = /** @class */ (function () {
|
|
|
1222
1223
|
}
|
|
1223
1224
|
fOptions.groupOne = this.checkValueRange(fOptions.maximumSignificantDigits, fOptions.minimumSignificantDigits, true);
|
|
1224
1225
|
this.checkValueRange(fOptions.maximumFractionDigits, fOptions.minimumFractionDigits, false, true);
|
|
1225
|
-
if (!isUndefined
|
|
1226
|
+
if (!isUndefined(fOptions.fractionDigits)) {
|
|
1226
1227
|
fOptions.minimumFractionDigits = fOptions.maximumFractionDigits = fOptions.fractionDigits;
|
|
1227
1228
|
}
|
|
1228
|
-
if (isUndefined
|
|
1229
|
+
if (isUndefined(fOptions.useGrouping)) {
|
|
1229
1230
|
fOptions.useGrouping = true;
|
|
1230
1231
|
}
|
|
1231
1232
|
if (fOptions.isCurrency && !isBlazor()) {
|
|
@@ -1240,17 +1241,17 @@ var NumberFormat = /** @class */ (function () {
|
|
|
1240
1241
|
fOptions.groupData = this.getGroupingDetails(split[0]);
|
|
1241
1242
|
}
|
|
1242
1243
|
}
|
|
1243
|
-
var minFrac = isUndefined
|
|
1244
|
+
var minFrac = isUndefined(fOptions.minimumFractionDigits);
|
|
1244
1245
|
if (minFrac) {
|
|
1245
1246
|
fOptions.minimumFractionDigits = cOptions.nData.minimumFraction;
|
|
1246
1247
|
}
|
|
1247
|
-
if (isUndefined
|
|
1248
|
+
if (isUndefined(fOptions.maximumFractionDigits)) {
|
|
1248
1249
|
var mval = cOptions.nData.maximumFraction;
|
|
1249
|
-
fOptions.maximumFractionDigits = isUndefined
|
|
1250
|
+
fOptions.maximumFractionDigits = isUndefined(mval) && fOptions.isPercent ? 0 : mval;
|
|
1250
1251
|
}
|
|
1251
1252
|
var mfrac = fOptions.minimumFractionDigits;
|
|
1252
1253
|
var lfrac = fOptions.maximumFractionDigits;
|
|
1253
|
-
if (!isUndefined
|
|
1254
|
+
if (!isUndefined(mfrac) && !isUndefined(lfrac)) {
|
|
1254
1255
|
if (mfrac > lfrac) {
|
|
1255
1256
|
fOptions.maximumFractionDigits = mfrac;
|
|
1256
1257
|
}
|
|
@@ -1306,11 +1307,11 @@ var NumberFormat = /** @class */ (function () {
|
|
|
1306
1307
|
var str1 = errorText['l' + decide];
|
|
1307
1308
|
// eslint-disable-next-line
|
|
1308
1309
|
var str2 = errorText['m' + decide];
|
|
1309
|
-
if (!isUndefined
|
|
1310
|
+
if (!isUndefined(val1)) {
|
|
1310
1311
|
this.checkRange(val1, str1, isFraction);
|
|
1311
1312
|
dint++;
|
|
1312
1313
|
}
|
|
1313
|
-
if (!isUndefined
|
|
1314
|
+
if (!isUndefined(val2)) {
|
|
1314
1315
|
this.checkRange(val2, str2, isFraction);
|
|
1315
1316
|
dint++;
|
|
1316
1317
|
}
|
|
@@ -1351,7 +1352,7 @@ var NumberFormat = /** @class */ (function () {
|
|
|
1351
1352
|
*/
|
|
1352
1353
|
NumberFormat.intNumberFormatter = function (value, fOptions, dOptions) {
|
|
1353
1354
|
var curData;
|
|
1354
|
-
if (isUndefined
|
|
1355
|
+
if (isUndefined(fOptions.nData.type)) {
|
|
1355
1356
|
return undefined;
|
|
1356
1357
|
}
|
|
1357
1358
|
else {
|
|
@@ -1428,7 +1429,7 @@ var NumberFormat = /** @class */ (function () {
|
|
|
1428
1429
|
* @returns {string} ?
|
|
1429
1430
|
*/
|
|
1430
1431
|
NumberFormat.groupNumbers = function (val, level1, sep, decimalSymbol, level2) {
|
|
1431
|
-
var flag = !isNullOrUndefined
|
|
1432
|
+
var flag = !isNullOrUndefined(level2) && level2 !== 0;
|
|
1432
1433
|
var split = val.split(decimalSymbol);
|
|
1433
1434
|
var prefix = split[0];
|
|
1434
1435
|
var length = prefix.length;
|
|
@@ -1470,7 +1471,7 @@ var NumberFormat = /** @class */ (function () {
|
|
|
1470
1471
|
}
|
|
1471
1472
|
return value.toFixed(min);
|
|
1472
1473
|
}
|
|
1473
|
-
else if (!isNullOrUndefined
|
|
1474
|
+
else if (!isNullOrUndefined(max) && (length > max || max === 0)) {
|
|
1474
1475
|
return value.toFixed(max);
|
|
1475
1476
|
}
|
|
1476
1477
|
return value + '';
|
|
@@ -1501,7 +1502,7 @@ var Observer = /** @class */ (function () {
|
|
|
1501
1502
|
function Observer(context) {
|
|
1502
1503
|
this.ranArray = [];
|
|
1503
1504
|
this.boundedEvents = {};
|
|
1504
|
-
if (isNullOrUndefined
|
|
1505
|
+
if (isNullOrUndefined(context)) {
|
|
1505
1506
|
return;
|
|
1506
1507
|
}
|
|
1507
1508
|
this.context = context;
|
|
@@ -1516,7 +1517,7 @@ var Observer = /** @class */ (function () {
|
|
|
1516
1517
|
* @returns {void}
|
|
1517
1518
|
*/
|
|
1518
1519
|
Observer.prototype.on = function (property, handler, context, id) {
|
|
1519
|
-
if (isNullOrUndefined
|
|
1520
|
+
if (isNullOrUndefined(handler)) {
|
|
1520
1521
|
return;
|
|
1521
1522
|
}
|
|
1522
1523
|
var cntxt = context || this.context;
|
|
@@ -1524,7 +1525,7 @@ var Observer = /** @class */ (function () {
|
|
|
1524
1525
|
this.boundedEvents[property] = [{ handler: handler, context: cntxt }];
|
|
1525
1526
|
return;
|
|
1526
1527
|
}
|
|
1527
|
-
if (!isNullOrUndefined
|
|
1528
|
+
if (!isNullOrUndefined(id)) {
|
|
1528
1529
|
if (this.ranArray.indexOf(id) === -1) {
|
|
1529
1530
|
this.ranArray.push(id);
|
|
1530
1531
|
this.boundedEvents[property].push({ handler: handler, context: cntxt, id: id });
|
|
@@ -2387,7 +2388,7 @@ var IntlBase;
|
|
|
2387
2388
|
else {
|
|
2388
2389
|
resPattern = getValue('dateTimeFormats.availableFormats.' + skeleton, dateObject);
|
|
2389
2390
|
}
|
|
2390
|
-
if (isUndefined
|
|
2391
|
+
if (isUndefined(resPattern) && skeleton === 'yMd') {
|
|
2391
2392
|
resPattern = 'M/d/y';
|
|
2392
2393
|
}
|
|
2393
2394
|
}
|
|
@@ -2509,7 +2510,7 @@ var IntlBase;
|
|
|
2509
2510
|
var fraction = match[7];
|
|
2510
2511
|
if (fraction && needFraction) {
|
|
2511
2512
|
var fmatch = fraction.match(fractionRegex);
|
|
2512
|
-
if (!isNullOrUndefined
|
|
2513
|
+
if (!isNullOrUndefined(fmatch)) {
|
|
2513
2514
|
nData.minimumFraction = fmatch.length;
|
|
2514
2515
|
}
|
|
2515
2516
|
else {
|
|
@@ -2569,9 +2570,9 @@ var IntlBase;
|
|
|
2569
2570
|
// eslint-disable-next-line
|
|
2570
2571
|
options[data[i]] = customNumberFormat(formatSplit[i], dOptions, obj);
|
|
2571
2572
|
}
|
|
2572
|
-
if (isNullOrUndefined
|
|
2573
|
+
if (isNullOrUndefined(options.nData)) {
|
|
2573
2574
|
options.nData = extend({}, options.pData);
|
|
2574
|
-
options.nData.nlead = isNullOrUndefined
|
|
2575
|
+
options.nData.nlead = isNullOrUndefined(dOptions) ? '-' + options.nData.nlead : dOptions.minusSymbol + options.nData.nlead;
|
|
2575
2576
|
}
|
|
2576
2577
|
return options;
|
|
2577
2578
|
}
|
|
@@ -2588,7 +2589,7 @@ var IntlBase;
|
|
|
2588
2589
|
function customNumberFormat(format, dOptions, numObject) {
|
|
2589
2590
|
var cOptions = { type: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 0 };
|
|
2590
2591
|
var pattern = format.match(IntlBase.customRegex);
|
|
2591
|
-
if (isNullOrUndefined
|
|
2592
|
+
if (isNullOrUndefined(pattern) || (pattern[5] === '' && format !== 'N/A')) {
|
|
2592
2593
|
cOptions.type = undefined;
|
|
2593
2594
|
return cOptions;
|
|
2594
2595
|
}
|
|
@@ -2603,7 +2604,7 @@ var IntlBase;
|
|
|
2603
2604
|
if (integerPart.indexOf('0') !== -1) {
|
|
2604
2605
|
cOptions.minimumIntegerDigits = integerPart.length - integerPart.indexOf('0');
|
|
2605
2606
|
}
|
|
2606
|
-
if (!isNullOrUndefined
|
|
2607
|
+
if (!isNullOrUndefined(fractionPart)) {
|
|
2607
2608
|
cOptions.minimumFractionDigits = fractionPart.lastIndexOf('0');
|
|
2608
2609
|
cOptions.maximumFractionDigits = fractionPart.lastIndexOf('#');
|
|
2609
2610
|
if (cOptions.minimumFractionDigits === -1) {
|
|
@@ -2613,7 +2614,7 @@ var IntlBase;
|
|
|
2613
2614
|
cOptions.maximumFractionDigits = cOptions.minimumFractionDigits;
|
|
2614
2615
|
}
|
|
2615
2616
|
}
|
|
2616
|
-
if (!isNullOrUndefined
|
|
2617
|
+
if (!isNullOrUndefined(dOptions)) {
|
|
2617
2618
|
extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '$', dOptions.currencySymbol));
|
|
2618
2619
|
if (!cOptions.isCurrency) {
|
|
2619
2620
|
extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '%', dOptions.percentSymbol));
|
|
@@ -2622,7 +2623,7 @@ var IntlBase;
|
|
|
2622
2623
|
else {
|
|
2623
2624
|
extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '%', '%'));
|
|
2624
2625
|
}
|
|
2625
|
-
if (!isNullOrUndefined
|
|
2626
|
+
if (!isNullOrUndefined(numObject)) {
|
|
2626
2627
|
var symbolPattern = getSymbolPattern(cOptions.type, dOptions.numberMapper.numberSystem, numObject, false);
|
|
2627
2628
|
if (cOptions.useGrouping) {
|
|
2628
2629
|
// eslint-disable-next-line
|
|
@@ -3087,7 +3088,7 @@ var Browser = /** @class */ (function () {
|
|
|
3087
3088
|
* @returns {BrowserInfo} ?
|
|
3088
3089
|
*/
|
|
3089
3090
|
get: function () {
|
|
3090
|
-
if (isUndefined
|
|
3091
|
+
if (isUndefined(window.browserDetails.info)) {
|
|
3091
3092
|
return window.browserDetails.info = Browser.extractBrowserDetail();
|
|
3092
3093
|
}
|
|
3093
3094
|
return window.browserDetails.info;
|
|
@@ -3114,7 +3115,7 @@ var Browser = /** @class */ (function () {
|
|
|
3114
3115
|
* @returns {boolean} ?
|
|
3115
3116
|
*/
|
|
3116
3117
|
get: function () {
|
|
3117
|
-
if (isUndefined
|
|
3118
|
+
if (isUndefined(window.browserDetails.isTouch)) {
|
|
3118
3119
|
return (window.browserDetails.isTouch =
|
|
3119
3120
|
('ontouchstart' in window.navigator) ||
|
|
3120
3121
|
(window &&
|
|
@@ -3133,7 +3134,7 @@ var Browser = /** @class */ (function () {
|
|
|
3133
3134
|
* @returns {boolean} ?
|
|
3134
3135
|
*/
|
|
3135
3136
|
get: function () {
|
|
3136
|
-
if (isUndefined
|
|
3137
|
+
if (isUndefined(window.browserDetails.isPointer)) {
|
|
3137
3138
|
return window.browserDetails.isPointer = ('pointerEnabled' in window.navigator);
|
|
3138
3139
|
}
|
|
3139
3140
|
return window.browserDetails.isPointer;
|
|
@@ -3148,7 +3149,7 @@ var Browser = /** @class */ (function () {
|
|
|
3148
3149
|
* @returns {boolean} ?
|
|
3149
3150
|
*/
|
|
3150
3151
|
get: function () {
|
|
3151
|
-
if (isUndefined
|
|
3152
|
+
if (isUndefined(window.browserDetails.isMSPointer)) {
|
|
3152
3153
|
return window.browserDetails.isMSPointer = ('msPointerEnabled' in window.navigator);
|
|
3153
3154
|
}
|
|
3154
3155
|
return window.browserDetails.isMSPointer;
|
|
@@ -3211,9 +3212,9 @@ var Browser = /** @class */ (function () {
|
|
|
3211
3212
|
* @returns {boolean} ?
|
|
3212
3213
|
*/
|
|
3213
3214
|
get: function () {
|
|
3214
|
-
if (isUndefined
|
|
3215
|
-
window.browserDetails.isWebView = !(isUndefined
|
|
3216
|
-
&& isUndefined
|
|
3215
|
+
if (isUndefined(window.browserDetails.isWebView)) {
|
|
3216
|
+
window.browserDetails.isWebView = !(isUndefined(window.cordova) && isUndefined(window.PhoneGap)
|
|
3217
|
+
&& isUndefined(window.phonegap) && window.forge !== 'object');
|
|
3217
3218
|
return window.browserDetails.isWebView;
|
|
3218
3219
|
}
|
|
3219
3220
|
return window.browserDetails.isWebView;
|
|
@@ -3240,7 +3241,7 @@ var Browser = /** @class */ (function () {
|
|
|
3240
3241
|
* @returns {string} ?
|
|
3241
3242
|
*/
|
|
3242
3243
|
get: function () {
|
|
3243
|
-
if (isUndefined
|
|
3244
|
+
if (isUndefined(window.browserDetails.touchStartEvent)) {
|
|
3244
3245
|
return window.browserDetails.touchStartEvent = Browser.getTouchStartEvent();
|
|
3245
3246
|
}
|
|
3246
3247
|
return window.browserDetails.touchStartEvent;
|
|
@@ -3255,7 +3256,7 @@ var Browser = /** @class */ (function () {
|
|
|
3255
3256
|
* @returns {string} ?
|
|
3256
3257
|
*/
|
|
3257
3258
|
get: function () {
|
|
3258
|
-
if (isUndefined
|
|
3259
|
+
if (isUndefined(window.browserDetails.touchMoveEvent)) {
|
|
3259
3260
|
return window.browserDetails.touchMoveEvent = Browser.getTouchMoveEvent();
|
|
3260
3261
|
}
|
|
3261
3262
|
return window.browserDetails.touchMoveEvent;
|
|
@@ -3270,7 +3271,7 @@ var Browser = /** @class */ (function () {
|
|
|
3270
3271
|
* @returns {string} ?
|
|
3271
3272
|
*/
|
|
3272
3273
|
get: function () {
|
|
3273
|
-
if (isUndefined
|
|
3274
|
+
if (isUndefined(window.browserDetails.touchEndEvent)) {
|
|
3274
3275
|
return window.browserDetails.touchEndEvent = Browser.getTouchEndEvent();
|
|
3275
3276
|
}
|
|
3276
3277
|
return window.browserDetails.touchEndEvent;
|
|
@@ -3285,7 +3286,7 @@ var Browser = /** @class */ (function () {
|
|
|
3285
3286
|
* @returns {string} ?
|
|
3286
3287
|
*/
|
|
3287
3288
|
get: function () {
|
|
3288
|
-
if (isUndefined
|
|
3289
|
+
if (isUndefined(window.browserDetails.touchCancelEvent)) {
|
|
3289
3290
|
return window.browserDetails.touchCancelEvent = Browser.getTouchCancelEvent();
|
|
3290
3291
|
}
|
|
3291
3292
|
return window.browserDetails.touchCancelEvent;
|
|
@@ -3489,9 +3490,9 @@ function addClass(elements, classes) {
|
|
|
3489
3490
|
var ele = _a[_i];
|
|
3490
3491
|
for (var _b = 0, classList_1 = classList; _b < classList_1.length; _b++) {
|
|
3491
3492
|
var className = classList_1[_b];
|
|
3492
|
-
if (isObject$
|
|
3493
|
+
if (isObject$1(ele)) {
|
|
3493
3494
|
var curClass = getValue('attributes.className', ele);
|
|
3494
|
-
if (isNullOrUndefined
|
|
3495
|
+
if (isNullOrUndefined(curClass)) {
|
|
3495
3496
|
setValue('attributes.className', className, ele);
|
|
3496
3497
|
}
|
|
3497
3498
|
else if (!new RegExp('\\b' + className + '\\b', 'i').test(curClass)) {
|
|
@@ -3519,7 +3520,7 @@ function removeClass(elements, classes) {
|
|
|
3519
3520
|
var classList = getClassList(classes);
|
|
3520
3521
|
for (var _i = 0, _a = elements; _i < _a.length; _i++) {
|
|
3521
3522
|
var ele = _a[_i];
|
|
3522
|
-
var flag = isObject$
|
|
3523
|
+
var flag = isObject$1(ele);
|
|
3523
3524
|
var canRemove = flag ? getValue('attributes.className', ele) : ele.className !== '';
|
|
3524
3525
|
if (canRemove) {
|
|
3525
3526
|
for (var _b = 0, classList_2 = classList; _b < classList_2.length; _b++) {
|
|
@@ -3583,7 +3584,7 @@ function attributes(element, attributes) {
|
|
|
3583
3584
|
var ele = element;
|
|
3584
3585
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
3585
3586
|
var key = keys_1[_i];
|
|
3586
|
-
if (isObject$
|
|
3587
|
+
if (isObject$1(ele)) {
|
|
3587
3588
|
var iKey = key;
|
|
3588
3589
|
if (key === 'tabindex') {
|
|
3589
3590
|
iKey = 'tabIndex';
|
|
@@ -3744,19 +3745,19 @@ var Base = /** @class */ (function () {
|
|
|
3744
3745
|
this.finalUpdate = function () { };
|
|
3745
3746
|
this.childChangedProperties = {};
|
|
3746
3747
|
this.modelObserver = new Observer(this);
|
|
3747
|
-
if (!isUndefined
|
|
3748
|
+
if (!isUndefined(element)) {
|
|
3748
3749
|
if ('string' === typeof (element)) {
|
|
3749
3750
|
this.element = document.querySelector(element);
|
|
3750
3751
|
}
|
|
3751
3752
|
else {
|
|
3752
3753
|
this.element = element;
|
|
3753
3754
|
}
|
|
3754
|
-
if (!isNullOrUndefined
|
|
3755
|
+
if (!isNullOrUndefined(this.element)) {
|
|
3755
3756
|
this.isProtectedOnChange = false;
|
|
3756
3757
|
this.addInstance();
|
|
3757
3758
|
}
|
|
3758
3759
|
}
|
|
3759
|
-
if (!isUndefined
|
|
3760
|
+
if (!isUndefined(options)) {
|
|
3760
3761
|
this.setProperties(options, true);
|
|
3761
3762
|
}
|
|
3762
3763
|
this.isDestroyed = false;
|
|
@@ -3938,7 +3939,7 @@ var Base = /** @class */ (function () {
|
|
|
3938
3939
|
// Add module class to the root element
|
|
3939
3940
|
var moduleClass = 'e-' + this.getModuleName().toLowerCase();
|
|
3940
3941
|
addClass([this.element], ['e-lib', moduleClass]);
|
|
3941
|
-
if (!isNullOrUndefined
|
|
3942
|
+
if (!isNullOrUndefined(this.element.ej2_instances)) {
|
|
3942
3943
|
this.element.ej2_instances.push(this);
|
|
3943
3944
|
}
|
|
3944
3945
|
else {
|
|
@@ -4110,7 +4111,7 @@ function Event() {
|
|
|
4110
4111
|
var oldValue = this.properties[key];
|
|
4111
4112
|
if (oldValue !== newValue) {
|
|
4112
4113
|
var finalContext = getParentContext(this, key);
|
|
4113
|
-
if (isUndefined
|
|
4114
|
+
if (isUndefined(oldValue) === false) {
|
|
4114
4115
|
finalContext.context.removeEventListener(finalContext.prefix, oldValue);
|
|
4115
4116
|
}
|
|
4116
4117
|
finalContext.context.addEventListener(finalContext.prefix, newValue);
|
|
@@ -4164,7 +4165,7 @@ function NotifyPropertyChanges(classConstructor) {
|
|
|
4164
4165
|
* @private
|
|
4165
4166
|
*/
|
|
4166
4167
|
function addPropertyCollection(target, key, propertyType, defaultValue, type) {
|
|
4167
|
-
if (isUndefined
|
|
4168
|
+
if (isUndefined(target.propList)) {
|
|
4168
4169
|
target.propList = {
|
|
4169
4170
|
props: [],
|
|
4170
4171
|
complexProps: [],
|
|
@@ -4822,7 +4823,7 @@ var LicenseValidator = /** @class */ (function () {
|
|
|
4822
4823
|
else {
|
|
4823
4824
|
validateMsg = this.errors.noLicense;
|
|
4824
4825
|
}
|
|
4825
|
-
if (validateMsg && typeof document !== 'undefined' && !isNullOrUndefined
|
|
4826
|
+
if (validateMsg && typeof document !== 'undefined' && !isNullOrUndefined(document)) {
|
|
4826
4827
|
var errorDiv = createElement('div', {
|
|
4827
4828
|
innerHTML: validateMsg +
|
|
4828
4829
|
'<span id="license-banner-error" class=".e-license-banner">' +
|
|
@@ -4996,10 +4997,10 @@ var lastHistoryLen = 0;
|
|
|
4996
4997
|
_this.isStringTemplate = false;
|
|
4997
4998
|
_this.needsID = false;
|
|
4998
4999
|
_this.isReactHybrid = false;
|
|
4999
|
-
if (isNullOrUndefined
|
|
5000
|
+
if (isNullOrUndefined(_this.enableRtl)) {
|
|
5000
5001
|
_this.setProperties({ 'enableRtl': rightToLeft }, true);
|
|
5001
5002
|
}
|
|
5002
|
-
if (isNullOrUndefined
|
|
5003
|
+
if (isNullOrUndefined(_this.locale)) {
|
|
5003
5004
|
_this.setProperties({ 'locale': defaultCulture }, true);
|
|
5004
5005
|
}
|
|
5005
5006
|
_this.moduleLoader = new ModuleLoader(_this);
|
|
@@ -5007,7 +5008,7 @@ var lastHistoryLen = 0;
|
|
|
5007
5008
|
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
5008
5009
|
onIntlChange.on('notifyExternalChange', _this.detectFunction, _this, _this.randomId);
|
|
5009
5010
|
validateLicense();
|
|
5010
|
-
if (!isUndefined
|
|
5011
|
+
if (!isUndefined(selector)) {
|
|
5011
5012
|
_this.appendTo();
|
|
5012
5013
|
}
|
|
5013
5014
|
return _this;
|
|
@@ -5091,13 +5092,13 @@ var lastHistoryLen = 0;
|
|
|
5091
5092
|
* @returns {void} ?
|
|
5092
5093
|
*/
|
|
5093
5094
|
Component.prototype.appendTo = function (selector) {
|
|
5094
|
-
if (!isNullOrUndefined
|
|
5095
|
+
if (!isNullOrUndefined(selector) && typeof (selector) === 'string') {
|
|
5095
5096
|
this.element = select(selector, document);
|
|
5096
5097
|
}
|
|
5097
|
-
else if (!isNullOrUndefined
|
|
5098
|
+
else if (!isNullOrUndefined(selector)) {
|
|
5098
5099
|
this.element = selector;
|
|
5099
5100
|
}
|
|
5100
|
-
if (!isNullOrUndefined
|
|
5101
|
+
if (!isNullOrUndefined(this.element)) {
|
|
5101
5102
|
var moduleClass = 'e-' + this.getModuleName().toLowerCase();
|
|
5102
5103
|
addClass([this.element], ['e-control', moduleClass]);
|
|
5103
5104
|
this.isProtectedOnChange = false;
|
|
@@ -5268,7 +5269,7 @@ var lastHistoryLen = 0;
|
|
|
5268
5269
|
{
|
|
5269
5270
|
data = window.localStorage.getItem(this.getModuleName() + this.element.id);
|
|
5270
5271
|
}
|
|
5271
|
-
if (!(isNullOrUndefined
|
|
5272
|
+
if (!(isNullOrUndefined(data) || (data === ''))) {
|
|
5272
5273
|
this.setProperties(JSON.parse(data), true);
|
|
5273
5274
|
}
|
|
5274
5275
|
};
|
|
@@ -5318,7 +5319,7 @@ var lastHistoryLen = 0;
|
|
|
5318
5319
|
var objValue = void 0;
|
|
5319
5320
|
// eslint-disable-next-line
|
|
5320
5321
|
objValue = getValue(key, this);
|
|
5321
|
-
if (!isUndefined
|
|
5322
|
+
if (!isUndefined(objValue)) {
|
|
5322
5323
|
setValue(key, this.getActualProperties(objValue), persistObj);
|
|
5323
5324
|
}
|
|
5324
5325
|
}
|
|
@@ -5477,7 +5478,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5477
5478
|
};
|
|
5478
5479
|
Draggable.prototype.toggleEvents = function (isUnWire) {
|
|
5479
5480
|
var ele;
|
|
5480
|
-
if (!isUndefined
|
|
5481
|
+
if (!isUndefined(this.handle)) {
|
|
5481
5482
|
ele = select(this.handle, this.element);
|
|
5482
5483
|
}
|
|
5483
5484
|
var handler = (this.enableTapHold && Browser.isDevice && Browser.isTouch) ? this.mobileInitialize : this.initialize;
|
|
@@ -5510,7 +5511,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5510
5511
|
Draggable.prototype.getScrollableParent = function (element, axis) {
|
|
5511
5512
|
var scroll = { 'vertical': 'scrollHeight', 'horizontal': 'scrollWidth' };
|
|
5512
5513
|
var client = { 'vertical': 'clientHeight', 'horizontal': 'clientWidth' };
|
|
5513
|
-
if (isNullOrUndefined
|
|
5514
|
+
if (isNullOrUndefined(element)) {
|
|
5514
5515
|
return null;
|
|
5515
5516
|
}
|
|
5516
5517
|
if (element[scroll[axis]] > element[client[axis]]) {
|
|
@@ -5525,7 +5526,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5525
5526
|
(this.parentScrollX === 0 ? element.scrollLeft : element.scrollLeft - this.parentScrollX);
|
|
5526
5527
|
this.tempScrollWidth = element.scrollWidth;
|
|
5527
5528
|
}
|
|
5528
|
-
if (!isNullOrUndefined
|
|
5529
|
+
if (!isNullOrUndefined(element)) {
|
|
5529
5530
|
return this.getScrollableParent(element.parentNode, axis);
|
|
5530
5531
|
}
|
|
5531
5532
|
else {
|
|
@@ -5565,7 +5566,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5565
5566
|
abortSelectors = [abortSelectors];
|
|
5566
5567
|
}
|
|
5567
5568
|
for (var i = 0; i < abortSelectors.length; i++) {
|
|
5568
|
-
if (!isNullOrUndefined
|
|
5569
|
+
if (!isNullOrUndefined(closest(evt.target, abortSelectors[i]))) {
|
|
5569
5570
|
/* istanbul ignore next */
|
|
5570
5571
|
if (this.isDragStarted()) {
|
|
5571
5572
|
this.isDragStarted(true);
|
|
@@ -5574,7 +5575,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5574
5575
|
}
|
|
5575
5576
|
}
|
|
5576
5577
|
}
|
|
5577
|
-
if (this.preventDefault && !isUndefined
|
|
5578
|
+
if (this.preventDefault && !isUndefined(evt.changedTouches) && evt.type !== 'touchstart') {
|
|
5578
5579
|
evt.preventDefault();
|
|
5579
5580
|
}
|
|
5580
5581
|
this.element.setAttribute('aria-grabbed', 'true');
|
|
@@ -5608,7 +5609,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5608
5609
|
};
|
|
5609
5610
|
Draggable.prototype.intDragStart = function (evt) {
|
|
5610
5611
|
this.removeTapholdTimer();
|
|
5611
|
-
var isChangeTouch = !isUndefined
|
|
5612
|
+
var isChangeTouch = !isUndefined(evt.changedTouches);
|
|
5612
5613
|
if (isChangeTouch && (evt.changedTouches.length !== 1)) {
|
|
5613
5614
|
return;
|
|
5614
5615
|
}
|
|
@@ -5624,7 +5625,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5624
5625
|
var element = this.element;
|
|
5625
5626
|
if (this.clone && this.dragTarget) {
|
|
5626
5627
|
var intClosest = closest(evt.target, this.dragTarget);
|
|
5627
|
-
if (!isNullOrUndefined
|
|
5628
|
+
if (!isNullOrUndefined(intClosest)) {
|
|
5628
5629
|
element = intClosest;
|
|
5629
5630
|
}
|
|
5630
5631
|
}
|
|
@@ -5639,7 +5640,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5639
5640
|
var distance = Math.sqrt((x * x) + (y * y));
|
|
5640
5641
|
if ((distance >= this.distance || this.externalInitialize)) {
|
|
5641
5642
|
var ele = this.getHelperElement(evt);
|
|
5642
|
-
if (!ele || isNullOrUndefined
|
|
5643
|
+
if (!ele || isNullOrUndefined(ele)) {
|
|
5643
5644
|
return;
|
|
5644
5645
|
}
|
|
5645
5646
|
if (isChangeTouch) {
|
|
@@ -5733,7 +5734,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5733
5734
|
return value;
|
|
5734
5735
|
};
|
|
5735
5736
|
Draggable.prototype.calculateParentPosition = function (ele) {
|
|
5736
|
-
if (isNullOrUndefined
|
|
5737
|
+
if (isNullOrUndefined(ele)) {
|
|
5737
5738
|
return { left: 0, top: 0 };
|
|
5738
5739
|
}
|
|
5739
5740
|
var rect = ele.getBoundingClientRect();
|
|
@@ -5745,7 +5746,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5745
5746
|
};
|
|
5746
5747
|
// tslint:disable-next-line:max-func-body-length
|
|
5747
5748
|
Draggable.prototype.intDrag = function (evt) {
|
|
5748
|
-
if (!isUndefined
|
|
5749
|
+
if (!isUndefined(evt.changedTouches) && (evt.changedTouches.length !== 1)) {
|
|
5749
5750
|
return;
|
|
5750
5751
|
}
|
|
5751
5752
|
if (this.clone && evt.changedTouches && Browser.isDevice && Browser.isTouch) {
|
|
@@ -5832,10 +5833,10 @@ var Position = /** @class */ (function (_super) {
|
|
|
5832
5833
|
var iTop = tTop + this.borderWidth.top;
|
|
5833
5834
|
var iLeft = tLeft + this.borderWidth.left;
|
|
5834
5835
|
if (this.dragProcessStarted) {
|
|
5835
|
-
if (isNullOrUndefined
|
|
5836
|
+
if (isNullOrUndefined(top)) {
|
|
5836
5837
|
top = this.prevTop;
|
|
5837
5838
|
}
|
|
5838
|
-
if (isNullOrUndefined
|
|
5839
|
+
if (isNullOrUndefined(left)) {
|
|
5839
5840
|
left = this.prevLeft;
|
|
5840
5841
|
}
|
|
5841
5842
|
}
|
|
@@ -5988,7 +5989,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
5988
5989
|
};
|
|
5989
5990
|
Draggable.prototype.intDragStop = function (evt) {
|
|
5990
5991
|
this.dragProcessStarted = false;
|
|
5991
|
-
if (!isUndefined
|
|
5992
|
+
if (!isUndefined(evt.changedTouches) && (evt.changedTouches.length !== 1)) {
|
|
5992
5993
|
return;
|
|
5993
5994
|
}
|
|
5994
5995
|
var type = ['touchend', 'pointerup', 'mouseup'];
|
|
@@ -6092,11 +6093,11 @@ var Position = /** @class */ (function (_super) {
|
|
|
6092
6093
|
/* istanbul ignore next */
|
|
6093
6094
|
Draggable.prototype.currentStateCheck = function (ele, oldEle) {
|
|
6094
6095
|
var elem;
|
|
6095
|
-
if (!isNullOrUndefined
|
|
6096
|
+
if (!isNullOrUndefined(this.currentStateTarget) && this.currentStateTarget !== ele) {
|
|
6096
6097
|
elem = this.currentStateTarget;
|
|
6097
6098
|
}
|
|
6098
6099
|
else {
|
|
6099
|
-
elem = !isNullOrUndefined
|
|
6100
|
+
elem = !isNullOrUndefined(oldEle) ? oldEle : ele;
|
|
6100
6101
|
}
|
|
6101
6102
|
return elem;
|
|
6102
6103
|
};
|
|
@@ -6106,7 +6107,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
6106
6107
|
var intCoord = this.getCoordinates(evt);
|
|
6107
6108
|
var pageX;
|
|
6108
6109
|
var pageY;
|
|
6109
|
-
var isOffsetParent = isNullOrUndefined
|
|
6110
|
+
var isOffsetParent = isNullOrUndefined(dragEle.offsetParent);
|
|
6110
6111
|
/* istanbul ignore next */
|
|
6111
6112
|
if (isdragscroll) {
|
|
6112
6113
|
pageX = this.clone ? intCoord.pageX :
|
|
@@ -6155,7 +6156,7 @@ var Position = /** @class */ (function (_super) {
|
|
|
6155
6156
|
Draggable.prototype.checkTargetElement = function (evt) {
|
|
6156
6157
|
var target = this.getProperTargetElement(evt);
|
|
6157
6158
|
var dropIns = this.getDropInstance(target);
|
|
6158
|
-
if (!dropIns && target && !isNullOrUndefined
|
|
6159
|
+
if (!dropIns && target && !isNullOrUndefined(target.parentNode)) {
|
|
6159
6160
|
var parent_1 = closest(target.parentNode, '.e-droppable') || target.parentElement;
|
|
6160
6161
|
if (parent_1) {
|
|
6161
6162
|
dropIns = this.getDropInstance(parent_1);
|
|
@@ -7574,7 +7575,7 @@ function detect (cssProp) {
|
|
|
7574
7575
|
return result
|
|
7575
7576
|
}
|
|
7576
7577
|
|
|
7577
|
-
function set
|
|
7578
|
+
function set () {
|
|
7578
7579
|
if (arguments.length === 2) {
|
|
7579
7580
|
if (typeof arguments[1] === 'string') {
|
|
7580
7581
|
arguments[0].style.cssText = arguments[1];
|
|
@@ -7586,8 +7587,8 @@ function set$1 () {
|
|
|
7586
7587
|
}
|
|
7587
7588
|
}
|
|
7588
7589
|
|
|
7589
|
-
domCss.exports = set
|
|
7590
|
-
domCss.exports.set = set
|
|
7590
|
+
domCss.exports = set;
|
|
7591
|
+
domCss.exports.set = set;
|
|
7591
7592
|
|
|
7592
7593
|
domCss.exports.get = function (element, properties) {
|
|
7593
7594
|
if (Array.isArray(properties)) {
|
|
@@ -8705,7 +8706,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
8705
8706
|
|
|
8706
8707
|
var PropTypes = propTypes$6.exports;
|
|
8707
8708
|
|
|
8708
|
-
var isString
|
|
8709
|
+
var isString = {};
|
|
8709
8710
|
|
|
8710
8711
|
(function (exports) {
|
|
8711
8712
|
|
|
@@ -8716,7 +8717,7 @@ exports["default"] = isString;
|
|
|
8716
8717
|
function isString(maybe) {
|
|
8717
8718
|
return typeof maybe === 'string';
|
|
8718
8719
|
}
|
|
8719
|
-
}(isString
|
|
8720
|
+
}(isString));
|
|
8720
8721
|
|
|
8721
8722
|
var getScrollbarWidth$1 = {};
|
|
8722
8723
|
|
|
@@ -8985,7 +8986,7 @@ var _propTypes = propTypes$6.exports;
|
|
|
8985
8986
|
|
|
8986
8987
|
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
8987
8988
|
|
|
8988
|
-
var _isString = isString
|
|
8989
|
+
var _isString = isString;
|
|
8989
8990
|
|
|
8990
8991
|
var _isString2 = _interopRequireDefault(_isString);
|
|
8991
8992
|
|
|
@@ -9774,1715 +9775,6 @@ exports["default"] = _Scrollbars2["default"];
|
|
|
9774
9775
|
exports.Scrollbars = _Scrollbars2["default"];
|
|
9775
9776
|
}(lib));
|
|
9776
9777
|
|
|
9777
|
-
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
9778
|
-
|
|
9779
|
-
var isDateObject = (value) => value instanceof Date;
|
|
9780
|
-
|
|
9781
|
-
var isNullOrUndefined = (value) => value == null;
|
|
9782
|
-
|
|
9783
|
-
const isObjectType = (value) => typeof value === 'object';
|
|
9784
|
-
var isObject$1 = (value) => !isNullOrUndefined(value) &&
|
|
9785
|
-
!Array.isArray(value) &&
|
|
9786
|
-
isObjectType(value) &&
|
|
9787
|
-
!isDateObject(value);
|
|
9788
|
-
|
|
9789
|
-
var getEventValue = (event) => isObject$1(event) && event.target
|
|
9790
|
-
? isCheckBoxInput(event.target)
|
|
9791
|
-
? event.target.checked
|
|
9792
|
-
: event.target.value
|
|
9793
|
-
: event;
|
|
9794
|
-
|
|
9795
|
-
var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
|
|
9796
|
-
|
|
9797
|
-
var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
|
|
9798
|
-
|
|
9799
|
-
var isPlainObject = (tempObject) => {
|
|
9800
|
-
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
|
9801
|
-
return (isObject$1(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
|
9802
|
-
};
|
|
9803
|
-
|
|
9804
|
-
var isWeb = typeof window !== 'undefined' &&
|
|
9805
|
-
typeof window.HTMLElement !== 'undefined' &&
|
|
9806
|
-
typeof document !== 'undefined';
|
|
9807
|
-
|
|
9808
|
-
function cloneObject(data) {
|
|
9809
|
-
let copy;
|
|
9810
|
-
const isArray = Array.isArray(data);
|
|
9811
|
-
if (data instanceof Date) {
|
|
9812
|
-
copy = new Date(data);
|
|
9813
|
-
}
|
|
9814
|
-
else if (data instanceof Set) {
|
|
9815
|
-
copy = new Set(data);
|
|
9816
|
-
}
|
|
9817
|
-
else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
|
|
9818
|
-
(isArray || isObject$1(data))) {
|
|
9819
|
-
copy = isArray ? [] : {};
|
|
9820
|
-
if (!Array.isArray(data) && !isPlainObject(data)) {
|
|
9821
|
-
copy = data;
|
|
9822
|
-
}
|
|
9823
|
-
else {
|
|
9824
|
-
for (const key in data) {
|
|
9825
|
-
copy[key] = cloneObject(data[key]);
|
|
9826
|
-
}
|
|
9827
|
-
}
|
|
9828
|
-
}
|
|
9829
|
-
else {
|
|
9830
|
-
return data;
|
|
9831
|
-
}
|
|
9832
|
-
return copy;
|
|
9833
|
-
}
|
|
9834
|
-
|
|
9835
|
-
var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
|
|
9836
|
-
|
|
9837
|
-
var isUndefined = (val) => val === undefined;
|
|
9838
|
-
|
|
9839
|
-
var get = (obj, path, defaultValue) => {
|
|
9840
|
-
if (!path || !isObject$1(obj)) {
|
|
9841
|
-
return defaultValue;
|
|
9842
|
-
}
|
|
9843
|
-
const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);
|
|
9844
|
-
return isUndefined(result) || result === obj
|
|
9845
|
-
? isUndefined(obj[path])
|
|
9846
|
-
? defaultValue
|
|
9847
|
-
: obj[path]
|
|
9848
|
-
: result;
|
|
9849
|
-
};
|
|
9850
|
-
|
|
9851
|
-
const EVENTS = {
|
|
9852
|
-
BLUR: 'blur',
|
|
9853
|
-
FOCUS_OUT: 'focusout',
|
|
9854
|
-
CHANGE: 'change',
|
|
9855
|
-
};
|
|
9856
|
-
const VALIDATION_MODE = {
|
|
9857
|
-
onBlur: 'onBlur',
|
|
9858
|
-
onChange: 'onChange',
|
|
9859
|
-
onSubmit: 'onSubmit',
|
|
9860
|
-
onTouched: 'onTouched',
|
|
9861
|
-
all: 'all',
|
|
9862
|
-
};
|
|
9863
|
-
const INPUT_VALIDATION_RULES = {
|
|
9864
|
-
max: 'max',
|
|
9865
|
-
min: 'min',
|
|
9866
|
-
maxLength: 'maxLength',
|
|
9867
|
-
minLength: 'minLength',
|
|
9868
|
-
pattern: 'pattern',
|
|
9869
|
-
required: 'required',
|
|
9870
|
-
validate: 'validate',
|
|
9871
|
-
};
|
|
9872
|
-
|
|
9873
|
-
React__default.createContext(null);
|
|
9874
|
-
|
|
9875
|
-
var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
|
|
9876
|
-
const result = {
|
|
9877
|
-
defaultValues: control._defaultValues,
|
|
9878
|
-
};
|
|
9879
|
-
for (const key in formState) {
|
|
9880
|
-
Object.defineProperty(result, key, {
|
|
9881
|
-
get: () => {
|
|
9882
|
-
const _key = key;
|
|
9883
|
-
if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
|
|
9884
|
-
control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
|
|
9885
|
-
}
|
|
9886
|
-
localProxyFormState && (localProxyFormState[_key] = true);
|
|
9887
|
-
return formState[_key];
|
|
9888
|
-
},
|
|
9889
|
-
});
|
|
9890
|
-
}
|
|
9891
|
-
return result;
|
|
9892
|
-
};
|
|
9893
|
-
|
|
9894
|
-
var isEmptyObject = (value) => isObject$1(value) && !Object.keys(value).length;
|
|
9895
|
-
|
|
9896
|
-
var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
|
|
9897
|
-
updateFormState(formStateData);
|
|
9898
|
-
const { name, ...formState } = formStateData;
|
|
9899
|
-
return (isEmptyObject(formState) ||
|
|
9900
|
-
Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
|
|
9901
|
-
Object.keys(formState).find((key) => _proxyFormState[key] ===
|
|
9902
|
-
(!isRoot || VALIDATION_MODE.all)));
|
|
9903
|
-
};
|
|
9904
|
-
|
|
9905
|
-
var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
|
|
9906
|
-
|
|
9907
|
-
function useSubscribe(props) {
|
|
9908
|
-
const _props = React__default.useRef(props);
|
|
9909
|
-
_props.current = props;
|
|
9910
|
-
React__default.useEffect(() => {
|
|
9911
|
-
const subscription = !props.disabled &&
|
|
9912
|
-
_props.current.subject &&
|
|
9913
|
-
_props.current.subject.subscribe({
|
|
9914
|
-
next: _props.current.next,
|
|
9915
|
-
});
|
|
9916
|
-
return () => {
|
|
9917
|
-
subscription && subscription.unsubscribe();
|
|
9918
|
-
};
|
|
9919
|
-
}, [props.disabled]);
|
|
9920
|
-
}
|
|
9921
|
-
|
|
9922
|
-
var isString = (value) => typeof value === 'string';
|
|
9923
|
-
|
|
9924
|
-
var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
|
|
9925
|
-
if (isString(names)) {
|
|
9926
|
-
isGlobal && _names.watch.add(names);
|
|
9927
|
-
return get(formValues, names, defaultValue);
|
|
9928
|
-
}
|
|
9929
|
-
if (Array.isArray(names)) {
|
|
9930
|
-
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
|
|
9931
|
-
}
|
|
9932
|
-
isGlobal && (_names.watchAll = true);
|
|
9933
|
-
return formValues;
|
|
9934
|
-
};
|
|
9935
|
-
|
|
9936
|
-
var isKey = (value) => /^\w*$/.test(value);
|
|
9937
|
-
|
|
9938
|
-
var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
|
|
9939
|
-
|
|
9940
|
-
function set(object, path, value) {
|
|
9941
|
-
let index = -1;
|
|
9942
|
-
const tempPath = isKey(path) ? [path] : stringToPath(path);
|
|
9943
|
-
const length = tempPath.length;
|
|
9944
|
-
const lastIndex = length - 1;
|
|
9945
|
-
while (++index < length) {
|
|
9946
|
-
const key = tempPath[index];
|
|
9947
|
-
let newValue = value;
|
|
9948
|
-
if (index !== lastIndex) {
|
|
9949
|
-
const objValue = object[key];
|
|
9950
|
-
newValue =
|
|
9951
|
-
isObject$1(objValue) || Array.isArray(objValue)
|
|
9952
|
-
? objValue
|
|
9953
|
-
: !isNaN(+tempPath[index + 1])
|
|
9954
|
-
? []
|
|
9955
|
-
: {};
|
|
9956
|
-
}
|
|
9957
|
-
object[key] = newValue;
|
|
9958
|
-
object = object[key];
|
|
9959
|
-
}
|
|
9960
|
-
return object;
|
|
9961
|
-
}
|
|
9962
|
-
|
|
9963
|
-
var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
|
|
9964
|
-
? {
|
|
9965
|
-
...errors[name],
|
|
9966
|
-
types: {
|
|
9967
|
-
...(errors[name] && errors[name].types ? errors[name].types : {}),
|
|
9968
|
-
[type]: message || true,
|
|
9969
|
-
},
|
|
9970
|
-
}
|
|
9971
|
-
: {};
|
|
9972
|
-
|
|
9973
|
-
const focusFieldBy = (fields, callback, fieldsNames) => {
|
|
9974
|
-
for (const key of fieldsNames || Object.keys(fields)) {
|
|
9975
|
-
const field = get(fields, key);
|
|
9976
|
-
if (field) {
|
|
9977
|
-
const { _f, ...currentField } = field;
|
|
9978
|
-
if (_f && callback(_f.name)) {
|
|
9979
|
-
if (_f.ref.focus) {
|
|
9980
|
-
_f.ref.focus();
|
|
9981
|
-
break;
|
|
9982
|
-
}
|
|
9983
|
-
else if (_f.refs && _f.refs[0].focus) {
|
|
9984
|
-
_f.refs[0].focus();
|
|
9985
|
-
break;
|
|
9986
|
-
}
|
|
9987
|
-
}
|
|
9988
|
-
else if (isObject$1(currentField)) {
|
|
9989
|
-
focusFieldBy(currentField, callback);
|
|
9990
|
-
}
|
|
9991
|
-
}
|
|
9992
|
-
}
|
|
9993
|
-
};
|
|
9994
|
-
|
|
9995
|
-
var getValidationModes = (mode) => ({
|
|
9996
|
-
isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
|
|
9997
|
-
isOnBlur: mode === VALIDATION_MODE.onBlur,
|
|
9998
|
-
isOnChange: mode === VALIDATION_MODE.onChange,
|
|
9999
|
-
isOnAll: mode === VALIDATION_MODE.all,
|
|
10000
|
-
isOnTouch: mode === VALIDATION_MODE.onTouched,
|
|
10001
|
-
});
|
|
10002
|
-
|
|
10003
|
-
var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
|
|
10004
|
-
(_names.watchAll ||
|
|
10005
|
-
_names.watch.has(name) ||
|
|
10006
|
-
[..._names.watch].some((watchName) => name.startsWith(watchName) &&
|
|
10007
|
-
/^\.\w+/.test(name.slice(watchName.length))));
|
|
10008
|
-
|
|
10009
|
-
var updateFieldArrayRootError = (errors, error, name) => {
|
|
10010
|
-
const fieldArrayErrors = compact(get(errors, name));
|
|
10011
|
-
set(fieldArrayErrors, 'root', error[name]);
|
|
10012
|
-
set(errors, name, fieldArrayErrors);
|
|
10013
|
-
return errors;
|
|
10014
|
-
};
|
|
10015
|
-
|
|
10016
|
-
var isBoolean = (value) => typeof value === 'boolean';
|
|
10017
|
-
|
|
10018
|
-
var isFileInput = (element) => element.type === 'file';
|
|
10019
|
-
|
|
10020
|
-
var isFunction$1 = (value) => typeof value === 'function';
|
|
10021
|
-
|
|
10022
|
-
var isHTMLElement = (value) => {
|
|
10023
|
-
if (!isWeb) {
|
|
10024
|
-
return false;
|
|
10025
|
-
}
|
|
10026
|
-
const owner = value ? value.ownerDocument : 0;
|
|
10027
|
-
return (value instanceof
|
|
10028
|
-
(owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));
|
|
10029
|
-
};
|
|
10030
|
-
|
|
10031
|
-
var isMessage = (value) => isString(value);
|
|
10032
|
-
|
|
10033
|
-
var isRadioInput = (element) => element.type === 'radio';
|
|
10034
|
-
|
|
10035
|
-
var isRegex = (value) => value instanceof RegExp;
|
|
10036
|
-
|
|
10037
|
-
const defaultResult = {
|
|
10038
|
-
value: false,
|
|
10039
|
-
isValid: false,
|
|
10040
|
-
};
|
|
10041
|
-
const validResult = { value: true, isValid: true };
|
|
10042
|
-
var getCheckboxValue = (options) => {
|
|
10043
|
-
if (Array.isArray(options)) {
|
|
10044
|
-
if (options.length > 1) {
|
|
10045
|
-
const values = options
|
|
10046
|
-
.filter((option) => option && option.checked && !option.disabled)
|
|
10047
|
-
.map((option) => option.value);
|
|
10048
|
-
return { value: values, isValid: !!values.length };
|
|
10049
|
-
}
|
|
10050
|
-
return options[0].checked && !options[0].disabled
|
|
10051
|
-
? // @ts-expect-error expected to work in the browser
|
|
10052
|
-
options[0].attributes && !isUndefined(options[0].attributes.value)
|
|
10053
|
-
? isUndefined(options[0].value) || options[0].value === ''
|
|
10054
|
-
? validResult
|
|
10055
|
-
: { value: options[0].value, isValid: true }
|
|
10056
|
-
: validResult
|
|
10057
|
-
: defaultResult;
|
|
10058
|
-
}
|
|
10059
|
-
return defaultResult;
|
|
10060
|
-
};
|
|
10061
|
-
|
|
10062
|
-
const defaultReturn = {
|
|
10063
|
-
isValid: false,
|
|
10064
|
-
value: null,
|
|
10065
|
-
};
|
|
10066
|
-
var getRadioValue = (options) => Array.isArray(options)
|
|
10067
|
-
? options.reduce((previous, option) => option && option.checked && !option.disabled
|
|
10068
|
-
? {
|
|
10069
|
-
isValid: true,
|
|
10070
|
-
value: option.value,
|
|
10071
|
-
}
|
|
10072
|
-
: previous, defaultReturn)
|
|
10073
|
-
: defaultReturn;
|
|
10074
|
-
|
|
10075
|
-
function getValidateError(result, ref, type = 'validate') {
|
|
10076
|
-
if (isMessage(result) ||
|
|
10077
|
-
(Array.isArray(result) && result.every(isMessage)) ||
|
|
10078
|
-
(isBoolean(result) && !result)) {
|
|
10079
|
-
return {
|
|
10080
|
-
type,
|
|
10081
|
-
message: isMessage(result) ? result : '',
|
|
10082
|
-
ref,
|
|
10083
|
-
};
|
|
10084
|
-
}
|
|
10085
|
-
}
|
|
10086
|
-
|
|
10087
|
-
var getValueAndMessage = (validationData) => isObject$1(validationData) && !isRegex(validationData)
|
|
10088
|
-
? validationData
|
|
10089
|
-
: {
|
|
10090
|
-
value: validationData,
|
|
10091
|
-
message: '',
|
|
10092
|
-
};
|
|
10093
|
-
|
|
10094
|
-
var validateField = async (field, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
|
|
10095
|
-
const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, disabled, } = field._f;
|
|
10096
|
-
const inputValue = get(formValues, name);
|
|
10097
|
-
if (!mount || disabled) {
|
|
10098
|
-
return {};
|
|
10099
|
-
}
|
|
10100
|
-
const inputRef = refs ? refs[0] : ref;
|
|
10101
|
-
const setCustomValidity = (message) => {
|
|
10102
|
-
if (shouldUseNativeValidation && inputRef.reportValidity) {
|
|
10103
|
-
inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');
|
|
10104
|
-
inputRef.reportValidity();
|
|
10105
|
-
}
|
|
10106
|
-
};
|
|
10107
|
-
const error = {};
|
|
10108
|
-
const isRadio = isRadioInput(ref);
|
|
10109
|
-
const isCheckBox = isCheckBoxInput(ref);
|
|
10110
|
-
const isRadioOrCheckbox = isRadio || isCheckBox;
|
|
10111
|
-
const isEmpty = ((valueAsNumber || isFileInput(ref)) &&
|
|
10112
|
-
isUndefined(ref.value) &&
|
|
10113
|
-
isUndefined(inputValue)) ||
|
|
10114
|
-
(isHTMLElement(ref) && ref.value === '') ||
|
|
10115
|
-
inputValue === '' ||
|
|
10116
|
-
(Array.isArray(inputValue) && !inputValue.length);
|
|
10117
|
-
const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
|
|
10118
|
-
const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
|
|
10119
|
-
const message = exceedMax ? maxLengthMessage : minLengthMessage;
|
|
10120
|
-
error[name] = {
|
|
10121
|
-
type: exceedMax ? maxType : minType,
|
|
10122
|
-
message,
|
|
10123
|
-
ref,
|
|
10124
|
-
...appendErrorsCurry(exceedMax ? maxType : minType, message),
|
|
10125
|
-
};
|
|
10126
|
-
};
|
|
10127
|
-
if (isFieldArray
|
|
10128
|
-
? !Array.isArray(inputValue) || !inputValue.length
|
|
10129
|
-
: required &&
|
|
10130
|
-
((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
|
|
10131
|
-
(isBoolean(inputValue) && !inputValue) ||
|
|
10132
|
-
(isCheckBox && !getCheckboxValue(refs).isValid) ||
|
|
10133
|
-
(isRadio && !getRadioValue(refs).isValid))) {
|
|
10134
|
-
const { value, message } = isMessage(required)
|
|
10135
|
-
? { value: !!required, message: required }
|
|
10136
|
-
: getValueAndMessage(required);
|
|
10137
|
-
if (value) {
|
|
10138
|
-
error[name] = {
|
|
10139
|
-
type: INPUT_VALIDATION_RULES.required,
|
|
10140
|
-
message,
|
|
10141
|
-
ref: inputRef,
|
|
10142
|
-
...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),
|
|
10143
|
-
};
|
|
10144
|
-
if (!validateAllFieldCriteria) {
|
|
10145
|
-
setCustomValidity(message);
|
|
10146
|
-
return error;
|
|
10147
|
-
}
|
|
10148
|
-
}
|
|
10149
|
-
}
|
|
10150
|
-
if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
|
|
10151
|
-
let exceedMax;
|
|
10152
|
-
let exceedMin;
|
|
10153
|
-
const maxOutput = getValueAndMessage(max);
|
|
10154
|
-
const minOutput = getValueAndMessage(min);
|
|
10155
|
-
if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {
|
|
10156
|
-
const valueNumber = ref.valueAsNumber ||
|
|
10157
|
-
(inputValue ? +inputValue : inputValue);
|
|
10158
|
-
if (!isNullOrUndefined(maxOutput.value)) {
|
|
10159
|
-
exceedMax = valueNumber > maxOutput.value;
|
|
10160
|
-
}
|
|
10161
|
-
if (!isNullOrUndefined(minOutput.value)) {
|
|
10162
|
-
exceedMin = valueNumber < minOutput.value;
|
|
10163
|
-
}
|
|
10164
|
-
}
|
|
10165
|
-
else {
|
|
10166
|
-
const valueDate = ref.valueAsDate || new Date(inputValue);
|
|
10167
|
-
const convertTimeToDate = (time) => new Date(new Date().toDateString() + ' ' + time);
|
|
10168
|
-
const isTime = ref.type == 'time';
|
|
10169
|
-
const isWeek = ref.type == 'week';
|
|
10170
|
-
if (isString(maxOutput.value) && inputValue) {
|
|
10171
|
-
exceedMax = isTime
|
|
10172
|
-
? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)
|
|
10173
|
-
: isWeek
|
|
10174
|
-
? inputValue > maxOutput.value
|
|
10175
|
-
: valueDate > new Date(maxOutput.value);
|
|
10176
|
-
}
|
|
10177
|
-
if (isString(minOutput.value) && inputValue) {
|
|
10178
|
-
exceedMin = isTime
|
|
10179
|
-
? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)
|
|
10180
|
-
: isWeek
|
|
10181
|
-
? inputValue < minOutput.value
|
|
10182
|
-
: valueDate < new Date(minOutput.value);
|
|
10183
|
-
}
|
|
10184
|
-
}
|
|
10185
|
-
if (exceedMax || exceedMin) {
|
|
10186
|
-
getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
|
|
10187
|
-
if (!validateAllFieldCriteria) {
|
|
10188
|
-
setCustomValidity(error[name].message);
|
|
10189
|
-
return error;
|
|
10190
|
-
}
|
|
10191
|
-
}
|
|
10192
|
-
}
|
|
10193
|
-
if ((maxLength || minLength) &&
|
|
10194
|
-
!isEmpty &&
|
|
10195
|
-
(isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))) {
|
|
10196
|
-
const maxLengthOutput = getValueAndMessage(maxLength);
|
|
10197
|
-
const minLengthOutput = getValueAndMessage(minLength);
|
|
10198
|
-
const exceedMax = !isNullOrUndefined(maxLengthOutput.value) &&
|
|
10199
|
-
inputValue.length > +maxLengthOutput.value;
|
|
10200
|
-
const exceedMin = !isNullOrUndefined(minLengthOutput.value) &&
|
|
10201
|
-
inputValue.length < +minLengthOutput.value;
|
|
10202
|
-
if (exceedMax || exceedMin) {
|
|
10203
|
-
getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
|
|
10204
|
-
if (!validateAllFieldCriteria) {
|
|
10205
|
-
setCustomValidity(error[name].message);
|
|
10206
|
-
return error;
|
|
10207
|
-
}
|
|
10208
|
-
}
|
|
10209
|
-
}
|
|
10210
|
-
if (pattern && !isEmpty && isString(inputValue)) {
|
|
10211
|
-
const { value: patternValue, message } = getValueAndMessage(pattern);
|
|
10212
|
-
if (isRegex(patternValue) && !inputValue.match(patternValue)) {
|
|
10213
|
-
error[name] = {
|
|
10214
|
-
type: INPUT_VALIDATION_RULES.pattern,
|
|
10215
|
-
message,
|
|
10216
|
-
ref,
|
|
10217
|
-
...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),
|
|
10218
|
-
};
|
|
10219
|
-
if (!validateAllFieldCriteria) {
|
|
10220
|
-
setCustomValidity(message);
|
|
10221
|
-
return error;
|
|
10222
|
-
}
|
|
10223
|
-
}
|
|
10224
|
-
}
|
|
10225
|
-
if (validate) {
|
|
10226
|
-
if (isFunction$1(validate)) {
|
|
10227
|
-
const result = await validate(inputValue, formValues);
|
|
10228
|
-
const validateError = getValidateError(result, inputRef);
|
|
10229
|
-
if (validateError) {
|
|
10230
|
-
error[name] = {
|
|
10231
|
-
...validateError,
|
|
10232
|
-
...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),
|
|
10233
|
-
};
|
|
10234
|
-
if (!validateAllFieldCriteria) {
|
|
10235
|
-
setCustomValidity(validateError.message);
|
|
10236
|
-
return error;
|
|
10237
|
-
}
|
|
10238
|
-
}
|
|
10239
|
-
}
|
|
10240
|
-
else if (isObject$1(validate)) {
|
|
10241
|
-
let validationResult = {};
|
|
10242
|
-
for (const key in validate) {
|
|
10243
|
-
if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
|
|
10244
|
-
break;
|
|
10245
|
-
}
|
|
10246
|
-
const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);
|
|
10247
|
-
if (validateError) {
|
|
10248
|
-
validationResult = {
|
|
10249
|
-
...validateError,
|
|
10250
|
-
...appendErrorsCurry(key, validateError.message),
|
|
10251
|
-
};
|
|
10252
|
-
setCustomValidity(validateError.message);
|
|
10253
|
-
if (validateAllFieldCriteria) {
|
|
10254
|
-
error[name] = validationResult;
|
|
10255
|
-
}
|
|
10256
|
-
}
|
|
10257
|
-
}
|
|
10258
|
-
if (!isEmptyObject(validationResult)) {
|
|
10259
|
-
error[name] = {
|
|
10260
|
-
ref: inputRef,
|
|
10261
|
-
...validationResult,
|
|
10262
|
-
};
|
|
10263
|
-
if (!validateAllFieldCriteria) {
|
|
10264
|
-
return error;
|
|
10265
|
-
}
|
|
10266
|
-
}
|
|
10267
|
-
}
|
|
10268
|
-
}
|
|
10269
|
-
setCustomValidity(true);
|
|
10270
|
-
return error;
|
|
10271
|
-
};
|
|
10272
|
-
|
|
10273
|
-
function baseGet(object, updatePath) {
|
|
10274
|
-
const length = updatePath.slice(0, -1).length;
|
|
10275
|
-
let index = 0;
|
|
10276
|
-
while (index < length) {
|
|
10277
|
-
object = isUndefined(object) ? index++ : object[updatePath[index++]];
|
|
10278
|
-
}
|
|
10279
|
-
return object;
|
|
10280
|
-
}
|
|
10281
|
-
function isEmptyArray(obj) {
|
|
10282
|
-
for (const key in obj) {
|
|
10283
|
-
if (!isUndefined(obj[key])) {
|
|
10284
|
-
return false;
|
|
10285
|
-
}
|
|
10286
|
-
}
|
|
10287
|
-
return true;
|
|
10288
|
-
}
|
|
10289
|
-
function unset(object, path) {
|
|
10290
|
-
const paths = Array.isArray(path)
|
|
10291
|
-
? path
|
|
10292
|
-
: isKey(path)
|
|
10293
|
-
? [path]
|
|
10294
|
-
: stringToPath(path);
|
|
10295
|
-
const childObject = paths.length === 1 ? object : baseGet(object, paths);
|
|
10296
|
-
const index = paths.length - 1;
|
|
10297
|
-
const key = paths[index];
|
|
10298
|
-
if (childObject) {
|
|
10299
|
-
delete childObject[key];
|
|
10300
|
-
}
|
|
10301
|
-
if (index !== 0 &&
|
|
10302
|
-
((isObject$1(childObject) && isEmptyObject(childObject)) ||
|
|
10303
|
-
(Array.isArray(childObject) && isEmptyArray(childObject)))) {
|
|
10304
|
-
unset(object, paths.slice(0, -1));
|
|
10305
|
-
}
|
|
10306
|
-
return object;
|
|
10307
|
-
}
|
|
10308
|
-
|
|
10309
|
-
function createSubject() {
|
|
10310
|
-
let _observers = [];
|
|
10311
|
-
const next = (value) => {
|
|
10312
|
-
for (const observer of _observers) {
|
|
10313
|
-
observer.next && observer.next(value);
|
|
10314
|
-
}
|
|
10315
|
-
};
|
|
10316
|
-
const subscribe = (observer) => {
|
|
10317
|
-
_observers.push(observer);
|
|
10318
|
-
return {
|
|
10319
|
-
unsubscribe: () => {
|
|
10320
|
-
_observers = _observers.filter((o) => o !== observer);
|
|
10321
|
-
},
|
|
10322
|
-
};
|
|
10323
|
-
};
|
|
10324
|
-
const unsubscribe = () => {
|
|
10325
|
-
_observers = [];
|
|
10326
|
-
};
|
|
10327
|
-
return {
|
|
10328
|
-
get observers() {
|
|
10329
|
-
return _observers;
|
|
10330
|
-
},
|
|
10331
|
-
next,
|
|
10332
|
-
subscribe,
|
|
10333
|
-
unsubscribe,
|
|
10334
|
-
};
|
|
10335
|
-
}
|
|
10336
|
-
|
|
10337
|
-
var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
|
|
10338
|
-
|
|
10339
|
-
function deepEqual(object1, object2) {
|
|
10340
|
-
if (isPrimitive(object1) || isPrimitive(object2)) {
|
|
10341
|
-
return object1 === object2;
|
|
10342
|
-
}
|
|
10343
|
-
if (isDateObject(object1) && isDateObject(object2)) {
|
|
10344
|
-
return object1.getTime() === object2.getTime();
|
|
10345
|
-
}
|
|
10346
|
-
const keys1 = Object.keys(object1);
|
|
10347
|
-
const keys2 = Object.keys(object2);
|
|
10348
|
-
if (keys1.length !== keys2.length) {
|
|
10349
|
-
return false;
|
|
10350
|
-
}
|
|
10351
|
-
for (const key of keys1) {
|
|
10352
|
-
const val1 = object1[key];
|
|
10353
|
-
if (!keys2.includes(key)) {
|
|
10354
|
-
return false;
|
|
10355
|
-
}
|
|
10356
|
-
if (key !== 'ref') {
|
|
10357
|
-
const val2 = object2[key];
|
|
10358
|
-
if ((isDateObject(val1) && isDateObject(val2)) ||
|
|
10359
|
-
(isObject$1(val1) && isObject$1(val2)) ||
|
|
10360
|
-
(Array.isArray(val1) && Array.isArray(val2))
|
|
10361
|
-
? !deepEqual(val1, val2)
|
|
10362
|
-
: val1 !== val2) {
|
|
10363
|
-
return false;
|
|
10364
|
-
}
|
|
10365
|
-
}
|
|
10366
|
-
}
|
|
10367
|
-
return true;
|
|
10368
|
-
}
|
|
10369
|
-
|
|
10370
|
-
var isMultipleSelect = (element) => element.type === `select-multiple`;
|
|
10371
|
-
|
|
10372
|
-
var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
|
|
10373
|
-
|
|
10374
|
-
var live = (ref) => isHTMLElement(ref) && ref.isConnected;
|
|
10375
|
-
|
|
10376
|
-
var objectHasFunction = (data) => {
|
|
10377
|
-
for (const key in data) {
|
|
10378
|
-
if (isFunction$1(data[key])) {
|
|
10379
|
-
return true;
|
|
10380
|
-
}
|
|
10381
|
-
}
|
|
10382
|
-
return false;
|
|
10383
|
-
};
|
|
10384
|
-
|
|
10385
|
-
function markFieldsDirty(data, fields = {}) {
|
|
10386
|
-
const isParentNodeArray = Array.isArray(data);
|
|
10387
|
-
if (isObject$1(data) || isParentNodeArray) {
|
|
10388
|
-
for (const key in data) {
|
|
10389
|
-
if (Array.isArray(data[key]) ||
|
|
10390
|
-
(isObject$1(data[key]) && !objectHasFunction(data[key]))) {
|
|
10391
|
-
fields[key] = Array.isArray(data[key]) ? [] : {};
|
|
10392
|
-
markFieldsDirty(data[key], fields[key]);
|
|
10393
|
-
}
|
|
10394
|
-
else if (!isNullOrUndefined(data[key])) {
|
|
10395
|
-
fields[key] = true;
|
|
10396
|
-
}
|
|
10397
|
-
}
|
|
10398
|
-
}
|
|
10399
|
-
return fields;
|
|
10400
|
-
}
|
|
10401
|
-
function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {
|
|
10402
|
-
const isParentNodeArray = Array.isArray(data);
|
|
10403
|
-
if (isObject$1(data) || isParentNodeArray) {
|
|
10404
|
-
for (const key in data) {
|
|
10405
|
-
if (Array.isArray(data[key]) ||
|
|
10406
|
-
(isObject$1(data[key]) && !objectHasFunction(data[key]))) {
|
|
10407
|
-
if (isUndefined(formValues) ||
|
|
10408
|
-
isPrimitive(dirtyFieldsFromValues[key])) {
|
|
10409
|
-
dirtyFieldsFromValues[key] = Array.isArray(data[key])
|
|
10410
|
-
? markFieldsDirty(data[key], [])
|
|
10411
|
-
: { ...markFieldsDirty(data[key]) };
|
|
10412
|
-
}
|
|
10413
|
-
else {
|
|
10414
|
-
getDirtyFieldsFromDefaultValues(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
|
|
10415
|
-
}
|
|
10416
|
-
}
|
|
10417
|
-
else {
|
|
10418
|
-
dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);
|
|
10419
|
-
}
|
|
10420
|
-
}
|
|
10421
|
-
}
|
|
10422
|
-
return dirtyFieldsFromValues;
|
|
10423
|
-
}
|
|
10424
|
-
var getDirtyFields = (defaultValues, formValues) => getDirtyFieldsFromDefaultValues(defaultValues, formValues, markFieldsDirty(formValues));
|
|
10425
|
-
|
|
10426
|
-
var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value)
|
|
10427
|
-
? value
|
|
10428
|
-
: valueAsNumber
|
|
10429
|
-
? value === ''
|
|
10430
|
-
? NaN
|
|
10431
|
-
: value
|
|
10432
|
-
? +value
|
|
10433
|
-
: value
|
|
10434
|
-
: valueAsDate && isString(value)
|
|
10435
|
-
? new Date(value)
|
|
10436
|
-
: setValueAs
|
|
10437
|
-
? setValueAs(value)
|
|
10438
|
-
: value;
|
|
10439
|
-
|
|
10440
|
-
function getFieldValue(_f) {
|
|
10441
|
-
const ref = _f.ref;
|
|
10442
|
-
if (_f.refs ? _f.refs.every((ref) => ref.disabled) : ref.disabled) {
|
|
10443
|
-
return;
|
|
10444
|
-
}
|
|
10445
|
-
if (isFileInput(ref)) {
|
|
10446
|
-
return ref.files;
|
|
10447
|
-
}
|
|
10448
|
-
if (isRadioInput(ref)) {
|
|
10449
|
-
return getRadioValue(_f.refs).value;
|
|
10450
|
-
}
|
|
10451
|
-
if (isMultipleSelect(ref)) {
|
|
10452
|
-
return [...ref.selectedOptions].map(({ value }) => value);
|
|
10453
|
-
}
|
|
10454
|
-
if (isCheckBoxInput(ref)) {
|
|
10455
|
-
return getCheckboxValue(_f.refs).value;
|
|
10456
|
-
}
|
|
10457
|
-
return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);
|
|
10458
|
-
}
|
|
10459
|
-
|
|
10460
|
-
var getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {
|
|
10461
|
-
const fields = {};
|
|
10462
|
-
for (const name of fieldsNames) {
|
|
10463
|
-
const field = get(_fields, name);
|
|
10464
|
-
field && set(fields, name, field._f);
|
|
10465
|
-
}
|
|
10466
|
-
return {
|
|
10467
|
-
criteriaMode,
|
|
10468
|
-
names: [...fieldsNames],
|
|
10469
|
-
fields,
|
|
10470
|
-
shouldUseNativeValidation,
|
|
10471
|
-
};
|
|
10472
|
-
};
|
|
10473
|
-
|
|
10474
|
-
var getRuleValue = (rule) => isUndefined(rule)
|
|
10475
|
-
? rule
|
|
10476
|
-
: isRegex(rule)
|
|
10477
|
-
? rule.source
|
|
10478
|
-
: isObject$1(rule)
|
|
10479
|
-
? isRegex(rule.value)
|
|
10480
|
-
? rule.value.source
|
|
10481
|
-
: rule.value
|
|
10482
|
-
: rule;
|
|
10483
|
-
|
|
10484
|
-
var hasValidation = (options) => options.mount &&
|
|
10485
|
-
(options.required ||
|
|
10486
|
-
options.min ||
|
|
10487
|
-
options.max ||
|
|
10488
|
-
options.maxLength ||
|
|
10489
|
-
options.minLength ||
|
|
10490
|
-
options.pattern ||
|
|
10491
|
-
options.validate);
|
|
10492
|
-
|
|
10493
|
-
function schemaErrorLookup(errors, _fields, name) {
|
|
10494
|
-
const error = get(errors, name);
|
|
10495
|
-
if (error || isKey(name)) {
|
|
10496
|
-
return {
|
|
10497
|
-
error,
|
|
10498
|
-
name,
|
|
10499
|
-
};
|
|
10500
|
-
}
|
|
10501
|
-
const names = name.split('.');
|
|
10502
|
-
while (names.length) {
|
|
10503
|
-
const fieldName = names.join('.');
|
|
10504
|
-
const field = get(_fields, fieldName);
|
|
10505
|
-
const foundError = get(errors, fieldName);
|
|
10506
|
-
if (field && !Array.isArray(field) && name !== fieldName) {
|
|
10507
|
-
return { name };
|
|
10508
|
-
}
|
|
10509
|
-
if (foundError && foundError.type) {
|
|
10510
|
-
return {
|
|
10511
|
-
name: fieldName,
|
|
10512
|
-
error: foundError,
|
|
10513
|
-
};
|
|
10514
|
-
}
|
|
10515
|
-
names.pop();
|
|
10516
|
-
}
|
|
10517
|
-
return {
|
|
10518
|
-
name,
|
|
10519
|
-
};
|
|
10520
|
-
}
|
|
10521
|
-
|
|
10522
|
-
var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {
|
|
10523
|
-
if (mode.isOnAll) {
|
|
10524
|
-
return false;
|
|
10525
|
-
}
|
|
10526
|
-
else if (!isSubmitted && mode.isOnTouch) {
|
|
10527
|
-
return !(isTouched || isBlurEvent);
|
|
10528
|
-
}
|
|
10529
|
-
else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
|
|
10530
|
-
return !isBlurEvent;
|
|
10531
|
-
}
|
|
10532
|
-
else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
|
|
10533
|
-
return isBlurEvent;
|
|
10534
|
-
}
|
|
10535
|
-
return true;
|
|
10536
|
-
};
|
|
10537
|
-
|
|
10538
|
-
var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
|
|
10539
|
-
|
|
10540
|
-
const defaultOptions = {
|
|
10541
|
-
mode: VALIDATION_MODE.onSubmit,
|
|
10542
|
-
reValidateMode: VALIDATION_MODE.onChange,
|
|
10543
|
-
shouldFocusError: true,
|
|
10544
|
-
};
|
|
10545
|
-
function createFormControl(props = {}, flushRootRender) {
|
|
10546
|
-
let _options = {
|
|
10547
|
-
...defaultOptions,
|
|
10548
|
-
...props,
|
|
10549
|
-
};
|
|
10550
|
-
let _formState = {
|
|
10551
|
-
submitCount: 0,
|
|
10552
|
-
isDirty: false,
|
|
10553
|
-
isLoading: isFunction$1(_options.defaultValues),
|
|
10554
|
-
isValidating: false,
|
|
10555
|
-
isSubmitted: false,
|
|
10556
|
-
isSubmitting: false,
|
|
10557
|
-
isSubmitSuccessful: false,
|
|
10558
|
-
isValid: false,
|
|
10559
|
-
touchedFields: {},
|
|
10560
|
-
dirtyFields: {},
|
|
10561
|
-
errors: {},
|
|
10562
|
-
};
|
|
10563
|
-
let _fields = {};
|
|
10564
|
-
let _defaultValues = isObject$1(_options.defaultValues) || isObject$1(_options.values)
|
|
10565
|
-
? cloneObject(_options.defaultValues || _options.values) || {}
|
|
10566
|
-
: {};
|
|
10567
|
-
let _formValues = _options.shouldUnregister
|
|
10568
|
-
? {}
|
|
10569
|
-
: cloneObject(_defaultValues);
|
|
10570
|
-
let _state = {
|
|
10571
|
-
action: false,
|
|
10572
|
-
mount: false,
|
|
10573
|
-
watch: false,
|
|
10574
|
-
};
|
|
10575
|
-
let _names = {
|
|
10576
|
-
mount: new Set(),
|
|
10577
|
-
unMount: new Set(),
|
|
10578
|
-
array: new Set(),
|
|
10579
|
-
watch: new Set(),
|
|
10580
|
-
};
|
|
10581
|
-
let delayErrorCallback;
|
|
10582
|
-
let timer = 0;
|
|
10583
|
-
const _proxyFormState = {
|
|
10584
|
-
isDirty: false,
|
|
10585
|
-
dirtyFields: false,
|
|
10586
|
-
touchedFields: false,
|
|
10587
|
-
isValidating: false,
|
|
10588
|
-
isValid: false,
|
|
10589
|
-
errors: false,
|
|
10590
|
-
};
|
|
10591
|
-
const _subjects = {
|
|
10592
|
-
values: createSubject(),
|
|
10593
|
-
array: createSubject(),
|
|
10594
|
-
state: createSubject(),
|
|
10595
|
-
};
|
|
10596
|
-
const shouldCaptureDirtyFields = props.resetOptions && props.resetOptions.keepDirtyValues;
|
|
10597
|
-
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
10598
|
-
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
10599
|
-
const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
|
|
10600
|
-
const debounce = (callback) => (wait) => {
|
|
10601
|
-
clearTimeout(timer);
|
|
10602
|
-
timer = setTimeout(callback, wait);
|
|
10603
|
-
};
|
|
10604
|
-
const _updateValid = async (shouldUpdateValid) => {
|
|
10605
|
-
if (_proxyFormState.isValid || shouldUpdateValid) {
|
|
10606
|
-
const isValid = _options.resolver
|
|
10607
|
-
? isEmptyObject((await _executeSchema()).errors)
|
|
10608
|
-
: await executeBuiltInValidation(_fields, true);
|
|
10609
|
-
if (isValid !== _formState.isValid) {
|
|
10610
|
-
_subjects.state.next({
|
|
10611
|
-
isValid,
|
|
10612
|
-
});
|
|
10613
|
-
}
|
|
10614
|
-
}
|
|
10615
|
-
};
|
|
10616
|
-
const _updateIsValidating = (value) => _proxyFormState.isValidating &&
|
|
10617
|
-
_subjects.state.next({
|
|
10618
|
-
isValidating: value,
|
|
10619
|
-
});
|
|
10620
|
-
const _updateFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
|
|
10621
|
-
if (args && method) {
|
|
10622
|
-
_state.action = true;
|
|
10623
|
-
if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
|
|
10624
|
-
const fieldValues = method(get(_fields, name), args.argA, args.argB);
|
|
10625
|
-
shouldSetValues && set(_fields, name, fieldValues);
|
|
10626
|
-
}
|
|
10627
|
-
if (shouldUpdateFieldsAndState &&
|
|
10628
|
-
Array.isArray(get(_formState.errors, name))) {
|
|
10629
|
-
const errors = method(get(_formState.errors, name), args.argA, args.argB);
|
|
10630
|
-
shouldSetValues && set(_formState.errors, name, errors);
|
|
10631
|
-
unsetEmptyArray(_formState.errors, name);
|
|
10632
|
-
}
|
|
10633
|
-
if (_proxyFormState.touchedFields &&
|
|
10634
|
-
shouldUpdateFieldsAndState &&
|
|
10635
|
-
Array.isArray(get(_formState.touchedFields, name))) {
|
|
10636
|
-
const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
|
|
10637
|
-
shouldSetValues && set(_formState.touchedFields, name, touchedFields);
|
|
10638
|
-
}
|
|
10639
|
-
if (_proxyFormState.dirtyFields) {
|
|
10640
|
-
_formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
|
|
10641
|
-
}
|
|
10642
|
-
_subjects.state.next({
|
|
10643
|
-
name,
|
|
10644
|
-
isDirty: _getDirty(name, values),
|
|
10645
|
-
dirtyFields: _formState.dirtyFields,
|
|
10646
|
-
errors: _formState.errors,
|
|
10647
|
-
isValid: _formState.isValid,
|
|
10648
|
-
});
|
|
10649
|
-
}
|
|
10650
|
-
else {
|
|
10651
|
-
set(_formValues, name, values);
|
|
10652
|
-
}
|
|
10653
|
-
};
|
|
10654
|
-
const updateErrors = (name, error) => {
|
|
10655
|
-
set(_formState.errors, name, error);
|
|
10656
|
-
_subjects.state.next({
|
|
10657
|
-
errors: _formState.errors,
|
|
10658
|
-
});
|
|
10659
|
-
};
|
|
10660
|
-
const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
|
|
10661
|
-
const field = get(_fields, name);
|
|
10662
|
-
if (field) {
|
|
10663
|
-
const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);
|
|
10664
|
-
isUndefined(defaultValue) ||
|
|
10665
|
-
(ref && ref.defaultChecked) ||
|
|
10666
|
-
shouldSkipSetValueAs
|
|
10667
|
-
? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
|
|
10668
|
-
: setFieldValue(name, defaultValue);
|
|
10669
|
-
_state.mount && _updateValid();
|
|
10670
|
-
}
|
|
10671
|
-
};
|
|
10672
|
-
const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
|
|
10673
|
-
let shouldUpdateField = false;
|
|
10674
|
-
let isPreviousDirty = false;
|
|
10675
|
-
const output = {
|
|
10676
|
-
name,
|
|
10677
|
-
};
|
|
10678
|
-
if (!isBlurEvent || shouldDirty) {
|
|
10679
|
-
if (_proxyFormState.isDirty) {
|
|
10680
|
-
isPreviousDirty = _formState.isDirty;
|
|
10681
|
-
_formState.isDirty = output.isDirty = _getDirty();
|
|
10682
|
-
shouldUpdateField = isPreviousDirty !== output.isDirty;
|
|
10683
|
-
}
|
|
10684
|
-
const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);
|
|
10685
|
-
isPreviousDirty = get(_formState.dirtyFields, name);
|
|
10686
|
-
isCurrentFieldPristine
|
|
10687
|
-
? unset(_formState.dirtyFields, name)
|
|
10688
|
-
: set(_formState.dirtyFields, name, true);
|
|
10689
|
-
output.dirtyFields = _formState.dirtyFields;
|
|
10690
|
-
shouldUpdateField =
|
|
10691
|
-
shouldUpdateField ||
|
|
10692
|
-
(_proxyFormState.dirtyFields &&
|
|
10693
|
-
isPreviousDirty !== !isCurrentFieldPristine);
|
|
10694
|
-
}
|
|
10695
|
-
if (isBlurEvent) {
|
|
10696
|
-
const isPreviousFieldTouched = get(_formState.touchedFields, name);
|
|
10697
|
-
if (!isPreviousFieldTouched) {
|
|
10698
|
-
set(_formState.touchedFields, name, isBlurEvent);
|
|
10699
|
-
output.touchedFields = _formState.touchedFields;
|
|
10700
|
-
shouldUpdateField =
|
|
10701
|
-
shouldUpdateField ||
|
|
10702
|
-
(_proxyFormState.touchedFields &&
|
|
10703
|
-
isPreviousFieldTouched !== isBlurEvent);
|
|
10704
|
-
}
|
|
10705
|
-
}
|
|
10706
|
-
shouldUpdateField && shouldRender && _subjects.state.next(output);
|
|
10707
|
-
return shouldUpdateField ? output : {};
|
|
10708
|
-
};
|
|
10709
|
-
const shouldRenderByError = (name, isValid, error, fieldState) => {
|
|
10710
|
-
const previousFieldError = get(_formState.errors, name);
|
|
10711
|
-
const shouldUpdateValid = _proxyFormState.isValid &&
|
|
10712
|
-
isBoolean(isValid) &&
|
|
10713
|
-
_formState.isValid !== isValid;
|
|
10714
|
-
if (props.delayError && error) {
|
|
10715
|
-
delayErrorCallback = debounce(() => updateErrors(name, error));
|
|
10716
|
-
delayErrorCallback(props.delayError);
|
|
10717
|
-
}
|
|
10718
|
-
else {
|
|
10719
|
-
clearTimeout(timer);
|
|
10720
|
-
delayErrorCallback = null;
|
|
10721
|
-
error
|
|
10722
|
-
? set(_formState.errors, name, error)
|
|
10723
|
-
: unset(_formState.errors, name);
|
|
10724
|
-
}
|
|
10725
|
-
if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||
|
|
10726
|
-
!isEmptyObject(fieldState) ||
|
|
10727
|
-
shouldUpdateValid) {
|
|
10728
|
-
const updatedFormState = {
|
|
10729
|
-
...fieldState,
|
|
10730
|
-
...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),
|
|
10731
|
-
errors: _formState.errors,
|
|
10732
|
-
name,
|
|
10733
|
-
};
|
|
10734
|
-
_formState = {
|
|
10735
|
-
..._formState,
|
|
10736
|
-
...updatedFormState,
|
|
10737
|
-
};
|
|
10738
|
-
_subjects.state.next(updatedFormState);
|
|
10739
|
-
}
|
|
10740
|
-
_updateIsValidating(false);
|
|
10741
|
-
};
|
|
10742
|
-
const _executeSchema = async (name) => _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
|
|
10743
|
-
const executeSchemaAndUpdateState = async (names) => {
|
|
10744
|
-
const { errors } = await _executeSchema();
|
|
10745
|
-
if (names) {
|
|
10746
|
-
for (const name of names) {
|
|
10747
|
-
const error = get(errors, name);
|
|
10748
|
-
error
|
|
10749
|
-
? set(_formState.errors, name, error)
|
|
10750
|
-
: unset(_formState.errors, name);
|
|
10751
|
-
}
|
|
10752
|
-
}
|
|
10753
|
-
else {
|
|
10754
|
-
_formState.errors = errors;
|
|
10755
|
-
}
|
|
10756
|
-
return errors;
|
|
10757
|
-
};
|
|
10758
|
-
const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
|
|
10759
|
-
valid: true,
|
|
10760
|
-
}) => {
|
|
10761
|
-
for (const name in fields) {
|
|
10762
|
-
const field = fields[name];
|
|
10763
|
-
if (field) {
|
|
10764
|
-
const { _f, ...fieldValue } = field;
|
|
10765
|
-
if (_f) {
|
|
10766
|
-
const isFieldArrayRoot = _names.array.has(_f.name);
|
|
10767
|
-
const fieldError = await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
|
|
10768
|
-
if (fieldError[_f.name]) {
|
|
10769
|
-
context.valid = false;
|
|
10770
|
-
if (shouldOnlyCheckValid) {
|
|
10771
|
-
break;
|
|
10772
|
-
}
|
|
10773
|
-
}
|
|
10774
|
-
!shouldOnlyCheckValid &&
|
|
10775
|
-
(get(fieldError, _f.name)
|
|
10776
|
-
? isFieldArrayRoot
|
|
10777
|
-
? updateFieldArrayRootError(_formState.errors, fieldError, _f.name)
|
|
10778
|
-
: set(_formState.errors, _f.name, fieldError[_f.name])
|
|
10779
|
-
: unset(_formState.errors, _f.name));
|
|
10780
|
-
}
|
|
10781
|
-
fieldValue &&
|
|
10782
|
-
(await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
|
|
10783
|
-
}
|
|
10784
|
-
}
|
|
10785
|
-
return context.valid;
|
|
10786
|
-
};
|
|
10787
|
-
const _removeUnmounted = () => {
|
|
10788
|
-
for (const name of _names.unMount) {
|
|
10789
|
-
const field = get(_fields, name);
|
|
10790
|
-
field &&
|
|
10791
|
-
(field._f.refs
|
|
10792
|
-
? field._f.refs.every((ref) => !live(ref))
|
|
10793
|
-
: !live(field._f.ref)) &&
|
|
10794
|
-
unregister(name);
|
|
10795
|
-
}
|
|
10796
|
-
_names.unMount = new Set();
|
|
10797
|
-
};
|
|
10798
|
-
const _getDirty = (name, data) => (name && data && set(_formValues, name, data),
|
|
10799
|
-
!deepEqual(getValues(), _defaultValues));
|
|
10800
|
-
const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
|
|
10801
|
-
...(_state.mount
|
|
10802
|
-
? _formValues
|
|
10803
|
-
: isUndefined(defaultValue)
|
|
10804
|
-
? _defaultValues
|
|
10805
|
-
: isString(names)
|
|
10806
|
-
? { [names]: defaultValue }
|
|
10807
|
-
: defaultValue),
|
|
10808
|
-
}, isGlobal, defaultValue);
|
|
10809
|
-
const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
|
|
10810
|
-
const setFieldValue = (name, value, options = {}) => {
|
|
10811
|
-
const field = get(_fields, name);
|
|
10812
|
-
let fieldValue = value;
|
|
10813
|
-
if (field) {
|
|
10814
|
-
const fieldReference = field._f;
|
|
10815
|
-
if (fieldReference) {
|
|
10816
|
-
!fieldReference.disabled &&
|
|
10817
|
-
set(_formValues, name, getFieldValueAs(value, fieldReference));
|
|
10818
|
-
fieldValue =
|
|
10819
|
-
isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)
|
|
10820
|
-
? ''
|
|
10821
|
-
: value;
|
|
10822
|
-
if (isMultipleSelect(fieldReference.ref)) {
|
|
10823
|
-
[...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));
|
|
10824
|
-
}
|
|
10825
|
-
else if (fieldReference.refs) {
|
|
10826
|
-
if (isCheckBoxInput(fieldReference.ref)) {
|
|
10827
|
-
fieldReference.refs.length > 1
|
|
10828
|
-
? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
|
|
10829
|
-
(checkboxRef.checked = Array.isArray(fieldValue)
|
|
10830
|
-
? !!fieldValue.find((data) => data === checkboxRef.value)
|
|
10831
|
-
: fieldValue === checkboxRef.value))
|
|
10832
|
-
: fieldReference.refs[0] &&
|
|
10833
|
-
(fieldReference.refs[0].checked = !!fieldValue);
|
|
10834
|
-
}
|
|
10835
|
-
else {
|
|
10836
|
-
fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
|
|
10837
|
-
}
|
|
10838
|
-
}
|
|
10839
|
-
else if (isFileInput(fieldReference.ref)) {
|
|
10840
|
-
fieldReference.ref.value = '';
|
|
10841
|
-
}
|
|
10842
|
-
else {
|
|
10843
|
-
fieldReference.ref.value = fieldValue;
|
|
10844
|
-
if (!fieldReference.ref.type) {
|
|
10845
|
-
_subjects.values.next({
|
|
10846
|
-
name,
|
|
10847
|
-
values: { ..._formValues },
|
|
10848
|
-
});
|
|
10849
|
-
}
|
|
10850
|
-
}
|
|
10851
|
-
}
|
|
10852
|
-
}
|
|
10853
|
-
(options.shouldDirty || options.shouldTouch) &&
|
|
10854
|
-
updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
|
|
10855
|
-
options.shouldValidate && trigger(name);
|
|
10856
|
-
};
|
|
10857
|
-
const setValues = (name, value, options) => {
|
|
10858
|
-
for (const fieldKey in value) {
|
|
10859
|
-
const fieldValue = value[fieldKey];
|
|
10860
|
-
const fieldName = `${name}.${fieldKey}`;
|
|
10861
|
-
const field = get(_fields, fieldName);
|
|
10862
|
-
(_names.array.has(name) ||
|
|
10863
|
-
!isPrimitive(fieldValue) ||
|
|
10864
|
-
(field && !field._f)) &&
|
|
10865
|
-
!isDateObject(fieldValue)
|
|
10866
|
-
? setValues(fieldName, fieldValue, options)
|
|
10867
|
-
: setFieldValue(fieldName, fieldValue, options);
|
|
10868
|
-
}
|
|
10869
|
-
};
|
|
10870
|
-
const setValue = (name, value, options = {}) => {
|
|
10871
|
-
const field = get(_fields, name);
|
|
10872
|
-
const isFieldArray = _names.array.has(name);
|
|
10873
|
-
const cloneValue = cloneObject(value);
|
|
10874
|
-
set(_formValues, name, cloneValue);
|
|
10875
|
-
if (isFieldArray) {
|
|
10876
|
-
_subjects.array.next({
|
|
10877
|
-
name,
|
|
10878
|
-
values: { ..._formValues },
|
|
10879
|
-
});
|
|
10880
|
-
if ((_proxyFormState.isDirty || _proxyFormState.dirtyFields) &&
|
|
10881
|
-
options.shouldDirty) {
|
|
10882
|
-
_subjects.state.next({
|
|
10883
|
-
name,
|
|
10884
|
-
dirtyFields: getDirtyFields(_defaultValues, _formValues),
|
|
10885
|
-
isDirty: _getDirty(name, cloneValue),
|
|
10886
|
-
});
|
|
10887
|
-
}
|
|
10888
|
-
}
|
|
10889
|
-
else {
|
|
10890
|
-
field && !field._f && !isNullOrUndefined(cloneValue)
|
|
10891
|
-
? setValues(name, cloneValue, options)
|
|
10892
|
-
: setFieldValue(name, cloneValue, options);
|
|
10893
|
-
}
|
|
10894
|
-
isWatched(name, _names) && _subjects.state.next({ ..._formState });
|
|
10895
|
-
_subjects.values.next({
|
|
10896
|
-
name,
|
|
10897
|
-
values: { ..._formValues },
|
|
10898
|
-
});
|
|
10899
|
-
!_state.mount && flushRootRender();
|
|
10900
|
-
};
|
|
10901
|
-
const onChange = async (event) => {
|
|
10902
|
-
const target = event.target;
|
|
10903
|
-
let name = target.name;
|
|
10904
|
-
let isFieldValueUpdated = true;
|
|
10905
|
-
const field = get(_fields, name);
|
|
10906
|
-
const getCurrentFieldValue = () => target.type ? getFieldValue(field._f) : getEventValue(event);
|
|
10907
|
-
if (field) {
|
|
10908
|
-
let error;
|
|
10909
|
-
let isValid;
|
|
10910
|
-
const fieldValue = getCurrentFieldValue();
|
|
10911
|
-
const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;
|
|
10912
|
-
const shouldSkipValidation = (!hasValidation(field._f) &&
|
|
10913
|
-
!_options.resolver &&
|
|
10914
|
-
!get(_formState.errors, name) &&
|
|
10915
|
-
!field._f.deps) ||
|
|
10916
|
-
skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);
|
|
10917
|
-
const watched = isWatched(name, _names, isBlurEvent);
|
|
10918
|
-
set(_formValues, name, fieldValue);
|
|
10919
|
-
if (isBlurEvent) {
|
|
10920
|
-
field._f.onBlur && field._f.onBlur(event);
|
|
10921
|
-
delayErrorCallback && delayErrorCallback(0);
|
|
10922
|
-
}
|
|
10923
|
-
else if (field._f.onChange) {
|
|
10924
|
-
field._f.onChange(event);
|
|
10925
|
-
}
|
|
10926
|
-
const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent, false);
|
|
10927
|
-
const shouldRender = !isEmptyObject(fieldState) || watched;
|
|
10928
|
-
!isBlurEvent &&
|
|
10929
|
-
_subjects.values.next({
|
|
10930
|
-
name,
|
|
10931
|
-
type: event.type,
|
|
10932
|
-
values: { ..._formValues },
|
|
10933
|
-
});
|
|
10934
|
-
if (shouldSkipValidation) {
|
|
10935
|
-
_proxyFormState.isValid && _updateValid();
|
|
10936
|
-
return (shouldRender &&
|
|
10937
|
-
_subjects.state.next({ name, ...(watched ? {} : fieldState) }));
|
|
10938
|
-
}
|
|
10939
|
-
!isBlurEvent && watched && _subjects.state.next({ ..._formState });
|
|
10940
|
-
_updateIsValidating(true);
|
|
10941
|
-
if (_options.resolver) {
|
|
10942
|
-
const { errors } = await _executeSchema([name]);
|
|
10943
|
-
const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
|
|
10944
|
-
const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
|
|
10945
|
-
error = errorLookupResult.error;
|
|
10946
|
-
name = errorLookupResult.name;
|
|
10947
|
-
isValid = isEmptyObject(errors);
|
|
10948
|
-
}
|
|
10949
|
-
else {
|
|
10950
|
-
error = (await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
|
|
10951
|
-
isFieldValueUpdated =
|
|
10952
|
-
isNaN(fieldValue) ||
|
|
10953
|
-
fieldValue === get(_formValues, name, fieldValue);
|
|
10954
|
-
if (isFieldValueUpdated) {
|
|
10955
|
-
if (error) {
|
|
10956
|
-
isValid = false;
|
|
10957
|
-
}
|
|
10958
|
-
else if (_proxyFormState.isValid) {
|
|
10959
|
-
isValid = await executeBuiltInValidation(_fields, true);
|
|
10960
|
-
}
|
|
10961
|
-
}
|
|
10962
|
-
}
|
|
10963
|
-
if (isFieldValueUpdated) {
|
|
10964
|
-
field._f.deps &&
|
|
10965
|
-
trigger(field._f.deps);
|
|
10966
|
-
shouldRenderByError(name, isValid, error, fieldState);
|
|
10967
|
-
}
|
|
10968
|
-
}
|
|
10969
|
-
};
|
|
10970
|
-
const trigger = async (name, options = {}) => {
|
|
10971
|
-
let isValid;
|
|
10972
|
-
let validationResult;
|
|
10973
|
-
const fieldNames = convertToArrayPayload(name);
|
|
10974
|
-
_updateIsValidating(true);
|
|
10975
|
-
if (_options.resolver) {
|
|
10976
|
-
const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
|
|
10977
|
-
isValid = isEmptyObject(errors);
|
|
10978
|
-
validationResult = name
|
|
10979
|
-
? !fieldNames.some((name) => get(errors, name))
|
|
10980
|
-
: isValid;
|
|
10981
|
-
}
|
|
10982
|
-
else if (name) {
|
|
10983
|
-
validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
|
|
10984
|
-
const field = get(_fields, fieldName);
|
|
10985
|
-
return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
|
|
10986
|
-
}))).every(Boolean);
|
|
10987
|
-
!(!validationResult && !_formState.isValid) && _updateValid();
|
|
10988
|
-
}
|
|
10989
|
-
else {
|
|
10990
|
-
validationResult = isValid = await executeBuiltInValidation(_fields);
|
|
10991
|
-
}
|
|
10992
|
-
_subjects.state.next({
|
|
10993
|
-
...(!isString(name) ||
|
|
10994
|
-
(_proxyFormState.isValid && isValid !== _formState.isValid)
|
|
10995
|
-
? {}
|
|
10996
|
-
: { name }),
|
|
10997
|
-
...(_options.resolver || !name ? { isValid } : {}),
|
|
10998
|
-
errors: _formState.errors,
|
|
10999
|
-
isValidating: false,
|
|
11000
|
-
});
|
|
11001
|
-
options.shouldFocus &&
|
|
11002
|
-
!validationResult &&
|
|
11003
|
-
focusFieldBy(_fields, (key) => key && get(_formState.errors, key), name ? fieldNames : _names.mount);
|
|
11004
|
-
return validationResult;
|
|
11005
|
-
};
|
|
11006
|
-
const getValues = (fieldNames) => {
|
|
11007
|
-
const values = {
|
|
11008
|
-
..._defaultValues,
|
|
11009
|
-
...(_state.mount ? _formValues : {}),
|
|
11010
|
-
};
|
|
11011
|
-
return isUndefined(fieldNames)
|
|
11012
|
-
? values
|
|
11013
|
-
: isString(fieldNames)
|
|
11014
|
-
? get(values, fieldNames)
|
|
11015
|
-
: fieldNames.map((name) => get(values, name));
|
|
11016
|
-
};
|
|
11017
|
-
const getFieldState = (name, formState) => ({
|
|
11018
|
-
invalid: !!get((formState || _formState).errors, name),
|
|
11019
|
-
isDirty: !!get((formState || _formState).dirtyFields, name),
|
|
11020
|
-
isTouched: !!get((formState || _formState).touchedFields, name),
|
|
11021
|
-
error: get((formState || _formState).errors, name),
|
|
11022
|
-
});
|
|
11023
|
-
const clearErrors = (name) => {
|
|
11024
|
-
name &&
|
|
11025
|
-
convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
|
|
11026
|
-
_subjects.state.next({
|
|
11027
|
-
errors: name ? _formState.errors : {},
|
|
11028
|
-
});
|
|
11029
|
-
};
|
|
11030
|
-
const setError = (name, error, options) => {
|
|
11031
|
-
const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
|
|
11032
|
-
set(_formState.errors, name, {
|
|
11033
|
-
...error,
|
|
11034
|
-
ref,
|
|
11035
|
-
});
|
|
11036
|
-
_subjects.state.next({
|
|
11037
|
-
name,
|
|
11038
|
-
errors: _formState.errors,
|
|
11039
|
-
isValid: false,
|
|
11040
|
-
});
|
|
11041
|
-
options && options.shouldFocus && ref && ref.focus && ref.focus();
|
|
11042
|
-
};
|
|
11043
|
-
const watch = (name, defaultValue) => isFunction$1(name)
|
|
11044
|
-
? _subjects.values.subscribe({
|
|
11045
|
-
next: (payload) => name(_getWatch(undefined, defaultValue), payload),
|
|
11046
|
-
})
|
|
11047
|
-
: _getWatch(name, defaultValue, true);
|
|
11048
|
-
const unregister = (name, options = {}) => {
|
|
11049
|
-
for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {
|
|
11050
|
-
_names.mount.delete(fieldName);
|
|
11051
|
-
_names.array.delete(fieldName);
|
|
11052
|
-
if (!options.keepValue) {
|
|
11053
|
-
unset(_fields, fieldName);
|
|
11054
|
-
unset(_formValues, fieldName);
|
|
11055
|
-
}
|
|
11056
|
-
!options.keepError && unset(_formState.errors, fieldName);
|
|
11057
|
-
!options.keepDirty && unset(_formState.dirtyFields, fieldName);
|
|
11058
|
-
!options.keepTouched && unset(_formState.touchedFields, fieldName);
|
|
11059
|
-
!_options.shouldUnregister &&
|
|
11060
|
-
!options.keepDefaultValue &&
|
|
11061
|
-
unset(_defaultValues, fieldName);
|
|
11062
|
-
}
|
|
11063
|
-
_subjects.values.next({
|
|
11064
|
-
values: { ..._formValues },
|
|
11065
|
-
});
|
|
11066
|
-
_subjects.state.next({
|
|
11067
|
-
..._formState,
|
|
11068
|
-
...(!options.keepDirty ? {} : { isDirty: _getDirty() }),
|
|
11069
|
-
});
|
|
11070
|
-
!options.keepIsValid && _updateValid();
|
|
11071
|
-
};
|
|
11072
|
-
const register = (name, options = {}) => {
|
|
11073
|
-
let field = get(_fields, name);
|
|
11074
|
-
const disabledIsDefined = isBoolean(options.disabled);
|
|
11075
|
-
set(_fields, name, {
|
|
11076
|
-
...(field || {}),
|
|
11077
|
-
_f: {
|
|
11078
|
-
...(field && field._f ? field._f : { ref: { name } }),
|
|
11079
|
-
name,
|
|
11080
|
-
mount: true,
|
|
11081
|
-
...options,
|
|
11082
|
-
},
|
|
11083
|
-
});
|
|
11084
|
-
_names.mount.add(name);
|
|
11085
|
-
field
|
|
11086
|
-
? disabledIsDefined &&
|
|
11087
|
-
set(_formValues, name, options.disabled
|
|
11088
|
-
? undefined
|
|
11089
|
-
: get(_formValues, name, getFieldValue(field._f)))
|
|
11090
|
-
: updateValidAndValue(name, true, options.value);
|
|
11091
|
-
return {
|
|
11092
|
-
...(disabledIsDefined ? { disabled: options.disabled } : {}),
|
|
11093
|
-
...(_options.shouldUseNativeValidation
|
|
11094
|
-
? {
|
|
11095
|
-
required: !!options.required,
|
|
11096
|
-
min: getRuleValue(options.min),
|
|
11097
|
-
max: getRuleValue(options.max),
|
|
11098
|
-
minLength: getRuleValue(options.minLength),
|
|
11099
|
-
maxLength: getRuleValue(options.maxLength),
|
|
11100
|
-
pattern: getRuleValue(options.pattern),
|
|
11101
|
-
}
|
|
11102
|
-
: {}),
|
|
11103
|
-
name,
|
|
11104
|
-
onChange,
|
|
11105
|
-
onBlur: onChange,
|
|
11106
|
-
ref: (ref) => {
|
|
11107
|
-
if (ref) {
|
|
11108
|
-
register(name, options);
|
|
11109
|
-
field = get(_fields, name);
|
|
11110
|
-
const fieldRef = isUndefined(ref.value)
|
|
11111
|
-
? ref.querySelectorAll
|
|
11112
|
-
? ref.querySelectorAll('input,select,textarea')[0] || ref
|
|
11113
|
-
: ref
|
|
11114
|
-
: ref;
|
|
11115
|
-
const radioOrCheckbox = isRadioOrCheckbox(fieldRef);
|
|
11116
|
-
const refs = field._f.refs || [];
|
|
11117
|
-
if (radioOrCheckbox
|
|
11118
|
-
? refs.find((option) => option === fieldRef)
|
|
11119
|
-
: fieldRef === field._f.ref) {
|
|
11120
|
-
return;
|
|
11121
|
-
}
|
|
11122
|
-
set(_fields, name, {
|
|
11123
|
-
_f: {
|
|
11124
|
-
...field._f,
|
|
11125
|
-
...(radioOrCheckbox
|
|
11126
|
-
? {
|
|
11127
|
-
refs: [
|
|
11128
|
-
...refs.filter(live),
|
|
11129
|
-
fieldRef,
|
|
11130
|
-
...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
|
|
11131
|
-
],
|
|
11132
|
-
ref: { type: fieldRef.type, name },
|
|
11133
|
-
}
|
|
11134
|
-
: { ref: fieldRef }),
|
|
11135
|
-
},
|
|
11136
|
-
});
|
|
11137
|
-
updateValidAndValue(name, false, undefined, fieldRef);
|
|
11138
|
-
}
|
|
11139
|
-
else {
|
|
11140
|
-
field = get(_fields, name, {});
|
|
11141
|
-
if (field._f) {
|
|
11142
|
-
field._f.mount = false;
|
|
11143
|
-
}
|
|
11144
|
-
(_options.shouldUnregister || options.shouldUnregister) &&
|
|
11145
|
-
!(isNameInFieldArray(_names.array, name) && _state.action) &&
|
|
11146
|
-
_names.unMount.add(name);
|
|
11147
|
-
}
|
|
11148
|
-
},
|
|
11149
|
-
};
|
|
11150
|
-
};
|
|
11151
|
-
const _focusError = () => _options.shouldFocusError &&
|
|
11152
|
-
focusFieldBy(_fields, (key) => key && get(_formState.errors, key), _names.mount);
|
|
11153
|
-
const handleSubmit = (onValid, onInvalid) => async (e) => {
|
|
11154
|
-
if (e) {
|
|
11155
|
-
e.preventDefault && e.preventDefault();
|
|
11156
|
-
e.persist && e.persist();
|
|
11157
|
-
}
|
|
11158
|
-
let fieldValues = cloneObject(_formValues);
|
|
11159
|
-
_subjects.state.next({
|
|
11160
|
-
isSubmitting: true,
|
|
11161
|
-
});
|
|
11162
|
-
if (_options.resolver) {
|
|
11163
|
-
const { errors, values } = await _executeSchema();
|
|
11164
|
-
_formState.errors = errors;
|
|
11165
|
-
fieldValues = values;
|
|
11166
|
-
}
|
|
11167
|
-
else {
|
|
11168
|
-
await executeBuiltInValidation(_fields);
|
|
11169
|
-
}
|
|
11170
|
-
unset(_formState.errors, 'root');
|
|
11171
|
-
if (isEmptyObject(_formState.errors)) {
|
|
11172
|
-
_subjects.state.next({
|
|
11173
|
-
errors: {},
|
|
11174
|
-
});
|
|
11175
|
-
await onValid(fieldValues, e);
|
|
11176
|
-
}
|
|
11177
|
-
else {
|
|
11178
|
-
if (onInvalid) {
|
|
11179
|
-
await onInvalid({ ..._formState.errors }, e);
|
|
11180
|
-
}
|
|
11181
|
-
_focusError();
|
|
11182
|
-
setTimeout(_focusError);
|
|
11183
|
-
}
|
|
11184
|
-
_subjects.state.next({
|
|
11185
|
-
isSubmitted: true,
|
|
11186
|
-
isSubmitting: false,
|
|
11187
|
-
isSubmitSuccessful: isEmptyObject(_formState.errors),
|
|
11188
|
-
submitCount: _formState.submitCount + 1,
|
|
11189
|
-
errors: _formState.errors,
|
|
11190
|
-
});
|
|
11191
|
-
};
|
|
11192
|
-
const resetField = (name, options = {}) => {
|
|
11193
|
-
if (get(_fields, name)) {
|
|
11194
|
-
if (isUndefined(options.defaultValue)) {
|
|
11195
|
-
setValue(name, get(_defaultValues, name));
|
|
11196
|
-
}
|
|
11197
|
-
else {
|
|
11198
|
-
setValue(name, options.defaultValue);
|
|
11199
|
-
set(_defaultValues, name, options.defaultValue);
|
|
11200
|
-
}
|
|
11201
|
-
if (!options.keepTouched) {
|
|
11202
|
-
unset(_formState.touchedFields, name);
|
|
11203
|
-
}
|
|
11204
|
-
if (!options.keepDirty) {
|
|
11205
|
-
unset(_formState.dirtyFields, name);
|
|
11206
|
-
_formState.isDirty = options.defaultValue
|
|
11207
|
-
? _getDirty(name, get(_defaultValues, name))
|
|
11208
|
-
: _getDirty();
|
|
11209
|
-
}
|
|
11210
|
-
if (!options.keepError) {
|
|
11211
|
-
unset(_formState.errors, name);
|
|
11212
|
-
_proxyFormState.isValid && _updateValid();
|
|
11213
|
-
}
|
|
11214
|
-
_subjects.state.next({ ..._formState });
|
|
11215
|
-
}
|
|
11216
|
-
};
|
|
11217
|
-
const _reset = (formValues, keepStateOptions = {}) => {
|
|
11218
|
-
const updatedValues = formValues || _defaultValues;
|
|
11219
|
-
const cloneUpdatedValues = cloneObject(updatedValues);
|
|
11220
|
-
const values = formValues && !isEmptyObject(formValues)
|
|
11221
|
-
? cloneUpdatedValues
|
|
11222
|
-
: _defaultValues;
|
|
11223
|
-
if (!keepStateOptions.keepDefaultValues) {
|
|
11224
|
-
_defaultValues = updatedValues;
|
|
11225
|
-
}
|
|
11226
|
-
if (!keepStateOptions.keepValues) {
|
|
11227
|
-
if (keepStateOptions.keepDirtyValues || shouldCaptureDirtyFields) {
|
|
11228
|
-
for (const fieldName of _names.mount) {
|
|
11229
|
-
get(_formState.dirtyFields, fieldName)
|
|
11230
|
-
? set(values, fieldName, get(_formValues, fieldName))
|
|
11231
|
-
: setValue(fieldName, get(values, fieldName));
|
|
11232
|
-
}
|
|
11233
|
-
}
|
|
11234
|
-
else {
|
|
11235
|
-
if (isWeb && isUndefined(formValues)) {
|
|
11236
|
-
for (const name of _names.mount) {
|
|
11237
|
-
const field = get(_fields, name);
|
|
11238
|
-
if (field && field._f) {
|
|
11239
|
-
const fieldReference = Array.isArray(field._f.refs)
|
|
11240
|
-
? field._f.refs[0]
|
|
11241
|
-
: field._f.ref;
|
|
11242
|
-
if (isHTMLElement(fieldReference)) {
|
|
11243
|
-
const form = fieldReference.closest('form');
|
|
11244
|
-
if (form) {
|
|
11245
|
-
form.reset();
|
|
11246
|
-
break;
|
|
11247
|
-
}
|
|
11248
|
-
}
|
|
11249
|
-
}
|
|
11250
|
-
}
|
|
11251
|
-
}
|
|
11252
|
-
_fields = {};
|
|
11253
|
-
}
|
|
11254
|
-
_formValues = props.shouldUnregister
|
|
11255
|
-
? keepStateOptions.keepDefaultValues
|
|
11256
|
-
? cloneObject(_defaultValues)
|
|
11257
|
-
: {}
|
|
11258
|
-
: cloneUpdatedValues;
|
|
11259
|
-
_subjects.array.next({
|
|
11260
|
-
values: { ...values },
|
|
11261
|
-
});
|
|
11262
|
-
_subjects.values.next({
|
|
11263
|
-
values: { ...values },
|
|
11264
|
-
});
|
|
11265
|
-
}
|
|
11266
|
-
_names = {
|
|
11267
|
-
mount: new Set(),
|
|
11268
|
-
unMount: new Set(),
|
|
11269
|
-
array: new Set(),
|
|
11270
|
-
watch: new Set(),
|
|
11271
|
-
watchAll: false,
|
|
11272
|
-
focus: '',
|
|
11273
|
-
};
|
|
11274
|
-
!_state.mount && flushRootRender();
|
|
11275
|
-
_state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
|
|
11276
|
-
_state.watch = !!props.shouldUnregister;
|
|
11277
|
-
_subjects.state.next({
|
|
11278
|
-
submitCount: keepStateOptions.keepSubmitCount
|
|
11279
|
-
? _formState.submitCount
|
|
11280
|
-
: 0,
|
|
11281
|
-
isDirty: keepStateOptions.keepDirty
|
|
11282
|
-
? _formState.isDirty
|
|
11283
|
-
: !!(keepStateOptions.keepDefaultValues &&
|
|
11284
|
-
!deepEqual(formValues, _defaultValues)),
|
|
11285
|
-
isSubmitted: keepStateOptions.keepIsSubmitted
|
|
11286
|
-
? _formState.isSubmitted
|
|
11287
|
-
: false,
|
|
11288
|
-
dirtyFields: keepStateOptions.keepDirtyValues
|
|
11289
|
-
? _formState.dirtyFields
|
|
11290
|
-
: keepStateOptions.keepDefaultValues && formValues
|
|
11291
|
-
? getDirtyFields(_defaultValues, formValues)
|
|
11292
|
-
: {},
|
|
11293
|
-
touchedFields: keepStateOptions.keepTouched
|
|
11294
|
-
? _formState.touchedFields
|
|
11295
|
-
: {},
|
|
11296
|
-
errors: keepStateOptions.keepErrors ? _formState.errors : {},
|
|
11297
|
-
isSubmitting: false,
|
|
11298
|
-
isSubmitSuccessful: false,
|
|
11299
|
-
});
|
|
11300
|
-
};
|
|
11301
|
-
const reset = (formValues, keepStateOptions) => _reset(isFunction$1(formValues)
|
|
11302
|
-
? formValues(_formValues)
|
|
11303
|
-
: formValues, keepStateOptions);
|
|
11304
|
-
const setFocus = (name, options = {}) => {
|
|
11305
|
-
const field = get(_fields, name);
|
|
11306
|
-
const fieldReference = field && field._f;
|
|
11307
|
-
if (fieldReference) {
|
|
11308
|
-
const fieldRef = fieldReference.refs
|
|
11309
|
-
? fieldReference.refs[0]
|
|
11310
|
-
: fieldReference.ref;
|
|
11311
|
-
if (fieldRef.focus) {
|
|
11312
|
-
fieldRef.focus();
|
|
11313
|
-
options.shouldSelect && fieldRef.select();
|
|
11314
|
-
}
|
|
11315
|
-
}
|
|
11316
|
-
};
|
|
11317
|
-
const _updateFormState = (updatedFormState) => {
|
|
11318
|
-
_formState = {
|
|
11319
|
-
..._formState,
|
|
11320
|
-
...updatedFormState,
|
|
11321
|
-
};
|
|
11322
|
-
};
|
|
11323
|
-
const _resetDefaultValues = () => isFunction$1(_options.defaultValues) &&
|
|
11324
|
-
_options.defaultValues().then((values) => {
|
|
11325
|
-
reset(values, _options.resetOptions);
|
|
11326
|
-
_subjects.state.next({
|
|
11327
|
-
isLoading: false,
|
|
11328
|
-
});
|
|
11329
|
-
});
|
|
11330
|
-
return {
|
|
11331
|
-
control: {
|
|
11332
|
-
register,
|
|
11333
|
-
unregister,
|
|
11334
|
-
getFieldState,
|
|
11335
|
-
_executeSchema,
|
|
11336
|
-
_getWatch,
|
|
11337
|
-
_getDirty,
|
|
11338
|
-
_updateValid,
|
|
11339
|
-
_removeUnmounted,
|
|
11340
|
-
_updateFieldArray,
|
|
11341
|
-
_getFieldArray,
|
|
11342
|
-
_reset,
|
|
11343
|
-
_resetDefaultValues,
|
|
11344
|
-
_updateFormState,
|
|
11345
|
-
_subjects,
|
|
11346
|
-
_proxyFormState,
|
|
11347
|
-
get _fields() {
|
|
11348
|
-
return _fields;
|
|
11349
|
-
},
|
|
11350
|
-
get _formValues() {
|
|
11351
|
-
return _formValues;
|
|
11352
|
-
},
|
|
11353
|
-
get _state() {
|
|
11354
|
-
return _state;
|
|
11355
|
-
},
|
|
11356
|
-
set _state(value) {
|
|
11357
|
-
_state = value;
|
|
11358
|
-
},
|
|
11359
|
-
get _defaultValues() {
|
|
11360
|
-
return _defaultValues;
|
|
11361
|
-
},
|
|
11362
|
-
get _names() {
|
|
11363
|
-
return _names;
|
|
11364
|
-
},
|
|
11365
|
-
set _names(value) {
|
|
11366
|
-
_names = value;
|
|
11367
|
-
},
|
|
11368
|
-
get _formState() {
|
|
11369
|
-
return _formState;
|
|
11370
|
-
},
|
|
11371
|
-
set _formState(value) {
|
|
11372
|
-
_formState = value;
|
|
11373
|
-
},
|
|
11374
|
-
get _options() {
|
|
11375
|
-
return _options;
|
|
11376
|
-
},
|
|
11377
|
-
set _options(value) {
|
|
11378
|
-
_options = {
|
|
11379
|
-
..._options,
|
|
11380
|
-
...value,
|
|
11381
|
-
};
|
|
11382
|
-
},
|
|
11383
|
-
},
|
|
11384
|
-
trigger,
|
|
11385
|
-
register,
|
|
11386
|
-
handleSubmit,
|
|
11387
|
-
watch,
|
|
11388
|
-
setValue,
|
|
11389
|
-
getValues,
|
|
11390
|
-
reset,
|
|
11391
|
-
resetField,
|
|
11392
|
-
clearErrors,
|
|
11393
|
-
unregister,
|
|
11394
|
-
setError,
|
|
11395
|
-
setFocus,
|
|
11396
|
-
getFieldState,
|
|
11397
|
-
};
|
|
11398
|
-
}
|
|
11399
|
-
|
|
11400
|
-
/**
|
|
11401
|
-
* Custom hook to manage the entire form.
|
|
11402
|
-
*
|
|
11403
|
-
* @remarks
|
|
11404
|
-
* [API](https://react-hook-form.com/api/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)
|
|
11405
|
-
*
|
|
11406
|
-
* @param props - form configuration and validation parameters.
|
|
11407
|
-
*
|
|
11408
|
-
* @returns methods - individual functions to manage the form state. {@link UseFormReturn}
|
|
11409
|
-
*
|
|
11410
|
-
* @example
|
|
11411
|
-
* ```tsx
|
|
11412
|
-
* function App() {
|
|
11413
|
-
* const { register, handleSubmit, watch, formState: { errors } } = useForm();
|
|
11414
|
-
* const onSubmit = data => console.log(data);
|
|
11415
|
-
*
|
|
11416
|
-
* console.log(watch("example"));
|
|
11417
|
-
*
|
|
11418
|
-
* return (
|
|
11419
|
-
* <form onSubmit={handleSubmit(onSubmit)}>
|
|
11420
|
-
* <input defaultValue="test" {...register("example")} />
|
|
11421
|
-
* <input {...register("exampleRequired", { required: true })} />
|
|
11422
|
-
* {errors.exampleRequired && <span>This field is required</span>}
|
|
11423
|
-
* <input type="submit" />
|
|
11424
|
-
* </form>
|
|
11425
|
-
* );
|
|
11426
|
-
* }
|
|
11427
|
-
* ```
|
|
11428
|
-
*/
|
|
11429
|
-
function useForm(props = {}) {
|
|
11430
|
-
const _formControl = React__default.useRef();
|
|
11431
|
-
const [formState, updateFormState] = React__default.useState({
|
|
11432
|
-
isDirty: false,
|
|
11433
|
-
isValidating: false,
|
|
11434
|
-
isLoading: isFunction$1(props.defaultValues),
|
|
11435
|
-
isSubmitted: false,
|
|
11436
|
-
isSubmitting: false,
|
|
11437
|
-
isSubmitSuccessful: false,
|
|
11438
|
-
isValid: false,
|
|
11439
|
-
submitCount: 0,
|
|
11440
|
-
dirtyFields: {},
|
|
11441
|
-
touchedFields: {},
|
|
11442
|
-
errors: {},
|
|
11443
|
-
defaultValues: isFunction$1(props.defaultValues)
|
|
11444
|
-
? undefined
|
|
11445
|
-
: props.defaultValues,
|
|
11446
|
-
});
|
|
11447
|
-
if (!_formControl.current) {
|
|
11448
|
-
_formControl.current = {
|
|
11449
|
-
...createFormControl(props, () => updateFormState((formState) => ({ ...formState }))),
|
|
11450
|
-
formState,
|
|
11451
|
-
};
|
|
11452
|
-
}
|
|
11453
|
-
const control = _formControl.current.control;
|
|
11454
|
-
control._options = props;
|
|
11455
|
-
useSubscribe({
|
|
11456
|
-
subject: control._subjects.state,
|
|
11457
|
-
next: (value) => {
|
|
11458
|
-
if (shouldRenderFormState(value, control._proxyFormState, control._updateFormState, true)) {
|
|
11459
|
-
updateFormState({ ...control._formState });
|
|
11460
|
-
}
|
|
11461
|
-
},
|
|
11462
|
-
});
|
|
11463
|
-
React__default.useEffect(() => {
|
|
11464
|
-
if (props.values && !deepEqual(props.values, control._defaultValues)) {
|
|
11465
|
-
control._reset(props.values, control._options.resetOptions);
|
|
11466
|
-
}
|
|
11467
|
-
else {
|
|
11468
|
-
control._resetDefaultValues();
|
|
11469
|
-
}
|
|
11470
|
-
}, [props.values, control]);
|
|
11471
|
-
React__default.useEffect(() => {
|
|
11472
|
-
if (!control._state.mount) {
|
|
11473
|
-
control._updateValid();
|
|
11474
|
-
control._state.mount = true;
|
|
11475
|
-
}
|
|
11476
|
-
if (control._state.watch) {
|
|
11477
|
-
control._state.watch = false;
|
|
11478
|
-
control._subjects.state.next({ ...control._formState });
|
|
11479
|
-
}
|
|
11480
|
-
control._removeUnmounted();
|
|
11481
|
-
});
|
|
11482
|
-
_formControl.current.formState = getProxyFormState(formState, control);
|
|
11483
|
-
return _formControl.current;
|
|
11484
|
-
}
|
|
11485
|
-
|
|
11486
9778
|
/******************************************************************************
|
|
11487
9779
|
Copyright (c) Microsoft Corporation.
|
|
11488
9780
|
|
|
@@ -18790,7 +17082,7 @@ const UpdateSettingConfig = (obj, file, callback) => {
|
|
|
18790
17082
|
formData.append(`Items[${index}].SortOrder`, item.SortOrder ?? 1);
|
|
18791
17083
|
});
|
|
18792
17084
|
if (file) {
|
|
18793
|
-
formData.append("
|
|
17085
|
+
formData.append("File", file);
|
|
18794
17086
|
}
|
|
18795
17087
|
const options = {
|
|
18796
17088
|
method: 'POST',
|