@bigbinary/neeto-form-frontend 1.2.14 → 1.2.16
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/README.md +1 -1
- package/app/javascript/src/translations/en.json +1 -1
- package/dist/index.cjs.js +1745 -384
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1746 -385
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/types.d.ts +267 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React$2 from 'react';
|
|
2
|
-
import React__default, { useState, useRef, useEffect, useContext, useLayoutEffect as useLayoutEffect$1, memo, forwardRef, useCallback as useCallback$1,
|
|
2
|
+
import React__default, { useState, useRef, useEffect, useContext, useLayoutEffect as useLayoutEffect$1, memo, forwardRef, useImperativeHandle, Fragment, useReducer, useCallback as useCallback$1, useMemo as useMemo$1, createContext, createElement } from 'react';
|
|
3
3
|
import { useField, useFormikContext, FieldArray, Form as Form$1, Formik, Field, FastField } from 'formik';
|
|
4
4
|
import { noop as noop$4, slugify, findBy, removeBy, isPresent as isPresent$1, findById, isNotEmpty, notEqualsDeep } from '@bigbinary/neeto-cist';
|
|
5
5
|
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
@@ -25,7 +25,6 @@ import localeData from 'dayjs/plugin/localeData';
|
|
|
25
25
|
import utc from 'dayjs/plugin/utc';
|
|
26
26
|
import weekday from 'dayjs/plugin/weekday';
|
|
27
27
|
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
28
|
-
import { useDropzone } from 'react-dropzone';
|
|
29
28
|
import { withEventTargetValue, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
|
|
30
29
|
|
|
31
30
|
function _extends$8() {
|
|
@@ -69,7 +68,7 @@ function _toPropertyKey(arg) {
|
|
|
69
68
|
return _typeof$4(key) === "symbol" ? key : String(key);
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
function _defineProperty$
|
|
71
|
+
function _defineProperty$7(obj, key, value) {
|
|
73
72
|
key = _toPropertyKey(key);
|
|
74
73
|
if (key in obj) {
|
|
75
74
|
Object.defineProperty(obj, key, {
|
|
@@ -95,7 +94,7 @@ var QUERY_KEYS = {
|
|
|
95
94
|
};
|
|
96
95
|
var DIRECT_UPLOAD_URL = "/api/direct_uploads";
|
|
97
96
|
|
|
98
|
-
function _objectWithoutPropertiesLoose$
|
|
97
|
+
function _objectWithoutPropertiesLoose$2(source, excluded) {
|
|
99
98
|
if (source == null) return {};
|
|
100
99
|
var target = {};
|
|
101
100
|
var sourceKeys = Object.keys(source);
|
|
@@ -108,9 +107,9 @@ function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
|
108
107
|
return target;
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
function _objectWithoutProperties(source, excluded) {
|
|
110
|
+
function _objectWithoutProperties$1(source, excluded) {
|
|
112
111
|
if (source == null) return {};
|
|
113
|
-
var target = _objectWithoutPropertiesLoose$
|
|
112
|
+
var target = _objectWithoutPropertiesLoose$2(source, excluded);
|
|
114
113
|
var key, i;
|
|
115
114
|
if (Object.getOwnPropertySymbols) {
|
|
116
115
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
@@ -132,7 +131,7 @@ var _excluded$e = ["size"],
|
|
|
132
131
|
var Star = function Star(props) {
|
|
133
132
|
var _props$size = props.size,
|
|
134
133
|
size = _props$size === void 0 ? 20 : _props$size,
|
|
135
|
-
other = _objectWithoutProperties(props, _excluded$e);
|
|
134
|
+
other = _objectWithoutProperties$1(props, _excluded$e);
|
|
136
135
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
137
136
|
fill: "none",
|
|
138
137
|
height: size,
|
|
@@ -150,7 +149,7 @@ var Star = function Star(props) {
|
|
|
150
149
|
var Heart = function Heart(props) {
|
|
151
150
|
var _props$size2 = props.size,
|
|
152
151
|
size = _props$size2 === void 0 ? 20 : _props$size2,
|
|
153
|
-
other = _objectWithoutProperties(props, _excluded2$1);
|
|
152
|
+
other = _objectWithoutProperties$1(props, _excluded2$1);
|
|
154
153
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
155
154
|
fill: "none",
|
|
156
155
|
height: size,
|
|
@@ -168,7 +167,7 @@ var Heart = function Heart(props) {
|
|
|
168
167
|
var Zap = function Zap(props) {
|
|
169
168
|
var _props$size3 = props.size,
|
|
170
169
|
size = _props$size3 === void 0 ? 20 : _props$size3,
|
|
171
|
-
other = _objectWithoutProperties(props, _excluded3$2);
|
|
170
|
+
other = _objectWithoutProperties$1(props, _excluded3$2);
|
|
172
171
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
173
172
|
fill: "none",
|
|
174
173
|
height: size,
|
|
@@ -186,7 +185,7 @@ var Zap = function Zap(props) {
|
|
|
186
185
|
var Crown = function Crown(_ref) {
|
|
187
186
|
var _ref$size = _ref.size,
|
|
188
187
|
size = _ref$size === void 0 ? 20 : _ref$size,
|
|
189
|
-
otherProps = _objectWithoutProperties(_ref, _excluded4$1);
|
|
188
|
+
otherProps = _objectWithoutProperties$1(_ref, _excluded4$1);
|
|
190
189
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
191
190
|
fill: "none",
|
|
192
191
|
height: size,
|
|
@@ -208,7 +207,7 @@ var Crown = function Crown(_ref) {
|
|
|
208
207
|
var Trophy = function Trophy(_ref2) {
|
|
209
208
|
var _ref2$size = _ref2.size,
|
|
210
209
|
size = _ref2$size === void 0 ? 20 : _ref2$size,
|
|
211
|
-
otherProps = _objectWithoutProperties(_ref2, _excluded5);
|
|
210
|
+
otherProps = _objectWithoutProperties$1(_ref2, _excluded5);
|
|
212
211
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
213
212
|
fill: "none",
|
|
214
213
|
height: size,
|
|
@@ -447,35 +446,35 @@ var ERROR_CODES = {
|
|
|
447
446
|
TOO_MANY_FILES: "too-many-files"
|
|
448
447
|
};
|
|
449
448
|
|
|
450
|
-
function _arrayLikeToArray$
|
|
449
|
+
function _arrayLikeToArray$9(arr, len) {
|
|
451
450
|
if (len == null || len > arr.length) len = arr.length;
|
|
452
451
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
453
452
|
return arr2;
|
|
454
453
|
}
|
|
455
454
|
|
|
456
|
-
function _arrayWithoutHoles(arr) {
|
|
457
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$
|
|
455
|
+
function _arrayWithoutHoles$1(arr) {
|
|
456
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$9(arr);
|
|
458
457
|
}
|
|
459
458
|
|
|
460
|
-
function _iterableToArray(iter) {
|
|
459
|
+
function _iterableToArray$1(iter) {
|
|
461
460
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
462
461
|
}
|
|
463
462
|
|
|
464
|
-
function _unsupportedIterableToArray$
|
|
463
|
+
function _unsupportedIterableToArray$9(o, minLen) {
|
|
465
464
|
if (!o) return;
|
|
466
|
-
if (typeof o === "string") return _arrayLikeToArray$
|
|
465
|
+
if (typeof o === "string") return _arrayLikeToArray$9(o, minLen);
|
|
467
466
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
468
467
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
469
468
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
470
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$
|
|
469
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$9(o, minLen);
|
|
471
470
|
}
|
|
472
471
|
|
|
473
|
-
function _nonIterableSpread() {
|
|
472
|
+
function _nonIterableSpread$1() {
|
|
474
473
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
475
474
|
}
|
|
476
475
|
|
|
477
|
-
function _toConsumableArray(arr) {
|
|
478
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$
|
|
476
|
+
function _toConsumableArray$1(arr) {
|
|
477
|
+
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$9(arr) || _nonIterableSpread$1();
|
|
479
478
|
}
|
|
480
479
|
|
|
481
480
|
var getFormsUrl = function getFormsUrl(id) {
|
|
@@ -553,25 +552,25 @@ var neetoFormApi = {
|
|
|
553
552
|
|
|
554
553
|
var _excluded$d = ["formId", "preview"],
|
|
555
554
|
_excluded3$1 = ["formId", "submissionId"];
|
|
556
|
-
function ownKeys$
|
|
557
|
-
function _objectSpread$
|
|
555
|
+
function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
556
|
+
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
558
557
|
var useForm = function useForm(_ref) {
|
|
559
558
|
var formId = _ref.formId,
|
|
560
559
|
preview = _ref.preview,
|
|
561
|
-
options = _objectWithoutProperties(_ref, _excluded$d);
|
|
560
|
+
options = _objectWithoutProperties$1(_ref, _excluded$d);
|
|
562
561
|
return useQuery([QUERY_KEYS.QUESTIONS, preview ? "preview/".concat(formId) : formId], function () {
|
|
563
562
|
return neetoFormApi.getPublicQuestions(formId);
|
|
564
|
-
}, _objectSpread$
|
|
563
|
+
}, _objectSpread$e({
|
|
565
564
|
keepPreviousData: true
|
|
566
565
|
}, options));
|
|
567
566
|
};
|
|
568
567
|
var useCreateForm = function useCreateForm(options) {
|
|
569
568
|
var queryClient = useQueryClient();
|
|
570
|
-
return useMutation(neetoFormApi.createForm, _objectSpread$
|
|
569
|
+
return useMutation(neetoFormApi.createForm, _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
571
570
|
onSuccess: function onSuccess(form) {
|
|
572
571
|
var _options$onSuccess;
|
|
573
572
|
queryClient.setQueryData(QUERY_KEYS.QUESTIONS, function (forms) {
|
|
574
|
-
return forms && [].concat(_toConsumableArray(forms), [form]);
|
|
573
|
+
return forms && [].concat(_toConsumableArray$1(forms), [form]);
|
|
575
574
|
});
|
|
576
575
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, form.id], form);
|
|
577
576
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(form.id)], form);
|
|
@@ -586,16 +585,16 @@ var useUpdateForm = function useUpdateForm(options) {
|
|
|
586
585
|
var id = _ref2.id,
|
|
587
586
|
values = _ref2.values;
|
|
588
587
|
return neetoFormApi.updateForm(id, values);
|
|
589
|
-
}, _objectSpread$
|
|
588
|
+
}, _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
590
589
|
onSuccess: function onSuccess(data, _ref3) {
|
|
591
590
|
var id = _ref3.id;
|
|
592
591
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, id], function (form) {
|
|
593
|
-
return _objectSpread$
|
|
592
|
+
return _objectSpread$e(_objectSpread$e({}, form), {}, {
|
|
594
593
|
title: data.title
|
|
595
594
|
});
|
|
596
595
|
});
|
|
597
596
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(id)], function (form) {
|
|
598
|
-
return _objectSpread$
|
|
597
|
+
return _objectSpread$e(_objectSpread$e({}, form), {}, {
|
|
599
598
|
title: data.title,
|
|
600
599
|
questions: data.questions
|
|
601
600
|
});
|
|
@@ -613,7 +612,7 @@ var useUpdateQuestions = function useUpdateQuestions(options) {
|
|
|
613
612
|
var id = _ref4.id,
|
|
614
613
|
values = _ref4.values;
|
|
615
614
|
return neetoFormApi.updateQuestions(id, values);
|
|
616
|
-
}, _objectSpread$
|
|
615
|
+
}, _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
617
616
|
onSuccess: function onSuccess() {
|
|
618
617
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
619
618
|
args[_key] = arguments[_key];
|
|
@@ -621,12 +620,12 @@ var useUpdateQuestions = function useUpdateQuestions(options) {
|
|
|
621
620
|
var data = args[0],
|
|
622
621
|
id = args[1].id;
|
|
623
622
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, id], function (form) {
|
|
624
|
-
return _objectSpread$
|
|
623
|
+
return _objectSpread$e(_objectSpread$e({}, form), {}, {
|
|
625
624
|
questions: data.questions
|
|
626
625
|
});
|
|
627
626
|
});
|
|
628
627
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(id)], function (form) {
|
|
629
|
-
return _objectSpread$
|
|
628
|
+
return _objectSpread$e(_objectSpread$e({}, form), {}, {
|
|
630
629
|
questions: data.questions
|
|
631
630
|
});
|
|
632
631
|
});
|
|
@@ -635,7 +634,7 @@ var useUpdateQuestions = function useUpdateQuestions(options) {
|
|
|
635
634
|
}));
|
|
636
635
|
};
|
|
637
636
|
var useForms = function useForms(options) {
|
|
638
|
-
return useQuery([QUERY_KEYS.FORMS], neetoFormApi.getForms, _objectSpread$
|
|
637
|
+
return useQuery([QUERY_KEYS.FORMS], neetoFormApi.getForms, _objectSpread$e({
|
|
639
638
|
keepPreviousData: true
|
|
640
639
|
}, options));
|
|
641
640
|
};
|
|
@@ -644,7 +643,7 @@ var useDeleteForm = function useDeleteForm(options) {
|
|
|
644
643
|
return useMutation(function (_ref5) {
|
|
645
644
|
var id = _ref5.id;
|
|
646
645
|
return neetoFormApi.destroyForm(id);
|
|
647
|
-
}, _objectSpread$
|
|
646
|
+
}, _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
648
647
|
onSuccess: function onSuccess() {
|
|
649
648
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
650
649
|
args[_key2] = arguments[_key2];
|
|
@@ -660,10 +659,10 @@ var useDeleteForm = function useDeleteForm(options) {
|
|
|
660
659
|
var useSubmission = function useSubmission(_ref7) {
|
|
661
660
|
var formId = _ref7.formId,
|
|
662
661
|
submissionId = _ref7.submissionId,
|
|
663
|
-
options = _objectWithoutProperties(_ref7, _excluded3$1);
|
|
662
|
+
options = _objectWithoutProperties$1(_ref7, _excluded3$1);
|
|
664
663
|
return useQuery([QUERY_KEYS.SUBMISSION, formId, submissionId], function () {
|
|
665
664
|
return neetoFormApi.getPublicSubmission(formId, submissionId);
|
|
666
|
-
}, _objectSpread$
|
|
665
|
+
}, _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
667
666
|
keepPreviousData: true
|
|
668
667
|
}));
|
|
669
668
|
};
|
|
@@ -673,7 +672,7 @@ var useCreateSubmission = function useCreateSubmission(options) {
|
|
|
673
672
|
var formId = _ref8.formId,
|
|
674
673
|
values = _ref8.values;
|
|
675
674
|
return neetoFormApi.submitPublicForm(formId, values);
|
|
676
|
-
}, _objectSpread$
|
|
675
|
+
}, _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
677
676
|
onSuccess: function onSuccess() {
|
|
678
677
|
var _data$submission, _data$submission2;
|
|
679
678
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
@@ -694,7 +693,7 @@ var useUpdateSubmission = function useUpdateSubmission(options) {
|
|
|
694
693
|
var formId = _ref9.formId,
|
|
695
694
|
values = _ref9.values;
|
|
696
695
|
return neetoFormApi.updatePublicSubmission(formId, values);
|
|
697
|
-
}, _objectSpread$
|
|
696
|
+
}, _objectSpread$e(_objectSpread$e({}, options), {}, {
|
|
698
697
|
onSuccess: function onSuccess() {
|
|
699
698
|
var _data$submission3;
|
|
700
699
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
@@ -805,11 +804,11 @@ var THUMBS_UP = {
|
|
|
805
804
|
className: "w-20"
|
|
806
805
|
};
|
|
807
806
|
|
|
808
|
-
function _arrayWithHoles$
|
|
807
|
+
function _arrayWithHoles$3(arr) {
|
|
809
808
|
if (Array.isArray(arr)) return arr;
|
|
810
809
|
}
|
|
811
810
|
|
|
812
|
-
function _iterableToArrayLimit$
|
|
811
|
+
function _iterableToArrayLimit$3(r, l) {
|
|
813
812
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
814
813
|
if (null != t) {
|
|
815
814
|
var e,
|
|
@@ -837,12 +836,12 @@ function _iterableToArrayLimit$1(r, l) {
|
|
|
837
836
|
}
|
|
838
837
|
}
|
|
839
838
|
|
|
840
|
-
function _nonIterableRest$
|
|
839
|
+
function _nonIterableRest$3() {
|
|
841
840
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
842
841
|
}
|
|
843
842
|
|
|
844
|
-
function _slicedToArray$
|
|
845
|
-
return _arrayWithHoles$
|
|
843
|
+
function _slicedToArray$3(arr, i) {
|
|
844
|
+
return _arrayWithHoles$3(arr) || _iterableToArrayLimit$3(arr, i) || _unsupportedIterableToArray$9(arr, i) || _nonIterableRest$3();
|
|
846
845
|
}
|
|
847
846
|
|
|
848
847
|
function _typeof$3(o) {
|
|
@@ -871,7 +870,7 @@ function toPropertyKey(t) {
|
|
|
871
870
|
return "symbol" == _typeof$3(i) ? i : String(i);
|
|
872
871
|
}
|
|
873
872
|
|
|
874
|
-
function _defineProperty$
|
|
873
|
+
function _defineProperty$6(obj, key, value) {
|
|
875
874
|
key = toPropertyKey(key);
|
|
876
875
|
if (key in obj) {
|
|
877
876
|
Object.defineProperty(obj, key, {
|
|
@@ -886,7 +885,7 @@ function _defineProperty$5(obj, key, value) {
|
|
|
886
885
|
return obj;
|
|
887
886
|
}
|
|
888
887
|
|
|
889
|
-
function ownKeys$
|
|
888
|
+
function ownKeys$e(e, r) {
|
|
890
889
|
var t = Object.keys(e);
|
|
891
890
|
if (Object.getOwnPropertySymbols) {
|
|
892
891
|
var o = Object.getOwnPropertySymbols(e);
|
|
@@ -899,9 +898,9 @@ function ownKeys$d(e, r) {
|
|
|
899
898
|
function _objectSpread2(e) {
|
|
900
899
|
for (var r = 1; r < arguments.length; r++) {
|
|
901
900
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
902
|
-
r % 2 ? ownKeys$
|
|
903
|
-
_defineProperty$
|
|
904
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$
|
|
901
|
+
r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) {
|
|
902
|
+
_defineProperty$6(e, r, t[r]);
|
|
903
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) {
|
|
905
904
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
906
905
|
});
|
|
907
906
|
}
|
|
@@ -1454,7 +1453,7 @@ function _extends$4() {
|
|
|
1454
1453
|
return _extends$4.apply(this, arguments);
|
|
1455
1454
|
}
|
|
1456
1455
|
|
|
1457
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
1456
|
+
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
1458
1457
|
if (source == null) return {};
|
|
1459
1458
|
var target = {};
|
|
1460
1459
|
var sourceKeys = Object.keys(source);
|
|
@@ -1691,7 +1690,7 @@ function finalPropsSelectorFactory(dispatch, _ref) {
|
|
|
1691
1690
|
initMapDispatchToProps,
|
|
1692
1691
|
initMergeProps
|
|
1693
1692
|
} = _ref,
|
|
1694
|
-
options = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
1693
|
+
options = _objectWithoutPropertiesLoose$1(_ref, _excluded$c);
|
|
1695
1694
|
|
|
1696
1695
|
const mapStateToProps = initMapStateToProps(dispatch, options);
|
|
1697
1696
|
const mapDispatchToProps = initMapDispatchToProps(dispatch, options);
|
|
@@ -2206,7 +2205,7 @@ function connect(mapStateToProps, mapDispatchToProps, mergeProps, {
|
|
|
2206
2205
|
const {
|
|
2207
2206
|
reactReduxForwardedRef
|
|
2208
2207
|
} = props,
|
|
2209
|
-
wrapperProps = _objectWithoutPropertiesLoose(props, _excluded$b);
|
|
2208
|
+
wrapperProps = _objectWithoutPropertiesLoose$1(props, _excluded$b);
|
|
2210
2209
|
|
|
2211
2210
|
return [props.context, reactReduxForwardedRef, wrapperProps];
|
|
2212
2211
|
}, [props]);
|
|
@@ -4899,7 +4898,7 @@ const idle$2 = {
|
|
|
4899
4898
|
completed: null,
|
|
4900
4899
|
shouldFlush: false
|
|
4901
4900
|
};
|
|
4902
|
-
var reducer = ((state = idle$2, action) => {
|
|
4901
|
+
var reducer$1 = ((state = idle$2, action) => {
|
|
4903
4902
|
if (action.type === 'FLUSH') {
|
|
4904
4903
|
return {
|
|
4905
4904
|
...idle$2,
|
|
@@ -5956,7 +5955,7 @@ var createStore = (({
|
|
|
5956
5955
|
getResponders,
|
|
5957
5956
|
announce,
|
|
5958
5957
|
autoScroller
|
|
5959
|
-
}) => createStore$1(reducer, composeEnhancers(applyMiddleware(style(styleMarshal), dimensionMarshalStopper(dimensionMarshal), lift(dimensionMarshal), drop, dropAnimationFinish, dropAnimationFlushOnScroll, pendingDrop$1, autoScroll(autoScroller), scrollListener$1, focus(focusMarshal), responders(getResponders, announce)))));
|
|
5958
|
+
}) => createStore$1(reducer$1, composeEnhancers(applyMiddleware(style(styleMarshal), dimensionMarshalStopper(dimensionMarshal), lift(dimensionMarshal), drop, dropAnimationFinish, dropAnimationFlushOnScroll, pendingDrop$1, autoScroll(autoScroller), scrollListener$1, focus(focusMarshal), responders(getResponders, announce)))));
|
|
5960
5959
|
|
|
5961
5960
|
const clean$1 = () => ({
|
|
5962
5961
|
additions: {},
|
|
@@ -9623,7 +9622,7 @@ function getBody() {
|
|
|
9623
9622
|
!document.body ? invariant$1(false) : void 0;
|
|
9624
9623
|
return document.body;
|
|
9625
9624
|
}
|
|
9626
|
-
const defaultProps = {
|
|
9625
|
+
const defaultProps$1 = {
|
|
9627
9626
|
mode: 'standard',
|
|
9628
9627
|
type: 'DEFAULT',
|
|
9629
9628
|
direction: 'vertical',
|
|
@@ -9638,11 +9637,11 @@ const attachDefaultPropsToOwnProps = ownProps => {
|
|
|
9638
9637
|
...ownProps
|
|
9639
9638
|
};
|
|
9640
9639
|
let defaultPropKey;
|
|
9641
|
-
for (defaultPropKey in defaultProps) {
|
|
9640
|
+
for (defaultPropKey in defaultProps$1) {
|
|
9642
9641
|
if (ownProps[defaultPropKey] === undefined) {
|
|
9643
9642
|
mergedProps = {
|
|
9644
9643
|
...mergedProps,
|
|
9645
|
-
[defaultPropKey]: defaultProps[defaultPropKey]
|
|
9644
|
+
[defaultPropKey]: defaultProps$1[defaultPropKey]
|
|
9646
9645
|
};
|
|
9647
9646
|
}
|
|
9648
9647
|
}
|
|
@@ -9772,8 +9771,8 @@ const ConnectedDroppable = connect(makeMapStateToProps, mapDispatchToProps, (sta
|
|
|
9772
9771
|
})(Droppable$1);
|
|
9773
9772
|
var ConnectedDroppable$1 = ConnectedDroppable;
|
|
9774
9773
|
|
|
9775
|
-
function ownKeys$
|
|
9776
|
-
function _objectSpread$
|
|
9774
|
+
function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9775
|
+
function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9777
9776
|
var defaultConfig = {
|
|
9778
9777
|
strict: true,
|
|
9779
9778
|
matchKey: "value"
|
|
@@ -9781,7 +9780,7 @@ var defaultConfig = {
|
|
|
9781
9780
|
var findOptionByValue = function findOptionByValue(value) {
|
|
9782
9781
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
9783
9782
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
9784
|
-
var configObject = _objectSpread$
|
|
9783
|
+
var configObject = _objectSpread$d(_objectSpread$d({}, defaultConfig), config);
|
|
9785
9784
|
var matchKey = configObject.matchKey,
|
|
9786
9785
|
strict = configObject.strict;
|
|
9787
9786
|
return options.find(function (option) {
|
|
@@ -9795,7 +9794,7 @@ var filterOptionsByValues = function filterOptionsByValues() {
|
|
|
9795
9794
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
9796
9795
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
9797
9796
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
9798
|
-
var configObject = _objectSpread$
|
|
9797
|
+
var configObject = _objectSpread$d(_objectSpread$d({}, defaultConfig), config);
|
|
9799
9798
|
var matchKey = configObject.matchKey,
|
|
9800
9799
|
strict = configObject.strict;
|
|
9801
9800
|
return options.filter(function (option) {
|
|
@@ -9810,10 +9809,10 @@ var filterOptionsByValues = function filterOptionsByValues() {
|
|
|
9810
9809
|
var destroyFromList = function destroyFromList(items, index) {
|
|
9811
9810
|
var itemToRemove = items[index];
|
|
9812
9811
|
if (itemToRemove) {
|
|
9813
|
-
var nextItems = _toConsumableArray(items);
|
|
9812
|
+
var nextItems = _toConsumableArray$1(items);
|
|
9814
9813
|
nextItems.splice(index, 1);
|
|
9815
9814
|
if (itemToRemove.id) {
|
|
9816
|
-
nextItems.push(_objectSpread$
|
|
9815
|
+
nextItems.push(_objectSpread$d(_objectSpread$d({}, itemToRemove), {}, {
|
|
9817
9816
|
_destroy: true
|
|
9818
9817
|
}));
|
|
9819
9818
|
}
|
|
@@ -9822,12 +9821,12 @@ var destroyFromList = function destroyFromList(items, index) {
|
|
|
9822
9821
|
return items;
|
|
9823
9822
|
};
|
|
9824
9823
|
var insertToList = function insertToList(items, item, index) {
|
|
9825
|
-
var nextItems = _toConsumableArray(items !== null && items !== void 0 ? items : []);
|
|
9824
|
+
var nextItems = _toConsumableArray$1(items !== null && items !== void 0 ? items : []);
|
|
9826
9825
|
nextItems.splice(index, 0, item);
|
|
9827
9826
|
return nextItems;
|
|
9828
9827
|
};
|
|
9829
9828
|
var pushToList = function pushToList(items, item) {
|
|
9830
|
-
var nextItems = _toConsumableArray(items !== null && items !== void 0 ? items : []);
|
|
9829
|
+
var nextItems = _toConsumableArray$1(items !== null && items !== void 0 ? items : []);
|
|
9831
9830
|
nextItems.push(item);
|
|
9832
9831
|
return nextItems;
|
|
9833
9832
|
};
|
|
@@ -9881,7 +9880,7 @@ var _excluded$a = ["size", "color"],
|
|
|
9881
9880
|
var BadSmiley = function BadSmiley(props) {
|
|
9882
9881
|
var size = props.size,
|
|
9883
9882
|
color = props.color,
|
|
9884
|
-
other = _objectWithoutProperties(props, _excluded$a);
|
|
9883
|
+
other = _objectWithoutProperties$1(props, _excluded$a);
|
|
9885
9884
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
9886
9885
|
fill: "none",
|
|
9887
9886
|
height: size,
|
|
@@ -9903,7 +9902,7 @@ BadSmiley.defaultProps = {
|
|
|
9903
9902
|
var OkaySmiley = function OkaySmiley(props) {
|
|
9904
9903
|
var size = props.size,
|
|
9905
9904
|
color = props.color,
|
|
9906
|
-
other = _objectWithoutProperties(props, _excluded2);
|
|
9905
|
+
other = _objectWithoutProperties$1(props, _excluded2);
|
|
9907
9906
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
9908
9907
|
fill: "none",
|
|
9909
9908
|
height: size,
|
|
@@ -9925,7 +9924,7 @@ OkaySmiley.defaultProps = {
|
|
|
9925
9924
|
var GoodSmiley = function GoodSmiley(props) {
|
|
9926
9925
|
var size = props.size,
|
|
9927
9926
|
color = props.color,
|
|
9928
|
-
other = _objectWithoutProperties(props, _excluded3);
|
|
9927
|
+
other = _objectWithoutProperties$1(props, _excluded3);
|
|
9929
9928
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
9930
9929
|
fill: "none",
|
|
9931
9930
|
height: size,
|
|
@@ -9947,7 +9946,7 @@ GoodSmiley.defaultProps = {
|
|
|
9947
9946
|
var Drag = function Drag(props) {
|
|
9948
9947
|
var size = props.size,
|
|
9949
9948
|
color = props.color,
|
|
9950
|
-
other = _objectWithoutProperties(props, _excluded4);
|
|
9949
|
+
other = _objectWithoutProperties$1(props, _excluded4);
|
|
9951
9950
|
return /*#__PURE__*/React__default.createElement("svg", _extends$8({
|
|
9952
9951
|
fill: "none",
|
|
9953
9952
|
height: size,
|
|
@@ -9987,7 +9986,7 @@ var Accordion = function Accordion(_ref) {
|
|
|
9987
9986
|
kindUniqueOn = _ref.kindUniqueOn,
|
|
9988
9987
|
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps;
|
|
9989
9988
|
var _useState = useState(false),
|
|
9990
|
-
_useState2 = _slicedToArray$
|
|
9989
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
9991
9990
|
isAddQuestionOpen = _useState2[0],
|
|
9992
9991
|
setIsAddQuestionOpen = _useState2[1];
|
|
9993
9992
|
var _useTranslation = useTranslation(),
|
|
@@ -10098,9 +10097,9 @@ var Accordion = function Accordion(_ref) {
|
|
|
10098
10097
|
var _excluded$9 = ["maxLength"];
|
|
10099
10098
|
var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
10100
10099
|
var maxLength = _ref.maxLength,
|
|
10101
|
-
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
10100
|
+
props = _objectWithoutProperties$1(_ref, _excluded$9);
|
|
10102
10101
|
var _useField = useField(props),
|
|
10103
|
-
_useField2 = _slicedToArray$
|
|
10102
|
+
_useField2 = _slicedToArray$3(_useField, 3),
|
|
10104
10103
|
value = _useField2[0].value,
|
|
10105
10104
|
setValue = _useField2[2].setValue;
|
|
10106
10105
|
useEffect(function () {
|
|
@@ -10117,9 +10116,9 @@ var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
|
10117
10116
|
var _excluded$8 = ["maxLength"];
|
|
10118
10117
|
var TextAreaWithMaxLength = function TextAreaWithMaxLength(_ref) {
|
|
10119
10118
|
var maxLength = _ref.maxLength,
|
|
10120
|
-
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
10119
|
+
props = _objectWithoutProperties$1(_ref, _excluded$8);
|
|
10121
10120
|
var _useField = useField(props),
|
|
10122
|
-
_useField2 = _slicedToArray$
|
|
10121
|
+
_useField2 = _slicedToArray$3(_useField, 3),
|
|
10123
10122
|
value = _useField2[0].value,
|
|
10124
10123
|
setValue = _useField2[2].setValue;
|
|
10125
10124
|
useEffect(function () {
|
|
@@ -10200,7 +10199,7 @@ var STAR_RATING_ICONS_MAP = {
|
|
|
10200
10199
|
trophy: MemoizedTrophy,
|
|
10201
10200
|
zap: MemoizedZap
|
|
10202
10201
|
};
|
|
10203
|
-
var FILE_TYPES_MAP = (_FILE_TYPES_MAP = {}, _defineProperty$
|
|
10202
|
+
var FILE_TYPES_MAP = (_FILE_TYPES_MAP = {}, _defineProperty$7(_FILE_TYPES_MAP, FILE_TYPES.DOCUMENTS, ["pdf", "doc", "docx", "xls", "xlsx", "csv", "txt", "rtf", "html", "zip", "md"]), _defineProperty$7(_FILE_TYPES_MAP, FILE_TYPES.IMAGES, ["jpg", "jpeg", "png", "gif"]), _defineProperty$7(_FILE_TYPES_MAP, FILE_TYPES.AUDIO_VIDEO, ["mp3", "wma", "mpg", "flv", "avi"]), _FILE_TYPES_MAP);
|
|
10204
10203
|
var DEFAULT_ALLOWED_FILE_TYPES = values(FILE_TYPES_MAP).flat().join(", ");
|
|
10205
10204
|
var FILE_GROUPS = [{
|
|
10206
10205
|
label: t$4("neetoForm.fileTypes.documents"),
|
|
@@ -10370,7 +10369,7 @@ var getAllowedFileTypes = function getAllowedFileTypes(_ref) {
|
|
|
10370
10369
|
allowedFileTypes = _ref.allowedFileTypes;
|
|
10371
10370
|
var fileTypes = allowedFileTypes ? allowedFileTypes.split(", ") : [];
|
|
10372
10371
|
if (isChecked) {
|
|
10373
|
-
var fileTypesSet = new Set([].concat(_toConsumableArray(FILE_TYPES_MAP[type]), _toConsumableArray(fileTypes)));
|
|
10372
|
+
var fileTypesSet = new Set([].concat(_toConsumableArray$1(FILE_TYPES_MAP[type]), _toConsumableArray$1(fileTypes)));
|
|
10374
10373
|
return Array.from(fileTypesSet).join(", ");
|
|
10375
10374
|
}
|
|
10376
10375
|
var newFileTypes = difference(fileTypes, FILE_TYPES_MAP[type]);
|
|
@@ -10798,7 +10797,7 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
10798
10797
|
var _useTranslation = useTranslation(),
|
|
10799
10798
|
t = _useTranslation.t;
|
|
10800
10799
|
var _useField = useField("".concat(name, ".shape")),
|
|
10801
|
-
_useField2 = _slicedToArray$
|
|
10800
|
+
_useField2 = _slicedToArray$3(_useField, 3),
|
|
10802
10801
|
value = _useField2[0].value,
|
|
10803
10802
|
setValue = _useField2[2].setValue;
|
|
10804
10803
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -10820,7 +10819,7 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
10820
10819
|
}), /*#__PURE__*/React__default.createElement(Label, null, t("neetoForm.common.icon")), /*#__PURE__*/React__default.createElement("div", {
|
|
10821
10820
|
className: "flex gap-2"
|
|
10822
10821
|
}, Object.entries(STAR_RATING_ICONS_MAP).map(function (_ref2) {
|
|
10823
|
-
var _ref3 = _slicedToArray$
|
|
10822
|
+
var _ref3 = _slicedToArray$3(_ref2, 2),
|
|
10824
10823
|
name = _ref3[0],
|
|
10825
10824
|
Shape = _ref3[1];
|
|
10826
10825
|
var isActive = name === value;
|
|
@@ -10858,7 +10857,7 @@ var Terms$3 = function Terms(_ref) {
|
|
|
10858
10857
|
name: "".concat(name, ".label"),
|
|
10859
10858
|
validate: validateContent
|
|
10860
10859
|
}),
|
|
10861
|
-
_useField2 = _slicedToArray$
|
|
10860
|
+
_useField2 = _slicedToArray$3(_useField, 3),
|
|
10862
10861
|
value = _useField2[0].value,
|
|
10863
10862
|
error = _useField2[1].error,
|
|
10864
10863
|
setValue = _useField2[2].setValue;
|
|
@@ -10917,7 +10916,7 @@ var Editor = function Editor(_ref) {
|
|
|
10917
10916
|
name: fieldName,
|
|
10918
10917
|
validate: validateContent
|
|
10919
10918
|
}),
|
|
10920
|
-
_useField2 = _slicedToArray$
|
|
10919
|
+
_useField2 = _slicedToArray$3(_useField, 2),
|
|
10921
10920
|
value = _useField2[0].value,
|
|
10922
10921
|
error = _useField2[1].error;
|
|
10923
10922
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -11335,8 +11334,8 @@ function v4(options, buf, offset) {
|
|
|
11335
11334
|
return unsafeStringify(rnds);
|
|
11336
11335
|
}
|
|
11337
11336
|
|
|
11338
|
-
function ownKeys$
|
|
11339
|
-
function _objectSpread$
|
|
11337
|
+
function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11338
|
+
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11340
11339
|
var isQuestionKindAlreadyActive = function isQuestionKindAlreadyActive(_ref) {
|
|
11341
11340
|
var activeQuestions = _ref.activeQuestions,
|
|
11342
11341
|
kind = _ref.kind;
|
|
@@ -11350,10 +11349,10 @@ var handleFieldDragEnd = function handleFieldDragEnd(_ref2) {
|
|
|
11350
11349
|
source = _ref2.source,
|
|
11351
11350
|
destination = _ref2.destination;
|
|
11352
11351
|
if (!(destination && items instanceof Array)) return;
|
|
11353
|
-
var nextItems = _toConsumableArray(items);
|
|
11352
|
+
var nextItems = _toConsumableArray$1(items);
|
|
11354
11353
|
arrayHelpers.moveItem(nextItems, source.index, destination.index);
|
|
11355
11354
|
var orderedItems = nextItems.map(function (item, index) {
|
|
11356
|
-
return _objectSpread$
|
|
11355
|
+
return _objectSpread$c(_objectSpread$c({}, item), {}, {
|
|
11357
11356
|
displayOrder: index
|
|
11358
11357
|
});
|
|
11359
11358
|
});
|
|
@@ -11363,7 +11362,7 @@ var createFieldData = function createFieldData(_ref3, isRequired) {
|
|
|
11363
11362
|
var defaults = _ref3.defaults,
|
|
11364
11363
|
type = _ref3.type,
|
|
11365
11364
|
metadata = _ref3.metadata;
|
|
11366
|
-
return _objectSpread$
|
|
11365
|
+
return _objectSpread$c(_objectSpread$c({}, defaults), {}, {
|
|
11367
11366
|
metadata: metadata,
|
|
11368
11367
|
isRequired: isRequired,
|
|
11369
11368
|
kind: type,
|
|
@@ -11380,7 +11379,7 @@ var duplicateFieldData = function duplicateFieldData(item, questionKinds) {
|
|
|
11380
11379
|
optionsAttributes = item.optionsAttributes;
|
|
11381
11380
|
var defaultAttributeNames = keys(questionKind.defaults || {});
|
|
11382
11381
|
var defaultAttributes = pick(defaultAttributeNames, item);
|
|
11383
|
-
return _objectSpread$
|
|
11382
|
+
return _objectSpread$c(_objectSpread$c({}, defaultAttributes), {}, {
|
|
11384
11383
|
isRequired: isRequired,
|
|
11385
11384
|
kind: kind,
|
|
11386
11385
|
label: label,
|
|
@@ -11460,7 +11459,7 @@ var List = function List(_ref) {
|
|
|
11460
11459
|
t = _useTranslation.t;
|
|
11461
11460
|
var disableAddNewQuestion = isEmpty(questionKinds);
|
|
11462
11461
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
11463
|
-
className: classnames("flex", _defineProperty$
|
|
11462
|
+
className: classnames("flex", _defineProperty$7({}, className, className))
|
|
11464
11463
|
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
11465
11464
|
disabled: !disableAddNewQuestion,
|
|
11466
11465
|
position: "top",
|
|
@@ -11487,8 +11486,8 @@ var List = function List(_ref) {
|
|
|
11487
11486
|
};
|
|
11488
11487
|
|
|
11489
11488
|
var _excluded$7 = ["questionKinds", "showAddQuestionDivider", "onValueChange", "showActionBlock", "formId", "isDeletable", "isRequiredField", "submitButtonProps", "cancelButtonProps", "isKindAlreadyActive", "getActiveKindDetails", "kindUniqueOn", "isDisabledFieldLabel", "disabledAddButtonTooltipProps"];
|
|
11490
|
-
function ownKeys$
|
|
11491
|
-
function _objectSpread$
|
|
11489
|
+
function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11490
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11492
11491
|
var Form = function Form(_ref) {
|
|
11493
11492
|
var _INDEPENDENT_LABELS_M, _questions$deleteQues, _questions$deleteQues2;
|
|
11494
11493
|
var questionKinds = _ref.questionKinds,
|
|
@@ -11505,16 +11504,16 @@ var Form = function Form(_ref) {
|
|
|
11505
11504
|
kindUniqueOn = _ref.kindUniqueOn,
|
|
11506
11505
|
isDisabledFieldLabel = _ref.isDisabledFieldLabel,
|
|
11507
11506
|
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
|
|
11508
|
-
formDomProps = _objectWithoutProperties(_ref, _excluded$7);
|
|
11507
|
+
formDomProps = _objectWithoutProperties$1(_ref, _excluded$7);
|
|
11509
11508
|
var _useTranslation = useTranslation(),
|
|
11510
11509
|
t = _useTranslation.t;
|
|
11511
11510
|
var _useState = useState({}),
|
|
11512
|
-
_useState2 = _slicedToArray$
|
|
11511
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
11513
11512
|
formFieldState = _useState2[0],
|
|
11514
11513
|
setFormFieldState = _useState2[1];
|
|
11515
11514
|
var formikContext = useFormikContext();
|
|
11516
11515
|
var _useState3 = useState(null),
|
|
11517
|
-
_useState4 = _slicedToArray$
|
|
11516
|
+
_useState4 = _slicedToArray$3(_useState3, 2),
|
|
11518
11517
|
deleteQuestionIndex = _useState4[0],
|
|
11519
11518
|
setDeleteQuestionIndex = _useState4[1];
|
|
11520
11519
|
var values = formikContext.values,
|
|
@@ -11570,7 +11569,7 @@ var Form = function Form(_ref) {
|
|
|
11570
11569
|
onDuplicate: function onDuplicate() {
|
|
11571
11570
|
var newQuestions = insert(item.displayOrder, duplicateFieldData(item, questionKinds), values.questions);
|
|
11572
11571
|
setFieldValue("questions", newQuestions.map(function (question, index) {
|
|
11573
|
-
return _objectSpread$
|
|
11572
|
+
return _objectSpread$b(_objectSpread$b({}, question), {}, {
|
|
11574
11573
|
displayOrder: index + 1
|
|
11575
11574
|
});
|
|
11576
11575
|
}));
|
|
@@ -11660,10 +11659,10 @@ var Form = function Form(_ref) {
|
|
|
11660
11659
|
className: "neeto-ui-border-gray-300 flex-shrink-0 border-t py-4"
|
|
11661
11660
|
}, /*#__PURE__*/React__default.createElement(ActionBlock, {
|
|
11662
11661
|
className: "space-x-2",
|
|
11663
|
-
cancelButtonProps: _objectSpread$
|
|
11662
|
+
cancelButtonProps: _objectSpread$b({
|
|
11664
11663
|
label: t("neetoForm.common.reset")
|
|
11665
11664
|
}, cancelButtonProps),
|
|
11666
|
-
submitButtonProps: _objectSpread$
|
|
11665
|
+
submitButtonProps: _objectSpread$b({
|
|
11667
11666
|
disabled: isSubmitting || !dirty
|
|
11668
11667
|
}, submitButtonProps)
|
|
11669
11668
|
}))));
|
|
@@ -11718,8 +11717,8 @@ var formValidationSchema = object().shape({
|
|
|
11718
11717
|
})).required()
|
|
11719
11718
|
});
|
|
11720
11719
|
|
|
11721
|
-
function ownKeys$
|
|
11722
|
-
function _objectSpread$
|
|
11720
|
+
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11721
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11723
11722
|
var BuildForm = function BuildForm(_ref) {
|
|
11724
11723
|
var id = _ref.id,
|
|
11725
11724
|
onUpdate = _ref.onUpdate,
|
|
@@ -11796,7 +11795,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
11796
11795
|
var handleSubmit = function handleSubmit(payload) {
|
|
11797
11796
|
return updateQuestions({
|
|
11798
11797
|
id: id,
|
|
11799
|
-
values: _objectSpread$
|
|
11798
|
+
values: _objectSpread$a({
|
|
11800
11799
|
neetoFormQuestion: payload
|
|
11801
11800
|
}, buildRequestArgs)
|
|
11802
11801
|
});
|
|
@@ -11833,7 +11832,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
11833
11832
|
}, function (_ref3) {
|
|
11834
11833
|
var errors = _ref3.errors,
|
|
11835
11834
|
setFieldError = _ref3.setFieldError;
|
|
11836
|
-
return /*#__PURE__*/React__default.createElement(Form, _extends$8({}, _objectSpread$
|
|
11835
|
+
return /*#__PURE__*/React__default.createElement(Form, _extends$8({}, _objectSpread$a(_objectSpread$a({}, formDomProps), {}, {
|
|
11837
11836
|
cancelButtonProps: cancelButtonProps,
|
|
11838
11837
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
11839
11838
|
getActiveKindDetails: getActiveKindDetails,
|
|
@@ -12274,7 +12273,7 @@ var Button = function Button(_ref) {
|
|
|
12274
12273
|
success = _ref$success === void 0 ? false : _ref$success,
|
|
12275
12274
|
_ref$className = _ref.className,
|
|
12276
12275
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
12277
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
12276
|
+
otherProps = _objectWithoutProperties$1(_ref, _excluded$6);
|
|
12278
12277
|
return /*#__PURE__*/React__default.createElement("button", _extends$8({
|
|
12279
12278
|
className: classnames("neeto-form-engine-button", className)
|
|
12280
12279
|
}, otherProps), loading && /*#__PURE__*/React__default.createElement(ButtonLoader, null), success && /*#__PURE__*/React__default.createElement(Success$2, null), label);
|
|
@@ -12316,7 +12315,7 @@ var Callout = function Callout(_ref) {
|
|
|
12316
12315
|
secondaryButton = callout.secondaryButton;
|
|
12317
12316
|
if (!isVisible) return null;
|
|
12318
12317
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
12319
|
-
className: classnames("neeto-form-engine-callout", _defineProperty$
|
|
12318
|
+
className: classnames("neeto-form-engine-callout", _defineProperty$7({
|
|
12320
12319
|
"neeto-form-engine-callout--error": style === CALLOUT_STYLES.ERROR,
|
|
12321
12320
|
"neeto-form-engine-callout--info": style === CALLOUT_STYLES.INFO,
|
|
12322
12321
|
"neeto-form-engine-callout--static": position === CALLOUT_POSITIONS.STATIC,
|
|
@@ -12569,7 +12568,7 @@ var validateFileUploadField = function validateFileUploadField(_ref9) {
|
|
|
12569
12568
|
files: files_schema
|
|
12570
12569
|
});
|
|
12571
12570
|
};
|
|
12572
|
-
var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty$
|
|
12571
|
+
var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.EMAIL.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.PHONE.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.TEXT.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.NAME.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.QUESTION.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.TEXTAREA.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.DECIMAL.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.INTEGER.value, validateTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.DROPDOWN.value, validateSingleChoiceField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.RADIO.value, validateSingleChoiceField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.CHECKBOX.value, validateMultiChoiceField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.RATING.value, validateRatingField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.TERMS.value, validateTermsField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.DATE.value, validateDateField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.STAR_RATING.value, validateStarRatingField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.ADDITIONAL_GUESTS.value, validateMultiEmailField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.RICH_TEXT.value, validateRichTextField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.CONDITION.value, validateConditionField), _defineProperty$7(_fieldKindValidatorMa, QUESTION_KIND.FILE_UPLOAD.value, validateFileUploadField), _fieldKindValidatorMa);
|
|
12573
12572
|
var validateFieldValue = function validateFieldValue(_ref10) {
|
|
12574
12573
|
var kind = _ref10.kind,
|
|
12575
12574
|
label = _ref10.label,
|
|
@@ -12632,14 +12631,14 @@ var MultipleEmailInput = function MultipleEmailInput(_ref) {
|
|
|
12632
12631
|
customValidator: customValidator
|
|
12633
12632
|
})
|
|
12634
12633
|
}),
|
|
12635
|
-
_useField2 = _slicedToArray$
|
|
12634
|
+
_useField2 = _slicedToArray$3(_useField, 3),
|
|
12636
12635
|
field = _useField2[0],
|
|
12637
12636
|
meta = _useField2[1],
|
|
12638
12637
|
_useField2$ = _useField2[2],
|
|
12639
12638
|
setValue = _useField2$.setValue,
|
|
12640
12639
|
setTouched = _useField2$.setTouched;
|
|
12641
12640
|
var _useState = useState(isPresent$1(field.value)),
|
|
12642
|
-
_useState2 = _slicedToArray$
|
|
12641
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
12643
12642
|
isInputVisible = _useState2[0],
|
|
12644
12643
|
setIsInputVisible = _useState2[1];
|
|
12645
12644
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -12674,7 +12673,7 @@ var Condition = function Condition(_ref, ref) {
|
|
|
12674
12673
|
label = _ref.label,
|
|
12675
12674
|
error = _ref.error,
|
|
12676
12675
|
value = _ref.value,
|
|
12677
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$5);
|
|
12676
|
+
otherProps = _objectWithoutProperties$1(_ref, _excluded$5);
|
|
12678
12677
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
12679
12678
|
className: "neeto-form-engine-terms"
|
|
12680
12679
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -13737,11 +13736,11 @@ function parseDigit(character) {
|
|
|
13737
13736
|
return DIGITS[character];
|
|
13738
13737
|
}
|
|
13739
13738
|
|
|
13740
|
-
function _createForOfIteratorHelperLoose$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$
|
|
13739
|
+
function _createForOfIteratorHelperLoose$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$8(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13741
13740
|
|
|
13742
|
-
function _unsupportedIterableToArray$
|
|
13741
|
+
function _unsupportedIterableToArray$8(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$8(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$8(o, minLen); }
|
|
13743
13742
|
|
|
13744
|
-
function _arrayLikeToArray$
|
|
13743
|
+
function _arrayLikeToArray$8(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
13745
13744
|
/**
|
|
13746
13745
|
* Parses phone number characters from a string.
|
|
13747
13746
|
* Drops all punctuation leaving only digits and the leading `+` sign (if any).
|
|
@@ -13801,11 +13800,11 @@ function parsePhoneNumberCharacter(character, prevParsedCharacters) {
|
|
|
13801
13800
|
return parseDigit(character);
|
|
13802
13801
|
}
|
|
13803
13802
|
|
|
13804
|
-
function _createForOfIteratorHelperLoose$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$
|
|
13803
|
+
function _createForOfIteratorHelperLoose$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$7(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13805
13804
|
|
|
13806
|
-
function _unsupportedIterableToArray$
|
|
13805
|
+
function _unsupportedIterableToArray$7(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$7(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen); }
|
|
13807
13806
|
|
|
13808
|
-
function _arrayLikeToArray$
|
|
13807
|
+
function _arrayLikeToArray$7(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
13809
13808
|
|
|
13810
13809
|
/**
|
|
13811
13810
|
* Merges two arrays.
|
|
@@ -14007,11 +14006,11 @@ function matchesEntirely(text, regular_expression) {
|
|
|
14007
14006
|
return new RegExp('^(?:' + regular_expression + ')$').test(text);
|
|
14008
14007
|
}
|
|
14009
14008
|
|
|
14010
|
-
function _createForOfIteratorHelperLoose$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$
|
|
14009
|
+
function _createForOfIteratorHelperLoose$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$6(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14011
14010
|
|
|
14012
|
-
function _unsupportedIterableToArray$
|
|
14011
|
+
function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); }
|
|
14013
14012
|
|
|
14014
|
-
function _arrayLikeToArray$
|
|
14013
|
+
function _arrayLikeToArray$6(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14015
14014
|
var NON_FIXED_LINE_PHONE_TYPES = ['MOBILE', 'PREMIUM_RATE', 'TOLL_FREE', 'SHARED_COST', 'VOIP', 'PERSONAL_NUMBER', 'PAGER', 'UAN', 'VOICEMAIL']; // Finds out national phone number type (fixed line, mobile, etc)
|
|
14016
14015
|
|
|
14017
14016
|
function getNumberType(input, options, metadata) {
|
|
@@ -14303,17 +14302,17 @@ function formatRFC3966(_ref) {
|
|
|
14303
14302
|
return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
|
|
14304
14303
|
}
|
|
14305
14304
|
|
|
14306
|
-
function _createForOfIteratorHelperLoose$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$
|
|
14305
|
+
function _createForOfIteratorHelperLoose$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14307
14306
|
|
|
14308
|
-
function _unsupportedIterableToArray$
|
|
14307
|
+
function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
|
|
14309
14308
|
|
|
14310
|
-
function _arrayLikeToArray$
|
|
14309
|
+
function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14311
14310
|
|
|
14312
|
-
function ownKeys$
|
|
14311
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14313
14312
|
|
|
14314
|
-
function _objectSpread$
|
|
14313
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty$5(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14315
14314
|
|
|
14316
|
-
function _defineProperty$
|
|
14315
|
+
function _defineProperty$5(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14317
14316
|
var DEFAULT_OPTIONS = {
|
|
14318
14317
|
formatExtension: function formatExtension(formattedNumber, extension, metadata) {
|
|
14319
14318
|
return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
|
|
@@ -14338,7 +14337,7 @@ var DEFAULT_OPTIONS = {
|
|
|
14338
14337
|
function formatNumber(input, format, options, metadata) {
|
|
14339
14338
|
// Apply default options.
|
|
14340
14339
|
if (options) {
|
|
14341
|
-
options = _objectSpread$
|
|
14340
|
+
options = _objectSpread$9(_objectSpread$9({}, DEFAULT_OPTIONS), options);
|
|
14342
14341
|
} else {
|
|
14343
14342
|
options = DEFAULT_OPTIONS;
|
|
14344
14343
|
}
|
|
@@ -14483,11 +14482,11 @@ function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry,
|
|
|
14483
14482
|
}
|
|
14484
14483
|
}
|
|
14485
14484
|
|
|
14486
|
-
function ownKeys$
|
|
14485
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14487
14486
|
|
|
14488
|
-
function _objectSpread$
|
|
14487
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty$4(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14489
14488
|
|
|
14490
|
-
function _defineProperty$
|
|
14489
|
+
function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14491
14490
|
|
|
14492
14491
|
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14493
14492
|
|
|
@@ -14597,7 +14596,7 @@ var PhoneNumber = /*#__PURE__*/function () {
|
|
|
14597
14596
|
}, {
|
|
14598
14597
|
key: "format",
|
|
14599
14598
|
value: function format(_format, options) {
|
|
14600
|
-
return formatNumber(this, _format, options ? _objectSpread$
|
|
14599
|
+
return formatNumber(this, _format, options ? _objectSpread$8(_objectSpread$8({}, options), {}, {
|
|
14601
14600
|
v2: true
|
|
14602
14601
|
}) : {
|
|
14603
14602
|
v2: true
|
|
@@ -15077,11 +15076,11 @@ function extractCountryCallingCode(number, country, callingCode, metadata) {
|
|
|
15077
15076
|
// FROM_DEFAULT_COUNTRY = 20;
|
|
15078
15077
|
// }
|
|
15079
15078
|
|
|
15080
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$
|
|
15079
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15081
15080
|
|
|
15082
|
-
function _unsupportedIterableToArray$
|
|
15081
|
+
function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); }
|
|
15083
15082
|
|
|
15084
|
-
function _arrayLikeToArray$
|
|
15083
|
+
function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15085
15084
|
function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
|
|
15086
15085
|
var countries = _ref.countries,
|
|
15087
15086
|
defaultCountry = _ref.defaultCountry,
|
|
@@ -15640,41 +15639,41 @@ function parsePhoneNumber$3(formattedPhoneNumber, defaultCountry, defaultCalling
|
|
|
15640
15639
|
};
|
|
15641
15640
|
}
|
|
15642
15641
|
|
|
15643
|
-
function ownKeys$
|
|
15642
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15644
15643
|
|
|
15645
|
-
function _objectSpread$
|
|
15644
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty$3(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15646
15645
|
|
|
15647
|
-
function _defineProperty$
|
|
15646
|
+
function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15648
15647
|
function parsePhoneNumberWithError(text, options, metadata) {
|
|
15649
|
-
return parse$1(text, _objectSpread$
|
|
15648
|
+
return parse$1(text, _objectSpread$7(_objectSpread$7({}, options), {}, {
|
|
15650
15649
|
v2: true
|
|
15651
15650
|
}), metadata);
|
|
15652
15651
|
}
|
|
15653
15652
|
|
|
15654
|
-
function ownKeys$
|
|
15653
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15655
15654
|
|
|
15656
|
-
function _objectSpread$
|
|
15655
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15657
15656
|
|
|
15658
|
-
function _defineProperty$
|
|
15657
|
+
function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15659
15658
|
|
|
15660
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$
|
|
15659
|
+
function _slicedToArray$2(arr, i) { return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$2(); }
|
|
15661
15660
|
|
|
15662
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15661
|
+
function _nonIterableRest$2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15663
15662
|
|
|
15664
|
-
function _unsupportedIterableToArray$
|
|
15663
|
+
function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
|
15665
15664
|
|
|
15666
|
-
function _arrayLikeToArray$
|
|
15665
|
+
function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15667
15666
|
|
|
15668
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
15667
|
+
function _iterableToArrayLimit$2(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
15669
15668
|
|
|
15670
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15669
|
+
function _arrayWithHoles$2(arr) { if (Array.isArray(arr)) return arr; }
|
|
15671
15670
|
// * input `text`
|
|
15672
15671
|
// * `options` object
|
|
15673
15672
|
// * `metadata` JSON
|
|
15674
15673
|
|
|
15675
15674
|
function normalizeArguments(args) {
|
|
15676
15675
|
var _Array$prototype$slic = Array.prototype.slice.call(args),
|
|
15677
|
-
_Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
|
|
15676
|
+
_Array$prototype$slic2 = _slicedToArray$2(_Array$prototype$slic, 4),
|
|
15678
15677
|
arg_1 = _Array$prototype$slic2[0],
|
|
15679
15678
|
arg_2 = _Array$prototype$slic2[1],
|
|
15680
15679
|
arg_3 = _Array$prototype$slic2[2],
|
|
@@ -15701,7 +15700,7 @@ function normalizeArguments(args) {
|
|
|
15701
15700
|
}
|
|
15702
15701
|
|
|
15703
15702
|
if (arg_2) {
|
|
15704
|
-
options = _objectSpread$
|
|
15703
|
+
options = _objectSpread$6({
|
|
15705
15704
|
defaultCountry: arg_2
|
|
15706
15705
|
}, options);
|
|
15707
15706
|
}
|
|
@@ -15723,15 +15722,15 @@ function normalizeArguments(args) {
|
|
|
15723
15722
|
};
|
|
15724
15723
|
}
|
|
15725
15724
|
|
|
15726
|
-
function ownKeys$
|
|
15725
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15727
15726
|
|
|
15728
|
-
function _objectSpread$
|
|
15727
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15729
15728
|
|
|
15730
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15729
|
+
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15731
15730
|
function parsePhoneNumber$2(text, options, metadata) {
|
|
15732
15731
|
// Validate `defaultCountry`.
|
|
15733
15732
|
if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
|
|
15734
|
-
options = _objectSpread$
|
|
15733
|
+
options = _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
15735
15734
|
defaultCountry: undefined
|
|
15736
15735
|
});
|
|
15737
15736
|
} // Parse phone number.
|
|
@@ -15760,8 +15759,8 @@ function parsePhoneNumber() {
|
|
|
15760
15759
|
return withMetadataArgument(parsePhoneNumber$1, arguments)
|
|
15761
15760
|
}
|
|
15762
15761
|
|
|
15763
|
-
function ownKeys$
|
|
15764
|
-
function _objectSpread$
|
|
15762
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15763
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15765
15764
|
var toEmailValues = function toEmailValues() {
|
|
15766
15765
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
15767
15766
|
return values.map(function (value) {
|
|
@@ -15782,7 +15781,7 @@ var generateInitValues = function generateInitValues(questions) {
|
|
|
15782
15781
|
var valuesMap = {};
|
|
15783
15782
|
if (initialValues) {
|
|
15784
15783
|
valuesMap = initialValues.reduce(function (acc, answer) {
|
|
15785
|
-
return _objectSpread$
|
|
15784
|
+
return _objectSpread$4(_objectSpread$4({}, acc), {}, _defineProperty$7({}, answer.questionId, {
|
|
15786
15785
|
value: answer.value,
|
|
15787
15786
|
optionIds: answer.optionIds
|
|
15788
15787
|
}));
|
|
@@ -16024,7 +16023,7 @@ var DateField = function DateField(_ref) {
|
|
|
16024
16023
|
var meta = _ref2.meta,
|
|
16025
16024
|
_ref2$field = _ref2.field,
|
|
16026
16025
|
value = _ref2$field.value,
|
|
16027
|
-
field = _objectWithoutProperties(_ref2$field, _excluded$4),
|
|
16026
|
+
field = _objectWithoutProperties$1(_ref2$field, _excluded$4),
|
|
16028
16027
|
form = _ref2.form;
|
|
16029
16028
|
return /*#__PURE__*/React__default.createElement(DatePicker, _extends$8({
|
|
16030
16029
|
dateFormat: "MMM D, YYYY",
|
|
@@ -16891,227 +16890,96 @@ function autostart() {
|
|
|
16891
16890
|
|
|
16892
16891
|
setTimeout(autostart, 1);
|
|
16893
16892
|
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
|
|
16928
|
-
|
|
16929
|
-
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
|
|
16958
|
-
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
16962
|
-
setUploadProgress(assoc(file.name, percentComplete));
|
|
16963
|
-
});
|
|
16964
|
-
xhr.upload.addEventListener("load", function () {
|
|
16965
|
-
setUploadProgress(assoc(file.name, undefined));
|
|
16966
|
-
});
|
|
16967
|
-
}
|
|
16968
|
-
});
|
|
16969
|
-
upload.create(function (error, blob) {
|
|
16970
|
-
if (error) {
|
|
16971
|
-
return setUploadError(error);
|
|
16972
|
-
}
|
|
16973
|
-
files.push({
|
|
16974
|
-
url: blob.blob_url,
|
|
16975
|
-
name: blob.filename,
|
|
16976
|
-
signedId: blob.signed_id
|
|
16977
|
-
});
|
|
16978
|
-
var isUploadCompleted = multiple ? acceptedFiles.length === files.length : files.length === 1;
|
|
16979
|
-
if (isUploadCompleted) {
|
|
16980
|
-
return resolve(files);
|
|
16981
|
-
}
|
|
16982
|
-
return "";
|
|
16983
|
-
});
|
|
16984
|
-
});
|
|
16985
|
-
return files;
|
|
16986
|
-
});
|
|
16987
|
-
case 7:
|
|
16988
|
-
newFiles = _context.sent;
|
|
16989
|
-
if (multiple) {
|
|
16990
|
-
setValue({
|
|
16991
|
-
files: filesRef.current.map(function (file) {
|
|
16992
|
-
var uploadedFile = findBy({
|
|
16993
|
-
name: file.name
|
|
16994
|
-
}, newFiles);
|
|
16995
|
-
return _objectSpread$2(_objectSpread$2({}, file), uploadedFile);
|
|
16996
|
-
})
|
|
16997
|
-
});
|
|
16998
|
-
} else {
|
|
16999
|
-
setValue({
|
|
17000
|
-
files: newFiles
|
|
17001
|
-
});
|
|
17002
|
-
}
|
|
17003
|
-
case 9:
|
|
17004
|
-
case "end":
|
|
17005
|
-
return _context.stop();
|
|
17006
|
-
}
|
|
17007
|
-
}, _callee);
|
|
17008
|
-
}));
|
|
17009
|
-
return function onDropAccepted(_x) {
|
|
17010
|
-
return _ref2.apply(this, arguments);
|
|
17011
|
-
};
|
|
17012
|
-
}();
|
|
17013
|
-
var onDropRejected = function onDropRejected(fileRejections) {
|
|
17014
|
-
fileRejections.forEach(function (fileObject) {
|
|
17015
|
-
setTouched(true);
|
|
17016
|
-
setUploadError(renderErrorMessage(fileObject, maxFileSize, multiple));
|
|
17017
|
-
});
|
|
17018
|
-
};
|
|
17019
|
-
var _useDropzone = useDropzone({
|
|
17020
|
-
disabled: disabled,
|
|
17021
|
-
accept: accept,
|
|
17022
|
-
multiple: multiple,
|
|
17023
|
-
onDropAccepted: onDropAccepted,
|
|
17024
|
-
onDropRejected: onDropRejected,
|
|
17025
|
-
maxSize: convertMbToBytes(maxFileSize)
|
|
17026
|
-
}),
|
|
17027
|
-
getRootProps = _useDropzone.getRootProps,
|
|
17028
|
-
getInputProps = _useDropzone.getInputProps,
|
|
17029
|
-
isDragActive = _useDropzone.isDragActive,
|
|
17030
|
-
fileRejections = _useDropzone.fileRejections;
|
|
17031
|
-
return {
|
|
17032
|
-
files: value === null || value === void 0 ? void 0 : value.files,
|
|
17033
|
-
progress: uploadProgress,
|
|
17034
|
-
cancel: cancel,
|
|
17035
|
-
getRootProps: getRootProps,
|
|
17036
|
-
getInputProps: getInputProps,
|
|
17037
|
-
isDragActive: isDragActive,
|
|
17038
|
-
fileRejections: fileRejections
|
|
16893
|
+
var propTypes = {exports: {}};
|
|
16894
|
+
|
|
16895
|
+
/**
|
|
16896
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
16897
|
+
*
|
|
16898
|
+
* This source code is licensed under the MIT license found in the
|
|
16899
|
+
* LICENSE file in the root directory of this source tree.
|
|
16900
|
+
*/
|
|
16901
|
+
|
|
16902
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
16903
|
+
|
|
16904
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
16905
|
+
|
|
16906
|
+
/**
|
|
16907
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
16908
|
+
*
|
|
16909
|
+
* This source code is licensed under the MIT license found in the
|
|
16910
|
+
* LICENSE file in the root directory of this source tree.
|
|
16911
|
+
*/
|
|
16912
|
+
|
|
16913
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
16914
|
+
|
|
16915
|
+
function emptyFunction() {}
|
|
16916
|
+
function emptyFunctionWithReset() {}
|
|
16917
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
16918
|
+
|
|
16919
|
+
var factoryWithThrowingShims = function() {
|
|
16920
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
16921
|
+
if (secret === ReactPropTypesSecret) {
|
|
16922
|
+
// It is still safe when called from React.
|
|
16923
|
+
return;
|
|
16924
|
+
}
|
|
16925
|
+
var err = new Error(
|
|
16926
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
16927
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
16928
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
16929
|
+
);
|
|
16930
|
+
err.name = 'Invariant Violation';
|
|
16931
|
+
throw err;
|
|
16932
|
+
} shim.isRequired = shim;
|
|
16933
|
+
function getShim() {
|
|
16934
|
+
return shim;
|
|
16935
|
+
} // Important!
|
|
16936
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
16937
|
+
var ReactPropTypes = {
|
|
16938
|
+
array: shim,
|
|
16939
|
+
bigint: shim,
|
|
16940
|
+
bool: shim,
|
|
16941
|
+
func: shim,
|
|
16942
|
+
number: shim,
|
|
16943
|
+
object: shim,
|
|
16944
|
+
string: shim,
|
|
16945
|
+
symbol: shim,
|
|
16946
|
+
|
|
16947
|
+
any: shim,
|
|
16948
|
+
arrayOf: getShim,
|
|
16949
|
+
element: shim,
|
|
16950
|
+
elementType: shim,
|
|
16951
|
+
instanceOf: getShim,
|
|
16952
|
+
node: shim,
|
|
16953
|
+
objectOf: getShim,
|
|
16954
|
+
oneOf: getShim,
|
|
16955
|
+
oneOfType: getShim,
|
|
16956
|
+
shape: getShim,
|
|
16957
|
+
exact: getShim,
|
|
16958
|
+
|
|
16959
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
16960
|
+
resetWarningCache: emptyFunction
|
|
17039
16961
|
};
|
|
16962
|
+
|
|
16963
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
16964
|
+
|
|
16965
|
+
return ReactPropTypes;
|
|
17040
16966
|
};
|
|
17041
16967
|
|
|
17042
|
-
|
|
17043
|
-
|
|
17044
|
-
|
|
17045
|
-
|
|
17046
|
-
|
|
17047
|
-
|
|
17048
|
-
fill: "none"
|
|
17049
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React$2.createElement("path", {
|
|
17050
|
-
fill: "currentColor",
|
|
17051
|
-
d: "M32 26h-6v10h-4V26h-6l8-8 8 8zm6.958-11.816C38.534 6.282 32.012 0 24 0S9.466 6.282 9.042 14.184C3.902 15.11 0 19.596 0 25c0 6.074 4.926 11 11 11h7v-4h-7c-3.86 0-7-3.14-7-7 0-5.594 4.958-7.666 8.866-7.44C12.532 9.124 17.282 4 24 4c6.906 0 11.782 5.594 11.134 13.56C38.624 17.468 44 19.062 44 25c0 3.86-3.14 7-7 7h-7v4h7c6.074 0 11-4.926 11-11 0-5.404-3.902-9.89-9.042-10.816z"
|
|
17052
|
-
})));
|
|
16968
|
+
/**
|
|
16969
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
16970
|
+
*
|
|
16971
|
+
* This source code is licensed under the MIT license found in the
|
|
16972
|
+
* LICENSE file in the root directory of this source tree.
|
|
16973
|
+
*/
|
|
17053
16974
|
|
|
17054
|
-
|
|
17055
|
-
|
|
17056
|
-
|
|
17057
|
-
|
|
17058
|
-
|
|
17059
|
-
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
allowedFileTypes = _ref.allowedFileTypes;
|
|
17063
|
-
var _useTranslation = useTranslation(),
|
|
17064
|
-
t = _useTranslation.t;
|
|
17065
|
-
var shouldShowFileSizeLimit = hasFileSizeLimit && maxFileSize;
|
|
17066
|
-
return /*#__PURE__*/React__default.createElement("div", getRootProps({
|
|
17067
|
-
className: classnames(["neeto-form-engine-file-upload__dropzone"], {
|
|
17068
|
-
"neeto-form-engine-file-upload__dropzone--drag-active": isDragActive
|
|
17069
|
-
})
|
|
17070
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
17071
|
-
className: "neeto-form-engine-file-upload__dropzone-inner",
|
|
17072
|
-
"data-cy": "file-upload-body"
|
|
17073
|
-
}, /*#__PURE__*/React__default.createElement(SvgFileUpload, {
|
|
17074
|
-
className: "neeto-form-engine-file-upload__upload-icon"
|
|
17075
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
17076
|
-
className: "neeto-form-engine-file-upload__dropzone-content"
|
|
17077
|
-
}, /*#__PURE__*/React__default.createElement("label", {
|
|
17078
|
-
className: "neeto-form-engine-file-upload__upload-label",
|
|
17079
|
-
htmlFor: "file-upload"
|
|
17080
|
-
}, /*#__PURE__*/React__default.createElement(Trans, {
|
|
17081
|
-
i18nKey: "neetoForm.fileUpload.dropzone.chooseOrDragFile",
|
|
17082
|
-
components: {
|
|
17083
|
-
typography: /*#__PURE__*/React__default.createElement(Typography, {
|
|
17084
|
-
component: "span",
|
|
17085
|
-
weight: "semibold"
|
|
17086
|
-
}),
|
|
17087
|
-
span: /*#__PURE__*/React__default.createElement(Typography, {
|
|
17088
|
-
component: "span",
|
|
17089
|
-
weight: "normal"
|
|
17090
|
-
})
|
|
17091
|
-
}
|
|
17092
|
-
}), /*#__PURE__*/React__default.createElement("input", _extends$8({}, getInputProps(), {
|
|
17093
|
-
"data-cy": "file-browse-button"
|
|
17094
|
-
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
17095
|
-
className: "neeto-form-engine-file-upload__dropzone-helper-block"
|
|
17096
|
-
}, !multipleFilesAllowed && /*#__PURE__*/React__default.createElement(Typography, {
|
|
17097
|
-
className: "neeto-form-engine-file-upload__dropzone-helper-text",
|
|
17098
|
-
"data-cy": "upload-only-one-file-text",
|
|
17099
|
-
style: "body3"
|
|
17100
|
-
}, t("neetoForm.fileUpload.dropzone.oneFileAllowed")), shouldShowFileSizeLimit && /*#__PURE__*/React__default.createElement(Typography, {
|
|
17101
|
-
className: "neeto-form-engine-file-upload__dropzone-helper-text",
|
|
17102
|
-
"data-cy": "maximum-allowed-size-text",
|
|
17103
|
-
style: "body3"
|
|
17104
|
-
}, t("neetoForm.fileUpload.dropzone.maxFileSize", {
|
|
17105
|
-
size: maxFileSize,
|
|
17106
|
-
unit: t("neetoForm.fileUpload.mb")
|
|
17107
|
-
})), allowedFileTypes && /*#__PURE__*/React__default.createElement(Typography, {
|
|
17108
|
-
className: "neeto-form-engine-file-upload__dropzone-helper-text",
|
|
17109
|
-
"data-cy": "allowed-files-types-text",
|
|
17110
|
-
style: "body3"
|
|
17111
|
-
}, t("neetoForm.fileUpload.dropzone.allowedFileTypes", {
|
|
17112
|
-
types: allowedFileTypes
|
|
17113
|
-
}))))));
|
|
17114
|
-
};
|
|
16975
|
+
{
|
|
16976
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
16977
|
+
// http://fb.me/prop-types-in-prod
|
|
16978
|
+
propTypes.exports = factoryWithThrowingShims();
|
|
16979
|
+
}
|
|
16980
|
+
|
|
16981
|
+
var propTypesExports = propTypes.exports;
|
|
16982
|
+
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
17115
16983
|
|
|
17116
16984
|
/******************************************************************************
|
|
17117
16985
|
Copyright (c) Microsoft Corporation.
|
|
@@ -17167,6 +17035,44 @@ function __rest(s, e) {
|
|
|
17167
17035
|
return t;
|
|
17168
17036
|
}
|
|
17169
17037
|
|
|
17038
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17039
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17040
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17041
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17042
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17043
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17044
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17045
|
+
});
|
|
17046
|
+
}
|
|
17047
|
+
|
|
17048
|
+
function __generator(thisArg, body) {
|
|
17049
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17050
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
17051
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17052
|
+
function step(op) {
|
|
17053
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17054
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17055
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
17056
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
17057
|
+
switch (op[0]) {
|
|
17058
|
+
case 0: case 1: t = op; break;
|
|
17059
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
17060
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
17061
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
17062
|
+
default:
|
|
17063
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
17064
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
17065
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
17066
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
17067
|
+
if (t[2]) _.ops.pop();
|
|
17068
|
+
_.trys.pop(); continue;
|
|
17069
|
+
}
|
|
17070
|
+
op = body.call(thisArg, _);
|
|
17071
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
17072
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
17073
|
+
}
|
|
17074
|
+
}
|
|
17075
|
+
|
|
17170
17076
|
function __read(o, n) {
|
|
17171
17077
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
17172
17078
|
if (!m) return o;
|
|
@@ -17184,6 +17090,13 @@ function __read(o, n) {
|
|
|
17184
17090
|
return ar;
|
|
17185
17091
|
}
|
|
17186
17092
|
|
|
17093
|
+
/** @deprecated */
|
|
17094
|
+
function __spread() {
|
|
17095
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
17096
|
+
ar = ar.concat(__read(arguments[i]));
|
|
17097
|
+
return ar;
|
|
17098
|
+
}
|
|
17099
|
+
|
|
17187
17100
|
function __spreadArray(to, from, pack) {
|
|
17188
17101
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
17189
17102
|
if (ar || !(i in from)) {
|
|
@@ -17199,6 +17112,1454 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
17199
17112
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
17200
17113
|
};
|
|
17201
17114
|
|
|
17115
|
+
var COMMON_MIME_TYPES = new Map([
|
|
17116
|
+
['avi', 'video/avi'],
|
|
17117
|
+
['gif', 'image/gif'],
|
|
17118
|
+
['ico', 'image/x-icon'],
|
|
17119
|
+
['jpeg', 'image/jpeg'],
|
|
17120
|
+
['jpg', 'image/jpeg'],
|
|
17121
|
+
['mkv', 'video/x-matroska'],
|
|
17122
|
+
['mov', 'video/quicktime'],
|
|
17123
|
+
['mp4', 'video/mp4'],
|
|
17124
|
+
['pdf', 'application/pdf'],
|
|
17125
|
+
['png', 'image/png'],
|
|
17126
|
+
['zip', 'application/zip'],
|
|
17127
|
+
['doc', 'application/msword'],
|
|
17128
|
+
['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
|
|
17129
|
+
]);
|
|
17130
|
+
function toFileWithPath(file, path) {
|
|
17131
|
+
var f = withMimeType(file);
|
|
17132
|
+
if (typeof f.path !== 'string') { // on electron, path is already set to the absolute path
|
|
17133
|
+
var webkitRelativePath = file.webkitRelativePath;
|
|
17134
|
+
Object.defineProperty(f, 'path', {
|
|
17135
|
+
value: typeof path === 'string'
|
|
17136
|
+
? path
|
|
17137
|
+
// If <input webkitdirectory> is set,
|
|
17138
|
+
// the File will have a {webkitRelativePath} property
|
|
17139
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
|
|
17140
|
+
: typeof webkitRelativePath === 'string' && webkitRelativePath.length > 0
|
|
17141
|
+
? webkitRelativePath
|
|
17142
|
+
: file.name,
|
|
17143
|
+
writable: false,
|
|
17144
|
+
configurable: false,
|
|
17145
|
+
enumerable: true
|
|
17146
|
+
});
|
|
17147
|
+
}
|
|
17148
|
+
return f;
|
|
17149
|
+
}
|
|
17150
|
+
function withMimeType(file) {
|
|
17151
|
+
var name = file.name;
|
|
17152
|
+
var hasExtension = name && name.lastIndexOf('.') !== -1;
|
|
17153
|
+
if (hasExtension && !file.type) {
|
|
17154
|
+
var ext = name.split('.')
|
|
17155
|
+
.pop().toLowerCase();
|
|
17156
|
+
var type = COMMON_MIME_TYPES.get(ext);
|
|
17157
|
+
if (type) {
|
|
17158
|
+
Object.defineProperty(file, 'type', {
|
|
17159
|
+
value: type,
|
|
17160
|
+
writable: false,
|
|
17161
|
+
configurable: false,
|
|
17162
|
+
enumerable: true
|
|
17163
|
+
});
|
|
17164
|
+
}
|
|
17165
|
+
}
|
|
17166
|
+
return file;
|
|
17167
|
+
}
|
|
17168
|
+
|
|
17169
|
+
var FILES_TO_IGNORE = [
|
|
17170
|
+
// Thumbnail cache files for macOS and Windows
|
|
17171
|
+
'.DS_Store',
|
|
17172
|
+
'Thumbs.db' // Windows
|
|
17173
|
+
];
|
|
17174
|
+
/**
|
|
17175
|
+
* Convert a DragEvent's DataTrasfer object to a list of File objects
|
|
17176
|
+
* NOTE: If some of the items are folders,
|
|
17177
|
+
* everything will be flattened and placed in the same list but the paths will be kept as a {path} property.
|
|
17178
|
+
* @param evt
|
|
17179
|
+
*/
|
|
17180
|
+
function fromEvent(evt) {
|
|
17181
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
17182
|
+
return __generator(this, function (_a) {
|
|
17183
|
+
return [2 /*return*/, isDragEvt(evt) && evt.dataTransfer
|
|
17184
|
+
? getDataTransferFiles(evt.dataTransfer, evt.type)
|
|
17185
|
+
: getInputFiles(evt)];
|
|
17186
|
+
});
|
|
17187
|
+
});
|
|
17188
|
+
}
|
|
17189
|
+
function isDragEvt(value) {
|
|
17190
|
+
return !!value.dataTransfer;
|
|
17191
|
+
}
|
|
17192
|
+
function getInputFiles(evt) {
|
|
17193
|
+
var files = isInput(evt.target)
|
|
17194
|
+
? evt.target.files
|
|
17195
|
+
? fromList(evt.target.files)
|
|
17196
|
+
: []
|
|
17197
|
+
: [];
|
|
17198
|
+
return files.map(function (file) { return toFileWithPath(file); });
|
|
17199
|
+
}
|
|
17200
|
+
function isInput(value) {
|
|
17201
|
+
return value !== null;
|
|
17202
|
+
}
|
|
17203
|
+
function getDataTransferFiles(dt, type) {
|
|
17204
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
17205
|
+
var items, files;
|
|
17206
|
+
return __generator(this, function (_a) {
|
|
17207
|
+
switch (_a.label) {
|
|
17208
|
+
case 0:
|
|
17209
|
+
if (!dt.items) return [3 /*break*/, 2];
|
|
17210
|
+
items = fromList(dt.items)
|
|
17211
|
+
.filter(function (item) { return item.kind === 'file'; });
|
|
17212
|
+
// According to https://html.spec.whatwg.org/multipage/dnd.html#dndevents,
|
|
17213
|
+
// only 'dragstart' and 'drop' has access to the data (source node)
|
|
17214
|
+
if (type !== 'drop') {
|
|
17215
|
+
return [2 /*return*/, items];
|
|
17216
|
+
}
|
|
17217
|
+
return [4 /*yield*/, Promise.all(items.map(toFilePromises))];
|
|
17218
|
+
case 1:
|
|
17219
|
+
files = _a.sent();
|
|
17220
|
+
return [2 /*return*/, noIgnoredFiles(flatten(files))];
|
|
17221
|
+
case 2: return [2 /*return*/, noIgnoredFiles(fromList(dt.files)
|
|
17222
|
+
.map(function (file) { return toFileWithPath(file); }))];
|
|
17223
|
+
}
|
|
17224
|
+
});
|
|
17225
|
+
});
|
|
17226
|
+
}
|
|
17227
|
+
function noIgnoredFiles(files) {
|
|
17228
|
+
return files.filter(function (file) { return FILES_TO_IGNORE.indexOf(file.name) === -1; });
|
|
17229
|
+
}
|
|
17230
|
+
// IE11 does not support Array.from()
|
|
17231
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Browser_compatibility
|
|
17232
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/FileList
|
|
17233
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList
|
|
17234
|
+
function fromList(items) {
|
|
17235
|
+
var files = [];
|
|
17236
|
+
// tslint:disable: prefer-for-of
|
|
17237
|
+
for (var i = 0; i < items.length; i++) {
|
|
17238
|
+
var file = items[i];
|
|
17239
|
+
files.push(file);
|
|
17240
|
+
}
|
|
17241
|
+
return files;
|
|
17242
|
+
}
|
|
17243
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem
|
|
17244
|
+
function toFilePromises(item) {
|
|
17245
|
+
if (typeof item.webkitGetAsEntry !== 'function') {
|
|
17246
|
+
return fromDataTransferItem(item);
|
|
17247
|
+
}
|
|
17248
|
+
var entry = item.webkitGetAsEntry();
|
|
17249
|
+
// Safari supports dropping an image node from a different window and can be retrieved using
|
|
17250
|
+
// the DataTransferItem.getAsFile() API
|
|
17251
|
+
// NOTE: FileSystemEntry.file() throws if trying to get the file
|
|
17252
|
+
if (entry && entry.isDirectory) {
|
|
17253
|
+
return fromDirEntry(entry);
|
|
17254
|
+
}
|
|
17255
|
+
return fromDataTransferItem(item);
|
|
17256
|
+
}
|
|
17257
|
+
function flatten(items) {
|
|
17258
|
+
return items.reduce(function (acc, files) { return __spread(acc, (Array.isArray(files) ? flatten(files) : [files])); }, []);
|
|
17259
|
+
}
|
|
17260
|
+
function fromDataTransferItem(item) {
|
|
17261
|
+
var file = item.getAsFile();
|
|
17262
|
+
if (!file) {
|
|
17263
|
+
return Promise.reject(item + " is not a File");
|
|
17264
|
+
}
|
|
17265
|
+
var fwp = toFileWithPath(file);
|
|
17266
|
+
return Promise.resolve(fwp);
|
|
17267
|
+
}
|
|
17268
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry
|
|
17269
|
+
function fromEntry(entry) {
|
|
17270
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
17271
|
+
return __generator(this, function (_a) {
|
|
17272
|
+
return [2 /*return*/, entry.isDirectory ? fromDirEntry(entry) : fromFileEntry(entry)];
|
|
17273
|
+
});
|
|
17274
|
+
});
|
|
17275
|
+
}
|
|
17276
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry
|
|
17277
|
+
function fromDirEntry(entry) {
|
|
17278
|
+
var reader = entry.createReader();
|
|
17279
|
+
return new Promise(function (resolve, reject) {
|
|
17280
|
+
var entries = [];
|
|
17281
|
+
function readEntries() {
|
|
17282
|
+
var _this = this;
|
|
17283
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry/createReader
|
|
17284
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader/readEntries
|
|
17285
|
+
reader.readEntries(function (batch) { return __awaiter(_this, void 0, void 0, function () {
|
|
17286
|
+
var files, err_1, items;
|
|
17287
|
+
return __generator(this, function (_a) {
|
|
17288
|
+
switch (_a.label) {
|
|
17289
|
+
case 0:
|
|
17290
|
+
if (!!batch.length) return [3 /*break*/, 5];
|
|
17291
|
+
_a.label = 1;
|
|
17292
|
+
case 1:
|
|
17293
|
+
_a.trys.push([1, 3, , 4]);
|
|
17294
|
+
return [4 /*yield*/, Promise.all(entries)];
|
|
17295
|
+
case 2:
|
|
17296
|
+
files = _a.sent();
|
|
17297
|
+
resolve(files);
|
|
17298
|
+
return [3 /*break*/, 4];
|
|
17299
|
+
case 3:
|
|
17300
|
+
err_1 = _a.sent();
|
|
17301
|
+
reject(err_1);
|
|
17302
|
+
return [3 /*break*/, 4];
|
|
17303
|
+
case 4: return [3 /*break*/, 6];
|
|
17304
|
+
case 5:
|
|
17305
|
+
items = Promise.all(batch.map(fromEntry));
|
|
17306
|
+
entries.push(items);
|
|
17307
|
+
// Continue reading
|
|
17308
|
+
readEntries();
|
|
17309
|
+
_a.label = 6;
|
|
17310
|
+
case 6: return [2 /*return*/];
|
|
17311
|
+
}
|
|
17312
|
+
});
|
|
17313
|
+
}); }, function (err) {
|
|
17314
|
+
reject(err);
|
|
17315
|
+
});
|
|
17316
|
+
}
|
|
17317
|
+
readEntries();
|
|
17318
|
+
});
|
|
17319
|
+
}
|
|
17320
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry
|
|
17321
|
+
function fromFileEntry(entry) {
|
|
17322
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
17323
|
+
return __generator(this, function (_a) {
|
|
17324
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
17325
|
+
entry.file(function (file) {
|
|
17326
|
+
var fwp = toFileWithPath(file, entry.fullPath);
|
|
17327
|
+
resolve(fwp);
|
|
17328
|
+
}, function (err) {
|
|
17329
|
+
reject(err);
|
|
17330
|
+
});
|
|
17331
|
+
})];
|
|
17332
|
+
});
|
|
17333
|
+
});
|
|
17334
|
+
}
|
|
17335
|
+
|
|
17336
|
+
var _default$1 = function (file, acceptedFiles) {
|
|
17337
|
+
if (file && acceptedFiles) {
|
|
17338
|
+
var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
|
|
17339
|
+
var fileName = file.name || '';
|
|
17340
|
+
var mimeType = (file.type || '').toLowerCase();
|
|
17341
|
+
var baseMimeType = mimeType.replace(/\/.*$/, '');
|
|
17342
|
+
return acceptedFilesArray.some(function (type) {
|
|
17343
|
+
var validType = type.trim().toLowerCase();
|
|
17344
|
+
|
|
17345
|
+
if (validType.charAt(0) === '.') {
|
|
17346
|
+
return fileName.toLowerCase().endsWith(validType);
|
|
17347
|
+
} else if (validType.endsWith('/*')) {
|
|
17348
|
+
// This is something like a image/* mime type
|
|
17349
|
+
return baseMimeType === validType.replace(/\/.*$/, '');
|
|
17350
|
+
}
|
|
17351
|
+
|
|
17352
|
+
return mimeType === validType;
|
|
17353
|
+
});
|
|
17354
|
+
}
|
|
17355
|
+
|
|
17356
|
+
return true;
|
|
17357
|
+
};
|
|
17358
|
+
|
|
17359
|
+
function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest$1(); }
|
|
17360
|
+
|
|
17361
|
+
function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17362
|
+
|
|
17363
|
+
function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
|
|
17364
|
+
|
|
17365
|
+
function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17366
|
+
|
|
17367
|
+
function _iterableToArrayLimit$1(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
17368
|
+
|
|
17369
|
+
function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
|
|
17370
|
+
|
|
17371
|
+
var FILE_INVALID_TYPE = 'file-invalid-type';
|
|
17372
|
+
var FILE_TOO_LARGE = 'file-too-large';
|
|
17373
|
+
var FILE_TOO_SMALL = 'file-too-small';
|
|
17374
|
+
var TOO_MANY_FILES = 'too-many-files'; // File Errors
|
|
17375
|
+
|
|
17376
|
+
var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr(accept) {
|
|
17377
|
+
accept = Array.isArray(accept) && accept.length === 1 ? accept[0] : accept;
|
|
17378
|
+
var messageSuffix = Array.isArray(accept) ? "one of ".concat(accept.join(', ')) : accept;
|
|
17379
|
+
return {
|
|
17380
|
+
code: FILE_INVALID_TYPE,
|
|
17381
|
+
message: "File type must be ".concat(messageSuffix)
|
|
17382
|
+
};
|
|
17383
|
+
};
|
|
17384
|
+
var getTooLargeRejectionErr = function getTooLargeRejectionErr(maxSize) {
|
|
17385
|
+
return {
|
|
17386
|
+
code: FILE_TOO_LARGE,
|
|
17387
|
+
message: "File is larger than ".concat(maxSize, " bytes")
|
|
17388
|
+
};
|
|
17389
|
+
};
|
|
17390
|
+
var getTooSmallRejectionErr = function getTooSmallRejectionErr(minSize) {
|
|
17391
|
+
return {
|
|
17392
|
+
code: FILE_TOO_SMALL,
|
|
17393
|
+
message: "File is smaller than ".concat(minSize, " bytes")
|
|
17394
|
+
};
|
|
17395
|
+
};
|
|
17396
|
+
var TOO_MANY_FILES_REJECTION = {
|
|
17397
|
+
code: TOO_MANY_FILES,
|
|
17398
|
+
message: 'Too many files'
|
|
17399
|
+
}; // Firefox versions prior to 53 return a bogus MIME type for every file drag, so dragovers with
|
|
17400
|
+
// that MIME type will always be accepted
|
|
17401
|
+
|
|
17402
|
+
function fileAccepted(file, accept) {
|
|
17403
|
+
var isAcceptable = file.type === 'application/x-moz-file' || _default$1(file, accept);
|
|
17404
|
+
return [isAcceptable, isAcceptable ? null : getInvalidTypeRejectionErr(accept)];
|
|
17405
|
+
}
|
|
17406
|
+
function fileMatchSize(file, minSize, maxSize) {
|
|
17407
|
+
if (isDefined(file.size)) {
|
|
17408
|
+
if (isDefined(minSize) && isDefined(maxSize)) {
|
|
17409
|
+
if (file.size > maxSize) return [false, getTooLargeRejectionErr(maxSize)];
|
|
17410
|
+
if (file.size < minSize) return [false, getTooSmallRejectionErr(minSize)];
|
|
17411
|
+
} else if (isDefined(minSize) && file.size < minSize) return [false, getTooSmallRejectionErr(minSize)];else if (isDefined(maxSize) && file.size > maxSize) return [false, getTooLargeRejectionErr(maxSize)];
|
|
17412
|
+
}
|
|
17413
|
+
|
|
17414
|
+
return [true, null];
|
|
17415
|
+
}
|
|
17416
|
+
|
|
17417
|
+
function isDefined(value) {
|
|
17418
|
+
return value !== undefined && value !== null;
|
|
17419
|
+
}
|
|
17420
|
+
|
|
17421
|
+
function allFilesAccepted(_ref) {
|
|
17422
|
+
var files = _ref.files,
|
|
17423
|
+
accept = _ref.accept,
|
|
17424
|
+
minSize = _ref.minSize,
|
|
17425
|
+
maxSize = _ref.maxSize,
|
|
17426
|
+
multiple = _ref.multiple,
|
|
17427
|
+
maxFiles = _ref.maxFiles;
|
|
17428
|
+
|
|
17429
|
+
if (!multiple && files.length > 1 || multiple && maxFiles >= 1 && files.length > maxFiles) {
|
|
17430
|
+
return false;
|
|
17431
|
+
}
|
|
17432
|
+
|
|
17433
|
+
return files.every(function (file) {
|
|
17434
|
+
var _fileAccepted = fileAccepted(file, accept),
|
|
17435
|
+
_fileAccepted2 = _slicedToArray$1(_fileAccepted, 1),
|
|
17436
|
+
accepted = _fileAccepted2[0];
|
|
17437
|
+
|
|
17438
|
+
var _fileMatchSize = fileMatchSize(file, minSize, maxSize),
|
|
17439
|
+
_fileMatchSize2 = _slicedToArray$1(_fileMatchSize, 1),
|
|
17440
|
+
sizeMatch = _fileMatchSize2[0];
|
|
17441
|
+
|
|
17442
|
+
return accepted && sizeMatch;
|
|
17443
|
+
});
|
|
17444
|
+
} // React's synthetic events has event.isPropagationStopped,
|
|
17445
|
+
// but to remain compatibility with other libs (Preact) fall back
|
|
17446
|
+
// to check event.cancelBubble
|
|
17447
|
+
|
|
17448
|
+
function isPropagationStopped(event) {
|
|
17449
|
+
if (typeof event.isPropagationStopped === 'function') {
|
|
17450
|
+
return event.isPropagationStopped();
|
|
17451
|
+
} else if (typeof event.cancelBubble !== 'undefined') {
|
|
17452
|
+
return event.cancelBubble;
|
|
17453
|
+
}
|
|
17454
|
+
|
|
17455
|
+
return false;
|
|
17456
|
+
}
|
|
17457
|
+
function isEvtWithFiles(event) {
|
|
17458
|
+
if (!event.dataTransfer) {
|
|
17459
|
+
return !!event.target && !!event.target.files;
|
|
17460
|
+
} // https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types
|
|
17461
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file
|
|
17462
|
+
|
|
17463
|
+
|
|
17464
|
+
return Array.prototype.some.call(event.dataTransfer.types, function (type) {
|
|
17465
|
+
return type === 'Files' || type === 'application/x-moz-file';
|
|
17466
|
+
});
|
|
17467
|
+
}
|
|
17468
|
+
|
|
17469
|
+
function onDocumentDragOver(event) {
|
|
17470
|
+
event.preventDefault();
|
|
17471
|
+
}
|
|
17472
|
+
|
|
17473
|
+
function isIe(userAgent) {
|
|
17474
|
+
return userAgent.indexOf('MSIE') !== -1 || userAgent.indexOf('Trident/') !== -1;
|
|
17475
|
+
}
|
|
17476
|
+
|
|
17477
|
+
function isEdge(userAgent) {
|
|
17478
|
+
return userAgent.indexOf('Edge/') !== -1;
|
|
17479
|
+
}
|
|
17480
|
+
|
|
17481
|
+
function isIeOrEdge() {
|
|
17482
|
+
var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.navigator.userAgent;
|
|
17483
|
+
return isIe(userAgent) || isEdge(userAgent);
|
|
17484
|
+
}
|
|
17485
|
+
/**
|
|
17486
|
+
* This is intended to be used to compose event handlers
|
|
17487
|
+
* They are executed in order until one of them calls `event.isPropagationStopped()`.
|
|
17488
|
+
* Note that the check is done on the first invoke too,
|
|
17489
|
+
* meaning that if propagation was stopped before invoking the fns,
|
|
17490
|
+
* no handlers will be executed.
|
|
17491
|
+
*
|
|
17492
|
+
* @param {Function} fns the event hanlder functions
|
|
17493
|
+
* @return {Function} the event handler to add to an element
|
|
17494
|
+
*/
|
|
17495
|
+
|
|
17496
|
+
function composeEventHandlers() {
|
|
17497
|
+
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17498
|
+
fns[_key] = arguments[_key];
|
|
17499
|
+
}
|
|
17500
|
+
|
|
17501
|
+
return function (event) {
|
|
17502
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
17503
|
+
args[_key2 - 1] = arguments[_key2];
|
|
17504
|
+
}
|
|
17505
|
+
|
|
17506
|
+
return fns.some(function (fn) {
|
|
17507
|
+
if (!isPropagationStopped(event) && fn) {
|
|
17508
|
+
fn.apply(void 0, [event].concat(args));
|
|
17509
|
+
}
|
|
17510
|
+
|
|
17511
|
+
return isPropagationStopped(event);
|
|
17512
|
+
});
|
|
17513
|
+
};
|
|
17514
|
+
}
|
|
17515
|
+
|
|
17516
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread(); }
|
|
17517
|
+
|
|
17518
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17519
|
+
|
|
17520
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
17521
|
+
|
|
17522
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray$1(arr); }
|
|
17523
|
+
|
|
17524
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest(); }
|
|
17525
|
+
|
|
17526
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17527
|
+
|
|
17528
|
+
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
17529
|
+
|
|
17530
|
+
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17531
|
+
|
|
17532
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
17533
|
+
|
|
17534
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17535
|
+
|
|
17536
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
17537
|
+
|
|
17538
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17539
|
+
|
|
17540
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17541
|
+
|
|
17542
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17543
|
+
|
|
17544
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17545
|
+
/**
|
|
17546
|
+
* Convenience wrapper component for the `useDropzone` hook
|
|
17547
|
+
*
|
|
17548
|
+
* ```jsx
|
|
17549
|
+
* <Dropzone>
|
|
17550
|
+
* {({getRootProps, getInputProps}) => (
|
|
17551
|
+
* <div {...getRootProps()}>
|
|
17552
|
+
* <input {...getInputProps()} />
|
|
17553
|
+
* <p>Drag 'n' drop some files here, or click to select files</p>
|
|
17554
|
+
* </div>
|
|
17555
|
+
* )}
|
|
17556
|
+
* </Dropzone>
|
|
17557
|
+
* ```
|
|
17558
|
+
*/
|
|
17559
|
+
|
|
17560
|
+
var Dropzone = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
17561
|
+
var children = _ref.children,
|
|
17562
|
+
params = _objectWithoutProperties(_ref, ["children"]);
|
|
17563
|
+
|
|
17564
|
+
var _useDropzone = useDropzone(params),
|
|
17565
|
+
open = _useDropzone.open,
|
|
17566
|
+
props = _objectWithoutProperties(_useDropzone, ["open"]);
|
|
17567
|
+
|
|
17568
|
+
useImperativeHandle(ref, function () {
|
|
17569
|
+
return {
|
|
17570
|
+
open: open
|
|
17571
|
+
};
|
|
17572
|
+
}, [open]); // TODO: Figure out why react-styleguidist cannot create docs if we don't return a jsx element
|
|
17573
|
+
|
|
17574
|
+
return /*#__PURE__*/React__default.createElement(Fragment, null, children(_objectSpread$3(_objectSpread$3({}, props), {}, {
|
|
17575
|
+
open: open
|
|
17576
|
+
})));
|
|
17577
|
+
});
|
|
17578
|
+
Dropzone.displayName = 'Dropzone'; // Add default props for react-docgen
|
|
17579
|
+
|
|
17580
|
+
var defaultProps = {
|
|
17581
|
+
disabled: false,
|
|
17582
|
+
getFilesFromEvent: fromEvent,
|
|
17583
|
+
maxSize: Infinity,
|
|
17584
|
+
minSize: 0,
|
|
17585
|
+
multiple: true,
|
|
17586
|
+
maxFiles: 0,
|
|
17587
|
+
preventDropOnDocument: true,
|
|
17588
|
+
noClick: false,
|
|
17589
|
+
noKeyboard: false,
|
|
17590
|
+
noDrag: false,
|
|
17591
|
+
noDragEventsBubbling: false
|
|
17592
|
+
};
|
|
17593
|
+
Dropzone.defaultProps = defaultProps;
|
|
17594
|
+
Dropzone.propTypes = {
|
|
17595
|
+
/**
|
|
17596
|
+
* Render function that exposes the dropzone state and prop getter fns
|
|
17597
|
+
*
|
|
17598
|
+
* @param {object} params
|
|
17599
|
+
* @param {Function} params.getRootProps Returns the props you should apply to the root drop container you render
|
|
17600
|
+
* @param {Function} params.getInputProps Returns the props you should apply to hidden file input you render
|
|
17601
|
+
* @param {Function} params.open Open the native file selection dialog
|
|
17602
|
+
* @param {boolean} params.isFocused Dropzone area is in focus
|
|
17603
|
+
* @param {boolean} params.isFileDialogActive File dialog is opened
|
|
17604
|
+
* @param {boolean} params.isDragActive Active drag is in progress
|
|
17605
|
+
* @param {boolean} params.isDragAccept Dragged files are accepted
|
|
17606
|
+
* @param {boolean} params.isDragReject Some dragged files are rejected
|
|
17607
|
+
* @param {File[]} params.draggedFiles Files in active drag
|
|
17608
|
+
* @param {File[]} params.acceptedFiles Accepted files
|
|
17609
|
+
* @param {FileRejection[]} params.fileRejections Rejected files and why they were rejected
|
|
17610
|
+
*/
|
|
17611
|
+
children: PropTypes.func,
|
|
17612
|
+
|
|
17613
|
+
/**
|
|
17614
|
+
* Set accepted file types.
|
|
17615
|
+
* See https://github.com/okonet/attr-accept for more information.
|
|
17616
|
+
* Keep in mind that mime type determination is not reliable across platforms. CSV files,
|
|
17617
|
+
* for example, are reported as text/plain under macOS but as application/vnd.ms-excel under
|
|
17618
|
+
* Windows. In some cases there might not be a mime type set at all.
|
|
17619
|
+
* See: https://github.com/react-dropzone/react-dropzone/issues/276
|
|
17620
|
+
*/
|
|
17621
|
+
accept: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
17622
|
+
|
|
17623
|
+
/**
|
|
17624
|
+
* Allow drag 'n' drop (or selection from the file dialog) of multiple files
|
|
17625
|
+
*/
|
|
17626
|
+
multiple: PropTypes.bool,
|
|
17627
|
+
|
|
17628
|
+
/**
|
|
17629
|
+
* If false, allow dropped items to take over the current browser window
|
|
17630
|
+
*/
|
|
17631
|
+
preventDropOnDocument: PropTypes.bool,
|
|
17632
|
+
|
|
17633
|
+
/**
|
|
17634
|
+
* If true, disables click to open the native file selection dialog
|
|
17635
|
+
*/
|
|
17636
|
+
noClick: PropTypes.bool,
|
|
17637
|
+
|
|
17638
|
+
/**
|
|
17639
|
+
* If true, disables SPACE/ENTER to open the native file selection dialog.
|
|
17640
|
+
* Note that it also stops tracking the focus state.
|
|
17641
|
+
*/
|
|
17642
|
+
noKeyboard: PropTypes.bool,
|
|
17643
|
+
|
|
17644
|
+
/**
|
|
17645
|
+
* If true, disables drag 'n' drop
|
|
17646
|
+
*/
|
|
17647
|
+
noDrag: PropTypes.bool,
|
|
17648
|
+
|
|
17649
|
+
/**
|
|
17650
|
+
* If true, stops drag event propagation to parents
|
|
17651
|
+
*/
|
|
17652
|
+
noDragEventsBubbling: PropTypes.bool,
|
|
17653
|
+
|
|
17654
|
+
/**
|
|
17655
|
+
* Minimum file size (in bytes)
|
|
17656
|
+
*/
|
|
17657
|
+
minSize: PropTypes.number,
|
|
17658
|
+
|
|
17659
|
+
/**
|
|
17660
|
+
* Maximum file size (in bytes)
|
|
17661
|
+
*/
|
|
17662
|
+
maxSize: PropTypes.number,
|
|
17663
|
+
|
|
17664
|
+
/**
|
|
17665
|
+
* Maximum accepted number of files
|
|
17666
|
+
* The default value is 0 which means there is no limitation to how many files are accepted.
|
|
17667
|
+
*/
|
|
17668
|
+
maxFiles: PropTypes.number,
|
|
17669
|
+
|
|
17670
|
+
/**
|
|
17671
|
+
* Enable/disable the dropzone
|
|
17672
|
+
*/
|
|
17673
|
+
disabled: PropTypes.bool,
|
|
17674
|
+
|
|
17675
|
+
/**
|
|
17676
|
+
* Use this to provide a custom file aggregator
|
|
17677
|
+
*
|
|
17678
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
17679
|
+
*/
|
|
17680
|
+
getFilesFromEvent: PropTypes.func,
|
|
17681
|
+
|
|
17682
|
+
/**
|
|
17683
|
+
* Cb for when closing the file dialog with no selection
|
|
17684
|
+
*/
|
|
17685
|
+
onFileDialogCancel: PropTypes.func,
|
|
17686
|
+
|
|
17687
|
+
/**
|
|
17688
|
+
* Cb for when the `dragenter` event occurs.
|
|
17689
|
+
*
|
|
17690
|
+
* @param {DragEvent} event
|
|
17691
|
+
*/
|
|
17692
|
+
onDragEnter: PropTypes.func,
|
|
17693
|
+
|
|
17694
|
+
/**
|
|
17695
|
+
* Cb for when the `dragleave` event occurs
|
|
17696
|
+
*
|
|
17697
|
+
* @param {DragEvent} event
|
|
17698
|
+
*/
|
|
17699
|
+
onDragLeave: PropTypes.func,
|
|
17700
|
+
|
|
17701
|
+
/**
|
|
17702
|
+
* Cb for when the `dragover` event occurs
|
|
17703
|
+
*
|
|
17704
|
+
* @param {DragEvent} event
|
|
17705
|
+
*/
|
|
17706
|
+
onDragOver: PropTypes.func,
|
|
17707
|
+
|
|
17708
|
+
/**
|
|
17709
|
+
* Cb for when the `drop` event occurs.
|
|
17710
|
+
* Note that this callback is invoked after the `getFilesFromEvent` callback is done.
|
|
17711
|
+
*
|
|
17712
|
+
* Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and `maxSize` props.
|
|
17713
|
+
* `accept` must be a valid [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml) according to [input element specification](https://www.w3.org/wiki/HTML/Elements/input/file) or a valid file extension.
|
|
17714
|
+
* If `multiple` is set to false and additional files are dropped,
|
|
17715
|
+
* all files besides the first will be rejected.
|
|
17716
|
+
* Any file which does not have a size in the [`minSize`, `maxSize`] range, will be rejected as well.
|
|
17717
|
+
*
|
|
17718
|
+
* Note that the `onDrop` callback will always be invoked regardless if the dropped files were accepted or rejected.
|
|
17719
|
+
* If you'd like to react to a specific scenario, use the `onDropAccepted`/`onDropRejected` props.
|
|
17720
|
+
*
|
|
17721
|
+
* `onDrop` will provide you with an array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects which you can then process and send to a server.
|
|
17722
|
+
* For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
|
|
17723
|
+
*
|
|
17724
|
+
* ```js
|
|
17725
|
+
* function onDrop(acceptedFiles) {
|
|
17726
|
+
* const req = request.post('/upload')
|
|
17727
|
+
* acceptedFiles.forEach(file => {
|
|
17728
|
+
* req.attach(file.name, file)
|
|
17729
|
+
* })
|
|
17730
|
+
* req.end(callback)
|
|
17731
|
+
* }
|
|
17732
|
+
* ```
|
|
17733
|
+
*
|
|
17734
|
+
* @param {File[]} acceptedFiles
|
|
17735
|
+
* @param {FileRejection[]} fileRejections
|
|
17736
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
17737
|
+
*/
|
|
17738
|
+
onDrop: PropTypes.func,
|
|
17739
|
+
|
|
17740
|
+
/**
|
|
17741
|
+
* Cb for when the `drop` event occurs.
|
|
17742
|
+
* Note that if no files are accepted, this callback is not invoked.
|
|
17743
|
+
*
|
|
17744
|
+
* @param {File[]} files
|
|
17745
|
+
* @param {(DragEvent|Event)} event
|
|
17746
|
+
*/
|
|
17747
|
+
onDropAccepted: PropTypes.func,
|
|
17748
|
+
|
|
17749
|
+
/**
|
|
17750
|
+
* Cb for when the `drop` event occurs.
|
|
17751
|
+
* Note that if no files are rejected, this callback is not invoked.
|
|
17752
|
+
*
|
|
17753
|
+
* @param {FileRejection[]} fileRejections
|
|
17754
|
+
* @param {(DragEvent|Event)} event
|
|
17755
|
+
*/
|
|
17756
|
+
onDropRejected: PropTypes.func
|
|
17757
|
+
};
|
|
17758
|
+
/**
|
|
17759
|
+
* A function that is invoked for the `dragenter`,
|
|
17760
|
+
* `dragover` and `dragleave` events.
|
|
17761
|
+
* It is not invoked if the items are not files (such as link, text, etc.).
|
|
17762
|
+
*
|
|
17763
|
+
* @callback dragCb
|
|
17764
|
+
* @param {DragEvent} event
|
|
17765
|
+
*/
|
|
17766
|
+
|
|
17767
|
+
/**
|
|
17768
|
+
* A function that is invoked for the `drop` or input change event.
|
|
17769
|
+
* It is not invoked if the items are not files (such as link, text, etc.).
|
|
17770
|
+
*
|
|
17771
|
+
* @callback dropCb
|
|
17772
|
+
* @param {File[]} acceptedFiles List of accepted files
|
|
17773
|
+
* @param {FileRejection[]} fileRejections List of rejected files and why they were rejected
|
|
17774
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
17775
|
+
*/
|
|
17776
|
+
|
|
17777
|
+
/**
|
|
17778
|
+
* A function that is invoked for the `drop` or input change event.
|
|
17779
|
+
* It is not invoked if the items are files (such as link, text, etc.).
|
|
17780
|
+
*
|
|
17781
|
+
* @callback dropAcceptedCb
|
|
17782
|
+
* @param {File[]} files List of accepted files that meet the given criteria
|
|
17783
|
+
* (`accept`, `multiple`, `minSize`, `maxSize`)
|
|
17784
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
17785
|
+
*/
|
|
17786
|
+
|
|
17787
|
+
/**
|
|
17788
|
+
* A function that is invoked for the `drop` or input change event.
|
|
17789
|
+
*
|
|
17790
|
+
* @callback dropRejectedCb
|
|
17791
|
+
* @param {File[]} files List of rejected files that do not meet the given criteria
|
|
17792
|
+
* (`accept`, `multiple`, `minSize`, `maxSize`)
|
|
17793
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
17794
|
+
*/
|
|
17795
|
+
|
|
17796
|
+
/**
|
|
17797
|
+
* A function that is used aggregate files,
|
|
17798
|
+
* in a asynchronous fashion, from drag or input change events.
|
|
17799
|
+
*
|
|
17800
|
+
* @callback getFilesFromEvent
|
|
17801
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
17802
|
+
* @returns {(File[]|Promise<File[]>)}
|
|
17803
|
+
*/
|
|
17804
|
+
|
|
17805
|
+
/**
|
|
17806
|
+
* An object with the current dropzone state and some helper functions.
|
|
17807
|
+
*
|
|
17808
|
+
* @typedef {object} DropzoneState
|
|
17809
|
+
* @property {Function} getRootProps Returns the props you should apply to the root drop container you render
|
|
17810
|
+
* @property {Function} getInputProps Returns the props you should apply to hidden file input you render
|
|
17811
|
+
* @property {Function} open Open the native file selection dialog
|
|
17812
|
+
* @property {boolean} isFocused Dropzone area is in focus
|
|
17813
|
+
* @property {boolean} isFileDialogActive File dialog is opened
|
|
17814
|
+
* @property {boolean} isDragActive Active drag is in progress
|
|
17815
|
+
* @property {boolean} isDragAccept Dragged files are accepted
|
|
17816
|
+
* @property {boolean} isDragReject Some dragged files are rejected
|
|
17817
|
+
* @property {File[]} draggedFiles Files in active drag
|
|
17818
|
+
* @property {File[]} acceptedFiles Accepted files
|
|
17819
|
+
* @property {FileRejection[]} fileRejections Rejected files and why they were rejected
|
|
17820
|
+
*/
|
|
17821
|
+
|
|
17822
|
+
var initialState = {
|
|
17823
|
+
isFocused: false,
|
|
17824
|
+
isFileDialogActive: false,
|
|
17825
|
+
isDragActive: false,
|
|
17826
|
+
isDragAccept: false,
|
|
17827
|
+
isDragReject: false,
|
|
17828
|
+
draggedFiles: [],
|
|
17829
|
+
acceptedFiles: [],
|
|
17830
|
+
fileRejections: []
|
|
17831
|
+
};
|
|
17832
|
+
/**
|
|
17833
|
+
* A React hook that creates a drag 'n' drop area.
|
|
17834
|
+
*
|
|
17835
|
+
* ```jsx
|
|
17836
|
+
* function MyDropzone(props) {
|
|
17837
|
+
* const {getRootProps, getInputProps} = useDropzone({
|
|
17838
|
+
* onDrop: acceptedFiles => {
|
|
17839
|
+
* // do something with the File objects, e.g. upload to some server
|
|
17840
|
+
* }
|
|
17841
|
+
* });
|
|
17842
|
+
* return (
|
|
17843
|
+
* <div {...getRootProps()}>
|
|
17844
|
+
* <input {...getInputProps()} />
|
|
17845
|
+
* <p>Drag and drop some files here, or click to select files</p>
|
|
17846
|
+
* </div>
|
|
17847
|
+
* )
|
|
17848
|
+
* }
|
|
17849
|
+
* ```
|
|
17850
|
+
*
|
|
17851
|
+
* @function useDropzone
|
|
17852
|
+
*
|
|
17853
|
+
* @param {object} props
|
|
17854
|
+
* @param {string|string[]} [props.accept] Set accepted file types.
|
|
17855
|
+
* See https://github.com/okonet/attr-accept for more information.
|
|
17856
|
+
* Keep in mind that mime type determination is not reliable across platforms. CSV files,
|
|
17857
|
+
* for example, are reported as text/plain under macOS but as application/vnd.ms-excel under
|
|
17858
|
+
* Windows. In some cases there might not be a mime type set at all.
|
|
17859
|
+
* See: https://github.com/react-dropzone/react-dropzone/issues/276
|
|
17860
|
+
* @param {boolean} [props.multiple=true] Allow drag 'n' drop (or selection from the file dialog) of multiple files
|
|
17861
|
+
* @param {boolean} [props.preventDropOnDocument=true] If false, allow dropped items to take over the current browser window
|
|
17862
|
+
* @param {boolean} [props.noClick=false] If true, disables click to open the native file selection dialog
|
|
17863
|
+
* @param {boolean} [props.noKeyboard=false] If true, disables SPACE/ENTER to open the native file selection dialog.
|
|
17864
|
+
* Note that it also stops tracking the focus state.
|
|
17865
|
+
* @param {boolean} [props.noDrag=false] If true, disables drag 'n' drop
|
|
17866
|
+
* @param {boolean} [props.noDragEventsBubbling=false] If true, stops drag event propagation to parents
|
|
17867
|
+
* @param {number} [props.minSize=0] Minimum file size (in bytes)
|
|
17868
|
+
* @param {number} [props.maxSize=Infinity] Maximum file size (in bytes)
|
|
17869
|
+
* @param {boolean} [props.disabled=false] Enable/disable the dropzone
|
|
17870
|
+
* @param {getFilesFromEvent} [props.getFilesFromEvent] Use this to provide a custom file aggregator
|
|
17871
|
+
* @param {Function} [props.onFileDialogCancel] Cb for when closing the file dialog with no selection
|
|
17872
|
+
* @param {dragCb} [props.onDragEnter] Cb for when the `dragenter` event occurs.
|
|
17873
|
+
* @param {dragCb} [props.onDragLeave] Cb for when the `dragleave` event occurs
|
|
17874
|
+
* @param {dragCb} [props.onDragOver] Cb for when the `dragover` event occurs
|
|
17875
|
+
* @param {dropCb} [props.onDrop] Cb for when the `drop` event occurs.
|
|
17876
|
+
* Note that this callback is invoked after the `getFilesFromEvent` callback is done.
|
|
17877
|
+
*
|
|
17878
|
+
* Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and `maxSize` props.
|
|
17879
|
+
* `accept` must be a valid [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml) according to [input element specification](https://www.w3.org/wiki/HTML/Elements/input/file) or a valid file extension.
|
|
17880
|
+
* If `multiple` is set to false and additional files are dropped,
|
|
17881
|
+
* all files besides the first will be rejected.
|
|
17882
|
+
* Any file which does not have a size in the [`minSize`, `maxSize`] range, will be rejected as well.
|
|
17883
|
+
*
|
|
17884
|
+
* Note that the `onDrop` callback will always be invoked regardless if the dropped files were accepted or rejected.
|
|
17885
|
+
* If you'd like to react to a specific scenario, use the `onDropAccepted`/`onDropRejected` props.
|
|
17886
|
+
*
|
|
17887
|
+
* `onDrop` will provide you with an array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects which you can then process and send to a server.
|
|
17888
|
+
* For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
|
|
17889
|
+
*
|
|
17890
|
+
* ```js
|
|
17891
|
+
* function onDrop(acceptedFiles) {
|
|
17892
|
+
* const req = request.post('/upload')
|
|
17893
|
+
* acceptedFiles.forEach(file => {
|
|
17894
|
+
* req.attach(file.name, file)
|
|
17895
|
+
* })
|
|
17896
|
+
* req.end(callback)
|
|
17897
|
+
* }
|
|
17898
|
+
* ```
|
|
17899
|
+
* @param {dropAcceptedCb} [props.onDropAccepted]
|
|
17900
|
+
* @param {dropRejectedCb} [props.onDropRejected]
|
|
17901
|
+
*
|
|
17902
|
+
* @returns {DropzoneState}
|
|
17903
|
+
*/
|
|
17904
|
+
|
|
17905
|
+
function useDropzone() {
|
|
17906
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17907
|
+
|
|
17908
|
+
var _defaultProps$options = _objectSpread$3(_objectSpread$3({}, defaultProps), options),
|
|
17909
|
+
accept = _defaultProps$options.accept,
|
|
17910
|
+
disabled = _defaultProps$options.disabled,
|
|
17911
|
+
getFilesFromEvent = _defaultProps$options.getFilesFromEvent,
|
|
17912
|
+
maxSize = _defaultProps$options.maxSize,
|
|
17913
|
+
minSize = _defaultProps$options.minSize,
|
|
17914
|
+
multiple = _defaultProps$options.multiple,
|
|
17915
|
+
maxFiles = _defaultProps$options.maxFiles,
|
|
17916
|
+
onDragEnter = _defaultProps$options.onDragEnter,
|
|
17917
|
+
onDragLeave = _defaultProps$options.onDragLeave,
|
|
17918
|
+
onDragOver = _defaultProps$options.onDragOver,
|
|
17919
|
+
onDrop = _defaultProps$options.onDrop,
|
|
17920
|
+
onDropAccepted = _defaultProps$options.onDropAccepted,
|
|
17921
|
+
onDropRejected = _defaultProps$options.onDropRejected,
|
|
17922
|
+
onFileDialogCancel = _defaultProps$options.onFileDialogCancel,
|
|
17923
|
+
preventDropOnDocument = _defaultProps$options.preventDropOnDocument,
|
|
17924
|
+
noClick = _defaultProps$options.noClick,
|
|
17925
|
+
noKeyboard = _defaultProps$options.noKeyboard,
|
|
17926
|
+
noDrag = _defaultProps$options.noDrag,
|
|
17927
|
+
noDragEventsBubbling = _defaultProps$options.noDragEventsBubbling;
|
|
17928
|
+
|
|
17929
|
+
var rootRef = useRef(null);
|
|
17930
|
+
var inputRef = useRef(null);
|
|
17931
|
+
|
|
17932
|
+
var _useReducer = useReducer(reducer, initialState),
|
|
17933
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
17934
|
+
state = _useReducer2[0],
|
|
17935
|
+
dispatch = _useReducer2[1];
|
|
17936
|
+
|
|
17937
|
+
var isFocused = state.isFocused,
|
|
17938
|
+
isFileDialogActive = state.isFileDialogActive,
|
|
17939
|
+
draggedFiles = state.draggedFiles; // Fn for opening the file dialog programmatically
|
|
17940
|
+
|
|
17941
|
+
var openFileDialog = useCallback$1(function () {
|
|
17942
|
+
if (inputRef.current) {
|
|
17943
|
+
dispatch({
|
|
17944
|
+
type: 'openDialog'
|
|
17945
|
+
});
|
|
17946
|
+
inputRef.current.value = null;
|
|
17947
|
+
inputRef.current.click();
|
|
17948
|
+
}
|
|
17949
|
+
}, [dispatch]); // Update file dialog active state when the window is focused on
|
|
17950
|
+
|
|
17951
|
+
var onWindowFocus = function onWindowFocus() {
|
|
17952
|
+
// Execute the timeout only if the file dialog is opened in the browser
|
|
17953
|
+
if (isFileDialogActive) {
|
|
17954
|
+
setTimeout(function () {
|
|
17955
|
+
if (inputRef.current) {
|
|
17956
|
+
var files = inputRef.current.files;
|
|
17957
|
+
|
|
17958
|
+
if (!files.length) {
|
|
17959
|
+
dispatch({
|
|
17960
|
+
type: 'closeDialog'
|
|
17961
|
+
});
|
|
17962
|
+
|
|
17963
|
+
if (typeof onFileDialogCancel === 'function') {
|
|
17964
|
+
onFileDialogCancel();
|
|
17965
|
+
}
|
|
17966
|
+
}
|
|
17967
|
+
}
|
|
17968
|
+
}, 300);
|
|
17969
|
+
}
|
|
17970
|
+
};
|
|
17971
|
+
|
|
17972
|
+
useEffect(function () {
|
|
17973
|
+
window.addEventListener('focus', onWindowFocus, false);
|
|
17974
|
+
return function () {
|
|
17975
|
+
window.removeEventListener('focus', onWindowFocus, false);
|
|
17976
|
+
};
|
|
17977
|
+
}, [inputRef, isFileDialogActive, onFileDialogCancel]); // Cb to open the file dialog when SPACE/ENTER occurs on the dropzone
|
|
17978
|
+
|
|
17979
|
+
var onKeyDownCb = useCallback$1(function (event) {
|
|
17980
|
+
// Ignore keyboard events bubbling up the DOM tree
|
|
17981
|
+
if (!rootRef.current || !rootRef.current.isEqualNode(event.target)) {
|
|
17982
|
+
return;
|
|
17983
|
+
}
|
|
17984
|
+
|
|
17985
|
+
if (event.keyCode === 32 || event.keyCode === 13) {
|
|
17986
|
+
event.preventDefault();
|
|
17987
|
+
openFileDialog();
|
|
17988
|
+
}
|
|
17989
|
+
}, [rootRef, inputRef]); // Update focus state for the dropzone
|
|
17990
|
+
|
|
17991
|
+
var onFocusCb = useCallback$1(function () {
|
|
17992
|
+
dispatch({
|
|
17993
|
+
type: 'focus'
|
|
17994
|
+
});
|
|
17995
|
+
}, []);
|
|
17996
|
+
var onBlurCb = useCallback$1(function () {
|
|
17997
|
+
dispatch({
|
|
17998
|
+
type: 'blur'
|
|
17999
|
+
});
|
|
18000
|
+
}, []); // Cb to open the file dialog when click occurs on the dropzone
|
|
18001
|
+
|
|
18002
|
+
var onClickCb = useCallback$1(function () {
|
|
18003
|
+
if (noClick) {
|
|
18004
|
+
return;
|
|
18005
|
+
} // In IE11/Edge the file-browser dialog is blocking, therefore, use setTimeout()
|
|
18006
|
+
// to ensure React can handle state changes
|
|
18007
|
+
// See: https://github.com/react-dropzone/react-dropzone/issues/450
|
|
18008
|
+
|
|
18009
|
+
|
|
18010
|
+
if (isIeOrEdge()) {
|
|
18011
|
+
setTimeout(openFileDialog, 0);
|
|
18012
|
+
} else {
|
|
18013
|
+
openFileDialog();
|
|
18014
|
+
}
|
|
18015
|
+
}, [inputRef, noClick]);
|
|
18016
|
+
var dragTargetsRef = useRef([]);
|
|
18017
|
+
|
|
18018
|
+
var onDocumentDrop = function onDocumentDrop(event) {
|
|
18019
|
+
if (rootRef.current && rootRef.current.contains(event.target)) {
|
|
18020
|
+
// If we intercepted an event for our instance, let it propagate down to the instance's onDrop handler
|
|
18021
|
+
return;
|
|
18022
|
+
}
|
|
18023
|
+
|
|
18024
|
+
event.preventDefault();
|
|
18025
|
+
dragTargetsRef.current = [];
|
|
18026
|
+
};
|
|
18027
|
+
|
|
18028
|
+
useEffect(function () {
|
|
18029
|
+
if (preventDropOnDocument) {
|
|
18030
|
+
document.addEventListener('dragover', onDocumentDragOver, false);
|
|
18031
|
+
document.addEventListener('drop', onDocumentDrop, false);
|
|
18032
|
+
}
|
|
18033
|
+
|
|
18034
|
+
return function () {
|
|
18035
|
+
if (preventDropOnDocument) {
|
|
18036
|
+
document.removeEventListener('dragover', onDocumentDragOver);
|
|
18037
|
+
document.removeEventListener('drop', onDocumentDrop);
|
|
18038
|
+
}
|
|
18039
|
+
};
|
|
18040
|
+
}, [rootRef, preventDropOnDocument]);
|
|
18041
|
+
var onDragEnterCb = useCallback$1(function (event) {
|
|
18042
|
+
event.preventDefault(); // Persist here because we need the event later after getFilesFromEvent() is done
|
|
18043
|
+
|
|
18044
|
+
event.persist();
|
|
18045
|
+
stopPropagation(event);
|
|
18046
|
+
dragTargetsRef.current = [].concat(_toConsumableArray(dragTargetsRef.current), [event.target]);
|
|
18047
|
+
|
|
18048
|
+
if (isEvtWithFiles(event)) {
|
|
18049
|
+
Promise.resolve(getFilesFromEvent(event)).then(function (draggedFiles) {
|
|
18050
|
+
if (isPropagationStopped(event) && !noDragEventsBubbling) {
|
|
18051
|
+
return;
|
|
18052
|
+
}
|
|
18053
|
+
|
|
18054
|
+
dispatch({
|
|
18055
|
+
draggedFiles: draggedFiles,
|
|
18056
|
+
isDragActive: true,
|
|
18057
|
+
type: 'setDraggedFiles'
|
|
18058
|
+
});
|
|
18059
|
+
|
|
18060
|
+
if (onDragEnter) {
|
|
18061
|
+
onDragEnter(event);
|
|
18062
|
+
}
|
|
18063
|
+
});
|
|
18064
|
+
}
|
|
18065
|
+
}, [getFilesFromEvent, onDragEnter, noDragEventsBubbling]);
|
|
18066
|
+
var onDragOverCb = useCallback$1(function (event) {
|
|
18067
|
+
event.preventDefault();
|
|
18068
|
+
event.persist();
|
|
18069
|
+
stopPropagation(event);
|
|
18070
|
+
|
|
18071
|
+
if (event.dataTransfer) {
|
|
18072
|
+
try {
|
|
18073
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
18074
|
+
} catch (_unused) {}
|
|
18075
|
+
/* eslint-disable-line no-empty */
|
|
18076
|
+
|
|
18077
|
+
}
|
|
18078
|
+
|
|
18079
|
+
if (isEvtWithFiles(event) && onDragOver) {
|
|
18080
|
+
onDragOver(event);
|
|
18081
|
+
}
|
|
18082
|
+
|
|
18083
|
+
return false;
|
|
18084
|
+
}, [onDragOver, noDragEventsBubbling]);
|
|
18085
|
+
var onDragLeaveCb = useCallback$1(function (event) {
|
|
18086
|
+
event.preventDefault();
|
|
18087
|
+
event.persist();
|
|
18088
|
+
stopPropagation(event); // Only deactivate once the dropzone and all children have been left
|
|
18089
|
+
|
|
18090
|
+
var targets = dragTargetsRef.current.filter(function (target) {
|
|
18091
|
+
return rootRef.current && rootRef.current.contains(target);
|
|
18092
|
+
}); // Make sure to remove a target present multiple times only once
|
|
18093
|
+
// (Firefox may fire dragenter/dragleave multiple times on the same element)
|
|
18094
|
+
|
|
18095
|
+
var targetIdx = targets.indexOf(event.target);
|
|
18096
|
+
|
|
18097
|
+
if (targetIdx !== -1) {
|
|
18098
|
+
targets.splice(targetIdx, 1);
|
|
18099
|
+
}
|
|
18100
|
+
|
|
18101
|
+
dragTargetsRef.current = targets;
|
|
18102
|
+
|
|
18103
|
+
if (targets.length > 0) {
|
|
18104
|
+
return;
|
|
18105
|
+
}
|
|
18106
|
+
|
|
18107
|
+
dispatch({
|
|
18108
|
+
isDragActive: false,
|
|
18109
|
+
type: 'setDraggedFiles',
|
|
18110
|
+
draggedFiles: []
|
|
18111
|
+
});
|
|
18112
|
+
|
|
18113
|
+
if (isEvtWithFiles(event) && onDragLeave) {
|
|
18114
|
+
onDragLeave(event);
|
|
18115
|
+
}
|
|
18116
|
+
}, [rootRef, onDragLeave, noDragEventsBubbling]);
|
|
18117
|
+
var onDropCb = useCallback$1(function (event) {
|
|
18118
|
+
event.preventDefault(); // Persist here because we need the event later after getFilesFromEvent() is done
|
|
18119
|
+
|
|
18120
|
+
event.persist();
|
|
18121
|
+
stopPropagation(event);
|
|
18122
|
+
dragTargetsRef.current = [];
|
|
18123
|
+
|
|
18124
|
+
if (isEvtWithFiles(event)) {
|
|
18125
|
+
Promise.resolve(getFilesFromEvent(event)).then(function (files) {
|
|
18126
|
+
if (isPropagationStopped(event) && !noDragEventsBubbling) {
|
|
18127
|
+
return;
|
|
18128
|
+
}
|
|
18129
|
+
|
|
18130
|
+
var acceptedFiles = [];
|
|
18131
|
+
var fileRejections = [];
|
|
18132
|
+
files.forEach(function (file) {
|
|
18133
|
+
var _fileAccepted = fileAccepted(file, accept),
|
|
18134
|
+
_fileAccepted2 = _slicedToArray(_fileAccepted, 2),
|
|
18135
|
+
accepted = _fileAccepted2[0],
|
|
18136
|
+
acceptError = _fileAccepted2[1];
|
|
18137
|
+
|
|
18138
|
+
var _fileMatchSize = fileMatchSize(file, minSize, maxSize),
|
|
18139
|
+
_fileMatchSize2 = _slicedToArray(_fileMatchSize, 2),
|
|
18140
|
+
sizeMatch = _fileMatchSize2[0],
|
|
18141
|
+
sizeError = _fileMatchSize2[1];
|
|
18142
|
+
|
|
18143
|
+
if (accepted && sizeMatch) {
|
|
18144
|
+
acceptedFiles.push(file);
|
|
18145
|
+
} else {
|
|
18146
|
+
var errors = [acceptError, sizeError].filter(function (e) {
|
|
18147
|
+
return e;
|
|
18148
|
+
});
|
|
18149
|
+
fileRejections.push({
|
|
18150
|
+
file: file,
|
|
18151
|
+
errors: errors
|
|
18152
|
+
});
|
|
18153
|
+
}
|
|
18154
|
+
});
|
|
18155
|
+
|
|
18156
|
+
if (!multiple && acceptedFiles.length > 1 || multiple && maxFiles >= 1 && acceptedFiles.length > maxFiles) {
|
|
18157
|
+
// Reject everything and empty accepted files
|
|
18158
|
+
acceptedFiles.forEach(function (file) {
|
|
18159
|
+
fileRejections.push({
|
|
18160
|
+
file: file,
|
|
18161
|
+
errors: [TOO_MANY_FILES_REJECTION]
|
|
18162
|
+
});
|
|
18163
|
+
});
|
|
18164
|
+
acceptedFiles.splice(0);
|
|
18165
|
+
}
|
|
18166
|
+
|
|
18167
|
+
dispatch({
|
|
18168
|
+
acceptedFiles: acceptedFiles,
|
|
18169
|
+
fileRejections: fileRejections,
|
|
18170
|
+
type: 'setFiles'
|
|
18171
|
+
});
|
|
18172
|
+
|
|
18173
|
+
if (onDrop) {
|
|
18174
|
+
onDrop(acceptedFiles, fileRejections, event);
|
|
18175
|
+
}
|
|
18176
|
+
|
|
18177
|
+
if (fileRejections.length > 0 && onDropRejected) {
|
|
18178
|
+
onDropRejected(fileRejections, event);
|
|
18179
|
+
}
|
|
18180
|
+
|
|
18181
|
+
if (acceptedFiles.length > 0 && onDropAccepted) {
|
|
18182
|
+
onDropAccepted(acceptedFiles, event);
|
|
18183
|
+
}
|
|
18184
|
+
});
|
|
18185
|
+
}
|
|
18186
|
+
|
|
18187
|
+
dispatch({
|
|
18188
|
+
type: 'reset'
|
|
18189
|
+
});
|
|
18190
|
+
}, [multiple, accept, minSize, maxSize, maxFiles, getFilesFromEvent, onDrop, onDropAccepted, onDropRejected, noDragEventsBubbling]);
|
|
18191
|
+
|
|
18192
|
+
var composeHandler = function composeHandler(fn) {
|
|
18193
|
+
return disabled ? null : fn;
|
|
18194
|
+
};
|
|
18195
|
+
|
|
18196
|
+
var composeKeyboardHandler = function composeKeyboardHandler(fn) {
|
|
18197
|
+
return noKeyboard ? null : composeHandler(fn);
|
|
18198
|
+
};
|
|
18199
|
+
|
|
18200
|
+
var composeDragHandler = function composeDragHandler(fn) {
|
|
18201
|
+
return noDrag ? null : composeHandler(fn);
|
|
18202
|
+
};
|
|
18203
|
+
|
|
18204
|
+
var stopPropagation = function stopPropagation(event) {
|
|
18205
|
+
if (noDragEventsBubbling) {
|
|
18206
|
+
event.stopPropagation();
|
|
18207
|
+
}
|
|
18208
|
+
};
|
|
18209
|
+
|
|
18210
|
+
var getRootProps = useMemo$1(function () {
|
|
18211
|
+
return function () {
|
|
18212
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
18213
|
+
_ref2$refKey = _ref2.refKey,
|
|
18214
|
+
refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
|
|
18215
|
+
onKeyDown = _ref2.onKeyDown,
|
|
18216
|
+
onFocus = _ref2.onFocus,
|
|
18217
|
+
onBlur = _ref2.onBlur,
|
|
18218
|
+
onClick = _ref2.onClick,
|
|
18219
|
+
onDragEnter = _ref2.onDragEnter,
|
|
18220
|
+
onDragOver = _ref2.onDragOver,
|
|
18221
|
+
onDragLeave = _ref2.onDragLeave,
|
|
18222
|
+
onDrop = _ref2.onDrop,
|
|
18223
|
+
rest = _objectWithoutProperties(_ref2, ["refKey", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"]);
|
|
18224
|
+
|
|
18225
|
+
return _objectSpread$3(_objectSpread$3(_defineProperty({
|
|
18226
|
+
onKeyDown: composeKeyboardHandler(composeEventHandlers(onKeyDown, onKeyDownCb)),
|
|
18227
|
+
onFocus: composeKeyboardHandler(composeEventHandlers(onFocus, onFocusCb)),
|
|
18228
|
+
onBlur: composeKeyboardHandler(composeEventHandlers(onBlur, onBlurCb)),
|
|
18229
|
+
onClick: composeHandler(composeEventHandlers(onClick, onClickCb)),
|
|
18230
|
+
onDragEnter: composeDragHandler(composeEventHandlers(onDragEnter, onDragEnterCb)),
|
|
18231
|
+
onDragOver: composeDragHandler(composeEventHandlers(onDragOver, onDragOverCb)),
|
|
18232
|
+
onDragLeave: composeDragHandler(composeEventHandlers(onDragLeave, onDragLeaveCb)),
|
|
18233
|
+
onDrop: composeDragHandler(composeEventHandlers(onDrop, onDropCb))
|
|
18234
|
+
}, refKey, rootRef), !disabled && !noKeyboard ? {
|
|
18235
|
+
tabIndex: 0
|
|
18236
|
+
} : {}), rest);
|
|
18237
|
+
};
|
|
18238
|
+
}, [rootRef, onKeyDownCb, onFocusCb, onBlurCb, onClickCb, onDragEnterCb, onDragOverCb, onDragLeaveCb, onDropCb, noKeyboard, noDrag, disabled]);
|
|
18239
|
+
var onInputElementClick = useCallback$1(function (event) {
|
|
18240
|
+
event.stopPropagation();
|
|
18241
|
+
}, []);
|
|
18242
|
+
var getInputProps = useMemo$1(function () {
|
|
18243
|
+
return function () {
|
|
18244
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
18245
|
+
_ref3$refKey = _ref3.refKey,
|
|
18246
|
+
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
18247
|
+
onChange = _ref3.onChange,
|
|
18248
|
+
onClick = _ref3.onClick,
|
|
18249
|
+
rest = _objectWithoutProperties(_ref3, ["refKey", "onChange", "onClick"]);
|
|
18250
|
+
|
|
18251
|
+
var inputProps = _defineProperty({
|
|
18252
|
+
accept: accept,
|
|
18253
|
+
multiple: multiple,
|
|
18254
|
+
type: 'file',
|
|
18255
|
+
style: {
|
|
18256
|
+
display: 'none'
|
|
18257
|
+
},
|
|
18258
|
+
onChange: composeHandler(composeEventHandlers(onChange, onDropCb)),
|
|
18259
|
+
onClick: composeHandler(composeEventHandlers(onClick, onInputElementClick)),
|
|
18260
|
+
autoComplete: 'off',
|
|
18261
|
+
tabIndex: -1
|
|
18262
|
+
}, refKey, inputRef);
|
|
18263
|
+
|
|
18264
|
+
return _objectSpread$3(_objectSpread$3({}, inputProps), rest);
|
|
18265
|
+
};
|
|
18266
|
+
}, [inputRef, accept, multiple, onDropCb, disabled]);
|
|
18267
|
+
var fileCount = draggedFiles.length;
|
|
18268
|
+
var isDragAccept = fileCount > 0 && allFilesAccepted({
|
|
18269
|
+
files: draggedFiles,
|
|
18270
|
+
accept: accept,
|
|
18271
|
+
minSize: minSize,
|
|
18272
|
+
maxSize: maxSize,
|
|
18273
|
+
multiple: multiple,
|
|
18274
|
+
maxFiles: maxFiles
|
|
18275
|
+
});
|
|
18276
|
+
var isDragReject = fileCount > 0 && !isDragAccept;
|
|
18277
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18278
|
+
isDragAccept: isDragAccept,
|
|
18279
|
+
isDragReject: isDragReject,
|
|
18280
|
+
isFocused: isFocused && !disabled,
|
|
18281
|
+
getRootProps: getRootProps,
|
|
18282
|
+
getInputProps: getInputProps,
|
|
18283
|
+
rootRef: rootRef,
|
|
18284
|
+
inputRef: inputRef,
|
|
18285
|
+
open: composeHandler(openFileDialog)
|
|
18286
|
+
});
|
|
18287
|
+
}
|
|
18288
|
+
|
|
18289
|
+
function reducer(state, action) {
|
|
18290
|
+
/* istanbul ignore next */
|
|
18291
|
+
switch (action.type) {
|
|
18292
|
+
case 'focus':
|
|
18293
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18294
|
+
isFocused: true
|
|
18295
|
+
});
|
|
18296
|
+
|
|
18297
|
+
case 'blur':
|
|
18298
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18299
|
+
isFocused: false
|
|
18300
|
+
});
|
|
18301
|
+
|
|
18302
|
+
case 'openDialog':
|
|
18303
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18304
|
+
isFileDialogActive: true
|
|
18305
|
+
});
|
|
18306
|
+
|
|
18307
|
+
case 'closeDialog':
|
|
18308
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18309
|
+
isFileDialogActive: false
|
|
18310
|
+
});
|
|
18311
|
+
|
|
18312
|
+
case 'setDraggedFiles':
|
|
18313
|
+
/* eslint no-case-declarations: 0 */
|
|
18314
|
+
var isDragActive = action.isDragActive,
|
|
18315
|
+
draggedFiles = action.draggedFiles;
|
|
18316
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18317
|
+
draggedFiles: draggedFiles,
|
|
18318
|
+
isDragActive: isDragActive
|
|
18319
|
+
});
|
|
18320
|
+
|
|
18321
|
+
case 'setFiles':
|
|
18322
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18323
|
+
acceptedFiles: action.acceptedFiles,
|
|
18324
|
+
fileRejections: action.fileRejections
|
|
18325
|
+
});
|
|
18326
|
+
|
|
18327
|
+
case 'reset':
|
|
18328
|
+
return _objectSpread$3(_objectSpread$3({}, state), {}, {
|
|
18329
|
+
isFileDialogActive: false,
|
|
18330
|
+
isDragActive: false,
|
|
18331
|
+
draggedFiles: [],
|
|
18332
|
+
acceptedFiles: [],
|
|
18333
|
+
fileRejections: []
|
|
18334
|
+
});
|
|
18335
|
+
|
|
18336
|
+
default:
|
|
18337
|
+
return state;
|
|
18338
|
+
}
|
|
18339
|
+
}
|
|
18340
|
+
|
|
18341
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18342
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18343
|
+
var useFileUpload = function useFileUpload(_ref) {
|
|
18344
|
+
var disabled = _ref.disabled,
|
|
18345
|
+
accept = _ref.accept,
|
|
18346
|
+
multiple = _ref.multiple,
|
|
18347
|
+
name = _ref.name,
|
|
18348
|
+
maxFileSize = _ref.maxFileSize;
|
|
18349
|
+
var _useState = useState({}),
|
|
18350
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
18351
|
+
uploadProgress = _useState2[0],
|
|
18352
|
+
setUploadProgress = _useState2[1];
|
|
18353
|
+
var _useState3 = useState(""),
|
|
18354
|
+
_useState4 = _slicedToArray$3(_useState3, 2),
|
|
18355
|
+
uploadError = _useState4[0],
|
|
18356
|
+
setUploadError = _useState4[1];
|
|
18357
|
+
var _useField = useField(name),
|
|
18358
|
+
_useField2 = _slicedToArray$3(_useField, 3);
|
|
18359
|
+
_useField2[0];
|
|
18360
|
+
var value = _useField2[1].value,
|
|
18361
|
+
_useField2$ = _useField2[2],
|
|
18362
|
+
setValue = _useField2$.setValue,
|
|
18363
|
+
setError = _useField2$.setError,
|
|
18364
|
+
setTouched = _useField2$.setTouched;
|
|
18365
|
+
var filesRef = useRef(value === null || value === void 0 ? void 0 : value.files);
|
|
18366
|
+
filesRef.current = value === null || value === void 0 ? void 0 : value.files;
|
|
18367
|
+
var cancel = useCallback$1(function (index) {
|
|
18368
|
+
return function () {
|
|
18369
|
+
var _value$files;
|
|
18370
|
+
setUploadProgress(assoc(value.files[index].name, null));
|
|
18371
|
+
var newFiles = (_value$files = value.files) === null || _value$files === void 0 ? void 0 : _value$files.filter(function (_, idx) {
|
|
18372
|
+
return idx !== index;
|
|
18373
|
+
});
|
|
18374
|
+
setValue({
|
|
18375
|
+
files: newFiles
|
|
18376
|
+
});
|
|
18377
|
+
};
|
|
18378
|
+
}, [value]);
|
|
18379
|
+
useEffect(function () {
|
|
18380
|
+
uploadError && setError(uploadError);
|
|
18381
|
+
}, [uploadError]);
|
|
18382
|
+
var onDropAccepted = /*#__PURE__*/function () {
|
|
18383
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(acceptedFiles) {
|
|
18384
|
+
var initialFiles, updatedFiles, newFiles;
|
|
18385
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18386
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18387
|
+
case 0:
|
|
18388
|
+
setTouched(false);
|
|
18389
|
+
setUploadError("");
|
|
18390
|
+
initialFiles = acceptedFiles.map(function (file) {
|
|
18391
|
+
return {
|
|
18392
|
+
name: file.name,
|
|
18393
|
+
size: file.size
|
|
18394
|
+
};
|
|
18395
|
+
});
|
|
18396
|
+
updatedFiles = multiple ? [].concat(_toConsumableArray$1(value.files || []), _toConsumableArray$1(initialFiles)) : initialFiles;
|
|
18397
|
+
setValue({
|
|
18398
|
+
files: updatedFiles
|
|
18399
|
+
});
|
|
18400
|
+
_context.next = 7;
|
|
18401
|
+
return new Promise(function (resolve) {
|
|
18402
|
+
var files = [];
|
|
18403
|
+
acceptedFiles.forEach(function (file) {
|
|
18404
|
+
setUploadProgress(assoc(file.name, 0));
|
|
18405
|
+
var upload = new DirectUpload(file, DIRECT_UPLOAD_URL, {
|
|
18406
|
+
directUploadWillStoreFileWithXHR: function directUploadWillStoreFileWithXHR(xhr) {
|
|
18407
|
+
xhr.upload.addEventListener("progress", function (event) {
|
|
18408
|
+
var percentComplete = Math.round(event.loaded / event.total * 100);
|
|
18409
|
+
setUploadProgress(assoc(file.name, percentComplete));
|
|
18410
|
+
});
|
|
18411
|
+
xhr.upload.addEventListener("load", function () {
|
|
18412
|
+
setUploadProgress(assoc(file.name, undefined));
|
|
18413
|
+
});
|
|
18414
|
+
}
|
|
18415
|
+
});
|
|
18416
|
+
upload.create(function (error, blob) {
|
|
18417
|
+
if (error) {
|
|
18418
|
+
return setUploadError(error);
|
|
18419
|
+
}
|
|
18420
|
+
files.push({
|
|
18421
|
+
url: blob.blob_url,
|
|
18422
|
+
name: blob.filename,
|
|
18423
|
+
signedId: blob.signed_id
|
|
18424
|
+
});
|
|
18425
|
+
var isUploadCompleted = multiple ? acceptedFiles.length === files.length : files.length === 1;
|
|
18426
|
+
if (isUploadCompleted) {
|
|
18427
|
+
return resolve(files);
|
|
18428
|
+
}
|
|
18429
|
+
return "";
|
|
18430
|
+
});
|
|
18431
|
+
});
|
|
18432
|
+
return files;
|
|
18433
|
+
});
|
|
18434
|
+
case 7:
|
|
18435
|
+
newFiles = _context.sent;
|
|
18436
|
+
if (multiple) {
|
|
18437
|
+
setValue({
|
|
18438
|
+
files: filesRef.current.map(function (file) {
|
|
18439
|
+
var uploadedFile = findBy({
|
|
18440
|
+
name: file.name
|
|
18441
|
+
}, newFiles);
|
|
18442
|
+
return _objectSpread$2(_objectSpread$2({}, file), uploadedFile);
|
|
18443
|
+
})
|
|
18444
|
+
});
|
|
18445
|
+
} else {
|
|
18446
|
+
setValue({
|
|
18447
|
+
files: newFiles
|
|
18448
|
+
});
|
|
18449
|
+
}
|
|
18450
|
+
case 9:
|
|
18451
|
+
case "end":
|
|
18452
|
+
return _context.stop();
|
|
18453
|
+
}
|
|
18454
|
+
}, _callee);
|
|
18455
|
+
}));
|
|
18456
|
+
return function onDropAccepted(_x) {
|
|
18457
|
+
return _ref2.apply(this, arguments);
|
|
18458
|
+
};
|
|
18459
|
+
}();
|
|
18460
|
+
var onDropRejected = function onDropRejected(fileRejections) {
|
|
18461
|
+
fileRejections.forEach(function (fileObject) {
|
|
18462
|
+
setTouched(true);
|
|
18463
|
+
setUploadError(renderErrorMessage(fileObject, maxFileSize, multiple));
|
|
18464
|
+
});
|
|
18465
|
+
};
|
|
18466
|
+
var _useDropzone = useDropzone({
|
|
18467
|
+
disabled: disabled,
|
|
18468
|
+
accept: accept,
|
|
18469
|
+
multiple: multiple,
|
|
18470
|
+
onDropAccepted: onDropAccepted,
|
|
18471
|
+
onDropRejected: onDropRejected,
|
|
18472
|
+
maxSize: convertMbToBytes(maxFileSize)
|
|
18473
|
+
}),
|
|
18474
|
+
getRootProps = _useDropzone.getRootProps,
|
|
18475
|
+
getInputProps = _useDropzone.getInputProps,
|
|
18476
|
+
isDragActive = _useDropzone.isDragActive,
|
|
18477
|
+
fileRejections = _useDropzone.fileRejections;
|
|
18478
|
+
return {
|
|
18479
|
+
files: value === null || value === void 0 ? void 0 : value.files,
|
|
18480
|
+
progress: uploadProgress,
|
|
18481
|
+
cancel: cancel,
|
|
18482
|
+
getRootProps: getRootProps,
|
|
18483
|
+
getInputProps: getInputProps,
|
|
18484
|
+
isDragActive: isDragActive,
|
|
18485
|
+
fileRejections: fileRejections
|
|
18486
|
+
};
|
|
18487
|
+
};
|
|
18488
|
+
|
|
18489
|
+
var _path$1;
|
|
18490
|
+
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
18491
|
+
const SvgFileUpload = props => /*#__PURE__*/React$2.createElement("svg", _extends$1({
|
|
18492
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
18493
|
+
width: 48,
|
|
18494
|
+
height: 36,
|
|
18495
|
+
fill: "none"
|
|
18496
|
+
}, props), _path$1 || (_path$1 = /*#__PURE__*/React$2.createElement("path", {
|
|
18497
|
+
fill: "currentColor",
|
|
18498
|
+
d: "M32 26h-6v10h-4V26h-6l8-8 8 8zm6.958-11.816C38.534 6.282 32.012 0 24 0S9.466 6.282 9.042 14.184C3.902 15.11 0 19.596 0 25c0 6.074 4.926 11 11 11h7v-4h-7c-3.86 0-7-3.14-7-7 0-5.594 4.958-7.666 8.866-7.44C12.532 9.124 17.282 4 24 4c6.906 0 11.782 5.594 11.134 13.56C38.624 17.468 44 19.062 44 25c0 3.86-3.14 7-7 7h-7v4h7c6.074 0 11-4.926 11-11 0-5.404-3.902-9.89-9.042-10.816z"
|
|
18499
|
+
})));
|
|
18500
|
+
|
|
18501
|
+
var DropZone = function DropZone(_ref) {
|
|
18502
|
+
var isDragActive = _ref.isDragActive,
|
|
18503
|
+
getRootProps = _ref.getRootProps,
|
|
18504
|
+
getInputProps = _ref.getInputProps,
|
|
18505
|
+
multipleFilesAllowed = _ref.multipleFilesAllowed,
|
|
18506
|
+
_ref$hasFileSizeLimit = _ref.hasFileSizeLimit,
|
|
18507
|
+
hasFileSizeLimit = _ref$hasFileSizeLimit === void 0 ? true : _ref$hasFileSizeLimit,
|
|
18508
|
+
maxFileSize = _ref.maxFileSize,
|
|
18509
|
+
allowedFileTypes = _ref.allowedFileTypes;
|
|
18510
|
+
var _useTranslation = useTranslation(),
|
|
18511
|
+
t = _useTranslation.t;
|
|
18512
|
+
var shouldShowFileSizeLimit = hasFileSizeLimit && maxFileSize;
|
|
18513
|
+
return /*#__PURE__*/React__default.createElement("div", getRootProps({
|
|
18514
|
+
className: classnames(["neeto-form-engine-file-upload__dropzone"], {
|
|
18515
|
+
"neeto-form-engine-file-upload__dropzone--drag-active": isDragActive
|
|
18516
|
+
})
|
|
18517
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
18518
|
+
className: "neeto-form-engine-file-upload__dropzone-inner",
|
|
18519
|
+
"data-cy": "file-upload-body"
|
|
18520
|
+
}, /*#__PURE__*/React__default.createElement(SvgFileUpload, {
|
|
18521
|
+
className: "neeto-form-engine-file-upload__upload-icon"
|
|
18522
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
18523
|
+
className: "neeto-form-engine-file-upload__dropzone-content"
|
|
18524
|
+
}, /*#__PURE__*/React__default.createElement("label", {
|
|
18525
|
+
className: "neeto-form-engine-file-upload__upload-label",
|
|
18526
|
+
htmlFor: "file-upload"
|
|
18527
|
+
}, /*#__PURE__*/React__default.createElement(Trans, {
|
|
18528
|
+
i18nKey: "neetoForm.fileUpload.dropzone.chooseOrDragFile",
|
|
18529
|
+
components: {
|
|
18530
|
+
typography: /*#__PURE__*/React__default.createElement(Typography, {
|
|
18531
|
+
component: "span",
|
|
18532
|
+
weight: "semibold"
|
|
18533
|
+
}),
|
|
18534
|
+
span: /*#__PURE__*/React__default.createElement(Typography, {
|
|
18535
|
+
component: "span",
|
|
18536
|
+
weight: "normal"
|
|
18537
|
+
})
|
|
18538
|
+
}
|
|
18539
|
+
}), /*#__PURE__*/React__default.createElement("input", _extends$8({}, getInputProps(), {
|
|
18540
|
+
"data-cy": "file-browse-button"
|
|
18541
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
18542
|
+
className: "neeto-form-engine-file-upload__dropzone-helper-block"
|
|
18543
|
+
}, !multipleFilesAllowed && /*#__PURE__*/React__default.createElement(Typography, {
|
|
18544
|
+
className: "neeto-form-engine-file-upload__dropzone-helper-text",
|
|
18545
|
+
"data-cy": "upload-only-one-file-text",
|
|
18546
|
+
style: "body3"
|
|
18547
|
+
}, t("neetoForm.fileUpload.dropzone.oneFileAllowed")), shouldShowFileSizeLimit && /*#__PURE__*/React__default.createElement(Typography, {
|
|
18548
|
+
className: "neeto-form-engine-file-upload__dropzone-helper-text",
|
|
18549
|
+
"data-cy": "maximum-allowed-size-text",
|
|
18550
|
+
style: "body3"
|
|
18551
|
+
}, t("neetoForm.fileUpload.dropzone.maxFileSize", {
|
|
18552
|
+
size: maxFileSize,
|
|
18553
|
+
unit: t("neetoForm.fileUpload.mb")
|
|
18554
|
+
})), allowedFileTypes && /*#__PURE__*/React__default.createElement(Typography, {
|
|
18555
|
+
className: "neeto-form-engine-file-upload__dropzone-helper-text",
|
|
18556
|
+
"data-cy": "allowed-files-types-text",
|
|
18557
|
+
style: "body3"
|
|
18558
|
+
}, t("neetoForm.fileUpload.dropzone.allowedFileTypes", {
|
|
18559
|
+
types: allowedFileTypes
|
|
18560
|
+
}))))));
|
|
18561
|
+
};
|
|
18562
|
+
|
|
17202
18563
|
var createDefinition = function (propNames) { return ({
|
|
17203
18564
|
isEnabled: function (props) { return propNames.some(function (name) { return !!props[name]; }); },
|
|
17204
18565
|
}); };
|
|
@@ -24668,7 +26029,7 @@ var FileUploadField = function FileUploadField(_ref) {
|
|
|
24668
26029
|
customValidator: customValidator
|
|
24669
26030
|
})
|
|
24670
26031
|
}),
|
|
24671
|
-
_useField2 = _slicedToArray$
|
|
26032
|
+
_useField2 = _slicedToArray$3(_useField, 2);
|
|
24672
26033
|
_useField2[0];
|
|
24673
26034
|
var _useField2$ = _useField2[1],
|
|
24674
26035
|
touched = _useField2$.touched,
|
|
@@ -24841,7 +26202,7 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
|
|
|
24841
26202
|
isRequired: isRequired
|
|
24842
26203
|
})
|
|
24843
26204
|
}),
|
|
24844
|
-
_useField2 = _slicedToArray$
|
|
26205
|
+
_useField2 = _slicedToArray$3(_useField, 3),
|
|
24845
26206
|
value = _useField2[0].value,
|
|
24846
26207
|
_useField2$ = _useField2[1],
|
|
24847
26208
|
touched = _useField2$.touched,
|
|
@@ -24873,7 +26234,7 @@ var Rating = function Rating(_ref) {
|
|
|
24873
26234
|
averageRatingLabel = _ref.averageRatingLabel,
|
|
24874
26235
|
highestRatingLabel = _ref.highestRatingLabel,
|
|
24875
26236
|
value = _ref.value,
|
|
24876
|
-
other = _objectWithoutProperties(_ref, _excluded$3);
|
|
26237
|
+
other = _objectWithoutProperties$1(_ref, _excluded$3);
|
|
24877
26238
|
var handleClick = function handleClick(e) {
|
|
24878
26239
|
return e.currentTarget.nextElementSibling.click();
|
|
24879
26240
|
};
|
|
@@ -25008,7 +26369,7 @@ var RatingButton = function RatingButton(_ref) {
|
|
|
25008
26369
|
label = _ref.label,
|
|
25009
26370
|
rating = _ref.rating,
|
|
25010
26371
|
count = _ref.count,
|
|
25011
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
26372
|
+
otherProps = _objectWithoutProperties$1(_ref, _excluded$2);
|
|
25012
26373
|
var handleClick = function handleClick(e) {
|
|
25013
26374
|
return e.currentTarget.nextElementSibling.click();
|
|
25014
26375
|
};
|
|
@@ -25042,7 +26403,7 @@ var StarRating = function StarRating(_ref) {
|
|
|
25042
26403
|
count = _ref.count,
|
|
25043
26404
|
shape = _ref.shape,
|
|
25044
26405
|
error = _ref.error,
|
|
25045
|
-
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
26406
|
+
props = _objectWithoutProperties$1(_ref, _excluded$1);
|
|
25046
26407
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
25047
26408
|
className: "neeto-form-engine-input__wrapper neeto-form-engine-star-rating"
|
|
25048
26409
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -25102,7 +26463,7 @@ var Terms = function Terms(_ref, ref) {
|
|
|
25102
26463
|
label = _ref.label,
|
|
25103
26464
|
error = _ref.error,
|
|
25104
26465
|
value = _ref.value,
|
|
25105
|
-
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
26466
|
+
otherProps = _objectWithoutProperties$1(_ref, _excluded);
|
|
25106
26467
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
25107
26468
|
className: "neeto-form-engine-terms"
|
|
25108
26469
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -25156,7 +26517,7 @@ var TermsField = function TermsField(_ref) {
|
|
|
25156
26517
|
};
|
|
25157
26518
|
|
|
25158
26519
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25159
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
26520
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25160
26521
|
var TextField = function TextField(_ref) {
|
|
25161
26522
|
var _otherProps$onChange;
|
|
25162
26523
|
var question = _ref.question,
|
|
@@ -25185,7 +26546,7 @@ var TextField = function TextField(_ref) {
|
|
|
25185
26546
|
customValidator: customValidator
|
|
25186
26547
|
})
|
|
25187
26548
|
}),
|
|
25188
|
-
_useField2 = _slicedToArray$
|
|
26549
|
+
_useField2 = _slicedToArray$3(_useField, 3),
|
|
25189
26550
|
field = _useField2[0],
|
|
25190
26551
|
_useField2$ = _useField2[1],
|
|
25191
26552
|
touched = _useField2$.touched,
|
|
@@ -25215,12 +26576,12 @@ var TextField = function TextField(_ref) {
|
|
|
25215
26576
|
};
|
|
25216
26577
|
|
|
25217
26578
|
var _QUESTION_TO_COMPONEN;
|
|
25218
|
-
var QUESTION_TO_COMPONENT_MAP = (_QUESTION_TO_COMPONEN = {}, _defineProperty$
|
|
26579
|
+
var QUESTION_TO_COMPONENT_MAP = (_QUESTION_TO_COMPONEN = {}, _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.TEXT.value, TextField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.NAME.value, TextField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.EMAIL.value, TextField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.INTEGER.value, TextField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.DECIMAL.value, TextField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.PHONE.value, PhoneNumberField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.QUESTION.value, TextField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.TEXTAREA.value, TextField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.CHECKBOX.value, OptionsField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.RADIO.value, OptionsField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.DROPDOWN.value, OptionsField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.RATING.value, RatingField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.PARAGRAPH.value, function (_ref) {
|
|
25219
26580
|
var question = _ref.question;
|
|
25220
26581
|
return /*#__PURE__*/React__default.createElement(EditorContent, {
|
|
25221
26582
|
content: question.label
|
|
25222
26583
|
});
|
|
25223
|
-
}), _defineProperty$
|
|
26584
|
+
}), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.TERMS.value, TermsField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.DATE.value, DateField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.STAR_RATING.value, StarRatingField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.ADDITIONAL_GUESTS.value, MultipleEmailInput), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.RICH_TEXT.value, RichTextEditor), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.CONDITION.value, ConditionField), _defineProperty$7(_QUESTION_TO_COMPONEN, QUESTION_KIND.FILE_UPLOAD.value, FileUploadField), _QUESTION_TO_COMPONEN);
|
|
25224
26585
|
|
|
25225
26586
|
var getFieldComponent = function getFieldComponent(_ref) {
|
|
25226
26587
|
var kind = _ref.kind;
|
|
@@ -25278,7 +26639,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
25278
26639
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25279
26640
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
25280
26641
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25281
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
26642
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty$7(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25282
26643
|
var ExternalForm = function ExternalForm(_ref) {
|
|
25283
26644
|
var _formikInnerRef$curre;
|
|
25284
26645
|
var _ref$preview = _ref.preview,
|
|
@@ -25322,20 +26683,20 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
25322
26683
|
_ref$autoCompleteKind = _ref.autoCompleteKinds,
|
|
25323
26684
|
autoCompleteKinds = _ref$autoCompleteKind === void 0 ? [] : _ref$autoCompleteKind;
|
|
25324
26685
|
var _useState = useState(false),
|
|
25325
|
-
_useState2 = _slicedToArray$
|
|
26686
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
25326
26687
|
isSubmitted = _useState2[0],
|
|
25327
26688
|
setIsSubmitted = _useState2[1];
|
|
25328
26689
|
var _useState3 = useState(false),
|
|
25329
|
-
_useState4 = _slicedToArray$
|
|
26690
|
+
_useState4 = _slicedToArray$3(_useState3, 2),
|
|
25330
26691
|
showSuccess = _useState4[0],
|
|
25331
26692
|
setShowSuccess = _useState4[1];
|
|
25332
26693
|
var _useState5 = useState(getWithExpiry("".concat(formId, "/values"))),
|
|
25333
|
-
_useState6 = _slicedToArray$
|
|
26694
|
+
_useState6 = _slicedToArray$3(_useState5, 2),
|
|
25334
26695
|
localValues = _useState6[0],
|
|
25335
26696
|
setLocalValues = _useState6[1];
|
|
25336
26697
|
var isMounted = useIsMounted();
|
|
25337
26698
|
var _useState7 = useState(null),
|
|
25338
|
-
_useState8 = _slicedToArray$
|
|
26699
|
+
_useState8 = _slicedToArray$3(_useState7, 2),
|
|
25339
26700
|
error = _useState8[0],
|
|
25340
26701
|
setError = _useState8[1];
|
|
25341
26702
|
var formRef = useRef();
|
|
@@ -25582,7 +26943,7 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
25582
26943
|
}, /*#__PURE__*/React__default.createElement(Form$1, _extends$8({
|
|
25583
26944
|
noValidate: true,
|
|
25584
26945
|
ref: mergeRefs(formRef, keyPressRef),
|
|
25585
|
-
className: classnames("neeto-form-engine-form relative space-y-4", _defineProperty$
|
|
26946
|
+
className: classnames("neeto-form-engine-form relative space-y-4", _defineProperty$7({}, className, className)),
|
|
25586
26947
|
onChange: function onChange(event) {
|
|
25587
26948
|
if (isEmpty(errors)) return;
|
|
25588
26949
|
setFieldError(event.target.name, "");
|
|
@@ -28268,7 +29629,7 @@ var Submission = function Submission(_ref3) {
|
|
|
28268
29629
|
}, /*#__PURE__*/React__default.createElement(PageLoader, null));
|
|
28269
29630
|
}
|
|
28270
29631
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
28271
|
-
className: classnames("mx-auto flex h-full w-full flex-col items-start", _defineProperty$
|
|
29632
|
+
className: classnames("mx-auto flex h-full w-full flex-col items-start", _defineProperty$7({}, className, className))
|
|
28272
29633
|
}, responses.map(function (_ref4) {
|
|
28273
29634
|
var kind = _ref4.kind,
|
|
28274
29635
|
label = _ref4.label,
|