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