@itcase/forms 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/form/Field/Input/Input.css +1 -1
- package/dist/css/form/FormField/FormField.css +2 -3
- package/dist/itcase-forms.cjs.js +971 -1511
- package/dist/itcase-forms.esm.js +971 -1511
- package/package.json +23 -26
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -42,28 +42,25 @@ var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
|
42
42
|
var castArray__default = /*#__PURE__*/_interopDefault(castArray);
|
|
43
43
|
var createDecorator__default = /*#__PURE__*/_interopDefault(createDecorator);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
const phoneValidation = (value, context) => {
|
|
46
46
|
if (!value) {
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
49
|
return libphonenumberJs.isPossiblePhoneNumber(value, 'RU');
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
const emailValidation = (value, context) => {
|
|
52
52
|
// from https://emailregex.com/
|
|
53
53
|
if (!value) {
|
|
54
54
|
return true;
|
|
55
55
|
}
|
|
56
56
|
// eslint-disable-next-line
|
|
57
|
-
|
|
57
|
+
const regexp = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/;
|
|
58
58
|
return regexp.test(String(value).toLowerCase());
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
schema.requiredFields = fields.reduce(
|
|
63
|
-
|
|
64
|
-
var fieldName = _ref[0],
|
|
65
|
-
validationProps = _ref[1];
|
|
66
|
-
if ((_validationProps$excl = validationProps.exclusiveTests) != null && _validationProps$excl.required) {
|
|
60
|
+
const addRequiredFieldsParamToSchema = schema => {
|
|
61
|
+
const fields = Object.entries(schema.fields);
|
|
62
|
+
schema.requiredFields = fields.reduce((list, [fieldName, validationProps]) => {
|
|
63
|
+
if (validationProps.exclusiveTests?.required) {
|
|
67
64
|
list.push(fieldName);
|
|
68
65
|
}
|
|
69
66
|
return list;
|
|
@@ -71,382 +68,6 @@ var addRequiredFieldsParamToSchema = function addRequiredFieldsParamToSchema(sch
|
|
|
71
68
|
return schema;
|
|
72
69
|
};
|
|
73
70
|
|
|
74
|
-
function _asyncIterator(r) {
|
|
75
|
-
var n,
|
|
76
|
-
t,
|
|
77
|
-
o,
|
|
78
|
-
e = 2;
|
|
79
|
-
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
|
|
80
|
-
if (t && null != (n = r[t])) return n.call(r);
|
|
81
|
-
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
|
82
|
-
t = "@@asyncIterator", o = "@@iterator";
|
|
83
|
-
}
|
|
84
|
-
throw new TypeError("Object is not async iterable");
|
|
85
|
-
}
|
|
86
|
-
function AsyncFromSyncIterator(r) {
|
|
87
|
-
function AsyncFromSyncIteratorContinuation(r) {
|
|
88
|
-
if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
|
|
89
|
-
var n = r.done;
|
|
90
|
-
return Promise.resolve(r.value).then(function (r) {
|
|
91
|
-
return {
|
|
92
|
-
value: r,
|
|
93
|
-
done: n
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return AsyncFromSyncIterator = function (r) {
|
|
98
|
-
this.s = r, this.n = r.next;
|
|
99
|
-
}, AsyncFromSyncIterator.prototype = {
|
|
100
|
-
s: null,
|
|
101
|
-
n: null,
|
|
102
|
-
next: function () {
|
|
103
|
-
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
104
|
-
},
|
|
105
|
-
return: function (r) {
|
|
106
|
-
var n = this.s.return;
|
|
107
|
-
return void 0 === n ? Promise.resolve({
|
|
108
|
-
value: r,
|
|
109
|
-
done: !0
|
|
110
|
-
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
111
|
-
},
|
|
112
|
-
throw: function (r) {
|
|
113
|
-
var n = this.s.return;
|
|
114
|
-
return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
115
|
-
}
|
|
116
|
-
}, new AsyncFromSyncIterator(r);
|
|
117
|
-
}
|
|
118
|
-
function _regeneratorRuntime() {
|
|
119
|
-
_regeneratorRuntime = function () {
|
|
120
|
-
return e;
|
|
121
|
-
};
|
|
122
|
-
var t,
|
|
123
|
-
e = {},
|
|
124
|
-
r = Object.prototype,
|
|
125
|
-
n = r.hasOwnProperty,
|
|
126
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
127
|
-
t[e] = r.value;
|
|
128
|
-
},
|
|
129
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
130
|
-
a = i.iterator || "@@iterator",
|
|
131
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
132
|
-
u = i.toStringTag || "@@toStringTag";
|
|
133
|
-
function define(t, e, r) {
|
|
134
|
-
return Object.defineProperty(t, e, {
|
|
135
|
-
value: r,
|
|
136
|
-
enumerable: !0,
|
|
137
|
-
configurable: !0,
|
|
138
|
-
writable: !0
|
|
139
|
-
}), t[e];
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
define({}, "");
|
|
143
|
-
} catch (t) {
|
|
144
|
-
define = function (t, e, r) {
|
|
145
|
-
return t[e] = r;
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function wrap(t, e, r, n) {
|
|
149
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
150
|
-
a = Object.create(i.prototype),
|
|
151
|
-
c = new Context(n || []);
|
|
152
|
-
return o(a, "_invoke", {
|
|
153
|
-
value: makeInvokeMethod(t, r, c)
|
|
154
|
-
}), a;
|
|
155
|
-
}
|
|
156
|
-
function tryCatch(t, e, r) {
|
|
157
|
-
try {
|
|
158
|
-
return {
|
|
159
|
-
type: "normal",
|
|
160
|
-
arg: t.call(e, r)
|
|
161
|
-
};
|
|
162
|
-
} catch (t) {
|
|
163
|
-
return {
|
|
164
|
-
type: "throw",
|
|
165
|
-
arg: t
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
e.wrap = wrap;
|
|
170
|
-
var h = "suspendedStart",
|
|
171
|
-
l = "suspendedYield",
|
|
172
|
-
f = "executing",
|
|
173
|
-
s = "completed",
|
|
174
|
-
y = {};
|
|
175
|
-
function Generator() {}
|
|
176
|
-
function GeneratorFunction() {}
|
|
177
|
-
function GeneratorFunctionPrototype() {}
|
|
178
|
-
var p = {};
|
|
179
|
-
define(p, a, function () {
|
|
180
|
-
return this;
|
|
181
|
-
});
|
|
182
|
-
var d = Object.getPrototypeOf,
|
|
183
|
-
v = d && d(d(values([])));
|
|
184
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
185
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
186
|
-
function defineIteratorMethods(t) {
|
|
187
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
188
|
-
define(t, e, function (t) {
|
|
189
|
-
return this._invoke(e, t);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
function AsyncIterator(t, e) {
|
|
194
|
-
function invoke(r, o, i, a) {
|
|
195
|
-
var c = tryCatch(t[r], t, o);
|
|
196
|
-
if ("throw" !== c.type) {
|
|
197
|
-
var u = c.arg,
|
|
198
|
-
h = u.value;
|
|
199
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
200
|
-
invoke("next", t, i, a);
|
|
201
|
-
}, function (t) {
|
|
202
|
-
invoke("throw", t, i, a);
|
|
203
|
-
}) : e.resolve(h).then(function (t) {
|
|
204
|
-
u.value = t, i(u);
|
|
205
|
-
}, function (t) {
|
|
206
|
-
return invoke("throw", t, i, a);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
a(c.arg);
|
|
210
|
-
}
|
|
211
|
-
var r;
|
|
212
|
-
o(this, "_invoke", {
|
|
213
|
-
value: function (t, n) {
|
|
214
|
-
function callInvokeWithMethodAndArg() {
|
|
215
|
-
return new e(function (e, r) {
|
|
216
|
-
invoke(t, n, e, r);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
function makeInvokeMethod(e, r, n) {
|
|
224
|
-
var o = h;
|
|
225
|
-
return function (i, a) {
|
|
226
|
-
if (o === f) throw new Error("Generator is already running");
|
|
227
|
-
if (o === s) {
|
|
228
|
-
if ("throw" === i) throw a;
|
|
229
|
-
return {
|
|
230
|
-
value: t,
|
|
231
|
-
done: !0
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
for (n.method = i, n.arg = a;;) {
|
|
235
|
-
var c = n.delegate;
|
|
236
|
-
if (c) {
|
|
237
|
-
var u = maybeInvokeDelegate(c, n);
|
|
238
|
-
if (u) {
|
|
239
|
-
if (u === y) continue;
|
|
240
|
-
return u;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
244
|
-
if (o === h) throw o = s, n.arg;
|
|
245
|
-
n.dispatchException(n.arg);
|
|
246
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
247
|
-
o = f;
|
|
248
|
-
var p = tryCatch(e, r, n);
|
|
249
|
-
if ("normal" === p.type) {
|
|
250
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
251
|
-
return {
|
|
252
|
-
value: p.arg,
|
|
253
|
-
done: n.done
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function maybeInvokeDelegate(e, r) {
|
|
261
|
-
var n = r.method,
|
|
262
|
-
o = e.iterator[n];
|
|
263
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
264
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
265
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
266
|
-
var a = i.arg;
|
|
267
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
268
|
-
}
|
|
269
|
-
function pushTryEntry(t) {
|
|
270
|
-
var e = {
|
|
271
|
-
tryLoc: t[0]
|
|
272
|
-
};
|
|
273
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
274
|
-
}
|
|
275
|
-
function resetTryEntry(t) {
|
|
276
|
-
var e = t.completion || {};
|
|
277
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
278
|
-
}
|
|
279
|
-
function Context(t) {
|
|
280
|
-
this.tryEntries = [{
|
|
281
|
-
tryLoc: "root"
|
|
282
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
283
|
-
}
|
|
284
|
-
function values(e) {
|
|
285
|
-
if (e || "" === e) {
|
|
286
|
-
var r = e[a];
|
|
287
|
-
if (r) return r.call(e);
|
|
288
|
-
if ("function" == typeof e.next) return e;
|
|
289
|
-
if (!isNaN(e.length)) {
|
|
290
|
-
var o = -1,
|
|
291
|
-
i = function next() {
|
|
292
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
293
|
-
return next.value = t, next.done = !0, next;
|
|
294
|
-
};
|
|
295
|
-
return i.next = i;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
299
|
-
}
|
|
300
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
301
|
-
value: GeneratorFunctionPrototype,
|
|
302
|
-
configurable: !0
|
|
303
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
304
|
-
value: GeneratorFunction,
|
|
305
|
-
configurable: !0
|
|
306
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
307
|
-
var e = "function" == typeof t && t.constructor;
|
|
308
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
309
|
-
}, e.mark = function (t) {
|
|
310
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
311
|
-
}, e.awrap = function (t) {
|
|
312
|
-
return {
|
|
313
|
-
__await: t
|
|
314
|
-
};
|
|
315
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
316
|
-
return this;
|
|
317
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
318
|
-
void 0 === i && (i = Promise);
|
|
319
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
320
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
321
|
-
return t.done ? t.value : a.next();
|
|
322
|
-
});
|
|
323
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
324
|
-
return this;
|
|
325
|
-
}), define(g, "toString", function () {
|
|
326
|
-
return "[object Generator]";
|
|
327
|
-
}), e.keys = function (t) {
|
|
328
|
-
var e = Object(t),
|
|
329
|
-
r = [];
|
|
330
|
-
for (var n in e) r.push(n);
|
|
331
|
-
return r.reverse(), function next() {
|
|
332
|
-
for (; r.length;) {
|
|
333
|
-
var t = r.pop();
|
|
334
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
335
|
-
}
|
|
336
|
-
return next.done = !0, next;
|
|
337
|
-
};
|
|
338
|
-
}, e.values = values, Context.prototype = {
|
|
339
|
-
constructor: Context,
|
|
340
|
-
reset: function (e) {
|
|
341
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
342
|
-
},
|
|
343
|
-
stop: function () {
|
|
344
|
-
this.done = !0;
|
|
345
|
-
var t = this.tryEntries[0].completion;
|
|
346
|
-
if ("throw" === t.type) throw t.arg;
|
|
347
|
-
return this.rval;
|
|
348
|
-
},
|
|
349
|
-
dispatchException: function (e) {
|
|
350
|
-
if (this.done) throw e;
|
|
351
|
-
var r = this;
|
|
352
|
-
function handle(n, o) {
|
|
353
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
354
|
-
}
|
|
355
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
356
|
-
var i = this.tryEntries[o],
|
|
357
|
-
a = i.completion;
|
|
358
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
359
|
-
if (i.tryLoc <= this.prev) {
|
|
360
|
-
var c = n.call(i, "catchLoc"),
|
|
361
|
-
u = n.call(i, "finallyLoc");
|
|
362
|
-
if (c && u) {
|
|
363
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
364
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
365
|
-
} else if (c) {
|
|
366
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
367
|
-
} else {
|
|
368
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
369
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
abrupt: function (t, e) {
|
|
375
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
376
|
-
var o = this.tryEntries[r];
|
|
377
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
378
|
-
var i = o;
|
|
379
|
-
break;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
383
|
-
var a = i ? i.completion : {};
|
|
384
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
385
|
-
},
|
|
386
|
-
complete: function (t, e) {
|
|
387
|
-
if ("throw" === t.type) throw t.arg;
|
|
388
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
389
|
-
},
|
|
390
|
-
finish: function (t) {
|
|
391
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
392
|
-
var r = this.tryEntries[e];
|
|
393
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
catch: function (t) {
|
|
397
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
398
|
-
var r = this.tryEntries[e];
|
|
399
|
-
if (r.tryLoc === t) {
|
|
400
|
-
var n = r.completion;
|
|
401
|
-
if ("throw" === n.type) {
|
|
402
|
-
var o = n.arg;
|
|
403
|
-
resetTryEntry(r);
|
|
404
|
-
}
|
|
405
|
-
return o;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
throw new Error("illegal catch attempt");
|
|
409
|
-
},
|
|
410
|
-
delegateYield: function (e, r, n) {
|
|
411
|
-
return this.delegate = {
|
|
412
|
-
iterator: values(e),
|
|
413
|
-
resultName: r,
|
|
414
|
-
nextLoc: n
|
|
415
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
416
|
-
}
|
|
417
|
-
}, e;
|
|
418
|
-
}
|
|
419
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
420
|
-
try {
|
|
421
|
-
var info = gen[key](arg);
|
|
422
|
-
var value = info.value;
|
|
423
|
-
} catch (error) {
|
|
424
|
-
reject(error);
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
if (info.done) {
|
|
428
|
-
resolve(value);
|
|
429
|
-
} else {
|
|
430
|
-
Promise.resolve(value).then(_next, _throw);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
function _asyncToGenerator(fn) {
|
|
434
|
-
return function () {
|
|
435
|
-
var self = this,
|
|
436
|
-
args = arguments;
|
|
437
|
-
return new Promise(function (resolve, reject) {
|
|
438
|
-
var gen = fn.apply(self, args);
|
|
439
|
-
function _next(value) {
|
|
440
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
441
|
-
}
|
|
442
|
-
function _throw(err) {
|
|
443
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
444
|
-
}
|
|
445
|
-
_next(undefined);
|
|
446
|
-
});
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
|
|
450
71
|
/**
|
|
451
72
|
* Sets the `innerError.message` in an `errors` object at the key
|
|
452
73
|
* defined by `innerError.path`.
|
|
@@ -454,7 +75,7 @@ function _asyncToGenerator(fn) {
|
|
|
454
75
|
* @param {{ path: string, message: string }} innerError A `yup` field error.
|
|
455
76
|
* @returns {Object} The result of setting the new error message onto `errors`.
|
|
456
77
|
*/
|
|
457
|
-
|
|
78
|
+
const setInError = (errors, innerError) => {
|
|
458
79
|
return finalForm.setIn(errors, innerError.path, innerError.message);
|
|
459
80
|
};
|
|
460
81
|
|
|
@@ -463,7 +84,7 @@ var setInError = function setInError(errors, innerError) {
|
|
|
463
84
|
* value for reducing the `err.inner` array of errors
|
|
464
85
|
* from a `yup~ValidationError`.
|
|
465
86
|
*/
|
|
466
|
-
|
|
87
|
+
const emptyObj = Object.create(null);
|
|
467
88
|
|
|
468
89
|
/**
|
|
469
90
|
* Takes a `yup` validation schema and returns a function that expects
|
|
@@ -475,146 +96,122 @@ var emptyObj = Object.create(null);
|
|
|
475
96
|
* and resolves to either `undefined` or a map of field names to error messages.
|
|
476
97
|
*/
|
|
477
98
|
|
|
478
|
-
|
|
479
|
-
return
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
_context.next = 12;
|
|
491
|
-
break;
|
|
492
|
-
case 5:
|
|
493
|
-
_context.prev = 5;
|
|
494
|
-
_context.t0 = _context["catch"](0);
|
|
495
|
-
if (!_context.t0.inner) {
|
|
496
|
-
_context.next = 11;
|
|
497
|
-
break;
|
|
498
|
-
}
|
|
499
|
-
return _context.abrupt("return", _context.t0.inner.reduce(setInError, emptyObj));
|
|
500
|
-
case 11:
|
|
501
|
-
console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
|
|
502
|
-
case 12:
|
|
503
|
-
case "end":
|
|
504
|
-
return _context.stop();
|
|
505
|
-
}
|
|
506
|
-
}, _callee, null, [[0, 5]]);
|
|
507
|
-
}));
|
|
508
|
-
function validate(_x) {
|
|
509
|
-
return _validate.apply(this, arguments);
|
|
99
|
+
const makeValidate = schema => {
|
|
100
|
+
return async function validate(values) {
|
|
101
|
+
try {
|
|
102
|
+
await schema.validate(values, {
|
|
103
|
+
abortEarly: false
|
|
104
|
+
});
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error.inner) {
|
|
107
|
+
return error.inner.reduce(setInError, emptyObj);
|
|
108
|
+
} else {
|
|
109
|
+
console.warn('itcase-forms schema.validate error: An error not related to the form occurred during validation. Validation ignored.');
|
|
110
|
+
}
|
|
510
111
|
}
|
|
511
|
-
|
|
512
|
-
}();
|
|
112
|
+
};
|
|
513
113
|
};
|
|
514
114
|
function useYupValidationSchema(schema, language) {
|
|
515
|
-
|
|
516
|
-
return schema && makeValidate(schema);
|
|
517
|
-
}, [schema, language]);
|
|
115
|
+
const validate = React.useMemo(() => schema && makeValidate(schema), [schema, language]);
|
|
518
116
|
return validate;
|
|
519
117
|
}
|
|
520
118
|
|
|
521
119
|
function FieldWrapperBase(props) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
120
|
+
const {
|
|
121
|
+
after,
|
|
122
|
+
afterItem,
|
|
123
|
+
before,
|
|
124
|
+
beforeItem,
|
|
125
|
+
children,
|
|
126
|
+
className,
|
|
127
|
+
desc,
|
|
128
|
+
descTextSize,
|
|
129
|
+
descTextColor,
|
|
130
|
+
descTextWidth,
|
|
131
|
+
divider,
|
|
132
|
+
dividerDirection,
|
|
133
|
+
dividerFill,
|
|
134
|
+
dividerSize,
|
|
135
|
+
dividerWidth,
|
|
136
|
+
fieldClassName,
|
|
137
|
+
id,
|
|
138
|
+
inputName,
|
|
139
|
+
inputValue,
|
|
140
|
+
isRequired,
|
|
141
|
+
label,
|
|
142
|
+
labelTextSize,
|
|
143
|
+
labelTextColor,
|
|
144
|
+
labelTextWidth,
|
|
145
|
+
errorMessageTextSize,
|
|
146
|
+
errorMessageTextWeight,
|
|
147
|
+
errorMessageTextColor,
|
|
148
|
+
message,
|
|
149
|
+
messageTextSize,
|
|
150
|
+
messageTextColor,
|
|
151
|
+
messageTextWeight,
|
|
152
|
+
metaActive,
|
|
153
|
+
metaError,
|
|
154
|
+
metaModifiedSinceLastSubmit,
|
|
155
|
+
metaSubmitError,
|
|
156
|
+
metaSubmitFailed,
|
|
157
|
+
metaTouched,
|
|
158
|
+
metaValid,
|
|
159
|
+
set,
|
|
160
|
+
type,
|
|
161
|
+
hideMessage,
|
|
162
|
+
isHidden,
|
|
163
|
+
tag: Tag,
|
|
164
|
+
dataTour,
|
|
165
|
+
showErrorsOnSubmit
|
|
166
|
+
} = props;
|
|
167
|
+
const error = metaError || !metaModifiedSinceLastSubmit && metaSubmitError || false;
|
|
168
|
+
const showError = React.useMemo(() => {
|
|
569
169
|
if (showErrorsOnSubmit) {
|
|
570
170
|
return metaSubmitFailed && metaTouched && error;
|
|
571
171
|
} else {
|
|
572
172
|
return metaTouched && error;
|
|
573
173
|
}
|
|
574
174
|
}, [showErrorsOnSubmit, metaSubmitFailed, metaTouched, error]);
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
175
|
+
const showValid = React.useMemo(() => {
|
|
176
|
+
const hasValue = Array.isArray(inputValue) ? inputValue.length : inputValue;
|
|
177
|
+
const isModifiedAfterSubmit = !metaError && metaSubmitError && metaModifiedSinceLastSubmit;
|
|
578
178
|
return hasValue && (metaValid || isModifiedAfterSubmit);
|
|
579
179
|
}, [inputValue, metaValid, metaError, metaSubmitError, metaModifiedSinceLastSubmit]);
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
var fieldClass = React.useMemo(function () {
|
|
584
|
-
return clsx__default.default(fieldClassName, showError && fieldClassName + "_state_error", showValid && fieldClassName + "_state_success", metaActive && fieldClassName + "_state_focus", inputValue && fieldClassName + "_state_filled");
|
|
585
|
-
}, [fieldClassName, showError, showValid, metaActive, inputValue]);
|
|
586
|
-
var sizeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
180
|
+
const formFieldClass = React.useMemo(() => clsx__default.default(className, showError && 'form__item_state_error', showValid && 'form__item_state_success', isRequired && 'form__item_state_required', metaActive && 'form__item_state_focus', inputValue && 'form__item_state_filled'), [className, showError, showValid, isRequired, metaActive, inputValue]);
|
|
181
|
+
const fieldClass = React.useMemo(() => clsx__default.default(fieldClassName, showError && `${fieldClassName}_state_error`, showValid && `${fieldClassName}_state_success`, metaActive && `${fieldClassName}_state_focus`, inputValue && `${fieldClassName}_state_filled`), [fieldClassName, showError, showValid, metaActive, inputValue]);
|
|
182
|
+
const sizeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
587
183
|
prefix: 'form-field_size_',
|
|
588
184
|
propsKey: 'size'
|
|
589
185
|
});
|
|
590
|
-
|
|
186
|
+
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
591
187
|
prefix: 'fill_',
|
|
592
188
|
propsKey: 'fill'
|
|
593
189
|
});
|
|
594
|
-
|
|
190
|
+
const inputFillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
595
191
|
prefix: 'fill_',
|
|
596
192
|
propsKey: 'inputFill'
|
|
597
193
|
});
|
|
598
|
-
|
|
194
|
+
const shapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
599
195
|
prefix: 'form-field_shape_',
|
|
600
196
|
propsKey: 'shape'
|
|
601
197
|
});
|
|
602
|
-
|
|
198
|
+
const inputShapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
603
199
|
prefix: 'form-field__item-value_shape_',
|
|
604
200
|
propsKey: 'inputShape'
|
|
605
201
|
});
|
|
606
|
-
|
|
202
|
+
const directionClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
607
203
|
prefix: 'direction_',
|
|
608
204
|
propsKey: 'direction'
|
|
609
205
|
});
|
|
610
|
-
|
|
206
|
+
const widthClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
611
207
|
prefix: 'width_',
|
|
612
208
|
propsKey: 'width'
|
|
613
209
|
});
|
|
614
|
-
|
|
615
|
-
formFieldStyles
|
|
210
|
+
const {
|
|
211
|
+
styles: formFieldStyles
|
|
212
|
+
} = useStyles.useStyles(props);
|
|
616
213
|
return /*#__PURE__*/React__default.default.createElement(Tag, {
|
|
617
|
-
className: clsx__default.default(formFieldClass, 'form__item', 'form-field', type &&
|
|
214
|
+
className: clsx__default.default(formFieldClass, 'form__item', 'form-field', type && `form-field_type_${type}`, set && `form-field_set_${set}`, sizeClass, fillClass, shapeClass, isHidden && `form-field_state_hidden`, directionClass, widthClass),
|
|
618
215
|
"data-tour": dataTour,
|
|
619
216
|
style: formFieldStyles
|
|
620
217
|
}, before, label && /*#__PURE__*/React__default.default.createElement("div", {
|
|
@@ -647,7 +244,7 @@ function FieldWrapperBase(props) {
|
|
|
647
244
|
size: errorMessageTextSize,
|
|
648
245
|
textWeight: errorMessageTextWeight,
|
|
649
246
|
textColor: errorMessageTextColor,
|
|
650
|
-
id: inputName
|
|
247
|
+
id: `${inputName}-error`
|
|
651
248
|
}, error), Boolean(message) && !showError && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
652
249
|
className: "form-field__message-item form-field__message-item_type_message",
|
|
653
250
|
size: messageTextSize,
|
|
@@ -656,7 +253,7 @@ function FieldWrapperBase(props) {
|
|
|
656
253
|
}, message), Boolean(!showError) && Boolean(!message) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
657
254
|
className: "form-field__message-item form-field__message-item_type_message",
|
|
658
255
|
size: messageTextSize
|
|
659
|
-
},
|
|
256
|
+
}, '\u00A0')), after);
|
|
660
257
|
}
|
|
661
258
|
FieldWrapperBase.defaultProps = {
|
|
662
259
|
tag: 'div',
|
|
@@ -712,12 +309,15 @@ FieldWrapperBase.propTypes = {
|
|
|
712
309
|
type: PropTypes__default.default.string
|
|
713
310
|
};
|
|
714
311
|
function FieldWrapper(props) {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
312
|
+
const {
|
|
313
|
+
inputName
|
|
314
|
+
} = props;
|
|
315
|
+
const {
|
|
316
|
+
change
|
|
317
|
+
} = reactFinalForm.useForm(); // , mutators
|
|
718
318
|
|
|
719
|
-
React.useEffect(
|
|
720
|
-
return
|
|
319
|
+
React.useEffect(() => {
|
|
320
|
+
return () => {
|
|
721
321
|
change(inputName, undefined);
|
|
722
322
|
};
|
|
723
323
|
}, []);
|
|
@@ -747,21 +347,24 @@ FieldWrapper.propTypes = {
|
|
|
747
347
|
showErrorsOnSubmit: PropTypes__default.default.bool
|
|
748
348
|
};
|
|
749
349
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
350
|
+
const CheckboxField = /*#__PURE__*/React__default.default.memo(function CheckboxField(props) {
|
|
351
|
+
const {
|
|
352
|
+
name,
|
|
353
|
+
isRequired,
|
|
354
|
+
onChange,
|
|
355
|
+
fieldProps,
|
|
356
|
+
inputProps,
|
|
357
|
+
classNameGroupItem,
|
|
358
|
+
hideMessage
|
|
359
|
+
} = props;
|
|
758
360
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
759
361
|
name: name,
|
|
760
362
|
type: "checkbox"
|
|
761
|
-
},
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
363
|
+
}, ({
|
|
364
|
+
input,
|
|
365
|
+
meta
|
|
366
|
+
}) => {
|
|
367
|
+
const onChangeField = React.useCallback(event => {
|
|
765
368
|
input.onChange(event);
|
|
766
369
|
if (onChange) {
|
|
767
370
|
onChange(event.target.checked, input.name);
|
|
@@ -805,41 +408,43 @@ CheckboxField.propTypes = {
|
|
|
805
408
|
onChange: PropTypes__default.default.func
|
|
806
409
|
};
|
|
807
410
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
411
|
+
const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceField(props) {
|
|
412
|
+
const {
|
|
413
|
+
options,
|
|
414
|
+
classNameGroupItem,
|
|
415
|
+
fieldProps,
|
|
416
|
+
inputProps,
|
|
417
|
+
isMultiple,
|
|
418
|
+
isRequired,
|
|
419
|
+
initialValue,
|
|
420
|
+
label,
|
|
421
|
+
name,
|
|
422
|
+
messageType,
|
|
423
|
+
hideMessage,
|
|
424
|
+
placeholder
|
|
425
|
+
} = props;
|
|
426
|
+
const {
|
|
427
|
+
change
|
|
428
|
+
} = reactFinalForm.useForm();
|
|
823
429
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
824
430
|
name: name,
|
|
825
431
|
initialValue: initialValue
|
|
826
|
-
},
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
432
|
+
}, ({
|
|
433
|
+
input,
|
|
434
|
+
meta
|
|
435
|
+
}) => {
|
|
436
|
+
const activeOption = React.useMemo(() => {
|
|
437
|
+
const emptyOption = {
|
|
831
438
|
value: null,
|
|
832
439
|
label: null
|
|
833
440
|
};
|
|
834
441
|
if (input.value) {
|
|
835
|
-
|
|
836
|
-
return option.value === input.value;
|
|
837
|
-
});
|
|
442
|
+
const currentOption = options.find(option => option.value === input.value);
|
|
838
443
|
return currentOption || emptyOption;
|
|
839
444
|
}
|
|
840
445
|
return emptyOption;
|
|
841
446
|
}, [input.value]);
|
|
842
|
-
|
|
447
|
+
const setActiveSegment = React.useCallback(option => {
|
|
843
448
|
change(name, option.value);
|
|
844
449
|
}, [change]);
|
|
845
450
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
@@ -882,37 +487,38 @@ ChoiceField.propTypes = {
|
|
|
882
487
|
placeholder: PropTypes__default.default.string
|
|
883
488
|
};
|
|
884
489
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
490
|
+
const CustomField = /*#__PURE__*/React__default.default.memo(function CustomField(props) {
|
|
491
|
+
const {
|
|
492
|
+
Component,
|
|
493
|
+
isRequired,
|
|
494
|
+
name,
|
|
495
|
+
fieldProps,
|
|
496
|
+
classNameGroupItem,
|
|
497
|
+
hideMessage
|
|
498
|
+
} = props;
|
|
892
499
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
893
500
|
name: name
|
|
894
|
-
},
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
});
|
|
501
|
+
}, ({
|
|
502
|
+
input,
|
|
503
|
+
meta
|
|
504
|
+
}) => /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
505
|
+
className: clsx__default.default('form-field_type_custom', 'form__item_type_custom', classNameGroupItem),
|
|
506
|
+
fieldClassName: 'form-custom',
|
|
507
|
+
inputName: input.name,
|
|
508
|
+
inputValue: input.value,
|
|
509
|
+
isRequired: isRequired,
|
|
510
|
+
metaActive: meta.active,
|
|
511
|
+
metaError: meta.error,
|
|
512
|
+
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
513
|
+
metaSubmitError: meta.submitError,
|
|
514
|
+
metaSubmitFailed: meta.submitFailed,
|
|
515
|
+
metaTouched: meta.touched,
|
|
516
|
+
metaValid: meta.valid,
|
|
517
|
+
hideMessage: hideMessage
|
|
518
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Component, Object.assign({}, props, {
|
|
519
|
+
input: input,
|
|
520
|
+
meta: meta
|
|
521
|
+
}))));
|
|
916
522
|
});
|
|
917
523
|
CustomField.defaultProps = {
|
|
918
524
|
inputProps: {},
|
|
@@ -925,41 +531,42 @@ CustomField.propTypes = {
|
|
|
925
531
|
inputProps: PropTypes__default.default.object
|
|
926
532
|
};
|
|
927
533
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
534
|
+
const CodeField = /*#__PURE__*/React__default.default.memo(function CodeField(props) {
|
|
535
|
+
const {
|
|
536
|
+
isRequired,
|
|
537
|
+
name,
|
|
538
|
+
fieldProps,
|
|
539
|
+
inputProps,
|
|
540
|
+
classNameGroupItem,
|
|
541
|
+
hideMessage
|
|
542
|
+
} = props;
|
|
935
543
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
936
544
|
name: name
|
|
937
|
-
},
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
});
|
|
545
|
+
}, ({
|
|
546
|
+
input,
|
|
547
|
+
meta
|
|
548
|
+
}) => /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
549
|
+
className: clsx__default.default('form-field_type_code', 'form__item_type_code', classNameGroupItem),
|
|
550
|
+
fieldClassName: 'form-code',
|
|
551
|
+
inputName: input.name,
|
|
552
|
+
inputValue: input.value,
|
|
553
|
+
isRequired: isRequired,
|
|
554
|
+
metaActive: meta.active,
|
|
555
|
+
metaError: meta.error,
|
|
556
|
+
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
557
|
+
metaSubmitError: meta.submitError,
|
|
558
|
+
metaSubmitFailed: meta.submitFailed,
|
|
559
|
+
metaTouched: meta.touched,
|
|
560
|
+
metaValid: meta.valid,
|
|
561
|
+
hideMessage: hideMessage
|
|
562
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Code.Code, Object.assign({
|
|
563
|
+
autoComplete: "nope",
|
|
564
|
+
name: input.name,
|
|
565
|
+
value: input.value,
|
|
566
|
+
onBlur: input.onBlur,
|
|
567
|
+
onChange: input.onChange,
|
|
568
|
+
onFocus: input.onFocus
|
|
569
|
+
}, inputProps))));
|
|
963
570
|
});
|
|
964
571
|
CodeField.defaultProps = {
|
|
965
572
|
inputProps: {},
|
|
@@ -973,28 +580,31 @@ CodeField.propTypes = {
|
|
|
973
580
|
};
|
|
974
581
|
|
|
975
582
|
function DatePickerField(props) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
583
|
+
const {
|
|
584
|
+
isRequired,
|
|
585
|
+
fieldProps,
|
|
586
|
+
inputProps,
|
|
587
|
+
datePickerProps,
|
|
588
|
+
name,
|
|
589
|
+
iconSize,
|
|
590
|
+
iconBorder,
|
|
591
|
+
iconBorderHover,
|
|
592
|
+
iconFill,
|
|
593
|
+
iconFillHover,
|
|
594
|
+
iconRevealableShow,
|
|
595
|
+
iconRevealableHide,
|
|
596
|
+
iconShape,
|
|
597
|
+
hideMessage,
|
|
598
|
+
onChange,
|
|
599
|
+
classNameGroupItem
|
|
600
|
+
} = props;
|
|
992
601
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
993
602
|
name: name
|
|
994
|
-
},
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
603
|
+
}, ({
|
|
604
|
+
input,
|
|
605
|
+
meta
|
|
606
|
+
}) => {
|
|
607
|
+
const onChangeField = React.useCallback(value => {
|
|
998
608
|
input.onChange(value);
|
|
999
609
|
if (onChange) {
|
|
1000
610
|
onChange(value, input.name);
|
|
@@ -1037,161 +647,78 @@ DatePickerField.propTypes = {
|
|
|
1037
647
|
onChange: PropTypes__default.default.func
|
|
1038
648
|
};
|
|
1039
649
|
|
|
1040
|
-
function getFileByURL(
|
|
1041
|
-
|
|
650
|
+
async function getFileByURL(url) {
|
|
651
|
+
try {
|
|
652
|
+
const response = await axios__default.default({
|
|
653
|
+
url: `/api/${url}/`,
|
|
654
|
+
responseType: 'blob'
|
|
655
|
+
});
|
|
656
|
+
const blobObject = response.data;
|
|
657
|
+
const dirtyFilename = response.headers['content-disposition']?.split('filename=')[1];
|
|
658
|
+
// Remove double quotes
|
|
659
|
+
let filename = dirtyFilename?.substring(1).slice(0, -1);
|
|
660
|
+
if (!filename) {
|
|
661
|
+
const typeParts = blobObject.type.split('/');
|
|
662
|
+
const fileType = typeParts[typeParts.length - 1];
|
|
663
|
+
filename = `${new Date().getTime()}.${fileType}`;
|
|
664
|
+
}
|
|
665
|
+
return new File([blobObject], filename, {
|
|
666
|
+
type: blobObject.type
|
|
667
|
+
});
|
|
668
|
+
} catch (error) {
|
|
669
|
+
console.log('error: ', error);
|
|
670
|
+
return null;
|
|
671
|
+
}
|
|
1042
672
|
}
|
|
1043
|
-
function
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
});
|
|
1055
|
-
case 3:
|
|
1056
|
-
response = _context3.sent;
|
|
1057
|
-
blobObject = response.data;
|
|
1058
|
-
dirtyFilename = (_response$headers$con = response.headers['content-disposition']) == null ? void 0 : _response$headers$con.split('filename=')[1]; // Remove double quotes
|
|
1059
|
-
filename = dirtyFilename == null ? void 0 : dirtyFilename.substring(1).slice(0, -1);
|
|
1060
|
-
if (!filename) {
|
|
1061
|
-
typeParts = blobObject.type.split('/');
|
|
1062
|
-
fileType = typeParts[typeParts.length - 1];
|
|
1063
|
-
filename = new Date().getTime() + "." + fileType;
|
|
1064
|
-
}
|
|
1065
|
-
return _context3.abrupt("return", new File([blobObject], filename, {
|
|
1066
|
-
type: blobObject.type
|
|
1067
|
-
}));
|
|
1068
|
-
case 11:
|
|
1069
|
-
_context3.prev = 11;
|
|
1070
|
-
_context3.t0 = _context3["catch"](0);
|
|
1071
|
-
console.log('error: ', _context3.t0);
|
|
1072
|
-
return _context3.abrupt("return", null);
|
|
1073
|
-
case 15:
|
|
1074
|
-
case "end":
|
|
1075
|
-
return _context3.stop();
|
|
673
|
+
async function convertToFiles(inputValue, isPreviews) {
|
|
674
|
+
const newFiles = [];
|
|
675
|
+
for await (const value of castArray__default.default(inputValue)) {
|
|
676
|
+
let newFile = null;
|
|
677
|
+
|
|
678
|
+
// Download image by url and save as File instance
|
|
679
|
+
const isURL = typeof value === 'string' && value.includes('/');
|
|
680
|
+
if (value.image || isURL) {
|
|
681
|
+
newFile = await getFileByURL(value.image || value);
|
|
682
|
+
if (newFile) {
|
|
683
|
+
setFileDataURL(newFile);
|
|
1076
684
|
}
|
|
1077
|
-
}
|
|
1078
|
-
}));
|
|
1079
|
-
return _getFileByURL.apply(this, arguments);
|
|
1080
|
-
}
|
|
1081
|
-
function convertToFiles(_x2, _x3) {
|
|
1082
|
-
return _convertToFiles.apply(this, arguments);
|
|
1083
|
-
}
|
|
1084
|
-
function _convertToFiles() {
|
|
1085
|
-
_convertToFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(inputValue, isPreviews) {
|
|
1086
|
-
var newFiles, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, newFile, isURL;
|
|
1087
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1088
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1089
|
-
case 0:
|
|
1090
|
-
newFiles = [];
|
|
1091
|
-
_iteratorAbruptCompletion = false;
|
|
1092
|
-
_didIteratorError = false;
|
|
1093
|
-
_context4.prev = 3;
|
|
1094
|
-
_iterator = _asyncIterator(castArray__default.default(inputValue));
|
|
1095
|
-
case 5:
|
|
1096
|
-
_context4.next = 7;
|
|
1097
|
-
return _iterator.next();
|
|
1098
|
-
case 7:
|
|
1099
|
-
if (!(_iteratorAbruptCompletion = !(_step = _context4.sent).done)) {
|
|
1100
|
-
_context4.next = 21;
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
value = _step.value;
|
|
1104
|
-
newFile = null; // Download image by url and save as File instance
|
|
1105
|
-
isURL = typeof value === 'string' && value.includes('/');
|
|
1106
|
-
if (!(value.image || isURL)) {
|
|
1107
|
-
_context4.next = 16;
|
|
1108
|
-
break;
|
|
1109
|
-
}
|
|
1110
|
-
_context4.next = 14;
|
|
1111
|
-
return getFileByURL(value.image || value);
|
|
1112
|
-
case 14:
|
|
1113
|
-
newFile = _context4.sent;
|
|
1114
|
-
if (newFile) {
|
|
1115
|
-
setFileDataURL(newFile);
|
|
1116
|
-
}
|
|
1117
|
-
case 16:
|
|
1118
|
-
// Convert dataURL to File instance
|
|
1119
|
-
if (value.dataURL) {
|
|
1120
|
-
newFile = common.createFileFromDataURL(value.name || value.path, value.dataURL);
|
|
1121
|
-
newFile.dataURL = value.dataURL;
|
|
1122
|
-
}
|
|
685
|
+
}
|
|
1123
686
|
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
newFiles.push(newFile);
|
|
1131
|
-
}
|
|
687
|
+
// Convert dataURL to File instance
|
|
688
|
+
if (value.dataURL) {
|
|
689
|
+
newFile = common.createFileFromDataURL(value.name || value.path, value.dataURL);
|
|
690
|
+
newFile.dataURL = value.dataURL;
|
|
691
|
+
}
|
|
1132
692
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
// }
|
|
1139
|
-
case 18:
|
|
1140
|
-
_iteratorAbruptCompletion = false;
|
|
1141
|
-
_context4.next = 5;
|
|
1142
|
-
break;
|
|
1143
|
-
case 21:
|
|
1144
|
-
_context4.next = 27;
|
|
1145
|
-
break;
|
|
1146
|
-
case 23:
|
|
1147
|
-
_context4.prev = 23;
|
|
1148
|
-
_context4.t0 = _context4["catch"](3);
|
|
1149
|
-
_didIteratorError = true;
|
|
1150
|
-
_iteratorError = _context4.t0;
|
|
1151
|
-
case 27:
|
|
1152
|
-
_context4.prev = 27;
|
|
1153
|
-
_context4.prev = 28;
|
|
1154
|
-
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
1155
|
-
_context4.next = 32;
|
|
1156
|
-
break;
|
|
1157
|
-
}
|
|
1158
|
-
_context4.next = 32;
|
|
1159
|
-
return _iterator["return"]();
|
|
1160
|
-
case 32:
|
|
1161
|
-
_context4.prev = 32;
|
|
1162
|
-
if (!_didIteratorError) {
|
|
1163
|
-
_context4.next = 35;
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
throw _iteratorError;
|
|
1167
|
-
case 35:
|
|
1168
|
-
return _context4.finish(32);
|
|
1169
|
-
case 36:
|
|
1170
|
-
return _context4.finish(27);
|
|
1171
|
-
case 37:
|
|
1172
|
-
return _context4.abrupt("return", newFiles);
|
|
1173
|
-
case 38:
|
|
1174
|
-
case "end":
|
|
1175
|
-
return _context4.stop();
|
|
693
|
+
// Save new File to state
|
|
694
|
+
if (newFile) {
|
|
695
|
+
newFile.id = value.id;
|
|
696
|
+
if (isPreviews) {
|
|
697
|
+
newFile.preview = URL.createObjectURL(newFile);
|
|
1176
698
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
699
|
+
newFiles.push(newFile);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// else if (value) {
|
|
703
|
+
// newFiles.push({
|
|
704
|
+
// name: value,
|
|
705
|
+
// error: 'File is unavailable',
|
|
706
|
+
// })
|
|
707
|
+
// }
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
return newFiles;
|
|
1180
711
|
}
|
|
1181
712
|
function setFileDataURL(file, resolve) {
|
|
1182
|
-
resolve = resolve ||
|
|
713
|
+
resolve = resolve || (() => {});
|
|
1183
714
|
// Init reader and save his file
|
|
1184
|
-
|
|
715
|
+
const reader = new FileReader();
|
|
1185
716
|
reader._readedFile = file;
|
|
1186
717
|
|
|
1187
718
|
// Set handlers
|
|
1188
|
-
reader.onabort =
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
reader.onerror = function () {
|
|
1192
|
-
return resolve();
|
|
1193
|
-
};
|
|
1194
|
-
reader.onload = function (event) {
|
|
719
|
+
reader.onabort = () => resolve();
|
|
720
|
+
reader.onerror = () => resolve();
|
|
721
|
+
reader.onload = event => {
|
|
1195
722
|
event.target._readedFile.dataURL = reader.result;
|
|
1196
723
|
resolve();
|
|
1197
724
|
};
|
|
@@ -1202,146 +729,122 @@ function setFileDataURL(file, resolve) {
|
|
|
1202
729
|
resolve();
|
|
1203
730
|
}
|
|
1204
731
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
dropzoneProps =
|
|
1241
|
-
onAddFiles
|
|
1242
|
-
onDeleteFile
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
var _useState2 = React.useState(false),
|
|
1247
|
-
fileIsLoading = _useState2[0],
|
|
1248
|
-
setFileIsLoading = _useState2[1];
|
|
732
|
+
const FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileInputDropzone(props) {
|
|
733
|
+
const {
|
|
734
|
+
inputName,
|
|
735
|
+
size,
|
|
736
|
+
className,
|
|
737
|
+
fileErrorText,
|
|
738
|
+
hintTitleTextSize,
|
|
739
|
+
removeThumbTextSize,
|
|
740
|
+
removeThumbTextColor,
|
|
741
|
+
removeThumbTextWeight,
|
|
742
|
+
thumbNameTextSize,
|
|
743
|
+
thumbNameTextColor,
|
|
744
|
+
removeThumbTextHoverColor,
|
|
745
|
+
thumbNameTextWrap,
|
|
746
|
+
thumbNameTextWeight,
|
|
747
|
+
hintTitleTextColor,
|
|
748
|
+
hintTitleTextWrap,
|
|
749
|
+
thumbColumn,
|
|
750
|
+
hintTitleTextWeight,
|
|
751
|
+
hintDescriptionTextSize,
|
|
752
|
+
hintDescriptionTextColor,
|
|
753
|
+
hintDescriptionTextWrap,
|
|
754
|
+
hintDescriptionTextWeight,
|
|
755
|
+
errorMessageTextSize,
|
|
756
|
+
errorMessageTextWeight,
|
|
757
|
+
errorMessageTextColor,
|
|
758
|
+
inputValue,
|
|
759
|
+
maxFiles,
|
|
760
|
+
maxSize,
|
|
761
|
+
removeThumbText,
|
|
762
|
+
hintTitle,
|
|
763
|
+
hintDescription,
|
|
764
|
+
isShowFilename,
|
|
765
|
+
isPreviews,
|
|
766
|
+
loadingText,
|
|
767
|
+
dropzoneProps = {},
|
|
768
|
+
onAddFiles,
|
|
769
|
+
onDeleteFile
|
|
770
|
+
} = props;
|
|
771
|
+
const [fileError, setFileError] = React.useState('');
|
|
772
|
+
const [fileIsLoading, setFileIsLoading] = React.useState(false);
|
|
1249
773
|
// State with instances of "File" type
|
|
1250
|
-
|
|
1251
|
-
files = _useState3[0],
|
|
1252
|
-
setFiles = _useState3[1];
|
|
774
|
+
const [files, setFiles] = React.useState(inputValue ? castArray__default.default(inputValue) : []);
|
|
1253
775
|
|
|
1254
776
|
// Save to mobx state
|
|
1255
|
-
|
|
1256
|
-
change
|
|
1257
|
-
|
|
777
|
+
const {
|
|
778
|
+
change
|
|
779
|
+
} = reactFinalForm.useForm();
|
|
780
|
+
const changeFormState = React.useCallback(newFiles => {
|
|
1258
781
|
// If max files in dropzone is 1 - return file as it self, else as array of files
|
|
1259
782
|
// ps: for old projects compatibility
|
|
1260
|
-
|
|
783
|
+
const toSave = dropzoneProps.maxFiles == 1 ? newFiles[0] : newFiles;
|
|
1261
784
|
change(inputName, toSave);
|
|
1262
785
|
return toSave;
|
|
1263
786
|
}, [dropzoneProps, change]);
|
|
1264
787
|
|
|
1265
788
|
// Create dropzone options
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1289
|
-
}, _callee);
|
|
1290
|
-
}));
|
|
1291
|
-
function getFilesFromEvent(_x4) {
|
|
1292
|
-
return _getFilesFromEvent.apply(this, arguments);
|
|
1293
|
-
}
|
|
1294
|
-
return getFilesFromEvent;
|
|
1295
|
-
}(),
|
|
1296
|
-
onDropAccepted: function onDropAccepted(acceptedFiles, event) {
|
|
1297
|
-
// If dropped files has accepted and we need a previews
|
|
1298
|
-
if (isPreviews) {
|
|
1299
|
-
// Add preview to every file
|
|
1300
|
-
acceptedFiles.forEach(function (file) {
|
|
1301
|
-
if (!file.error) {
|
|
1302
|
-
file.preview = URL.createObjectURL(file);
|
|
1303
|
-
}
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
// Save to form data (including empty when files are not valid)
|
|
1307
|
-
setFiles(acceptedFiles);
|
|
1308
|
-
setFileError('');
|
|
1309
|
-
|
|
1310
|
-
// Save DataURL for all files
|
|
1311
|
-
var readerPromisesList = acceptedFiles.map(function (file) {
|
|
1312
|
-
return new Promise(function (resolve) {
|
|
1313
|
-
return setFileDataURL(file, resolve);
|
|
1314
|
-
});
|
|
1315
|
-
});
|
|
1316
|
-
// Save files to form values
|
|
1317
|
-
Promise.all(readerPromisesList).then(function () {
|
|
1318
|
-
var filesToSave = changeFormState(acceptedFiles);
|
|
1319
|
-
if (onAddFiles) {
|
|
1320
|
-
onAddFiles(filesToSave, inputName);
|
|
789
|
+
const {
|
|
790
|
+
getRootProps,
|
|
791
|
+
getInputProps
|
|
792
|
+
} = reactDropzone.useDropzone({
|
|
793
|
+
maxSize: maxSize || 10485760,
|
|
794
|
+
// 10mb
|
|
795
|
+
maxFiles: maxFiles || 5,
|
|
796
|
+
// accept: { 'image/*': [] },
|
|
797
|
+
...dropzoneProps,
|
|
798
|
+
getFilesFromEvent: async event => {
|
|
799
|
+
const result = await fileSelector.fromEvent(event);
|
|
800
|
+
const newFiles = result.filter(item => item instanceof File);
|
|
801
|
+
// Add exists and new files to accepted(or rejected)
|
|
802
|
+
return [...files, ...newFiles];
|
|
803
|
+
},
|
|
804
|
+
onDropAccepted: (acceptedFiles, event) => {
|
|
805
|
+
// If dropped files has accepted and we need a previews
|
|
806
|
+
if (isPreviews) {
|
|
807
|
+
// Add preview to every file
|
|
808
|
+
acceptedFiles.forEach(file => {
|
|
809
|
+
if (!file.error) {
|
|
810
|
+
file.preview = URL.createObjectURL(file);
|
|
1321
811
|
}
|
|
1322
812
|
});
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
813
|
+
}
|
|
814
|
+
// Save to form data (including empty when files are not valid)
|
|
815
|
+
setFiles(acceptedFiles);
|
|
816
|
+
setFileError('');
|
|
817
|
+
|
|
818
|
+
// Save DataURL for all files
|
|
819
|
+
const readerPromisesList = acceptedFiles.map(file => {
|
|
820
|
+
return new Promise(resolve => setFileDataURL(file, resolve));
|
|
821
|
+
});
|
|
822
|
+
// Save files to form values
|
|
823
|
+
Promise.all(readerPromisesList).then(() => {
|
|
824
|
+
const filesToSave = changeFormState(acceptedFiles);
|
|
825
|
+
if (onAddFiles) {
|
|
826
|
+
onAddFiles(filesToSave, inputName);
|
|
1334
827
|
}
|
|
828
|
+
});
|
|
829
|
+
},
|
|
830
|
+
onDropRejected: (rejectedFiles, event) => {
|
|
831
|
+
// If dropped files has rejected
|
|
832
|
+
if (rejectedFiles.length) {
|
|
833
|
+
const firstFileError = rejectedFiles[0].errors[0]?.message;
|
|
834
|
+
// Show error
|
|
835
|
+
setFileError(firstFileError || 'Error on adding file');
|
|
836
|
+
} else {
|
|
837
|
+
// Else clean error
|
|
838
|
+
setFileError('');
|
|
1335
839
|
}
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
getInputProps = _useDropzone.getInputProps;
|
|
840
|
+
}
|
|
841
|
+
});
|
|
1339
842
|
|
|
1340
843
|
// Delete file from dropzone
|
|
1341
|
-
|
|
844
|
+
const removeFile = React.useCallback((event, index) => {
|
|
1342
845
|
event.stopPropagation();
|
|
1343
846
|
event.preventDefault();
|
|
1344
|
-
|
|
847
|
+
const newFiles = [...files];
|
|
1345
848
|
newFiles.splice(index, 1);
|
|
1346
849
|
if (onDeleteFile) {
|
|
1347
850
|
onDeleteFile(files[index], inputName);
|
|
@@ -1350,38 +853,19 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
|
|
|
1350
853
|
}, [files, changeFormState, onDeleteFile]);
|
|
1351
854
|
|
|
1352
855
|
//
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
return convertToFiles(newInputValue, isPreviews);
|
|
1362
|
-
case 3:
|
|
1363
|
-
newFiles = _context2.sent;
|
|
1364
|
-
setFileIsLoading(false);
|
|
1365
|
-
setFiles(newFiles);
|
|
1366
|
-
return _context2.abrupt("return", newFiles);
|
|
1367
|
-
case 7:
|
|
1368
|
-
case "end":
|
|
1369
|
-
return _context2.stop();
|
|
1370
|
-
}
|
|
1371
|
-
}, _callee2);
|
|
1372
|
-
}));
|
|
1373
|
-
return function (_x5) {
|
|
1374
|
-
return _ref.apply(this, arguments);
|
|
1375
|
-
};
|
|
1376
|
-
}(), [isPreviews]);
|
|
1377
|
-
React.useEffect(function () {
|
|
856
|
+
const convertFiledValueAndSaveAsFiles = React.useCallback(async newInputValue => {
|
|
857
|
+
setFileIsLoading(true);
|
|
858
|
+
const newFiles = await convertToFiles(newInputValue, isPreviews);
|
|
859
|
+
setFileIsLoading(false);
|
|
860
|
+
setFiles(newFiles);
|
|
861
|
+
return newFiles;
|
|
862
|
+
}, [isPreviews]);
|
|
863
|
+
React.useEffect(() => {
|
|
1378
864
|
// First time convert value to Files and save to local and form state
|
|
1379
|
-
convertFiledValueAndSaveAsFiles(inputValue).then(
|
|
1380
|
-
return changeFormState(newFiles);
|
|
1381
|
-
});
|
|
865
|
+
convertFiledValueAndSaveAsFiles(inputValue).then(newFiles => changeFormState(newFiles));
|
|
1382
866
|
}, []); // eslint-disable-line
|
|
1383
867
|
|
|
1384
|
-
React.useEffect(
|
|
868
|
+
React.useEffect(() => {
|
|
1385
869
|
// Everytime convert value to Files and save to local state
|
|
1386
870
|
if (!inputValue) {
|
|
1387
871
|
setFiles([]);
|
|
@@ -1391,116 +875,108 @@ var FileInputDropzone = /*#__PURE__*/React__default.default.memo(function FileIn
|
|
|
1391
875
|
// only "inputValue"
|
|
1392
876
|
}, [inputValue]); // eslint-disable-line
|
|
1393
877
|
|
|
1394
|
-
React.useEffect(
|
|
878
|
+
React.useEffect(() => {
|
|
1395
879
|
// Make sure to revoke the data uris to avoid memory leaks, will run on unmount
|
|
1396
|
-
return
|
|
1397
|
-
return files.forEach(function (file) {
|
|
1398
|
-
return URL.revokeObjectURL(file == null ? void 0 : file.preview);
|
|
1399
|
-
});
|
|
1400
|
-
};
|
|
880
|
+
return () => files.forEach(file => URL.revokeObjectURL(file?.preview));
|
|
1401
881
|
}, []); // eslint-disable-line
|
|
1402
882
|
|
|
1403
|
-
|
|
883
|
+
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1404
884
|
prefix: 'fill_',
|
|
1405
885
|
propsKey: 'fill'
|
|
1406
886
|
});
|
|
1407
|
-
|
|
887
|
+
const fillHoverClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1408
888
|
prefix: 'fill_hover_',
|
|
1409
889
|
propsKey: 'fillHover'
|
|
1410
890
|
});
|
|
1411
|
-
|
|
891
|
+
const borderWidthClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1412
892
|
prefix: 'border-width_',
|
|
1413
893
|
propsKey: 'borderWidth'
|
|
1414
894
|
});
|
|
1415
|
-
|
|
895
|
+
const borderColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1416
896
|
prefix: 'border-color_',
|
|
1417
897
|
propsKey: 'borderColor'
|
|
1418
898
|
});
|
|
1419
|
-
|
|
899
|
+
const borderColorHoverClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1420
900
|
prefix: 'border-color_hover_',
|
|
1421
901
|
propsKey: 'borderColorHover'
|
|
1422
902
|
});
|
|
1423
|
-
|
|
903
|
+
const borderTypeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1424
904
|
prefix: 'border_type_',
|
|
1425
905
|
propsKey: 'borderType'
|
|
1426
906
|
});
|
|
1427
|
-
|
|
907
|
+
const shapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1428
908
|
prefix: 'form-dropzone_shape_',
|
|
1429
909
|
propsKey: 'shape'
|
|
1430
910
|
});
|
|
1431
|
-
|
|
911
|
+
const thumbBorderWidthClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1432
912
|
prefix: 'border-width_',
|
|
1433
913
|
propsKey: 'thumbBorderWidth'
|
|
1434
914
|
});
|
|
1435
|
-
|
|
915
|
+
const thumbDirectionClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1436
916
|
prefix: 'form-dropzone__thumb_direction_',
|
|
1437
917
|
propsKey: 'thumbDirection'
|
|
1438
918
|
});
|
|
1439
|
-
|
|
919
|
+
const thumbBorderColorClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1440
920
|
prefix: 'border-color_',
|
|
1441
921
|
propsKey: 'thumbBorderColor'
|
|
1442
922
|
});
|
|
1443
|
-
|
|
923
|
+
const thumbBorderColorHoverClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1444
924
|
prefix: 'border-color_hover_',
|
|
1445
925
|
propsKey: 'thumbBorderColorHover'
|
|
1446
926
|
});
|
|
1447
|
-
|
|
927
|
+
const thumbBorderTypeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
1448
928
|
prefix: 'border_type_',
|
|
1449
929
|
propsKey: 'thumbBorderType'
|
|
1450
930
|
});
|
|
1451
931
|
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, /*#__PURE__*/React__default.default.createElement("div", getRootProps({
|
|
1452
|
-
className:
|
|
932
|
+
className: `form-dropzone__dropzone dropzone ${className} thumbColumn form-dropzone__dropzone_size_${size} ${shapeClass}`
|
|
1453
933
|
}), /*#__PURE__*/React__default.default.createElement("input", Object.assign({}, getInputProps(), {
|
|
1454
934
|
name: inputName
|
|
1455
935
|
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
1456
|
-
className: clsx__default.default('form-dropzone__dropzone-wrapper', thumbColumn &&
|
|
1457
|
-
}, files.map(
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
textColorHover: removeThumbTextHoverColor,
|
|
1501
|
-
className: "form-dropzone__thumb-remove-text"
|
|
1502
|
-
}, removeThumbText || 'Remove')));
|
|
1503
|
-
}), !files.length ? /*#__PURE__*/React__default.default.createElement("div", {
|
|
936
|
+
className: clsx__default.default('form-dropzone__dropzone-wrapper', thumbColumn && `form-dropzone__dropzone-wrapper_column_${thumbColumn}`, fillClass, fillHoverClass, borderWidthClass, borderColorClass, borderColorHoverClass, borderTypeClass)
|
|
937
|
+
}, files.map((file, i) => /*#__PURE__*/React__default.default.createElement("aside", {
|
|
938
|
+
className: clsx__default.default('form-dropzone__thumb', fillClass, thumbDirectionClass, thumbBorderWidthClass, thumbBorderColorClass, thumbBorderColorHoverClass, thumbBorderTypeClass),
|
|
939
|
+
key: `${file.id || `${file.name}_${i}` || 'i' + i}`
|
|
940
|
+
}, isPreviews && !file.error && /*#__PURE__*/React__default.default.createElement("div", {
|
|
941
|
+
className: "form-dropzone__thumb-image"
|
|
942
|
+
}, /*#__PURE__*/React__default.default.createElement("img", {
|
|
943
|
+
className: "form-dropzone__thumb-image-inner",
|
|
944
|
+
src: file.preview || file.image,
|
|
945
|
+
onLoad: () => {
|
|
946
|
+
// Revoke data uri after image is loaded
|
|
947
|
+
URL.revokeObjectURL(file.preview);
|
|
948
|
+
}
|
|
949
|
+
})), file.error && /*#__PURE__*/React__default.default.createElement("div", null, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
950
|
+
size: thumbNameTextSize,
|
|
951
|
+
textColor: thumbNameTextColor,
|
|
952
|
+
textWrap: thumbNameTextWrap,
|
|
953
|
+
textWeight: thumbNameTextWeight
|
|
954
|
+
}, fileErrorText || file.error)), isShowFilename && /*#__PURE__*/React__default.default.createElement("div", {
|
|
955
|
+
className: "form-dropzone__thumb-name"
|
|
956
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
957
|
+
size: thumbNameTextSize,
|
|
958
|
+
textColor: thumbNameTextColor,
|
|
959
|
+
textWrap: thumbNameTextWrap,
|
|
960
|
+
textWeight: thumbNameTextWeight,
|
|
961
|
+
className: "form-dropzone__thumb-name-inner"
|
|
962
|
+
}, file.name)), fileIsLoading && /*#__PURE__*/React__default.default.createElement("div", {
|
|
963
|
+
className: "form-dropzone__thumb-loader"
|
|
964
|
+
}, /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
965
|
+
fill: "surfacePrimary",
|
|
966
|
+
height: "fill",
|
|
967
|
+
itemFill: "surfaceItemAccent",
|
|
968
|
+
set: "simple",
|
|
969
|
+
width: "fill"
|
|
970
|
+
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
971
|
+
className: "form-dropzone__thumb-remove",
|
|
972
|
+
onClick: event => removeFile(event, i)
|
|
973
|
+
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
974
|
+
size: removeThumbTextSize,
|
|
975
|
+
textColor: removeThumbTextColor,
|
|
976
|
+
textWeight: removeThumbTextWeight,
|
|
977
|
+
textColorHover: removeThumbTextHoverColor,
|
|
978
|
+
className: "form-dropzone__thumb-remove-text"
|
|
979
|
+
}, removeThumbText || 'Remove')))), !files.length ? /*#__PURE__*/React__default.default.createElement("div", {
|
|
1504
980
|
className: "form-dropzone__hint"
|
|
1505
981
|
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1506
982
|
size: hintTitleTextSize,
|
|
@@ -1553,132 +1029,133 @@ FileInputDropzone.propTypes = {
|
|
|
1553
1029
|
onDeleteFile: PropTypes__default.default.func
|
|
1554
1030
|
};
|
|
1555
1031
|
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1032
|
+
const FileInput = /*#__PURE__*/React__default.default.memo(function FileInput(props) {
|
|
1033
|
+
const {
|
|
1034
|
+
name,
|
|
1035
|
+
shape,
|
|
1036
|
+
size,
|
|
1037
|
+
borderWidth,
|
|
1038
|
+
borderColor,
|
|
1039
|
+
borderColorHover,
|
|
1040
|
+
borderType,
|
|
1041
|
+
label,
|
|
1042
|
+
thumbBorderWidth,
|
|
1043
|
+
thumbBorderColor,
|
|
1044
|
+
thumbBorderColorHover,
|
|
1045
|
+
thumbBorderType,
|
|
1046
|
+
removeThumbTextHoverColor,
|
|
1047
|
+
labelTextColor,
|
|
1048
|
+
fill,
|
|
1049
|
+
fillHover,
|
|
1050
|
+
className,
|
|
1051
|
+
removeThumbText,
|
|
1052
|
+
thumbNameTextSize,
|
|
1053
|
+
thumbNameTextColor,
|
|
1054
|
+
thumbNameTextWrap,
|
|
1055
|
+
thumbNameTextWeight,
|
|
1056
|
+
removeThumbTextSize,
|
|
1057
|
+
removeThumbTextColor,
|
|
1058
|
+
removeThumbTextWeight,
|
|
1059
|
+
hintTitle,
|
|
1060
|
+
errorMessageTextSize,
|
|
1061
|
+
errorMessageTextWeight,
|
|
1062
|
+
errorMessageTextColor,
|
|
1063
|
+
fieldProps,
|
|
1064
|
+
hintTitleTextSize,
|
|
1065
|
+
hintTitleTextColor,
|
|
1066
|
+
hintTitleTextWrap,
|
|
1067
|
+
hintTitleTextWeight,
|
|
1068
|
+
hintDescriptionTextSize,
|
|
1069
|
+
hintDescriptionTextColor,
|
|
1070
|
+
hintDescriptionTextWrap,
|
|
1071
|
+
hintDescriptionTextWeight,
|
|
1072
|
+
hideMessage,
|
|
1073
|
+
thumbDirection,
|
|
1074
|
+
hintDescription,
|
|
1075
|
+
isShowFilename,
|
|
1076
|
+
fileErrorText,
|
|
1077
|
+
dropzoneProps,
|
|
1078
|
+
maxFiles,
|
|
1079
|
+
maxSize,
|
|
1080
|
+
thumbColumn,
|
|
1081
|
+
isRequired,
|
|
1082
|
+
isPreviews,
|
|
1083
|
+
onAddFiles,
|
|
1084
|
+
onDeleteFile,
|
|
1085
|
+
classNameGroupItem
|
|
1086
|
+
} = props;
|
|
1609
1087
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1610
1088
|
name: name
|
|
1611
|
-
},
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
});
|
|
1089
|
+
}, ({
|
|
1090
|
+
input,
|
|
1091
|
+
meta
|
|
1092
|
+
}) => /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1093
|
+
className: clsx__default.default('form-field_type_dropzone', 'form__item_type_dropzone', classNameGroupItem),
|
|
1094
|
+
fieldClassName: "form-dropzone",
|
|
1095
|
+
inputName: input.name,
|
|
1096
|
+
inputValue: input.value,
|
|
1097
|
+
isRequired: isRequired,
|
|
1098
|
+
label: label,
|
|
1099
|
+
labelTextColor: labelTextColor,
|
|
1100
|
+
metaActive: meta.active,
|
|
1101
|
+
metaError: meta.error,
|
|
1102
|
+
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1103
|
+
metaSubmitError: meta.submitError,
|
|
1104
|
+
metaSubmitFailed: meta.submitFailed,
|
|
1105
|
+
metaTouched: meta.touched,
|
|
1106
|
+
metaValid: meta.valid,
|
|
1107
|
+
hideMessage: hideMessage
|
|
1108
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(FileInputDropzone, {
|
|
1109
|
+
dropzoneProps: dropzoneProps,
|
|
1110
|
+
hintDescription: hintDescription,
|
|
1111
|
+
hintTitle: hintTitle,
|
|
1112
|
+
borderWidth: borderWidth,
|
|
1113
|
+
borderColor: borderColor,
|
|
1114
|
+
borderColorHover: borderColorHover,
|
|
1115
|
+
borderType: borderType,
|
|
1116
|
+
thumbBorderWidth: thumbBorderWidth,
|
|
1117
|
+
thumbBorderColor: thumbBorderColor,
|
|
1118
|
+
thumbBorderColorHover: thumbBorderColorHover,
|
|
1119
|
+
thumbBorderType: thumbBorderType,
|
|
1120
|
+
fileErrorText: fileErrorText,
|
|
1121
|
+
fill: fill,
|
|
1122
|
+
size: size,
|
|
1123
|
+
maxFiles: maxFiles,
|
|
1124
|
+
maxSize: maxSize,
|
|
1125
|
+
removeThumbTextHoverColor: removeThumbTextHoverColor,
|
|
1126
|
+
fillHover: fillHover,
|
|
1127
|
+
className: className,
|
|
1128
|
+
thumbColumn: thumbColumn,
|
|
1129
|
+
thumbDirection: thumbDirection,
|
|
1130
|
+
inputName: input.name,
|
|
1131
|
+
inputValue: input.value,
|
|
1132
|
+
thumbNameTextSize: thumbNameTextSize,
|
|
1133
|
+
thumbNameTextColor: thumbNameTextColor,
|
|
1134
|
+
thumbNameTextWrap: thumbNameTextWrap,
|
|
1135
|
+
thumbNameTextWeight: thumbNameTextWeight,
|
|
1136
|
+
hintTitleTextSize: hintTitleTextSize,
|
|
1137
|
+
hintTitleTextColor: hintTitleTextColor,
|
|
1138
|
+
hintTitleTextWrap: hintTitleTextWrap,
|
|
1139
|
+
hintTitleTextWeight: hintTitleTextWeight,
|
|
1140
|
+
removeThumbTextSize: removeThumbTextSize,
|
|
1141
|
+
removeThumbTextColor: removeThumbTextColor,
|
|
1142
|
+
removeThumbTextWeight: removeThumbTextWeight,
|
|
1143
|
+
hintDescriptionTextSize: hintDescriptionTextSize,
|
|
1144
|
+
hintDescriptionTextColor: hintDescriptionTextColor,
|
|
1145
|
+
hintDescriptionTextWrap: hintDescriptionTextWrap,
|
|
1146
|
+
hintDescriptionTextWeight: hintDescriptionTextWeight,
|
|
1147
|
+
errorMessageTextSize: errorMessageTextSize,
|
|
1148
|
+
errorMessageWeight: errorMessageTextWeight,
|
|
1149
|
+
errorMessageTextColor: errorMessageTextColor,
|
|
1150
|
+
isPreviews: isPreviews,
|
|
1151
|
+
shape: shape,
|
|
1152
|
+
isShowFilename: isShowFilename,
|
|
1153
|
+
metaError: meta.error,
|
|
1154
|
+
metaTouched: meta.touched,
|
|
1155
|
+
removeThumbText: removeThumbText,
|
|
1156
|
+
onAddFiles: onAddFiles,
|
|
1157
|
+
onDeleteFile: onDeleteFile
|
|
1158
|
+
})));
|
|
1682
1159
|
});
|
|
1683
1160
|
FileInput.defaultProps = {
|
|
1684
1161
|
errorMessageTextSize: 's',
|
|
@@ -1705,33 +1182,36 @@ FileInput.propTypes = {
|
|
|
1705
1182
|
onDeleteFile: PropTypes__default.default.func
|
|
1706
1183
|
};
|
|
1707
1184
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1185
|
+
const Group = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
1186
|
+
const {
|
|
1187
|
+
after,
|
|
1188
|
+
before,
|
|
1189
|
+
className,
|
|
1190
|
+
label,
|
|
1191
|
+
labelTextColor,
|
|
1192
|
+
labelTextSize,
|
|
1193
|
+
labelTextWeight,
|
|
1194
|
+
message,
|
|
1195
|
+
errorMessageTextSize,
|
|
1196
|
+
errorMessageTextWeight,
|
|
1197
|
+
errorMessageTextColor,
|
|
1198
|
+
messageTextSize,
|
|
1199
|
+
messageTextWeight,
|
|
1200
|
+
messageTextColor,
|
|
1201
|
+
children,
|
|
1202
|
+
dataTour,
|
|
1203
|
+
hideMessage,
|
|
1204
|
+
name,
|
|
1205
|
+
showErrorsOnSubmit
|
|
1206
|
+
} = props;
|
|
1728
1207
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1729
1208
|
name: name
|
|
1730
|
-
},
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1209
|
+
}, ({
|
|
1210
|
+
input,
|
|
1211
|
+
meta
|
|
1212
|
+
}) => {
|
|
1213
|
+
const error = meta.error || !meta.modifiedSinceLastSubmit && meta.submitError || false;
|
|
1214
|
+
const showError = React.useMemo(() => {
|
|
1735
1215
|
if (showErrorsOnSubmit) {
|
|
1736
1216
|
return meta.submitFailed && meta.touched && error;
|
|
1737
1217
|
} else {
|
|
@@ -1756,7 +1236,7 @@ var Group = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
|
1756
1236
|
size: errorMessageTextSize,
|
|
1757
1237
|
textWeight: errorMessageTextWeight,
|
|
1758
1238
|
textColor: errorMessageTextColor,
|
|
1759
|
-
id: name
|
|
1239
|
+
id: `${name}-error`
|
|
1760
1240
|
}, error), Boolean(message) && !showError && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1761
1241
|
className: "form__group-message",
|
|
1762
1242
|
size: messageTextSize,
|
|
@@ -1765,7 +1245,7 @@ var Group = /*#__PURE__*/React__default.default.memo(function Group(props) {
|
|
|
1765
1245
|
}, message), Boolean(!showError) && Boolean(!message) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
1766
1246
|
className: "form__group-message",
|
|
1767
1247
|
size: messageTextSize
|
|
1768
|
-
},
|
|
1248
|
+
}, '\u00A0')));
|
|
1769
1249
|
});
|
|
1770
1250
|
});
|
|
1771
1251
|
Group.defaultProps = {
|
|
@@ -1784,48 +1264,47 @@ Group.propTypes = {
|
|
|
1784
1264
|
inputProps: PropTypes__default.default.object
|
|
1785
1265
|
};
|
|
1786
1266
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1267
|
+
const InputField = /*#__PURE__*/React__default.default.memo(function InputField(props) {
|
|
1268
|
+
const {
|
|
1269
|
+
isPassword,
|
|
1270
|
+
isRequired,
|
|
1271
|
+
fieldProps,
|
|
1272
|
+
inputProps,
|
|
1273
|
+
isRevealable,
|
|
1274
|
+
name,
|
|
1275
|
+
parse,
|
|
1276
|
+
iconSize,
|
|
1277
|
+
iconBorder,
|
|
1278
|
+
iconBorderHover,
|
|
1279
|
+
iconFill,
|
|
1280
|
+
iconFillHover,
|
|
1281
|
+
iconRevealableShow,
|
|
1282
|
+
iconRevealableHide,
|
|
1283
|
+
iconShape,
|
|
1284
|
+
hideMessage,
|
|
1285
|
+
onChange,
|
|
1286
|
+
classNameGroupItem
|
|
1287
|
+
} = props;
|
|
1288
|
+
const [isRevealed, setIsRevealed] = React.useState(false);
|
|
1289
|
+
const inputType = React.useMemo(() => {
|
|
1810
1290
|
if (isPassword) {
|
|
1811
1291
|
return isRevealed ? 'text' : 'password';
|
|
1812
1292
|
} else {
|
|
1813
1293
|
return 'text';
|
|
1814
1294
|
}
|
|
1815
1295
|
}, [isRevealed, isPassword]);
|
|
1816
|
-
|
|
1296
|
+
const revealeHandler = React.useCallback(e => {
|
|
1817
1297
|
e.preventDefault();
|
|
1818
|
-
setIsRevealed(
|
|
1819
|
-
return !prev;
|
|
1820
|
-
});
|
|
1298
|
+
setIsRevealed(prev => !prev);
|
|
1821
1299
|
}, [setIsRevealed]);
|
|
1822
1300
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1823
1301
|
name: name,
|
|
1824
1302
|
parse: parse
|
|
1825
|
-
},
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1303
|
+
}, ({
|
|
1304
|
+
input,
|
|
1305
|
+
meta
|
|
1306
|
+
}) => {
|
|
1307
|
+
const onChangeField = React.useCallback(event => {
|
|
1829
1308
|
input.onChange(event);
|
|
1830
1309
|
if (onChange) {
|
|
1831
1310
|
onChange(event.target.value, input.name);
|
|
@@ -1881,11 +1360,13 @@ InputField.propTypes = {
|
|
|
1881
1360
|
};
|
|
1882
1361
|
|
|
1883
1362
|
function RadioGroupItem(props) {
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1363
|
+
const {
|
|
1364
|
+
input,
|
|
1365
|
+
option,
|
|
1366
|
+
onChange,
|
|
1367
|
+
inputProps
|
|
1368
|
+
} = props;
|
|
1369
|
+
const onChangeField = React.useCallback(event => {
|
|
1889
1370
|
if (event.target.checked) {
|
|
1890
1371
|
onChange(option.value);
|
|
1891
1372
|
}
|
|
@@ -1919,12 +1400,12 @@ RadioGroupItem.propTypes = {
|
|
|
1919
1400
|
};
|
|
1920
1401
|
|
|
1921
1402
|
function RadioGroupInput(props) {
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1403
|
+
const {
|
|
1404
|
+
input,
|
|
1405
|
+
value,
|
|
1406
|
+
onChange
|
|
1407
|
+
} = props;
|
|
1408
|
+
const onChangeField = React.useCallback(event => onChange(event.target.value), [onChange]);
|
|
1928
1409
|
return /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
1929
1410
|
autoComplete: "nope",
|
|
1930
1411
|
name: input.name,
|
|
@@ -1942,29 +1423,25 @@ RadioGroupInput.propTypes = {
|
|
|
1942
1423
|
};
|
|
1943
1424
|
|
|
1944
1425
|
function RadioGroupList(props) {
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
setEditableValue = _useState[1];
|
|
1961
|
-
React.useEffect(function () {
|
|
1426
|
+
const {
|
|
1427
|
+
input,
|
|
1428
|
+
options,
|
|
1429
|
+
editableProps,
|
|
1430
|
+
onChange,
|
|
1431
|
+
inputProps
|
|
1432
|
+
} = props;
|
|
1433
|
+
const [editableValue, setEditableValue] = React.useState(() => {
|
|
1434
|
+
const isRadioValue = options.find(option => option.value === input.value);
|
|
1435
|
+
if (!isRadioValue) {
|
|
1436
|
+
return input.value;
|
|
1437
|
+
}
|
|
1438
|
+
return '';
|
|
1439
|
+
});
|
|
1440
|
+
React.useEffect(() => {
|
|
1962
1441
|
// When a new value from outside enters the form
|
|
1963
1442
|
if (input.value) {
|
|
1964
1443
|
// Check value for radio type
|
|
1965
|
-
|
|
1966
|
-
return option.value === input.value && !option.editable;
|
|
1967
|
-
});
|
|
1444
|
+
const isRadioValue = options.find(option => option.value === input.value && !option.editable);
|
|
1968
1445
|
// If new value not in radio list - set to editable input
|
|
1969
1446
|
setEditableValue(isRadioValue ? '' : input.value);
|
|
1970
1447
|
} else {
|
|
@@ -1974,7 +1451,7 @@ function RadioGroupList(props) {
|
|
|
1974
1451
|
}, [input.value]);
|
|
1975
1452
|
|
|
1976
1453
|
// Callback for value changes
|
|
1977
|
-
|
|
1454
|
+
const onChangeSomeInput = React.useCallback(value => {
|
|
1978
1455
|
// Save to form values
|
|
1979
1456
|
input.onChange(value);
|
|
1980
1457
|
if (onChange) {
|
|
@@ -1984,33 +1461,31 @@ function RadioGroupList(props) {
|
|
|
1984
1461
|
}, [input, onChange]);
|
|
1985
1462
|
|
|
1986
1463
|
// Handle for radio inputs
|
|
1987
|
-
|
|
1464
|
+
const onChangeRadio = React.useCallback(value => {
|
|
1988
1465
|
setEditableValue('');
|
|
1989
1466
|
onChangeSomeInput(value);
|
|
1990
1467
|
}, [onChangeSomeInput]);
|
|
1991
1468
|
|
|
1992
1469
|
// Handle for text input
|
|
1993
|
-
|
|
1470
|
+
const onChangeEditable = React.useCallback(value => {
|
|
1994
1471
|
setEditableValue(value);
|
|
1995
1472
|
onChangeSomeInput(value);
|
|
1996
1473
|
}, [onChangeSomeInput]);
|
|
1997
|
-
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
});
|
|
2013
|
-
}));
|
|
1474
|
+
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(option => option.editable ? /*#__PURE__*/React__default.default.createElement(RadioGroupInput, {
|
|
1475
|
+
key: option.label,
|
|
1476
|
+
input: input,
|
|
1477
|
+
value: editableValue,
|
|
1478
|
+
option: option,
|
|
1479
|
+
onChange: onChangeEditable,
|
|
1480
|
+
editableProps: editableProps,
|
|
1481
|
+
inputProps: inputProps
|
|
1482
|
+
}) : /*#__PURE__*/React__default.default.createElement(RadioGroupItem, {
|
|
1483
|
+
key: option.value,
|
|
1484
|
+
input: input,
|
|
1485
|
+
option: option,
|
|
1486
|
+
onChange: onChangeRadio,
|
|
1487
|
+
inputProps: inputProps
|
|
1488
|
+
})));
|
|
2014
1489
|
}
|
|
2015
1490
|
RadioGroupList.propTypes = {
|
|
2016
1491
|
editableProps: PropTypes__default.default.object,
|
|
@@ -2020,42 +1495,43 @@ RadioGroupList.propTypes = {
|
|
|
2020
1495
|
options: PropTypes__default.default.object
|
|
2021
1496
|
};
|
|
2022
1497
|
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
1498
|
+
const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(props) {
|
|
1499
|
+
const {
|
|
1500
|
+
isRequired,
|
|
1501
|
+
name,
|
|
1502
|
+
options,
|
|
1503
|
+
fieldProps,
|
|
1504
|
+
editableProps,
|
|
1505
|
+
inputProps,
|
|
1506
|
+
onChange,
|
|
1507
|
+
hideMessage
|
|
1508
|
+
} = props;
|
|
2032
1509
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2033
1510
|
name: name
|
|
2034
|
-
},
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
});
|
|
1511
|
+
}, ({
|
|
1512
|
+
input,
|
|
1513
|
+
meta
|
|
1514
|
+
}) => /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1515
|
+
className: "form__item_type_radio",
|
|
1516
|
+
fieldClassName: 'form-radio',
|
|
1517
|
+
inputName: input.name,
|
|
1518
|
+
inputValue: input.value || '',
|
|
1519
|
+
isRequired: isRequired,
|
|
1520
|
+
metaActive: meta.active,
|
|
1521
|
+
metaError: meta.error,
|
|
1522
|
+
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1523
|
+
metaSubmitError: meta.submitError,
|
|
1524
|
+
metaSubmitFailed: meta.submitFailed,
|
|
1525
|
+
metaTouched: meta.touched,
|
|
1526
|
+
metaValid: meta.valid,
|
|
1527
|
+
hideMessage: hideMessage
|
|
1528
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(RadioGroupList, {
|
|
1529
|
+
input: input,
|
|
1530
|
+
options: options,
|
|
1531
|
+
onChange: onChange,
|
|
1532
|
+
editableProps: editableProps,
|
|
1533
|
+
inputProps: inputProps
|
|
1534
|
+
})));
|
|
2059
1535
|
});
|
|
2060
1536
|
RadioGroup.defaultProps = {
|
|
2061
1537
|
fieldProps: {},
|
|
@@ -2075,33 +1551,35 @@ RadioGroup.propTypes = {
|
|
|
2075
1551
|
|
|
2076
1552
|
// const SegmentedField = React.memo(
|
|
2077
1553
|
function SegmentedField(props) {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
1554
|
+
const {
|
|
1555
|
+
options,
|
|
1556
|
+
isRequired,
|
|
1557
|
+
name,
|
|
1558
|
+
fieldProps,
|
|
1559
|
+
inputProps,
|
|
1560
|
+
hideMessage
|
|
1561
|
+
} = props;
|
|
1562
|
+
const {
|
|
1563
|
+
change
|
|
1564
|
+
} = reactFinalForm.useForm();
|
|
2086
1565
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2087
1566
|
name: name
|
|
2088
|
-
},
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
1567
|
+
}, ({
|
|
1568
|
+
input,
|
|
1569
|
+
meta
|
|
1570
|
+
}) => {
|
|
1571
|
+
const activeOption = React.useMemo(() => {
|
|
1572
|
+
const emptyOption = {
|
|
2093
1573
|
value: null,
|
|
2094
1574
|
label: null
|
|
2095
1575
|
};
|
|
2096
1576
|
if (input.value) {
|
|
2097
|
-
|
|
2098
|
-
return option.value === input.value;
|
|
2099
|
-
});
|
|
1577
|
+
const currentOption = options.find(option => option.value === input.value);
|
|
2100
1578
|
return currentOption || emptyOption;
|
|
2101
1579
|
}
|
|
2102
1580
|
return emptyOption;
|
|
2103
1581
|
}, [input.value]);
|
|
2104
|
-
|
|
1582
|
+
const setActiveSegment = React.useCallback(option => {
|
|
2105
1583
|
change(name, option.value);
|
|
2106
1584
|
}, [change]);
|
|
2107
1585
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
@@ -2140,12 +1618,12 @@ SegmentedField.propTypes = {
|
|
|
2140
1618
|
};
|
|
2141
1619
|
|
|
2142
1620
|
function getDefaultValue(options, selectValue) {
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
options.forEach(
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
1621
|
+
const selectValues = Array.isArray(selectValue) ? selectValue : [selectValue];
|
|
1622
|
+
let result = [];
|
|
1623
|
+
options.forEach(item => {
|
|
1624
|
+
const isValue = selectValues.includes(item.value);
|
|
1625
|
+
const isLabel = selectValues.includes(item.label);
|
|
1626
|
+
let childOptions = [];
|
|
2149
1627
|
if (item.options) {
|
|
2150
1628
|
childOptions = getDefaultValue(item.options, selectValue);
|
|
2151
1629
|
}
|
|
@@ -2157,35 +1635,35 @@ function getDefaultValue(options, selectValue) {
|
|
|
2157
1635
|
});
|
|
2158
1636
|
return result;
|
|
2159
1637
|
}
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
1638
|
+
const SelectField = /*#__PURE__*/React__default.default.memo(function SelectField(props) {
|
|
1639
|
+
const {
|
|
1640
|
+
isRequired,
|
|
1641
|
+
key,
|
|
1642
|
+
name,
|
|
1643
|
+
options,
|
|
1644
|
+
fieldProps,
|
|
1645
|
+
selectProps,
|
|
1646
|
+
selectRef,
|
|
1647
|
+
onChange,
|
|
1648
|
+
classNameGroupItem,
|
|
1649
|
+
hideMessage
|
|
1650
|
+
} = props;
|
|
2171
1651
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2172
1652
|
name: name
|
|
2173
|
-
},
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
1653
|
+
}, ({
|
|
1654
|
+
input,
|
|
1655
|
+
meta
|
|
1656
|
+
}) => {
|
|
1657
|
+
const onChangeField = React.useCallback(value => {
|
|
2177
1658
|
input.onChange(value);
|
|
2178
1659
|
if (onChange) {
|
|
2179
1660
|
onChange(value, input.name);
|
|
2180
1661
|
}
|
|
2181
1662
|
}, [onChange]);
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
var _input$value;
|
|
2187
|
-
var optionsValues = getDefaultValue(options, input.value);
|
|
2188
|
-
if (!optionsValues.length && (_input$value = input.value) != null && _input$value.length) {
|
|
1663
|
+
const [selectedOptions, setSelectedOptions] = React.useState(null);
|
|
1664
|
+
const defaultValue = React.useMemo(() => {
|
|
1665
|
+
const optionsValues = getDefaultValue(options, input.value);
|
|
1666
|
+
if (!optionsValues.length && input.value?.length) {
|
|
2189
1667
|
optionsValues.push({
|
|
2190
1668
|
value: input.value,
|
|
2191
1669
|
label: input.value
|
|
@@ -2193,13 +1671,9 @@ var SelectField = /*#__PURE__*/React__default.default.memo(function SelectField(
|
|
|
2193
1671
|
}
|
|
2194
1672
|
return optionsValues;
|
|
2195
1673
|
}, [input.value]);
|
|
2196
|
-
React.useEffect(
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
var onChangeValue = React.useCallback(function (option, actionMeta) {
|
|
2200
|
-
var value = Array.isArray(option) ? option.map(function (o) {
|
|
2201
|
-
return o.value;
|
|
2202
|
-
}) : (option == null ? void 0 : option.value) || null;
|
|
1674
|
+
React.useEffect(() => setSelectedOptions(defaultValue), [defaultValue]);
|
|
1675
|
+
const onChangeValue = React.useCallback((option, actionMeta) => {
|
|
1676
|
+
const value = Array.isArray(option) ? option.map(o => o.value) : option?.value || null;
|
|
2203
1677
|
setSelectedOptions(option);
|
|
2204
1678
|
onChangeField(value);
|
|
2205
1679
|
}, [onChangeField]);
|
|
@@ -2219,7 +1693,7 @@ var SelectField = /*#__PURE__*/React__default.default.memo(function SelectField(
|
|
|
2219
1693
|
hideMessage: hideMessage
|
|
2220
1694
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Select.Select, Object.assign({
|
|
2221
1695
|
className: "form-select-item",
|
|
2222
|
-
instanceId:
|
|
1696
|
+
instanceId: `id_${input.name}`,
|
|
2223
1697
|
value: selectedOptions,
|
|
2224
1698
|
onChange: onChangeValue,
|
|
2225
1699
|
options: options,
|
|
@@ -2238,21 +1712,24 @@ SelectField.propTypes = {
|
|
|
2238
1712
|
onChange: PropTypes__default.default.func
|
|
2239
1713
|
};
|
|
2240
1714
|
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
1715
|
+
const SwitchField = /*#__PURE__*/React__default.default.memo(function SwitchField(props) {
|
|
1716
|
+
const {
|
|
1717
|
+
name,
|
|
1718
|
+
isRequired,
|
|
1719
|
+
onChange,
|
|
1720
|
+
fieldProps,
|
|
1721
|
+
inputProps,
|
|
1722
|
+
classNameGroupItem,
|
|
1723
|
+
hideMessage
|
|
1724
|
+
} = props;
|
|
2249
1725
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2250
1726
|
name: name,
|
|
2251
1727
|
type: "checkbox"
|
|
2252
|
-
},
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
1728
|
+
}, ({
|
|
1729
|
+
input,
|
|
1730
|
+
meta
|
|
1731
|
+
}) => {
|
|
1732
|
+
const onChangeField = React.useCallback(event => {
|
|
2256
1733
|
input.onChange(event);
|
|
2257
1734
|
if (onChange) {
|
|
2258
1735
|
onChange(event.target.checked, input.name);
|
|
@@ -2296,41 +1773,42 @@ SwitchField.propTypes = {
|
|
|
2296
1773
|
onChange: PropTypes__default.default.func
|
|
2297
1774
|
};
|
|
2298
1775
|
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
1776
|
+
const TextareaField = /*#__PURE__*/React__default.default.memo(function TextareaField(props) {
|
|
1777
|
+
const {
|
|
1778
|
+
isRequired,
|
|
1779
|
+
name,
|
|
1780
|
+
fieldProps,
|
|
1781
|
+
inputProps,
|
|
1782
|
+
classNameGroupItem,
|
|
1783
|
+
hideMessage
|
|
1784
|
+
} = props;
|
|
2306
1785
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2307
1786
|
name: name
|
|
2308
|
-
},
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
});
|
|
1787
|
+
}, ({
|
|
1788
|
+
input,
|
|
1789
|
+
meta
|
|
1790
|
+
}) => /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1791
|
+
className: clsx__default.default('form-field_type_textarea', 'form__item_type_textarea', classNameGroupItem),
|
|
1792
|
+
fieldClassName: 'form-textarea',
|
|
1793
|
+
inputName: input.name,
|
|
1794
|
+
inputValue: input.value,
|
|
1795
|
+
isRequired: isRequired,
|
|
1796
|
+
metaActive: meta.active,
|
|
1797
|
+
metaError: meta.error,
|
|
1798
|
+
metaModifiedSinceLastSubmit: meta.modifiedSinceLastSubmit,
|
|
1799
|
+
metaSubmitError: meta.submitError,
|
|
1800
|
+
metaSubmitFailed: meta.submitFailed,
|
|
1801
|
+
metaTouched: meta.touched,
|
|
1802
|
+
metaValid: meta.valid,
|
|
1803
|
+
hideMessage: hideMessage
|
|
1804
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Textarea.Textarea, Object.assign({
|
|
1805
|
+
autoComplete: "nope",
|
|
1806
|
+
name: input.name,
|
|
1807
|
+
value: input.value,
|
|
1808
|
+
onBlur: input.onBlur,
|
|
1809
|
+
onChange: input.onChange,
|
|
1810
|
+
onFocus: input.onFocus
|
|
1811
|
+
}, inputProps))));
|
|
2334
1812
|
});
|
|
2335
1813
|
TextareaField.defaultProps = {
|
|
2336
1814
|
inputProps: {},
|
|
@@ -2343,32 +1821,32 @@ TextareaField.propTypes = {
|
|
|
2343
1821
|
inputProps: PropTypes__default.default.object
|
|
2344
1822
|
};
|
|
2345
1823
|
|
|
2346
|
-
|
|
2347
|
-
|
|
1824
|
+
const focusOnError = (formElementsList, errors) => {
|
|
1825
|
+
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2348
1826
|
if (fieldName === finalForm.FORM_ERROR) {
|
|
2349
1827
|
// TODO: get from somewhere
|
|
2350
1828
|
return 'notification__item_status_error';
|
|
2351
1829
|
}
|
|
2352
|
-
return
|
|
1830
|
+
return `react-select-id_${fieldName}-input`;
|
|
2353
1831
|
});
|
|
2354
|
-
|
|
1832
|
+
const errorFieldElement = formElementsList.find(element => {
|
|
2355
1833
|
if (element.name) {
|
|
2356
1834
|
return finalForm.getIn(errors, element.name);
|
|
2357
1835
|
} else {
|
|
2358
1836
|
return selectsIds.includes(element.id);
|
|
2359
1837
|
}
|
|
2360
1838
|
});
|
|
2361
|
-
|
|
1839
|
+
const errorsList = Object.keys(errors);
|
|
2362
1840
|
if (!errorFieldElement && errorsList.length) {
|
|
2363
|
-
|
|
1841
|
+
let errorElement;
|
|
2364
1842
|
try {
|
|
2365
|
-
|
|
1843
|
+
const fieldName = errorsList[0];
|
|
2366
1844
|
if (fieldName === finalForm.FORM_ERROR) {
|
|
2367
1845
|
errorElement = document.querySelector('notification__item_status_error');
|
|
2368
1846
|
} else {
|
|
2369
|
-
errorElement = document.querySelector(
|
|
1847
|
+
errorElement = document.querySelector(`#${fieldName}-error`);
|
|
2370
1848
|
if (!errorElement) {
|
|
2371
|
-
errorElement = document.querySelector(
|
|
1849
|
+
errorElement = document.querySelector(`#id_${fieldName}`);
|
|
2372
1850
|
}
|
|
2373
1851
|
}
|
|
2374
1852
|
} catch (err) {
|
|
@@ -2390,12 +1868,11 @@ var focusOnError = function focusOnError(formElementsList, errors) {
|
|
|
2390
1868
|
}
|
|
2391
1869
|
return null;
|
|
2392
1870
|
};
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
var fieldError = data.error;
|
|
1871
|
+
const focusOnErrorDecorator = createDecorator__default.default(null, focusOnError);
|
|
1872
|
+
const setErrorsMutator = (args, state) => {
|
|
1873
|
+
const [fieldName, data] = args;
|
|
1874
|
+
const submitError = data.submitError;
|
|
1875
|
+
const fieldError = data.error;
|
|
2399
1876
|
if (fieldName === 'non_field_errors') {
|
|
2400
1877
|
// state.formState.invalid = true
|
|
2401
1878
|
// state.formState.valid = false
|
|
@@ -2403,15 +1880,17 @@ var setErrorsMutator = function setErrorsMutator(args, state) {
|
|
|
2403
1880
|
state.formState.submitError = submitError;
|
|
2404
1881
|
} else if (fieldName in state.fields) {
|
|
2405
1882
|
if (fieldError) {
|
|
2406
|
-
|
|
2407
|
-
|
|
1883
|
+
const errorsState = Object.assign({}, state.formState.errors, {
|
|
1884
|
+
[fieldName]: fieldError
|
|
1885
|
+
});
|
|
2408
1886
|
state.fields[fieldName].touched = true;
|
|
2409
1887
|
state.fields[fieldName].error = fieldError;
|
|
2410
1888
|
state.formState.errors = errorsState;
|
|
2411
1889
|
}
|
|
2412
1890
|
if (submitError) {
|
|
2413
|
-
|
|
2414
|
-
|
|
1891
|
+
const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
|
|
1892
|
+
[fieldName]: submitError
|
|
1893
|
+
});
|
|
2415
1894
|
|
|
2416
1895
|
// state.fields[fieldName].submitFailed = true
|
|
2417
1896
|
// state.fields[fieldName].submitSucceeded = false
|
|
@@ -2423,56 +1902,36 @@ var setErrorsMutator = function setErrorsMutator(args, state) {
|
|
|
2423
1902
|
}
|
|
2424
1903
|
}
|
|
2425
1904
|
};
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
var fieldName = _ref2[0],
|
|
2455
|
-
errorsList = _ref2[1];
|
|
2456
|
-
formErrors[fieldName] = errorsList[0];
|
|
2457
|
-
});
|
|
2458
|
-
}
|
|
2459
|
-
return _context.abrupt("return", {
|
|
2460
|
-
success: false,
|
|
2461
|
-
formErrors: formErrors,
|
|
2462
|
-
error: _context.t0
|
|
2463
|
-
});
|
|
2464
|
-
case 13:
|
|
2465
|
-
case "end":
|
|
2466
|
-
return _context.stop();
|
|
2467
|
-
}
|
|
2468
|
-
}, _callee, null, [[0, 7]]);
|
|
2469
|
-
}));
|
|
2470
|
-
return function sendFormDataToServer(_x, _x2) {
|
|
2471
|
-
return _ref.apply(this, arguments);
|
|
2472
|
-
};
|
|
2473
|
-
}();
|
|
1905
|
+
const sendFormDataToServer = async (url, data) => {
|
|
1906
|
+
try {
|
|
1907
|
+
const response = await axios__default.default({
|
|
1908
|
+
url: url,
|
|
1909
|
+
method: 'POST',
|
|
1910
|
+
data: data
|
|
1911
|
+
});
|
|
1912
|
+
return {
|
|
1913
|
+
success: true,
|
|
1914
|
+
response
|
|
1915
|
+
};
|
|
1916
|
+
} catch (error) {
|
|
1917
|
+
const formErrors = {};
|
|
1918
|
+
if (typeof error.response?.data === 'string') {
|
|
1919
|
+
formErrors[finalForm.FORM_ERROR] = 'Something went wrong';
|
|
1920
|
+
}
|
|
1921
|
+
if (typeof error.response?.data === 'object') {
|
|
1922
|
+
Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
|
|
1923
|
+
formErrors[fieldName] = errorsList[0];
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
return {
|
|
1927
|
+
success: false,
|
|
1928
|
+
formErrors,
|
|
1929
|
+
error
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
};
|
|
2474
1933
|
|
|
2475
|
-
|
|
1934
|
+
const formTypes = {
|
|
2476
1935
|
checkbox: 'checkbox',
|
|
2477
1936
|
custom: 'custom',
|
|
2478
1937
|
choice: 'choice',
|
|
@@ -2484,7 +1943,7 @@ var formTypes = {
|
|
|
2484
1943
|
radioGroup: 'radioGroup',
|
|
2485
1944
|
segmented: 'segmented',
|
|
2486
1945
|
select: 'select',
|
|
2487
|
-
|
|
1946
|
+
switch: 'switch',
|
|
2488
1947
|
text: 'text',
|
|
2489
1948
|
textarea: 'textarea'
|
|
2490
1949
|
};
|
|
@@ -2508,7 +1967,7 @@ function generateField(field, config, props) {
|
|
|
2508
1967
|
key: config.key
|
|
2509
1968
|
}, field, props));
|
|
2510
1969
|
}
|
|
2511
|
-
case formTypes
|
|
1970
|
+
case formTypes.switch:
|
|
2512
1971
|
{
|
|
2513
1972
|
return /*#__PURE__*/React__default.default.createElement(SwitchField, Object.assign({
|
|
2514
1973
|
key: config.key
|
|
@@ -2566,13 +2025,12 @@ function generateField(field, config, props) {
|
|
|
2566
2025
|
{
|
|
2567
2026
|
return /*#__PURE__*/React__default.default.createElement(Group, Object.assign({
|
|
2568
2027
|
key: config.key
|
|
2569
|
-
}, field, props), Object.entries(field.group).map(
|
|
2570
|
-
|
|
2571
|
-
value
|
|
2572
|
-
var groupProps = Object.assign({}, value, {
|
|
2028
|
+
}, field, props), Object.entries(field.group).map(([key, value]) => {
|
|
2029
|
+
const groupProps = {
|
|
2030
|
+
...value,
|
|
2573
2031
|
hideMessage: field.hideMessage,
|
|
2574
2032
|
classNameGroupItem: value.classNameGroupItem || 'form__group-item'
|
|
2575
|
-
}
|
|
2033
|
+
};
|
|
2576
2034
|
return generateField(groupProps, {
|
|
2577
2035
|
key: key + '_form_group'
|
|
2578
2036
|
}, props);
|
|
@@ -2581,118 +2039,121 @@ function generateField(field, config, props) {
|
|
|
2581
2039
|
}
|
|
2582
2040
|
}
|
|
2583
2041
|
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2042
|
+
const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalForm(props, ref) {
|
|
2043
|
+
const {
|
|
2044
|
+
additionalProps,
|
|
2045
|
+
after,
|
|
2046
|
+
before,
|
|
2047
|
+
buttonDirection,
|
|
2048
|
+
buttonGap,
|
|
2049
|
+
buttonPadding,
|
|
2050
|
+
groupGap,
|
|
2051
|
+
className,
|
|
2052
|
+
config,
|
|
2053
|
+
description,
|
|
2054
|
+
descriptionSize,
|
|
2055
|
+
descriptionTextColor,
|
|
2056
|
+
descriptionTextWeight,
|
|
2057
|
+
disableFieldsAutoComplete,
|
|
2058
|
+
fieldsGap,
|
|
2059
|
+
formName,
|
|
2060
|
+
initialValues,
|
|
2061
|
+
initialValuesEqual,
|
|
2062
|
+
isLoading,
|
|
2063
|
+
loader,
|
|
2064
|
+
loaderSet,
|
|
2065
|
+
loaderFill,
|
|
2066
|
+
loaderItemFill,
|
|
2067
|
+
loaderText,
|
|
2068
|
+
language,
|
|
2069
|
+
mutators,
|
|
2070
|
+
onChangeFormValues,
|
|
2071
|
+
onClickSecondaryButton,
|
|
2072
|
+
onClickTertiaryButton,
|
|
2073
|
+
onSubmit,
|
|
2074
|
+
primaryButton,
|
|
2075
|
+
primaryButtonLabel,
|
|
2076
|
+
secondaryButton,
|
|
2077
|
+
secondaryButtonLabel,
|
|
2078
|
+
primaryButtonFill,
|
|
2079
|
+
primaryButtonFillHover,
|
|
2080
|
+
secondaryButtonFill,
|
|
2081
|
+
secondaryButtonFillHover,
|
|
2082
|
+
primaryButtonSize,
|
|
2083
|
+
primaryButtonLabelTextColor,
|
|
2084
|
+
primaryButtonLabelSize,
|
|
2085
|
+
primaryButtonLabelTextWeight,
|
|
2086
|
+
secondaryButtonSize,
|
|
2087
|
+
secondaryButtonLabelTextColor,
|
|
2088
|
+
secondaryButtonLabelSize,
|
|
2089
|
+
secondaryButtonLabelTextWeight,
|
|
2090
|
+
tertiaryButton,
|
|
2091
|
+
tertiaryButtonFill,
|
|
2092
|
+
tertiaryButtonFillHover,
|
|
2093
|
+
tertiaryButtonSize,
|
|
2094
|
+
tertiaryButtonLabelTextColor,
|
|
2095
|
+
tertiaryButtonLabelSize,
|
|
2096
|
+
tertiaryButtonLabelTextWeight,
|
|
2097
|
+
tertiaryButtonLabel,
|
|
2098
|
+
set,
|
|
2099
|
+
type,
|
|
2100
|
+
buttonJustifyContent,
|
|
2101
|
+
title,
|
|
2102
|
+
notificationType,
|
|
2103
|
+
notificationClose,
|
|
2104
|
+
buttonFill,
|
|
2105
|
+
titleTextSize,
|
|
2106
|
+
titleTextColor,
|
|
2107
|
+
titleTextWeight,
|
|
2108
|
+
validationSchema,
|
|
2109
|
+
dataTour,
|
|
2110
|
+
dataTourButtons,
|
|
2111
|
+
dataTourPrimaryButton,
|
|
2112
|
+
dataTourSecondaryButton,
|
|
2113
|
+
dataTourTertiaryButton
|
|
2114
|
+
} = props;
|
|
2115
|
+
const validate = useYupValidationSchema(validationSchema, language);
|
|
2116
|
+
const onRefFormInstance = React.useCallback(formInstance => {
|
|
2656
2117
|
if (ref) {
|
|
2657
2118
|
ref.current = formInstance;
|
|
2658
2119
|
}
|
|
2659
2120
|
}, [ref]);
|
|
2660
|
-
|
|
2121
|
+
const fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
2661
2122
|
prefix: 'fill_',
|
|
2662
2123
|
propsKey: 'fill'
|
|
2663
2124
|
});
|
|
2664
|
-
|
|
2125
|
+
const directionClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
2665
2126
|
prefix: 'direction_',
|
|
2666
2127
|
propsKey: 'direction'
|
|
2667
2128
|
});
|
|
2668
|
-
|
|
2129
|
+
const shapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
2669
2130
|
prefix: 'shape_',
|
|
2670
2131
|
propsKey: 'shape'
|
|
2671
2132
|
});
|
|
2672
|
-
|
|
2133
|
+
const elevationClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
2673
2134
|
prefix: 'elevation_',
|
|
2674
2135
|
propsKey: 'elevation'
|
|
2675
2136
|
});
|
|
2676
|
-
|
|
2677
|
-
formStyles
|
|
2137
|
+
const {
|
|
2138
|
+
styles: formStyles
|
|
2139
|
+
} = useStyles.useStyles(props);
|
|
2678
2140
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Form, {
|
|
2679
2141
|
decorators: [focusOnErrorDecorator],
|
|
2680
2142
|
initialValues: initialValues,
|
|
2681
2143
|
initialValuesEqual: initialValuesEqual,
|
|
2682
2144
|
mutators: mutators,
|
|
2683
|
-
render:
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2145
|
+
render: ({
|
|
2146
|
+
handleSubmit,
|
|
2147
|
+
submitError,
|
|
2148
|
+
modifiedSinceLastSubmit,
|
|
2149
|
+
form
|
|
2150
|
+
}) => {
|
|
2688
2151
|
return /*#__PURE__*/React__default.default.createElement("form", {
|
|
2689
2152
|
style: formStyles,
|
|
2690
|
-
className: clsx__default.default(className, 'form', set &&
|
|
2153
|
+
className: clsx__default.default(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass),
|
|
2691
2154
|
name: formName,
|
|
2692
2155
|
"data-tour": dataTour,
|
|
2693
|
-
ref:
|
|
2694
|
-
return onRefFormInstance(form);
|
|
2695
|
-
},
|
|
2156
|
+
ref: () => onRefFormInstance(form),
|
|
2696
2157
|
onSubmit: handleSubmit,
|
|
2697
2158
|
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2698
2159
|
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
@@ -2709,10 +2170,11 @@ var FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalFor
|
|
|
2709
2170
|
textColor: descriptionTextColor,
|
|
2710
2171
|
textWeight: descriptionTextWeight
|
|
2711
2172
|
}, description), submitError && !modifiedSinceLastSubmit && /*#__PURE__*/React__default.default.createElement("div", {
|
|
2712
|
-
className: clsx__default.default('notification', 'form-notification', notificationType ?
|
|
2173
|
+
className: clsx__default.default('notification', 'form-notification', notificationType ? `form-notification_type_${notificationType}` : 'form-notification_type_global')
|
|
2713
2174
|
}, /*#__PURE__*/React__default.default.createElement(Notification.NotificationItem, {
|
|
2714
2175
|
className: "form-notification__item",
|
|
2715
2176
|
titleTextSize: "h6",
|
|
2177
|
+
notificationClose: notificationClose,
|
|
2716
2178
|
title: form.getState().submitError,
|
|
2717
2179
|
set: "form",
|
|
2718
2180
|
status: "error"
|
|
@@ -2725,11 +2187,9 @@ var FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalFor
|
|
|
2725
2187
|
direction: "vertical",
|
|
2726
2188
|
gap: fieldsGap || groupGap,
|
|
2727
2189
|
className: "form__wrapper"
|
|
2728
|
-
}, Object.keys(config).map(
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
}, additionalProps[config[key].name]);
|
|
2732
|
-
}), isLoading && (loader || /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
2190
|
+
}, Object.keys(config).map(key => generateField(config[key], {
|
|
2191
|
+
key
|
|
2192
|
+
}, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
2733
2193
|
className: "form__loader",
|
|
2734
2194
|
set: loaderSet,
|
|
2735
2195
|
fill: loaderFill,
|