@mamrp/components 1.7.60 → 1.7.62

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.mjs CHANGED
@@ -16,8 +16,8 @@ import { useState } from "react";
16
16
  function Page({
17
17
  data
18
18
  }) {
19
- const Accordion = styled((props) => /* @__PURE__ */ React.createElement(MuiAccordion, { disableGutters: true, elevation: 0, square: true, ...props }))(({ theme: theme3 }) => ({
20
- border: `1px solid ${theme3.palette.divider}`,
19
+ const Accordion = styled((props) => /* @__PURE__ */ React.createElement(MuiAccordion, { disableGutters: true, elevation: 0, square: true, ...props }))(({ theme: theme4 }) => ({
20
+ border: `1px solid ${theme4.palette.divider}`,
21
21
  "&:not(:last-child)": {
22
22
  borderBottom: 0
23
23
  },
@@ -25,21 +25,21 @@ function Page({
25
25
  display: "none"
26
26
  }
27
27
  }));
28
- const AccordionSummary = styled((props) => /* @__PURE__ */ React.createElement(MuiAccordionSummary, { expandIcon: /* @__PURE__ */ React.createElement(IoIosArrowForward, null), ...props }))(({ theme: theme3 }) => ({
28
+ const AccordionSummary = styled((props) => /* @__PURE__ */ React.createElement(MuiAccordionSummary, { expandIcon: /* @__PURE__ */ React.createElement(IoIosArrowForward, null), ...props }))(({ theme: theme4 }) => ({
29
29
  backgroundColor: "rgba(0, 0, 0, .03)",
30
30
  flexDirection: "row-reverse",
31
31
  [`& .${accordionSummaryClasses.expandIconWrapper}.${accordionSummaryClasses.expanded}`]: {
32
32
  transform: "rotate(90deg)"
33
33
  },
34
34
  [`& .${accordionSummaryClasses.content}`]: {
35
- marginLeft: theme3.spacing(1)
35
+ marginLeft: theme4.spacing(1)
36
36
  },
37
- ...theme3.applyStyles("dark", {
37
+ ...theme4.applyStyles("dark", {
38
38
  backgroundColor: "rgba(255, 255, 255, .05)"
39
39
  })
40
40
  }));
41
- const AccordionDetails = styled(MuiAccordionDetails)(({ theme: theme3 }) => ({
42
- padding: theme3.spacing(2),
41
+ const AccordionDetails = styled(MuiAccordionDetails)(({ theme: theme4 }) => ({
42
+ padding: theme4.spacing(2),
43
43
  borderTop: "1px solid rgba(0, 0, 0, .125)"
44
44
  }));
45
45
  const [expanded, setExpanded] = useState("");
@@ -148,7 +148,7 @@ function LicensePlate({
148
148
  readOnly = true,
149
149
  size
150
150
  }) {
151
- const theme3 = useTheme();
151
+ const theme4 = useTheme();
152
152
  const [open, setOpen] = useState2(false);
153
153
  const [inputValues, setInputValues] = useState2({
154
154
  input1: "",
@@ -200,7 +200,7 @@ function LicensePlate({
200
200
  }
201
201
  };
202
202
  const inputStyle = {
203
- color: theme3.palette.text.primary,
203
+ color: theme4.palette.text.primary,
204
204
  width: "30px",
205
205
  textAlign: "center",
206
206
  backgroundColor: "transparent",
@@ -739,8 +739,8 @@ function AdvancedSearchButton({
739
739
  backgroundColor,
740
740
  border = false
741
741
  }) {
742
- const theme3 = useTheme2();
743
- const isDarkMode = theme3.palette.mode === "dark";
742
+ const theme4 = useTheme2();
743
+ const isDarkMode = theme4.palette.mode === "dark";
744
744
  return /* @__PURE__ */ React5.createElement(
745
745
  Button3,
746
746
  {
@@ -750,7 +750,7 @@ function AdvancedSearchButton({
750
750
  },
751
751
  startIcon: /* @__PURE__ */ React5.createElement(AnimatedIcon, { isShowFilter }),
752
752
  sx: {
753
- color: theme3.palette.text.primary ?? color,
753
+ color: theme4.palette.text.primary ?? color,
754
754
  borderRadius: borderRadius ?? 2,
755
755
  paddingY,
756
756
  fontSize,
@@ -907,7 +907,7 @@ function ConfirmationDialog({
907
907
  position: "absolute",
908
908
  right: 8,
909
909
  top: 8,
910
- color: (theme3) => theme3.palette.grey[500]
910
+ color: (theme4) => theme4.palette.grey[500]
911
911
  }
912
912
  },
913
913
  /* @__PURE__ */ React8.createElement(MdClose, null)
@@ -1098,7 +1098,7 @@ var DateTimePickerComponent = ({
1098
1098
  clearable = false,
1099
1099
  variant = "outlined"
1100
1100
  }) => {
1101
- const theme3 = useTheme3();
1101
+ const theme4 = useTheme3();
1102
1102
  const [isOpen, setIsOpen] = useState5(false);
1103
1103
  const [hasUserInteracted, setHasUserInteracted] = useState5(false);
1104
1104
  const hourInputRef = useRef4(null);
@@ -1671,7 +1671,7 @@ var DateTimePickerComponent = ({
1671
1671
  fontWeight: isSelected(day) ? 700 : 400,
1672
1672
  bgcolor: isSelected(day) ? "primary.main" : isToday(day) ? "primary.lighter" : "transparent",
1673
1673
  color: isSelected(day) ? "primary.contrastText" : isToday(day) ? "primary.main" : index % 7 === 6 ? "error.main" : "text.primary",
1674
- border: isToday(day) && !isSelected(day) ? `2px solid ${theme3.palette.primary.main}` : "none",
1674
+ border: isToday(day) && !isSelected(day) ? `2px solid ${theme4.palette.primary.main}` : "none",
1675
1675
  transition: "all 0.15s ease",
1676
1676
  "&:hover": day ? {
1677
1677
  bgcolor: isSelected(day) ? "primary.dark" : "action.hover"
@@ -1742,7 +1742,7 @@ function CustomDialog({
1742
1742
  {
1743
1743
  alignItems: "center",
1744
1744
  sx: {
1745
- color: iconColor ? (theme3) => {
1745
+ color: iconColor ? (theme4) => {
1746
1746
  const paletteColors = [
1747
1747
  "primary",
1748
1748
  "secondary",
@@ -1761,11 +1761,11 @@ function CustomDialog({
1761
1761
  "customRed"
1762
1762
  ];
1763
1763
  if (paletteColors.includes(iconColor)) {
1764
- const palette = theme3.palette;
1764
+ const palette = theme4.palette;
1765
1765
  return palette[iconColor]?.main || iconColor;
1766
1766
  }
1767
1767
  return iconColor;
1768
- } : (theme3) => theme3.palette.info.main,
1768
+ } : (theme4) => theme4.palette.info.main,
1769
1769
  pr: 0.5
1770
1770
  }
1771
1771
  },
@@ -1781,7 +1781,7 @@ function CustomDialog({
1781
1781
  position: "absolute",
1782
1782
  right: 8,
1783
1783
  top: 8,
1784
- color: (theme3) => theme3.palette.grey[500]
1784
+ color: (theme4) => theme4.palette.grey[500]
1785
1785
  },
1786
1786
  disabled: isSubmiting
1787
1787
  },
@@ -1856,7 +1856,7 @@ var TimePickerComponent = ({
1856
1856
  disabled = false,
1857
1857
  variant = "outlined"
1858
1858
  }) => {
1859
- const theme3 = useTheme4();
1859
+ const theme4 = useTheme4();
1860
1860
  const initialHour = value ? parseInt(value.split(":")[0]) : null;
1861
1861
  const initialMinute = value ? parseInt(value.split(":")[1]) : null;
1862
1862
  const [isModalOpen, setIsModalOpen] = useState6(false);
@@ -1958,7 +1958,7 @@ var TimePickerComponent = ({
1958
1958
  },
1959
1959
  InputProps: {
1960
1960
  ...!disabled && {
1961
- endAdornment: /* @__PURE__ */ React.createElement(InputAdornment2, { position: "end" }, /* @__PURE__ */ React.createElement(Tooltip3, { title: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0632\u0645\u0627\u0646" }, /* @__PURE__ */ React.createElement(IconButton5, { onClick: () => setIsModalOpen(true) }, /* @__PURE__ */ React.createElement(Clock, { size: 22, color: theme3.palette.text.primary }))))
1961
+ endAdornment: /* @__PURE__ */ React.createElement(InputAdornment2, { position: "end" }, /* @__PURE__ */ React.createElement(Tooltip3, { title: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0632\u0645\u0627\u0646" }, /* @__PURE__ */ React.createElement(IconButton5, { onClick: () => setIsModalOpen(true) }, /* @__PURE__ */ React.createElement(Clock, { size: 22, color: theme4.palette.text.primary }))))
1962
1962
  }
1963
1963
  },
1964
1964
  sx: {
@@ -2025,7 +2025,7 @@ var TimePickerComponent = ({
2025
2025
  position: "absolute",
2026
2026
  right: 8,
2027
2027
  top: 8,
2028
- color: (theme4) => theme4.palette.grey[500]
2028
+ color: (theme5) => theme5.palette.grey[500]
2029
2029
  }
2030
2030
  },
2031
2031
  /* @__PURE__ */ React.createElement(MdClose4, null)
@@ -3747,6 +3747,23 @@ function ImageViewer({
3747
3747
  }
3748
3748
 
3749
3749
  // src/enhanced-upload-image/index.tsx
3750
+ import heic2any from "heic2any";
3751
+ var isHeic = (file) => file.type === "image/heic" || file.type === "image/heif" || file.name.toLowerCase().endsWith(".heic") || file.name.toLowerCase().endsWith(".heif");
3752
+ var convertHeicToJpeg = async (file) => {
3753
+ const convertedBlob = await heic2any({
3754
+ blob: file,
3755
+ toType: "image/jpeg",
3756
+ quality: 0.9
3757
+ });
3758
+ return new File(
3759
+ [convertedBlob],
3760
+ file.name.replace(/\.(heic|heif)$/i, ".jpg"),
3761
+ {
3762
+ type: "image/jpeg",
3763
+ lastModified: Date.now()
3764
+ }
3765
+ );
3766
+ };
3750
3767
  var UploadImage = ({
3751
3768
  placeholder,
3752
3769
  name,
@@ -3808,20 +3825,20 @@ var UploadImage = ({
3808
3825
  });
3809
3826
  };
3810
3827
  const handleImageChange = async (event) => {
3811
- const file = event.target.files?.[0];
3812
- if (file) {
3813
- console.log("Original file size (KB):", (file.size / 1024).toFixed(2));
3814
- const compressedFile = await compressImage(file);
3815
- if (compressedFile) {
3816
- console.log(
3817
- "Compressed file size (KB):",
3818
- (compressedFile.size / 1024).toFixed(2)
3819
- );
3820
- const objectURL = URL.createObjectURL(compressedFile);
3821
- setSelectedImage(objectURL);
3822
- setValue(name, compressedFile);
3828
+ let file = event.target.files?.[0];
3829
+ if (!file) return;
3830
+ if (isHeic(file)) {
3831
+ try {
3832
+ file = await convertHeicToJpeg(file);
3833
+ } catch (e) {
3834
+ return;
3823
3835
  }
3824
3836
  }
3837
+ const compressedFile = await compressImage(file);
3838
+ if (!compressedFile) return;
3839
+ const objectURL = URL.createObjectURL(compressedFile);
3840
+ setSelectedImage(objectURL);
3841
+ setValue(name, compressedFile);
3825
3842
  };
3826
3843
  const handleRemoveImage = () => {
3827
3844
  setSelectedImage(null);
@@ -4323,7 +4340,7 @@ function SearchLicensePlate({
4323
4340
  readOnly = true,
4324
4341
  size = "small"
4325
4342
  }) {
4326
- const theme3 = useTheme5();
4343
+ const theme4 = useTheme5();
4327
4344
  const [open, setOpen] = useState13(false);
4328
4345
  const [inputValues, setInputValues] = useState13({
4329
4346
  input1: "",
@@ -4338,7 +4355,7 @@ function SearchLicensePlate({
4338
4355
  input4: useRef7(null)
4339
4356
  };
4340
4357
  const inputStyle = {
4341
- color: theme3.palette.text.primary,
4358
+ color: theme4.palette.text.primary,
4342
4359
  width: "30px",
4343
4360
  textAlign: "center",
4344
4361
  backgroundColor: "transparent",
@@ -4885,7 +4902,7 @@ function ConfirmationDialog2({
4885
4902
  position: "absolute",
4886
4903
  right: 8,
4887
4904
  top: 8,
4888
- color: (theme3) => theme3.palette.grey[500]
4905
+ color: (theme4) => theme4.palette.grey[500]
4889
4906
  }
4890
4907
  },
4891
4908
  /* @__PURE__ */ React15.createElement(MdClose7, null)
@@ -4943,7 +4960,7 @@ function NoResult({
4943
4960
  description,
4944
4961
  sx = {}
4945
4962
  }) {
4946
- const theme3 = useTheme6();
4963
+ const theme4 = useTheme6();
4947
4964
  return /* @__PURE__ */ React16.createElement(
4948
4965
  Card2,
4949
4966
  {
@@ -4951,7 +4968,7 @@ function NoResult({
4951
4968
  width: "100%",
4952
4969
  minWidth: 300,
4953
4970
  borderRadius: "12px",
4954
- border: `1px solid ${theme3.palette.secondary.light}`
4971
+ border: `1px solid ${theme4.palette.secondary.light}`
4955
4972
  }
4956
4973
  },
4957
4974
  /* @__PURE__ */ React16.createElement(
@@ -5410,11 +5427,11 @@ var SwitchButton = ({
5410
5427
  iconChecked,
5411
5428
  iconUnchecked
5412
5429
  }) => {
5413
- const theme3 = useTheme8();
5414
- const isDarkMode = theme3.palette.mode === "dark";
5415
- const CustomSwitch = styled3(Switch)(({ theme: theme4 }) => ({
5430
+ const theme4 = useTheme8();
5431
+ const isDarkMode = theme4.palette.mode === "dark";
5432
+ const CustomSwitch = styled3(Switch)(({ theme: theme5 }) => ({
5416
5433
  "& .MuiSwitch-switchBase.Mui-checked": {
5417
- color: theme4.palette.primary.main
5434
+ color: theme5.palette.primary.main
5418
5435
  },
5419
5436
  "& .MuiSwitch-switchBase": {
5420
5437
  color: isDarkMode ? "rgba(220,220,220,1)" : "rgba(188,188,188,1)"
@@ -5425,16 +5442,16 @@ var SwitchButton = ({
5425
5442
  border: isDarkMode ? "2px solid white" : "2px solid rgba(80,80,80, 1)"
5426
5443
  }
5427
5444
  }));
5428
- const BoxContainer = styled3(Box25)(({ theme: theme4 }) => ({
5445
+ const BoxContainer = styled3(Box25)(({ theme: theme5 }) => ({
5429
5446
  display: "flex",
5430
5447
  alignItems: "center",
5431
5448
  backgroundColor: "rgba(188,188,188, 0.1)",
5432
5449
  border: "2px solid rgba(200,200,200, 1)",
5433
5450
  borderRadius: 10,
5434
5451
  transition: "all 0.3s ease",
5435
- paddingTop: theme4.spacing(0.1),
5436
- paddingBottom: theme4.spacing(0.1),
5437
- paddingLeft: theme4.spacing(1)
5452
+ paddingTop: theme5.spacing(0.1),
5453
+ paddingBottom: theme5.spacing(0.1),
5454
+ paddingLeft: theme5.spacing(1)
5438
5455
  }));
5439
5456
  const LabelContainer = styled3("div")({
5440
5457
  transition: "all 0.2s ease",
@@ -6196,8 +6213,8 @@ function MapLocationPicker({
6196
6213
  minZoom = 10,
6197
6214
  maxZoom = 19
6198
6215
  }) {
6199
- const theme3 = useTheme9();
6200
- const isDarkMode = theme3.palette.mode === "dark";
6216
+ const theme4 = useTheme9();
6217
+ const isDarkMode = theme4.palette.mode === "dark";
6201
6218
  const { field: latField, fieldState: latState } = useController({
6202
6219
  name: nameLat,
6203
6220
  control
@@ -6546,7 +6563,7 @@ function MapLocationPicker({
6546
6563
  onClick: handleClearLocation,
6547
6564
  sx: {
6548
6565
  backgroundColor: isDarkMode ? "#1e1e1e" : "white",
6549
- color: theme3.palette.error.main,
6566
+ color: theme4.palette.error.main,
6550
6567
  boxShadow: 2,
6551
6568
  "&:hover": {
6552
6569
  backgroundColor: isDarkMode ? "#2a2a2a" : "#f5f5f5"
@@ -6586,9 +6603,117 @@ function MapLocationPicker({
6586
6603
  helperText
6587
6604
  ));
6588
6605
  }
6606
+
6607
+ // src/checkbox-group/index.tsx
6608
+ import * as React28 from "react";
6609
+ import { Controller as Controller15 } from "react-hook-form";
6610
+ import Checkbox3 from "@mui/material/Checkbox";
6611
+ import FormControlLabel4 from "@mui/material/FormControlLabel";
6612
+ import FormControl3 from "@mui/material/FormControl";
6613
+ import FormLabel2 from "@mui/material/FormLabel";
6614
+ import { Typography as Typography20 } from "@mui/material";
6615
+ import { Box as Box28 } from "@mui/system";
6616
+ import theme3 from "@mamrp/layout/theme";
6617
+ function CheckBoxGroup({
6618
+ name,
6619
+ label,
6620
+ options,
6621
+ control,
6622
+ align = "start",
6623
+ disabledBoarder,
6624
+ direction = "row"
6625
+ }) {
6626
+ const normalize = (v) => typeof v === "string" && !isNaN(Number(v)) ? Number(v) : v;
6627
+ return /* @__PURE__ */ React28.createElement(
6628
+ FormControl3,
6629
+ {
6630
+ sx: {
6631
+ display: "flex",
6632
+ flexDirection: direction,
6633
+ alignItems: "center",
6634
+ justifyContent: "start"
6635
+ }
6636
+ },
6637
+ /* @__PURE__ */ React28.createElement(
6638
+ Controller15,
6639
+ {
6640
+ name,
6641
+ control,
6642
+ defaultValue: [],
6643
+ render: ({ field, fieldState: { error } }) => /* @__PURE__ */ React28.createElement(Box28, { display: "flex", width: "100%", flexDirection: "column" }, label && /* @__PURE__ */ React28.createElement(
6644
+ FormLabel2,
6645
+ {
6646
+ sx: {
6647
+ position: "absolute",
6648
+ top: -10,
6649
+ left: 15,
6650
+ px: 0.5,
6651
+ backgroundColor: "background.paper",
6652
+ color: error?.message ? theme3.CustomComponents.RadioButton.errorColor : theme3.CustomComponents.RadioButton.textColor,
6653
+ fontSize: 15,
6654
+ zIndex: 1
6655
+ }
6656
+ },
6657
+ label
6658
+ ), /* @__PURE__ */ React28.createElement(
6659
+ Box28,
6660
+ {
6661
+ sx: {
6662
+ width: "100%",
6663
+ p: 0.8,
6664
+ px: 1,
6665
+ borderRadius: 3,
6666
+ display: "flex",
6667
+ justifyContent: align,
6668
+ flexDirection: "row",
6669
+ border: disabledBoarder ? "" : `${theme3.CustomComponents.RadioButton.borderSize}px solid`,
6670
+ borderColor: error?.message ? theme3.CustomComponents.RadioButton.errorColor : theme3.CustomComponents.RadioButton.borderColor
6671
+ }
6672
+ },
6673
+ options.map((option) => /* @__PURE__ */ React28.createElement(
6674
+ FormControlLabel4,
6675
+ {
6676
+ key: option.value,
6677
+ label: option.name,
6678
+ control: /* @__PURE__ */ React28.createElement(
6679
+ Checkbox3,
6680
+ {
6681
+ checked: Array.isArray(field.value) && field.value.includes(normalize(option.value)),
6682
+ onChange: (e) => {
6683
+ const checked = e.target.checked;
6684
+ const value = normalize(option.value);
6685
+ const currentValue = Array.isArray(field.value) ? field.value.map(normalize) : [];
6686
+ if (checked) {
6687
+ if (!currentValue.includes(value)) {
6688
+ field.onChange([...currentValue, value]);
6689
+ }
6690
+ } else {
6691
+ field.onChange(
6692
+ currentValue.filter((v) => v !== value)
6693
+ );
6694
+ }
6695
+ }
6696
+ }
6697
+ )
6698
+ }
6699
+ ))
6700
+ ), error?.message && /* @__PURE__ */ React28.createElement(
6701
+ Typography20,
6702
+ {
6703
+ color: "error",
6704
+ fontSize: theme3.CustomComponents.RadioButton.errorFontSize,
6705
+ ml: 2
6706
+ },
6707
+ error?.message
6708
+ ))
6709
+ }
6710
+ )
6711
+ );
6712
+ }
6589
6713
  export {
6590
6714
  Page as Accordion,
6591
6715
  AdvancedSearchButton,
6716
+ CheckBoxGroup,
6592
6717
  ConfirmationDialog,
6593
6718
  bascule_connection_button_default as ConnectToBasculeButton,
6594
6719
  CustomCheckbox,