@ctlyst.id/internal-ui 3.5.4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -2773,7 +2773,7 @@ var Datepicker = ({
2773
2773
  isError,
2774
2774
  addOnRight: /* @__PURE__ */ jsxs10(InputRightElement, { alignSelf: "center", bottom: 0, flexDir: "row-reverse", width: "auto", mr: 2, gap: 2, children: [
2775
2775
  /* @__PURE__ */ jsx27(Calendar, { size: 4, color: "neutral.400" }),
2776
- value && /* @__PURE__ */ jsx27(
2776
+ value && !props.disabled && /* @__PURE__ */ jsx27(
2777
2777
  IconButton4,
2778
2778
  {
2779
2779
  "data-test-id": "H0rseVCzGIaqoLho-EPbu",
@@ -5714,47 +5714,6 @@ 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
-
5758
5717
  // src/components/uploader/components/uploader.tsx
5759
5718
  import { Fragment as Fragment12, jsx as jsx66, jsxs as jsxs31 } from "react/jsx-runtime";
5760
5719
  var Uploader = ({
@@ -5829,12 +5788,6 @@ var Uploader = ({
5829
5788
  const validator = useCallback2(
5830
5789
  (file) => {
5831
5790
  const result = [];
5832
- if (acceptFormat.validate) {
5833
- const error = extensionValidator(acceptFormat.validate, acceptFormat.message)(file);
5834
- if (error) {
5835
- result.push(error);
5836
- }
5837
- }
5838
5791
  if (validatorExt) {
5839
5792
  validatorExt.forEach((validatorFn) => {
5840
5793
  const error = validatorFn(file);
@@ -5848,12 +5801,11 @@ var Uploader = ({
5848
5801
  },
5849
5802
  [validatorExt]
5850
5803
  );
5804
+ const acceptFile = acceptFormat.validate.map((type) => [`image/${type}`, []]);
5851
5805
  const { getRootProps, getInputProps, isDragActive, acceptedFiles, open } = useDropzone({
5852
5806
  onDropAccepted,
5853
5807
  onDropRejected,
5854
- accept: {
5855
- "image/*": [...acceptFormat.validate]
5856
- },
5808
+ accept: Object.fromEntries(acceptFile),
5857
5809
  maxFiles: 1,
5858
5810
  maxSize: maxFileSize == null ? void 0 : maxFileSize.validate,
5859
5811
  noClick: isDisabled,
@@ -6003,6 +5955,35 @@ var Uploader = ({
6003
5955
  };
6004
5956
  var uploader_default = Uploader;
6005
5957
 
5958
+ // src/components/uploader/utils/is-ratio-equal.ts
5959
+ var isRatioEqual = (base, img) => {
5960
+ const baseRatio = (base.width / base.height).toFixed(2);
5961
+ const imgRatio = (img.width / img.height).toFixed(2);
5962
+ return baseRatio === imgRatio;
5963
+ };
5964
+
5965
+ // src/components/uploader/components/validator.ts
5966
+ var dimensionValidator = (dimension, message) => {
5967
+ return (file) => {
5968
+ const imageUrl = URL.createObjectURL(file);
5969
+ const img = new Image();
5970
+ img.src = imageUrl;
5971
+ img.onload = () => {
5972
+ };
5973
+ const isRatioValid = isRatioEqual(
5974
+ { width: dimension[0], height: dimension[1] },
5975
+ { width: img.width, height: img.height }
5976
+ );
5977
+ if (isRatioValid) {
5978
+ return null;
5979
+ }
5980
+ return {
5981
+ code: error_code_default.FileInvalidDimension,
5982
+ message: message != null ? message : "File has invalid dimension"
5983
+ };
5984
+ };
5985
+ };
5986
+
6006
5987
  // src/components/index.ts
6007
5988
  import {
6008
5989
  Avatar as Avatar2,
@@ -8087,7 +8068,6 @@ export {
8087
8068
  defaultOnHandleRejections,
8088
8069
  dimensionValidator,
8089
8070
  extendTheme,
8090
- extensionValidator,
8091
8071
  forwardRef13 as forwardRef,
8092
8072
  getSelectAllCheckboxState,
8093
8073
  getTheme,