@ctlyst.id/internal-ui 3.5.2 → 3.5.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +51 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -5714,6 +5714,47 @@ var defaultOnHandleRejections = (fileRejection, config2, handleRejection) => {
|
|
5714
5714
|
}
|
5715
5715
|
};
|
5716
5716
|
|
5717
|
+
// src/components/uploader/utils/is-ratio-equal.ts
|
5718
|
+
var isRatioEqual = (base, img) => {
|
5719
|
+
const baseRatio = (base.width / base.height).toFixed(2);
|
5720
|
+
const imgRatio = (img.width / img.height).toFixed(2);
|
5721
|
+
return baseRatio === imgRatio;
|
5722
|
+
};
|
5723
|
+
|
5724
|
+
// src/components/uploader/components/validator.ts
|
5725
|
+
var dimensionValidator = (dimension, message) => {
|
5726
|
+
return (file) => {
|
5727
|
+
const imageUrl = URL.createObjectURL(file);
|
5728
|
+
const img = new Image();
|
5729
|
+
img.src = imageUrl;
|
5730
|
+
img.onload = () => {
|
5731
|
+
};
|
5732
|
+
const isRatioValid = isRatioEqual(
|
5733
|
+
{ width: dimension[0], height: dimension[1] },
|
5734
|
+
{ width: img.width, height: img.height }
|
5735
|
+
);
|
5736
|
+
if (isRatioValid) {
|
5737
|
+
return null;
|
5738
|
+
}
|
5739
|
+
return {
|
5740
|
+
code: error_code_default.FileInvalidDimension,
|
5741
|
+
message: message != null ? message : "File has invalid dimension"
|
5742
|
+
};
|
5743
|
+
};
|
5744
|
+
};
|
5745
|
+
var extensionValidator = (extensions, message) => {
|
5746
|
+
return (file) => {
|
5747
|
+
const fileFormat = file.name.split(".").pop();
|
5748
|
+
if (!extensions.includes(fileFormat)) {
|
5749
|
+
return {
|
5750
|
+
code: error_code_default.FileInvalidType,
|
5751
|
+
message: message != null ? message : formatValidationMessage(extensions)
|
5752
|
+
};
|
5753
|
+
}
|
5754
|
+
return null;
|
5755
|
+
};
|
5756
|
+
};
|
5757
|
+
|
5717
5758
|
// src/components/uploader/components/uploader.tsx
|
5718
5759
|
import { Fragment as Fragment12, jsx as jsx66, jsxs as jsxs31 } from "react/jsx-runtime";
|
5719
5760
|
var Uploader = ({
|
@@ -5787,16 +5828,22 @@ var Uploader = ({
|
|
5787
5828
|
}, []);
|
5788
5829
|
const validator = useCallback2(
|
5789
5830
|
(file) => {
|
5831
|
+
const result = [];
|
5832
|
+
if (acceptFormat.validate) {
|
5833
|
+
const error = extensionValidator(acceptFormat.validate, acceptFormat.message)(file);
|
5834
|
+
if (error) {
|
5835
|
+
result.push(error);
|
5836
|
+
}
|
5837
|
+
}
|
5790
5838
|
if (validatorExt) {
|
5791
|
-
const result = [];
|
5792
5839
|
validatorExt.forEach((validatorFn) => {
|
5793
5840
|
const error = validatorFn(file);
|
5794
5841
|
if (Array.isArray(error)) {
|
5795
5842
|
result.push(...error);
|
5796
5843
|
} else if (error) result.push(error);
|
5797
5844
|
});
|
5798
|
-
return result;
|
5799
5845
|
}
|
5846
|
+
if (result.length > 0) return result;
|
5800
5847
|
return null;
|
5801
5848
|
},
|
5802
5849
|
[validatorExt]
|
@@ -5956,36 +6003,6 @@ var Uploader = ({
|
|
5956
6003
|
};
|
5957
6004
|
var uploader_default = Uploader;
|
5958
6005
|
|
5959
|
-
// src/components/uploader/utils/is-ratio-equal.ts
|
5960
|
-
var isRatioEqual = (base, img) => {
|
5961
|
-
const baseRatio = (base.width / base.height).toFixed(2);
|
5962
|
-
const imgRatio = (img.width / img.height).toFixed(2);
|
5963
|
-
return baseRatio === imgRatio;
|
5964
|
-
};
|
5965
|
-
|
5966
|
-
// src/components/uploader/components/validator.ts
|
5967
|
-
var dimensionValidator = (dimension, message) => {
|
5968
|
-
return (file) => {
|
5969
|
-
const imageUrl = URL.createObjectURL(file);
|
5970
|
-
const img = new Image();
|
5971
|
-
img.src = imageUrl;
|
5972
|
-
img.onload = () => {
|
5973
|
-
};
|
5974
|
-
const isRatioValid = isRatioEqual(
|
5975
|
-
{ width: dimension[0], height: dimension[1] },
|
5976
|
-
{ width: img.width, height: img.height }
|
5977
|
-
);
|
5978
|
-
console.log("log", isRatioValid);
|
5979
|
-
if (isRatioValid) {
|
5980
|
-
return null;
|
5981
|
-
}
|
5982
|
-
return {
|
5983
|
-
code: error_code_default.FileInvalidDimension,
|
5984
|
-
message: message != null ? message : "File has invalid dimension"
|
5985
|
-
};
|
5986
|
-
};
|
5987
|
-
};
|
5988
|
-
|
5989
6006
|
// src/components/index.ts
|
5990
6007
|
import {
|
5991
6008
|
Avatar as Avatar2,
|
@@ -8070,6 +8087,7 @@ export {
|
|
8070
8087
|
defaultOnHandleRejections,
|
8071
8088
|
dimensionValidator,
|
8072
8089
|
extendTheme,
|
8090
|
+
extensionValidator,
|
8073
8091
|
forwardRef13 as forwardRef,
|
8074
8092
|
getSelectAllCheckboxState,
|
8075
8093
|
getTheme,
|