@esvndev/es-react-config-setting 1.0.81 → 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 CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
+ var reactHookForm = require('react-hook-form');
7
8
  var reactI18next = require('react-i18next');
8
9
  var ReactDOM = require('react-dom');
9
10
 
@@ -87,7 +88,7 @@ function getValue(nameSpace, obj) {
87
88
  // eslint-disable-next-line
88
89
  var value = obj;
89
90
  var splits = nameSpace.replace(/\[/g, '.').replace(/\]/g, '').split('.');
90
- for (var i = 0; i < splits.length && !isUndefined$1(value); i++) {
91
+ for (var i = 0; i < splits.length && !isUndefined(value); i++) {
91
92
  value = value[splits[i]];
92
93
  }
93
94
  return value;
@@ -116,7 +117,7 @@ function setValue(nameSpace, value, obj) {
116
117
  if (i + 1 === length) {
117
118
  fromObj[key] = value === undefined ? {} : value;
118
119
  }
119
- else if (isNullOrUndefined$1(fromObj[key])) {
120
+ else if (isNullOrUndefined(fromObj[key])) {
120
121
  fromObj[key] = {};
121
122
  }
122
123
  fromObj = fromObj[key];
@@ -147,9 +148,9 @@ var containerObject = typeof window !== "undefined" ? window : {};
147
148
  * @private
148
149
  */
149
150
  // eslint-disable-next-line
150
- function isObject$2(obj) {
151
+ function isObject$1(obj) {
151
152
  var objCon = {};
152
- return (!isNullOrUndefined$1(obj) && obj.constructor === objCon.constructor);
153
+ return (!isNullOrUndefined(obj) && obj.constructor === objCon.constructor);
153
154
  }
154
155
  /**
155
156
  * Merge the source object into destination object.
@@ -160,15 +161,15 @@ function isObject$2(obj) {
160
161
  * @private
161
162
  */
162
163
  function merge(source, destination) {
163
- if (!isNullOrUndefined$1(destination)) {
164
+ if (!isNullOrUndefined(destination)) {
164
165
  var temrObj = source;
165
166
  var tempProp = destination;
166
167
  var keys = Object.keys(destination);
167
168
  var deepmerge = 'deepMerge';
168
169
  for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
169
170
  var key = keys_1[_i];
170
- if (!isNullOrUndefined$1(temrObj[deepmerge]) && (temrObj[deepmerge].indexOf(key) !== -1) &&
171
- (isObject$2(tempProp[key]) || Array.isArray(tempProp[key]))) {
171
+ if (!isNullOrUndefined(temrObj[deepmerge]) && (temrObj[deepmerge].indexOf(key) !== -1) &&
172
+ (isObject$1(tempProp[key]) || Array.isArray(tempProp[key]))) {
172
173
  extend(temrObj[key], temrObj[key], tempProp[key], true);
173
174
  }
174
175
  else {
@@ -207,8 +208,8 @@ function extend(copied, first, second, deep) {
207
208
  Array.isArray(copy) && Array.isArray(src) && (copy.length !== src.length);
208
209
  // eslint-disable-next-line
209
210
  var blazorEventExtend = true;
210
- if (deep && blazorEventExtend && (isObject$2(copy) || Array.isArray(copy))) {
211
- if (isObject$2(copy)) {
211
+ if (deep && blazorEventExtend && (isObject$1(copy) || Array.isArray(copy))) {
212
+ if (isObject$1(copy)) {
212
213
  clone = src ? src : {};
213
214
  // eslint-disable-next-line
214
215
  if (Array.isArray(clone) && clone.hasOwnProperty('isComplexArray')) {
@@ -242,7 +243,7 @@ function extend(copied, first, second, deep) {
242
243
  * @returns {boolean} ?
243
244
  * @private
244
245
  */
245
- function isNullOrUndefined$1(value) {
246
+ function isNullOrUndefined(value) {
246
247
  return value === undefined || value === null;
247
248
  }
248
249
  /**
@@ -252,7 +253,7 @@ function isNullOrUndefined$1(value) {
252
253
  * @returns {boolean} ?
253
254
  * @private
254
255
  */
255
- function isUndefined$1(value) {
256
+ function isUndefined(value) {
256
257
  return ('undefined' === typeof value);
257
258
  }
258
259
  /**
@@ -504,9 +505,9 @@ var ParserBase = /** @class */ (function () {
504
505
  ParserBase.getCurrentNumericOptions = function (curObj, numberSystem, needSymbols, blazorMode) {
505
506
  var ret = {};
506
507
  var cur = this.getDefaultNumberingSystem(curObj);
507
- if (!isUndefined$1(cur.nSystem) || blazorMode) {
508
+ if (!isUndefined(cur.nSystem) || blazorMode) {
508
509
  var digits = blazorMode ? getValue('obj.mapperDigits', cur) : getValue(cur.nSystem + '._digits', numberSystem);
509
- if (!isUndefined$1(digits)) {
510
+ if (!isUndefined(digits)) {
510
511
  ret.numericPair = this.reverseObject(digits, latnNumberSystem);
511
512
  ret.numberParseRegex = new RegExp(this.constructRegex(digits), 'g');
512
513
  ret.numericRegex = '[' + digits[0] + '-' + digits[9] + ']';
@@ -532,12 +533,12 @@ var ParserBase = /** @class */ (function () {
532
533
  ParserBase.getNumberMapper = function (curObj, numberSystem, isNumber) {
533
534
  var ret = { mapper: {} };
534
535
  var cur = this.getDefaultNumberingSystem(curObj);
535
- if (!isUndefined$1(cur.nSystem)) {
536
+ if (!isUndefined(cur.nSystem)) {
536
537
  ret.numberSystem = cur.nSystem;
537
538
  ret.numberSymbols = getValue('symbols-numberSystem-' + cur.nSystem, cur.obj);
538
539
  ret.timeSeparator = getValue('timeSeparator', ret.numberSymbols);
539
540
  var digits = getValue(cur.nSystem + '._digits', numberSystem);
540
- if (!isUndefined$1(digits)) {
541
+ if (!isUndefined(digits)) {
541
542
  for (var _i = 0, latnNumberSystem_1 = latnNumberSystem; _i < latnNumberSystem_1.length; _i++) {
542
543
  var i = latnNumberSystem_1[_i];
543
544
  // eslint-disable-next-line
@@ -963,7 +964,7 @@ var DateFormat = /** @class */ (function () {
963
964
  var resPattern = option.format ||
964
965
  IntlBase.getResultantPattern(option.skeleton, dependable.dateObject, option.type, false, '');
965
966
  formatOptions.dateSeperator = IntlBase.getDateSeparator(dependable.dateObject);
966
- if (isUndefined$1(resPattern)) {
967
+ if (isUndefined(resPattern)) {
967
968
  throwError('Format options or type given must be invalid');
968
969
  }
969
970
  else {
@@ -1108,7 +1109,7 @@ var DateFormat = /** @class */ (function () {
1108
1109
  var dec = value.getFullYear() < 0 ? 0 : 1;
1109
1110
  // eslint-disable-next-line
1110
1111
  var retu = options.era[dec];
1111
- if (isNullOrUndefined$1(retu)) {
1112
+ if (isNullOrUndefined(retu)) {
1112
1113
  // eslint-disable-next-line
1113
1114
  retu = options.era[dec ? 0 : 1];
1114
1115
  }
@@ -1249,10 +1250,10 @@ var NumberFormat = /** @class */ (function () {
1249
1250
  }
1250
1251
  fOptions.groupOne = this.checkValueRange(fOptions.maximumSignificantDigits, fOptions.minimumSignificantDigits, true);
1251
1252
  this.checkValueRange(fOptions.maximumFractionDigits, fOptions.minimumFractionDigits, false, true);
1252
- if (!isUndefined$1(fOptions.fractionDigits)) {
1253
+ if (!isUndefined(fOptions.fractionDigits)) {
1253
1254
  fOptions.minimumFractionDigits = fOptions.maximumFractionDigits = fOptions.fractionDigits;
1254
1255
  }
1255
- if (isUndefined$1(fOptions.useGrouping)) {
1256
+ if (isUndefined(fOptions.useGrouping)) {
1256
1257
  fOptions.useGrouping = true;
1257
1258
  }
1258
1259
  if (fOptions.isCurrency && !isBlazor()) {
@@ -1267,17 +1268,17 @@ var NumberFormat = /** @class */ (function () {
1267
1268
  fOptions.groupData = this.getGroupingDetails(split[0]);
1268
1269
  }
1269
1270
  }
1270
- var minFrac = isUndefined$1(fOptions.minimumFractionDigits);
1271
+ var minFrac = isUndefined(fOptions.minimumFractionDigits);
1271
1272
  if (minFrac) {
1272
1273
  fOptions.minimumFractionDigits = cOptions.nData.minimumFraction;
1273
1274
  }
1274
- if (isUndefined$1(fOptions.maximumFractionDigits)) {
1275
+ if (isUndefined(fOptions.maximumFractionDigits)) {
1275
1276
  var mval = cOptions.nData.maximumFraction;
1276
- fOptions.maximumFractionDigits = isUndefined$1(mval) && fOptions.isPercent ? 0 : mval;
1277
+ fOptions.maximumFractionDigits = isUndefined(mval) && fOptions.isPercent ? 0 : mval;
1277
1278
  }
1278
1279
  var mfrac = fOptions.minimumFractionDigits;
1279
1280
  var lfrac = fOptions.maximumFractionDigits;
1280
- if (!isUndefined$1(mfrac) && !isUndefined$1(lfrac)) {
1281
+ if (!isUndefined(mfrac) && !isUndefined(lfrac)) {
1281
1282
  if (mfrac > lfrac) {
1282
1283
  fOptions.maximumFractionDigits = mfrac;
1283
1284
  }
@@ -1333,11 +1334,11 @@ var NumberFormat = /** @class */ (function () {
1333
1334
  var str1 = errorText['l' + decide];
1334
1335
  // eslint-disable-next-line
1335
1336
  var str2 = errorText['m' + decide];
1336
- if (!isUndefined$1(val1)) {
1337
+ if (!isUndefined(val1)) {
1337
1338
  this.checkRange(val1, str1, isFraction);
1338
1339
  dint++;
1339
1340
  }
1340
- if (!isUndefined$1(val2)) {
1341
+ if (!isUndefined(val2)) {
1341
1342
  this.checkRange(val2, str2, isFraction);
1342
1343
  dint++;
1343
1344
  }
@@ -1378,7 +1379,7 @@ var NumberFormat = /** @class */ (function () {
1378
1379
  */
1379
1380
  NumberFormat.intNumberFormatter = function (value, fOptions, dOptions) {
1380
1381
  var curData;
1381
- if (isUndefined$1(fOptions.nData.type)) {
1382
+ if (isUndefined(fOptions.nData.type)) {
1382
1383
  return undefined;
1383
1384
  }
1384
1385
  else {
@@ -1455,7 +1456,7 @@ var NumberFormat = /** @class */ (function () {
1455
1456
  * @returns {string} ?
1456
1457
  */
1457
1458
  NumberFormat.groupNumbers = function (val, level1, sep, decimalSymbol, level2) {
1458
- var flag = !isNullOrUndefined$1(level2) && level2 !== 0;
1459
+ var flag = !isNullOrUndefined(level2) && level2 !== 0;
1459
1460
  var split = val.split(decimalSymbol);
1460
1461
  var prefix = split[0];
1461
1462
  var length = prefix.length;
@@ -1497,7 +1498,7 @@ var NumberFormat = /** @class */ (function () {
1497
1498
  }
1498
1499
  return value.toFixed(min);
1499
1500
  }
1500
- else if (!isNullOrUndefined$1(max) && (length > max || max === 0)) {
1501
+ else if (!isNullOrUndefined(max) && (length > max || max === 0)) {
1501
1502
  return value.toFixed(max);
1502
1503
  }
1503
1504
  return value + '';
@@ -1528,7 +1529,7 @@ var Observer = /** @class */ (function () {
1528
1529
  function Observer(context) {
1529
1530
  this.ranArray = [];
1530
1531
  this.boundedEvents = {};
1531
- if (isNullOrUndefined$1(context)) {
1532
+ if (isNullOrUndefined(context)) {
1532
1533
  return;
1533
1534
  }
1534
1535
  this.context = context;
@@ -1543,7 +1544,7 @@ var Observer = /** @class */ (function () {
1543
1544
  * @returns {void}
1544
1545
  */
1545
1546
  Observer.prototype.on = function (property, handler, context, id) {
1546
- if (isNullOrUndefined$1(handler)) {
1547
+ if (isNullOrUndefined(handler)) {
1547
1548
  return;
1548
1549
  }
1549
1550
  var cntxt = context || this.context;
@@ -1551,7 +1552,7 @@ var Observer = /** @class */ (function () {
1551
1552
  this.boundedEvents[property] = [{ handler: handler, context: cntxt }];
1552
1553
  return;
1553
1554
  }
1554
- if (!isNullOrUndefined$1(id)) {
1555
+ if (!isNullOrUndefined(id)) {
1555
1556
  if (this.ranArray.indexOf(id) === -1) {
1556
1557
  this.ranArray.push(id);
1557
1558
  this.boundedEvents[property].push({ handler: handler, context: cntxt, id: id });
@@ -2414,7 +2415,7 @@ var IntlBase;
2414
2415
  else {
2415
2416
  resPattern = getValue('dateTimeFormats.availableFormats.' + skeleton, dateObject);
2416
2417
  }
2417
- if (isUndefined$1(resPattern) && skeleton === 'yMd') {
2418
+ if (isUndefined(resPattern) && skeleton === 'yMd') {
2418
2419
  resPattern = 'M/d/y';
2419
2420
  }
2420
2421
  }
@@ -2536,7 +2537,7 @@ var IntlBase;
2536
2537
  var fraction = match[7];
2537
2538
  if (fraction && needFraction) {
2538
2539
  var fmatch = fraction.match(fractionRegex);
2539
- if (!isNullOrUndefined$1(fmatch)) {
2540
+ if (!isNullOrUndefined(fmatch)) {
2540
2541
  nData.minimumFraction = fmatch.length;
2541
2542
  }
2542
2543
  else {
@@ -2596,9 +2597,9 @@ var IntlBase;
2596
2597
  // eslint-disable-next-line
2597
2598
  options[data[i]] = customNumberFormat(formatSplit[i], dOptions, obj);
2598
2599
  }
2599
- if (isNullOrUndefined$1(options.nData)) {
2600
+ if (isNullOrUndefined(options.nData)) {
2600
2601
  options.nData = extend({}, options.pData);
2601
- options.nData.nlead = isNullOrUndefined$1(dOptions) ? '-' + options.nData.nlead : dOptions.minusSymbol + options.nData.nlead;
2602
+ options.nData.nlead = isNullOrUndefined(dOptions) ? '-' + options.nData.nlead : dOptions.minusSymbol + options.nData.nlead;
2602
2603
  }
2603
2604
  return options;
2604
2605
  }
@@ -2615,7 +2616,7 @@ var IntlBase;
2615
2616
  function customNumberFormat(format, dOptions, numObject) {
2616
2617
  var cOptions = { type: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 0 };
2617
2618
  var pattern = format.match(IntlBase.customRegex);
2618
- if (isNullOrUndefined$1(pattern) || (pattern[5] === '' && format !== 'N/A')) {
2619
+ if (isNullOrUndefined(pattern) || (pattern[5] === '' && format !== 'N/A')) {
2619
2620
  cOptions.type = undefined;
2620
2621
  return cOptions;
2621
2622
  }
@@ -2630,7 +2631,7 @@ var IntlBase;
2630
2631
  if (integerPart.indexOf('0') !== -1) {
2631
2632
  cOptions.minimumIntegerDigits = integerPart.length - integerPart.indexOf('0');
2632
2633
  }
2633
- if (!isNullOrUndefined$1(fractionPart)) {
2634
+ if (!isNullOrUndefined(fractionPart)) {
2634
2635
  cOptions.minimumFractionDigits = fractionPart.lastIndexOf('0');
2635
2636
  cOptions.maximumFractionDigits = fractionPart.lastIndexOf('#');
2636
2637
  if (cOptions.minimumFractionDigits === -1) {
@@ -2640,7 +2641,7 @@ var IntlBase;
2640
2641
  cOptions.maximumFractionDigits = cOptions.minimumFractionDigits;
2641
2642
  }
2642
2643
  }
2643
- if (!isNullOrUndefined$1(dOptions)) {
2644
+ if (!isNullOrUndefined(dOptions)) {
2644
2645
  extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '$', dOptions.currencySymbol));
2645
2646
  if (!cOptions.isCurrency) {
2646
2647
  extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '%', dOptions.percentSymbol));
@@ -2649,7 +2650,7 @@ var IntlBase;
2649
2650
  else {
2650
2651
  extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '%', '%'));
2651
2652
  }
2652
- if (!isNullOrUndefined$1(numObject)) {
2653
+ if (!isNullOrUndefined(numObject)) {
2653
2654
  var symbolPattern = getSymbolPattern(cOptions.type, dOptions.numberMapper.numberSystem, numObject, false);
2654
2655
  if (cOptions.useGrouping) {
2655
2656
  // eslint-disable-next-line
@@ -3114,7 +3115,7 @@ var Browser = /** @class */ (function () {
3114
3115
  * @returns {BrowserInfo} ?
3115
3116
  */
3116
3117
  get: function () {
3117
- if (isUndefined$1(window.browserDetails.info)) {
3118
+ if (isUndefined(window.browserDetails.info)) {
3118
3119
  return window.browserDetails.info = Browser.extractBrowserDetail();
3119
3120
  }
3120
3121
  return window.browserDetails.info;
@@ -3141,7 +3142,7 @@ var Browser = /** @class */ (function () {
3141
3142
  * @returns {boolean} ?
3142
3143
  */
3143
3144
  get: function () {
3144
- if (isUndefined$1(window.browserDetails.isTouch)) {
3145
+ if (isUndefined(window.browserDetails.isTouch)) {
3145
3146
  return (window.browserDetails.isTouch =
3146
3147
  ('ontouchstart' in window.navigator) ||
3147
3148
  (window &&
@@ -3160,7 +3161,7 @@ var Browser = /** @class */ (function () {
3160
3161
  * @returns {boolean} ?
3161
3162
  */
3162
3163
  get: function () {
3163
- if (isUndefined$1(window.browserDetails.isPointer)) {
3164
+ if (isUndefined(window.browserDetails.isPointer)) {
3164
3165
  return window.browserDetails.isPointer = ('pointerEnabled' in window.navigator);
3165
3166
  }
3166
3167
  return window.browserDetails.isPointer;
@@ -3175,7 +3176,7 @@ var Browser = /** @class */ (function () {
3175
3176
  * @returns {boolean} ?
3176
3177
  */
3177
3178
  get: function () {
3178
- if (isUndefined$1(window.browserDetails.isMSPointer)) {
3179
+ if (isUndefined(window.browserDetails.isMSPointer)) {
3179
3180
  return window.browserDetails.isMSPointer = ('msPointerEnabled' in window.navigator);
3180
3181
  }
3181
3182
  return window.browserDetails.isMSPointer;
@@ -3238,9 +3239,9 @@ var Browser = /** @class */ (function () {
3238
3239
  * @returns {boolean} ?
3239
3240
  */
3240
3241
  get: function () {
3241
- if (isUndefined$1(window.browserDetails.isWebView)) {
3242
- window.browserDetails.isWebView = !(isUndefined$1(window.cordova) && isUndefined$1(window.PhoneGap)
3243
- && isUndefined$1(window.phonegap) && window.forge !== 'object');
3242
+ if (isUndefined(window.browserDetails.isWebView)) {
3243
+ window.browserDetails.isWebView = !(isUndefined(window.cordova) && isUndefined(window.PhoneGap)
3244
+ && isUndefined(window.phonegap) && window.forge !== 'object');
3244
3245
  return window.browserDetails.isWebView;
3245
3246
  }
3246
3247
  return window.browserDetails.isWebView;
@@ -3267,7 +3268,7 @@ var Browser = /** @class */ (function () {
3267
3268
  * @returns {string} ?
3268
3269
  */
3269
3270
  get: function () {
3270
- if (isUndefined$1(window.browserDetails.touchStartEvent)) {
3271
+ if (isUndefined(window.browserDetails.touchStartEvent)) {
3271
3272
  return window.browserDetails.touchStartEvent = Browser.getTouchStartEvent();
3272
3273
  }
3273
3274
  return window.browserDetails.touchStartEvent;
@@ -3282,7 +3283,7 @@ var Browser = /** @class */ (function () {
3282
3283
  * @returns {string} ?
3283
3284
  */
3284
3285
  get: function () {
3285
- if (isUndefined$1(window.browserDetails.touchMoveEvent)) {
3286
+ if (isUndefined(window.browserDetails.touchMoveEvent)) {
3286
3287
  return window.browserDetails.touchMoveEvent = Browser.getTouchMoveEvent();
3287
3288
  }
3288
3289
  return window.browserDetails.touchMoveEvent;
@@ -3297,7 +3298,7 @@ var Browser = /** @class */ (function () {
3297
3298
  * @returns {string} ?
3298
3299
  */
3299
3300
  get: function () {
3300
- if (isUndefined$1(window.browserDetails.touchEndEvent)) {
3301
+ if (isUndefined(window.browserDetails.touchEndEvent)) {
3301
3302
  return window.browserDetails.touchEndEvent = Browser.getTouchEndEvent();
3302
3303
  }
3303
3304
  return window.browserDetails.touchEndEvent;
@@ -3312,7 +3313,7 @@ var Browser = /** @class */ (function () {
3312
3313
  * @returns {string} ?
3313
3314
  */
3314
3315
  get: function () {
3315
- if (isUndefined$1(window.browserDetails.touchCancelEvent)) {
3316
+ if (isUndefined(window.browserDetails.touchCancelEvent)) {
3316
3317
  return window.browserDetails.touchCancelEvent = Browser.getTouchCancelEvent();
3317
3318
  }
3318
3319
  return window.browserDetails.touchCancelEvent;
@@ -3516,9 +3517,9 @@ function addClass(elements, classes) {
3516
3517
  var ele = _a[_i];
3517
3518
  for (var _b = 0, classList_1 = classList; _b < classList_1.length; _b++) {
3518
3519
  var className = classList_1[_b];
3519
- if (isObject$2(ele)) {
3520
+ if (isObject$1(ele)) {
3520
3521
  var curClass = getValue('attributes.className', ele);
3521
- if (isNullOrUndefined$1(curClass)) {
3522
+ if (isNullOrUndefined(curClass)) {
3522
3523
  setValue('attributes.className', className, ele);
3523
3524
  }
3524
3525
  else if (!new RegExp('\\b' + className + '\\b', 'i').test(curClass)) {
@@ -3546,7 +3547,7 @@ function removeClass(elements, classes) {
3546
3547
  var classList = getClassList(classes);
3547
3548
  for (var _i = 0, _a = elements; _i < _a.length; _i++) {
3548
3549
  var ele = _a[_i];
3549
- var flag = isObject$2(ele);
3550
+ var flag = isObject$1(ele);
3550
3551
  var canRemove = flag ? getValue('attributes.className', ele) : ele.className !== '';
3551
3552
  if (canRemove) {
3552
3553
  for (var _b = 0, classList_2 = classList; _b < classList_2.length; _b++) {
@@ -3610,7 +3611,7 @@ function attributes(element, attributes) {
3610
3611
  var ele = element;
3611
3612
  for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
3612
3613
  var key = keys_1[_i];
3613
- if (isObject$2(ele)) {
3614
+ if (isObject$1(ele)) {
3614
3615
  var iKey = key;
3615
3616
  if (key === 'tabindex') {
3616
3617
  iKey = 'tabIndex';
@@ -3771,19 +3772,19 @@ var Base = /** @class */ (function () {
3771
3772
  this.finalUpdate = function () { };
3772
3773
  this.childChangedProperties = {};
3773
3774
  this.modelObserver = new Observer(this);
3774
- if (!isUndefined$1(element)) {
3775
+ if (!isUndefined(element)) {
3775
3776
  if ('string' === typeof (element)) {
3776
3777
  this.element = document.querySelector(element);
3777
3778
  }
3778
3779
  else {
3779
3780
  this.element = element;
3780
3781
  }
3781
- if (!isNullOrUndefined$1(this.element)) {
3782
+ if (!isNullOrUndefined(this.element)) {
3782
3783
  this.isProtectedOnChange = false;
3783
3784
  this.addInstance();
3784
3785
  }
3785
3786
  }
3786
- if (!isUndefined$1(options)) {
3787
+ if (!isUndefined(options)) {
3787
3788
  this.setProperties(options, true);
3788
3789
  }
3789
3790
  this.isDestroyed = false;
@@ -3965,7 +3966,7 @@ var Base = /** @class */ (function () {
3965
3966
  // Add module class to the root element
3966
3967
  var moduleClass = 'e-' + this.getModuleName().toLowerCase();
3967
3968
  addClass([this.element], ['e-lib', moduleClass]);
3968
- if (!isNullOrUndefined$1(this.element.ej2_instances)) {
3969
+ if (!isNullOrUndefined(this.element.ej2_instances)) {
3969
3970
  this.element.ej2_instances.push(this);
3970
3971
  }
3971
3972
  else {
@@ -4137,7 +4138,7 @@ function Event() {
4137
4138
  var oldValue = this.properties[key];
4138
4139
  if (oldValue !== newValue) {
4139
4140
  var finalContext = getParentContext(this, key);
4140
- if (isUndefined$1(oldValue) === false) {
4141
+ if (isUndefined(oldValue) === false) {
4141
4142
  finalContext.context.removeEventListener(finalContext.prefix, oldValue);
4142
4143
  }
4143
4144
  finalContext.context.addEventListener(finalContext.prefix, newValue);
@@ -4191,7 +4192,7 @@ function NotifyPropertyChanges(classConstructor) {
4191
4192
  * @private
4192
4193
  */
4193
4194
  function addPropertyCollection(target, key, propertyType, defaultValue, type) {
4194
- if (isUndefined$1(target.propList)) {
4195
+ if (isUndefined(target.propList)) {
4195
4196
  target.propList = {
4196
4197
  props: [],
4197
4198
  complexProps: [],
@@ -4849,7 +4850,7 @@ var LicenseValidator = /** @class */ (function () {
4849
4850
  else {
4850
4851
  validateMsg = this.errors.noLicense;
4851
4852
  }
4852
- if (validateMsg && typeof document !== 'undefined' && !isNullOrUndefined$1(document)) {
4853
+ if (validateMsg && typeof document !== 'undefined' && !isNullOrUndefined(document)) {
4853
4854
  var errorDiv = createElement('div', {
4854
4855
  innerHTML: validateMsg +
4855
4856
  '<span id="license-banner-error" class=".e-license-banner">' +
@@ -5023,10 +5024,10 @@ var lastHistoryLen = 0;
5023
5024
  _this.isStringTemplate = false;
5024
5025
  _this.needsID = false;
5025
5026
  _this.isReactHybrid = false;
5026
- if (isNullOrUndefined$1(_this.enableRtl)) {
5027
+ if (isNullOrUndefined(_this.enableRtl)) {
5027
5028
  _this.setProperties({ 'enableRtl': rightToLeft }, true);
5028
5029
  }
5029
- if (isNullOrUndefined$1(_this.locale)) {
5030
+ if (isNullOrUndefined(_this.locale)) {
5030
5031
  _this.setProperties({ 'locale': defaultCulture }, true);
5031
5032
  }
5032
5033
  _this.moduleLoader = new ModuleLoader(_this);
@@ -5034,7 +5035,7 @@ var lastHistoryLen = 0;
5034
5035
  // tslint:disable-next-line:no-function-constructor-with-string-args
5035
5036
  onIntlChange.on('notifyExternalChange', _this.detectFunction, _this, _this.randomId);
5036
5037
  validateLicense();
5037
- if (!isUndefined$1(selector)) {
5038
+ if (!isUndefined(selector)) {
5038
5039
  _this.appendTo();
5039
5040
  }
5040
5041
  return _this;
@@ -5118,13 +5119,13 @@ var lastHistoryLen = 0;
5118
5119
  * @returns {void} ?
5119
5120
  */
5120
5121
  Component.prototype.appendTo = function (selector) {
5121
- if (!isNullOrUndefined$1(selector) && typeof (selector) === 'string') {
5122
+ if (!isNullOrUndefined(selector) && typeof (selector) === 'string') {
5122
5123
  this.element = select(selector, document);
5123
5124
  }
5124
- else if (!isNullOrUndefined$1(selector)) {
5125
+ else if (!isNullOrUndefined(selector)) {
5125
5126
  this.element = selector;
5126
5127
  }
5127
- if (!isNullOrUndefined$1(this.element)) {
5128
+ if (!isNullOrUndefined(this.element)) {
5128
5129
  var moduleClass = 'e-' + this.getModuleName().toLowerCase();
5129
5130
  addClass([this.element], ['e-control', moduleClass]);
5130
5131
  this.isProtectedOnChange = false;
@@ -5295,7 +5296,7 @@ var lastHistoryLen = 0;
5295
5296
  {
5296
5297
  data = window.localStorage.getItem(this.getModuleName() + this.element.id);
5297
5298
  }
5298
- if (!(isNullOrUndefined$1(data) || (data === ''))) {
5299
+ if (!(isNullOrUndefined(data) || (data === ''))) {
5299
5300
  this.setProperties(JSON.parse(data), true);
5300
5301
  }
5301
5302
  };
@@ -5345,7 +5346,7 @@ var lastHistoryLen = 0;
5345
5346
  var objValue = void 0;
5346
5347
  // eslint-disable-next-line
5347
5348
  objValue = getValue(key, this);
5348
- if (!isUndefined$1(objValue)) {
5349
+ if (!isUndefined(objValue)) {
5349
5350
  setValue(key, this.getActualProperties(objValue), persistObj);
5350
5351
  }
5351
5352
  }
@@ -5504,7 +5505,7 @@ var Position = /** @class */ (function (_super) {
5504
5505
  };
5505
5506
  Draggable.prototype.toggleEvents = function (isUnWire) {
5506
5507
  var ele;
5507
- if (!isUndefined$1(this.handle)) {
5508
+ if (!isUndefined(this.handle)) {
5508
5509
  ele = select(this.handle, this.element);
5509
5510
  }
5510
5511
  var handler = (this.enableTapHold && Browser.isDevice && Browser.isTouch) ? this.mobileInitialize : this.initialize;
@@ -5537,7 +5538,7 @@ var Position = /** @class */ (function (_super) {
5537
5538
  Draggable.prototype.getScrollableParent = function (element, axis) {
5538
5539
  var scroll = { 'vertical': 'scrollHeight', 'horizontal': 'scrollWidth' };
5539
5540
  var client = { 'vertical': 'clientHeight', 'horizontal': 'clientWidth' };
5540
- if (isNullOrUndefined$1(element)) {
5541
+ if (isNullOrUndefined(element)) {
5541
5542
  return null;
5542
5543
  }
5543
5544
  if (element[scroll[axis]] > element[client[axis]]) {
@@ -5552,7 +5553,7 @@ var Position = /** @class */ (function (_super) {
5552
5553
  (this.parentScrollX === 0 ? element.scrollLeft : element.scrollLeft - this.parentScrollX);
5553
5554
  this.tempScrollWidth = element.scrollWidth;
5554
5555
  }
5555
- if (!isNullOrUndefined$1(element)) {
5556
+ if (!isNullOrUndefined(element)) {
5556
5557
  return this.getScrollableParent(element.parentNode, axis);
5557
5558
  }
5558
5559
  else {
@@ -5592,7 +5593,7 @@ var Position = /** @class */ (function (_super) {
5592
5593
  abortSelectors = [abortSelectors];
5593
5594
  }
5594
5595
  for (var i = 0; i < abortSelectors.length; i++) {
5595
- if (!isNullOrUndefined$1(closest(evt.target, abortSelectors[i]))) {
5596
+ if (!isNullOrUndefined(closest(evt.target, abortSelectors[i]))) {
5596
5597
  /* istanbul ignore next */
5597
5598
  if (this.isDragStarted()) {
5598
5599
  this.isDragStarted(true);
@@ -5601,7 +5602,7 @@ var Position = /** @class */ (function (_super) {
5601
5602
  }
5602
5603
  }
5603
5604
  }
5604
- if (this.preventDefault && !isUndefined$1(evt.changedTouches) && evt.type !== 'touchstart') {
5605
+ if (this.preventDefault && !isUndefined(evt.changedTouches) && evt.type !== 'touchstart') {
5605
5606
  evt.preventDefault();
5606
5607
  }
5607
5608
  this.element.setAttribute('aria-grabbed', 'true');
@@ -5635,7 +5636,7 @@ var Position = /** @class */ (function (_super) {
5635
5636
  };
5636
5637
  Draggable.prototype.intDragStart = function (evt) {
5637
5638
  this.removeTapholdTimer();
5638
- var isChangeTouch = !isUndefined$1(evt.changedTouches);
5639
+ var isChangeTouch = !isUndefined(evt.changedTouches);
5639
5640
  if (isChangeTouch && (evt.changedTouches.length !== 1)) {
5640
5641
  return;
5641
5642
  }
@@ -5651,7 +5652,7 @@ var Position = /** @class */ (function (_super) {
5651
5652
  var element = this.element;
5652
5653
  if (this.clone && this.dragTarget) {
5653
5654
  var intClosest = closest(evt.target, this.dragTarget);
5654
- if (!isNullOrUndefined$1(intClosest)) {
5655
+ if (!isNullOrUndefined(intClosest)) {
5655
5656
  element = intClosest;
5656
5657
  }
5657
5658
  }
@@ -5666,7 +5667,7 @@ var Position = /** @class */ (function (_super) {
5666
5667
  var distance = Math.sqrt((x * x) + (y * y));
5667
5668
  if ((distance >= this.distance || this.externalInitialize)) {
5668
5669
  var ele = this.getHelperElement(evt);
5669
- if (!ele || isNullOrUndefined$1(ele)) {
5670
+ if (!ele || isNullOrUndefined(ele)) {
5670
5671
  return;
5671
5672
  }
5672
5673
  if (isChangeTouch) {
@@ -5760,7 +5761,7 @@ var Position = /** @class */ (function (_super) {
5760
5761
  return value;
5761
5762
  };
5762
5763
  Draggable.prototype.calculateParentPosition = function (ele) {
5763
- if (isNullOrUndefined$1(ele)) {
5764
+ if (isNullOrUndefined(ele)) {
5764
5765
  return { left: 0, top: 0 };
5765
5766
  }
5766
5767
  var rect = ele.getBoundingClientRect();
@@ -5772,7 +5773,7 @@ var Position = /** @class */ (function (_super) {
5772
5773
  };
5773
5774
  // tslint:disable-next-line:max-func-body-length
5774
5775
  Draggable.prototype.intDrag = function (evt) {
5775
- if (!isUndefined$1(evt.changedTouches) && (evt.changedTouches.length !== 1)) {
5776
+ if (!isUndefined(evt.changedTouches) && (evt.changedTouches.length !== 1)) {
5776
5777
  return;
5777
5778
  }
5778
5779
  if (this.clone && evt.changedTouches && Browser.isDevice && Browser.isTouch) {
@@ -5859,10 +5860,10 @@ var Position = /** @class */ (function (_super) {
5859
5860
  var iTop = tTop + this.borderWidth.top;
5860
5861
  var iLeft = tLeft + this.borderWidth.left;
5861
5862
  if (this.dragProcessStarted) {
5862
- if (isNullOrUndefined$1(top)) {
5863
+ if (isNullOrUndefined(top)) {
5863
5864
  top = this.prevTop;
5864
5865
  }
5865
- if (isNullOrUndefined$1(left)) {
5866
+ if (isNullOrUndefined(left)) {
5866
5867
  left = this.prevLeft;
5867
5868
  }
5868
5869
  }
@@ -6015,7 +6016,7 @@ var Position = /** @class */ (function (_super) {
6015
6016
  };
6016
6017
  Draggable.prototype.intDragStop = function (evt) {
6017
6018
  this.dragProcessStarted = false;
6018
- if (!isUndefined$1(evt.changedTouches) && (evt.changedTouches.length !== 1)) {
6019
+ if (!isUndefined(evt.changedTouches) && (evt.changedTouches.length !== 1)) {
6019
6020
  return;
6020
6021
  }
6021
6022
  var type = ['touchend', 'pointerup', 'mouseup'];
@@ -6119,11 +6120,11 @@ var Position = /** @class */ (function (_super) {
6119
6120
  /* istanbul ignore next */
6120
6121
  Draggable.prototype.currentStateCheck = function (ele, oldEle) {
6121
6122
  var elem;
6122
- if (!isNullOrUndefined$1(this.currentStateTarget) && this.currentStateTarget !== ele) {
6123
+ if (!isNullOrUndefined(this.currentStateTarget) && this.currentStateTarget !== ele) {
6123
6124
  elem = this.currentStateTarget;
6124
6125
  }
6125
6126
  else {
6126
- elem = !isNullOrUndefined$1(oldEle) ? oldEle : ele;
6127
+ elem = !isNullOrUndefined(oldEle) ? oldEle : ele;
6127
6128
  }
6128
6129
  return elem;
6129
6130
  };
@@ -6133,7 +6134,7 @@ var Position = /** @class */ (function (_super) {
6133
6134
  var intCoord = this.getCoordinates(evt);
6134
6135
  var pageX;
6135
6136
  var pageY;
6136
- var isOffsetParent = isNullOrUndefined$1(dragEle.offsetParent);
6137
+ var isOffsetParent = isNullOrUndefined(dragEle.offsetParent);
6137
6138
  /* istanbul ignore next */
6138
6139
  if (isdragscroll) {
6139
6140
  pageX = this.clone ? intCoord.pageX :
@@ -6182,7 +6183,7 @@ var Position = /** @class */ (function (_super) {
6182
6183
  Draggable.prototype.checkTargetElement = function (evt) {
6183
6184
  var target = this.getProperTargetElement(evt);
6184
6185
  var dropIns = this.getDropInstance(target);
6185
- if (!dropIns && target && !isNullOrUndefined$1(target.parentNode)) {
6186
+ if (!dropIns && target && !isNullOrUndefined(target.parentNode)) {
6186
6187
  var parent_1 = closest(target.parentNode, '.e-droppable') || target.parentElement;
6187
6188
  if (parent_1) {
6188
6189
  dropIns = this.getDropInstance(parent_1);
@@ -7601,7 +7602,7 @@ function detect (cssProp) {
7601
7602
  return result
7602
7603
  }
7603
7604
 
7604
- function set$1 () {
7605
+ function set () {
7605
7606
  if (arguments.length === 2) {
7606
7607
  if (typeof arguments[1] === 'string') {
7607
7608
  arguments[0].style.cssText = arguments[1];
@@ -7613,8 +7614,8 @@ function set$1 () {
7613
7614
  }
7614
7615
  }
7615
7616
 
7616
- domCss.exports = set$1;
7617
- domCss.exports.set = set$1;
7617
+ domCss.exports = set;
7618
+ domCss.exports.set = set;
7618
7619
 
7619
7620
  domCss.exports.get = function (element, properties) {
7620
7621
  if (Array.isArray(properties)) {
@@ -8732,7 +8733,7 @@ if (process.env.NODE_ENV !== 'production') {
8732
8733
 
8733
8734
  var PropTypes = propTypes$6.exports;
8734
8735
 
8735
- var isString$1 = {};
8736
+ var isString = {};
8736
8737
 
8737
8738
  (function (exports) {
8738
8739
 
@@ -8743,7 +8744,7 @@ exports["default"] = isString;
8743
8744
  function isString(maybe) {
8744
8745
  return typeof maybe === 'string';
8745
8746
  }
8746
- }(isString$1));
8747
+ }(isString));
8747
8748
 
8748
8749
  var getScrollbarWidth$1 = {};
8749
8750
 
@@ -9012,7 +9013,7 @@ var _propTypes = propTypes$6.exports;
9012
9013
 
9013
9014
  var _propTypes2 = _interopRequireDefault(_propTypes);
9014
9015
 
9015
- var _isString = isString$1;
9016
+ var _isString = isString;
9016
9017
 
9017
9018
  var _isString2 = _interopRequireDefault(_isString);
9018
9019
 
@@ -9801,1715 +9802,6 @@ exports["default"] = _Scrollbars2["default"];
9801
9802
  exports.Scrollbars = _Scrollbars2["default"];
9802
9803
  }(lib));
9803
9804
 
9804
- var isCheckBoxInput = (element) => element.type === 'checkbox';
9805
-
9806
- var isDateObject = (value) => value instanceof Date;
9807
-
9808
- var isNullOrUndefined = (value) => value == null;
9809
-
9810
- const isObjectType = (value) => typeof value === 'object';
9811
- var isObject$1 = (value) => !isNullOrUndefined(value) &&
9812
- !Array.isArray(value) &&
9813
- isObjectType(value) &&
9814
- !isDateObject(value);
9815
-
9816
- var getEventValue = (event) => isObject$1(event) && event.target
9817
- ? isCheckBoxInput(event.target)
9818
- ? event.target.checked
9819
- : event.target.value
9820
- : event;
9821
-
9822
- var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
9823
-
9824
- var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
9825
-
9826
- var isPlainObject = (tempObject) => {
9827
- const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
9828
- return (isObject$1(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
9829
- };
9830
-
9831
- var isWeb = typeof window !== 'undefined' &&
9832
- typeof window.HTMLElement !== 'undefined' &&
9833
- typeof document !== 'undefined';
9834
-
9835
- function cloneObject(data) {
9836
- let copy;
9837
- const isArray = Array.isArray(data);
9838
- if (data instanceof Date) {
9839
- copy = new Date(data);
9840
- }
9841
- else if (data instanceof Set) {
9842
- copy = new Set(data);
9843
- }
9844
- else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
9845
- (isArray || isObject$1(data))) {
9846
- copy = isArray ? [] : {};
9847
- if (!Array.isArray(data) && !isPlainObject(data)) {
9848
- copy = data;
9849
- }
9850
- else {
9851
- for (const key in data) {
9852
- copy[key] = cloneObject(data[key]);
9853
- }
9854
- }
9855
- }
9856
- else {
9857
- return data;
9858
- }
9859
- return copy;
9860
- }
9861
-
9862
- var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
9863
-
9864
- var isUndefined = (val) => val === undefined;
9865
-
9866
- var get = (obj, path, defaultValue) => {
9867
- if (!path || !isObject$1(obj)) {
9868
- return defaultValue;
9869
- }
9870
- const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);
9871
- return isUndefined(result) || result === obj
9872
- ? isUndefined(obj[path])
9873
- ? defaultValue
9874
- : obj[path]
9875
- : result;
9876
- };
9877
-
9878
- const EVENTS = {
9879
- BLUR: 'blur',
9880
- FOCUS_OUT: 'focusout',
9881
- CHANGE: 'change',
9882
- };
9883
- const VALIDATION_MODE = {
9884
- onBlur: 'onBlur',
9885
- onChange: 'onChange',
9886
- onSubmit: 'onSubmit',
9887
- onTouched: 'onTouched',
9888
- all: 'all',
9889
- };
9890
- const INPUT_VALIDATION_RULES = {
9891
- max: 'max',
9892
- min: 'min',
9893
- maxLength: 'maxLength',
9894
- minLength: 'minLength',
9895
- pattern: 'pattern',
9896
- required: 'required',
9897
- validate: 'validate',
9898
- };
9899
-
9900
- React__default["default"].createContext(null);
9901
-
9902
- var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
9903
- const result = {
9904
- defaultValues: control._defaultValues,
9905
- };
9906
- for (const key in formState) {
9907
- Object.defineProperty(result, key, {
9908
- get: () => {
9909
- const _key = key;
9910
- if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
9911
- control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
9912
- }
9913
- localProxyFormState && (localProxyFormState[_key] = true);
9914
- return formState[_key];
9915
- },
9916
- });
9917
- }
9918
- return result;
9919
- };
9920
-
9921
- var isEmptyObject = (value) => isObject$1(value) && !Object.keys(value).length;
9922
-
9923
- var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
9924
- updateFormState(formStateData);
9925
- const { name, ...formState } = formStateData;
9926
- return (isEmptyObject(formState) ||
9927
- Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
9928
- Object.keys(formState).find((key) => _proxyFormState[key] ===
9929
- (!isRoot || VALIDATION_MODE.all)));
9930
- };
9931
-
9932
- var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
9933
-
9934
- function useSubscribe(props) {
9935
- const _props = React__default["default"].useRef(props);
9936
- _props.current = props;
9937
- React__default["default"].useEffect(() => {
9938
- const subscription = !props.disabled &&
9939
- _props.current.subject &&
9940
- _props.current.subject.subscribe({
9941
- next: _props.current.next,
9942
- });
9943
- return () => {
9944
- subscription && subscription.unsubscribe();
9945
- };
9946
- }, [props.disabled]);
9947
- }
9948
-
9949
- var isString = (value) => typeof value === 'string';
9950
-
9951
- var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
9952
- if (isString(names)) {
9953
- isGlobal && _names.watch.add(names);
9954
- return get(formValues, names, defaultValue);
9955
- }
9956
- if (Array.isArray(names)) {
9957
- return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
9958
- }
9959
- isGlobal && (_names.watchAll = true);
9960
- return formValues;
9961
- };
9962
-
9963
- var isKey = (value) => /^\w*$/.test(value);
9964
-
9965
- var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
9966
-
9967
- function set(object, path, value) {
9968
- let index = -1;
9969
- const tempPath = isKey(path) ? [path] : stringToPath(path);
9970
- const length = tempPath.length;
9971
- const lastIndex = length - 1;
9972
- while (++index < length) {
9973
- const key = tempPath[index];
9974
- let newValue = value;
9975
- if (index !== lastIndex) {
9976
- const objValue = object[key];
9977
- newValue =
9978
- isObject$1(objValue) || Array.isArray(objValue)
9979
- ? objValue
9980
- : !isNaN(+tempPath[index + 1])
9981
- ? []
9982
- : {};
9983
- }
9984
- object[key] = newValue;
9985
- object = object[key];
9986
- }
9987
- return object;
9988
- }
9989
-
9990
- var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
9991
- ? {
9992
- ...errors[name],
9993
- types: {
9994
- ...(errors[name] && errors[name].types ? errors[name].types : {}),
9995
- [type]: message || true,
9996
- },
9997
- }
9998
- : {};
9999
-
10000
- const focusFieldBy = (fields, callback, fieldsNames) => {
10001
- for (const key of fieldsNames || Object.keys(fields)) {
10002
- const field = get(fields, key);
10003
- if (field) {
10004
- const { _f, ...currentField } = field;
10005
- if (_f && callback(_f.name)) {
10006
- if (_f.ref.focus) {
10007
- _f.ref.focus();
10008
- break;
10009
- }
10010
- else if (_f.refs && _f.refs[0].focus) {
10011
- _f.refs[0].focus();
10012
- break;
10013
- }
10014
- }
10015
- else if (isObject$1(currentField)) {
10016
- focusFieldBy(currentField, callback);
10017
- }
10018
- }
10019
- }
10020
- };
10021
-
10022
- var getValidationModes = (mode) => ({
10023
- isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
10024
- isOnBlur: mode === VALIDATION_MODE.onBlur,
10025
- isOnChange: mode === VALIDATION_MODE.onChange,
10026
- isOnAll: mode === VALIDATION_MODE.all,
10027
- isOnTouch: mode === VALIDATION_MODE.onTouched,
10028
- });
10029
-
10030
- var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
10031
- (_names.watchAll ||
10032
- _names.watch.has(name) ||
10033
- [..._names.watch].some((watchName) => name.startsWith(watchName) &&
10034
- /^\.\w+/.test(name.slice(watchName.length))));
10035
-
10036
- var updateFieldArrayRootError = (errors, error, name) => {
10037
- const fieldArrayErrors = compact(get(errors, name));
10038
- set(fieldArrayErrors, 'root', error[name]);
10039
- set(errors, name, fieldArrayErrors);
10040
- return errors;
10041
- };
10042
-
10043
- var isBoolean = (value) => typeof value === 'boolean';
10044
-
10045
- var isFileInput = (element) => element.type === 'file';
10046
-
10047
- var isFunction$1 = (value) => typeof value === 'function';
10048
-
10049
- var isHTMLElement = (value) => {
10050
- if (!isWeb) {
10051
- return false;
10052
- }
10053
- const owner = value ? value.ownerDocument : 0;
10054
- return (value instanceof
10055
- (owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));
10056
- };
10057
-
10058
- var isMessage = (value) => isString(value);
10059
-
10060
- var isRadioInput = (element) => element.type === 'radio';
10061
-
10062
- var isRegex = (value) => value instanceof RegExp;
10063
-
10064
- const defaultResult = {
10065
- value: false,
10066
- isValid: false,
10067
- };
10068
- const validResult = { value: true, isValid: true };
10069
- var getCheckboxValue = (options) => {
10070
- if (Array.isArray(options)) {
10071
- if (options.length > 1) {
10072
- const values = options
10073
- .filter((option) => option && option.checked && !option.disabled)
10074
- .map((option) => option.value);
10075
- return { value: values, isValid: !!values.length };
10076
- }
10077
- return options[0].checked && !options[0].disabled
10078
- ? // @ts-expect-error expected to work in the browser
10079
- options[0].attributes && !isUndefined(options[0].attributes.value)
10080
- ? isUndefined(options[0].value) || options[0].value === ''
10081
- ? validResult
10082
- : { value: options[0].value, isValid: true }
10083
- : validResult
10084
- : defaultResult;
10085
- }
10086
- return defaultResult;
10087
- };
10088
-
10089
- const defaultReturn = {
10090
- isValid: false,
10091
- value: null,
10092
- };
10093
- var getRadioValue = (options) => Array.isArray(options)
10094
- ? options.reduce((previous, option) => option && option.checked && !option.disabled
10095
- ? {
10096
- isValid: true,
10097
- value: option.value,
10098
- }
10099
- : previous, defaultReturn)
10100
- : defaultReturn;
10101
-
10102
- function getValidateError(result, ref, type = 'validate') {
10103
- if (isMessage(result) ||
10104
- (Array.isArray(result) && result.every(isMessage)) ||
10105
- (isBoolean(result) && !result)) {
10106
- return {
10107
- type,
10108
- message: isMessage(result) ? result : '',
10109
- ref,
10110
- };
10111
- }
10112
- }
10113
-
10114
- var getValueAndMessage = (validationData) => isObject$1(validationData) && !isRegex(validationData)
10115
- ? validationData
10116
- : {
10117
- value: validationData,
10118
- message: '',
10119
- };
10120
-
10121
- var validateField = async (field, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
10122
- const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, disabled, } = field._f;
10123
- const inputValue = get(formValues, name);
10124
- if (!mount || disabled) {
10125
- return {};
10126
- }
10127
- const inputRef = refs ? refs[0] : ref;
10128
- const setCustomValidity = (message) => {
10129
- if (shouldUseNativeValidation && inputRef.reportValidity) {
10130
- inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');
10131
- inputRef.reportValidity();
10132
- }
10133
- };
10134
- const error = {};
10135
- const isRadio = isRadioInput(ref);
10136
- const isCheckBox = isCheckBoxInput(ref);
10137
- const isRadioOrCheckbox = isRadio || isCheckBox;
10138
- const isEmpty = ((valueAsNumber || isFileInput(ref)) &&
10139
- isUndefined(ref.value) &&
10140
- isUndefined(inputValue)) ||
10141
- (isHTMLElement(ref) && ref.value === '') ||
10142
- inputValue === '' ||
10143
- (Array.isArray(inputValue) && !inputValue.length);
10144
- const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
10145
- const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
10146
- const message = exceedMax ? maxLengthMessage : minLengthMessage;
10147
- error[name] = {
10148
- type: exceedMax ? maxType : minType,
10149
- message,
10150
- ref,
10151
- ...appendErrorsCurry(exceedMax ? maxType : minType, message),
10152
- };
10153
- };
10154
- if (isFieldArray
10155
- ? !Array.isArray(inputValue) || !inputValue.length
10156
- : required &&
10157
- ((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
10158
- (isBoolean(inputValue) && !inputValue) ||
10159
- (isCheckBox && !getCheckboxValue(refs).isValid) ||
10160
- (isRadio && !getRadioValue(refs).isValid))) {
10161
- const { value, message } = isMessage(required)
10162
- ? { value: !!required, message: required }
10163
- : getValueAndMessage(required);
10164
- if (value) {
10165
- error[name] = {
10166
- type: INPUT_VALIDATION_RULES.required,
10167
- message,
10168
- ref: inputRef,
10169
- ...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),
10170
- };
10171
- if (!validateAllFieldCriteria) {
10172
- setCustomValidity(message);
10173
- return error;
10174
- }
10175
- }
10176
- }
10177
- if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
10178
- let exceedMax;
10179
- let exceedMin;
10180
- const maxOutput = getValueAndMessage(max);
10181
- const minOutput = getValueAndMessage(min);
10182
- if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {
10183
- const valueNumber = ref.valueAsNumber ||
10184
- (inputValue ? +inputValue : inputValue);
10185
- if (!isNullOrUndefined(maxOutput.value)) {
10186
- exceedMax = valueNumber > maxOutput.value;
10187
- }
10188
- if (!isNullOrUndefined(minOutput.value)) {
10189
- exceedMin = valueNumber < minOutput.value;
10190
- }
10191
- }
10192
- else {
10193
- const valueDate = ref.valueAsDate || new Date(inputValue);
10194
- const convertTimeToDate = (time) => new Date(new Date().toDateString() + ' ' + time);
10195
- const isTime = ref.type == 'time';
10196
- const isWeek = ref.type == 'week';
10197
- if (isString(maxOutput.value) && inputValue) {
10198
- exceedMax = isTime
10199
- ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)
10200
- : isWeek
10201
- ? inputValue > maxOutput.value
10202
- : valueDate > new Date(maxOutput.value);
10203
- }
10204
- if (isString(minOutput.value) && inputValue) {
10205
- exceedMin = isTime
10206
- ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)
10207
- : isWeek
10208
- ? inputValue < minOutput.value
10209
- : valueDate < new Date(minOutput.value);
10210
- }
10211
- }
10212
- if (exceedMax || exceedMin) {
10213
- getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
10214
- if (!validateAllFieldCriteria) {
10215
- setCustomValidity(error[name].message);
10216
- return error;
10217
- }
10218
- }
10219
- }
10220
- if ((maxLength || minLength) &&
10221
- !isEmpty &&
10222
- (isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))) {
10223
- const maxLengthOutput = getValueAndMessage(maxLength);
10224
- const minLengthOutput = getValueAndMessage(minLength);
10225
- const exceedMax = !isNullOrUndefined(maxLengthOutput.value) &&
10226
- inputValue.length > +maxLengthOutput.value;
10227
- const exceedMin = !isNullOrUndefined(minLengthOutput.value) &&
10228
- inputValue.length < +minLengthOutput.value;
10229
- if (exceedMax || exceedMin) {
10230
- getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
10231
- if (!validateAllFieldCriteria) {
10232
- setCustomValidity(error[name].message);
10233
- return error;
10234
- }
10235
- }
10236
- }
10237
- if (pattern && !isEmpty && isString(inputValue)) {
10238
- const { value: patternValue, message } = getValueAndMessage(pattern);
10239
- if (isRegex(patternValue) && !inputValue.match(patternValue)) {
10240
- error[name] = {
10241
- type: INPUT_VALIDATION_RULES.pattern,
10242
- message,
10243
- ref,
10244
- ...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),
10245
- };
10246
- if (!validateAllFieldCriteria) {
10247
- setCustomValidity(message);
10248
- return error;
10249
- }
10250
- }
10251
- }
10252
- if (validate) {
10253
- if (isFunction$1(validate)) {
10254
- const result = await validate(inputValue, formValues);
10255
- const validateError = getValidateError(result, inputRef);
10256
- if (validateError) {
10257
- error[name] = {
10258
- ...validateError,
10259
- ...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),
10260
- };
10261
- if (!validateAllFieldCriteria) {
10262
- setCustomValidity(validateError.message);
10263
- return error;
10264
- }
10265
- }
10266
- }
10267
- else if (isObject$1(validate)) {
10268
- let validationResult = {};
10269
- for (const key in validate) {
10270
- if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
10271
- break;
10272
- }
10273
- const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);
10274
- if (validateError) {
10275
- validationResult = {
10276
- ...validateError,
10277
- ...appendErrorsCurry(key, validateError.message),
10278
- };
10279
- setCustomValidity(validateError.message);
10280
- if (validateAllFieldCriteria) {
10281
- error[name] = validationResult;
10282
- }
10283
- }
10284
- }
10285
- if (!isEmptyObject(validationResult)) {
10286
- error[name] = {
10287
- ref: inputRef,
10288
- ...validationResult,
10289
- };
10290
- if (!validateAllFieldCriteria) {
10291
- return error;
10292
- }
10293
- }
10294
- }
10295
- }
10296
- setCustomValidity(true);
10297
- return error;
10298
- };
10299
-
10300
- function baseGet(object, updatePath) {
10301
- const length = updatePath.slice(0, -1).length;
10302
- let index = 0;
10303
- while (index < length) {
10304
- object = isUndefined(object) ? index++ : object[updatePath[index++]];
10305
- }
10306
- return object;
10307
- }
10308
- function isEmptyArray(obj) {
10309
- for (const key in obj) {
10310
- if (!isUndefined(obj[key])) {
10311
- return false;
10312
- }
10313
- }
10314
- return true;
10315
- }
10316
- function unset(object, path) {
10317
- const paths = Array.isArray(path)
10318
- ? path
10319
- : isKey(path)
10320
- ? [path]
10321
- : stringToPath(path);
10322
- const childObject = paths.length === 1 ? object : baseGet(object, paths);
10323
- const index = paths.length - 1;
10324
- const key = paths[index];
10325
- if (childObject) {
10326
- delete childObject[key];
10327
- }
10328
- if (index !== 0 &&
10329
- ((isObject$1(childObject) && isEmptyObject(childObject)) ||
10330
- (Array.isArray(childObject) && isEmptyArray(childObject)))) {
10331
- unset(object, paths.slice(0, -1));
10332
- }
10333
- return object;
10334
- }
10335
-
10336
- function createSubject() {
10337
- let _observers = [];
10338
- const next = (value) => {
10339
- for (const observer of _observers) {
10340
- observer.next && observer.next(value);
10341
- }
10342
- };
10343
- const subscribe = (observer) => {
10344
- _observers.push(observer);
10345
- return {
10346
- unsubscribe: () => {
10347
- _observers = _observers.filter((o) => o !== observer);
10348
- },
10349
- };
10350
- };
10351
- const unsubscribe = () => {
10352
- _observers = [];
10353
- };
10354
- return {
10355
- get observers() {
10356
- return _observers;
10357
- },
10358
- next,
10359
- subscribe,
10360
- unsubscribe,
10361
- };
10362
- }
10363
-
10364
- var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
10365
-
10366
- function deepEqual(object1, object2) {
10367
- if (isPrimitive(object1) || isPrimitive(object2)) {
10368
- return object1 === object2;
10369
- }
10370
- if (isDateObject(object1) && isDateObject(object2)) {
10371
- return object1.getTime() === object2.getTime();
10372
- }
10373
- const keys1 = Object.keys(object1);
10374
- const keys2 = Object.keys(object2);
10375
- if (keys1.length !== keys2.length) {
10376
- return false;
10377
- }
10378
- for (const key of keys1) {
10379
- const val1 = object1[key];
10380
- if (!keys2.includes(key)) {
10381
- return false;
10382
- }
10383
- if (key !== 'ref') {
10384
- const val2 = object2[key];
10385
- if ((isDateObject(val1) && isDateObject(val2)) ||
10386
- (isObject$1(val1) && isObject$1(val2)) ||
10387
- (Array.isArray(val1) && Array.isArray(val2))
10388
- ? !deepEqual(val1, val2)
10389
- : val1 !== val2) {
10390
- return false;
10391
- }
10392
- }
10393
- }
10394
- return true;
10395
- }
10396
-
10397
- var isMultipleSelect = (element) => element.type === `select-multiple`;
10398
-
10399
- var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
10400
-
10401
- var live = (ref) => isHTMLElement(ref) && ref.isConnected;
10402
-
10403
- var objectHasFunction = (data) => {
10404
- for (const key in data) {
10405
- if (isFunction$1(data[key])) {
10406
- return true;
10407
- }
10408
- }
10409
- return false;
10410
- };
10411
-
10412
- function markFieldsDirty(data, fields = {}) {
10413
- const isParentNodeArray = Array.isArray(data);
10414
- if (isObject$1(data) || isParentNodeArray) {
10415
- for (const key in data) {
10416
- if (Array.isArray(data[key]) ||
10417
- (isObject$1(data[key]) && !objectHasFunction(data[key]))) {
10418
- fields[key] = Array.isArray(data[key]) ? [] : {};
10419
- markFieldsDirty(data[key], fields[key]);
10420
- }
10421
- else if (!isNullOrUndefined(data[key])) {
10422
- fields[key] = true;
10423
- }
10424
- }
10425
- }
10426
- return fields;
10427
- }
10428
- function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {
10429
- const isParentNodeArray = Array.isArray(data);
10430
- if (isObject$1(data) || isParentNodeArray) {
10431
- for (const key in data) {
10432
- if (Array.isArray(data[key]) ||
10433
- (isObject$1(data[key]) && !objectHasFunction(data[key]))) {
10434
- if (isUndefined(formValues) ||
10435
- isPrimitive(dirtyFieldsFromValues[key])) {
10436
- dirtyFieldsFromValues[key] = Array.isArray(data[key])
10437
- ? markFieldsDirty(data[key], [])
10438
- : { ...markFieldsDirty(data[key]) };
10439
- }
10440
- else {
10441
- getDirtyFieldsFromDefaultValues(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
10442
- }
10443
- }
10444
- else {
10445
- dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);
10446
- }
10447
- }
10448
- }
10449
- return dirtyFieldsFromValues;
10450
- }
10451
- var getDirtyFields = (defaultValues, formValues) => getDirtyFieldsFromDefaultValues(defaultValues, formValues, markFieldsDirty(formValues));
10452
-
10453
- var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value)
10454
- ? value
10455
- : valueAsNumber
10456
- ? value === ''
10457
- ? NaN
10458
- : value
10459
- ? +value
10460
- : value
10461
- : valueAsDate && isString(value)
10462
- ? new Date(value)
10463
- : setValueAs
10464
- ? setValueAs(value)
10465
- : value;
10466
-
10467
- function getFieldValue(_f) {
10468
- const ref = _f.ref;
10469
- if (_f.refs ? _f.refs.every((ref) => ref.disabled) : ref.disabled) {
10470
- return;
10471
- }
10472
- if (isFileInput(ref)) {
10473
- return ref.files;
10474
- }
10475
- if (isRadioInput(ref)) {
10476
- return getRadioValue(_f.refs).value;
10477
- }
10478
- if (isMultipleSelect(ref)) {
10479
- return [...ref.selectedOptions].map(({ value }) => value);
10480
- }
10481
- if (isCheckBoxInput(ref)) {
10482
- return getCheckboxValue(_f.refs).value;
10483
- }
10484
- return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);
10485
- }
10486
-
10487
- var getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {
10488
- const fields = {};
10489
- for (const name of fieldsNames) {
10490
- const field = get(_fields, name);
10491
- field && set(fields, name, field._f);
10492
- }
10493
- return {
10494
- criteriaMode,
10495
- names: [...fieldsNames],
10496
- fields,
10497
- shouldUseNativeValidation,
10498
- };
10499
- };
10500
-
10501
- var getRuleValue = (rule) => isUndefined(rule)
10502
- ? rule
10503
- : isRegex(rule)
10504
- ? rule.source
10505
- : isObject$1(rule)
10506
- ? isRegex(rule.value)
10507
- ? rule.value.source
10508
- : rule.value
10509
- : rule;
10510
-
10511
- var hasValidation = (options) => options.mount &&
10512
- (options.required ||
10513
- options.min ||
10514
- options.max ||
10515
- options.maxLength ||
10516
- options.minLength ||
10517
- options.pattern ||
10518
- options.validate);
10519
-
10520
- function schemaErrorLookup(errors, _fields, name) {
10521
- const error = get(errors, name);
10522
- if (error || isKey(name)) {
10523
- return {
10524
- error,
10525
- name,
10526
- };
10527
- }
10528
- const names = name.split('.');
10529
- while (names.length) {
10530
- const fieldName = names.join('.');
10531
- const field = get(_fields, fieldName);
10532
- const foundError = get(errors, fieldName);
10533
- if (field && !Array.isArray(field) && name !== fieldName) {
10534
- return { name };
10535
- }
10536
- if (foundError && foundError.type) {
10537
- return {
10538
- name: fieldName,
10539
- error: foundError,
10540
- };
10541
- }
10542
- names.pop();
10543
- }
10544
- return {
10545
- name,
10546
- };
10547
- }
10548
-
10549
- var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {
10550
- if (mode.isOnAll) {
10551
- return false;
10552
- }
10553
- else if (!isSubmitted && mode.isOnTouch) {
10554
- return !(isTouched || isBlurEvent);
10555
- }
10556
- else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
10557
- return !isBlurEvent;
10558
- }
10559
- else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
10560
- return isBlurEvent;
10561
- }
10562
- return true;
10563
- };
10564
-
10565
- var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
10566
-
10567
- const defaultOptions = {
10568
- mode: VALIDATION_MODE.onSubmit,
10569
- reValidateMode: VALIDATION_MODE.onChange,
10570
- shouldFocusError: true,
10571
- };
10572
- function createFormControl(props = {}, flushRootRender) {
10573
- let _options = {
10574
- ...defaultOptions,
10575
- ...props,
10576
- };
10577
- let _formState = {
10578
- submitCount: 0,
10579
- isDirty: false,
10580
- isLoading: isFunction$1(_options.defaultValues),
10581
- isValidating: false,
10582
- isSubmitted: false,
10583
- isSubmitting: false,
10584
- isSubmitSuccessful: false,
10585
- isValid: false,
10586
- touchedFields: {},
10587
- dirtyFields: {},
10588
- errors: {},
10589
- };
10590
- let _fields = {};
10591
- let _defaultValues = isObject$1(_options.defaultValues) || isObject$1(_options.values)
10592
- ? cloneObject(_options.defaultValues || _options.values) || {}
10593
- : {};
10594
- let _formValues = _options.shouldUnregister
10595
- ? {}
10596
- : cloneObject(_defaultValues);
10597
- let _state = {
10598
- action: false,
10599
- mount: false,
10600
- watch: false,
10601
- };
10602
- let _names = {
10603
- mount: new Set(),
10604
- unMount: new Set(),
10605
- array: new Set(),
10606
- watch: new Set(),
10607
- };
10608
- let delayErrorCallback;
10609
- let timer = 0;
10610
- const _proxyFormState = {
10611
- isDirty: false,
10612
- dirtyFields: false,
10613
- touchedFields: false,
10614
- isValidating: false,
10615
- isValid: false,
10616
- errors: false,
10617
- };
10618
- const _subjects = {
10619
- values: createSubject(),
10620
- array: createSubject(),
10621
- state: createSubject(),
10622
- };
10623
- const shouldCaptureDirtyFields = props.resetOptions && props.resetOptions.keepDirtyValues;
10624
- const validationModeBeforeSubmit = getValidationModes(_options.mode);
10625
- const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
10626
- const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
10627
- const debounce = (callback) => (wait) => {
10628
- clearTimeout(timer);
10629
- timer = setTimeout(callback, wait);
10630
- };
10631
- const _updateValid = async (shouldUpdateValid) => {
10632
- if (_proxyFormState.isValid || shouldUpdateValid) {
10633
- const isValid = _options.resolver
10634
- ? isEmptyObject((await _executeSchema()).errors)
10635
- : await executeBuiltInValidation(_fields, true);
10636
- if (isValid !== _formState.isValid) {
10637
- _subjects.state.next({
10638
- isValid,
10639
- });
10640
- }
10641
- }
10642
- };
10643
- const _updateIsValidating = (value) => _proxyFormState.isValidating &&
10644
- _subjects.state.next({
10645
- isValidating: value,
10646
- });
10647
- const _updateFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
10648
- if (args && method) {
10649
- _state.action = true;
10650
- if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
10651
- const fieldValues = method(get(_fields, name), args.argA, args.argB);
10652
- shouldSetValues && set(_fields, name, fieldValues);
10653
- }
10654
- if (shouldUpdateFieldsAndState &&
10655
- Array.isArray(get(_formState.errors, name))) {
10656
- const errors = method(get(_formState.errors, name), args.argA, args.argB);
10657
- shouldSetValues && set(_formState.errors, name, errors);
10658
- unsetEmptyArray(_formState.errors, name);
10659
- }
10660
- if (_proxyFormState.touchedFields &&
10661
- shouldUpdateFieldsAndState &&
10662
- Array.isArray(get(_formState.touchedFields, name))) {
10663
- const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
10664
- shouldSetValues && set(_formState.touchedFields, name, touchedFields);
10665
- }
10666
- if (_proxyFormState.dirtyFields) {
10667
- _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
10668
- }
10669
- _subjects.state.next({
10670
- name,
10671
- isDirty: _getDirty(name, values),
10672
- dirtyFields: _formState.dirtyFields,
10673
- errors: _formState.errors,
10674
- isValid: _formState.isValid,
10675
- });
10676
- }
10677
- else {
10678
- set(_formValues, name, values);
10679
- }
10680
- };
10681
- const updateErrors = (name, error) => {
10682
- set(_formState.errors, name, error);
10683
- _subjects.state.next({
10684
- errors: _formState.errors,
10685
- });
10686
- };
10687
- const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
10688
- const field = get(_fields, name);
10689
- if (field) {
10690
- const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);
10691
- isUndefined(defaultValue) ||
10692
- (ref && ref.defaultChecked) ||
10693
- shouldSkipSetValueAs
10694
- ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
10695
- : setFieldValue(name, defaultValue);
10696
- _state.mount && _updateValid();
10697
- }
10698
- };
10699
- const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
10700
- let shouldUpdateField = false;
10701
- let isPreviousDirty = false;
10702
- const output = {
10703
- name,
10704
- };
10705
- if (!isBlurEvent || shouldDirty) {
10706
- if (_proxyFormState.isDirty) {
10707
- isPreviousDirty = _formState.isDirty;
10708
- _formState.isDirty = output.isDirty = _getDirty();
10709
- shouldUpdateField = isPreviousDirty !== output.isDirty;
10710
- }
10711
- const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);
10712
- isPreviousDirty = get(_formState.dirtyFields, name);
10713
- isCurrentFieldPristine
10714
- ? unset(_formState.dirtyFields, name)
10715
- : set(_formState.dirtyFields, name, true);
10716
- output.dirtyFields = _formState.dirtyFields;
10717
- shouldUpdateField =
10718
- shouldUpdateField ||
10719
- (_proxyFormState.dirtyFields &&
10720
- isPreviousDirty !== !isCurrentFieldPristine);
10721
- }
10722
- if (isBlurEvent) {
10723
- const isPreviousFieldTouched = get(_formState.touchedFields, name);
10724
- if (!isPreviousFieldTouched) {
10725
- set(_formState.touchedFields, name, isBlurEvent);
10726
- output.touchedFields = _formState.touchedFields;
10727
- shouldUpdateField =
10728
- shouldUpdateField ||
10729
- (_proxyFormState.touchedFields &&
10730
- isPreviousFieldTouched !== isBlurEvent);
10731
- }
10732
- }
10733
- shouldUpdateField && shouldRender && _subjects.state.next(output);
10734
- return shouldUpdateField ? output : {};
10735
- };
10736
- const shouldRenderByError = (name, isValid, error, fieldState) => {
10737
- const previousFieldError = get(_formState.errors, name);
10738
- const shouldUpdateValid = _proxyFormState.isValid &&
10739
- isBoolean(isValid) &&
10740
- _formState.isValid !== isValid;
10741
- if (props.delayError && error) {
10742
- delayErrorCallback = debounce(() => updateErrors(name, error));
10743
- delayErrorCallback(props.delayError);
10744
- }
10745
- else {
10746
- clearTimeout(timer);
10747
- delayErrorCallback = null;
10748
- error
10749
- ? set(_formState.errors, name, error)
10750
- : unset(_formState.errors, name);
10751
- }
10752
- if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||
10753
- !isEmptyObject(fieldState) ||
10754
- shouldUpdateValid) {
10755
- const updatedFormState = {
10756
- ...fieldState,
10757
- ...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),
10758
- errors: _formState.errors,
10759
- name,
10760
- };
10761
- _formState = {
10762
- ..._formState,
10763
- ...updatedFormState,
10764
- };
10765
- _subjects.state.next(updatedFormState);
10766
- }
10767
- _updateIsValidating(false);
10768
- };
10769
- const _executeSchema = async (name) => _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
10770
- const executeSchemaAndUpdateState = async (names) => {
10771
- const { errors } = await _executeSchema();
10772
- if (names) {
10773
- for (const name of names) {
10774
- const error = get(errors, name);
10775
- error
10776
- ? set(_formState.errors, name, error)
10777
- : unset(_formState.errors, name);
10778
- }
10779
- }
10780
- else {
10781
- _formState.errors = errors;
10782
- }
10783
- return errors;
10784
- };
10785
- const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
10786
- valid: true,
10787
- }) => {
10788
- for (const name in fields) {
10789
- const field = fields[name];
10790
- if (field) {
10791
- const { _f, ...fieldValue } = field;
10792
- if (_f) {
10793
- const isFieldArrayRoot = _names.array.has(_f.name);
10794
- const fieldError = await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
10795
- if (fieldError[_f.name]) {
10796
- context.valid = false;
10797
- if (shouldOnlyCheckValid) {
10798
- break;
10799
- }
10800
- }
10801
- !shouldOnlyCheckValid &&
10802
- (get(fieldError, _f.name)
10803
- ? isFieldArrayRoot
10804
- ? updateFieldArrayRootError(_formState.errors, fieldError, _f.name)
10805
- : set(_formState.errors, _f.name, fieldError[_f.name])
10806
- : unset(_formState.errors, _f.name));
10807
- }
10808
- fieldValue &&
10809
- (await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
10810
- }
10811
- }
10812
- return context.valid;
10813
- };
10814
- const _removeUnmounted = () => {
10815
- for (const name of _names.unMount) {
10816
- const field = get(_fields, name);
10817
- field &&
10818
- (field._f.refs
10819
- ? field._f.refs.every((ref) => !live(ref))
10820
- : !live(field._f.ref)) &&
10821
- unregister(name);
10822
- }
10823
- _names.unMount = new Set();
10824
- };
10825
- const _getDirty = (name, data) => (name && data && set(_formValues, name, data),
10826
- !deepEqual(getValues(), _defaultValues));
10827
- const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
10828
- ...(_state.mount
10829
- ? _formValues
10830
- : isUndefined(defaultValue)
10831
- ? _defaultValues
10832
- : isString(names)
10833
- ? { [names]: defaultValue }
10834
- : defaultValue),
10835
- }, isGlobal, defaultValue);
10836
- const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
10837
- const setFieldValue = (name, value, options = {}) => {
10838
- const field = get(_fields, name);
10839
- let fieldValue = value;
10840
- if (field) {
10841
- const fieldReference = field._f;
10842
- if (fieldReference) {
10843
- !fieldReference.disabled &&
10844
- set(_formValues, name, getFieldValueAs(value, fieldReference));
10845
- fieldValue =
10846
- isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)
10847
- ? ''
10848
- : value;
10849
- if (isMultipleSelect(fieldReference.ref)) {
10850
- [...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));
10851
- }
10852
- else if (fieldReference.refs) {
10853
- if (isCheckBoxInput(fieldReference.ref)) {
10854
- fieldReference.refs.length > 1
10855
- ? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
10856
- (checkboxRef.checked = Array.isArray(fieldValue)
10857
- ? !!fieldValue.find((data) => data === checkboxRef.value)
10858
- : fieldValue === checkboxRef.value))
10859
- : fieldReference.refs[0] &&
10860
- (fieldReference.refs[0].checked = !!fieldValue);
10861
- }
10862
- else {
10863
- fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
10864
- }
10865
- }
10866
- else if (isFileInput(fieldReference.ref)) {
10867
- fieldReference.ref.value = '';
10868
- }
10869
- else {
10870
- fieldReference.ref.value = fieldValue;
10871
- if (!fieldReference.ref.type) {
10872
- _subjects.values.next({
10873
- name,
10874
- values: { ..._formValues },
10875
- });
10876
- }
10877
- }
10878
- }
10879
- }
10880
- (options.shouldDirty || options.shouldTouch) &&
10881
- updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
10882
- options.shouldValidate && trigger(name);
10883
- };
10884
- const setValues = (name, value, options) => {
10885
- for (const fieldKey in value) {
10886
- const fieldValue = value[fieldKey];
10887
- const fieldName = `${name}.${fieldKey}`;
10888
- const field = get(_fields, fieldName);
10889
- (_names.array.has(name) ||
10890
- !isPrimitive(fieldValue) ||
10891
- (field && !field._f)) &&
10892
- !isDateObject(fieldValue)
10893
- ? setValues(fieldName, fieldValue, options)
10894
- : setFieldValue(fieldName, fieldValue, options);
10895
- }
10896
- };
10897
- const setValue = (name, value, options = {}) => {
10898
- const field = get(_fields, name);
10899
- const isFieldArray = _names.array.has(name);
10900
- const cloneValue = cloneObject(value);
10901
- set(_formValues, name, cloneValue);
10902
- if (isFieldArray) {
10903
- _subjects.array.next({
10904
- name,
10905
- values: { ..._formValues },
10906
- });
10907
- if ((_proxyFormState.isDirty || _proxyFormState.dirtyFields) &&
10908
- options.shouldDirty) {
10909
- _subjects.state.next({
10910
- name,
10911
- dirtyFields: getDirtyFields(_defaultValues, _formValues),
10912
- isDirty: _getDirty(name, cloneValue),
10913
- });
10914
- }
10915
- }
10916
- else {
10917
- field && !field._f && !isNullOrUndefined(cloneValue)
10918
- ? setValues(name, cloneValue, options)
10919
- : setFieldValue(name, cloneValue, options);
10920
- }
10921
- isWatched(name, _names) && _subjects.state.next({ ..._formState });
10922
- _subjects.values.next({
10923
- name,
10924
- values: { ..._formValues },
10925
- });
10926
- !_state.mount && flushRootRender();
10927
- };
10928
- const onChange = async (event) => {
10929
- const target = event.target;
10930
- let name = target.name;
10931
- let isFieldValueUpdated = true;
10932
- const field = get(_fields, name);
10933
- const getCurrentFieldValue = () => target.type ? getFieldValue(field._f) : getEventValue(event);
10934
- if (field) {
10935
- let error;
10936
- let isValid;
10937
- const fieldValue = getCurrentFieldValue();
10938
- const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;
10939
- const shouldSkipValidation = (!hasValidation(field._f) &&
10940
- !_options.resolver &&
10941
- !get(_formState.errors, name) &&
10942
- !field._f.deps) ||
10943
- skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);
10944
- const watched = isWatched(name, _names, isBlurEvent);
10945
- set(_formValues, name, fieldValue);
10946
- if (isBlurEvent) {
10947
- field._f.onBlur && field._f.onBlur(event);
10948
- delayErrorCallback && delayErrorCallback(0);
10949
- }
10950
- else if (field._f.onChange) {
10951
- field._f.onChange(event);
10952
- }
10953
- const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent, false);
10954
- const shouldRender = !isEmptyObject(fieldState) || watched;
10955
- !isBlurEvent &&
10956
- _subjects.values.next({
10957
- name,
10958
- type: event.type,
10959
- values: { ..._formValues },
10960
- });
10961
- if (shouldSkipValidation) {
10962
- _proxyFormState.isValid && _updateValid();
10963
- return (shouldRender &&
10964
- _subjects.state.next({ name, ...(watched ? {} : fieldState) }));
10965
- }
10966
- !isBlurEvent && watched && _subjects.state.next({ ..._formState });
10967
- _updateIsValidating(true);
10968
- if (_options.resolver) {
10969
- const { errors } = await _executeSchema([name]);
10970
- const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
10971
- const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
10972
- error = errorLookupResult.error;
10973
- name = errorLookupResult.name;
10974
- isValid = isEmptyObject(errors);
10975
- }
10976
- else {
10977
- error = (await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
10978
- isFieldValueUpdated =
10979
- isNaN(fieldValue) ||
10980
- fieldValue === get(_formValues, name, fieldValue);
10981
- if (isFieldValueUpdated) {
10982
- if (error) {
10983
- isValid = false;
10984
- }
10985
- else if (_proxyFormState.isValid) {
10986
- isValid = await executeBuiltInValidation(_fields, true);
10987
- }
10988
- }
10989
- }
10990
- if (isFieldValueUpdated) {
10991
- field._f.deps &&
10992
- trigger(field._f.deps);
10993
- shouldRenderByError(name, isValid, error, fieldState);
10994
- }
10995
- }
10996
- };
10997
- const trigger = async (name, options = {}) => {
10998
- let isValid;
10999
- let validationResult;
11000
- const fieldNames = convertToArrayPayload(name);
11001
- _updateIsValidating(true);
11002
- if (_options.resolver) {
11003
- const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
11004
- isValid = isEmptyObject(errors);
11005
- validationResult = name
11006
- ? !fieldNames.some((name) => get(errors, name))
11007
- : isValid;
11008
- }
11009
- else if (name) {
11010
- validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
11011
- const field = get(_fields, fieldName);
11012
- return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
11013
- }))).every(Boolean);
11014
- !(!validationResult && !_formState.isValid) && _updateValid();
11015
- }
11016
- else {
11017
- validationResult = isValid = await executeBuiltInValidation(_fields);
11018
- }
11019
- _subjects.state.next({
11020
- ...(!isString(name) ||
11021
- (_proxyFormState.isValid && isValid !== _formState.isValid)
11022
- ? {}
11023
- : { name }),
11024
- ...(_options.resolver || !name ? { isValid } : {}),
11025
- errors: _formState.errors,
11026
- isValidating: false,
11027
- });
11028
- options.shouldFocus &&
11029
- !validationResult &&
11030
- focusFieldBy(_fields, (key) => key && get(_formState.errors, key), name ? fieldNames : _names.mount);
11031
- return validationResult;
11032
- };
11033
- const getValues = (fieldNames) => {
11034
- const values = {
11035
- ..._defaultValues,
11036
- ...(_state.mount ? _formValues : {}),
11037
- };
11038
- return isUndefined(fieldNames)
11039
- ? values
11040
- : isString(fieldNames)
11041
- ? get(values, fieldNames)
11042
- : fieldNames.map((name) => get(values, name));
11043
- };
11044
- const getFieldState = (name, formState) => ({
11045
- invalid: !!get((formState || _formState).errors, name),
11046
- isDirty: !!get((formState || _formState).dirtyFields, name),
11047
- isTouched: !!get((formState || _formState).touchedFields, name),
11048
- error: get((formState || _formState).errors, name),
11049
- });
11050
- const clearErrors = (name) => {
11051
- name &&
11052
- convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
11053
- _subjects.state.next({
11054
- errors: name ? _formState.errors : {},
11055
- });
11056
- };
11057
- const setError = (name, error, options) => {
11058
- const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
11059
- set(_formState.errors, name, {
11060
- ...error,
11061
- ref,
11062
- });
11063
- _subjects.state.next({
11064
- name,
11065
- errors: _formState.errors,
11066
- isValid: false,
11067
- });
11068
- options && options.shouldFocus && ref && ref.focus && ref.focus();
11069
- };
11070
- const watch = (name, defaultValue) => isFunction$1(name)
11071
- ? _subjects.values.subscribe({
11072
- next: (payload) => name(_getWatch(undefined, defaultValue), payload),
11073
- })
11074
- : _getWatch(name, defaultValue, true);
11075
- const unregister = (name, options = {}) => {
11076
- for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {
11077
- _names.mount.delete(fieldName);
11078
- _names.array.delete(fieldName);
11079
- if (!options.keepValue) {
11080
- unset(_fields, fieldName);
11081
- unset(_formValues, fieldName);
11082
- }
11083
- !options.keepError && unset(_formState.errors, fieldName);
11084
- !options.keepDirty && unset(_formState.dirtyFields, fieldName);
11085
- !options.keepTouched && unset(_formState.touchedFields, fieldName);
11086
- !_options.shouldUnregister &&
11087
- !options.keepDefaultValue &&
11088
- unset(_defaultValues, fieldName);
11089
- }
11090
- _subjects.values.next({
11091
- values: { ..._formValues },
11092
- });
11093
- _subjects.state.next({
11094
- ..._formState,
11095
- ...(!options.keepDirty ? {} : { isDirty: _getDirty() }),
11096
- });
11097
- !options.keepIsValid && _updateValid();
11098
- };
11099
- const register = (name, options = {}) => {
11100
- let field = get(_fields, name);
11101
- const disabledIsDefined = isBoolean(options.disabled);
11102
- set(_fields, name, {
11103
- ...(field || {}),
11104
- _f: {
11105
- ...(field && field._f ? field._f : { ref: { name } }),
11106
- name,
11107
- mount: true,
11108
- ...options,
11109
- },
11110
- });
11111
- _names.mount.add(name);
11112
- field
11113
- ? disabledIsDefined &&
11114
- set(_formValues, name, options.disabled
11115
- ? undefined
11116
- : get(_formValues, name, getFieldValue(field._f)))
11117
- : updateValidAndValue(name, true, options.value);
11118
- return {
11119
- ...(disabledIsDefined ? { disabled: options.disabled } : {}),
11120
- ...(_options.shouldUseNativeValidation
11121
- ? {
11122
- required: !!options.required,
11123
- min: getRuleValue(options.min),
11124
- max: getRuleValue(options.max),
11125
- minLength: getRuleValue(options.minLength),
11126
- maxLength: getRuleValue(options.maxLength),
11127
- pattern: getRuleValue(options.pattern),
11128
- }
11129
- : {}),
11130
- name,
11131
- onChange,
11132
- onBlur: onChange,
11133
- ref: (ref) => {
11134
- if (ref) {
11135
- register(name, options);
11136
- field = get(_fields, name);
11137
- const fieldRef = isUndefined(ref.value)
11138
- ? ref.querySelectorAll
11139
- ? ref.querySelectorAll('input,select,textarea')[0] || ref
11140
- : ref
11141
- : ref;
11142
- const radioOrCheckbox = isRadioOrCheckbox(fieldRef);
11143
- const refs = field._f.refs || [];
11144
- if (radioOrCheckbox
11145
- ? refs.find((option) => option === fieldRef)
11146
- : fieldRef === field._f.ref) {
11147
- return;
11148
- }
11149
- set(_fields, name, {
11150
- _f: {
11151
- ...field._f,
11152
- ...(radioOrCheckbox
11153
- ? {
11154
- refs: [
11155
- ...refs.filter(live),
11156
- fieldRef,
11157
- ...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
11158
- ],
11159
- ref: { type: fieldRef.type, name },
11160
- }
11161
- : { ref: fieldRef }),
11162
- },
11163
- });
11164
- updateValidAndValue(name, false, undefined, fieldRef);
11165
- }
11166
- else {
11167
- field = get(_fields, name, {});
11168
- if (field._f) {
11169
- field._f.mount = false;
11170
- }
11171
- (_options.shouldUnregister || options.shouldUnregister) &&
11172
- !(isNameInFieldArray(_names.array, name) && _state.action) &&
11173
- _names.unMount.add(name);
11174
- }
11175
- },
11176
- };
11177
- };
11178
- const _focusError = () => _options.shouldFocusError &&
11179
- focusFieldBy(_fields, (key) => key && get(_formState.errors, key), _names.mount);
11180
- const handleSubmit = (onValid, onInvalid) => async (e) => {
11181
- if (e) {
11182
- e.preventDefault && e.preventDefault();
11183
- e.persist && e.persist();
11184
- }
11185
- let fieldValues = cloneObject(_formValues);
11186
- _subjects.state.next({
11187
- isSubmitting: true,
11188
- });
11189
- if (_options.resolver) {
11190
- const { errors, values } = await _executeSchema();
11191
- _formState.errors = errors;
11192
- fieldValues = values;
11193
- }
11194
- else {
11195
- await executeBuiltInValidation(_fields);
11196
- }
11197
- unset(_formState.errors, 'root');
11198
- if (isEmptyObject(_formState.errors)) {
11199
- _subjects.state.next({
11200
- errors: {},
11201
- });
11202
- await onValid(fieldValues, e);
11203
- }
11204
- else {
11205
- if (onInvalid) {
11206
- await onInvalid({ ..._formState.errors }, e);
11207
- }
11208
- _focusError();
11209
- setTimeout(_focusError);
11210
- }
11211
- _subjects.state.next({
11212
- isSubmitted: true,
11213
- isSubmitting: false,
11214
- isSubmitSuccessful: isEmptyObject(_formState.errors),
11215
- submitCount: _formState.submitCount + 1,
11216
- errors: _formState.errors,
11217
- });
11218
- };
11219
- const resetField = (name, options = {}) => {
11220
- if (get(_fields, name)) {
11221
- if (isUndefined(options.defaultValue)) {
11222
- setValue(name, get(_defaultValues, name));
11223
- }
11224
- else {
11225
- setValue(name, options.defaultValue);
11226
- set(_defaultValues, name, options.defaultValue);
11227
- }
11228
- if (!options.keepTouched) {
11229
- unset(_formState.touchedFields, name);
11230
- }
11231
- if (!options.keepDirty) {
11232
- unset(_formState.dirtyFields, name);
11233
- _formState.isDirty = options.defaultValue
11234
- ? _getDirty(name, get(_defaultValues, name))
11235
- : _getDirty();
11236
- }
11237
- if (!options.keepError) {
11238
- unset(_formState.errors, name);
11239
- _proxyFormState.isValid && _updateValid();
11240
- }
11241
- _subjects.state.next({ ..._formState });
11242
- }
11243
- };
11244
- const _reset = (formValues, keepStateOptions = {}) => {
11245
- const updatedValues = formValues || _defaultValues;
11246
- const cloneUpdatedValues = cloneObject(updatedValues);
11247
- const values = formValues && !isEmptyObject(formValues)
11248
- ? cloneUpdatedValues
11249
- : _defaultValues;
11250
- if (!keepStateOptions.keepDefaultValues) {
11251
- _defaultValues = updatedValues;
11252
- }
11253
- if (!keepStateOptions.keepValues) {
11254
- if (keepStateOptions.keepDirtyValues || shouldCaptureDirtyFields) {
11255
- for (const fieldName of _names.mount) {
11256
- get(_formState.dirtyFields, fieldName)
11257
- ? set(values, fieldName, get(_formValues, fieldName))
11258
- : setValue(fieldName, get(values, fieldName));
11259
- }
11260
- }
11261
- else {
11262
- if (isWeb && isUndefined(formValues)) {
11263
- for (const name of _names.mount) {
11264
- const field = get(_fields, name);
11265
- if (field && field._f) {
11266
- const fieldReference = Array.isArray(field._f.refs)
11267
- ? field._f.refs[0]
11268
- : field._f.ref;
11269
- if (isHTMLElement(fieldReference)) {
11270
- const form = fieldReference.closest('form');
11271
- if (form) {
11272
- form.reset();
11273
- break;
11274
- }
11275
- }
11276
- }
11277
- }
11278
- }
11279
- _fields = {};
11280
- }
11281
- _formValues = props.shouldUnregister
11282
- ? keepStateOptions.keepDefaultValues
11283
- ? cloneObject(_defaultValues)
11284
- : {}
11285
- : cloneUpdatedValues;
11286
- _subjects.array.next({
11287
- values: { ...values },
11288
- });
11289
- _subjects.values.next({
11290
- values: { ...values },
11291
- });
11292
- }
11293
- _names = {
11294
- mount: new Set(),
11295
- unMount: new Set(),
11296
- array: new Set(),
11297
- watch: new Set(),
11298
- watchAll: false,
11299
- focus: '',
11300
- };
11301
- !_state.mount && flushRootRender();
11302
- _state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
11303
- _state.watch = !!props.shouldUnregister;
11304
- _subjects.state.next({
11305
- submitCount: keepStateOptions.keepSubmitCount
11306
- ? _formState.submitCount
11307
- : 0,
11308
- isDirty: keepStateOptions.keepDirty
11309
- ? _formState.isDirty
11310
- : !!(keepStateOptions.keepDefaultValues &&
11311
- !deepEqual(formValues, _defaultValues)),
11312
- isSubmitted: keepStateOptions.keepIsSubmitted
11313
- ? _formState.isSubmitted
11314
- : false,
11315
- dirtyFields: keepStateOptions.keepDirtyValues
11316
- ? _formState.dirtyFields
11317
- : keepStateOptions.keepDefaultValues && formValues
11318
- ? getDirtyFields(_defaultValues, formValues)
11319
- : {},
11320
- touchedFields: keepStateOptions.keepTouched
11321
- ? _formState.touchedFields
11322
- : {},
11323
- errors: keepStateOptions.keepErrors ? _formState.errors : {},
11324
- isSubmitting: false,
11325
- isSubmitSuccessful: false,
11326
- });
11327
- };
11328
- const reset = (formValues, keepStateOptions) => _reset(isFunction$1(formValues)
11329
- ? formValues(_formValues)
11330
- : formValues, keepStateOptions);
11331
- const setFocus = (name, options = {}) => {
11332
- const field = get(_fields, name);
11333
- const fieldReference = field && field._f;
11334
- if (fieldReference) {
11335
- const fieldRef = fieldReference.refs
11336
- ? fieldReference.refs[0]
11337
- : fieldReference.ref;
11338
- if (fieldRef.focus) {
11339
- fieldRef.focus();
11340
- options.shouldSelect && fieldRef.select();
11341
- }
11342
- }
11343
- };
11344
- const _updateFormState = (updatedFormState) => {
11345
- _formState = {
11346
- ..._formState,
11347
- ...updatedFormState,
11348
- };
11349
- };
11350
- const _resetDefaultValues = () => isFunction$1(_options.defaultValues) &&
11351
- _options.defaultValues().then((values) => {
11352
- reset(values, _options.resetOptions);
11353
- _subjects.state.next({
11354
- isLoading: false,
11355
- });
11356
- });
11357
- return {
11358
- control: {
11359
- register,
11360
- unregister,
11361
- getFieldState,
11362
- _executeSchema,
11363
- _getWatch,
11364
- _getDirty,
11365
- _updateValid,
11366
- _removeUnmounted,
11367
- _updateFieldArray,
11368
- _getFieldArray,
11369
- _reset,
11370
- _resetDefaultValues,
11371
- _updateFormState,
11372
- _subjects,
11373
- _proxyFormState,
11374
- get _fields() {
11375
- return _fields;
11376
- },
11377
- get _formValues() {
11378
- return _formValues;
11379
- },
11380
- get _state() {
11381
- return _state;
11382
- },
11383
- set _state(value) {
11384
- _state = value;
11385
- },
11386
- get _defaultValues() {
11387
- return _defaultValues;
11388
- },
11389
- get _names() {
11390
- return _names;
11391
- },
11392
- set _names(value) {
11393
- _names = value;
11394
- },
11395
- get _formState() {
11396
- return _formState;
11397
- },
11398
- set _formState(value) {
11399
- _formState = value;
11400
- },
11401
- get _options() {
11402
- return _options;
11403
- },
11404
- set _options(value) {
11405
- _options = {
11406
- ..._options,
11407
- ...value,
11408
- };
11409
- },
11410
- },
11411
- trigger,
11412
- register,
11413
- handleSubmit,
11414
- watch,
11415
- setValue,
11416
- getValues,
11417
- reset,
11418
- resetField,
11419
- clearErrors,
11420
- unregister,
11421
- setError,
11422
- setFocus,
11423
- getFieldState,
11424
- };
11425
- }
11426
-
11427
- /**
11428
- * Custom hook to manage the entire form.
11429
- *
11430
- * @remarks
11431
- * [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)
11432
- *
11433
- * @param props - form configuration and validation parameters.
11434
- *
11435
- * @returns methods - individual functions to manage the form state. {@link UseFormReturn}
11436
- *
11437
- * @example
11438
- * ```tsx
11439
- * function App() {
11440
- * const { register, handleSubmit, watch, formState: { errors } } = useForm();
11441
- * const onSubmit = data => console.log(data);
11442
- *
11443
- * console.log(watch("example"));
11444
- *
11445
- * return (
11446
- * <form onSubmit={handleSubmit(onSubmit)}>
11447
- * <input defaultValue="test" {...register("example")} />
11448
- * <input {...register("exampleRequired", { required: true })} />
11449
- * {errors.exampleRequired && <span>This field is required</span>}
11450
- * <input type="submit" />
11451
- * </form>
11452
- * );
11453
- * }
11454
- * ```
11455
- */
11456
- function useForm(props = {}) {
11457
- const _formControl = React__default["default"].useRef();
11458
- const [formState, updateFormState] = React__default["default"].useState({
11459
- isDirty: false,
11460
- isValidating: false,
11461
- isLoading: isFunction$1(props.defaultValues),
11462
- isSubmitted: false,
11463
- isSubmitting: false,
11464
- isSubmitSuccessful: false,
11465
- isValid: false,
11466
- submitCount: 0,
11467
- dirtyFields: {},
11468
- touchedFields: {},
11469
- errors: {},
11470
- defaultValues: isFunction$1(props.defaultValues)
11471
- ? undefined
11472
- : props.defaultValues,
11473
- });
11474
- if (!_formControl.current) {
11475
- _formControl.current = {
11476
- ...createFormControl(props, () => updateFormState((formState) => ({ ...formState }))),
11477
- formState,
11478
- };
11479
- }
11480
- const control = _formControl.current.control;
11481
- control._options = props;
11482
- useSubscribe({
11483
- subject: control._subjects.state,
11484
- next: (value) => {
11485
- if (shouldRenderFormState(value, control._proxyFormState, control._updateFormState, true)) {
11486
- updateFormState({ ...control._formState });
11487
- }
11488
- },
11489
- });
11490
- React__default["default"].useEffect(() => {
11491
- if (props.values && !deepEqual(props.values, control._defaultValues)) {
11492
- control._reset(props.values, control._options.resetOptions);
11493
- }
11494
- else {
11495
- control._resetDefaultValues();
11496
- }
11497
- }, [props.values, control]);
11498
- React__default["default"].useEffect(() => {
11499
- if (!control._state.mount) {
11500
- control._updateValid();
11501
- control._state.mount = true;
11502
- }
11503
- if (control._state.watch) {
11504
- control._state.watch = false;
11505
- control._subjects.state.next({ ...control._formState });
11506
- }
11507
- control._removeUnmounted();
11508
- });
11509
- _formControl.current.formState = getProxyFormState(formState, control);
11510
- return _formControl.current;
11511
- }
11512
-
11513
9805
  /******************************************************************************
11514
9806
  Copyright (c) Microsoft Corporation.
11515
9807
 
@@ -18817,10 +17109,7 @@ const UpdateSettingConfig = (obj, file, callback) => {
18817
17109
  formData.append(`Items[${index}].SortOrder`, item.SortOrder ?? 1);
18818
17110
  });
18819
17111
  if (file) {
18820
- formData.append("file", file);
18821
- }
18822
- else {
18823
- formData.append("file", '');
17112
+ formData.append("File", file);
18824
17113
  }
18825
17114
  const options = {
18826
17115
  method: 'POST',
@@ -18837,7 +17126,7 @@ const UpdateSettingConfig = (obj, file, callback) => {
18837
17126
 
18838
17127
  const SettingApp = (props) => {
18839
17128
  const { isOpen, eventChange, eventClose } = { ...props };
18840
- useForm({
17129
+ reactHookForm.useForm({
18841
17130
  mode: 'onChange'
18842
17131
  });
18843
17132
  const getWindowSize = () => {