@mamrp/components 1.2.0 → 1.2.1

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
@@ -3495,10 +3495,108 @@ var FormInputText = ({
3495
3495
  };
3496
3496
  var text_type_default = FormInputText;
3497
3497
 
3498
+ // src/text-field/number-pattern-input/index.tsx
3499
+ import CircularProgress6 from "@mui/material/CircularProgress";
3500
+ import InputAdornment4 from "@mui/material/InputAdornment";
3501
+ import TextField5 from "@mui/material/TextField";
3502
+ import React24, { forwardRef as forwardRef2 } from "react";
3503
+ import { Controller as Controller10 } from "react-hook-form";
3504
+ import { PatternFormat } from "react-number-format";
3505
+ var PatternTextField = ({
3506
+ name,
3507
+ control,
3508
+ label,
3509
+ maxLength,
3510
+ readOnly,
3511
+ rules,
3512
+ size = "small",
3513
+ disabled = false,
3514
+ multiline,
3515
+ isLoading,
3516
+ onBlurHandler,
3517
+ rows,
3518
+ groupEvery,
3519
+ groupSeparator = "-",
3520
+ formatPattern,
3521
+ ...rest
3522
+ }) => {
3523
+ const isNumericMode = !!groupEvery;
3524
+ const formatValue = (val) => {
3525
+ if (!val) return "";
3526
+ const raw = isNumericMode ? val.replace(/\D/g, "") : val;
3527
+ if (groupEvery) {
3528
+ return raw.match(new RegExp(`.{1,${groupEvery}}`, "g"))?.join(groupSeparator) || "";
3529
+ }
3530
+ return val;
3531
+ };
3532
+ return /* @__PURE__ */ React24.createElement(
3533
+ Controller10,
3534
+ {
3535
+ name,
3536
+ control,
3537
+ rules,
3538
+ render: ({ field: { onChange, value, ref }, fieldState: { error } }) => /* @__PURE__ */ React24.createElement(
3539
+ TextField5,
3540
+ {
3541
+ ...rest,
3542
+ disabled: disabled || isLoading,
3543
+ helperText: error?.message || null,
3544
+ multiline,
3545
+ size,
3546
+ rows: rows || void 0,
3547
+ error: !!error,
3548
+ value: formatValue(value?.toString() || ""),
3549
+ onChange: (e) => {
3550
+ let newRaw = e.target.value;
3551
+ if (isNumericMode) newRaw = newRaw.replace(/\D/g, "");
3552
+ if (!maxLength || newRaw.length <= maxLength) onChange(newRaw);
3553
+ },
3554
+ fullWidth: true,
3555
+ label,
3556
+ variant: "outlined",
3557
+ inputProps: { ...rest.inputProps, readOnly },
3558
+ InputProps: {
3559
+ inputComponent: formatPattern ? PatternFormatCustom : void 0,
3560
+ inputProps: {
3561
+ format: formatPattern
3562
+ // 👈 الگوی نمایش
3563
+ },
3564
+ endAdornment: isLoading ? /* @__PURE__ */ React24.createElement(InputAdornment4, { position: "end" }, /* @__PURE__ */ React24.createElement(CircularProgress6, { size: 20 })) : null
3565
+ },
3566
+ InputLabelProps: { shrink: true },
3567
+ inputRef: ref
3568
+ }
3569
+ )
3570
+ }
3571
+ );
3572
+ };
3573
+ var PatternFormatCustom = forwardRef2(
3574
+ function PatternFormatCustom2(props, ref) {
3575
+ const { onChange, format, ...other } = props;
3576
+ return /* @__PURE__ */ React24.createElement(
3577
+ PatternFormat,
3578
+ {
3579
+ ...other,
3580
+ getInputRef: ref,
3581
+ format,
3582
+ onValueChange: (values) => {
3583
+ onChange({
3584
+ target: {
3585
+ name: props.name,
3586
+ value: values.value
3587
+ }
3588
+ });
3589
+ }
3590
+ }
3591
+ );
3592
+ }
3593
+ );
3594
+ var number_pattern_input_default = PatternTextField;
3595
+
3498
3596
  // src/upload-image/index.tsx
3499
- import React24 from "react";
3597
+ import React25 from "react";
3500
3598
  import {
3501
- Controller as Controller10
3599
+ Controller as Controller11
3502
3600
  } from "react-hook-form";
3503
3601
  import { Box as Box17, Button as Button11, Stack as Stack5, Typography as Typography13 } from "@mui/material";
3504
3602
  import { GrUpload, GrGallery } from "react-icons/gr";
@@ -3573,12 +3671,12 @@ var UploadImage = ({
3573
3671
  }
3574
3672
  }
3575
3673
  };
3576
- return /* @__PURE__ */ React24.createElement(
3577
- Controller10,
3674
+ return /* @__PURE__ */ React25.createElement(
3675
+ Controller11,
3578
3676
  {
3579
3677
  name,
3580
3678
  control,
3581
- render: ({ field }) => /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(
3679
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
3582
3680
  "label",
3583
3681
  {
3584
3682
  htmlFor: "file-upload",
@@ -3598,7 +3696,7 @@ var UploadImage = ({
3598
3696
  overflow: "hidden"
3599
3697
  }
3600
3698
  },
3601
- selectedImage ? /* @__PURE__ */ React24.createElement(
3699
+ selectedImage ? /* @__PURE__ */ React25.createElement(
3602
3700
  Image3,
3603
3701
  {
3604
3702
  src: selectedImage,
@@ -3606,13 +3704,13 @@ var UploadImage = ({
3606
3704
  fill: true,
3607
3705
  objectFit: imageFit
3608
3706
  }
3609
- ) : /* @__PURE__ */ React24.createElement(
3707
+ ) : /* @__PURE__ */ React25.createElement(
3610
3708
  Stack5,
3611
3709
  {
3612
3710
  spacing: allowGallery ? 2 : 0,
3613
3711
  sx: { pt: allowGallery ? 2 : 0 }
3614
3712
  },
3615
- /* @__PURE__ */ React24.createElement(
3713
+ /* @__PURE__ */ React25.createElement(
3616
3714
  Box17,
3617
3715
  {
3618
3716
  sx: {
@@ -3622,31 +3720,31 @@ var UploadImage = ({
3622
3720
  gap: 1.5
3623
3721
  }
3624
3722
  },
3625
- /* @__PURE__ */ React24.createElement(Box17, { sx: { paddingBottom: "0.5rem" } }, /* @__PURE__ */ React24.createElement(GrUpload, null)),
3723
+ /* @__PURE__ */ React25.createElement(Box17, { sx: { paddingBottom: "0.5rem" } }, /* @__PURE__ */ React25.createElement(GrUpload, null)),
3626
3724
  placeholder
3627
3725
  ),
3628
- allowGallery && /* @__PURE__ */ React24.createElement(Stack5, { spacing: 1.5 }, /* @__PURE__ */ React24.createElement(
3726
+ allowGallery && /* @__PURE__ */ React25.createElement(Stack5, { spacing: 1.5 }, /* @__PURE__ */ React25.createElement(
3629
3727
  Button11,
3630
3728
  {
3631
3729
  sx: { width: "9rem" },
3632
3730
  variant: "outlined",
3633
3731
  color: "info",
3634
- startIcon: /* @__PURE__ */ React24.createElement(MdOutlineCameraAlt, { size: 16 }),
3732
+ startIcon: /* @__PURE__ */ React25.createElement(MdOutlineCameraAlt, { size: 16 }),
3635
3733
  onClick: () => document.getElementById("camera-upload")?.click()
3636
3734
  },
3637
3735
  "\u062F\u0648\u0631\u0628\u06CC\u0646"
3638
- ), /* @__PURE__ */ React24.createElement(
3736
+ ), /* @__PURE__ */ React25.createElement(
3639
3737
  Button11,
3640
3738
  {
3641
3739
  sx: { width: "9rem" },
3642
3740
  variant: "outlined",
3643
3741
  color: "info",
3644
- startIcon: /* @__PURE__ */ React24.createElement(GrGallery, { size: 16 }),
3742
+ startIcon: /* @__PURE__ */ React25.createElement(GrGallery, { size: 16 }),
3645
3743
  onClick: () => document.getElementById("gallery-upload")?.click()
3646
3744
  },
3647
3745
  "\u06AF\u0627\u0644\u0631\u06CC"
3648
3746
  )),
3649
- !allowGallery && /* @__PURE__ */ React24.createElement(
3747
+ !allowGallery && /* @__PURE__ */ React25.createElement(
3650
3748
  "input",
3651
3749
  {
3652
3750
  id: "file-upload",
@@ -3661,7 +3759,7 @@ var UploadImage = ({
3661
3759
  }
3662
3760
  )
3663
3761
  )
3664
- ), /* @__PURE__ */ React24.createElement(
3762
+ ), /* @__PURE__ */ React25.createElement(
3665
3763
  "input",
3666
3764
  {
3667
3765
  id: "gallery-upload",
@@ -3673,7 +3771,7 @@ var UploadImage = ({
3673
3771
  },
3674
3772
  style: { display: "none" }
3675
3773
  }
3676
- ), /* @__PURE__ */ React24.createElement(
3774
+ ), /* @__PURE__ */ React25.createElement(
3677
3775
  "input",
3678
3776
  {
3679
3777
  id: "camera-upload",
@@ -3686,12 +3784,12 @@ var UploadImage = ({
3686
3784
  },
3687
3785
  style: { display: "none" }
3688
3786
  }
3689
- ), selectedImage && /* @__PURE__ */ React24.createElement(
3787
+ ), selectedImage && /* @__PURE__ */ React25.createElement(
3690
3788
  Box17,
3691
3789
  {
3692
3790
  sx: { display: "flex", justifyContent: "center", marginTop: 2 }
3693
3791
  },
3694
- /* @__PURE__ */ React24.createElement(
3792
+ /* @__PURE__ */ React25.createElement(
3695
3793
  Button11,
3696
3794
  {
3697
3795
  onClick: () => {
@@ -3711,7 +3809,7 @@ var UploadImage = ({
3711
3809
  },
3712
3810
  "\u062D\u0630\u0641 \u062A\u0635\u0648\u06CC\u0631"
3713
3811
  )
3714
- ), errors[name] && /* @__PURE__ */ React24.createElement(Typography13, { color: "error", variant: "body2", sx: { mt: 1.5, ml: 1 } }, String(errors[name]?.message || "")))
3812
+ ), errors[name] && /* @__PURE__ */ React25.createElement(Typography13, { color: "error", variant: "body2", sx: { mt: 1.5, ml: 1 } }, String(errors[name]?.message || "")))
3715
3813
  }
3716
3814
  );
3717
3815
  };
@@ -3792,7 +3890,7 @@ function Page({
3792
3890
  // src/switch-button/index.tsx
3793
3891
  import { Box as Box18, FormControlLabel as FormControlLabel3, Switch } from "@mui/material";
3794
3892
  import { styled as styled4 } from "@mui/system";
3795
- import React25 from "react";
3893
+ import React26 from "react";
3796
3894
  import { PiCardsDuotone, PiTableDuotone } from "react-icons/pi";
3797
3895
  import { useTheme as useTheme6 } from "@mui/material";
3798
3896
  var SwitchButton = ({
@@ -3831,10 +3929,10 @@ var SwitchButton = ({
3831
3929
  transition: "all 0.2s ease",
3832
3930
  color: isDarkMode ? "rgba(220,220,220, 1)" : "rgba(160,160,160, 1)"
3833
3931
  });
3834
- return /* @__PURE__ */ React25.createElement(BoxContainer, null, /* @__PURE__ */ React25.createElement(
3932
+ return /* @__PURE__ */ React26.createElement(BoxContainer, null, /* @__PURE__ */ React26.createElement(
3835
3933
  FormControlLabel3,
3836
3934
  {
3837
- control: /* @__PURE__ */ React25.createElement(
3935
+ control: /* @__PURE__ */ React26.createElement(
3838
3936
  CustomSwitch,
3839
3937
  {
3840
3938
  checked,
@@ -3842,7 +3940,7 @@ var SwitchButton = ({
3842
3940
  name: "switch"
3843
3941
  }
3844
3942
  ),
3845
- label: /* @__PURE__ */ React25.createElement(LabelContainer, null, checked ? iconChecked ? iconChecked : /* @__PURE__ */ React25.createElement(PiTableDuotone, { size: 30 }) : iconUnchecked ? iconUnchecked : /* @__PURE__ */ React25.createElement(PiCardsDuotone, { size: 30 }))
3943
+ label: /* @__PURE__ */ React26.createElement(LabelContainer, null, checked ? iconChecked ? iconChecked : /* @__PURE__ */ React26.createElement(PiTableDuotone, { size: 30 }) : iconUnchecked ? iconUnchecked : /* @__PURE__ */ React26.createElement(PiCardsDuotone, { size: 30 }))
3846
3944
  }
3847
3945
  ));
3848
3946
  };
@@ -3850,7 +3948,7 @@ var switch_button_default = SwitchButton;
3850
3948
 
3851
3949
  // src/bascule-connection-button/index.tsx
3852
3950
  import { Box as Box19, Button as Button12 } from "@mui/material";
3853
- import React26, { useRef as useRef4, useState as useState12 } from "react";
3951
+ import React27, { useRef as useRef4, useState as useState12 } from "react";
3854
3952
  import toast from "react-hot-toast";
3855
3953
  import { PiPlugs, PiPlugsConnected } from "react-icons/pi";
3856
3954
  var ConnectToBasculeButton = ({
@@ -3879,7 +3977,7 @@ var ConnectToBasculeButton = ({
3879
3977
  toast.error("\u062E\u0637\u0627 \u062F\u0631 \u0627\u062A\u0635\u0627\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644. \u0644\u0637\u0641\u0627\u064B \u062F\u0648\u0628\u0627\u0631\u0647 \u062A\u0644\u0627\u0634 \u06A9\u0646\u06CC\u062F.");
3880
3978
  }
3881
3979
  };
3882
- return /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement("style", null, `
3980
+ return /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement("style", null, `
3883
3981
  @keyframes jumpAnimation {
3884
3982
  0% { transform: translateY(1px); }
3885
3983
  12.5% { transform: translateY(-2px); }
@@ -3888,7 +3986,7 @@ var ConnectToBasculeButton = ({
3888
3986
  50% { transform: translateY(0); }
3889
3987
  100% { transform: translateY(0); }
3890
3988
  }
3891
- `), /* @__PURE__ */ React26.createElement(
3989
+ `), /* @__PURE__ */ React27.createElement(
3892
3990
  Button12,
3893
3991
  {
3894
3992
  variant: "contained",
@@ -3896,7 +3994,7 @@ var ConnectToBasculeButton = ({
3896
3994
  disabled: connected,
3897
3995
  sx: { minWidth: "11rem" }
3898
3996
  },
3899
- /* @__PURE__ */ React26.createElement(
3997
+ /* @__PURE__ */ React27.createElement(
3900
3998
  Box19,
3901
3999
  {
3902
4000
  sx: {
@@ -3906,7 +4004,7 @@ var ConnectToBasculeButton = ({
3906
4004
  fontSize: 16
3907
4005
  }
3908
4006
  },
3909
- connected ? /* @__PURE__ */ React26.createElement(React26.Fragment, null, "\u0645\u062A\u0635\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ React26.createElement(PiPlugsConnected, { size: 20 })) : /* @__PURE__ */ React26.createElement(React26.Fragment, null, "\u0627\u062A\u0635\u0627\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ React26.createElement(
4007
+ connected ? /* @__PURE__ */ React27.createElement(React27.Fragment, null, "\u0645\u062A\u0635\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ React27.createElement(PiPlugsConnected, { size: 20 })) : /* @__PURE__ */ React27.createElement(React27.Fragment, null, "\u0627\u062A\u0635\u0627\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ React27.createElement(
3910
4008
  PiPlugs,
3911
4009
  {
3912
4010
  size: 20,
@@ -3964,6 +4062,7 @@ export {
3964
4062
  selector_default as NestedSelectort,
3965
4063
  NoResult,
3966
4064
  PaginationList,
4065
+ number_pattern_input_default as PatternTextField,
3967
4066
  RadioButton,
3968
4067
  SearchLicensePlate,
3969
4068
  MultipleSelectChip as Selector,