@xaypay/tui 0.0.71 → 0.0.72
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/index.es.js +454 -166
- package/dist/index.js +454 -166
- package/package.json +1 -1
- package/src/components/autocomplate/autocomplate.stories.js +1 -1
- package/src/components/icon/ListItemJpeg.js +21 -0
- package/src/components/icon/ListItemPng.js +21 -0
- package/src/components/icon/index.js +2 -1
- package/src/components/input/index.js +22 -15
- package/src/components/input/input.stories.js +11 -5
- package/src/components/newAutocomplete/NewAutocomplete.stories.js +26 -26
- package/src/components/newAutocomplete/index.js +113 -92
- package/src/components/newFile/fileItem.js +213 -0
- package/src/components/newFile/index.js +154 -129
- package/src/components/newFile/newFile.stories.js +5 -2
- package/src/components/textarea/index.js +30 -1
- package/src/stories/configuration.stories.mdx +42 -0
- package/src/stories/static/autocomplete-usage.png +0 -0
- package/src/stories/static/file-single-usage.png +0 -0
- package/src/stories/static/file-usage.png +0 -0
- package/src/stories/static/input-usage.png +0 -0
- package/src/stories/static/tooltip-usage.png +0 -0
- package/src/stories/usage.stories.mdx +17 -8
- package/tui.config.js +20 -2
- package/src/stories/static/input-tooltip-usage.png +0 -0
- package/src/stories/static/new-autocomplete-usage.png +0 -0
package/dist/index.es.js
CHANGED
|
@@ -574,6 +574,9 @@ const InputTypes = {
|
|
|
574
574
|
TEXT: "text",
|
|
575
575
|
PASSWORD: "password"
|
|
576
576
|
};
|
|
577
|
+
const P = styled.p`
|
|
578
|
+
animation: ${props => props.errorAnimation ? props.animation : 'none'};
|
|
579
|
+
`;
|
|
577
580
|
const Input = ({
|
|
578
581
|
type,
|
|
579
582
|
size,
|
|
@@ -585,12 +588,12 @@ const Input = ({
|
|
|
585
588
|
regexp,
|
|
586
589
|
height,
|
|
587
590
|
radius,
|
|
591
|
+
change,
|
|
588
592
|
padding,
|
|
589
593
|
tooltip,
|
|
590
594
|
leftIcon,
|
|
591
595
|
required,
|
|
592
596
|
disabled,
|
|
593
|
-
onChange,
|
|
594
597
|
transform,
|
|
595
598
|
iconWidth,
|
|
596
599
|
rightIcon,
|
|
@@ -647,12 +650,12 @@ const Input = ({
|
|
|
647
650
|
const animation = _ => css`
|
|
648
651
|
${errorShow} ${errorAnimationDuration ? errorAnimationDuration : configStyles.INPUT.errorAnimationDuration} forwards
|
|
649
652
|
`;
|
|
650
|
-
const P = styled.p`
|
|
651
|
-
animation: ${errorAnimation ? animation : 'none'};
|
|
652
|
-
`;
|
|
653
653
|
const handleChange = event => {
|
|
654
654
|
const currentValue = event.target.value;
|
|
655
655
|
setInnerValue(currentValue);
|
|
656
|
+
if (change) {
|
|
657
|
+
change(currentValue);
|
|
658
|
+
}
|
|
656
659
|
if (type === 'tel') {
|
|
657
660
|
if (!phoneNumberRegex.test(currentValue)) {
|
|
658
661
|
telErrorMessage && setInnerErrorMessage(telErrorMessage);
|
|
@@ -661,27 +664,27 @@ const Input = ({
|
|
|
661
664
|
setInnerErrorMessage('');
|
|
662
665
|
if (currentValue.length > 8) {
|
|
663
666
|
setInnerValue(currentValue.substr(0, 8));
|
|
664
|
-
if (
|
|
665
|
-
|
|
667
|
+
if (change) {
|
|
668
|
+
change(currentValue.substr(0, 8));
|
|
666
669
|
}
|
|
667
670
|
} else {
|
|
668
671
|
setInnerValue(currentValue);
|
|
669
|
-
if (
|
|
670
|
-
|
|
672
|
+
if (change) {
|
|
673
|
+
change(currentValue);
|
|
671
674
|
}
|
|
672
675
|
}
|
|
673
676
|
}
|
|
674
677
|
}
|
|
675
678
|
if (maxLength && currentValue.length > maxLength && type !== 'tel') {
|
|
676
679
|
setInnerValue(currentValue.substr(0, maxLength));
|
|
677
|
-
if (
|
|
678
|
-
|
|
680
|
+
if (change) {
|
|
681
|
+
change(currentValue.substr(0, maxLength));
|
|
679
682
|
}
|
|
680
683
|
}
|
|
681
684
|
if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
|
|
682
685
|
!regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
|
|
683
|
-
if (
|
|
684
|
-
|
|
686
|
+
if (change) {
|
|
687
|
+
change(currentValue);
|
|
685
688
|
}
|
|
686
689
|
}
|
|
687
690
|
};
|
|
@@ -700,7 +703,7 @@ const Input = ({
|
|
|
700
703
|
if (value !== undefined && value !== null) {
|
|
701
704
|
setInnerValue(value);
|
|
702
705
|
if (type === 'tel') {
|
|
703
|
-
if (!phoneNumberRegex.test(
|
|
706
|
+
if (!phoneNumberRegex.test(value)) {
|
|
704
707
|
telErrorMessage && setInnerErrorMessage(telErrorMessage);
|
|
705
708
|
setInnerValue('');
|
|
706
709
|
} else {
|
|
@@ -811,7 +814,10 @@ const Input = ({
|
|
|
811
814
|
backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.backgroundColor
|
|
812
815
|
}
|
|
813
816
|
}, type === 'password' ? show ? rightIcon[1] : rightIcon[0] : rightIcon[0]) : ''), tooltip ? tooltip : '', innerErrorMessage ? /*#__PURE__*/React__default.createElement(P, {
|
|
817
|
+
errorAnimation: errorAnimation,
|
|
818
|
+
animation: animation,
|
|
814
819
|
style: {
|
|
820
|
+
margin: '0px',
|
|
815
821
|
left: errorLeft ? errorLeft : configStyles.INPUT.errorLeft,
|
|
816
822
|
color: errorColor ? errorColor : configStyles.INPUT.errorColor,
|
|
817
823
|
fontSize: errorSize ? errorSize : configStyles.INPUT.errorSize,
|
|
@@ -826,11 +832,11 @@ const Input = ({
|
|
|
826
832
|
};
|
|
827
833
|
Input.propTypes = {
|
|
828
834
|
name: PropTypes.string,
|
|
835
|
+
change: PropTypes.func,
|
|
829
836
|
color: PropTypes.string,
|
|
830
837
|
value: PropTypes.string,
|
|
831
838
|
width: PropTypes.string,
|
|
832
839
|
label: PropTypes.string,
|
|
833
|
-
onChange: PropTypes.func,
|
|
834
840
|
required: PropTypes.bool,
|
|
835
841
|
disabled: PropTypes.bool,
|
|
836
842
|
height: PropTypes.string,
|
|
@@ -2159,53 +2165,47 @@ function v4(options, buf, offset) {
|
|
|
2159
2165
|
return stringify(rnds);
|
|
2160
2166
|
}
|
|
2161
2167
|
|
|
2162
|
-
const
|
|
2168
|
+
const SvgListItemPdf = ({
|
|
2163
2169
|
title,
|
|
2164
2170
|
titleId,
|
|
2165
2171
|
...props
|
|
2166
2172
|
}) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
2167
|
-
width: "
|
|
2168
|
-
height: "
|
|
2169
|
-
viewBox: "0 0
|
|
2173
|
+
width: "32",
|
|
2174
|
+
height: "42",
|
|
2175
|
+
viewBox: "0 0 32 42",
|
|
2170
2176
|
fill: "none",
|
|
2171
2177
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2172
2178
|
"aria-labelledby": titleId
|
|
2173
2179
|
}, props), title ? /*#__PURE__*/React.createElement("title", {
|
|
2174
2180
|
id: titleId
|
|
2175
2181
|
}, title) : null, /*#__PURE__*/React.createElement("path", {
|
|
2176
|
-
d: "M41.54 11.842h-.017c-.23-3.225-2.902-5.772-6.167-5.772-1.08 0-2.095.28-2.979.77C30.267 2.774 26.041 0 21.167 0 14.318 0 8.742 5.483 8.534 12.326 3.758 12.708 0 16.726 0 21.63c0 5.155 4.153 9.334 9.277 9.334h22.625a10.987 10.987 0 0 1-.888-4.334c0-6.059 4.899-10.987 10.918-10.987 3.773 0 7.106 1.938 9.068 4.875-.444-4.864-4.508-8.675-9.46-8.675ZM15.654 6.975c-.072.06-.144.12-.211.185-.266.259-.512.53-.705.849-.741 1.218-.882 2.523-.72 3.927.156 1.35-1.942 1.334-2.095 0-.289-2.493.504-5.307 2.664-6.775 1.12-.763 2.164 1.052 1.067 1.814Zm-.022.015c-.047.035-.111.093 0 0Z",
|
|
2177
|
-
fill: "#D1D1D1"
|
|
2178
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
2179
2182
|
fillRule: "evenodd",
|
|
2180
2183
|
clipRule: "evenodd",
|
|
2181
|
-
d: "
|
|
2182
|
-
fill: "#
|
|
2184
|
+
d: "M31.862 10.64c.007.01.015.02.022.027l.116.108v28.328c0 .768-.306 1.505-.852 2.049a2.917 2.917 0 0 1-2.057.848H2.909a2.917 2.917 0 0 1-2.057-.848A2.891 2.891 0 0 1 0 39.103V2.897C0 2.128.306 1.392.852.848A2.917 2.917 0 0 1 2.909 0h18.27l.108.116.03.025.028.026.025.02.026.023L31.79 10.558c.02.018.037.037.052.058l.02.025Zm-1.743 29.486a1.45 1.45 0 0 0 .427-1.022v-8.77H13.95a.716.716 0 0 1-.546-.246l-1.963-2.238H1.455v11.254c.001.383.155.751.427 1.022.273.272.642.425 1.027.426h26.182a1.463 1.463 0 0 0 1.027-.426ZM4.364 17.633c0 .4.324.724.724.724h21.825a.724.724 0 1 0 0-1.448H5.088c-.4 0-.724.324-.724.724Zm23.273 3.186c0-.4-.325-.724-.724-.724H15.48a.724.724 0 0 0 0 1.448h11.432c.4 0 .724-.324.724-.724Zm-.724-5.641a.724.724 0 1 0 0-1.449H5.088a.724.724 0 1 0 0 1.449h21.825Zm-22.55-3.91c0 .4.325.723.725.723H16.52a.724.724 0 0 0 0-1.448H5.088c-.4 0-.724.324-.724.724Zm17.672-1.345c.272.27.642.423 1.027.425h6.458l-7.913-7.879V8.9c.002.384.155.752.428 1.024ZM10.43 36.013H9.103v2.385H8V32h2.43c.495 0 .916.088 1.261.264.349.172.614.413.796.72.181.305.272.654.272 1.046 0 .413-.09.768-.272 1.064a1.754 1.754 0 0 1-.796.68c-.345.16-.766.238-1.26.238Zm-1.327-3.134v2.259h1.327c.29 0 .525-.047.703-.14a.877.877 0 0 0 .391-.388c.085-.167.128-.357.128-.57 0-.203-.043-.392-.128-.568a.971.971 0 0 0-.39-.43c-.18-.109-.414-.163-.704-.163H9.103Zm6.504 5.52h-1.859V32H15.646c.425 0 .813.072 1.165.215.352.141.655.345.91.611.258.267.455.586.593.958.138.372.206.788.206 1.248v.339c0 .46-.068.876-.206 1.248a2.714 2.714 0 0 1-.593.958 2.662 2.662 0 0 1-.923.61c-.355.141-.752.211-1.191.211Zm0-.875h-.756v-4.645h.795c.285 0 .535.047.752.14.22.094.404.232.554.414a1.8 1.8 0 0 1 .342.672c.08.267.12.573.12.918v.348c0 .445-.07.829-.208 1.151-.134.322-.336.57-.606.743-.267.172-.598.259-.993.259Zm5.124-2.725v-1.92h2.975V32h-4.078v6.398h1.103v-2.724h2.61v-.875h-2.61Z",
|
|
2185
|
+
fill: "#051942"
|
|
2183
2186
|
}));
|
|
2184
2187
|
|
|
2185
|
-
const
|
|
2188
|
+
const SvgListItemJpg = ({
|
|
2186
2189
|
title,
|
|
2187
2190
|
titleId,
|
|
2188
2191
|
...props
|
|
2189
2192
|
}) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
2190
|
-
width: "
|
|
2191
|
-
height: "
|
|
2192
|
-
viewBox: "0 0
|
|
2193
|
+
width: "32",
|
|
2194
|
+
height: "42",
|
|
2195
|
+
viewBox: "0 0 32 42",
|
|
2193
2196
|
fill: "none",
|
|
2194
2197
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2195
2198
|
"aria-labelledby": titleId
|
|
2196
2199
|
}, props), title ? /*#__PURE__*/React.createElement("title", {
|
|
2197
2200
|
id: titleId
|
|
2198
|
-
}, title) : null, /*#__PURE__*/React.createElement("
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
fill: "#
|
|
2203
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
2204
|
-
d: "M13 4c.822 0 1.611.296 2.206.826s.95 1.255.99 2.024l.005.15h4c.204 0 .4.073.548.205.148.13.238.31.25.501a.72.72 0 0 1-.185.525.817.817 0 0 1-.52.264l-.093.005h-.68l-.943 10.915a2.75 2.75 0 0 1-.957 1.84 3.114 3.114 0 0 1-2.034.745h-5.173c-.754 0-1.48-.266-2.034-.745a2.75 2.75 0 0 1-.957-1.84L6.478 8.5H5.8a.831.831 0 0 1-.531-.19.736.736 0 0 1-.263-.472L5 7.75c0-.184.072-.361.202-.498a.818.818 0 0 1 .504-.247L5.8 7h4c0-.796.337-1.559.938-2.121A3.312 3.312 0 0 1 13 4Zm-1.8 6.938a.623.623 0 0 0-.394.138.553.553 0 0 0-.2.348l-.006.076v6l.006.076c.02.135.09.258.2.348.11.09.25.138.394.138.145 0 .285-.049.395-.138.109-.09.18-.213.2-.348l.005-.076v-6l-.005-.076a.553.553 0 0 0-.2-.348.624.624 0 0 0-.395-.139Zm3.6 0a.623.623 0 0 0-.394.138.553.553 0 0 0-.2.348l-.005.076v6l.005.076c.02.135.091.258.2.348.11.09.25.138.394.138.145 0 .286-.049.395-.138.11-.09.18-.213.2-.348l.006-.076v-6l-.006-.076a.553.553 0 0 0-.2-.348.624.624 0 0 0-.395-.139ZM13 5.5a1.66 1.66 0 0 0-1.088.4c-.296.257-.477.61-.508.987L11.4 7h3.2l-.003-.112a1.465 1.465 0 0 0-.508-.988A1.66 1.66 0 0 0 13 5.5Z",
|
|
2205
|
-
fill: "#00236A"
|
|
2201
|
+
}, title) : null, /*#__PURE__*/React.createElement("path", {
|
|
2202
|
+
fillRule: "evenodd",
|
|
2203
|
+
clipRule: "evenodd",
|
|
2204
|
+
d: "M31.862 10.64c.007.01.015.02.022.027l.116.108v28.328c0 .768-.306 1.505-.852 2.049a2.917 2.917 0 0 1-2.057.848H2.909a2.917 2.917 0 0 1-2.057-.848A2.891 2.891 0 0 1 0 39.103V2.897C0 2.128.306 1.392.852.848A2.917 2.917 0 0 1 2.909 0h18.27l.108.116.03.025.028.026.025.02.026.023L31.79 10.558c.02.018.037.037.052.058l.02.025Zm-1.743 29.486a1.45 1.45 0 0 0 .427-1.022v-8.77H13.95a.716.716 0 0 1-.546-.246l-1.963-2.238H1.455v11.254c.001.383.155.751.427 1.022.273.272.642.425 1.027.426h26.182a1.463 1.463 0 0 0 1.027-.426ZM4.364 17.633c0 .4.324.724.724.724h21.825a.724.724 0 1 0 0-1.448H5.088c-.4 0-.724.324-.724.724Zm23.273 3.186c0-.4-.325-.724-.724-.724H15.48a.724.724 0 0 0 0 1.448h11.432c.4 0 .724-.324.724-.724Zm-.724-5.641a.724.724 0 1 0 0-1.449H5.088a.724.724 0 1 0 0 1.449h21.825Zm-22.55-3.91c0 .4.325.723.725.723H16.52a.724.724 0 0 0 0-1.448H5.088c-.4 0-.724.324-.724.724Zm17.672-1.345c.272.27.642.423 1.027.425h6.458l-7.913-7.879V8.9c.002.384.155.752.428 1.024Zm2.071 27.737v-2.443h-2.43v.822h1.331v1.27a1.19 1.19 0 0 1-.224.175c-.094.059-.221.11-.382.154a2.579 2.579 0 0 1-.62.062c-.258 0-.489-.047-.694-.14a1.408 1.408 0 0 1-.523-.427 2.062 2.062 0 0 1-.325-.69 3.614 3.614 0 0 1-.11-.936v-.453c0-.346.032-.653.097-.923.064-.27.16-.498.285-.685.13-.188.29-.33.484-.426.193-.097.417-.146.672-.146.296 0 .536.052.72.154.188.1.332.238.431.413.103.176.172.375.207.598h1.081a2.633 2.633 0 0 0-.356-1.055 1.913 1.913 0 0 0-.8-.72c-.343-.176-.776-.264-1.3-.264-.41 0-.778.069-1.104.206a2.204 2.204 0 0 0-.826.598 2.742 2.742 0 0 0-.527.967c-.12.378-.18.809-.18 1.292v.444c0 .486.066.92.197 1.3.132.378.318.7.559.963.243.264.531.464.865.602.334.135.702.202 1.103.202.472 0 .866-.051 1.182-.154.317-.102.57-.224.76-.364a2.13 2.13 0 0 0 .427-.396Zm-13.03-1.094v-4.478h1.099v4.478c0 .425-.091.786-.273 1.085-.181.3-.429.528-.742.686-.314.158-.67.237-1.068.237-.407 0-.77-.069-1.086-.206a1.622 1.622 0 0 1-.738-.633C8.09 37.45 8 37.09 8 36.654h1.107c0 .252.04.455.12.61a.755.755 0 0 0 .342.335c.15.067.324.1.523.1a.99.99 0 0 0 .505-.127.909.909 0 0 0 .352-.382c.085-.17.127-.378.127-.624Zm4.799-.466h-1.327v2.386h-1.103v-6.398h2.43c.495 0 .916.088 1.261.264.349.172.614.413.796.72.181.305.272.654.272 1.046 0 .413-.09.768-.272 1.064a1.753 1.753 0 0 1-.796.68c-.345.159-.766.238-1.261.238Zm-1.327-3.133v2.259h1.327c.29 0 .524-.047.703-.141a.876.876 0 0 0 .391-.387c.085-.167.128-.357.128-.571 0-.202-.043-.391-.128-.567a.97.97 0 0 0-.39-.43c-.18-.109-.414-.163-.704-.163h-1.327Z",
|
|
2205
|
+
fill: "#051942"
|
|
2206
2206
|
}));
|
|
2207
2207
|
|
|
2208
|
-
const
|
|
2208
|
+
const SvgListItemPng = ({
|
|
2209
2209
|
title,
|
|
2210
2210
|
titleId,
|
|
2211
2211
|
...props
|
|
@@ -2221,18 +2221,18 @@ const SvgListItemPdf = ({
|
|
|
2221
2221
|
}, title) : null, /*#__PURE__*/React.createElement("path", {
|
|
2222
2222
|
fillRule: "evenodd",
|
|
2223
2223
|
clipRule: "evenodd",
|
|
2224
|
-
d: "
|
|
2224
|
+
d: "m31.873 10.655-.011-.014c-.007-.01-.014-.018-.021-.025a.356.356 0 0 0-.052-.058L21.396.21 21.37.188l-.025-.021a.476.476 0 0 0-.029-.025l-.029-.026L21.178 0H2.91C2.138 0 1.398.305.852.848A2.891 2.891 0 0 0 0 2.897v36.206c0 .768.306 1.505.852 2.049A2.917 2.917 0 0 0 2.909 42h26.182c.771 0 1.511-.305 2.057-.848.546-.544.852-1.28.852-2.049V10.775l-.116-.108a.21.21 0 0 1-.01-.012Zm-1.327 28.449a1.45 1.45 0 0 1-.427 1.022 1.463 1.463 0 0 1-1.028.426H2.91a1.463 1.463 0 0 1-1.027-.426 1.45 1.45 0 0 1-.427-1.022V27.85h9.986l1.963 2.238a.716.716 0 0 0 .546.246h16.596v8.77ZM5.088 18.357a.724.724 0 1 1 0-1.448h21.825a.724.724 0 1 1 0 1.448H5.088Zm21.825 1.738a.724.724 0 0 1 0 1.448H15.48a.724.724 0 0 1 0-1.448h11.432Zm.724-5.641c0 .4-.325.724-.724.724H5.088a.724.724 0 1 1 0-1.449h21.825c.4 0 .724.325.724.725ZM5.088 11.99a.724.724 0 1 1 0-1.448H16.52a.724.724 0 0 1 0 1.449H5.088Zm17.974-1.643A1.451 1.451 0 0 1 21.607 8.9V2.47l7.913 7.878h-6.458ZM9.103 36.012h1.327c.495 0 .916-.079 1.261-.237.349-.158.614-.385.796-.681.181-.296.272-.65.272-1.064 0-.392-.09-.74-.272-1.046a1.85 1.85 0 0 0-.796-.72c-.345-.176-.766-.264-1.26-.264H8v6.398h1.103v-2.386Zm0-.874v-2.26h1.327c.29 0 .525.055.703.163.179.109.31.253.391.431.085.176.128.365.128.567 0 .214-.043.404-.128.571a.877.877 0 0 1-.39.387c-.18.094-.414.14-.704.14H9.103ZM13.7 32h1.09l3.292 5.106a63.566 63.566 0 0 1-.044-1.379V32h.956v6.398h-1.1l-3.303-4.9.002.044c.012.134.02.279.027.435l.018.468c.006.163.009.327.009.49v3.463H13.7V32Zm11.393 5.66v-2.443h-2.43v.822h1.332v1.27a1.19 1.19 0 0 1-.225.175c-.093.059-.22.11-.382.154a2.578 2.578 0 0 1-.62.062c-.257 0-.489-.047-.694-.14a1.408 1.408 0 0 1-.523-.427 2.062 2.062 0 0 1-.325-.69 3.614 3.614 0 0 1-.11-.936v-.453c0-.346.032-.653.097-.923.064-.27.16-.498.285-.685.13-.188.29-.33.484-.426.193-.097.417-.146.672-.146.296 0 .536.052.721.154.188.1.331.238.43.413a1.7 1.7 0 0 1 .207.598h1.081a2.633 2.633 0 0 0-.356-1.055 1.913 1.913 0 0 0-.8-.72c-.342-.176-.776-.264-1.3-.264-.41 0-.778.069-1.103.206a2.204 2.204 0 0 0-.826.598 2.742 2.742 0 0 0-.528.967c-.12.378-.18.809-.18 1.292v.444c0 .486.066.92.198 1.3.132.378.318.7.558.963.243.264.532.464.866.602.334.135.701.202 1.103.202.471 0 .865-.051 1.182-.154.316-.102.57-.224.76-.364.193-.144.335-.276.426-.396Z",
|
|
2225
2225
|
fill: "#051942"
|
|
2226
2226
|
}));
|
|
2227
2227
|
|
|
2228
|
-
const
|
|
2228
|
+
const SvgListItemJpeg = ({
|
|
2229
2229
|
title,
|
|
2230
2230
|
titleId,
|
|
2231
2231
|
...props
|
|
2232
2232
|
}) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
2233
|
-
width: "
|
|
2233
|
+
width: "33",
|
|
2234
2234
|
height: "42",
|
|
2235
|
-
viewBox: "0 0
|
|
2235
|
+
viewBox: "0 0 33 42",
|
|
2236
2236
|
fill: "none",
|
|
2237
2237
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2238
2238
|
"aria-labelledby": titleId
|
|
@@ -2241,7 +2241,7 @@ const SvgListItemJpg = ({
|
|
|
2241
2241
|
}, title) : null, /*#__PURE__*/React.createElement("path", {
|
|
2242
2242
|
fillRule: "evenodd",
|
|
2243
2243
|
clipRule: "evenodd",
|
|
2244
|
-
d: "
|
|
2244
|
+
d: "m32.384 10.667-.022-.026-.021-.025a.356.356 0 0 0-.052-.058L21.896.21 21.87.188l-.025-.021-.029-.026a.477.477 0 0 1-.029-.025L21.678 0H3.41c-.771 0-1.511.305-2.057.848A2.891 2.891 0 0 0 .5 2.897v36.206c0 .768.306 1.505.852 2.049A2.917 2.917 0 0 0 3.409 42h26.182c.771 0 1.511-.305 2.057-.848.546-.544.852-1.28.852-2.049V10.775l-.116-.108Zm-1.338 28.437a1.45 1.45 0 0 1-.427 1.022 1.463 1.463 0 0 1-1.028.426H3.41a1.463 1.463 0 0 1-1.027-.426 1.45 1.45 0 0 1-.427-1.022V27.85h9.986l1.963 2.238a.716.716 0 0 0 .546.246h16.596v8.77ZM5.588 18.357a.724.724 0 1 1 0-1.448h21.825a.724.724 0 1 1 0 1.448H5.588Zm21.825 1.738a.724.724 0 0 1 0 1.448H15.98a.724.724 0 0 1 0-1.448h11.432Zm.724-5.641c0 .4-.325.724-.724.724H5.588a.724.724 0 1 1 0-1.449h21.825c.4 0 .724.325.724.725ZM5.588 11.99a.724.724 0 1 1 0-1.448H17.02a.724.724 0 0 1 0 1.449H5.588Zm17.974-1.643A1.451 1.451 0 0 1 22.107 8.9V2.47l7.913 7.878h-6.458ZM8.576 32.088v4.478c0 .246-.042.454-.127.624a.91.91 0 0 1-.352.382.99.99 0 0 1-.505.128c-.2 0-.374-.034-.523-.101a.755.755 0 0 1-.343-.334c-.079-.156-.119-.36-.119-.611H5.5c0 .436.09.797.268 1.08.179.285.425.496.738.634.317.137.679.206 1.086.206.398 0 .754-.079 1.068-.237.313-.158.56-.387.742-.686.182-.299.273-.66.273-1.085v-4.478H8.576Zm3.472 4.012h1.327c.495 0 .915-.079 1.261-.237.349-.158.614-.386.796-.681.181-.296.272-.65.272-1.064 0-.392-.09-.741-.272-1.046a1.849 1.849 0 0 0-.796-.72c-.345-.176-.766-.264-1.261-.264h-2.43v6.398h1.103V36.1Zm0-.874v-2.26h1.327c.29 0 .524.055.703.163a.97.97 0 0 1 .391.431c.085.176.128.365.128.567 0 .214-.043.404-.128.571a.876.876 0 0 1-.39.387c-.18.094-.414.14-.704.14h-1.327Zm14.545.087v2.444c-.09.12-.233.252-.426.395-.19.141-.444.263-.76.365-.317.103-.71.154-1.182.154-.402 0-.77-.068-1.103-.202a2.415 2.415 0 0 1-.866-.602 2.755 2.755 0 0 1-.558-.963 3.964 3.964 0 0 1-.198-1.3v-.444c0-.484.06-.914.18-1.292.123-.381.299-.703.527-.967.229-.264.504-.463.827-.598a2.805 2.805 0 0 1 1.103-.206c.524 0 .958.088 1.3.263.346.173.613.413.8.721.188.308.307.66.356 1.055h-1.08a1.7 1.7 0 0 0-.207-.598 1.046 1.046 0 0 0-.431-.413c-.185-.102-.425-.154-.72-.154-.256 0-.48.049-.673.145a1.271 1.271 0 0 0-.483.426 2.093 2.093 0 0 0-.286.686c-.065.27-.097.577-.097.923v.452c0 .352.037.664.11.937.076.272.185.502.325.69.144.187.318.33.523.426.205.093.437.14.695.14.252 0 .458-.02.62-.061.16-.044.288-.095.381-.154.097-.062.172-.12.225-.176v-1.27h-1.332v-.822h2.43ZM16.7 32.085h3.791v.884h-2.78v1.754h2.618v.875H17.71v2.033h2.781v.884h-3.79v-6.43Z",
|
|
2245
2245
|
fill: "#051942"
|
|
2246
2246
|
}));
|
|
2247
2247
|
|
|
@@ -2263,6 +2263,206 @@ const SvgListItemDelete = ({
|
|
|
2263
2263
|
fill: "#051942"
|
|
2264
2264
|
}));
|
|
2265
2265
|
|
|
2266
|
+
const FileItem = /*#__PURE__*/React__default.memo(({
|
|
2267
|
+
size,
|
|
2268
|
+
name,
|
|
2269
|
+
uuid,
|
|
2270
|
+
check,
|
|
2271
|
+
radius,
|
|
2272
|
+
status,
|
|
2273
|
+
removeFile,
|
|
2274
|
+
fileFormat,
|
|
2275
|
+
progressColor,
|
|
2276
|
+
listItemHeight,
|
|
2277
|
+
listItemPadding,
|
|
2278
|
+
progressFontSize,
|
|
2279
|
+
listItemErrorSize,
|
|
2280
|
+
listItemErrorColor,
|
|
2281
|
+
progressTrackColor,
|
|
2282
|
+
progressFailedColor,
|
|
2283
|
+
progressSuccessColor,
|
|
2284
|
+
progressLoadingColor,
|
|
2285
|
+
listItemBackgroundColor,
|
|
2286
|
+
listItemBackgroundErrorColor
|
|
2287
|
+
}) => {
|
|
2288
|
+
const [i, setI] = useState(_ => _);
|
|
2289
|
+
const [t, setT] = useState(_ => _);
|
|
2290
|
+
const [progress, setProgress] = useState(7);
|
|
2291
|
+
const handleRemoveItem = id => {
|
|
2292
|
+
removeFile(id);
|
|
2293
|
+
};
|
|
2294
|
+
useEffect(() => {
|
|
2295
|
+
let time = Math.floor(Math.random() * (1100 - 900 + 1)) + 900;
|
|
2296
|
+
let fileSizeInMB = Math.round(size / (1024 * 1024));
|
|
2297
|
+
if (fileSizeInMB > 5) {
|
|
2298
|
+
const times = [Math.floor(Math.random() * (1700 - 1300 + 1)) + 1300, Math.floor(Math.random() * (3200 - 2800 + 1)) + 2800, Math.floor(Math.random() * (4700 - 4300 + 1)) + 4300, Math.floor(Math.random() * (6200 - 5800 + 1)) + 5800, Math.floor(Math.random() * (7700 - 7300 + 1)) + 7300];
|
|
2299
|
+
const index = Math.min(Math.floor((size - 1) / 15), times.length - 1);
|
|
2300
|
+
time = times[index];
|
|
2301
|
+
}
|
|
2302
|
+
setI(setInterval(() => {
|
|
2303
|
+
setProgress(prev => {
|
|
2304
|
+
return prev += 7;
|
|
2305
|
+
});
|
|
2306
|
+
}, time));
|
|
2307
|
+
return () => {
|
|
2308
|
+
setI(_ => _);
|
|
2309
|
+
clearTimeout(t);
|
|
2310
|
+
clearInterval(i);
|
|
2311
|
+
};
|
|
2312
|
+
}, []);
|
|
2313
|
+
useEffect(() => {
|
|
2314
|
+
if (progress > 84) {
|
|
2315
|
+
clearInterval(i);
|
|
2316
|
+
}
|
|
2317
|
+
}, [progress]);
|
|
2318
|
+
useEffect(() => {
|
|
2319
|
+
if (status === 'success') {
|
|
2320
|
+
setProgress(100);
|
|
2321
|
+
clearInterval(i);
|
|
2322
|
+
}
|
|
2323
|
+
if (status === 'failed') {
|
|
2324
|
+
setProgress(0);
|
|
2325
|
+
clearInterval(i);
|
|
2326
|
+
}
|
|
2327
|
+
}, [status]);
|
|
2328
|
+
useEffect(() => {
|
|
2329
|
+
if (check !== '') {
|
|
2330
|
+
setT(setTimeout(() => {
|
|
2331
|
+
removeFile(uuid);
|
|
2332
|
+
}, 3500));
|
|
2333
|
+
}
|
|
2334
|
+
}, [check]);
|
|
2335
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2336
|
+
style: {
|
|
2337
|
+
width: '100%',
|
|
2338
|
+
display: 'flex',
|
|
2339
|
+
marginTop: '6px',
|
|
2340
|
+
alignItems: 'center',
|
|
2341
|
+
borderRadius: radius,
|
|
2342
|
+
height: listItemHeight,
|
|
2343
|
+
boxSizing: 'border-box',
|
|
2344
|
+
padding: listItemPadding,
|
|
2345
|
+
flexDirection: check !== '' ? 'column' : 'row',
|
|
2346
|
+
justifyContent: check !== '' ? 'space-around' : 'space-between',
|
|
2347
|
+
backgroundColor: check !== '' ? listItemBackgroundErrorColor : listItemBackgroundColor
|
|
2348
|
+
}
|
|
2349
|
+
}, check !== '' ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("p", {
|
|
2350
|
+
style: {
|
|
2351
|
+
margin: '0px',
|
|
2352
|
+
color: listItemErrorColor,
|
|
2353
|
+
fontSize: listItemErrorSize
|
|
2354
|
+
}
|
|
2355
|
+
}, name), /*#__PURE__*/React__default.createElement("p", {
|
|
2356
|
+
style: {
|
|
2357
|
+
margin: '0px',
|
|
2358
|
+
color: listItemErrorColor,
|
|
2359
|
+
fontSize: listItemErrorSize
|
|
2360
|
+
}
|
|
2361
|
+
}, check)) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
2362
|
+
style: {
|
|
2363
|
+
width: '32px'
|
|
2364
|
+
}
|
|
2365
|
+
}, fileFormat === 'pdf' ? /*#__PURE__*/React__default.createElement(SvgListItemPdf, null) : fileFormat === 'jpg' ? /*#__PURE__*/React__default.createElement(SvgListItemJpg, null) : fileFormat === 'png' ? /*#__PURE__*/React__default.createElement(SvgListItemPng, null) : fileFormat === 'jpeg' ? /*#__PURE__*/React__default.createElement(SvgListItemJpeg, null) : ''), /*#__PURE__*/React__default.createElement("div", {
|
|
2366
|
+
style: {
|
|
2367
|
+
position: 'relative',
|
|
2368
|
+
display: 'flex',
|
|
2369
|
+
height: '40px',
|
|
2370
|
+
margin: '0px 14px',
|
|
2371
|
+
alignItems: 'flex-end',
|
|
2372
|
+
width: 'calc(100% - 82px)'
|
|
2373
|
+
}
|
|
2374
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2375
|
+
style: {
|
|
2376
|
+
width: '100%',
|
|
2377
|
+
height: '100%',
|
|
2378
|
+
display: 'flex',
|
|
2379
|
+
paddingTop: '5px',
|
|
2380
|
+
color: progressColor,
|
|
2381
|
+
boxSizing: 'border-box',
|
|
2382
|
+
alignItems: 'flex-start',
|
|
2383
|
+
fontSize: progressFontSize,
|
|
2384
|
+
justifyContent: 'space-between'
|
|
2385
|
+
}
|
|
2386
|
+
}, /*#__PURE__*/React__default.createElement("p", {
|
|
2387
|
+
style: {
|
|
2388
|
+
margin: '0px',
|
|
2389
|
+
overflow: 'hidden',
|
|
2390
|
+
whiteSpace: 'nowrap',
|
|
2391
|
+
textOverflow: 'ellipsis',
|
|
2392
|
+
maxWidth: 'calc(100% - 56px)'
|
|
2393
|
+
}
|
|
2394
|
+
}, name), /*#__PURE__*/React__default.createElement("span", null, progress, " %")), /*#__PURE__*/React__default.createElement("div", {
|
|
2395
|
+
style: {
|
|
2396
|
+
position: 'absolute',
|
|
2397
|
+
left: '0px',
|
|
2398
|
+
bottom: '5px',
|
|
2399
|
+
width: '100%',
|
|
2400
|
+
height: '4px',
|
|
2401
|
+
borderRadius: '10px',
|
|
2402
|
+
backgroundColor: progressTrackColor
|
|
2403
|
+
}
|
|
2404
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2405
|
+
style: {
|
|
2406
|
+
height: '100%',
|
|
2407
|
+
borderRadius: '10px',
|
|
2408
|
+
width: status === 'failed' ? '100%' : progress + '%',
|
|
2409
|
+
backgroundColor: status === 'success' ? progressSuccessColor : status === 'failed' ? progressFailedColor : progressLoadingColor
|
|
2410
|
+
}
|
|
2411
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
2412
|
+
style: {
|
|
2413
|
+
width: '22px',
|
|
2414
|
+
cursor: 'pointer'
|
|
2415
|
+
},
|
|
2416
|
+
onClick: () => handleRemoveItem(uuid)
|
|
2417
|
+
}, /*#__PURE__*/React__default.createElement(SvgListItemDelete, null))));
|
|
2418
|
+
});
|
|
2419
|
+
|
|
2420
|
+
const SvgUpload = ({
|
|
2421
|
+
title,
|
|
2422
|
+
titleId,
|
|
2423
|
+
...props
|
|
2424
|
+
}) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
2425
|
+
width: "51",
|
|
2426
|
+
height: "35",
|
|
2427
|
+
viewBox: "0 0 51 35",
|
|
2428
|
+
fill: "none",
|
|
2429
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2430
|
+
"aria-labelledby": titleId
|
|
2431
|
+
}, props), title ? /*#__PURE__*/React.createElement("title", {
|
|
2432
|
+
id: titleId
|
|
2433
|
+
}, title) : null, /*#__PURE__*/React.createElement("path", {
|
|
2434
|
+
d: "M41.54 11.842h-.017c-.23-3.225-2.902-5.772-6.167-5.772-1.08 0-2.095.28-2.979.77C30.267 2.774 26.041 0 21.167 0 14.318 0 8.742 5.483 8.534 12.326 3.758 12.708 0 16.726 0 21.63c0 5.155 4.153 9.334 9.277 9.334h22.625a10.987 10.987 0 0 1-.888-4.334c0-6.059 4.899-10.987 10.918-10.987 3.773 0 7.106 1.938 9.068 4.875-.444-4.864-4.508-8.675-9.46-8.675ZM15.654 6.975c-.072.06-.144.12-.211.185-.266.259-.512.53-.705.849-.741 1.218-.882 2.523-.72 3.927.156 1.35-1.942 1.334-2.095 0-.289-2.493.504-5.307 2.664-6.775 1.12-.763 2.164 1.052 1.067 1.814Zm-.022.015c-.047.035-.111.093 0 0Z",
|
|
2435
|
+
fill: "#D1D1D1"
|
|
2436
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
2437
|
+
fillRule: "evenodd",
|
|
2438
|
+
clipRule: "evenodd",
|
|
2439
|
+
d: "M41.822 17.245c-4.864 0-8.822 3.982-8.822 8.878C33 31.018 36.958 35 41.822 35c4.864 0 8.822-3.982 8.822-8.877 0-4.896-3.959-8.878-8.822-8.878Zm-.536 13.005v-6.689l-3.067 3.22a.69.69 0 0 1-1.01 0 .777.777 0 0 1 0-1.06l4.286-4.5A.71.71 0 0 1 42 21a.684.684 0 0 1 .505.22l4.286 4.5a.777.777 0 0 1 0 1.06.69.69 0 0 1-1.01 0l-3.067-3.22v6.69c0 .414-.32.75-.714.75-.395 0-.714-.336-.714-.75Z",
|
|
2440
|
+
fill: "#0DA574"
|
|
2441
|
+
}));
|
|
2442
|
+
|
|
2443
|
+
const SvgRemoveFile = ({
|
|
2444
|
+
title,
|
|
2445
|
+
titleId,
|
|
2446
|
+
...props
|
|
2447
|
+
}) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
2448
|
+
width: "26",
|
|
2449
|
+
height: "26",
|
|
2450
|
+
viewBox: "0 0 26 26",
|
|
2451
|
+
fill: "none",
|
|
2452
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2453
|
+
"aria-labelledby": titleId
|
|
2454
|
+
}, props), title ? /*#__PURE__*/React.createElement("title", {
|
|
2455
|
+
id: titleId
|
|
2456
|
+
}, title) : null, /*#__PURE__*/React.createElement("rect", {
|
|
2457
|
+
width: 26,
|
|
2458
|
+
height: 26,
|
|
2459
|
+
rx: 6,
|
|
2460
|
+
fill: "#FBFBFB"
|
|
2461
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
2462
|
+
d: "M13 4c.822 0 1.611.296 2.206.826s.95 1.255.99 2.024l.005.15h4c.204 0 .4.073.548.205.148.13.238.31.25.501a.72.72 0 0 1-.185.525.817.817 0 0 1-.52.264l-.093.005h-.68l-.943 10.915a2.75 2.75 0 0 1-.957 1.84 3.114 3.114 0 0 1-2.034.745h-5.173c-.754 0-1.48-.266-2.034-.745a2.75 2.75 0 0 1-.957-1.84L6.478 8.5H5.8a.831.831 0 0 1-.531-.19.736.736 0 0 1-.263-.472L5 7.75c0-.184.072-.361.202-.498a.818.818 0 0 1 .504-.247L5.8 7h4c0-.796.337-1.559.938-2.121A3.312 3.312 0 0 1 13 4Zm-1.8 6.938a.623.623 0 0 0-.394.138.553.553 0 0 0-.2.348l-.006.076v6l.006.076c.02.135.09.258.2.348.11.09.25.138.394.138.145 0 .285-.049.395-.138.109-.09.18-.213.2-.348l.005-.076v-6l-.005-.076a.553.553 0 0 0-.2-.348.624.624 0 0 0-.395-.139Zm3.6 0a.623.623 0 0 0-.394.138.553.553 0 0 0-.2.348l-.005.076v6l.005.076c.02.135.091.258.2.348.11.09.25.138.394.138.145 0 .286-.049.395-.138.11-.09.18-.213.2-.348l.006-.076v-6l-.006-.076a.553.553 0 0 0-.2-.348.624.624 0 0 0-.395-.139ZM13 5.5a1.66 1.66 0 0 0-1.088.4c-.296.257-.477.61-.508.987L11.4 7h3.2l-.003-.112a1.465 1.465 0 0 0-.508-.988A1.66 1.66 0 0 0 13 5.5Z",
|
|
2463
|
+
fill: "#00236A"
|
|
2464
|
+
}));
|
|
2465
|
+
|
|
2266
2466
|
const SvgDeleteComponent = ({
|
|
2267
2467
|
title,
|
|
2268
2468
|
titleId,
|
|
@@ -2289,6 +2489,7 @@ const SvgDeleteComponent = ({
|
|
|
2289
2489
|
}));
|
|
2290
2490
|
|
|
2291
2491
|
const NewFile = ({
|
|
2492
|
+
or,
|
|
2292
2493
|
size,
|
|
2293
2494
|
name,
|
|
2294
2495
|
color,
|
|
@@ -2299,36 +2500,52 @@ const NewFile = ({
|
|
|
2299
2500
|
radius,
|
|
2300
2501
|
change,
|
|
2301
2502
|
border,
|
|
2503
|
+
upload,
|
|
2302
2504
|
maxSize,
|
|
2303
2505
|
disabled,
|
|
2304
2506
|
multiple,
|
|
2305
2507
|
required,
|
|
2306
2508
|
errorSize,
|
|
2307
2509
|
labelSize,
|
|
2510
|
+
removeFile,
|
|
2308
2511
|
labelColor,
|
|
2309
2512
|
errorColor,
|
|
2310
2513
|
filesArray,
|
|
2514
|
+
putFileHere,
|
|
2311
2515
|
borderColor,
|
|
2312
2516
|
uploadColor,
|
|
2313
2517
|
defaultData,
|
|
2314
2518
|
errorMessage,
|
|
2519
|
+
fileSizeText,
|
|
2520
|
+
progressColor,
|
|
2315
2521
|
fileExtensions,
|
|
2522
|
+
listItemHeight,
|
|
2316
2523
|
backgroundColor,
|
|
2317
2524
|
deleteComponent,
|
|
2525
|
+
listItemPadding,
|
|
2526
|
+
progressFontSize,
|
|
2318
2527
|
borderHoverColor,
|
|
2528
|
+
listItemErrorSize,
|
|
2319
2529
|
progressTrackColor,
|
|
2530
|
+
fileAreaImageWidth,
|
|
2531
|
+
listItemErrorColor,
|
|
2320
2532
|
labelRequiredColor,
|
|
2533
|
+
progressFailedColor,
|
|
2534
|
+
fileAreaImageHeight,
|
|
2535
|
+
progressSuccessColor,
|
|
2536
|
+
progressLoadingColor,
|
|
2321
2537
|
hiddenBackgroundColor,
|
|
2322
2538
|
extentionsRowMarginTop,
|
|
2323
|
-
listItemBackgroundColor
|
|
2539
|
+
listItemBackgroundColor,
|
|
2540
|
+
listItemBackgroundErrorColor
|
|
2324
2541
|
}) => {
|
|
2325
2542
|
const ref = useRef(null);
|
|
2326
2543
|
const inpRef = useRef(null);
|
|
2544
|
+
const memoizedItems = useMemo(() => filesArray, [filesArray]);
|
|
2327
2545
|
const [error, setError] = useState('');
|
|
2328
|
-
const [image, setImage] = useState('');
|
|
2329
|
-
const [progress, setProgress] = useState(5);
|
|
2330
2546
|
const [isHover, setIsHover] = useState(false);
|
|
2331
|
-
const [
|
|
2547
|
+
const [singleFile, setSingleFile] = useState(null);
|
|
2548
|
+
const [image, setImage] = useState(!multiple ? defaultData ? defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf' : null : null);
|
|
2332
2549
|
const configStyles = compereConfigs();
|
|
2333
2550
|
const handleRemoveComponent = () => {
|
|
2334
2551
|
const node = ReactDOM.findDOMNode(ref.current);
|
|
@@ -2336,44 +2553,67 @@ const NewFile = ({
|
|
|
2336
2553
|
parent.removeChild(node);
|
|
2337
2554
|
};
|
|
2338
2555
|
const handleRemoveFile = () => {
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
onChange(null);
|
|
2342
|
-
}
|
|
2556
|
+
setImage(null);
|
|
2557
|
+
removeFile(singleFile);
|
|
2343
2558
|
};
|
|
2344
2559
|
const handleChange = e => {
|
|
2345
2560
|
const file = e.target.files;
|
|
2346
|
-
if (
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2561
|
+
if (multiple) {
|
|
2562
|
+
setError('');
|
|
2563
|
+
setImage(null);
|
|
2564
|
+
for (let ix = 0; ix < file.length; ix++) {
|
|
2565
|
+
if (file[ix]) {
|
|
2566
|
+
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
2567
|
+
if (fileExtensions.includes(file[ix].type.split('/')[1])) {
|
|
2568
|
+
change({
|
|
2569
|
+
id: '',
|
|
2570
|
+
check: '',
|
|
2571
|
+
status: '',
|
|
2572
|
+
file: file[ix],
|
|
2573
|
+
uuid: v4()
|
|
2574
|
+
});
|
|
2575
|
+
} else {
|
|
2576
|
+
change({
|
|
2577
|
+
file: file[ix],
|
|
2578
|
+
uuid: v4(),
|
|
2579
|
+
check: 'ֆայլի սխալ ֆորմատ'
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2355
2582
|
} else {
|
|
2356
2583
|
change({
|
|
2357
|
-
file
|
|
2584
|
+
file: file[ix],
|
|
2585
|
+
uuid: v4(),
|
|
2586
|
+
check: 'առավելագույն ծավալ'
|
|
2358
2587
|
});
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
if (file.length === 0 && memoizedItems.length === 0) {
|
|
2592
|
+
setError('Ֆայլը ընտրված չէ');
|
|
2593
|
+
}
|
|
2594
|
+
} else {
|
|
2595
|
+
if (file[0]) {
|
|
2596
|
+
if (file[0].size <= maxSize * Math.pow(2, 20)) {
|
|
2597
|
+
if (fileExtensions.includes(file[0].type.split('/')[1])) {
|
|
2598
|
+
setError('');
|
|
2599
|
+
change(file);
|
|
2600
|
+
setSingleFile(file);
|
|
2359
2601
|
if (file[0].type === 'application/pdf') {
|
|
2360
2602
|
setImage('pdf');
|
|
2361
2603
|
} else {
|
|
2362
2604
|
setImage(URL.createObjectURL(file[0]));
|
|
2363
2605
|
}
|
|
2606
|
+
} else {
|
|
2607
|
+
setImage(null);
|
|
2608
|
+
setError('ֆայլի սխալ ֆորմատ');
|
|
2364
2609
|
}
|
|
2365
2610
|
} else {
|
|
2366
|
-
setImage(
|
|
2367
|
-
setError('
|
|
2611
|
+
setImage(null);
|
|
2612
|
+
setError('առավելագույն ծավալ');
|
|
2368
2613
|
}
|
|
2369
|
-
} else {
|
|
2370
|
-
setImage('');
|
|
2371
|
-
setError('առավելագույն ծավալ');
|
|
2372
2614
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
if (!multiple || multiple && filesArray && filesArray.length === 0) {
|
|
2376
|
-
setImage('');
|
|
2615
|
+
if (file.length === 0) {
|
|
2616
|
+
setImage(null);
|
|
2377
2617
|
setError('Ֆայլը ընտրված չէ');
|
|
2378
2618
|
}
|
|
2379
2619
|
}
|
|
@@ -2383,6 +2623,21 @@ const NewFile = ({
|
|
|
2383
2623
|
inpRef.current.click();
|
|
2384
2624
|
}
|
|
2385
2625
|
};
|
|
2626
|
+
const handleDrop = e => {
|
|
2627
|
+
if (!disabled) {
|
|
2628
|
+
e.preventDefault();
|
|
2629
|
+
handleChange({
|
|
2630
|
+
target: {
|
|
2631
|
+
files: e.dataTransfer.files
|
|
2632
|
+
}
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
};
|
|
2636
|
+
const handleDragOver = e => {
|
|
2637
|
+
if (!disabled) {
|
|
2638
|
+
e.preventDefault();
|
|
2639
|
+
}
|
|
2640
|
+
};
|
|
2386
2641
|
const handleMouseEnter = () => {
|
|
2387
2642
|
setIsHover(true);
|
|
2388
2643
|
};
|
|
@@ -2394,17 +2649,18 @@ const NewFile = ({
|
|
|
2394
2649
|
};
|
|
2395
2650
|
useEffect(() => {
|
|
2396
2651
|
if (!multiple && defaultData) {
|
|
2397
|
-
if (defaultData.type
|
|
2398
|
-
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2652
|
+
if (!defaultData.type) {
|
|
2653
|
+
alert('Please add type in defaultData prop');
|
|
2654
|
+
}
|
|
2655
|
+
if (!defaultData.url) {
|
|
2656
|
+
alert('Please add url in defaultData prop');
|
|
2401
2657
|
}
|
|
2402
2658
|
}
|
|
2403
2659
|
if (multiple && !filesArray) {
|
|
2404
2660
|
alert('In multiple mode, you should add filesArray prop for drawing files');
|
|
2405
2661
|
}
|
|
2406
|
-
if (
|
|
2407
|
-
|
|
2662
|
+
if (multiple) {
|
|
2663
|
+
setSingleFile(null);
|
|
2408
2664
|
}
|
|
2409
2665
|
}, [multiple, filesArray && filesArray.length, defaultData]);
|
|
2410
2666
|
useEffect(() => {
|
|
@@ -2418,8 +2674,10 @@ const NewFile = ({
|
|
|
2418
2674
|
if (!change) {
|
|
2419
2675
|
alert('Please add change prop on File component');
|
|
2420
2676
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2677
|
+
if (!removeFile) {
|
|
2678
|
+
alert('Please add removeFile prop on File component');
|
|
2679
|
+
}
|
|
2680
|
+
}, [change, removeFile]);
|
|
2423
2681
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2424
2682
|
ref: ref,
|
|
2425
2683
|
style: {
|
|
@@ -2461,7 +2719,9 @@ const NewFile = ({
|
|
|
2461
2719
|
backgroundColor: backgroundColor ? backgroundColor : configStyles.File.backgroundColor,
|
|
2462
2720
|
borderColor: error ? errorColor ? errorColor : configStyles.File.errorColor : disabled ? borderColor ? borderColor : configStyles.File.borderColor : isHover ? borderHoverColor ? borderHoverColor : configStyles.File.borderHoverColor : borderColor ? borderColor : configStyles.File.borderColor
|
|
2463
2721
|
},
|
|
2722
|
+
onDrop: handleDrop,
|
|
2464
2723
|
onClick: handleClick,
|
|
2724
|
+
onDragOver: handleDragOver,
|
|
2465
2725
|
onMouseEnter: handleMouseEnter,
|
|
2466
2726
|
onMouseLeave: handleMouseLeave
|
|
2467
2727
|
}, /*#__PURE__*/React__default.createElement("input", {
|
|
@@ -2470,6 +2730,7 @@ const NewFile = ({
|
|
|
2470
2730
|
type: "file",
|
|
2471
2731
|
ref: inpRef,
|
|
2472
2732
|
disabled: disabled,
|
|
2733
|
+
multiple: multiple,
|
|
2473
2734
|
onChange: handleChange
|
|
2474
2735
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
2475
2736
|
style: {
|
|
@@ -2484,21 +2745,26 @@ const NewFile = ({
|
|
|
2484
2745
|
fontSize: size ? size : configStyles.File.size,
|
|
2485
2746
|
fontWeight: weight ? weight : configStyles.File.weight
|
|
2486
2747
|
}
|
|
2487
|
-
}, !multiple && image ? image === 'pdf' ? /*#__PURE__*/React__default.createElement(
|
|
2748
|
+
}, !multiple && image ? image === 'pdf' ? /*#__PURE__*/React__default.createElement(SvgPdf, null) : /*#__PURE__*/React__default.createElement("img", {
|
|
2488
2749
|
src: image,
|
|
2489
2750
|
style: {
|
|
2490
|
-
|
|
2751
|
+
display: 'block',
|
|
2752
|
+
maxWidth: '100%',
|
|
2753
|
+
maxHeight: '95%',
|
|
2754
|
+
objectFit: 'contain',
|
|
2755
|
+
width: fileAreaImageWidth ? fileAreaImageWidth : configStyles.File.fileAreaImageWidth,
|
|
2756
|
+
height: fileAreaImageHeight ? fileAreaImageHeight : configStyles.File.fileAreaImageHeight
|
|
2491
2757
|
},
|
|
2492
2758
|
alt: "file preview"
|
|
2493
2759
|
}) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SvgUpload, null)), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", {
|
|
2494
2760
|
style: {
|
|
2495
2761
|
margin: '0px'
|
|
2496
2762
|
}
|
|
2497
|
-
},
|
|
2763
|
+
}, putFileHere ? putFileHere : configStyles.File.putFileHere, /*#__PURE__*/React__default.createElement("br", null), or ? or : configStyles.File.or, " ", /*#__PURE__*/React__default.createElement("span", {
|
|
2498
2764
|
style: {
|
|
2499
2765
|
color: uploadColor ? uploadColor : configStyles.File.uploadColor
|
|
2500
2766
|
}
|
|
2501
|
-
},
|
|
2767
|
+
}, upload ? upload : configStyles.File.upload))), /*#__PURE__*/React__default.createElement("div", {
|
|
2502
2768
|
style: {
|
|
2503
2769
|
marginTop: extentionsRowMarginTop ? extentionsRowMarginTop : configStyles.File.extentionsRowMarginTop
|
|
2504
2770
|
}
|
|
@@ -2506,7 +2772,7 @@ const NewFile = ({
|
|
|
2506
2772
|
style: {
|
|
2507
2773
|
margin: '0px'
|
|
2508
2774
|
}
|
|
2509
|
-
}, "
|
|
2775
|
+
}, fileSizeText ? fileSizeText : configStyles.File.fileSizeText, " ", maxSize, "\u0544\u0532 ( ", fileExtensions.toString().split(',').join(', '), " )")))), /*#__PURE__*/React__default.createElement("div", {
|
|
2510
2776
|
style: {
|
|
2511
2777
|
position: 'absolute',
|
|
2512
2778
|
top: '0px',
|
|
@@ -2536,62 +2802,34 @@ const NewFile = ({
|
|
|
2536
2802
|
color: errorColor ? errorColor : configStyles.File.errorColor,
|
|
2537
2803
|
fontSize: errorSize ? errorSize : configStyles.File.errorSize
|
|
2538
2804
|
}
|
|
2539
|
-
}, error) : '', multiple &&
|
|
2540
|
-
return /*#__PURE__*/React__default.createElement(
|
|
2541
|
-
key:
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
margin: '0px 14px',
|
|
2564
|
-
alignItems: 'flex-end',
|
|
2565
|
-
width: 'calc(100% - 82px)'
|
|
2566
|
-
}
|
|
2567
|
-
}, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", {
|
|
2568
|
-
className: "new"
|
|
2569
|
-
}, item.file.name)), /*#__PURE__*/React__default.createElement("div", {
|
|
2570
|
-
style: {
|
|
2571
|
-
position: 'absolute',
|
|
2572
|
-
left: '0px',
|
|
2573
|
-
bottom: '5px',
|
|
2574
|
-
width: '100%',
|
|
2575
|
-
height: '4px',
|
|
2576
|
-
borderRadius: '10px',
|
|
2577
|
-
backgroundColor: progressTrackColor ? progressTrackColor : configStyles.File.progressTrackColor
|
|
2578
|
-
}
|
|
2579
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2580
|
-
style: {
|
|
2581
|
-
width: progress + '%',
|
|
2582
|
-
height: '100%',
|
|
2583
|
-
borderRadius: '10px',
|
|
2584
|
-
backgroundColor: 'green'
|
|
2585
|
-
}
|
|
2586
|
-
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
2587
|
-
style: {
|
|
2588
|
-
width: '22px',
|
|
2589
|
-
cursor: 'pointer'
|
|
2590
|
-
}
|
|
2591
|
-
}, /*#__PURE__*/React__default.createElement(SvgListItemDelete, null)));
|
|
2805
|
+
}, error) : '', multiple && memoizedItems && memoizedItems.length > 0 && memoizedItems.map(item => {
|
|
2806
|
+
return /*#__PURE__*/React__default.createElement(FileItem, {
|
|
2807
|
+
key: item.uuid,
|
|
2808
|
+
uuid: item.uuid,
|
|
2809
|
+
check: item.check,
|
|
2810
|
+
status: item.status,
|
|
2811
|
+
size: item.file.size,
|
|
2812
|
+
name: item.file.name,
|
|
2813
|
+
removeFile: removeFile,
|
|
2814
|
+
radius: radius ? radius : configStyles.File.radius,
|
|
2815
|
+
fileFormat: item.file.type.split('/')[1].toLowerCase(),
|
|
2816
|
+
progressColor: progressColor ? progressColor : configStyles.File.progressColor,
|
|
2817
|
+
listItemHeight: listItemHeight ? listItemHeight : configStyles.File.listItemHeight,
|
|
2818
|
+
listItemPadding: listItemPadding ? listItemPadding : configStyles.File.listItemPadding,
|
|
2819
|
+
progressFontSize: progressFontSize ? progressFontSize : configStyles.File.progressFontSize,
|
|
2820
|
+
listItemErrorSize: listItemErrorSize ? listItemErrorSize : configStyles.File.listItemErrorSize,
|
|
2821
|
+
listItemErrorColor: listItemErrorColor ? listItemErrorColor : configStyles.File.listItemErrorColor,
|
|
2822
|
+
progressTrackColor: progressTrackColor ? progressTrackColor : configStyles.File.progressTrackColor,
|
|
2823
|
+
progressFailedColor: progressFailedColor ? progressFailedColor : configStyles.File.progressFailedColor,
|
|
2824
|
+
progressSuccessColor: progressSuccessColor ? progressSuccessColor : configStyles.File.progressSuccessColor,
|
|
2825
|
+
progressLoadingColor: progressLoadingColor ? progressLoadingColor : configStyles.File.progressLoadingColor,
|
|
2826
|
+
listItemBackgroundColor: listItemBackgroundColor ? listItemBackgroundColor : configStyles.File.listItemBackgroundColor,
|
|
2827
|
+
listItemBackgroundErrorColor: listItemBackgroundErrorColor ? listItemBackgroundErrorColor : configStyles.File.listItemBackgroundErrorColor
|
|
2828
|
+
});
|
|
2592
2829
|
}));
|
|
2593
2830
|
};
|
|
2594
2831
|
NewFile.propTypes = {
|
|
2832
|
+
or: PropTypes.string,
|
|
2595
2833
|
size: PropTypes.string,
|
|
2596
2834
|
label: PropTypes.string,
|
|
2597
2835
|
width: PropTypes.string,
|
|
@@ -2601,30 +2839,46 @@ NewFile.propTypes = {
|
|
|
2601
2839
|
radius: PropTypes.string,
|
|
2602
2840
|
border: PropTypes.string,
|
|
2603
2841
|
required: PropTypes.bool,
|
|
2842
|
+
upload: PropTypes.string,
|
|
2604
2843
|
weight: PropTypes.number,
|
|
2605
2844
|
maxSize: PropTypes.number,
|
|
2606
2845
|
errorSize: PropTypes.string,
|
|
2607
2846
|
labelSize: PropTypes.string,
|
|
2608
2847
|
labelColor: PropTypes.string,
|
|
2609
2848
|
errorColor: PropTypes.string,
|
|
2849
|
+
putFileHere: PropTypes.string,
|
|
2610
2850
|
borderColor: PropTypes.string,
|
|
2611
2851
|
uploadColor: PropTypes.string,
|
|
2612
2852
|
defaultData: PropTypes.object,
|
|
2613
2853
|
errorMessage: PropTypes.string,
|
|
2854
|
+
fileSizeText: PropTypes.string,
|
|
2855
|
+
progressColor: PropTypes.string,
|
|
2614
2856
|
deleteComponent: PropTypes.bool,
|
|
2857
|
+
listItemHeight: PropTypes.string,
|
|
2615
2858
|
backgroundColor: PropTypes.string,
|
|
2616
2859
|
change: PropTypes.func.isRequired,
|
|
2860
|
+
listItemPadding: PropTypes.string,
|
|
2861
|
+
progressFontSize: PropTypes.string,
|
|
2617
2862
|
borderHoverColor: PropTypes.string,
|
|
2863
|
+
listItemErrorSize: PropTypes.string,
|
|
2618
2864
|
labelRequiredColor: PropTypes.string,
|
|
2619
2865
|
progressTrackColor: PropTypes.string,
|
|
2866
|
+
fileAreaImageWidth: PropTypes.string,
|
|
2867
|
+
listItemErrorColor: PropTypes.string,
|
|
2868
|
+
removeFile: PropTypes.func.isRequired,
|
|
2869
|
+
fileAreaImageHeight: PropTypes.string,
|
|
2870
|
+
progressFailedColor: PropTypes.string,
|
|
2871
|
+
progressSuccessColor: PropTypes.string,
|
|
2872
|
+
progressLoadingColor: PropTypes.string,
|
|
2620
2873
|
hiddenBackgroundColor: PropTypes.string,
|
|
2621
2874
|
extentionsRowMarginTop: PropTypes.string,
|
|
2622
2875
|
listItemBackgroundColor: PropTypes.string,
|
|
2876
|
+
listItemBackgroundErrorColor: PropTypes.string,
|
|
2623
2877
|
filesArray: PropTypes.arrayOf(PropTypes.object),
|
|
2624
2878
|
fileExtensions: PropTypes.arrayOf(PropTypes.string)
|
|
2625
2879
|
};
|
|
2626
2880
|
NewFile.defaultProps = {
|
|
2627
|
-
maxSize:
|
|
2881
|
+
maxSize: 50,
|
|
2628
2882
|
fileExtensions: ['jpg', 'jpeg', 'png', 'pdf']
|
|
2629
2883
|
};
|
|
2630
2884
|
|
|
@@ -2650,17 +2904,21 @@ const Textarea = ({
|
|
|
2650
2904
|
boxSizing,
|
|
2651
2905
|
maxLength,
|
|
2652
2906
|
labelSize,
|
|
2907
|
+
errorSize,
|
|
2653
2908
|
labelColor,
|
|
2909
|
+
errorColor,
|
|
2654
2910
|
borderColor,
|
|
2655
2911
|
labelWeight,
|
|
2656
2912
|
placeholder,
|
|
2657
2913
|
labelDisplay,
|
|
2914
|
+
errorMesaage,
|
|
2658
2915
|
backgroundColor,
|
|
2659
2916
|
borderFocusColor,
|
|
2660
2917
|
borderHoverColor,
|
|
2661
2918
|
showCharacterCount,
|
|
2662
2919
|
labelRequiredColor
|
|
2663
2920
|
}) => {
|
|
2921
|
+
const [error, setError] = useState('');
|
|
2664
2922
|
const [isHover, setIsHover] = useState(false);
|
|
2665
2923
|
const [isFocus, setIsFocus] = useState(false);
|
|
2666
2924
|
const [innerValue, setInnerValue] = useState('');
|
|
@@ -2683,10 +2941,16 @@ const Textarea = ({
|
|
|
2683
2941
|
if (maxLength) {
|
|
2684
2942
|
if (value.length > maxLength) {
|
|
2685
2943
|
onChange(value.substr(0, maxLength));
|
|
2944
|
+
setError('Նիշերի քանակը գերազանցում է');
|
|
2945
|
+
} else {
|
|
2946
|
+
setError('');
|
|
2686
2947
|
}
|
|
2687
2948
|
} else {
|
|
2688
2949
|
if (value.length > configStyles.TEXTAREA.maxLength) {
|
|
2950
|
+
setError('Նիշերի քանակը գերազանցում է');
|
|
2689
2951
|
onChange(value.substr(0, configStyles.TEXTAREA.maxLength));
|
|
2952
|
+
} else {
|
|
2953
|
+
setError('');
|
|
2690
2954
|
}
|
|
2691
2955
|
}
|
|
2692
2956
|
};
|
|
@@ -2699,6 +2963,13 @@ const Textarea = ({
|
|
|
2699
2963
|
}
|
|
2700
2964
|
setInnerValue(value);
|
|
2701
2965
|
}, [value, onChange]);
|
|
2966
|
+
useEffect(() => {
|
|
2967
|
+
if (errorMesaage) {
|
|
2968
|
+
setError(errorMesaage);
|
|
2969
|
+
} else {
|
|
2970
|
+
setError('');
|
|
2971
|
+
}
|
|
2972
|
+
}, [errorMesaage]);
|
|
2702
2973
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2703
2974
|
style: {
|
|
2704
2975
|
width: width ? width : configStyles.TEXTAREA.width
|
|
@@ -2741,7 +3012,7 @@ const Textarea = ({
|
|
|
2741
3012
|
maxHeight: maxHeight ? maxHeight : configStyles.TEXTAREA.maxHeight,
|
|
2742
3013
|
boxSizing: boxSizing ? boxSizing : configStyles.TEXTAREA.boxSizing,
|
|
2743
3014
|
backgroundColor: backgroundColor ? backgroundColor : configStyles.TEXTAREA.backgroundColor,
|
|
2744
|
-
borderColor: isFocus ? borderFocusColor ? borderFocusColor : configStyles.TEXTAREA.borderFocusColor : isHover ? borderHoverColor ? borderHoverColor : configStyles.TEXTAREA.borderHoverColor : borderColor ? borderColor : configStyles.TEXTAREA.borderColor,
|
|
3015
|
+
borderColor: error ? errorColor ? errorColor : configStyles.TEXTAREA.errorColor : isFocus ? borderFocusColor ? borderFocusColor : configStyles.TEXTAREA.borderFocusColor : isHover ? borderHoverColor ? borderHoverColor : configStyles.TEXTAREA.borderHoverColor : borderColor ? borderColor : configStyles.TEXTAREA.borderColor,
|
|
2745
3016
|
resize: resize ? resize : configStyles.TEXTAREA.resize
|
|
2746
3017
|
},
|
|
2747
3018
|
value: innerValue,
|
|
@@ -2751,7 +3022,14 @@ const Textarea = ({
|
|
|
2751
3022
|
placeholder: placeholder,
|
|
2752
3023
|
onMouseEnter: handleMouseEnter,
|
|
2753
3024
|
onMouseLeave: handleMouseLeave
|
|
2754
|
-
})
|
|
3025
|
+
}), error ? /*#__PURE__*/React__default.createElement("span", {
|
|
3026
|
+
style: {
|
|
3027
|
+
marginTop: '6px',
|
|
3028
|
+
display: 'inline-block',
|
|
3029
|
+
fontSize: errorSize ? errorSize : configStyles.TEXTAREA.errorSize,
|
|
3030
|
+
color: errorColor ? errorColor : configStyles.TEXTAREA.errorColor
|
|
3031
|
+
}
|
|
3032
|
+
}, error) : '');
|
|
2755
3033
|
};
|
|
2756
3034
|
Textarea.propTypes = {
|
|
2757
3035
|
size: PropTypes.string,
|
|
@@ -3114,6 +3392,7 @@ Autocomplate.defaultProps = {
|
|
|
3114
3392
|
|
|
3115
3393
|
const NewAutocomplete = ({
|
|
3116
3394
|
label,
|
|
3395
|
+
change,
|
|
3117
3396
|
options,
|
|
3118
3397
|
getItem,
|
|
3119
3398
|
required,
|
|
@@ -3187,6 +3466,7 @@ const NewAutocomplete = ({
|
|
|
3187
3466
|
const [isHover, setIsHover] = useState(false);
|
|
3188
3467
|
const [isFocus, setIsFocus] = useState(false);
|
|
3189
3468
|
const [innerValue, setInnerValue] = useState('');
|
|
3469
|
+
const [innerOptions, setInnerOptions] = useState([]);
|
|
3190
3470
|
const configStyles = compereConfigs();
|
|
3191
3471
|
const showOption = keyframes`
|
|
3192
3472
|
100% {
|
|
@@ -3220,13 +3500,18 @@ const NewAutocomplete = ({
|
|
|
3220
3500
|
const value = e.target.value;
|
|
3221
3501
|
value.length > 0 ? setShow(true) : setShow(false);
|
|
3222
3502
|
setInnerValue(value);
|
|
3503
|
+
if (value.length >= searchCount) {
|
|
3504
|
+
change(value);
|
|
3505
|
+
} else {
|
|
3506
|
+
change('');
|
|
3507
|
+
}
|
|
3223
3508
|
};
|
|
3224
3509
|
const handleClick = selectedValue => {
|
|
3225
3510
|
setShow(false);
|
|
3226
3511
|
getItem(selectedValue);
|
|
3227
|
-
setInnerValue(selectedValue.
|
|
3512
|
+
setInnerValue(selectedValue.name);
|
|
3228
3513
|
};
|
|
3229
|
-
const optionList = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, show &&
|
|
3514
|
+
const optionList = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, show && innerOptions ? innerOptions.length > 0 ? /*#__PURE__*/React__default.createElement("div", {
|
|
3230
3515
|
style: {
|
|
3231
3516
|
left: contentBottomLeft ? contentBottomLeft : configStyles.NEWAUTOCOMPLETE.contentBottomLeft,
|
|
3232
3517
|
width: contentBottomWidth ? contentBottomWidth : configStyles.NEWAUTOCOMPLETE.contentBottomWidth,
|
|
@@ -3249,9 +3534,9 @@ const NewAutocomplete = ({
|
|
|
3249
3534
|
maxHeight: contentBottomInnerMaxHeight ? contentBottomInnerMaxHeight : configStyles.NEWAUTOCOMPLETE.contentBottomInnerMaxHeight,
|
|
3250
3535
|
flexDirection: contentBottomInnerDirection ? contentBottomInnerDirection : configStyles.NEWAUTOCOMPLETE.contentBottomInnerDirection
|
|
3251
3536
|
}
|
|
3252
|
-
},
|
|
3537
|
+
}, innerOptions.map(item => {
|
|
3253
3538
|
return /*#__PURE__*/React__default.createElement("p", {
|
|
3254
|
-
key:
|
|
3539
|
+
key: item.id,
|
|
3255
3540
|
onMouseEnter: handleRowMouseEnter,
|
|
3256
3541
|
onMouseLeave: handleRowMouseLeave,
|
|
3257
3542
|
onClick: () => handleClick(item),
|
|
@@ -3271,40 +3556,37 @@ const NewAutocomplete = ({
|
|
|
3271
3556
|
marginBottom: contentBottomRowMarginBottom ? contentBottomRowMarginBottom : configStyles.NEWAUTOCOMPLETE.contentBottomRowMarginBottom,
|
|
3272
3557
|
backgroundColor: contentBottomRowBackgroundColor ? contentBottomRowBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowBackgroundColor
|
|
3273
3558
|
}
|
|
3274
|
-
}, item.
|
|
3275
|
-
}) : /*#__PURE__*/React__default.createElement("p", {
|
|
3276
|
-
style: {
|
|
3277
|
-
color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
|
|
3278
|
-
fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
|
|
3279
|
-
height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
|
|
3280
|
-
padding: contentBottomRowPadding ? contentBottomRowPadding : configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
|
|
3281
|
-
lineHeight: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight
|
|
3282
|
-
}
|
|
3283
|
-
}, "\u0546\u0574\u0561\u0576 \u057F\u057E\u0575\u0561\u056C \u0561\u057C\u056F\u0561 \u0579\u0567") : /*#__PURE__*/React__default.createElement("p", {
|
|
3559
|
+
}, item.name);
|
|
3560
|
+
}))) : innerOptions.length <= 0 ? /*#__PURE__*/React__default.createElement("p", {
|
|
3284
3561
|
style: {
|
|
3562
|
+
margin: '0px',
|
|
3285
3563
|
color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
|
|
3286
3564
|
fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
|
|
3287
3565
|
height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
|
|
3288
3566
|
padding: contentBottomRowPadding ? contentBottomRowPadding : configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
|
|
3289
|
-
lineHeight: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight
|
|
3567
|
+
lineHeight: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
|
|
3568
|
+
backgroundColor: contentBottomBackgroundColor ? contentBottomBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomBackgroundColor
|
|
3290
3569
|
}
|
|
3291
|
-
}, innerValue.length
|
|
3570
|
+
}, innerValue.length >= searchCount ? 'Նման տվյալ առկա չէ' : `Լրացնել առնվազն ${searchCount} նիշ`) : '' : '');
|
|
3292
3571
|
useEffect(() => {
|
|
3293
|
-
if (
|
|
3294
|
-
alert('Please add
|
|
3295
|
-
}
|
|
3296
|
-
if (options.length === 0) {
|
|
3297
|
-
alert('Please fill options array');
|
|
3572
|
+
if (options === undefined) {
|
|
3573
|
+
alert('Please add options prop');
|
|
3298
3574
|
}
|
|
3299
3575
|
options && options.length > 0 && options.map(item => {
|
|
3300
|
-
if (!item.hasOwnProperty('
|
|
3301
|
-
alert('Please add
|
|
3576
|
+
if (!item.hasOwnProperty('name')) {
|
|
3577
|
+
alert('Please add name property in items of options array');
|
|
3302
3578
|
}
|
|
3303
3579
|
});
|
|
3304
3580
|
if (!getItem) {
|
|
3305
3581
|
alert('Please add getItem function for get choosen item from autocomplete');
|
|
3306
3582
|
}
|
|
3307
|
-
|
|
3583
|
+
options && setInnerOptions(options);
|
|
3584
|
+
}, [options, options.length, getItem]);
|
|
3585
|
+
useEffect(() => {
|
|
3586
|
+
if (!change) {
|
|
3587
|
+
alert('Please add change prop on New Autocomplete component');
|
|
3588
|
+
}
|
|
3589
|
+
}, [change]);
|
|
3308
3590
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, label ? /*#__PURE__*/React__default.createElement("label", {
|
|
3309
3591
|
style: {
|
|
3310
3592
|
color: labelColor ? labelColor : configStyles.NEWAUTOCOMPLETE.labelColor,
|
|
@@ -3312,6 +3594,7 @@ const NewAutocomplete = ({
|
|
|
3312
3594
|
display: labelDisplay ? labelDisplay : configStyles.NEWAUTOCOMPLETE.labelDisplay,
|
|
3313
3595
|
fontWeight: labelWeight ? labelWeight : configStyles.NEWAUTOCOMPLETE.labelWeight,
|
|
3314
3596
|
lineHeight: labelLineHeight ? labelLineHeight : configStyles.NEWAUTOCOMPLETE.labelLineHeight,
|
|
3597
|
+
maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
|
|
3315
3598
|
marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.NEWAUTOCOMPLETE.labelMarginBottom,
|
|
3316
3599
|
textTransform: labelTextTransform ? labelTextTransform : configStyles.NEWAUTOCOMPLETE.labelTextTransform
|
|
3317
3600
|
}
|
|
@@ -3323,7 +3606,8 @@ const NewAutocomplete = ({
|
|
|
3323
3606
|
style: {
|
|
3324
3607
|
display: contentDisplay ? contentDisplay : configStyles.NEWAUTOCOMPLETE.contentDisplay,
|
|
3325
3608
|
position: contentPosition ? contentPosition : configStyles.NEWAUTOCOMPLETE.contentPosition,
|
|
3326
|
-
flexDirection: contentDirection ? contentDirection : configStyles.NEWAUTOCOMPLETE.contentDirection
|
|
3609
|
+
flexDirection: contentDirection ? contentDirection : configStyles.NEWAUTOCOMPLETE.contentDirection,
|
|
3610
|
+
maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth
|
|
3327
3611
|
}
|
|
3328
3612
|
}, /*#__PURE__*/React__default.createElement("input", _extends({
|
|
3329
3613
|
type: "text",
|
|
@@ -3332,11 +3616,12 @@ const NewAutocomplete = ({
|
|
|
3332
3616
|
onBlur: handleBlur,
|
|
3333
3617
|
onFocus: handleFocus,
|
|
3334
3618
|
onInput: handleChange,
|
|
3335
|
-
placeholder: placeHolder ? placeHolder : '',
|
|
3336
|
-
autoComplete: autoComplete ? autoComplete : configStyles.NEWAUTOCOMPLETE.autoComplete,
|
|
3337
3619
|
onMouseEnter: handleMouseEnter,
|
|
3338
3620
|
onMouseLeave: handleMouseLeave,
|
|
3621
|
+
placeholder: placeHolder ? placeHolder : '',
|
|
3622
|
+
autoComplete: autoComplete ? autoComplete : configStyles.NEWAUTOCOMPLETE.autoComplete,
|
|
3339
3623
|
style: {
|
|
3624
|
+
maxWidth: '100%',
|
|
3340
3625
|
transition: 'all 240ms',
|
|
3341
3626
|
cursor: disabled ? 'not-allowed' : 'auto',
|
|
3342
3627
|
color: contentTopColor ? contentTopColor : configStyles.NEWAUTOCOMPLETE.contentTopColor,
|
|
@@ -3347,7 +3632,6 @@ const NewAutocomplete = ({
|
|
|
3347
3632
|
display: contentTopDisplay ? contentTopDisplay : configStyles.NEWAUTOCOMPLETE.contentTopDisplay,
|
|
3348
3633
|
fontWeight: contentTopWeight ? contentTopWeight : configStyles.NEWAUTOCOMPLETE.contentTopWeight,
|
|
3349
3634
|
borderRadius: contentTopRadius ? contentTopRadius : configStyles.NEWAUTOCOMPLETE.contentTopRadius,
|
|
3350
|
-
maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
|
|
3351
3635
|
boxSizing: contentTopBoxSizing ? contentTopBoxSizing : configStyles.NEWAUTOCOMPLETE.contentTopBoxSizing,
|
|
3352
3636
|
lineHeight: contentTopLineHeight ? contentTopLineHeight : configStyles.NEWAUTOCOMPLETE.contentTopLineHeight,
|
|
3353
3637
|
flexDirection: contentTopDirection ? contentTopDirection : configStyles.NEWAUTOCOMPLETE.contentTopDirection,
|
|
@@ -3355,8 +3639,11 @@ const NewAutocomplete = ({
|
|
|
3355
3639
|
}
|
|
3356
3640
|
}, props)), errorMessage ? /*#__PURE__*/React__default.createElement("span", {
|
|
3357
3641
|
style: {
|
|
3642
|
+
margin: '0px',
|
|
3643
|
+
display: 'inline-block',
|
|
3358
3644
|
color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
|
|
3359
|
-
fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize
|
|
3645
|
+
fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
|
|
3646
|
+
maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth
|
|
3360
3647
|
}
|
|
3361
3648
|
}, errorMessage) : '', optionList));
|
|
3362
3649
|
};
|
|
@@ -3379,6 +3666,7 @@ NewAutocomplete.propTypes = {
|
|
|
3379
3666
|
contentPosition: PropTypes.string,
|
|
3380
3667
|
labelLineHeight: PropTypes.string,
|
|
3381
3668
|
contentTopColor: PropTypes.string,
|
|
3669
|
+
change: PropTypes.func.isRequired,
|
|
3382
3670
|
contentDirection: PropTypes.string,
|
|
3383
3671
|
contentTopWeight: PropTypes.number,
|
|
3384
3672
|
contentTopRadius: PropTypes.string,
|