ods-component-lib 1.20.1 → 1.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { Alert, AutoComplete, Badge, Table, Button, Calendar, Card as Card$1, Switch, Input, Select, Row, Col, Typography, Checkbox, Collapse, Tooltip as Tooltip$1, InputNumber, DatePicker, Divider, Dropdown, notification, Upload, Modal, Image, List, Space, Progress, Radio, TimePicker, Rate, Spin, Tabs, Tag, Timeline, Tree, ConfigProvider, TreeSelect, theme, Form, Popover, Transfer, Menu } from 'antd';
1
+ import { Alert, AutoComplete, Badge, Table, Button, Calendar, Card as Card$1, Switch, Input, Select, Row, Col, Typography, Checkbox, Collapse, Tooltip as Tooltip$1, InputNumber, DatePicker, Divider, Dropdown, notification, Upload, Modal, Image as Image$1, List, Space, Progress, Radio, TimePicker, Rate, Spin, Tabs, Tag, Timeline, Tree, ConfigProvider, TreeSelect, theme, Form, Popover, Transfer, Menu } from 'antd';
2
2
  import styled, { ThemeProvider } from 'styled-components';
3
3
  import React, { useState, useCallback, useEffect, useMemo, useRef, Suspense, forwardRef, useImperativeHandle } from 'react';
4
4
  import Marquee from 'react-fast-marquee';
@@ -847,7 +847,7 @@ var CurrencySelect = function CurrencySelect(_ref) {
847
847
  }));
848
848
  };
849
849
 
850
- var _excluded$1 = ["currencySelectProps", "defaultValue", "locale", "dontFormatValue", "min", "asPercentage", "isOnRight"];
850
+ var _excluded$1 = ["currencySelectProps", "defaultValue", "locale", "dontFormatValue", "min", "asPercentage", "isOnRight", "fractionDigits"];
851
851
  var _templateObject$d;
852
852
  var useStyles$1 = createStyles(function (_ref) {
853
853
  var css = _ref.css;
@@ -866,6 +866,7 @@ var OdsCurrencyInput = function OdsCurrencyInput(_ref2) {
866
866
  min = _ref2$min === void 0 ? 0 : _ref2$min,
867
867
  asPercentage = _ref2.asPercentage,
868
868
  isOnRight = _ref2.isOnRight,
869
+ fractionDigits = _ref2.fractionDigits,
869
870
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
870
871
  var _useStyles = useStyles$1(),
871
872
  styles = _useStyles.styles;
@@ -906,16 +907,19 @@ var OdsCurrencyInput = function OdsCurrencyInput(_ref2) {
906
907
  return props.onChange(value);
907
908
  },
908
909
  formatter: function formatter(value) {
909
- return dontFormatValue ? String(value) : formatValue(value, locale);
910
+ return dontFormatValue ? String(value) : formatValue(value, locale, fractionDigits);
910
911
  },
911
912
  parser: function parser(value) {
912
913
  return dontFormatValue ? value : parseValue(value, locale);
913
914
  }
914
915
  }, props))));
915
916
  };
916
- var formatValue = function formatValue(value, locale) {
917
+ var formatValue = function formatValue(value, locale, fractionDigits) {
917
918
  if (!value) return value;
918
- return new Intl.NumberFormat(locale).format(Number(value));
919
+ return new Intl.NumberFormat(locale, fractionDigits ? {
920
+ minimumFractionDigits: fractionDigits,
921
+ maximumFractionDigits: fractionDigits
922
+ } : {}).format(Number(value));
919
923
  };
920
924
  var parseValue = function parseValue(stringNumber, locale) {
921
925
  if (!stringNumber) return stringNumber;
@@ -1070,25 +1074,50 @@ function OdsFileUpload(props) {
1070
1074
  var fileType = allowDocumentUpload ? ["image/png", "image/jpg", "image/jpeg", "image/svg+xml", "application/pdf", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"] : ["image/png", "image/jpg", "image/jpeg", "image/svg+xml"];
1071
1075
  var isFileSizeOk = skipSizeValidation ? true : file.size / (1024 * 1024) <= maxFileSizeMB;
1072
1076
  var checkType = fileType.includes(file.type);
1073
- if (!checkType) {
1074
- OdsNotification({
1075
- title: "",
1076
- content: customValidationMessages.typeValidationFailMessage,
1077
- type: "warning",
1078
- placement: "bottom"
1079
- });
1080
- return Promise.resolve(Upload.LIST_IGNORE);
1081
- }
1082
- if (!isFileSizeOk) {
1083
- OdsNotification({
1084
- title: "",
1085
- content: customValidationMessages.sizeValidationFailMessage,
1086
- type: "warning",
1087
- placement: "bottom"
1077
+ var checkDimensions = function checkDimensions(file) {
1078
+ return new Promise(function (resolve) {
1079
+ if (file.type.startsWith("image/") && (props.minWidth || props.minHeight)) {
1080
+ var img = new Image();
1081
+ img.src = URL.createObjectURL(file);
1082
+ img.onload = function () {
1083
+ var isValid = (!props.minWidth || img.width >= props.minWidth) && (!props.minHeight || img.height >= props.minHeight);
1084
+ resolve(isValid);
1085
+ };
1086
+ } else {
1087
+ resolve(true);
1088
+ }
1088
1089
  });
1089
- return Promise.resolve(Upload.LIST_IGNORE);
1090
- }
1091
- return Promise.resolve(false);
1090
+ };
1091
+ return Promise.resolve(checkDimensions(file)).then(function (isDimensionsOk) {
1092
+ if (!isDimensionsOk) {
1093
+ OdsNotification({
1094
+ title: "",
1095
+ content: customValidationMessages.dimensionValidationFailMessage || "Image dimensions are too small. Minimum size is " + (props.minWidth || 0) + "px width and " + (props.minHeight || 0) + "px height.",
1096
+ type: "warning",
1097
+ placement: "bottom"
1098
+ });
1099
+ return Upload.LIST_IGNORE;
1100
+ }
1101
+ if (!checkType) {
1102
+ OdsNotification({
1103
+ title: "",
1104
+ content: customValidationMessages.typeValidationFailMessage,
1105
+ type: "warning",
1106
+ placement: "bottom"
1107
+ });
1108
+ return Upload.LIST_IGNORE;
1109
+ }
1110
+ if (!isFileSizeOk) {
1111
+ OdsNotification({
1112
+ title: "",
1113
+ content: customValidationMessages.sizeValidationFailMessage,
1114
+ type: "warning",
1115
+ placement: "bottom"
1116
+ });
1117
+ return Upload.LIST_IGNORE;
1118
+ }
1119
+ return false;
1120
+ });
1092
1121
  } catch (e) {
1093
1122
  return Promise.reject(e);
1094
1123
  }
@@ -1595,7 +1624,7 @@ function OdsFileUploadv2(props) {
1595
1624
  }
1596
1625
 
1597
1626
  function OdsImage(props) {
1598
- return React.createElement(Image, Object.assign({}, props));
1627
+ return React.createElement(Image$1, Object.assign({}, props));
1599
1628
  }
1600
1629
 
1601
1630
  var _templateObject$g;