@widergy/energy-ui 1.136.0 → 1.136.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EnergyThemeProvider/index.js +13 -36
- package/dist/components/Loading/constants.js +1 -2
- package/dist/components/Loading/index.js +13 -12
- package/dist/components/Loading/theme.js +9 -11
- package/dist/components/UTAlert/AlertHandler.js +75 -101
- package/dist/components/UTAlert/index.js +65 -87
- package/dist/components/UTAlert/theme.js +29 -31
- package/dist/components/UTAttachment/components/Preview/index.js +8 -9
- package/dist/components/UTAttachment/constants.js +7 -13
- package/dist/components/UTAttachment/index.js +153 -232
- package/dist/components/UTAttachment/layout.js +25 -26
- package/dist/components/UTAttachment/theme.js +12 -14
- package/dist/components/UTAttachment/utils.js +34 -117
- package/dist/components/UTAutocomplete/components/ListBox/index.js +13 -21
- package/dist/components/UTAutocomplete/components/ListBox/utils.js +9 -11
- package/dist/components/UTAutocomplete/constants.js +12 -23
- package/dist/components/UTAutocomplete/index.js +45 -66
- package/dist/components/UTAutocomplete/theme.js +3 -3
- package/dist/components/UTAvatar/constants.js +2 -3
- package/dist/components/UTAvatar/index.js +15 -12
- package/dist/components/UTBarChart/components/Bars/components/Bar/components/Rect/index.js +22 -22
- package/dist/components/UTBarChart/components/Bars/components/Bar/constants.js +1 -1
- package/dist/components/UTBarChart/components/Bars/components/Bar/index.js +21 -22
- package/dist/components/UTBarChart/components/Bars/constants.js +3 -6
- package/dist/components/UTBarChart/components/Bars/index.js +70 -80
- package/dist/components/UTBarChart/components/Legend/constants.js +12 -18
- package/dist/components/UTBarChart/components/Legend/index.js +73 -91
- package/dist/components/UTBarChart/components/Legend/utils.js +1 -5
- package/dist/components/UTBarChart/components/Levels/index.js +16 -14
- package/dist/components/UTBarChart/components/Levels/utils.js +25 -27
- package/dist/components/UTBarChart/components/LinearPlot/constants.js +3 -5
- package/dist/components/UTBarChart/components/LinearPlot/index.js +25 -20
- package/dist/components/UTBarChart/components/LinearPlot/utils.js +37 -39
- package/dist/components/UTBarChart/components/Pagination/constants.js +1 -2
- package/dist/components/UTBarChart/components/Pagination/index.js +20 -24
- package/dist/components/UTBarChart/components/XAxis/components/AxisElement/index.js +21 -32
- package/dist/components/UTBarChart/components/XAxis/components/Decoration/constants.js +2 -4
- package/dist/components/UTBarChart/components/XAxis/components/Decoration/index.js +20 -19
- package/dist/components/UTBarChart/components/XAxis/constants.js +1 -2
- package/dist/components/UTBarChart/components/XAxis/index.js +54 -65
- package/dist/components/UTBarChart/components/YAxis/AxisElement/index.js +12 -11
- package/dist/components/UTBarChart/components/YAxis/constants.js +1 -2
- package/dist/components/UTBarChart/components/YAxis/index.js +24 -31
- package/dist/components/UTBarChart/components/YAxis/utils.js +4 -6
- package/dist/components/UTBarChart/constants.js +4 -8
- package/dist/components/UTBarChart/hooks/use-dynamic-margins.js +23 -40
- package/dist/components/UTBarChart/index.js +148 -162
- package/dist/components/UTBarChart/theme.js +102 -104
- package/dist/components/UTBarChart/types.js +9 -17
- package/dist/components/UTBarChart/utils.js +107 -111
- package/dist/components/UTBreadcrumbs/constants.js +3 -6
- package/dist/components/UTBreadcrumbs/index.js +79 -106
- package/dist/components/UTBreadcrumbs/theme.js +21 -23
- package/dist/components/UTButton/index.js +48 -71
- package/dist/components/UTButton/theme.js +172 -174
- package/dist/components/UTCBUInput/index.js +36 -40
- package/dist/components/UTCBUInput/theme.js +5 -7
- package/dist/components/UTCaptcha/index.js +19 -45
- package/dist/components/UTCard/components/UTCardFooter/index.js +16 -17
- package/dist/components/UTCard/index.js +87 -122
- package/dist/components/UTCard/theme.js +8 -11
- package/dist/components/UTCard/types.js +2 -3
- package/dist/components/UTCarousel/components/Button/index.js +13 -13
- package/dist/components/UTCarousel/components/Legend/index.js +14 -16
- package/dist/components/UTCarousel/components/Slider/component/Slide/index.js +16 -16
- package/dist/components/UTCarousel/components/Slider/constants.js +5 -10
- package/dist/components/UTCarousel/components/Slider/index.js +181 -252
- package/dist/components/UTCarousel/components/Slider/layout.js +66 -93
- package/dist/components/UTCarousel/index.js +14 -15
- package/dist/components/UTCarousel/theme.js +35 -37
- package/dist/components/UTCheckList/constants.js +1 -2
- package/dist/components/UTCheckList/index.js +72 -91
- package/dist/components/UTCheckList/theme.js +66 -70
- package/dist/components/UTCheckbox/constants.js +3 -6
- package/dist/components/UTCheckbox/index.js +31 -42
- package/dist/components/UTCheckbox/theme.js +49 -53
- package/dist/components/UTConsumptionBar/components/ConsumptionBarIndicator/index.js +9 -9
- package/dist/components/UTConsumptionBar/constants.js +3 -6
- package/dist/components/UTConsumptionBar/index.js +49 -74
- package/dist/components/UTCuit/index.js +109 -133
- package/dist/components/UTCuit/theme.js +47 -49
- package/dist/components/UTDatePicker/components/Day/constants.js +1 -2
- package/dist/components/UTDatePicker/components/Day/index.js +12 -12
- package/dist/components/UTDatePicker/constants.js +20 -31
- package/dist/components/UTDatePicker/index.js +59 -101
- package/dist/components/UTDatePicker/theme.js +173 -177
- package/dist/components/UTDatePicker/types.js +2 -3
- package/dist/components/UTDatePicker/utils.js +2 -6
- package/dist/components/UTDialog/components/ActionButton/index.js +10 -9
- package/dist/components/UTDialog/constants.js +2 -4
- package/dist/components/UTDialog/index.js +39 -38
- package/dist/components/UTDialog/theme.js +93 -95
- package/dist/components/UTDialog/types.js +2 -3
- package/dist/components/UTDotMenu/index.js +33 -57
- package/dist/components/UTEmojiPicker/constants.js +6 -11
- package/dist/components/UTEmojiPicker/index.js +45 -65
- package/dist/components/UTEmojiPicker/theme.js +1 -1
- package/dist/components/UTEmojiPicker/utils.js +21 -51
- package/dist/components/UTExternalLink/index.js +17 -14
- package/dist/components/UTFileInput/constants.js +2 -4
- package/dist/components/UTFileInput/index.js +7 -31
- package/dist/components/UTFileInput/layout.js +67 -96
- package/dist/components/UTIconButton/index.js +49 -72
- package/dist/components/UTIconButton/theme.js +53 -55
- package/dist/components/UTImageRadio/components/ImageRadioCard/index.js +53 -58
- package/dist/components/UTImageRadio/constants.js +3 -6
- package/dist/components/UTImageRadio/index.js +39 -47
- package/dist/components/UTImageRadio/theme.js +8 -11
- package/dist/components/UTImageRadio/types.js +2 -3
- package/dist/components/UTImageRadio/utils.js +2 -6
- package/dist/components/UTLabel/index.js +69 -90
- package/dist/components/UTLabel/theme.js +84 -86
- package/dist/components/UTList/index.js +15 -18
- package/dist/components/UTLoading/index.js +15 -15
- package/dist/components/UTMap/components/GoogleMaps/constants.js +8 -11
- package/dist/components/UTMap/components/GoogleMaps/index.js +63 -91
- package/dist/components/UTMap/components/GoogleMaps/styles.js +2 -3
- package/dist/components/UTMap/constants.js +6 -12
- package/dist/components/UTMap/index.js +163 -198
- package/dist/components/UTMap/types.js +4 -6
- package/dist/components/UTMap/utils.js +29 -46
- package/dist/components/UTMap/withGoogleMapScript.js +12 -17
- package/dist/components/UTMenu/index.js +52 -69
- package/dist/components/UTMenu/theme.js +2 -2
- package/dist/components/UTMenu/utils.js +5 -11
- package/dist/components/UTPagination/theme.js +4 -2
- package/dist/components/UTPanel/index.js +38 -44
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Error/index.js +14 -11
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Validation/index.js +24 -21
- package/dist/components/UTPasswordField/components/PasswordValidations/index.js +63 -50
- package/dist/components/UTPasswordField/components/PasswordWarning/index.js +26 -27
- package/dist/components/UTPasswordField/index.js +26 -23
- package/dist/components/UTPasswordField/theme.js +37 -39
- package/dist/components/UTPhoneInput/constants.js +3 -6
- package/dist/components/UTPhoneInput/index.js +180 -205
- package/dist/components/UTPhoneInput/theme.js +109 -113
- package/dist/components/UTPieChart/components/ArrowLabel/constants.js +4 -8
- package/dist/components/UTPieChart/components/ArrowLabel/index.js +24 -23
- package/dist/components/UTPieChart/components/Legend/contants.js +3 -6
- package/dist/components/UTPieChart/components/Legend/index.js +27 -24
- package/dist/components/UTPieChart/constants.js +13 -26
- package/dist/components/UTPieChart/hooks/use-animated-value/index.js +15 -33
- package/dist/components/UTPieChart/index.js +73 -76
- package/dist/components/UTPieChart/theme.js +23 -25
- package/dist/components/UTPieChart/utils.js +4 -2
- package/dist/components/UTProgressBar/constants.js +2 -4
- package/dist/components/UTProgressBar/index.js +12 -11
- package/dist/components/UTProgressBar/theme.js +25 -27
- package/dist/components/UTProgressBar/types.js +2 -3
- package/dist/components/UTRadioGroup/index.js +45 -71
- package/dist/components/UTRadioGroup/theme.js +82 -86
- package/dist/components/UTRating/components/Circle/index.js +41 -56
- package/dist/components/UTRating/components/Faces/constants.js +2 -4
- package/dist/components/UTRating/components/Faces/index.js +34 -36
- package/dist/components/UTRating/components/Star/index.js +36 -40
- package/dist/components/UTRating/constants.js +4 -8
- package/dist/components/UTRating/index.js +31 -46
- package/dist/components/UTRating/theme.js +77 -79
- package/dist/components/UTRipple/Ripple.js +22 -39
- package/dist/components/UTRipple/index.js +18 -37
- package/dist/components/UTSelect/components/Option/index.js +13 -13
- package/dist/components/UTSelect/constants.js +4 -8
- package/dist/components/UTSelect/index.js +61 -81
- package/dist/components/UTSelect/stylesJS.js +2 -3
- package/dist/components/UTSelect/theme.js +43 -45
- package/dist/components/UTSelect/utils.js +3 -13
- package/dist/components/UTSidebar/components/ListOption/index.js +32 -47
- package/dist/components/UTSidebar/components/LogosContainer/components/DynamicIcon/index.js +8 -8
- package/dist/components/UTSidebar/components/LogosContainer/index.js +14 -14
- package/dist/components/UTSidebar/components/Option/constants.js +2 -3
- package/dist/components/UTSidebar/components/Option/index.js +28 -32
- package/dist/components/UTSidebar/components/Toggler/index.js +11 -11
- package/dist/components/UTSidebar/index.js +42 -53
- package/dist/components/UTSidebar/theme.js +1 -1
- package/dist/components/UTSidebar/types.js +5 -10
- package/dist/components/UTSkeleton/index.js +10 -36
- package/dist/components/UTSwitch/constants.js +3 -6
- package/dist/components/UTSwitch/index.js +42 -57
- package/dist/components/UTSwitch/theme.js +115 -117
- package/dist/components/UTTable/components/ActionIcons/constants.js +1 -2
- package/dist/components/UTTable/components/ActionIcons/index.js +44 -81
- package/dist/components/UTTable/components/Cell/index.js +18 -23
- package/dist/components/UTTable/components/HeaderCell/constants.js +2 -3
- package/dist/components/UTTable/components/HeaderCell/index.js +23 -30
- package/dist/components/UTTable/components/HeaderCell/utils.js +3 -3
- package/dist/components/UTTable/components/PrimaryAction/index.js +12 -11
- package/dist/components/UTTable/components/ResponsiveCell/index.js +19 -20
- package/dist/components/UTTable/components/Status/index.js +18 -19
- package/dist/components/UTTable/components/TableFooter/components/PageSizeSelector/index.js +10 -9
- package/dist/components/UTTable/components/TableFooter/components/PageSizeSelector/utils.js +7 -13
- package/dist/components/UTTable/components/TableFooter/components/Pagination/components/NavigationButton/index.js +12 -12
- package/dist/components/UTTable/components/TableFooter/components/Pagination/index.js +21 -32
- package/dist/components/UTTable/components/TableFooter/components/Pagination/utils.js +8 -14
- package/dist/components/UTTable/components/TableFooter/constants.js +1 -2
- package/dist/components/UTTable/components/TableFooter/index.js +15 -15
- package/dist/components/UTTable/components/TableHeader/index.js +11 -11
- package/dist/components/UTTable/components/TableRow/constants.js +3 -6
- package/dist/components/UTTable/components/TableRow/index.js +79 -94
- package/dist/components/UTTable/constants.js +26 -43
- package/dist/components/UTTable/hook.js +11 -26
- package/dist/components/UTTable/index.js +125 -213
- package/dist/components/UTTable/theme.js +13 -16
- package/dist/components/UTTable/types.js +4 -8
- package/dist/components/UTTable/utils.js +70 -74
- package/dist/components/UTTabs/components/TooltipTab/index.js +20 -30
- package/dist/components/UTTabs/constants.js +4 -8
- package/dist/components/UTTabs/index.js +55 -84
- package/dist/components/UTTabs/theme.js +112 -114
- package/dist/components/UTTabs/utils.js +1 -1
- package/dist/components/UTTextArea/constants.js +4 -6
- package/dist/components/UTTextArea/index.js +40 -24
- package/dist/components/UTTextArea/styles.module.scss +20 -1
- package/dist/components/UTTextArea/theme.js +1 -1
- package/dist/components/UTTextInput/constants.js +2 -3
- package/dist/components/UTTextInput/index.js +116 -146
- package/dist/components/UTTextInput/theme.js +28 -30
- package/dist/components/UTThirdPartyCookieChecker/index.js +17 -21
- package/dist/components/UTToggle/components/ToggleOption/index.js +16 -17
- package/dist/components/UTToggle/index.js +25 -26
- package/dist/components/UTToggle/theme.js +47 -49
- package/dist/components/UTTooltip/index.js +23 -30
- package/dist/components/UTTooltip/theme.js +1 -1
- package/dist/components/UTTopbar/theme.js +4 -2
- package/dist/components/UTTouchableWithoutFeedback/index.js +14 -27
- package/dist/components/UTVirtualizedList/components/VirtualizedData/components/ListRow/constants.js +2 -4
- package/dist/components/UTVirtualizedList/components/VirtualizedData/components/ListRow/index.js +34 -31
- package/dist/components/UTVirtualizedList/components/VirtualizedData/components/ListRow/utils.js +4 -4
- package/dist/components/UTVirtualizedList/components/VirtualizedData/constants.js +6 -12
- package/dist/components/UTVirtualizedList/components/VirtualizedData/hooks/use-ledger.js +8 -18
- package/dist/components/UTVirtualizedList/components/VirtualizedData/hooks/use-virtualized-data.js +23 -47
- package/dist/components/UTVirtualizedList/components/VirtualizedData/index.js +31 -34
- package/dist/components/UTVirtualizedList/components/VirtualizedData/utils.js +81 -93
- package/dist/components/UTVirtualizedList/constants.js +4 -8
- package/dist/components/UTVirtualizedList/index.js +26 -38
- package/dist/components/UTWorkflowContainer/components/ActionButton/index.js +11 -11
- package/dist/components/UTWorkflowContainer/constants.js +5 -9
- package/dist/components/UTWorkflowContainer/hooks/use-previous.js +3 -3
- package/dist/components/UTWorkflowContainer/index.js +31 -50
- package/dist/components/UTWorkflowContainer/theme.js +70 -64
- package/dist/components/UTWorkflowContainer/types.js +2 -3
- package/dist/components/WithLoading/index.js +10 -15
- package/dist/components/WithTheme/index.js +10 -17
- package/dist/components/WithTheme/layout.js +18 -41
- package/dist/components/WithTouch/index.js +12 -19
- package/dist/index.js +54 -54
- package/dist/scss/variables/colors.module.scss +1 -0
- package/dist/theme.js +5 -3
- package/dist/types/commonTypes.js +3 -5
- package/dist/types/consumptionTypes.js +3 -5
- package/dist/types/formTypes.js +4 -7
- package/dist/types/tableTypes.js +2 -3
- package/dist/utils/classesUtils.js +4 -10
- package/dist/utils/componentUtils.js +10 -13
- package/dist/utils/helperFunctions.js +4 -4
- package/dist/utils/useScreenSize.js +2 -3
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -11,13 +10,14 @@ var _utils = require("../../utils");
|
|
|
11
10
|
var _constants = require("../../constants");
|
|
12
11
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
13
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _getRequireWildcardCache(
|
|
15
|
-
function _interopRequireWildcard(
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
15
|
function _extends() { _extends = 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.apply(this, arguments); } /* eslint-disable jsx-a11y/media-has-caption */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
previewProps =
|
|
16
|
+
const Preview = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
preview,
|
|
19
|
+
previewProps = {}
|
|
20
|
+
} = _ref;
|
|
21
21
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, (0, _utils.isImage)(preview) && /*#__PURE__*/_react.default.createElement("img", _extends({
|
|
22
22
|
src: preview.src,
|
|
23
23
|
className: _stylesModule.default.previewImage,
|
|
@@ -46,5 +46,4 @@ Preview.propTypes = {
|
|
|
46
46
|
type: _propTypes.string
|
|
47
47
|
})
|
|
48
48
|
};
|
|
49
|
-
var _default = /*#__PURE__*/(0, _react.memo)(Preview);
|
|
50
|
-
exports.default = _default;
|
|
49
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(Preview);
|
|
@@ -5,19 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.previewPropType = exports.SIZE_ERROR_TEXT = exports.FORMAT_ERROR_TEXT = exports.DEFAULT_UPLOADING_TEXT = exports.DEFAULT_ATTACHMENT_NAME = exports.ASPECT_RATIO_ERROR_TEXT = void 0;
|
|
7
7
|
var _propTypes = require("prop-types");
|
|
8
|
-
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
exports.
|
|
12
|
-
|
|
13
|
-
exports.
|
|
14
|
-
var DEFAULT_UPLOADING_TEXT = 'Cargando';
|
|
15
|
-
exports.DEFAULT_UPLOADING_TEXT = DEFAULT_UPLOADING_TEXT;
|
|
16
|
-
var DEFAULT_ATTACHMENT_NAME = 'Adjunto';
|
|
17
|
-
exports.DEFAULT_ATTACHMENT_NAME = DEFAULT_ATTACHMENT_NAME;
|
|
18
|
-
var previewPropType = (0, _propTypes.shape)({
|
|
8
|
+
const FORMAT_ERROR_TEXT = exports.FORMAT_ERROR_TEXT = 'El formato de archivo es inválido';
|
|
9
|
+
const SIZE_ERROR_TEXT = exports.SIZE_ERROR_TEXT = 'El archivo excede el tamaño máximo de ';
|
|
10
|
+
const ASPECT_RATIO_ERROR_TEXT = exports.ASPECT_RATIO_ERROR_TEXT = 'El formato de archivo es inválido. (Válidos:';
|
|
11
|
+
const DEFAULT_UPLOADING_TEXT = exports.DEFAULT_UPLOADING_TEXT = 'Cargando';
|
|
12
|
+
const DEFAULT_ATTACHMENT_NAME = exports.DEFAULT_ATTACHMENT_NAME = 'Adjunto';
|
|
13
|
+
const previewPropType = exports.previewPropType = (0, _propTypes.shape)({
|
|
19
14
|
audio: _propTypes.object,
|
|
20
15
|
image: _propTypes.object,
|
|
21
16
|
video: _propTypes.object
|
|
22
|
-
});
|
|
23
|
-
exports.previewPropType = previewPropType;
|
|
17
|
+
});
|
|
@@ -16,266 +16,188 @@ var _constants = require("./constants");
|
|
|
16
16
|
var _layout = _interopRequireDefault(require("./layout"));
|
|
17
17
|
var _utils = require("./utils");
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
function _getRequireWildcardCache(
|
|
20
|
-
function _interopRequireWildcard(
|
|
21
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
22
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
23
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
24
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
25
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
26
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
27
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
28
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
32
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
35
21
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
36
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return
|
|
37
|
-
function _toPrimitive(input, hint) { if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _this;
|
|
43
|
-
_classCallCheck(this, AttachmentContainer);
|
|
44
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
|
-
args[_key] = arguments[_key];
|
|
46
|
-
}
|
|
47
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
48
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
24
|
+
class AttachmentContainer extends _react.Component {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
_defineProperty(this, "state", {
|
|
49
28
|
loading: false,
|
|
50
29
|
name: '',
|
|
51
30
|
preview: {},
|
|
52
31
|
error: false,
|
|
53
32
|
errorText: _constants.FORMAT_ERROR_TEXT
|
|
54
33
|
});
|
|
55
|
-
_defineProperty(
|
|
56
|
-
|
|
57
|
-
input
|
|
58
|
-
onLoaded
|
|
59
|
-
|
|
34
|
+
_defineProperty(this, "loadElement", () => {
|
|
35
|
+
const {
|
|
36
|
+
input,
|
|
37
|
+
onLoaded
|
|
38
|
+
} = this.props;
|
|
39
|
+
(0, _utils.getBlobFromUrl)(input.value, response => {
|
|
60
40
|
if (response !== null && response !== void 0 && response.type) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
name:
|
|
41
|
+
const fileType = response.type.substring(response.type.indexOf('/') + 1);
|
|
42
|
+
this.setState({
|
|
43
|
+
name: this.getDefaultAttachment(input.value, fileType)
|
|
64
44
|
});
|
|
65
|
-
if ((0, _utils.hasPreview)(response))
|
|
66
|
-
} else
|
|
67
|
-
name:
|
|
45
|
+
if ((0, _utils.hasPreview)(response)) this.buildPreview(response);
|
|
46
|
+
} else this.setState({
|
|
47
|
+
name: this.getDefaultAttachment(input.value)
|
|
68
48
|
});
|
|
69
49
|
if (onLoaded) onLoaded();
|
|
70
50
|
});
|
|
71
51
|
});
|
|
72
|
-
_defineProperty(
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
_defineProperty(this, "loadDefaultValues", () => {
|
|
53
|
+
const {
|
|
54
|
+
input
|
|
55
|
+
} = this.props;
|
|
56
|
+
if (this.hasDefaultValueToLoad()) this.loadElement();else if (this.hasDefaultFileObjectToLoad()) this.setFile(input.value.file);
|
|
75
57
|
});
|
|
76
|
-
_defineProperty(
|
|
77
|
-
|
|
58
|
+
_defineProperty(this, "componentDidMount", () => {
|
|
59
|
+
this.loadDefaultValues();
|
|
78
60
|
});
|
|
79
|
-
_defineProperty(
|
|
61
|
+
_defineProperty(this, "componentDidUpdate", prevProps => {
|
|
80
62
|
var _prevProps$fieldTypes;
|
|
81
|
-
|
|
82
|
-
fieldTypes
|
|
83
|
-
input
|
|
84
|
-
|
|
63
|
+
const {
|
|
64
|
+
fieldTypes,
|
|
65
|
+
input
|
|
66
|
+
} = this.props;
|
|
67
|
+
if (((_prevProps$fieldTypes = prevProps.fieldTypes) === null || _prevProps$fieldTypes === void 0 ? void 0 : _prevProps$fieldTypes[0]) !== (fieldTypes === null || fieldTypes === void 0 ? void 0 : fieldTypes[0])) this.removeValue();else if ((0, _utils.isNewFile)(prevProps.input.value, input.value)) this.loadDefaultValues();
|
|
85
68
|
});
|
|
86
|
-
_defineProperty(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
69
|
+
_defineProperty(this, "getDefaultAttachment", (url, fileType) => url && typeof url === 'string' && /*#__PURE__*/_react.default.createElement("a", {
|
|
70
|
+
href: url,
|
|
71
|
+
target: "_blank",
|
|
72
|
+
rel: "noopener noreferrer"
|
|
73
|
+
}, _constants.DEFAULT_ATTACHMENT_NAME, fileType && ".".concat(fileType)) || '');
|
|
74
|
+
_defineProperty(this, "hasDefaultValueToLoad", () => this.props.input.value && typeof this.props.input.value === 'string');
|
|
75
|
+
_defineProperty(this, "hasDefaultFileObjectToLoad", () => {
|
|
76
|
+
const {
|
|
77
|
+
input
|
|
78
|
+
} = this.props;
|
|
79
|
+
return input.value && typeof input.value === 'object' && (0, _utils.isValidFile)(input.value.file);
|
|
92
80
|
});
|
|
93
|
-
_defineProperty(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
105
|
-
while (1) switch (_context.prev = _context.next) {
|
|
106
|
-
case 0:
|
|
107
|
-
file = ev.target.files[0];
|
|
108
|
-
_this$props3 = _this.props, resizeConfig = _this$props3.resizeConfig, disableResize = _this$props3.disableResize;
|
|
109
|
-
fileErrorTexts = {
|
|
110
|
-
formatError: _constants.FORMAT_ERROR_TEXT,
|
|
111
|
-
sizeError: "".concat(_constants.SIZE_ERROR_TEXT, " ").concat(Math.round(_this.props.maxFileSize / 1048576), "MB."),
|
|
112
|
-
aspectRatioError: "".concat(_constants.ASPECT_RATIO_ERROR_TEXT, " ").concat((_this$props$allowedPD = _this.props.allowedPDFUploadSizes) === null || _this$props$allowedPD === void 0 ? void 0 : _this$props$allowedPD.map(function (aspectRatio) {
|
|
113
|
-
return aspectRatio.name;
|
|
114
|
-
}).join(' - '), ")")
|
|
115
|
-
};
|
|
116
|
-
_this.setState({
|
|
117
|
-
error: false
|
|
118
|
-
});
|
|
119
|
-
if (!file) {
|
|
120
|
-
_context.next = 26;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
_context.next = 7;
|
|
124
|
-
return (0, _validate.fileSignatureValidation)(file, _this.props.fieldTypes, file.type);
|
|
125
|
-
case 7:
|
|
126
|
-
validation = _context.sent;
|
|
127
|
-
if (!validation) {
|
|
128
|
-
_context.next = 25;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
if (!_this.props.sanitize) {
|
|
132
|
-
_context.next = 13;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
_context.next = 12;
|
|
136
|
-
return _this.props.sanitize(file);
|
|
137
|
-
case 12:
|
|
138
|
-
file = _context.sent;
|
|
139
|
-
case 13:
|
|
140
|
-
validation = (0, _validate.fileSizeValidation)(file, _this.props.maxFileSize);
|
|
141
|
-
if (!(validation && (0, _utils.isPDF)(file) && !(0, _array.isEmpty)(_this.props.allowedPDFUploadSizes))) {
|
|
142
|
-
_context.next = 19;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
_context.next = 17;
|
|
146
|
-
return (0, _utils.pdfAspectRatioValidation)(file, _this.props.allowedPDFUploadSizes);
|
|
147
|
-
case 17:
|
|
148
|
-
validation = _context.sent;
|
|
149
|
-
return _context.abrupt("return", validation ? _this.setFile(file) : _this.onFailValidation(fileErrorTexts.aspectRatioError));
|
|
150
|
-
case 19:
|
|
151
|
-
if (!(!validation && !disableResize && (0, _utils.isImage)(file) && !(0, _browser.isIE)())) {
|
|
152
|
-
_context.next = 24;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
_context.next = 22;
|
|
156
|
-
return (0, _image.resizeImage)(file, resizeConfig);
|
|
157
|
-
case 22:
|
|
158
|
-
file = _context.sent;
|
|
159
|
-
validation = (0, _validate.fileSizeValidation)(file, _this.props.maxFileSize);
|
|
160
|
-
case 24:
|
|
161
|
-
return _context.abrupt("return", validation ? _this.setFile(file) : _this.onFailValidation(fileErrorTexts.sizeError));
|
|
162
|
-
case 25:
|
|
163
|
-
_this.onFailValidation(fileErrorTexts.formatError);
|
|
164
|
-
case 26:
|
|
165
|
-
case "end":
|
|
166
|
-
return _context.stop();
|
|
167
|
-
}
|
|
168
|
-
}, _callee);
|
|
169
|
-
}));
|
|
170
|
-
return function (_x) {
|
|
171
|
-
return _ref.apply(this, arguments);
|
|
81
|
+
_defineProperty(this, "onChange", async ev => {
|
|
82
|
+
var _this$props$allowedPD;
|
|
83
|
+
let file = ev.target.files[0];
|
|
84
|
+
const {
|
|
85
|
+
resizeConfig,
|
|
86
|
+
disableResize
|
|
87
|
+
} = this.props;
|
|
88
|
+
const fileErrorTexts = {
|
|
89
|
+
formatError: _constants.FORMAT_ERROR_TEXT,
|
|
90
|
+
sizeError: "".concat(_constants.SIZE_ERROR_TEXT, " ").concat(Math.round(this.props.maxFileSize / 1048576), "MB."),
|
|
91
|
+
aspectRatioError: "".concat(_constants.ASPECT_RATIO_ERROR_TEXT, " ").concat((_this$props$allowedPD = this.props.allowedPDFUploadSizes) === null || _this$props$allowedPD === void 0 ? void 0 : _this$props$allowedPD.map(aspectRatio => aspectRatio.name).join(' - '), ")")
|
|
172
92
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return _this.setState({
|
|
176
|
-
error: true,
|
|
177
|
-
errorText: errorMessage
|
|
93
|
+
this.setState({
|
|
94
|
+
error: false
|
|
178
95
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
_this.setState({
|
|
188
|
-
loading: true,
|
|
189
|
-
name: file.name
|
|
190
|
-
});
|
|
191
|
-
if ((0, _utils.hasPreview)(file)) _this.buildPreview(file);
|
|
192
|
-
if (onChange) onChange({
|
|
193
|
-
file: file
|
|
194
|
-
});
|
|
195
|
-
_this.setState({
|
|
196
|
-
loading: false
|
|
197
|
-
});
|
|
198
|
-
if (onLoaded) onLoaded();
|
|
199
|
-
case 6:
|
|
200
|
-
case "end":
|
|
201
|
-
return _context2.stop();
|
|
96
|
+
if (file) {
|
|
97
|
+
let validation = await (0, _validate.fileSignatureValidation)(file, this.props.fieldTypes, file.type);
|
|
98
|
+
if (validation) {
|
|
99
|
+
if (this.props.sanitize) file = await this.props.sanitize(file);
|
|
100
|
+
validation = (0, _validate.fileSizeValidation)(file, this.props.maxFileSize);
|
|
101
|
+
if (validation && (0, _utils.isPDF)(file) && !(0, _array.isEmpty)(this.props.allowedPDFUploadSizes)) {
|
|
102
|
+
validation = await (0, _utils.pdfAspectRatioValidation)(file, this.props.allowedPDFUploadSizes);
|
|
103
|
+
return validation ? this.setFile(file) : this.onFailValidation(fileErrorTexts.aspectRatioError);
|
|
202
104
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return _ref2.apply(this, arguments);
|
|
207
|
-
};
|
|
208
|
-
}());
|
|
209
|
-
_defineProperty(_assertThisInitialized(_this), "buildPreview", function (file) {
|
|
210
|
-
var reader = new FileReader();
|
|
211
|
-
reader.onload = function (e) {
|
|
212
|
-
return _this.setState({
|
|
213
|
-
preview: {
|
|
214
|
-
src: e.target.result,
|
|
215
|
-
type: file.type
|
|
105
|
+
if (!validation && !disableResize && (0, _utils.isImage)(file) && !(0, _browser.isIE)()) {
|
|
106
|
+
file = await (0, _image.resizeImage)(file, resizeConfig);
|
|
107
|
+
validation = (0, _validate.fileSizeValidation)(file, this.props.maxFileSize);
|
|
216
108
|
}
|
|
217
|
-
|
|
218
|
-
|
|
109
|
+
return validation ? this.setFile(file) : this.onFailValidation(fileErrorTexts.sizeError);
|
|
110
|
+
}
|
|
111
|
+
this.onFailValidation(fileErrorTexts.formatError);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
_defineProperty(this, "onFailValidation", errorMessage => this.setState({
|
|
115
|
+
error: true,
|
|
116
|
+
errorText: errorMessage
|
|
117
|
+
}));
|
|
118
|
+
_defineProperty(this, "setFile", async file => {
|
|
119
|
+
const {
|
|
120
|
+
onChange,
|
|
121
|
+
onLoaded
|
|
122
|
+
} = this.props;
|
|
123
|
+
this.setState({
|
|
124
|
+
loading: true,
|
|
125
|
+
name: file.name
|
|
126
|
+
});
|
|
127
|
+
if ((0, _utils.hasPreview)(file)) this.buildPreview(file);
|
|
128
|
+
if (onChange) onChange({
|
|
129
|
+
file
|
|
130
|
+
});
|
|
131
|
+
this.setState({
|
|
132
|
+
loading: false
|
|
133
|
+
});
|
|
134
|
+
if (onLoaded) onLoaded();
|
|
135
|
+
});
|
|
136
|
+
_defineProperty(this, "buildPreview", file => {
|
|
137
|
+
const reader = new FileReader();
|
|
138
|
+
reader.onload = e => this.setState({
|
|
139
|
+
preview: {
|
|
140
|
+
src: e.target.result,
|
|
141
|
+
type: file.type
|
|
142
|
+
}
|
|
143
|
+
});
|
|
219
144
|
reader.readAsDataURL(file);
|
|
220
145
|
});
|
|
221
|
-
_defineProperty(
|
|
222
|
-
|
|
146
|
+
_defineProperty(this, "removeValue", () => {
|
|
147
|
+
this.setState({
|
|
223
148
|
loading: false,
|
|
224
149
|
name: '',
|
|
225
150
|
preview: {}
|
|
226
151
|
});
|
|
227
|
-
if (
|
|
152
|
+
if (this.props.onChange) this.props.onChange('');
|
|
228
153
|
});
|
|
229
|
-
return _this;
|
|
230
154
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return AttachmentContainer;
|
|
278
|
-
}(_react.Component);
|
|
155
|
+
render() {
|
|
156
|
+
const {
|
|
157
|
+
classes,
|
|
158
|
+
containerClassname,
|
|
159
|
+
disabled,
|
|
160
|
+
errorClassname,
|
|
161
|
+
fieldTypes,
|
|
162
|
+
icon,
|
|
163
|
+
input,
|
|
164
|
+
loadingTextClassname,
|
|
165
|
+
previewClassname,
|
|
166
|
+
previewProps,
|
|
167
|
+
RemoveIcon,
|
|
168
|
+
removeFileClassname
|
|
169
|
+
} = this.props;
|
|
170
|
+
const {
|
|
171
|
+
name,
|
|
172
|
+
preview,
|
|
173
|
+
loading,
|
|
174
|
+
error,
|
|
175
|
+
errorText
|
|
176
|
+
} = this.state;
|
|
177
|
+
const loadingDefaultValue = this.hasDefaultValueToLoad() && !name;
|
|
178
|
+
return /*#__PURE__*/_react.default.createElement(_layout.default, {
|
|
179
|
+
loading: loading || loadingDefaultValue,
|
|
180
|
+
uploadingText: loadingDefaultValue ? _constants.DEFAULT_UPLOADING_TEXT : '',
|
|
181
|
+
name: name || this.getDefaultAttachment(input.value),
|
|
182
|
+
previewClassname: previewClassname,
|
|
183
|
+
containerClassname: containerClassname,
|
|
184
|
+
preview: preview,
|
|
185
|
+
onChange: this.onChange,
|
|
186
|
+
onClick: this.removeValue,
|
|
187
|
+
error: error,
|
|
188
|
+
errorText: errorText,
|
|
189
|
+
fieldTypes: fieldTypes,
|
|
190
|
+
loadingTextClassname: loadingTextClassname,
|
|
191
|
+
classes: classes,
|
|
192
|
+
errorClassname: errorClassname,
|
|
193
|
+
removeFileClassname: removeFileClassname,
|
|
194
|
+
icon: icon,
|
|
195
|
+
disabled: disabled,
|
|
196
|
+
RemoveIcon: RemoveIcon,
|
|
197
|
+
previewProps: previewProps
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
279
201
|
AttachmentContainer.propTypes = {
|
|
280
202
|
allowedPDFUploadSizes: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
281
203
|
name: _propTypes.string,
|
|
@@ -314,5 +236,4 @@ AttachmentContainer.propTypes = {
|
|
|
314
236
|
AttachmentContainer.defaultProps = {
|
|
315
237
|
maxFileSize: 99999999
|
|
316
238
|
};
|
|
317
|
-
var _default = (0, _WithTheme.default)(_theme.retrieveStyle)(AttachmentContainer);
|
|
318
|
-
exports.default = _default;
|
|
239
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(AttachmentContainer);
|
|
@@ -15,30 +15,30 @@ var _Preview = _interopRequireDefault(require("./components/Preview"));
|
|
|
15
15
|
var _constants = require("./constants");
|
|
16
16
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
const Attachment = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
name,
|
|
21
|
+
preview,
|
|
22
|
+
loading,
|
|
23
|
+
containerClassname,
|
|
24
|
+
previewClassname,
|
|
25
|
+
removeFileClassname,
|
|
26
|
+
onClick,
|
|
27
|
+
onChange,
|
|
28
|
+
error,
|
|
29
|
+
errorText,
|
|
30
|
+
fieldTypes,
|
|
31
|
+
loadingTextClassname,
|
|
32
|
+
classes,
|
|
33
|
+
errorClassname,
|
|
34
|
+
icon,
|
|
35
|
+
disabled,
|
|
36
|
+
uploadingText,
|
|
37
|
+
RemoveIcon,
|
|
38
|
+
previewProps
|
|
39
|
+
} = _ref;
|
|
40
|
+
const fieldType = fieldTypes.map(type => _files.inputFiles[type].inputType).join();
|
|
41
|
+
const Icon = RemoveIcon || _DeleteForever.default;
|
|
42
42
|
return name && !loading ? /*#__PURE__*/_react.default.createElement("div", {
|
|
43
43
|
className: "".concat(_stylesModule.default.previewContainer, " ").concat(previewClassname)
|
|
44
44
|
}, /*#__PURE__*/_react.default.createElement(_Preview.default, {
|
|
@@ -93,5 +93,4 @@ Attachment.propTypes = {
|
|
|
93
93
|
RemoveIcon: _propTypes.elementType,
|
|
94
94
|
previewProps: _constants.previewPropType
|
|
95
95
|
};
|
|
96
|
-
var _default = Attachment;
|
|
97
|
-
exports.default = _default;
|
|
96
|
+
var _default = exports.default = Attachment;
|
|
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.retrieveStyle = void 0;
|
|
7
7
|
var _seamlessImmutable = require("seamless-immutable");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'
|
|
18
|
-
fill: (0, _seamlessImmutable.getIn)(theme, ['UTAttachment', 'icon', 'fill'])
|
|
19
|
-
}
|
|
8
|
+
const retrieveStyle = theme => ({
|
|
9
|
+
container: {
|
|
10
|
+
border: (0, _seamlessImmutable.getIn)(theme, ['UTAttachment', 'container', 'border'])
|
|
11
|
+
},
|
|
12
|
+
fileInputLabel: {
|
|
13
|
+
color: (0, _seamlessImmutable.getIn)(theme, ['UTAttachment', 'label', 'color'])
|
|
14
|
+
},
|
|
15
|
+
icon: {
|
|
16
|
+
'& g': {
|
|
17
|
+
fill: (0, _seamlessImmutable.getIn)(theme, ['UTAttachment', 'icon', 'fill'])
|
|
20
18
|
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
19
|
+
}
|
|
20
|
+
});
|
|
23
21
|
exports.retrieveStyle = retrieveStyle;
|