@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.
- package/Accordion.js +116 -76
- package/AddInterest.js +777 -440
- package/AddProductInterest.js +644 -485
- package/BrandSelector.js +336 -176
- package/Checkbox.js +101 -68
- package/CheckboxButton.js +124 -79
- package/CommunicationPreferenceOptionsRenderer.js +169 -159
- package/CommunicationPreferenceSection.js +178 -166
- package/CommunicationPreferences.js +427 -549
- package/ConditionSelector.js +336 -174
- package/CountryCodeSelect.js +10 -7
- package/CurrencyInputFormatter.js +56 -29
- package/CurrencySelect.js +49 -23
- package/DropdownSelector.js +92 -68
- package/GALink.js +16 -6
- package/GenderSelector.js +142 -88
- package/GraphQLDropdownSelector.js +1511 -933
- package/GraphQLMultiSelector.js +274 -141
- package/IconHeader.js +25 -11
- package/IconWrapper.js +7 -3
- package/InterestCatSelector.js +74 -34
- package/InterestItem.js +187 -103
- package/Interests.js +1466 -917
- package/InterestsSubheading.js +10 -5
- package/InvertedTextButton.js +63 -27
- package/LuxityAppSideNav.js +22 -19
- package/LuxityDesktopHeader.js +663 -549
- package/LuxityFooter.js +325 -434
- package/LuxityGraphQLDropdownSelector.js +1543 -949
- package/LuxityGraphQLMultiselector.js +321 -167
- package/LuxityMobileHeader.js +807 -681
- package/LuxityPageReady.js +136 -74
- package/LuxityProductInterestItem.js +175 -97
- package/LuxitySideNav.js +310 -382
- package/MaterialSelector.js +1550 -955
- package/ModelSelector.js +1550 -955
- package/NotificationDropDown.js +221 -122
- package/Notify.js +1 -0
- package/OutlinePrimaryButton.js +58 -26
- package/PriceRangeSelector.js +281 -168
- package/PrimaryButton.js +58 -26
- package/RadioButtons.js +140 -114
- package/RangeSlider.js +242 -152
- package/RareStepFooter.js +41 -27
- package/RareStepHeader.js +190 -139
- package/ReactSelectWrapper.js +1 -0
- package/SecondaryButton.js +58 -26
- package/ShoeSizeRangeSelector.js +260 -162
- package/ShoeSizeSelector.js +263 -158
- package/SimpleErrorBoundary.js +106 -59
- package/StyleSelector.js +336 -176
- package/TextButton.js +58 -26
- package/Tooltip.js +39 -17
- package/Tracking.js +1 -0
- package/WrapperButton.js +43 -20
- package/build/bundle.css +1 -1
- package/build/bundle.js +2973 -2457
- package/package.json +2 -3
- package/svg/Accessories.js +13 -6
- package/svg/Account.js +13 -6
- package/svg/Add.js +13 -6
- package/svg/ArrowRight.js +13 -6
- package/svg/Bags.js +13 -6
- package/svg/BurgerMenu.js +13 -6
- package/svg/Calendar.js +13 -6
- package/svg/CalendarCircled.js +13 -6
- package/svg/CheckCircled.js +13 -6
- package/svg/Close.js +13 -6
- package/svg/Clothing.js +13 -6
- package/svg/Dot.js +13 -6
- package/svg/Edit.js +13 -6
- package/svg/Eye.js +13 -6
- package/svg/FileAttach.js +13 -6
- package/svg/FileAttachCircled.js +13 -6
- package/svg/LightBulb.js +13 -6
- package/svg/Logo.js +13 -6
- package/svg/LuxityMenu.js +13 -6
- package/svg/Minus.js +13 -6
- package/svg/MobileAvatar.js +13 -6
- package/svg/MyOrder.js +13 -6
- package/svg/MyPayment.js +13 -6
- package/svg/MyProfile.js +14 -8
- package/svg/MySale.js +13 -6
- package/svg/Notification.js +13 -6
- package/svg/PointerDown.js +13 -6
- package/svg/Search.js +13 -6
- package/svg/Shoes.js +13 -6
- package/svg/SvgWrapper.js +7 -3
- package/svg/Trash.js +13 -6
- 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
|
-
|
|
20
|
-
for (var
|
|
21
|
-
var
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
}, _extends.apply(null, arguments);
|
|
36
|
+
}));
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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 ||
|
|
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 = (
|
|
141
|
-
if (!path || !isObject(
|
|
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],
|
|
145
|
-
return isUndefined(result) || result ===
|
|
146
|
-
? isUndefined(
|
|
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
|
-
:
|
|
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 =
|
|
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,
|
|
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 ||
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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 = (
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
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
|
|
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 (!
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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.
|
|
1034
|
-
|
|
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 (
|
|
1037
|
+
if (props.delayError && error) {
|
|
1057
1038
|
delayErrorCallback = debounce(() => updateErrors(name, error));
|
|
1058
|
-
delayErrorCallback(
|
|
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
|
|
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
|
-
|
|
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) =>
|
|
1152
|
-
(
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
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
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
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 (
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
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)
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
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,
|
|
1531
|
+
setValue(name, get(_defaultValues, name));
|
|
1622
1532
|
}
|
|
1623
1533
|
else {
|
|
1624
1534
|
setValue(name, options.defaultValue);
|
|
1625
|
-
set(_defaultValues, name,
|
|
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,
|
|
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
|
|
1647
|
-
|
|
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
|
|
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 =
|
|
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:
|
|
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
|
-
|
|
1706
|
-
|
|
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:
|
|
1714
|
-
?
|
|
1715
|
-
: keepStateOptions.
|
|
1716
|
-
|
|
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:
|
|
1723
|
-
?
|
|
1724
|
-
: keepStateOptions.
|
|
1725
|
-
?
|
|
1726
|
-
|
|
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(
|
|
1880
|
-
const _values = React__default.useRef(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
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
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
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
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
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
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
2172
|
+
links = _ref2.links;
|
|
2173
|
+
|
|
2287
2174
|
var _useState = React.useState(false),
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
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;
|