@bonlineza/luxity-lib 2.36.1-beta.4 → 2.36.1

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.
Files changed (90) hide show
  1. package/Accordion.js +116 -76
  2. package/AddInterest.js +777 -440
  3. package/AddProductInterest.js +644 -485
  4. package/BrandSelector.js +336 -176
  5. package/Checkbox.js +101 -68
  6. package/CheckboxButton.js +124 -79
  7. package/CommunicationPreferenceOptionsRenderer.js +169 -159
  8. package/CommunicationPreferenceSection.js +178 -166
  9. package/CommunicationPreferences.js +427 -549
  10. package/ConditionSelector.js +336 -174
  11. package/CountryCodeSelect.js +10 -7
  12. package/CurrencyInputFormatter.js +56 -29
  13. package/CurrencySelect.js +49 -23
  14. package/DropdownSelector.js +92 -68
  15. package/GALink.js +16 -6
  16. package/GenderSelector.js +142 -88
  17. package/GraphQLDropdownSelector.js +1511 -933
  18. package/GraphQLMultiSelector.js +274 -141
  19. package/IconHeader.js +25 -11
  20. package/IconWrapper.js +7 -3
  21. package/InterestCatSelector.js +74 -34
  22. package/InterestItem.js +187 -103
  23. package/Interests.js +1466 -917
  24. package/InterestsSubheading.js +10 -5
  25. package/InvertedTextButton.js +63 -27
  26. package/LuxityAppSideNav.js +22 -19
  27. package/LuxityDesktopHeader.js +663 -549
  28. package/LuxityFooter.js +325 -434
  29. package/LuxityGraphQLDropdownSelector.js +1543 -949
  30. package/LuxityGraphQLMultiselector.js +321 -167
  31. package/LuxityMobileHeader.js +807 -681
  32. package/LuxityPageReady.js +136 -74
  33. package/LuxityProductInterestItem.js +175 -97
  34. package/LuxitySideNav.js +310 -382
  35. package/MaterialSelector.js +1550 -955
  36. package/ModelSelector.js +1550 -955
  37. package/NotificationDropDown.js +221 -122
  38. package/Notify.js +1 -0
  39. package/OutlinePrimaryButton.js +58 -26
  40. package/PriceRangeSelector.js +281 -168
  41. package/PrimaryButton.js +58 -26
  42. package/RadioButtons.js +140 -114
  43. package/RangeSlider.js +242 -152
  44. package/RareStepFooter.js +41 -27
  45. package/RareStepHeader.js +190 -139
  46. package/ReactSelectWrapper.js +1 -0
  47. package/SecondaryButton.js +58 -26
  48. package/ShoeSizeRangeSelector.js +260 -162
  49. package/ShoeSizeSelector.js +263 -158
  50. package/SimpleErrorBoundary.js +106 -59
  51. package/StyleSelector.js +336 -176
  52. package/TextButton.js +58 -26
  53. package/Tooltip.js +39 -17
  54. package/Tracking.js +1 -0
  55. package/WrapperButton.js +43 -20
  56. package/build/bundle.css +1 -1
  57. package/build/bundle.js +2973 -2457
  58. package/package.json +2 -3
  59. package/svg/Accessories.js +13 -6
  60. package/svg/Account.js +13 -6
  61. package/svg/Add.js +13 -6
  62. package/svg/ArrowRight.js +13 -6
  63. package/svg/Bags.js +13 -6
  64. package/svg/BurgerMenu.js +13 -6
  65. package/svg/Calendar.js +13 -6
  66. package/svg/CalendarCircled.js +13 -6
  67. package/svg/CheckCircled.js +13 -6
  68. package/svg/Close.js +13 -6
  69. package/svg/Clothing.js +13 -6
  70. package/svg/Dot.js +13 -6
  71. package/svg/Edit.js +13 -6
  72. package/svg/Eye.js +13 -6
  73. package/svg/FileAttach.js +13 -6
  74. package/svg/FileAttachCircled.js +13 -6
  75. package/svg/LightBulb.js +13 -6
  76. package/svg/Logo.js +13 -6
  77. package/svg/LuxityMenu.js +13 -6
  78. package/svg/Minus.js +13 -6
  79. package/svg/MobileAvatar.js +13 -6
  80. package/svg/MyOrder.js +13 -6
  81. package/svg/MyPayment.js +13 -6
  82. package/svg/MyProfile.js +14 -8
  83. package/svg/MySale.js +13 -6
  84. package/svg/Notification.js +13 -6
  85. package/svg/PointerDown.js +13 -6
  86. package/svg/Search.js +13 -6
  87. package/svg/Shoes.js +13 -6
  88. package/svg/SvgWrapper.js +7 -3
  89. package/svg/Trash.js +13 -6
  90. package/svg/Watches.js +13 -6
package/LuxityFooter.js CHANGED
@@ -7,69 +7,92 @@
7
7
  var React__default = 'default' in React ? React['default'] : React;
8
8
  var styled__default = 'default' in styled ? styled['default'] : styled;
9
9
 
10
- function _arrayLikeToArray(r, a) {
11
- (null == a || a > r.length) && (a = r.length);
12
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
13
- return n;
14
- }
15
- function _arrayWithHoles(r) {
16
- if (Array.isArray(r)) return r;
17
- }
18
10
  function _extends() {
19
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
20
- for (var e = 1; e < arguments.length; e++) {
21
- var t = arguments[e];
22
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
11
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
12
+ for (var i = 1; i < arguments.length; i++) {
13
+ var source = arguments[i];
14
+
15
+ for (var key in source) {
16
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
17
+ target[key] = source[key];
18
+ }
19
+ }
20
+ }
21
+
22
+ return target;
23
+ };
24
+ return _extends.apply(this, arguments);
25
+ }
26
+
27
+ function _taggedTemplateLiteral(strings, raw) {
28
+ if (!raw) {
29
+ raw = strings.slice(0);
30
+ }
31
+
32
+ return Object.freeze(Object.defineProperties(strings, {
33
+ raw: {
34
+ value: Object.freeze(raw)
23
35
  }
24
- return n;
25
- }, _extends.apply(null, arguments);
36
+ }));
26
37
  }
27
- function _iterableToArrayLimit(r, l) {
28
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
29
- if (null != t) {
30
- var e,
31
- n,
32
- i,
33
- u,
34
- a = [],
35
- f = !0,
36
- o = !1;
38
+
39
+ function _slicedToArray(arr, i) {
40
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
41
+ }
42
+
43
+ function _arrayWithHoles(arr) {
44
+ if (Array.isArray(arr)) return arr;
45
+ }
46
+
47
+ function _iterableToArrayLimit(arr, i) {
48
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
49
+
50
+ if (_i == null) return;
51
+ var _arr = [];
52
+ var _n = true;
53
+ var _d = false;
54
+
55
+ var _s, _e;
56
+
57
+ try {
58
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
59
+ _arr.push(_s.value);
60
+
61
+ if (i && _arr.length === i) break;
62
+ }
63
+ } catch (err) {
64
+ _d = true;
65
+ _e = err;
66
+ } finally {
37
67
  try {
38
- if (i = (t = t.call(r)).next, 0 === l) {
39
- if (Object(t) !== t) return;
40
- f = !1;
41
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
42
- } catch (r) {
43
- o = !0, n = r;
68
+ if (!_n && _i["return"] != null) _i["return"]();
44
69
  } finally {
45
- try {
46
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
47
- } finally {
48
- if (o) throw n;
49
- }
70
+ if (_d) throw _e;
50
71
  }
51
- return a;
52
72
  }
73
+
74
+ return _arr;
53
75
  }
54
- function _nonIterableRest() {
55
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
56
- }
57
- function _slicedToArray(r, e) {
58
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
76
+
77
+ function _unsupportedIterableToArray(o, minLen) {
78
+ if (!o) return;
79
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
80
+ var n = Object.prototype.toString.call(o).slice(8, -1);
81
+ if (n === "Object" && o.constructor) n = o.constructor.name;
82
+ if (n === "Map" || n === "Set") return Array.from(o);
83
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
59
84
  }
60
- function _taggedTemplateLiteral(e, t) {
61
- return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
62
- raw: {
63
- value: Object.freeze(t)
64
- }
65
- }));
85
+
86
+ function _arrayLikeToArray(arr, len) {
87
+ if (len == null || len > arr.length) len = arr.length;
88
+
89
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
90
+
91
+ return arr2;
66
92
  }
67
- function _unsupportedIterableToArray(r, a) {
68
- if (r) {
69
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
70
- var t = {}.toString.call(r).slice(8, -1);
71
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
72
- }
93
+
94
+ function _nonIterableRest() {
95
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
73
96
  }
74
97
 
75
98
  var isCheckBoxInput = (element) => element.type === 'checkbox';
@@ -106,14 +129,13 @@
106
129
  function cloneObject(data) {
107
130
  let copy;
108
131
  const isArray = Array.isArray(data);
109
- const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
110
132
  if (data instanceof Date) {
111
133
  copy = new Date(data);
112
134
  }
113
135
  else if (data instanceof Set) {
114
136
  copy = new Set(data);
115
137
  }
116
- else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
138
+ else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
117
139
  (isArray || isObject(data))) {
118
140
  copy = isArray ? [] : {};
119
141
  if (!isArray && !isPlainObject(data)) {
@@ -137,50 +159,18 @@
137
159
 
138
160
  var isUndefined = (val) => val === undefined;
139
161
 
140
- var get = (object, path, defaultValue) => {
141
- if (!path || !isObject(object)) {
162
+ var get = (obj, path, defaultValue) => {
163
+ if (!path || !isObject(obj)) {
142
164
  return defaultValue;
143
165
  }
144
- const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
145
- return isUndefined(result) || result === object
146
- ? isUndefined(object[path])
166
+ const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);
167
+ return isUndefined(result) || result === obj
168
+ ? isUndefined(obj[path])
147
169
  ? defaultValue
148
- : object[path]
170
+ : obj[path]
149
171
  : result;
150
172
  };
151
173
 
152
- var isBoolean = (value) => typeof value === 'boolean';
153
-
154
- var isKey = (value) => /^\w*$/.test(value);
155
-
156
- var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
157
-
158
- var set = (object, path, value) => {
159
- let index = -1;
160
- const tempPath = isKey(path) ? [path] : stringToPath(path);
161
- const length = tempPath.length;
162
- const lastIndex = length - 1;
163
- while (++index < length) {
164
- const key = tempPath[index];
165
- let newValue = value;
166
- if (index !== lastIndex) {
167
- const objValue = object[key];
168
- newValue =
169
- isObject(objValue) || Array.isArray(objValue)
170
- ? objValue
171
- : !isNaN(+tempPath[index + 1])
172
- ? []
173
- : {};
174
- }
175
- if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
176
- return;
177
- }
178
- object[key] = newValue;
179
- object = object[key];
180
- }
181
- return object;
182
- };
183
-
184
174
  const EVENTS = {
185
175
  BLUR: 'blur',
186
176
  FOCUS_OUT: 'focusout',
@@ -266,6 +256,33 @@
266
256
  return formValues;
267
257
  };
268
258
 
259
+ var isKey = (value) => /^\w*$/.test(value);
260
+
261
+ var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
262
+
263
+ function set(object, path, value) {
264
+ let index = -1;
265
+ const tempPath = isKey(path) ? [path] : stringToPath(path);
266
+ const length = tempPath.length;
267
+ const lastIndex = length - 1;
268
+ while (++index < length) {
269
+ const key = tempPath[index];
270
+ let newValue = value;
271
+ if (index !== lastIndex) {
272
+ const objValue = object[key];
273
+ newValue =
274
+ isObject(objValue) || Array.isArray(objValue)
275
+ ? objValue
276
+ : !isNaN(+tempPath[index + 1])
277
+ ? []
278
+ : {};
279
+ }
280
+ object[key] = newValue;
281
+ object = object[key];
282
+ }
283
+ return object;
284
+ }
285
+
269
286
  var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
270
287
  ? {
271
288
  ...errors[name],
@@ -276,6 +293,28 @@
276
293
  }
277
294
  : {};
278
295
 
296
+ const focusFieldBy = (fields, callback, fieldsNames) => {
297
+ for (const key of fieldsNames || Object.keys(fields)) {
298
+ const field = get(fields, key);
299
+ if (field) {
300
+ const { _f, ...currentField } = field;
301
+ if (_f && callback(_f.name)) {
302
+ if (_f.ref.focus) {
303
+ _f.ref.focus();
304
+ break;
305
+ }
306
+ else if (_f.refs && _f.refs[0].focus) {
307
+ _f.refs[0].focus();
308
+ break;
309
+ }
310
+ }
311
+ else if (isObject(currentField)) {
312
+ focusFieldBy(currentField, callback);
313
+ }
314
+ }
315
+ }
316
+ };
317
+
279
318
  var getValidationModes = (mode) => ({
280
319
  isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
281
320
  isOnBlur: mode === VALIDATION_MODE.onBlur,
@@ -290,41 +329,15 @@
290
329
  [..._names.watch].some((watchName) => name.startsWith(watchName) &&
291
330
  /^\.\w+/.test(name.slice(watchName.length))));
292
331
 
293
- const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
294
- for (const key of fieldsNames || Object.keys(fields)) {
295
- const field = get(fields, key);
296
- if (field) {
297
- const { _f, ...currentField } = field;
298
- if (_f) {
299
- if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {
300
- return true;
301
- }
302
- else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {
303
- return true;
304
- }
305
- else {
306
- if (iterateFieldsByAction(currentField, action)) {
307
- break;
308
- }
309
- }
310
- }
311
- else if (isObject(currentField)) {
312
- if (iterateFieldsByAction(currentField, action)) {
313
- break;
314
- }
315
- }
316
- }
317
- }
318
- return;
319
- };
320
-
321
332
  var updateFieldArrayRootError = (errors, error, name) => {
322
- const fieldArrayErrors = convertToArrayPayload(get(errors, name));
333
+ const fieldArrayErrors = compact(get(errors, name));
323
334
  set(fieldArrayErrors, 'root', error[name]);
324
335
  set(errors, name, fieldArrayErrors);
325
336
  return errors;
326
337
  };
327
338
 
339
+ var isBoolean = (value) => typeof value === 'boolean';
340
+
328
341
  var isFileInput = (element) => element.type === 'file';
329
342
 
330
343
  var isFunction = (value) => typeof value === 'function';
@@ -401,10 +414,10 @@
401
414
  message: '',
402
415
  };
403
416
 
404
- var validateField = async (field, disabledFieldNames, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
405
- const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, } = field._f;
417
+ var validateField = async (field, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
418
+ const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, disabled, } = field._f;
406
419
  const inputValue = get(formValues, name);
407
- if (!mount || disabledFieldNames.has(name)) {
420
+ if (!mount || disabled) {
408
421
  return {};
409
422
  }
410
423
  const inputRef = refs ? refs[0] : ref;
@@ -616,7 +629,7 @@
616
629
  return object;
617
630
  }
618
631
 
619
- var createSubject = () => {
632
+ function createSubject() {
620
633
  let _observers = [];
621
634
  const next = (value) => {
622
635
  for (const observer of _observers) {
@@ -642,7 +655,7 @@
642
655
  subscribe,
643
656
  unsubscribe,
644
657
  };
645
- };
658
+ }
646
659
 
647
660
  var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
648
661
 
@@ -749,6 +762,9 @@
749
762
 
750
763
  function getFieldValue(_f) {
751
764
  const ref = _f.ref;
765
+ if (_f.refs ? _f.refs.every((ref) => ref.disabled) : ref.disabled) {
766
+ return;
767
+ }
752
768
  if (isFileInput(ref)) {
753
769
  return ref.files;
754
770
  }
@@ -788,14 +804,6 @@
788
804
  : rule.value
789
805
  : rule;
790
806
 
791
- const ASYNC_FUNCTION = 'AsyncFunction';
792
- var hasPromiseValidation = (fieldReference) => !!fieldReference &&
793
- !!fieldReference.validate &&
794
- !!((isFunction(fieldReference.validate) &&
795
- fieldReference.validate.constructor.name === ASYNC_FUNCTION) ||
796
- (isObject(fieldReference.validate) &&
797
- Object.values(fieldReference.validate).find((validateFunction) => validateFunction.constructor.name === ASYNC_FUNCTION)));
798
-
799
807
  var hasValidation = (options) => options.mount &&
800
808
  (options.required ||
801
809
  options.min ||
@@ -857,7 +865,7 @@
857
865
  reValidateMode: VALIDATION_MODE.onChange,
858
866
  shouldFocusError: true,
859
867
  };
860
- function createFormControl(props = {}) {
868
+ function createFormControl(props = {}, flushRootRender) {
861
869
  let _options = {
862
870
  ...defaultOptions,
863
871
  ...props,
@@ -873,9 +881,7 @@
873
881
  isValid: false,
874
882
  touchedFields: {},
875
883
  dirtyFields: {},
876
- validatingFields: {},
877
- errors: _options.errors || {},
878
- disabled: _options.disabled || false,
884
+ errors: {},
879
885
  };
880
886
  let _fields = {};
881
887
  let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
@@ -891,7 +897,6 @@
891
897
  };
892
898
  let _names = {
893
899
  mount: new Set(),
894
- disabled: new Set(),
895
900
  unMount: new Set(),
896
901
  array: new Set(),
897
902
  watch: new Set(),
@@ -901,7 +906,6 @@
901
906
  const _proxyFormState = {
902
907
  isDirty: false,
903
908
  dirtyFields: false,
904
- validatingFields: false,
905
909
  touchedFields: false,
906
910
  isValidating: false,
907
911
  isValid: false,
@@ -912,6 +916,7 @@
912
916
  array: createSubject(),
913
917
  state: createSubject(),
914
918
  };
919
+ const shouldCaptureDirtyFields = props.resetOptions && props.resetOptions.keepDirtyValues;
915
920
  const validationModeBeforeSubmit = getValidationModes(_options.mode);
916
921
  const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
917
922
  const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
@@ -920,7 +925,7 @@
920
925
  timer = setTimeout(callback, wait);
921
926
  };
922
927
  const _updateValid = async (shouldUpdateValid) => {
923
- if (!_options.disabled && (_proxyFormState.isValid || shouldUpdateValid)) {
928
+ if (_proxyFormState.isValid || shouldUpdateValid) {
924
929
  const isValid = _options.resolver
925
930
  ? isEmptyObject((await _executeSchema()).errors)
926
931
  : await executeBuiltInValidation(_fields, true);
@@ -931,24 +936,12 @@
931
936
  }
932
937
  }
933
938
  };
934
- const _updateIsValidating = (names, isValidating) => {
935
- if (!_options.disabled &&
936
- (_proxyFormState.isValidating || _proxyFormState.validatingFields)) {
937
- (names || Array.from(_names.mount)).forEach((name) => {
938
- if (name) {
939
- isValidating
940
- ? set(_formState.validatingFields, name, isValidating)
941
- : unset(_formState.validatingFields, name);
942
- }
943
- });
944
- _subjects.state.next({
945
- validatingFields: _formState.validatingFields,
946
- isValidating: !isEmptyObject(_formState.validatingFields),
947
- });
948
- }
949
- };
939
+ const _updateIsValidating = (value) => _proxyFormState.isValidating &&
940
+ _subjects.state.next({
941
+ isValidating: value,
942
+ });
950
943
  const _updateFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
951
- if (args && method && !_options.disabled) {
944
+ if (args && method) {
952
945
  _state.action = true;
953
946
  if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
954
947
  const fieldValues = method(get(_fields, name), args.argA, args.argB);
@@ -987,13 +980,6 @@
987
980
  errors: _formState.errors,
988
981
  });
989
982
  };
990
- const _setErrors = (errors) => {
991
- _formState.errors = errors;
992
- _subjects.state.next({
993
- errors: _formState.errors,
994
- isValid: false,
995
- });
996
- };
997
983
  const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
998
984
  const field = get(_fields, name);
999
985
  if (field) {
@@ -1012,40 +998,35 @@
1012
998
  const output = {
1013
999
  name,
1014
1000
  };
1015
- if (!_options.disabled) {
1016
- const disabledField = !!(get(_fields, name) &&
1017
- get(_fields, name)._f &&
1018
- get(_fields, name)._f.disabled);
1019
- if (!isBlurEvent || shouldDirty) {
1020
- if (_proxyFormState.isDirty) {
1021
- isPreviousDirty = _formState.isDirty;
1022
- _formState.isDirty = output.isDirty = _getDirty();
1023
- shouldUpdateField = isPreviousDirty !== output.isDirty;
1024
- }
1025
- const isCurrentFieldPristine = disabledField || deepEqual(get(_defaultValues, name), fieldValue);
1026
- isPreviousDirty = !!(!disabledField && get(_formState.dirtyFields, name));
1027
- isCurrentFieldPristine || disabledField
1028
- ? unset(_formState.dirtyFields, name)
1029
- : set(_formState.dirtyFields, name, true);
1030
- output.dirtyFields = _formState.dirtyFields;
1001
+ if (!isBlurEvent || shouldDirty) {
1002
+ if (_proxyFormState.isDirty) {
1003
+ isPreviousDirty = _formState.isDirty;
1004
+ _formState.isDirty = output.isDirty = _getDirty();
1005
+ shouldUpdateField = isPreviousDirty !== output.isDirty;
1006
+ }
1007
+ const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);
1008
+ isPreviousDirty = get(_formState.dirtyFields, name);
1009
+ isCurrentFieldPristine
1010
+ ? unset(_formState.dirtyFields, name)
1011
+ : set(_formState.dirtyFields, name, true);
1012
+ output.dirtyFields = _formState.dirtyFields;
1013
+ shouldUpdateField =
1014
+ shouldUpdateField ||
1015
+ (_proxyFormState.dirtyFields &&
1016
+ isPreviousDirty !== !isCurrentFieldPristine);
1017
+ }
1018
+ if (isBlurEvent) {
1019
+ const isPreviousFieldTouched = get(_formState.touchedFields, name);
1020
+ if (!isPreviousFieldTouched) {
1021
+ set(_formState.touchedFields, name, isBlurEvent);
1022
+ output.touchedFields = _formState.touchedFields;
1031
1023
  shouldUpdateField =
1032
1024
  shouldUpdateField ||
1033
- (_proxyFormState.dirtyFields &&
1034
- isPreviousDirty !== !isCurrentFieldPristine);
1025
+ (_proxyFormState.touchedFields &&
1026
+ isPreviousFieldTouched !== isBlurEvent);
1035
1027
  }
1036
- if (isBlurEvent) {
1037
- const isPreviousFieldTouched = get(_formState.touchedFields, name);
1038
- if (!isPreviousFieldTouched) {
1039
- set(_formState.touchedFields, name, isBlurEvent);
1040
- output.touchedFields = _formState.touchedFields;
1041
- shouldUpdateField =
1042
- shouldUpdateField ||
1043
- (_proxyFormState.touchedFields &&
1044
- isPreviousFieldTouched !== isBlurEvent);
1045
- }
1046
- }
1047
- shouldUpdateField && shouldRender && _subjects.state.next(output);
1048
1028
  }
1029
+ shouldUpdateField && shouldRender && _subjects.state.next(output);
1049
1030
  return shouldUpdateField ? output : {};
1050
1031
  };
1051
1032
  const shouldRenderByError = (name, isValid, error, fieldState) => {
@@ -1053,9 +1034,9 @@
1053
1034
  const shouldUpdateValid = _proxyFormState.isValid &&
1054
1035
  isBoolean(isValid) &&
1055
1036
  _formState.isValid !== isValid;
1056
- if (_options.delayError && error) {
1037
+ if (props.delayError && error) {
1057
1038
  delayErrorCallback = debounce(() => updateErrors(name, error));
1058
- delayErrorCallback(_options.delayError);
1039
+ delayErrorCallback(props.delayError);
1059
1040
  }
1060
1041
  else {
1061
1042
  clearTimeout(timer);
@@ -1079,13 +1060,9 @@
1079
1060
  };
1080
1061
  _subjects.state.next(updatedFormState);
1081
1062
  }
1063
+ _updateIsValidating(false);
1082
1064
  };
1083
- const _executeSchema = async (name) => {
1084
- _updateIsValidating(name, true);
1085
- const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
1086
- _updateIsValidating(name);
1087
- return result;
1088
- };
1065
+ const _executeSchema = async (name) => _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
1089
1066
  const executeSchemaAndUpdateState = async (names) => {
1090
1067
  const { errors } = await _executeSchema(names);
1091
1068
  if (names) {
@@ -1110,14 +1087,7 @@
1110
1087
  const { _f, ...fieldValue } = field;
1111
1088
  if (_f) {
1112
1089
  const isFieldArrayRoot = _names.array.has(_f.name);
1113
- const isPromiseFunction = field._f && hasPromiseValidation(field._f);
1114
- if (isPromiseFunction && _proxyFormState.validatingFields) {
1115
- _updateIsValidating([name], true);
1116
- }
1117
- const fieldError = await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
1118
- if (isPromiseFunction && _proxyFormState.validatingFields) {
1119
- _updateIsValidating([name]);
1120
- }
1090
+ const fieldError = await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
1121
1091
  if (fieldError[_f.name]) {
1122
1092
  context.valid = false;
1123
1093
  if (shouldOnlyCheckValid) {
@@ -1131,7 +1101,7 @@
1131
1101
  : set(_formState.errors, _f.name, fieldError[_f.name])
1132
1102
  : unset(_formState.errors, _f.name));
1133
1103
  }
1134
- !isEmptyObject(fieldValue) &&
1104
+ fieldValue &&
1135
1105
  (await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
1136
1106
  }
1137
1107
  }
@@ -1148,9 +1118,8 @@
1148
1118
  }
1149
1119
  _names.unMount = new Set();
1150
1120
  };
1151
- const _getDirty = (name, data) => !_options.disabled &&
1152
- (name && data && set(_formValues, name, data),
1153
- !deepEqual(getValues(), _defaultValues));
1121
+ const _getDirty = (name, data) => (name && data && set(_formValues, name, data),
1122
+ !deepEqual(getValues(), _defaultValues));
1154
1123
  const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
1155
1124
  ...(_state.mount
1156
1125
  ? _formValues
@@ -1160,7 +1129,7 @@
1160
1129
  ? { [names]: defaultValue }
1161
1130
  : defaultValue),
1162
1131
  }, isGlobal, defaultValue);
1163
- const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, _options.shouldUnregister ? get(_defaultValues, name, []) : []));
1132
+ const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
1164
1133
  const setFieldValue = (name, value, options = {}) => {
1165
1134
  const field = get(_fields, name);
1166
1135
  let fieldValue = value;
@@ -1214,7 +1183,7 @@
1214
1183
  const fieldName = `${name}.${fieldKey}`;
1215
1184
  const field = get(_fields, fieldName);
1216
1185
  (_names.array.has(name) ||
1217
- isObject(fieldValue) ||
1186
+ !isPrimitive(fieldValue) ||
1218
1187
  (field && !field._f)) &&
1219
1188
  !isDateObject(fieldValue)
1220
1189
  ? setValues(fieldName, fieldValue, options)
@@ -1247,23 +1216,17 @@
1247
1216
  }
1248
1217
  isWatched(name, _names) && _subjects.state.next({ ..._formState });
1249
1218
  _subjects.values.next({
1250
- name: _state.mount ? name : undefined,
1219
+ name,
1251
1220
  values: { ..._formValues },
1252
1221
  });
1222
+ !_state.mount && flushRootRender();
1253
1223
  };
1254
1224
  const onChange = async (event) => {
1255
- _state.mount = true;
1256
1225
  const target = event.target;
1257
1226
  let name = target.name;
1258
1227
  let isFieldValueUpdated = true;
1259
1228
  const field = get(_fields, name);
1260
1229
  const getCurrentFieldValue = () => target.type ? getFieldValue(field._f) : getEventValue(event);
1261
- const _updateIsFieldValueUpdated = (fieldValue) => {
1262
- isFieldValueUpdated =
1263
- Number.isNaN(fieldValue) ||
1264
- (isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
1265
- deepEqual(fieldValue, get(_formValues, name, fieldValue));
1266
- };
1267
1230
  if (field) {
1268
1231
  let error;
1269
1232
  let isValid;
@@ -1292,34 +1255,25 @@
1292
1255
  values: { ..._formValues },
1293
1256
  });
1294
1257
  if (shouldSkipValidation) {
1295
- if (_proxyFormState.isValid) {
1296
- if (_options.mode === 'onBlur' && isBlurEvent) {
1297
- _updateValid();
1298
- }
1299
- else if (!isBlurEvent) {
1300
- _updateValid();
1301
- }
1302
- }
1258
+ _proxyFormState.isValid && _updateValid();
1303
1259
  return (shouldRender &&
1304
1260
  _subjects.state.next({ name, ...(watched ? {} : fieldState) }));
1305
1261
  }
1306
1262
  !isBlurEvent && watched && _subjects.state.next({ ..._formState });
1263
+ _updateIsValidating(true);
1307
1264
  if (_options.resolver) {
1308
1265
  const { errors } = await _executeSchema([name]);
1309
- _updateIsFieldValueUpdated(fieldValue);
1310
- if (isFieldValueUpdated) {
1311
- const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
1312
- const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
1313
- error = errorLookupResult.error;
1314
- name = errorLookupResult.name;
1315
- isValid = isEmptyObject(errors);
1316
- }
1266
+ const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
1267
+ const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
1268
+ error = errorLookupResult.error;
1269
+ name = errorLookupResult.name;
1270
+ isValid = isEmptyObject(errors);
1317
1271
  }
1318
1272
  else {
1319
- _updateIsValidating([name], true);
1320
- error = (await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
1321
- _updateIsValidating([name]);
1322
- _updateIsFieldValueUpdated(fieldValue);
1273
+ error = (await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
1274
+ isFieldValueUpdated =
1275
+ isNaN(fieldValue) ||
1276
+ fieldValue === get(_formValues, name, fieldValue);
1323
1277
  if (isFieldValueUpdated) {
1324
1278
  if (error) {
1325
1279
  isValid = false;
@@ -1336,17 +1290,11 @@
1336
1290
  }
1337
1291
  }
1338
1292
  };
1339
- const _focusInput = (ref, key) => {
1340
- if (get(_formState.errors, key) && ref.focus) {
1341
- ref.focus();
1342
- return 1;
1343
- }
1344
- return;
1345
- };
1346
1293
  const trigger = async (name, options = {}) => {
1347
1294
  let isValid;
1348
1295
  let validationResult;
1349
1296
  const fieldNames = convertToArrayPayload(name);
1297
+ _updateIsValidating(true);
1350
1298
  if (_options.resolver) {
1351
1299
  const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
1352
1300
  isValid = isEmptyObject(errors);
@@ -1371,15 +1319,17 @@
1371
1319
  : { name }),
1372
1320
  ...(_options.resolver || !name ? { isValid } : {}),
1373
1321
  errors: _formState.errors,
1322
+ isValidating: false,
1374
1323
  });
1375
1324
  options.shouldFocus &&
1376
1325
  !validationResult &&
1377
- iterateFieldsByAction(_fields, _focusInput, name ? fieldNames : _names.mount);
1326
+ focusFieldBy(_fields, (key) => key && get(_formState.errors, key), name ? fieldNames : _names.mount);
1378
1327
  return validationResult;
1379
1328
  };
1380
1329
  const getValues = (fieldNames) => {
1381
1330
  const values = {
1382
- ...(_state.mount ? _formValues : _defaultValues),
1331
+ ..._defaultValues,
1332
+ ...(_state.mount ? _formValues : {}),
1383
1333
  };
1384
1334
  return isUndefined(fieldNames)
1385
1335
  ? values
@@ -1390,9 +1340,8 @@
1390
1340
  const getFieldState = (name, formState) => ({
1391
1341
  invalid: !!get((formState || _formState).errors, name),
1392
1342
  isDirty: !!get((formState || _formState).dirtyFields, name),
1393
- error: get((formState || _formState).errors, name),
1394
- isValidating: !!get(_formState.validatingFields, name),
1395
1343
  isTouched: !!get((formState || _formState).touchedFields, name),
1344
+ error: get((formState || _formState).errors, name),
1396
1345
  });
1397
1346
  const clearErrors = (name) => {
1398
1347
  name &&
@@ -1403,11 +1352,7 @@
1403
1352
  };
1404
1353
  const setError = (name, error, options) => {
1405
1354
  const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
1406
- const currentError = get(_formState.errors, name) || {};
1407
- // Don't override existing error messages elsewhere in the object tree.
1408
- const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;
1409
1355
  set(_formState.errors, name, {
1410
- ...restOfErrorTree,
1411
1356
  ...error,
1412
1357
  ref,
1413
1358
  });
@@ -1434,8 +1379,6 @@
1434
1379
  !options.keepError && unset(_formState.errors, fieldName);
1435
1380
  !options.keepDirty && unset(_formState.dirtyFields, fieldName);
1436
1381
  !options.keepTouched && unset(_formState.touchedFields, fieldName);
1437
- !options.keepIsValidating &&
1438
- unset(_formState.validatingFields, fieldName);
1439
1382
  !_options.shouldUnregister &&
1440
1383
  !options.keepDefaultValue &&
1441
1384
  unset(_defaultValues, fieldName);
@@ -1450,16 +1393,17 @@
1450
1393
  !options.keepIsValid && _updateValid();
1451
1394
  };
1452
1395
  const _updateDisabledField = ({ disabled, name, field, fields, }) => {
1453
- if ((isBoolean(disabled) && _state.mount) ||
1454
- !!disabled ||
1455
- _names.disabled.has(name)) {
1456
- disabled ? _names.disabled.add(name) : _names.disabled.delete(name);
1457
- updateTouchAndDirty(name, getFieldValue(field ? field._f : get(fields, name)._f), false, false, true);
1396
+ if (isBoolean(disabled)) {
1397
+ const value = disabled
1398
+ ? undefined
1399
+ : get(_formValues, name, getFieldValue(field ? field._f : get(fields, name)._f));
1400
+ set(_formValues, name, value);
1401
+ updateTouchAndDirty(name, value, false, false, true);
1458
1402
  }
1459
1403
  };
1460
1404
  const register = (name, options = {}) => {
1461
1405
  let field = get(_fields, name);
1462
- const disabledIsDefined = isBoolean(options.disabled) || isBoolean(_options.disabled);
1406
+ const disabledIsDefined = isBoolean(options.disabled);
1463
1407
  set(_fields, name, {
1464
1408
  ...(field || {}),
1465
1409
  _f: {
@@ -1473,9 +1417,7 @@
1473
1417
  if (field) {
1474
1418
  _updateDisabledField({
1475
1419
  field,
1476
- disabled: isBoolean(options.disabled)
1477
- ? options.disabled
1478
- : _options.disabled,
1420
+ disabled: options.disabled,
1479
1421
  name,
1480
1422
  });
1481
1423
  }
@@ -1483,9 +1425,7 @@
1483
1425
  updateValidAndValue(name, true, options.value);
1484
1426
  }
1485
1427
  return {
1486
- ...(disabledIsDefined
1487
- ? { disabled: options.disabled || _options.disabled }
1488
- : {}),
1428
+ ...(disabledIsDefined ? { disabled: options.disabled } : {}),
1489
1429
  ...(_options.progressive
1490
1430
  ? {
1491
1431
  required: !!options.required,
@@ -1545,35 +1485,13 @@
1545
1485
  };
1546
1486
  };
1547
1487
  const _focusError = () => _options.shouldFocusError &&
1548
- iterateFieldsByAction(_fields, _focusInput, _names.mount);
1549
- const _disableForm = (disabled) => {
1550
- if (isBoolean(disabled)) {
1551
- _subjects.state.next({ disabled });
1552
- iterateFieldsByAction(_fields, (ref, name) => {
1553
- const currentField = get(_fields, name);
1554
- if (currentField) {
1555
- ref.disabled = currentField._f.disabled || disabled;
1556
- if (Array.isArray(currentField._f.refs)) {
1557
- currentField._f.refs.forEach((inputRef) => {
1558
- inputRef.disabled = currentField._f.disabled || disabled;
1559
- });
1560
- }
1561
- }
1562
- }, 0, false);
1563
- }
1564
- };
1488
+ focusFieldBy(_fields, (key) => key && get(_formState.errors, key), _names.mount);
1565
1489
  const handleSubmit = (onValid, onInvalid) => async (e) => {
1566
- let onValidError = undefined;
1567
1490
  if (e) {
1568
1491
  e.preventDefault && e.preventDefault();
1569
1492
  e.persist && e.persist();
1570
1493
  }
1571
1494
  let fieldValues = cloneObject(_formValues);
1572
- if (_names.disabled.size) {
1573
- for (const name of _names.disabled) {
1574
- set(fieldValues, name, undefined);
1575
- }
1576
- }
1577
1495
  _subjects.state.next({
1578
1496
  isSubmitting: true,
1579
1497
  });
@@ -1590,12 +1508,7 @@
1590
1508
  _subjects.state.next({
1591
1509
  errors: {},
1592
1510
  });
1593
- try {
1594
- await onValid(fieldValues, e);
1595
- }
1596
- catch (error) {
1597
- onValidError = error;
1598
- }
1511
+ await onValid(fieldValues, e);
1599
1512
  }
1600
1513
  else {
1601
1514
  if (onInvalid) {
@@ -1607,22 +1520,19 @@
1607
1520
  _subjects.state.next({
1608
1521
  isSubmitted: true,
1609
1522
  isSubmitting: false,
1610
- isSubmitSuccessful: isEmptyObject(_formState.errors) && !onValidError,
1523
+ isSubmitSuccessful: isEmptyObject(_formState.errors),
1611
1524
  submitCount: _formState.submitCount + 1,
1612
1525
  errors: _formState.errors,
1613
1526
  });
1614
- if (onValidError) {
1615
- throw onValidError;
1616
- }
1617
1527
  };
1618
1528
  const resetField = (name, options = {}) => {
1619
1529
  if (get(_fields, name)) {
1620
1530
  if (isUndefined(options.defaultValue)) {
1621
- setValue(name, cloneObject(get(_defaultValues, name)));
1531
+ setValue(name, get(_defaultValues, name));
1622
1532
  }
1623
1533
  else {
1624
1534
  setValue(name, options.defaultValue);
1625
- set(_defaultValues, name, cloneObject(options.defaultValue));
1535
+ set(_defaultValues, name, options.defaultValue);
1626
1536
  }
1627
1537
  if (!options.keepTouched) {
1628
1538
  unset(_formState.touchedFields, name);
@@ -1630,7 +1540,7 @@
1630
1540
  if (!options.keepDirty) {
1631
1541
  unset(_formState.dirtyFields, name);
1632
1542
  _formState.isDirty = options.defaultValue
1633
- ? _getDirty(name, cloneObject(get(_defaultValues, name)))
1543
+ ? _getDirty(name, get(_defaultValues, name))
1634
1544
  : _getDirty();
1635
1545
  }
1636
1546
  if (!options.keepError) {
@@ -1643,18 +1553,15 @@
1643
1553
  const _reset = (formValues, keepStateOptions = {}) => {
1644
1554
  const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;
1645
1555
  const cloneUpdatedValues = cloneObject(updatedValues);
1646
- const isEmptyResetValues = isEmptyObject(formValues);
1647
- const values = isEmptyResetValues ? _defaultValues : cloneUpdatedValues;
1556
+ const values = formValues && !isEmptyObject(formValues)
1557
+ ? cloneUpdatedValues
1558
+ : _defaultValues;
1648
1559
  if (!keepStateOptions.keepDefaultValues) {
1649
1560
  _defaultValues = updatedValues;
1650
1561
  }
1651
1562
  if (!keepStateOptions.keepValues) {
1652
- if (keepStateOptions.keepDirtyValues) {
1653
- const fieldsToCheck = new Set([
1654
- ..._names.mount,
1655
- ...Object.keys(getDirtyFields(_defaultValues, _formValues)),
1656
- ]);
1657
- for (const fieldName of Array.from(fieldsToCheck)) {
1563
+ if (keepStateOptions.keepDirtyValues || shouldCaptureDirtyFields) {
1564
+ for (const fieldName of _names.mount) {
1658
1565
  get(_formState.dirtyFields, fieldName)
1659
1566
  ? set(values, fieldName, get(_formValues, fieldName))
1660
1567
  : setValue(fieldName, get(values, fieldName));
@@ -1680,7 +1587,7 @@
1680
1587
  }
1681
1588
  _fields = {};
1682
1589
  }
1683
- _formValues = _options.shouldUnregister
1590
+ _formValues = props.shouldUnregister
1684
1591
  ? keepStateOptions.keepDefaultValues
1685
1592
  ? cloneObject(_defaultValues)
1686
1593
  : {}
@@ -1693,51 +1600,38 @@
1693
1600
  });
1694
1601
  }
1695
1602
  _names = {
1696
- mount: keepStateOptions.keepDirtyValues ? _names.mount : new Set(),
1603
+ mount: new Set(),
1697
1604
  unMount: new Set(),
1698
1605
  array: new Set(),
1699
- disabled: new Set(),
1700
1606
  watch: new Set(),
1701
1607
  watchAll: false,
1702
1608
  focus: '',
1703
1609
  };
1704
- _state.mount =
1705
- !_proxyFormState.isValid ||
1706
- !!keepStateOptions.keepIsValid ||
1707
- !!keepStateOptions.keepDirtyValues;
1708
- _state.watch = !!_options.shouldUnregister;
1610
+ !_state.mount && flushRootRender();
1611
+ _state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
1612
+ _state.watch = !!props.shouldUnregister;
1709
1613
  _subjects.state.next({
1710
1614
  submitCount: keepStateOptions.keepSubmitCount
1711
1615
  ? _formState.submitCount
1712
1616
  : 0,
1713
- isDirty: isEmptyResetValues
1714
- ? false
1715
- : keepStateOptions.keepDirty
1716
- ? _formState.isDirty
1717
- : !!(keepStateOptions.keepDefaultValues &&
1718
- !deepEqual(formValues, _defaultValues)),
1617
+ isDirty: keepStateOptions.keepDirty
1618
+ ? _formState.isDirty
1619
+ : !!(keepStateOptions.keepDefaultValues &&
1620
+ !deepEqual(formValues, _defaultValues)),
1719
1621
  isSubmitted: keepStateOptions.keepIsSubmitted
1720
1622
  ? _formState.isSubmitted
1721
1623
  : false,
1722
- dirtyFields: isEmptyResetValues
1723
- ? {}
1724
- : keepStateOptions.keepDirtyValues
1725
- ? keepStateOptions.keepDefaultValues && _formValues
1726
- ? getDirtyFields(_defaultValues, _formValues)
1727
- : _formState.dirtyFields
1728
- : keepStateOptions.keepDefaultValues && formValues
1729
- ? getDirtyFields(_defaultValues, formValues)
1730
- : keepStateOptions.keepDirty
1731
- ? _formState.dirtyFields
1732
- : {},
1624
+ dirtyFields: keepStateOptions.keepDirtyValues
1625
+ ? _formState.dirtyFields
1626
+ : keepStateOptions.keepDefaultValues && formValues
1627
+ ? getDirtyFields(_defaultValues, formValues)
1628
+ : {},
1733
1629
  touchedFields: keepStateOptions.keepTouched
1734
1630
  ? _formState.touchedFields
1735
1631
  : {},
1736
1632
  errors: keepStateOptions.keepErrors ? _formState.errors : {},
1737
- isSubmitSuccessful: keepStateOptions.keepIsSubmitSuccessful
1738
- ? _formState.isSubmitSuccessful
1739
- : false,
1740
1633
  isSubmitting: false,
1634
+ isSubmitSuccessful: false,
1741
1635
  });
1742
1636
  };
1743
1637
  const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues)
@@ -1752,9 +1646,7 @@
1752
1646
  : fieldReference.ref;
1753
1647
  if (fieldRef.focus) {
1754
1648
  fieldRef.focus();
1755
- options.shouldSelect &&
1756
- isFunction(fieldRef.select) &&
1757
- fieldRef.select();
1649
+ options.shouldSelect && fieldRef.select();
1758
1650
  }
1759
1651
  }
1760
1652
  };
@@ -1789,10 +1681,8 @@
1789
1681
  _reset,
1790
1682
  _resetDefaultValues,
1791
1683
  _updateFormState,
1792
- _disableForm,
1793
1684
  _subjects,
1794
1685
  _proxyFormState,
1795
- _setErrors,
1796
1686
  get _fields() {
1797
1687
  return _fields;
1798
1688
  },
@@ -1876,8 +1766,8 @@
1876
1766
  * ```
1877
1767
  */
1878
1768
  function useForm(props = {}) {
1879
- const _formControl = React__default.useRef(undefined);
1880
- const _values = React__default.useRef(undefined);
1769
+ const _formControl = React__default.useRef();
1770
+ const _values = React__default.useRef();
1881
1771
  const [formState, updateFormState] = React__default.useState({
1882
1772
  isDirty: false,
1883
1773
  isValidating: false,
@@ -1889,16 +1779,14 @@
1889
1779
  submitCount: 0,
1890
1780
  dirtyFields: {},
1891
1781
  touchedFields: {},
1892
- validatingFields: {},
1893
- errors: props.errors || {},
1894
- disabled: props.disabled || false,
1782
+ errors: {},
1895
1783
  defaultValues: isFunction(props.defaultValues)
1896
1784
  ? undefined
1897
1785
  : props.defaultValues,
1898
1786
  });
1899
1787
  if (!_formControl.current) {
1900
1788
  _formControl.current = {
1901
- ...createFormControl(props),
1789
+ ...createFormControl(props, () => updateFormState((formState) => ({ ...formState }))),
1902
1790
  formState,
1903
1791
  };
1904
1792
  }
@@ -1912,32 +1800,15 @@
1912
1800
  }
1913
1801
  },
1914
1802
  });
1915
- React__default.useEffect(() => control._disableForm(props.disabled), [control, props.disabled]);
1916
- React__default.useEffect(() => {
1917
- if (control._proxyFormState.isDirty) {
1918
- const isDirty = control._getDirty();
1919
- if (isDirty !== formState.isDirty) {
1920
- control._subjects.state.next({
1921
- isDirty,
1922
- });
1923
- }
1924
- }
1925
- }, [control, formState.isDirty]);
1926
1803
  React__default.useEffect(() => {
1927
1804
  if (props.values && !deepEqual(props.values, _values.current)) {
1928
1805
  control._reset(props.values, control._options.resetOptions);
1929
1806
  _values.current = props.values;
1930
- updateFormState((state) => ({ ...state }));
1931
1807
  }
1932
1808
  else {
1933
1809
  control._resetDefaultValues();
1934
1810
  }
1935
1811
  }, [props.values, control]);
1936
- React__default.useEffect(() => {
1937
- if (props.errors) {
1938
- control._setErrors(props.errors);
1939
- }
1940
- }, [props.errors, control]);
1941
1812
  React__default.useEffect(() => {
1942
1813
  if (!control._state.mount) {
1943
1814
  control._updateValid();
@@ -1949,12 +1820,6 @@
1949
1820
  }
1950
1821
  control._removeUnmounted();
1951
1822
  });
1952
- React__default.useEffect(() => {
1953
- props.shouldUnregister &&
1954
- control._subjects.values.next({
1955
- values: control._getWatch(),
1956
- });
1957
- }, [props.shouldUnregister, control]);
1958
1823
  _formControl.current.formState = getProxyFormState(formState, control);
1959
1824
  return _formControl.current;
1960
1825
  }
@@ -2033,6 +1898,7 @@
2033
1898
  var action = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
2034
1899
  var label = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
2035
1900
  var value = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
1901
+
2036
1902
  if (track) {
2037
1903
  instance.event({
2038
1904
  category: category,
@@ -2046,10 +1912,12 @@
2046
1912
  var GALink = function GALink(props) {
2047
1913
  var gaOnClick = function gaOnClick(event) {
2048
1914
  Event(props.instance, props.track, 'Link', "Click on ".concat(props.href), props.label);
1915
+
2049
1916
  if (typeof props.onClick === 'function') {
2050
1917
  props.onClick(event);
2051
1918
  }
2052
1919
  };
1920
+
2053
1921
  return /*#__PURE__*/React__default.createElement("a", _extends({
2054
1922
  href: "/"
2055
1923
  }, props, {
@@ -2058,8 +1926,8 @@
2058
1926
  };
2059
1927
 
2060
1928
  var _templateObject$1, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
2061
-
2062
1929
  /* position relative is required for the Body element to be positioned correctly */
1930
+
2063
1931
  var relativeInlineStyle = styled.css(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n position: relative;\n"])));
2064
1932
  var topMiddleBodyStyle = styled.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 1;\n bottom: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n"])));
2065
1933
  var getTopMiddleArrowAfterStyle = function getTopMiddleArrowAfterStyle(props) {
@@ -2073,31 +1941,40 @@
2073
1941
  };
2074
1942
 
2075
1943
  var _templateObject$2;
1944
+
2076
1945
  var getBodyStyle = function getBodyStyle() {
2077
1946
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2078
1947
  var _props$toolTipPositio = props.toolTipPosition,
2079
- toolTipPosition = _props$toolTipPositio === void 0 ? '' : _props$toolTipPositio;
1948
+ toolTipPosition = _props$toolTipPositio === void 0 ? '' : _props$toolTipPositio;
1949
+
2080
1950
  switch (toolTipPosition) {
2081
1951
  case 'top':
2082
1952
  return topMiddleBodyStyle;
1953
+
2083
1954
  case 'bottom':
2084
1955
  return getBottomMiddleBodyStyle(props);
1956
+
2085
1957
  default:
2086
1958
  return null;
2087
1959
  }
2088
1960
  };
1961
+
2089
1962
  var getAfterStyling = function getAfterStyling() {
2090
1963
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2091
1964
  var toolTipPosition = props.toolTipPosition;
1965
+
2092
1966
  switch (toolTipPosition) {
2093
1967
  case 'top':
2094
1968
  return getTopMiddleArrowAfterStyle(props);
1969
+
2095
1970
  case 'bottom':
2096
1971
  return getBottomMiddleArrowAfterStyle(props);
1972
+
2097
1973
  default:
2098
1974
  return '';
2099
1975
  }
2100
1976
  };
1977
+
2101
1978
  var Body = styled__default.span(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n ", ";\n visibility: hidden;\n opacity: 0;\n width: ", ";\n transition: visibility 0.3s linear, opacity 0.3s linear;\n background-color: ", ";\n color: white;\n text-align: center;\n border-radius: 5px;\n ", "\n &::after {\n content: ' ';\n position: absolute;\n ", "\n }\n"])), relativeInlineStyle, function (props) {
2102
1979
  return props.bodyWidth;
2103
1980
  }, function (props) {
@@ -2113,12 +1990,12 @@
2113
1990
 
2114
1991
  var Tooltip = function Tooltip(_ref) {
2115
1992
  var children = _ref.children,
2116
- toolTipText = _ref.toolTipText,
2117
- toolTipPosition = _ref.toolTipPosition,
2118
- bodyWidth = _ref.bodyWidth,
2119
- apexWidth = _ref.apexWidth,
2120
- containerClassName = _ref.containerClassName,
2121
- bodyClassName = _ref.bodyClassName;
1993
+ toolTipText = _ref.toolTipText,
1994
+ toolTipPosition = _ref.toolTipPosition,
1995
+ bodyWidth = _ref.bodyWidth,
1996
+ apexWidth = _ref.apexWidth,
1997
+ containerClassName = _ref.containerClassName,
1998
+ bodyClassName = _ref.bodyClassName;
2122
1999
  return /*#__PURE__*/React__default.createElement(Container, {
2123
2000
  className: containerClassName
2124
2001
  }, children, /*#__PURE__*/React__default.createElement(Body, {
@@ -2128,6 +2005,7 @@
2128
2005
  className: bodyClassName
2129
2006
  }, toolTipText));
2130
2007
  };
2008
+
2131
2009
  Tooltip.defaultProps = {
2132
2010
  children: null,
2133
2011
  toolTipText: '',
@@ -2141,21 +2019,25 @@
2141
2019
 
2142
2020
  var CurrencySelect = function CurrencySelect(_ref) {
2143
2021
  var currency = _ref.currency,
2144
- currencyOptions = _ref.currencyOptions,
2145
- onCurrencyChange = _ref.onCurrencyChange,
2146
- _ref$isCurrencySelect = _ref.isCurrencySelectionDisabled,
2147
- isCurrencySelectionDisabled = _ref$isCurrencySelect === void 0 ? false : _ref$isCurrencySelect,
2148
- _ref$tooltipContent = _ref.tooltipContent,
2149
- tooltipContent = _ref$tooltipContent === void 0 ? '' : _ref$tooltipContent;
2022
+ currencyOptions = _ref.currencyOptions,
2023
+ onCurrencyChange = _ref.onCurrencyChange,
2024
+ _ref$isCurrencySelect = _ref.isCurrencySelectionDisabled,
2025
+ isCurrencySelectionDisabled = _ref$isCurrencySelect === void 0 ? false : _ref$isCurrencySelect,
2026
+ _ref$tooltipContent = _ref.tooltipContent,
2027
+ tooltipContent = _ref$tooltipContent === void 0 ? '' : _ref$tooltipContent;
2028
+
2150
2029
  if (!currencyOptions || currencyOptions.length === 0) {
2151
2030
  return null;
2152
2031
  }
2032
+
2153
2033
  var selectedOption = currencyOptions.find(function (opt) {
2154
2034
  return opt.value === currency;
2155
2035
  });
2036
+
2156
2037
  if (!selectedOption) {
2157
2038
  return null;
2158
2039
  }
2040
+
2159
2041
  return /*#__PURE__*/React__default.createElement(Tooltip$1, {
2160
2042
  toolTipText: isCurrencySelectionDisabled ? tooltipContent : '',
2161
2043
  toolTipPosition: "bottom",
@@ -2184,47 +2066,49 @@
2184
2066
 
2185
2067
  var LuxityFooter = function LuxityFooter(_ref) {
2186
2068
  var _ref$showNewsletter = _ref.showNewsletter,
2187
- showNewsletter = _ref$showNewsletter === void 0 ? true : _ref$showNewsletter,
2188
- _ref$buyLinks = _ref.buyLinks,
2189
- buyLinks = _ref$buyLinks === void 0 ? [] : _ref$buyLinks,
2190
- _ref$sellLinks = _ref.sellLinks,
2191
- sellLinks = _ref$sellLinks === void 0 ? [] : _ref$sellLinks,
2192
- _ref$companyLinks = _ref.companyLinks,
2193
- companyLinks = _ref$companyLinks === void 0 ? [] : _ref$companyLinks,
2194
- _ref$storeLinks = _ref.storeLinks,
2195
- storeLinks = _ref$storeLinks === void 0 ? [] : _ref$storeLinks,
2196
- _ref$popularLinks = _ref.popularLinks,
2197
- popularLinks = _ref$popularLinks === void 0 ? [] : _ref$popularLinks,
2198
- _ref$socialLinks = _ref.socialLinks,
2199
- socialLinks = _ref$socialLinks === void 0 ? [] : _ref$socialLinks,
2200
- _ref$contactLinks = _ref.contactLinks,
2201
- contactLinks = _ref$contactLinks === void 0 ? [] : _ref$contactLinks,
2202
- visaImgSrc = _ref.visaImgSrc,
2203
- masterCardSrc = _ref.masterCardSrc,
2204
- paypalImgSrc = _ref.paypalImgSrc,
2205
- logoSrc = _ref.logoSrc,
2206
- formIconSrc = _ref.formIconSrc,
2207
- onSubmit = _ref.onSubmit,
2208
- currency = _ref.currency,
2209
- currencyOptions = _ref.currencyOptions,
2210
- onCurrencyChange = _ref.onCurrencyChange,
2211
- isCurrencySelectionDisabled = _ref.isCurrencySelectionDisabled,
2212
- tooltipContent = _ref.tooltipContent;
2069
+ showNewsletter = _ref$showNewsletter === void 0 ? true : _ref$showNewsletter,
2070
+ _ref$buyLinks = _ref.buyLinks,
2071
+ buyLinks = _ref$buyLinks === void 0 ? [] : _ref$buyLinks,
2072
+ _ref$sellLinks = _ref.sellLinks,
2073
+ sellLinks = _ref$sellLinks === void 0 ? [] : _ref$sellLinks,
2074
+ _ref$companyLinks = _ref.companyLinks,
2075
+ companyLinks = _ref$companyLinks === void 0 ? [] : _ref$companyLinks,
2076
+ _ref$storeLinks = _ref.storeLinks,
2077
+ storeLinks = _ref$storeLinks === void 0 ? [] : _ref$storeLinks,
2078
+ _ref$popularLinks = _ref.popularLinks,
2079
+ popularLinks = _ref$popularLinks === void 0 ? [] : _ref$popularLinks,
2080
+ _ref$socialLinks = _ref.socialLinks,
2081
+ socialLinks = _ref$socialLinks === void 0 ? [] : _ref$socialLinks,
2082
+ _ref$contactLinks = _ref.contactLinks,
2083
+ contactLinks = _ref$contactLinks === void 0 ? [] : _ref$contactLinks,
2084
+ visaImgSrc = _ref.visaImgSrc,
2085
+ masterCardSrc = _ref.masterCardSrc,
2086
+ paypalImgSrc = _ref.paypalImgSrc,
2087
+ logoSrc = _ref.logoSrc,
2088
+ formIconSrc = _ref.formIconSrc,
2089
+ onSubmit = _ref.onSubmit,
2090
+ currency = _ref.currency,
2091
+ currencyOptions = _ref.currencyOptions,
2092
+ onCurrencyChange = _ref.onCurrencyChange,
2093
+ isCurrencySelectionDisabled = _ref.isCurrencySelectionDisabled,
2094
+ tooltipContent = _ref.tooltipContent;
2213
2095
  var currentYear = new Date().getFullYear();
2096
+
2214
2097
  var _useForm = useForm(),
2215
- handleSubmit = _useForm.handleSubmit,
2216
- register = _useForm.register,
2217
- errors = _useForm.formState.errors,
2218
- reset = _useForm.reset,
2219
- setError = _useForm.setError;
2098
+ handleSubmit = _useForm.handleSubmit,
2099
+ register = _useForm.register,
2100
+ errors = _useForm.formState.errors,
2101
+ reset = _useForm.reset,
2102
+ setError = _useForm.setError;
2103
+
2220
2104
  var renderLinks = function renderLinks(links, title) {
2221
- return /*#__PURE__*/React__default.createElement("div", {
2105
+ return !!links.length && /*#__PURE__*/React__default.createElement("div", {
2222
2106
  className: "footer__link-container"
2223
2107
  }, /*#__PURE__*/React__default.createElement("div", {
2224
2108
  className: "footer__link-title"
2225
2109
  }, title), /*#__PURE__*/React__default.createElement("div", {
2226
2110
  className: "footer__links"
2227
- }, !!links.length && links.map(function (link) {
2111
+ }, links.map(function (link) {
2228
2112
  return /*#__PURE__*/React__default.createElement("div", {
2229
2113
  className: "footer__link-wrapper",
2230
2114
  key: link.label
@@ -2245,6 +2129,7 @@
2245
2129
  }), link.label));
2246
2130
  })));
2247
2131
  };
2132
+
2248
2133
  var renderSocialLinks = function renderSocialLinks(links) {
2249
2134
  return /*#__PURE__*/React__default.createElement("div", {
2250
2135
  className: "footer__link-container"
@@ -2281,13 +2166,16 @@
2281
2166
  }, link.label);
2282
2167
  })));
2283
2168
  };
2169
+
2284
2170
  var AccordionSection = function AccordionSection(_ref2) {
2285
2171
  var title = _ref2.title,
2286
- links = _ref2.links;
2172
+ links = _ref2.links;
2173
+
2287
2174
  var _useState = React.useState(false),
2288
- _useState2 = _slicedToArray(_useState, 2),
2289
- isOpen = _useState2[0],
2290
- setIsOpen = _useState2[1];
2175
+ _useState2 = _slicedToArray(_useState, 2),
2176
+ isOpen = _useState2[0],
2177
+ setIsOpen = _useState2[1];
2178
+
2291
2179
  var contentRef = React.useRef(null);
2292
2180
  return /*#__PURE__*/React__default.createElement("div", {
2293
2181
  className: "border-b border-gray-200"
@@ -2313,6 +2201,7 @@
2313
2201
  }, link.label);
2314
2202
  })));
2315
2203
  };
2204
+
2316
2205
  var submitForm = function submitForm(data) {
2317
2206
  onSubmit(data).then(function (res) {
2318
2207
  if (res.success) {
@@ -2325,6 +2214,7 @@
2325
2214
  }
2326
2215
  });
2327
2216
  };
2217
+
2328
2218
  return /*#__PURE__*/React__default.createElement(FooterWrapper, null, showNewsletter && /*#__PURE__*/React__default.createElement("div", {
2329
2219
  className: "footer__newsletter-section"
2330
2220
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -2401,13 +2291,13 @@
2401
2291
  }), /*#__PURE__*/React__default.createElement(AccordionSection, {
2402
2292
  title: "POPULAR",
2403
2293
  links: popularLinks
2404
- }), /*#__PURE__*/React__default.createElement(AccordionSection, {
2294
+ }), !!sellLinks.length && /*#__PURE__*/React__default.createElement(AccordionSection, {
2405
2295
  title: "SELL",
2406
2296
  links: sellLinks
2407
2297
  }), /*#__PURE__*/React__default.createElement(AccordionSection, {
2408
2298
  title: "COMPANY",
2409
2299
  links: companyLinks
2410
- }), /*#__PURE__*/React__default.createElement(AccordionSection, {
2300
+ }), !!storeLinks.length && /*#__PURE__*/React__default.createElement(AccordionSection, {
2411
2301
  title: "CONNECT",
2412
2302
  links: storeLinks
2413
2303
  }), /*#__PURE__*/React__default.createElement("div", {
@@ -2416,6 +2306,7 @@
2416
2306
  className: "footer__copyright footer__copyright--mobile"
2417
2307
  }, "Copyright ", currentYear, " | Luxity (Pty) LTD | All Rights Reserved")));
2418
2308
  };
2309
+
2419
2310
  var index = themed(LuxityFooter);
2420
2311
 
2421
2312
  return index;