@mamrp/components 1.7.16 → 1.7.18

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
@@ -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,
@@ -5080,9 +5260,15 @@ function CustomDialog({
5080
5260
  onClose,
5081
5261
  maxWidth = "sm",
5082
5262
  fullWidth = true,
5263
+ fullScreen = false,
5083
5264
  children,
5084
5265
  actions,
5085
- isSubmiting = false
5266
+ isSubmiting = false,
5267
+ sx,
5268
+ paperSx,
5269
+ contentSx,
5270
+ titleSx,
5271
+ actionsSx
5086
5272
  }) {
5087
5273
  const handleClose = (event, reason) => {
5088
5274
  if (isSubmiting) {
@@ -5091,79 +5277,156 @@ function CustomDialog({
5091
5277
  onClose();
5092
5278
  };
5093
5279
  return /* @__PURE__ */ React.createElement(
5094
- Dialog7,
5280
+ Dialog8,
5095
5281
  {
5096
5282
  open,
5097
5283
  onClose: handleClose,
5098
5284
  maxWidth,
5099
5285
  fullWidth,
5100
- PaperComponent: DraggablePaper,
5101
- disableScrollLock: true
5286
+ fullScreen,
5287
+ PaperComponent: fullScreen ? void 0 : DraggablePaper,
5288
+ disableScrollLock: true,
5289
+ sx: [
5290
+ fullScreen ? {
5291
+ "& .MuiDialog-container": {
5292
+ alignItems: "flex-start"
5293
+ }
5294
+ } : {},
5295
+ ...Array.isArray(sx) ? sx : [sx]
5296
+ ],
5297
+ PaperProps: {
5298
+ sx: [
5299
+ fullScreen ? {
5300
+ height: "100vh",
5301
+ maxHeight: "100vh",
5302
+ width: "100%",
5303
+ maxWidth: "100%",
5304
+ margin: 0,
5305
+ borderRadius: 0,
5306
+ overflow: "hidden"
5307
+ } : {
5308
+ maxHeight: "calc(100vh - 64px)"
5309
+ },
5310
+ ...Array.isArray(paperSx) ? paperSx : [paperSx]
5311
+ ]
5312
+ }
5102
5313
  },
5103
5314
  /* @__PURE__ */ React.createElement(
5104
- DialogTitle6,
5315
+ Box25,
5105
5316
  {
5106
- fontWeight: 700,
5107
- fontSize: "1.2rem",
5108
- display: "flex",
5109
- alignItems: "center",
5110
- gap: "4px",
5111
- sx: { cursor: "move" },
5112
- id: "draggable-dialog"
5317
+ sx: {
5318
+ display: "flex",
5319
+ flexDirection: "column",
5320
+ height: fullScreen ? "100%" : "auto"
5321
+ }
5113
5322
  },
5114
- /* @__PURE__ */ React.createElement(Stack7, { direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React.createElement(Box24, null, Icon && /* @__PURE__ */ React.createElement(
5115
- Stack7,
5323
+ /* @__PURE__ */ React.createElement(
5324
+ DialogTitle6,
5116
5325
  {
5326
+ fontWeight: 700,
5327
+ fontSize: "1.2rem",
5328
+ display: "flex",
5117
5329
  alignItems: "center",
5118
- sx: {
5119
- color: iconColor ? (theme3) => {
5120
- const paletteColors = [
5121
- "primary",
5122
- "secondary",
5123
- "error",
5124
- "warning",
5125
- "info",
5126
- "success",
5127
- "tertiary",
5128
- "accent",
5129
- "successLight",
5130
- "orange",
5131
- "indigo",
5132
- "teal",
5133
- "pinkLight",
5134
- "aqua",
5135
- "customRed"
5136
- ];
5137
- if (paletteColors.includes(iconColor)) {
5138
- const palette = theme3.palette;
5139
- return palette[iconColor]?.main || iconColor;
5140
- }
5141
- return iconColor;
5142
- } : (theme3) => theme3.palette.info.main,
5143
- pr: 0.5
5144
- }
5330
+ gap: "4px",
5331
+ sx: [
5332
+ fullScreen ? { cursor: "default" } : { cursor: "move" },
5333
+ {
5334
+ flexShrink: 0,
5335
+ py: 2,
5336
+ px: 3
5337
+ },
5338
+ ...Array.isArray(titleSx) ? titleSx : [titleSx]
5339
+ ],
5340
+ id: fullScreen ? void 0 : "draggable-dialog"
5145
5341
  },
5146
- /* @__PURE__ */ React.createElement(Icon, { size: 20 })
5147
- )), /* @__PURE__ */ React.createElement(Box24, null, title))
5148
- ),
5149
- /* @__PURE__ */ React.createElement(Tooltip4, { title: "\u0628\u0633\u062A\u0646" }, /* @__PURE__ */ React.createElement(
5150
- IconButton10,
5151
- {
5152
- "aria-label": "close",
5153
- onClick: onClose,
5154
- sx: {
5155
- position: "absolute",
5156
- right: 8,
5157
- top: 8,
5158
- color: (theme3) => theme3.palette.grey[500]
5342
+ /* @__PURE__ */ React.createElement(Stack7, { direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React.createElement(Box25, null, Icon && /* @__PURE__ */ React.createElement(
5343
+ Stack7,
5344
+ {
5345
+ alignItems: "center",
5346
+ sx: {
5347
+ color: iconColor ? (theme3) => {
5348
+ const paletteColors = [
5349
+ "primary",
5350
+ "secondary",
5351
+ "error",
5352
+ "warning",
5353
+ "info",
5354
+ "success",
5355
+ "tertiary",
5356
+ "accent",
5357
+ "successLight",
5358
+ "orange",
5359
+ "indigo",
5360
+ "teal",
5361
+ "pinkLight",
5362
+ "aqua",
5363
+ "customRed"
5364
+ ];
5365
+ if (paletteColors.includes(iconColor)) {
5366
+ const palette = theme3.palette;
5367
+ return palette[iconColor]?.main || iconColor;
5368
+ }
5369
+ return iconColor;
5370
+ } : (theme3) => theme3.palette.info.main,
5371
+ pr: 0.5
5372
+ }
5373
+ },
5374
+ /* @__PURE__ */ React.createElement(Icon, { size: 20 })
5375
+ )), /* @__PURE__ */ React.createElement(Box25, null, title))
5376
+ ),
5377
+ /* @__PURE__ */ React.createElement(Tooltip4, { title: "\u0628\u0633\u062A\u0646" }, /* @__PURE__ */ React.createElement(
5378
+ IconButton11,
5379
+ {
5380
+ "aria-label": "close",
5381
+ onClick: onClose,
5382
+ sx: [
5383
+ {
5384
+ position: "absolute",
5385
+ right: 8,
5386
+ top: 8,
5387
+ color: (theme3) => theme3.palette.grey[500]
5388
+ },
5389
+ fullScreen && {
5390
+ top: 12,
5391
+ right: 12
5392
+ }
5393
+ ],
5394
+ disabled: isSubmiting
5159
5395
  },
5160
- disabled: isSubmiting
5161
- },
5162
- /* @__PURE__ */ React.createElement(MdClose5, null)
5163
- )),
5164
- /* @__PURE__ */ React.createElement(Divider4, null),
5165
- /* @__PURE__ */ React.createElement(DialogContent6, null, children),
5166
- actions && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DialogActions4, null, actions))
5396
+ /* @__PURE__ */ React.createElement(MdClose6, null)
5397
+ )),
5398
+ /* @__PURE__ */ React.createElement(Divider4, { sx: { flexShrink: 0 } }),
5399
+ /* @__PURE__ */ React.createElement(
5400
+ DialogContent6,
5401
+ {
5402
+ sx: [
5403
+ {
5404
+ flex: 1,
5405
+ display: "flex",
5406
+ flexDirection: "column",
5407
+ overflow: "auto",
5408
+ p: 0
5409
+ },
5410
+ ...Array.isArray(contentSx) ? contentSx : [contentSx]
5411
+ ]
5412
+ },
5413
+ /* @__PURE__ */ React.createElement(Box25, { sx: { p: fullScreen ? 3 : 2, flex: 1, overflow: "auto" } }, children)
5414
+ ),
5415
+ actions && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
5416
+ DialogActions4,
5417
+ {
5418
+ sx: [
5419
+ {
5420
+ flexShrink: 0,
5421
+ py: 2,
5422
+ px: 3
5423
+ },
5424
+ ...Array.isArray(actionsSx) ? actionsSx : [actionsSx]
5425
+ ]
5426
+ },
5427
+ actions
5428
+ ))
5429
+ )
5167
5430
  );
5168
5431
  }
5169
5432
  export {
@@ -5186,6 +5449,7 @@ export {
5186
5449
  number_type_default as FormInputNumber,
5187
5450
  text_type_default as FormInputText,
5188
5451
  HorizontalStepper,
5452
+ imgViewer as ImgViewer,
5189
5453
  LicensePlate,
5190
5454
  mobile_date_time_picker_default as MobileDateTimePicker,
5191
5455
  ConfirmationDialog2 as Modal,