@mamrp/components 1.7.15 → 1.7.17

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
@@ -157,8 +157,8 @@ function LicensePlate({
157
157
  sx: {
158
158
  backgroundColor: "#172554",
159
159
  width: size === "small" ? "30px" : "36px",
160
- minHeight: size === "small" ? "40px" : "52px",
161
- maxHeight: size === "small" ? "40px" : "52px",
160
+ minHeight: "52px",
161
+ maxHeight: "52px",
162
162
  display: "flex",
163
163
  justifyContent: "center",
164
164
  alignItems: "center",
@@ -2397,7 +2397,7 @@ function SearchLicensePlate({
2397
2397
  sx: {
2398
2398
  backgroundColor: "#172554",
2399
2399
  width: "2.25rem",
2400
- height: "3.25rem",
2400
+ height: "3rem",
2401
2401
  display: "flex",
2402
2402
  justifyContent: "center",
2403
2403
  alignItems: "center",
@@ -3895,7 +3895,8 @@ var UploadImage = ({
3895
3895
  setValue,
3896
3896
  height,
3897
3897
  allowGallery = false,
3898
- imageFit = "cover"
3898
+ imageFit = "cover",
3899
+ disableCamera = false
3899
3900
  }) => {
3900
3901
  const compressImage = (file, quality = 0.8, maxWidth = 800, maxHeight = 800) => {
3901
3902
  return new Promise((resolve) => {
@@ -4006,7 +4007,7 @@ var UploadImage = ({
4006
4007
  /* @__PURE__ */ React24.createElement(Box18, { sx: { paddingBottom: "0.5rem" } }, /* @__PURE__ */ React24.createElement(GrUpload, null)),
4007
4008
  placeholder
4008
4009
  ),
4009
- allowGallery && /* @__PURE__ */ React24.createElement(Stack5, { spacing: 1.5 }, /* @__PURE__ */ React24.createElement(
4010
+ allowGallery && /* @__PURE__ */ React24.createElement(Stack5, { spacing: 1.5 }, !disableCamera && /* @__PURE__ */ React24.createElement(
4010
4011
  Button10,
4011
4012
  {
4012
4013
  sx: { width: "9rem" },
@@ -5059,19 +5060,198 @@ var DataTable = ({
5059
5060
  };
5060
5061
  var data_table_default = DataTable;
5061
5062
 
5062
- // src/custom-dialog/index.tsx
5063
+ // src/img-viewer/index.tsx
5063
5064
  import {
5064
- Box as Box24,
5065
5065
  Dialog as Dialog7,
5066
+ IconButton as IconButton10,
5067
+ CircularProgress as CircularProgress10,
5068
+ Box as Box24,
5069
+ Typography as Typography17
5070
+ } from "@mui/material";
5071
+ import {
5072
+ MdZoomIn as MdZoomIn2,
5073
+ MdZoomOut as MdZoomOut2,
5074
+ MdRotateLeft as MdRotateLeft2,
5075
+ MdRotateRight as MdRotateRight2,
5076
+ MdClose as MdClose5
5077
+ } from "react-icons/md";
5078
+ import Image6 from "next/image";
5079
+ import { useEffect as useEffect10, useState as useState15, useCallback as useCallback2 } from "react";
5080
+ function imgViewer({
5081
+ open,
5082
+ handleClose,
5083
+ src,
5084
+ isLoading,
5085
+ title = "",
5086
+ noResetBtn = false,
5087
+ noRotate = false,
5088
+ noZoom = false,
5089
+ unoptimized = false
5090
+ }) {
5091
+ const [zoom, setZoom] = useState15(1);
5092
+ const [rotate, setRotate] = useState15(0);
5093
+ const [loading, setLoading] = useState15(true);
5094
+ const [position, setPosition] = useState15({ x: 0, y: 0 });
5095
+ const [dragging, setDragging] = useState15(false);
5096
+ const [startMouse, setStartMouse] = useState15({ x: 0, y: 0 });
5097
+ const [startOffset, setStartOffset] = useState15({ x: 0, y: 0 });
5098
+ const reset = () => {
5099
+ setZoom(1);
5100
+ setRotate(0);
5101
+ setPosition({ x: 0, y: 0 });
5102
+ };
5103
+ const handleWheel = useCallback2((e) => {
5104
+ e.preventDefault();
5105
+ const delta = -e.deltaY * 1e-3;
5106
+ setZoom((z) => Math.min(5, Math.max(0.2, z + delta)));
5107
+ }, []);
5108
+ const handleMouseDown = (e) => {
5109
+ setDragging(true);
5110
+ setStartMouse({ x: e.clientX, y: e.clientY });
5111
+ setStartOffset({ ...position });
5112
+ };
5113
+ const handleMouseMove = (e) => {
5114
+ if (!dragging) return;
5115
+ const dx = e.clientX - startMouse.x;
5116
+ const dy = e.clientY - startMouse.y;
5117
+ setPosition({
5118
+ x: startOffset.x - dx,
5119
+ y: startOffset.y + dy
5120
+ });
5121
+ };
5122
+ const handleMouseUp = () => setDragging(false);
5123
+ useEffect10(() => {
5124
+ if (dragging) {
5125
+ window.addEventListener("mousemove", handleMouseMove);
5126
+ window.addEventListener("mouseup", handleMouseUp);
5127
+ } else {
5128
+ window.removeEventListener("mousemove", handleMouseMove);
5129
+ window.removeEventListener("mouseup", handleMouseUp);
5130
+ }
5131
+ return () => {
5132
+ window.removeEventListener("mousemove", handleMouseMove);
5133
+ window.removeEventListener("mouseup", handleMouseUp);
5134
+ };
5135
+ }, [dragging, startMouse, startOffset]);
5136
+ useEffect10(() => {
5137
+ if (open) reset();
5138
+ }, [open]);
5139
+ return /* @__PURE__ */ React.createElement(
5140
+ Dialog7,
5141
+ {
5142
+ open,
5143
+ onClose: handleClose,
5144
+ maxWidth: "xl",
5145
+ fullWidth: true,
5146
+ sx: {
5147
+ "& .MuiPaper-root": {
5148
+ borderRadius: 3,
5149
+ backgroundColor: "transparent"
5150
+ }
5151
+ }
5152
+ },
5153
+ /* @__PURE__ */ React.createElement(
5154
+ Box24,
5155
+ {
5156
+ sx: {
5157
+ position: "relative",
5158
+ width: "100%",
5159
+ height: "90vh",
5160
+ bgcolor: "rgba(17,17,17,0.9)",
5161
+ overflow: "hidden",
5162
+ display: "flex",
5163
+ justifyContent: "center",
5164
+ alignItems: "center"
5165
+ },
5166
+ onWheel: handleWheel
5167
+ },
5168
+ /* @__PURE__ */ React.createElement(
5169
+ Box24,
5170
+ {
5171
+ sx: {
5172
+ position: "absolute",
5173
+ top: 10,
5174
+ left: 10,
5175
+ zIndex: 20,
5176
+ display: "flex",
5177
+ gap: 1,
5178
+ alignItems: "center"
5179
+ }
5180
+ },
5181
+ /* @__PURE__ */ React.createElement(IconButton10, { onClick: handleClose }, /* @__PURE__ */ React.createElement(MdClose5, { color: "white" })),
5182
+ !noResetBtn && /* @__PURE__ */ React.createElement(IconButton10, { onClick: reset }, /* @__PURE__ */ React.createElement("span", { style: { color: "white", fontSize: "0.9rem" } }, "\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u06CC")),
5183
+ !noRotate && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(IconButton10, { onClick: () => setRotate((r) => r - 90) }, /* @__PURE__ */ React.createElement(MdRotateLeft2, { color: "white" })), /* @__PURE__ */ React.createElement(IconButton10, { onClick: () => setRotate((r) => r + 90) }, /* @__PURE__ */ React.createElement(MdRotateRight2, { color: "white" }))),
5184
+ !noZoom && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(IconButton10, { onClick: () => setZoom((z) => z + 0.2) }, /* @__PURE__ */ React.createElement(MdZoomIn2, { color: "white" })), /* @__PURE__ */ React.createElement(
5185
+ IconButton10,
5186
+ {
5187
+ onClick: () => setZoom((z) => Math.max(0.2, z - 0.2))
5188
+ },
5189
+ /* @__PURE__ */ React.createElement(MdZoomOut2, { color: "white" })
5190
+ )),
5191
+ /* @__PURE__ */ React.createElement(Typography17, { color: "white" }, title)
5192
+ ),
5193
+ (isLoading || loading) && /* @__PURE__ */ React.createElement(
5194
+ Box24,
5195
+ {
5196
+ sx: {
5197
+ position: "absolute",
5198
+ zIndex: 10,
5199
+ top: "50%",
5200
+ left: "50%",
5201
+ transform: "translate(-50%, -50%)",
5202
+ color: "white"
5203
+ }
5204
+ },
5205
+ /* @__PURE__ */ React.createElement(CircularProgress10, { color: "inherit" })
5206
+ ),
5207
+ /* @__PURE__ */ React.createElement(
5208
+ Box24,
5209
+ {
5210
+ onMouseDown: handleMouseDown,
5211
+ sx: {
5212
+ position: "relative",
5213
+ cursor: dragging ? "grabbing" : "grab",
5214
+ transform: `translate(${position.x}px, ${position.y}px) scale(${zoom}) rotate(${rotate}deg)`,
5215
+ transition: dragging ? "none" : "transform 0.3s ease",
5216
+ zIndex: 5
5217
+ }
5218
+ },
5219
+ src && !isLoading && /* @__PURE__ */ React.createElement(
5220
+ Image6,
5221
+ {
5222
+ src,
5223
+ alt: title,
5224
+ width: 1e3,
5225
+ height: 800,
5226
+ onLoad: () => setLoading(false),
5227
+ onError: () => setLoading(false),
5228
+ style: {
5229
+ objectFit: "contain",
5230
+ userSelect: "none",
5231
+ pointerEvents: "none"
5232
+ },
5233
+ unoptimized,
5234
+ ...unoptimized ? { loader: ({ src: src2 }) => src2 } : { loader: void 0 }
5235
+ }
5236
+ )
5237
+ )
5238
+ )
5239
+ );
5240
+ }
5241
+
5242
+ // src/custom-dialog/index.tsx
5243
+ import {
5244
+ Box as Box25,
5245
+ Dialog as Dialog8,
5066
5246
  DialogActions as DialogActions4,
5067
5247
  DialogContent as DialogContent6,
5068
5248
  DialogTitle as DialogTitle6,
5069
5249
  Divider as Divider4,
5070
- IconButton as IconButton10,
5250
+ IconButton as IconButton11,
5071
5251
  Stack as Stack7,
5072
5252
  Tooltip as Tooltip4
5073
5253
  } from "@mui/material";
5074
- import { MdClose as MdClose5 } from "react-icons/md";
5254
+ import { MdClose as MdClose6 } from "react-icons/md";
5075
5255
  function CustomDialog({
5076
5256
  title,
5077
5257
  icon: Icon,
@@ -5091,7 +5271,7 @@ function CustomDialog({
5091
5271
  onClose();
5092
5272
  };
5093
5273
  return /* @__PURE__ */ React.createElement(
5094
- Dialog7,
5274
+ Dialog8,
5095
5275
  {
5096
5276
  open,
5097
5277
  onClose: handleClose,
@@ -5111,7 +5291,7 @@ function CustomDialog({
5111
5291
  sx: { cursor: "move" },
5112
5292
  id: "draggable-dialog"
5113
5293
  },
5114
- /* @__PURE__ */ React.createElement(Stack7, { direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React.createElement(Box24, null, Icon && /* @__PURE__ */ React.createElement(
5294
+ /* @__PURE__ */ React.createElement(Stack7, { direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React.createElement(Box25, null, Icon && /* @__PURE__ */ React.createElement(
5115
5295
  Stack7,
5116
5296
  {
5117
5297
  alignItems: "center",
@@ -5144,10 +5324,10 @@ function CustomDialog({
5144
5324
  }
5145
5325
  },
5146
5326
  /* @__PURE__ */ React.createElement(Icon, { size: 20 })
5147
- )), /* @__PURE__ */ React.createElement(Box24, null, title))
5327
+ )), /* @__PURE__ */ React.createElement(Box25, null, title))
5148
5328
  ),
5149
5329
  /* @__PURE__ */ React.createElement(Tooltip4, { title: "\u0628\u0633\u062A\u0646" }, /* @__PURE__ */ React.createElement(
5150
- IconButton10,
5330
+ IconButton11,
5151
5331
  {
5152
5332
  "aria-label": "close",
5153
5333
  onClick: onClose,
@@ -5159,7 +5339,7 @@ function CustomDialog({
5159
5339
  },
5160
5340
  disabled: isSubmiting
5161
5341
  },
5162
- /* @__PURE__ */ React.createElement(MdClose5, null)
5342
+ /* @__PURE__ */ React.createElement(MdClose6, null)
5163
5343
  )),
5164
5344
  /* @__PURE__ */ React.createElement(Divider4, null),
5165
5345
  /* @__PURE__ */ React.createElement(DialogContent6, null, children),
@@ -5186,6 +5366,7 @@ export {
5186
5366
  number_type_default as FormInputNumber,
5187
5367
  text_type_default as FormInputText,
5188
5368
  HorizontalStepper,
5369
+ imgViewer as ImgViewer,
5189
5370
  LicensePlate,
5190
5371
  mobile_date_time_picker_default as MobileDateTimePicker,
5191
5372
  ConfirmationDialog2 as Modal,