@mamrp/components 1.3.0 → 1.3.2

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.js CHANGED
@@ -43,6 +43,7 @@ __export(src_exports, {
43
43
  DateTimePicker: () => date_time_picker_default,
44
44
  DateTimeRangePicker: () => date_time_range_picker_default,
45
45
  DraggablePaper: () => DraggablePaper,
46
+ EnhancedUploadImage: () => enhanced_upload_image_default,
46
47
  FormInputNumber: () => number_type_default,
47
48
  FormInputText: () => text_type_default,
48
49
  HorizontalStepper: () => HorizontalStepper,
@@ -1971,11 +1972,26 @@ var import_x_date_pickers4 = require("@mui/x-date-pickers");
1971
1972
  var import_AdapterMomentJalaali4 = require("@mui/x-date-pickers/AdapterMomentJalaali");
1972
1973
  var import_dayjs2 = __toESM(require("dayjs"));
1973
1974
  var import_moment_jalaali4 = __toESM(require("moment-jalaali"));
1974
- var import_fa5 = require("moment/locale/fa");
1975
1975
  var import_react13 = __toESM(require("react"));
1976
1976
  var import_react_hook_form9 = require("react-hook-form");
1977
1977
  import_moment_jalaali4.default.locale("fa");
1978
1978
  import_moment_jalaali4.default.loadPersian({ dialect: "persian-modern", usePersianDigits: true });
1979
+ import_moment_jalaali4.default.updateLocale("fa", {
1980
+ months: [
1981
+ "\u0641\u0631\u0648\u0631\u062F\u06CC\u0646",
1982
+ "\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A",
1983
+ "\u062E\u0631\u062F\u0627\u062F",
1984
+ "\u062A\u06CC\u0631",
1985
+ "\u0645\u0631\u062F\u0627\u062F",
1986
+ "\u0634\u0647\u0631\u06CC\u0648\u0631",
1987
+ "\u0645\u0647\u0631",
1988
+ "\u0622\u0628\u0627\u0646",
1989
+ "\u0622\u0630\u0631",
1990
+ "\u062F\u06CC",
1991
+ "\u0628\u0647\u0645\u0646",
1992
+ "\u0627\u0633\u0641\u0646\u062F"
1993
+ ]
1994
+ });
1979
1995
  var DateMonthPicker = ({
1980
1996
  name,
1981
1997
  control,
@@ -1989,7 +2005,6 @@ var DateMonthPicker = ({
1989
2005
  clear = true
1990
2006
  }) => {
1991
2007
  const today = (0, import_moment_jalaali4.default)();
1992
- const [open, setOpen] = (0, import_react13.useState)(false);
1993
2008
  const customLocaleText = {
1994
2009
  cancelButtonLabel: "\u0644\u063A\u0648",
1995
2010
  okButtonLabel: "\u062A\u0623\u06CC\u06CC\u062F",
@@ -2914,7 +2929,7 @@ var import_material17 = require("@mui/material");
2914
2929
  var import_Stack = __toESM(require("@mui/material/Stack"));
2915
2930
  var import_system5 = require("@mui/system");
2916
2931
  var React17 = __toESM(require("react"));
2917
- var import_fa6 = require("react-icons/fa");
2932
+ var import_fa5 = require("react-icons/fa");
2918
2933
  function PaginationList({
2919
2934
  currentPage,
2920
2935
  setCurrentPage,
@@ -2958,7 +2973,7 @@ function PaginationList({
2958
2973
  justifyContent: "center"
2959
2974
  },
2960
2975
  size: "large",
2961
- startIcon: /* @__PURE__ */ React17.createElement(import_fa6.FaChevronRight, null)
2976
+ startIcon: /* @__PURE__ */ React17.createElement(import_fa5.FaChevronRight, null)
2962
2977
  },
2963
2978
  "\u0642\u0628\u0644\u06CC",
2964
2979
  " "
@@ -2999,7 +3014,7 @@ function PaginationList({
2999
3014
  justifyContent: "center"
3000
3015
  },
3001
3016
  size: "large",
3002
- endIcon: /* @__PURE__ */ React17.createElement(import_fa6.FaChevronLeft, null)
3017
+ endIcon: /* @__PURE__ */ React17.createElement(import_fa5.FaChevronLeft, null)
3003
3018
  },
3004
3019
  "\u0628\u0639\u062F\u06CC",
3005
3020
  " "
@@ -4030,14 +4045,562 @@ var UploadImage = ({
4030
4045
  };
4031
4046
  var upload_image_default = UploadImage;
4032
4047
 
4048
+ // src/enhanced-upload-image/index.tsx
4049
+ var import_icons = require("@mamrp/icons");
4050
+ var import_material24 = require("@mui/material");
4051
+ var import_image5 = __toESM(require("next/image"));
4052
+ var import_react27 = __toESM(require("react"));
4053
+ var import_react_hook_form16 = require("react-hook-form");
4054
+ var import_gr2 = require("react-icons/gr");
4055
+ var import_md7 = require("react-icons/md");
4056
+
4057
+ // src/enhanced-upload-image/ImageViewer.tsx
4058
+ var import_material23 = require("@mui/material");
4059
+ var import_image4 = __toESM(require("next/image"));
4060
+ var import_react26 = require("react");
4061
+ var import_md6 = require("react-icons/md");
4062
+ function ImageViewer({
4063
+ open,
4064
+ handleClose,
4065
+ src,
4066
+ isLoading,
4067
+ title = "",
4068
+ noResetBtn = false,
4069
+ noRotate = false,
4070
+ noZoom = false
4071
+ }) {
4072
+ const [zoom, setZoom] = (0, import_react26.useState)(1);
4073
+ const [rotate, setRotate] = (0, import_react26.useState)(0);
4074
+ const [loading, setLoading] = (0, import_react26.useState)(true);
4075
+ const [viewerOpen, setViewerOpen] = (0, import_react26.useState)(false);
4076
+ const [viewerSrc, setViewerSrc] = (0, import_react26.useState)("");
4077
+ const [position, setPosition] = (0, import_react26.useState)({ x: 0, y: 0 });
4078
+ const [dragging, setDragging] = (0, import_react26.useState)(false);
4079
+ const [startMouse, setStartMouse] = (0, import_react26.useState)({ x: 0, y: 0 });
4080
+ const [startOffset, setStartOffset] = (0, import_react26.useState)({ x: 0, y: 0 });
4081
+ const reset = () => {
4082
+ setZoom(1);
4083
+ setRotate(0);
4084
+ setPosition({ x: 0, y: 0 });
4085
+ };
4086
+ const handleWheel = (0, import_react26.useCallback)((e) => {
4087
+ e.preventDefault();
4088
+ const delta = -e.deltaY * 1e-3;
4089
+ setZoom((z) => Math.min(5, Math.max(0.2, z + delta)));
4090
+ }, []);
4091
+ const handleMouseDown = (e) => {
4092
+ setDragging(true);
4093
+ setStartMouse({ x: e.clientX, y: e.clientY });
4094
+ setStartOffset({ ...position });
4095
+ };
4096
+ const handleMouseMove = (e) => {
4097
+ if (!dragging) return;
4098
+ const dx = e.clientX - startMouse.x;
4099
+ const dy = e.clientY - startMouse.y;
4100
+ setPosition({
4101
+ x: startOffset.x - dx,
4102
+ y: startOffset.y + dy
4103
+ });
4104
+ };
4105
+ const handleMouseUp = () => setDragging(false);
4106
+ (0, import_react26.useEffect)(() => {
4107
+ if (dragging) {
4108
+ window.addEventListener("mousemove", handleMouseMove);
4109
+ window.addEventListener("mouseup", handleMouseUp);
4110
+ } else {
4111
+ window.removeEventListener("mousemove", handleMouseMove);
4112
+ window.removeEventListener("mouseup", handleMouseUp);
4113
+ }
4114
+ return () => {
4115
+ window.removeEventListener("mousemove", handleMouseMove);
4116
+ window.removeEventListener("mouseup", handleMouseUp);
4117
+ };
4118
+ }, [dragging, startMouse, startOffset]);
4119
+ (0, import_react26.useEffect)(() => {
4120
+ if (open) reset();
4121
+ }, [open]);
4122
+ return /* @__PURE__ */ React.createElement(
4123
+ import_material23.Dialog,
4124
+ {
4125
+ open,
4126
+ onClose: handleClose,
4127
+ maxWidth: "xl",
4128
+ fullWidth: true,
4129
+ sx: {
4130
+ "& .MuiPaper-root": {
4131
+ borderRadius: 3,
4132
+ backgroundColor: "transparent"
4133
+ }
4134
+ }
4135
+ },
4136
+ /* @__PURE__ */ React.createElement(
4137
+ import_material23.Box,
4138
+ {
4139
+ sx: {
4140
+ position: "relative",
4141
+ width: "100%",
4142
+ height: "90vh",
4143
+ bgcolor: "rgba(17,17,17,0.9)",
4144
+ overflow: "hidden",
4145
+ display: "flex",
4146
+ justifyContent: "center",
4147
+ alignItems: "center"
4148
+ },
4149
+ onWheel: handleWheel
4150
+ },
4151
+ /* @__PURE__ */ React.createElement(
4152
+ import_material23.Box,
4153
+ {
4154
+ sx: {
4155
+ position: "absolute",
4156
+ top: 10,
4157
+ left: 10,
4158
+ zIndex: 20,
4159
+ display: "flex",
4160
+ gap: 1,
4161
+ alignItems: "center"
4162
+ }
4163
+ },
4164
+ /* @__PURE__ */ React.createElement(import_material23.IconButton, { onClick: handleClose }, /* @__PURE__ */ React.createElement(import_md6.MdClose, { color: "white" })),
4165
+ !noResetBtn && /* @__PURE__ */ React.createElement(import_material23.IconButton, { onClick: reset }, /* @__PURE__ */ React.createElement("span", { style: { color: "white", fontSize: "0.9rem" } }, "\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u06CC")),
4166
+ !noRotate && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(import_material23.IconButton, { onClick: () => setRotate((r) => r - 90) }, /* @__PURE__ */ React.createElement(import_md6.MdRotateLeft, { color: "white" })), /* @__PURE__ */ React.createElement(import_material23.IconButton, { onClick: () => setRotate((r) => r + 90) }, /* @__PURE__ */ React.createElement(import_md6.MdRotateRight, { color: "white" }))),
4167
+ !noZoom && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(import_material23.IconButton, { onClick: () => setZoom((z) => z + 0.2) }, /* @__PURE__ */ React.createElement(import_md6.MdZoomIn, { color: "white" })), /* @__PURE__ */ React.createElement(
4168
+ import_material23.IconButton,
4169
+ {
4170
+ onClick: () => setZoom((z) => Math.max(0.2, z - 0.2))
4171
+ },
4172
+ /* @__PURE__ */ React.createElement(import_md6.MdZoomOut, { color: "white" })
4173
+ )),
4174
+ /* @__PURE__ */ React.createElement(import_material23.Typography, { color: "white" }, title)
4175
+ ),
4176
+ (isLoading || loading) && /* @__PURE__ */ React.createElement(
4177
+ import_material23.Box,
4178
+ {
4179
+ sx: {
4180
+ position: "absolute",
4181
+ zIndex: 10,
4182
+ top: "50%",
4183
+ left: "50%",
4184
+ transform: "translate(-50%, -50%)",
4185
+ color: "white"
4186
+ }
4187
+ },
4188
+ /* @__PURE__ */ React.createElement(import_material23.CircularProgress, { color: "inherit" })
4189
+ ),
4190
+ /* @__PURE__ */ React.createElement(
4191
+ import_material23.Box,
4192
+ {
4193
+ onMouseDown: handleMouseDown,
4194
+ sx: {
4195
+ position: "relative",
4196
+ width: "100%",
4197
+ height: "78vh",
4198
+ cursor: dragging ? "grabbing" : "grab",
4199
+ display: "flex",
4200
+ justifyContent: "center",
4201
+ alignItems: "center",
4202
+ overflow: "hidden"
4203
+ }
4204
+ },
4205
+ src && !isLoading && /* @__PURE__ */ React.createElement(
4206
+ import_image4.default,
4207
+ {
4208
+ src,
4209
+ alt: title,
4210
+ fill: true,
4211
+ style: {
4212
+ objectFit: "contain",
4213
+ transform: `translate(${position.x}px, ${position.y}px) scale(${zoom}) rotate(${rotate}deg)`,
4214
+ transition: dragging ? "none" : "transform 0.3s ease"
4215
+ },
4216
+ onLoadingComplete: () => setLoading(false)
4217
+ }
4218
+ )
4219
+ )
4220
+ ),
4221
+ /* @__PURE__ */ React.createElement(
4222
+ ImageViewer,
4223
+ {
4224
+ open: viewerOpen,
4225
+ handleClose: () => setViewerOpen(false),
4226
+ src: src || "",
4227
+ isLoading: false
4228
+ }
4229
+ )
4230
+ );
4231
+ }
4232
+
4233
+ // src/enhanced-upload-image/index.tsx
4234
+ var UploadImage2 = ({
4235
+ placeholder,
4236
+ name,
4237
+ selectedImage,
4238
+ setSelectedImage,
4239
+ control,
4240
+ errors,
4241
+ setValue,
4242
+ height = "280px",
4243
+ allowGallery = false,
4244
+ imageFit = "cover"
4245
+ }) => {
4246
+ const theme2 = (0, import_material24.useTheme)();
4247
+ const [viewerOpen, setViewerOpen] = (0, import_react27.useState)(false);
4248
+ const [viewerSrc, setViewerSrc] = (0, import_react27.useState)("");
4249
+ const compressImage = (file, quality = 0.9, maxWidth = 1600, maxHeight = 1600) => {
4250
+ return new Promise((resolve) => {
4251
+ const reader = new FileReader();
4252
+ reader.readAsDataURL(file);
4253
+ reader.onload = (event) => {
4254
+ const img = new window.Image();
4255
+ img.src = event.target?.result;
4256
+ img.onload = () => {
4257
+ const canvas = document.createElement("canvas");
4258
+ let width = img.width;
4259
+ let height2 = img.height;
4260
+ if (width > maxWidth) {
4261
+ height2 *= maxWidth / width;
4262
+ width = maxWidth;
4263
+ }
4264
+ if (height2 > maxHeight) {
4265
+ width *= maxHeight / height2;
4266
+ height2 = maxHeight;
4267
+ }
4268
+ canvas.width = width;
4269
+ canvas.height = height2;
4270
+ const ctx = canvas.getContext("2d");
4271
+ if (ctx) {
4272
+ ctx.drawImage(img, 0, 0, width, height2);
4273
+ canvas.toBlob(
4274
+ (blob) => {
4275
+ if (blob) {
4276
+ const compressedFile = new File([blob], file.name, {
4277
+ type: "image/jpeg",
4278
+ lastModified: Date.now()
4279
+ });
4280
+ resolve(compressedFile);
4281
+ } else {
4282
+ resolve(null);
4283
+ }
4284
+ },
4285
+ "image/jpeg",
4286
+ quality
4287
+ );
4288
+ } else {
4289
+ resolve(null);
4290
+ }
4291
+ };
4292
+ };
4293
+ });
4294
+ };
4295
+ const handleImageChange = async (event) => {
4296
+ const file = event.target.files?.[0];
4297
+ if (file) {
4298
+ console.log("Original file size (KB):", (file.size / 1024).toFixed(2));
4299
+ const compressedFile = await compressImage(file);
4300
+ if (compressedFile) {
4301
+ console.log(
4302
+ "Compressed file size (KB):",
4303
+ (compressedFile.size / 1024).toFixed(2)
4304
+ );
4305
+ const objectURL = URL.createObjectURL(compressedFile);
4306
+ setSelectedImage(objectURL);
4307
+ setValue(name, compressedFile);
4308
+ }
4309
+ }
4310
+ };
4311
+ const handleRemoveImage = () => {
4312
+ setSelectedImage(null);
4313
+ setValue(name, null);
4314
+ const galleryInput = document.getElementById(
4315
+ "gallery-upload"
4316
+ );
4317
+ const cameraInput = document.getElementById(
4318
+ "camera-upload"
4319
+ );
4320
+ const fileInput = document.getElementById(
4321
+ "file-upload"
4322
+ );
4323
+ if (galleryInput) galleryInput.value = "";
4324
+ if (cameraInput) cameraInput.value = "";
4325
+ if (fileInput) fileInput.value = "";
4326
+ };
4327
+ return /* @__PURE__ */ import_react27.default.createElement(
4328
+ import_react_hook_form16.Controller,
4329
+ {
4330
+ name,
4331
+ control,
4332
+ render: ({ field }) => /* @__PURE__ */ import_react27.default.createElement(import_material24.Box, { sx: { width: "100%" } }, /* @__PURE__ */ import_react27.default.createElement(
4333
+ import_material24.Box,
4334
+ {
4335
+ sx: {
4336
+ position: "relative",
4337
+ width: "100%",
4338
+ height,
4339
+ borderRadius: 3,
4340
+ overflow: "hidden",
4341
+ backgroundColor: selectedImage ? "transparent" : (0, import_material24.alpha)(theme2.palette.primary.main, 0.02),
4342
+ border: selectedImage ? `2px solid ${(0, import_material24.alpha)(theme2.palette.primary.main, 0.1)}` : `2px dashed ${(0, import_material24.alpha)(theme2.palette.primary.main, 0.2)}`,
4343
+ transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
4344
+ cursor: allowGallery ? "default" : "pointer",
4345
+ "&:hover": {
4346
+ borderColor: selectedImage ? (0, import_material24.alpha)(theme2.palette.primary.main, 0.3) : (0, import_material24.alpha)(theme2.palette.primary.main, 0.4),
4347
+ backgroundColor: selectedImage ? "transparent" : (0, import_material24.alpha)(theme2.palette.primary.main, 0.04)
4348
+ }
4349
+ }
4350
+ },
4351
+ selectedImage ? /* @__PURE__ */ import_react27.default.createElement(import_react27.default.Fragment, null, /* @__PURE__ */ import_react27.default.createElement(
4352
+ import_image5.default,
4353
+ {
4354
+ src: selectedImage,
4355
+ alt: "Preview",
4356
+ width: 900,
4357
+ height: 600,
4358
+ style: {
4359
+ maxWidth: "100%",
4360
+ maxHeight: "250px",
4361
+ borderRadius: "8px",
4362
+ border: "1px solid #ccc",
4363
+ objectFit: "contain",
4364
+ cursor: "pointer"
4365
+ },
4366
+ onClick: () => {
4367
+ setViewerSrc(selectedImage);
4368
+ setViewerOpen(true);
4369
+ }
4370
+ }
4371
+ ), /* @__PURE__ */ import_react27.default.createElement(import_material24.Fade, { in: true }, /* @__PURE__ */ import_react27.default.createElement(import_material24.Tooltip, { title: "\u062D\u0630\u0641" }, /* @__PURE__ */ import_react27.default.createElement(
4372
+ import_material24.IconButton,
4373
+ {
4374
+ onClick: (e) => {
4375
+ e.preventDefault();
4376
+ e.stopPropagation();
4377
+ handleRemoveImage();
4378
+ },
4379
+ sx: {
4380
+ position: "absolute",
4381
+ top: 12,
4382
+ right: 12,
4383
+ backgroundColor: (0, import_material24.alpha)(theme2.palette.error.main, 0.9),
4384
+ color: "white",
4385
+ width: 40,
4386
+ height: 40,
4387
+ "&:hover": {
4388
+ backgroundColor: theme2.palette.error.main,
4389
+ transform: "scale(1.1)"
4390
+ },
4391
+ transition: "all 0.2s ease",
4392
+ boxShadow: `0 4px 12px ${(0, import_material24.alpha)(
4393
+ theme2.palette.error.main,
4394
+ 0.3
4395
+ )}`
4396
+ }
4397
+ },
4398
+ /* @__PURE__ */ import_react27.default.createElement(import_icons.Delete, { size: 18 })
4399
+ )))) : /* @__PURE__ */ import_react27.default.createElement(
4400
+ import_material24.Stack,
4401
+ {
4402
+ spacing: 3,
4403
+ sx: {
4404
+ height: "100%",
4405
+ justifyContent: "center",
4406
+ alignItems: "center",
4407
+ p: 3
4408
+ }
4409
+ },
4410
+ /* @__PURE__ */ import_react27.default.createElement(import_material24.Stack, { spacing: 2, alignItems: "center" }, /* @__PURE__ */ import_react27.default.createElement(
4411
+ import_material24.Box,
4412
+ {
4413
+ sx: {
4414
+ width: 64,
4415
+ height: 64,
4416
+ borderRadius: "50%",
4417
+ backgroundColor: (0, import_material24.alpha)(
4418
+ theme2.palette.successLight.main,
4419
+ 0.1
4420
+ ),
4421
+ display: "flex",
4422
+ alignItems: "center",
4423
+ justifyContent: "center",
4424
+ transition: "all 0.3s ease"
4425
+ }
4426
+ },
4427
+ /* @__PURE__ */ import_react27.default.createElement(
4428
+ import_md7.MdAddPhotoAlternate,
4429
+ {
4430
+ size: 32,
4431
+ color: theme2.palette.successLight.main,
4432
+ style: { opacity: 0.8 }
4433
+ }
4434
+ )
4435
+ ), /* @__PURE__ */ import_react27.default.createElement(
4436
+ import_material24.Typography,
4437
+ {
4438
+ variant: "h6",
4439
+ sx: {
4440
+ color: theme2.palette.text.primary,
4441
+ fontWeight: 500,
4442
+ textAlign: "center",
4443
+ mb: 1
4444
+ }
4445
+ },
4446
+ placeholder
4447
+ ), /* @__PURE__ */ import_react27.default.createElement(
4448
+ import_material24.Typography,
4449
+ {
4450
+ variant: "body2",
4451
+ sx: {
4452
+ color: theme2.palette.text.secondary,
4453
+ textAlign: "center",
4454
+ fontSize: "0.875rem"
4455
+ }
4456
+ },
4457
+ "PNG, JPG \u06CC\u0627 WEBP \u067E\u0634\u062A\u06CC\u0628\u0627\u0646\u06CC \u0645\u06CC\u200C\u0634\u0648\u062F"
4458
+ )),
4459
+ allowGallery && /* @__PURE__ */ import_react27.default.createElement(import_material24.Stack, { direction: "row", spacing: 2 }, /* @__PURE__ */ import_react27.default.createElement(
4460
+ import_material24.Button,
4461
+ {
4462
+ variant: "contained",
4463
+ startIcon: /* @__PURE__ */ import_react27.default.createElement(import_md7.MdOutlineCameraAlt, { size: 16 }),
4464
+ onClick: (e) => {
4465
+ e.preventDefault();
4466
+ document.getElementById("camera-upload")?.click();
4467
+ },
4468
+ sx: {
4469
+ borderRadius: 2,
4470
+ px: 2.5,
4471
+ textTransform: "none",
4472
+ fontWeight: 600,
4473
+ boxShadow: `0 4px 12px ${(0, import_material24.alpha)(
4474
+ theme2.palette.successLight.main,
4475
+ 0.3
4476
+ )}`,
4477
+ zIndex: 1,
4478
+ transition: "all 0.2s ease",
4479
+ "&:hover": {
4480
+ boxShadow: `0 6px 20px ${(0, import_material24.alpha)(
4481
+ theme2.palette.successLight.main,
4482
+ 0.4
4483
+ )}`,
4484
+ transform: "translateY(-1px)"
4485
+ }
4486
+ },
4487
+ color: "successLight"
4488
+ },
4489
+ "\u062F\u0648\u0631\u0628\u06CC\u0646"
4490
+ ), /* @__PURE__ */ import_react27.default.createElement(
4491
+ import_material24.Button,
4492
+ {
4493
+ variant: "outlined",
4494
+ startIcon: /* @__PURE__ */ import_react27.default.createElement(import_gr2.GrGallery, { size: 16 }),
4495
+ onClick: (e) => {
4496
+ e.preventDefault();
4497
+ document.getElementById("gallery-upload")?.click();
4498
+ },
4499
+ sx: {
4500
+ borderRadius: 2,
4501
+ px: 2.5,
4502
+ textTransform: "none",
4503
+ fontWeight: 600,
4504
+ borderWidth: 2,
4505
+ transition: "all 0.2s ease",
4506
+ "&:hover": {
4507
+ boxShadow: `0 6px 20px ${(0, import_material24.alpha)(
4508
+ theme2.palette.successLight.main,
4509
+ 0.4
4510
+ )}`,
4511
+ transform: "translateY(-1px)"
4512
+ }
4513
+ },
4514
+ color: "successLight"
4515
+ },
4516
+ "\u06AF\u0627\u0644\u0631\u06CC"
4517
+ ))
4518
+ )
4519
+ ), !allowGallery && /* @__PURE__ */ import_react27.default.createElement(
4520
+ "input",
4521
+ {
4522
+ id: "file-upload",
4523
+ type: "file",
4524
+ accept: "image/*",
4525
+ capture: "environment",
4526
+ onChange: (event) => {
4527
+ handleImageChange(event);
4528
+ field.onChange(event.target.files?.[0] || null);
4529
+ },
4530
+ style: { display: "none" }
4531
+ }
4532
+ ), /* @__PURE__ */ import_react27.default.createElement(
4533
+ "input",
4534
+ {
4535
+ id: "gallery-upload",
4536
+ type: "file",
4537
+ accept: "image/*",
4538
+ onChange: (event) => {
4539
+ handleImageChange(event);
4540
+ field.onChange(event.target.files?.[0] || null);
4541
+ },
4542
+ style: { display: "none" }
4543
+ }
4544
+ ), /* @__PURE__ */ import_react27.default.createElement(
4545
+ "input",
4546
+ {
4547
+ id: "camera-upload",
4548
+ type: "file",
4549
+ accept: "image/*",
4550
+ capture: "environment",
4551
+ onChange: (event) => {
4552
+ handleImageChange(event);
4553
+ field.onChange(event.target.files?.[0] || null);
4554
+ },
4555
+ style: { display: "none" }
4556
+ }
4557
+ ), errors[name] && /* @__PURE__ */ import_react27.default.createElement(import_material24.Fade, { in: true }, /* @__PURE__ */ import_react27.default.createElement(
4558
+ import_material24.Box,
4559
+ {
4560
+ sx: {
4561
+ mt: 1.5,
4562
+ p: 1.5,
4563
+ borderRadius: 1,
4564
+ backgroundColor: (0, import_material24.alpha)(theme2.palette.error.main, 0.05),
4565
+ border: `1px solid ${(0, import_material24.alpha)(theme2.palette.error.main, 0.2)}`
4566
+ }
4567
+ },
4568
+ /* @__PURE__ */ import_react27.default.createElement(
4569
+ import_material24.Typography,
4570
+ {
4571
+ color: "error",
4572
+ variant: "body2",
4573
+ sx: {
4574
+ fontWeight: 500,
4575
+ display: "flex",
4576
+ alignItems: "center",
4577
+ gap: 1
4578
+ }
4579
+ },
4580
+ String(errors[name]?.message || "")
4581
+ )
4582
+ )), /* @__PURE__ */ import_react27.default.createElement(
4583
+ ImageViewer,
4584
+ {
4585
+ open: viewerOpen,
4586
+ handleClose: () => setViewerOpen(false),
4587
+ src: viewerSrc,
4588
+ isLoading: false
4589
+ }
4590
+ ))
4591
+ }
4592
+ );
4593
+ };
4594
+ var enhanced_upload_image_default = UploadImage2;
4595
+
4033
4596
  // src/accordion/index.tsx
4034
4597
  var import_styles2 = require("@mui/material/styles");
4035
4598
  var import_io2 = require("react-icons/io");
4036
4599
  var import_Accordion = __toESM(require("@mui/material/Accordion"));
4037
4600
  var import_AccordionSummary = __toESM(require("@mui/material/AccordionSummary"));
4038
4601
  var import_AccordionDetails = __toESM(require("@mui/material/AccordionDetails"));
4039
- var import_material23 = require("@mui/material");
4040
- var import_react26 = require("react");
4602
+ var import_material25 = require("@mui/material");
4603
+ var import_react28 = require("react");
4041
4604
  function Page({
4042
4605
  data
4043
4606
  }) {
@@ -4067,7 +4630,7 @@ function Page({
4067
4630
  padding: theme2.spacing(2),
4068
4631
  borderTop: "1px solid rgba(0, 0, 0, .125)"
4069
4632
  }));
4070
- const [expanded, setExpanded] = (0, import_react26.useState)("");
4633
+ const [expanded, setExpanded] = (0, import_react28.useState)("");
4071
4634
  const handleChange = (panel) => (event, newExpanded) => {
4072
4635
  setExpanded(newExpanded ? panel : false);
4073
4636
  };
@@ -4091,7 +4654,7 @@ function Page({
4091
4654
  }
4092
4655
  }
4093
4656
  },
4094
- /* @__PURE__ */ React.createElement(import_material23.Typography, { component: "span" }, item.title)
4657
+ /* @__PURE__ */ React.createElement(import_material25.Typography, { component: "span" }, item.title)
4095
4658
  ),
4096
4659
  /* @__PURE__ */ React.createElement(AccordionDetails, null, item.body)
4097
4660
  );
@@ -4099,20 +4662,20 @@ function Page({
4099
4662
  }
4100
4663
 
4101
4664
  // src/switch-button/index.tsx
4102
- var import_material24 = require("@mui/material");
4665
+ var import_material26 = require("@mui/material");
4103
4666
  var import_system8 = require("@mui/system");
4104
- var import_react27 = __toESM(require("react"));
4667
+ var import_react29 = __toESM(require("react"));
4105
4668
  var import_pi = require("react-icons/pi");
4106
- var import_material25 = require("@mui/material");
4669
+ var import_material27 = require("@mui/material");
4107
4670
  var SwitchButton = ({
4108
4671
  checked,
4109
4672
  handleChange,
4110
4673
  iconChecked,
4111
4674
  iconUnchecked
4112
4675
  }) => {
4113
- const theme2 = (0, import_material25.useTheme)();
4676
+ const theme2 = (0, import_material27.useTheme)();
4114
4677
  const isDarkMode = theme2.palette.mode === "dark";
4115
- const CustomSwitch = (0, import_system8.styled)(import_material24.Switch)(({ theme: theme3 }) => ({
4678
+ const CustomSwitch = (0, import_system8.styled)(import_material26.Switch)(({ theme: theme3 }) => ({
4116
4679
  "& .MuiSwitch-switchBase.Mui-checked": {
4117
4680
  color: theme3.palette.primary.main
4118
4681
  },
@@ -4125,7 +4688,7 @@ var SwitchButton = ({
4125
4688
  border: isDarkMode ? "2px solid white" : "2px solid rgba(80,80,80, 1)"
4126
4689
  }
4127
4690
  }));
4128
- const BoxContainer = (0, import_system8.styled)(import_material24.Box)(({ theme: theme3 }) => ({
4691
+ const BoxContainer = (0, import_system8.styled)(import_material26.Box)(({ theme: theme3 }) => ({
4129
4692
  display: "flex",
4130
4693
  alignItems: "center",
4131
4694
  backgroundColor: "rgba(188,188,188, 0.1)",
@@ -4140,10 +4703,10 @@ var SwitchButton = ({
4140
4703
  transition: "all 0.2s ease",
4141
4704
  color: isDarkMode ? "rgba(220,220,220, 1)" : "rgba(160,160,160, 1)"
4142
4705
  });
4143
- return /* @__PURE__ */ import_react27.default.createElement(BoxContainer, null, /* @__PURE__ */ import_react27.default.createElement(
4144
- import_material24.FormControlLabel,
4706
+ return /* @__PURE__ */ import_react29.default.createElement(BoxContainer, null, /* @__PURE__ */ import_react29.default.createElement(
4707
+ import_material26.FormControlLabel,
4145
4708
  {
4146
- control: /* @__PURE__ */ import_react27.default.createElement(
4709
+ control: /* @__PURE__ */ import_react29.default.createElement(
4147
4710
  CustomSwitch,
4148
4711
  {
4149
4712
  checked,
@@ -4151,15 +4714,15 @@ var SwitchButton = ({
4151
4714
  name: "switch"
4152
4715
  }
4153
4716
  ),
4154
- label: /* @__PURE__ */ import_react27.default.createElement(LabelContainer, null, checked ? iconChecked ? iconChecked : /* @__PURE__ */ import_react27.default.createElement(import_pi.PiTableDuotone, { size: 30 }) : iconUnchecked ? iconUnchecked : /* @__PURE__ */ import_react27.default.createElement(import_pi.PiCardsDuotone, { size: 30 }))
4717
+ label: /* @__PURE__ */ import_react29.default.createElement(LabelContainer, null, checked ? iconChecked ? iconChecked : /* @__PURE__ */ import_react29.default.createElement(import_pi.PiTableDuotone, { size: 30 }) : iconUnchecked ? iconUnchecked : /* @__PURE__ */ import_react29.default.createElement(import_pi.PiCardsDuotone, { size: 30 }))
4155
4718
  }
4156
4719
  ));
4157
4720
  };
4158
4721
  var switch_button_default = SwitchButton;
4159
4722
 
4160
4723
  // src/bascule-connection-button/index.tsx
4161
- var import_material26 = require("@mui/material");
4162
- var import_react28 = __toESM(require("react"));
4724
+ var import_material28 = require("@mui/material");
4725
+ var import_react30 = __toESM(require("react"));
4163
4726
  var import_react_hot_toast = __toESM(require("react-hot-toast"));
4164
4727
  var import_pi2 = require("react-icons/pi");
4165
4728
  var ConnectToBasculeButton = ({
@@ -4169,8 +4732,8 @@ var ConnectToBasculeButton = ({
4169
4732
  parity = "none",
4170
4733
  flowControl = "none"
4171
4734
  }) => {
4172
- const [connected, setConnected] = (0, import_react28.useState)(false);
4173
- const portRef = (0, import_react28.useRef)(null);
4735
+ const [connected, setConnected] = (0, import_react30.useState)(false);
4736
+ const portRef = (0, import_react30.useRef)(null);
4174
4737
  const connectToBascule = async () => {
4175
4738
  if (!("serial" in navigator)) {
4176
4739
  import_react_hot_toast.default.error("Web Serial API \u062A\u0648\u0633\u0637 \u0627\u06CC\u0646 \u0645\u0631\u0648\u0631\u06AF\u0631 \u067E\u0634\u062A\u06CC\u0628\u0627\u0646\u06CC \u0646\u0645\u06CC\u200C\u0634\u0648\u062F.");
@@ -4188,7 +4751,7 @@ var ConnectToBasculeButton = ({
4188
4751
  import_react_hot_toast.default.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.");
4189
4752
  }
4190
4753
  };
4191
- return /* @__PURE__ */ import_react28.default.createElement(import_react28.default.Fragment, null, /* @__PURE__ */ import_react28.default.createElement("style", null, `
4754
+ return /* @__PURE__ */ import_react30.default.createElement(import_react30.default.Fragment, null, /* @__PURE__ */ import_react30.default.createElement("style", null, `
4192
4755
  @keyframes jumpAnimation {
4193
4756
  0% { transform: translateY(1px); }
4194
4757
  12.5% { transform: translateY(-2px); }
@@ -4197,16 +4760,16 @@ var ConnectToBasculeButton = ({
4197
4760
  50% { transform: translateY(0); }
4198
4761
  100% { transform: translateY(0); }
4199
4762
  }
4200
- `), /* @__PURE__ */ import_react28.default.createElement(
4201
- import_material26.Button,
4763
+ `), /* @__PURE__ */ import_react30.default.createElement(
4764
+ import_material28.Button,
4202
4765
  {
4203
4766
  variant: "contained",
4204
4767
  onClick: connectToBascule,
4205
4768
  disabled: connected,
4206
4769
  sx: { minWidth: "11rem" }
4207
4770
  },
4208
- /* @__PURE__ */ import_react28.default.createElement(
4209
- import_material26.Box,
4771
+ /* @__PURE__ */ import_react30.default.createElement(
4772
+ import_material28.Box,
4210
4773
  {
4211
4774
  sx: {
4212
4775
  display: "flex",
@@ -4215,7 +4778,7 @@ var ConnectToBasculeButton = ({
4215
4778
  fontSize: 16
4216
4779
  }
4217
4780
  },
4218
- connected ? /* @__PURE__ */ import_react28.default.createElement(import_react28.default.Fragment, null, "\u0645\u062A\u0635\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ import_react28.default.createElement(import_pi2.PiPlugsConnected, { size: 20 })) : /* @__PURE__ */ import_react28.default.createElement(import_react28.default.Fragment, null, "\u0627\u062A\u0635\u0627\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ import_react28.default.createElement(
4781
+ connected ? /* @__PURE__ */ import_react30.default.createElement(import_react30.default.Fragment, null, "\u0645\u062A\u0635\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ import_react30.default.createElement(import_pi2.PiPlugsConnected, { size: 20 })) : /* @__PURE__ */ import_react30.default.createElement(import_react30.default.Fragment, null, "\u0627\u062A\u0635\u0627\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ import_react30.default.createElement(
4219
4782
  import_pi2.PiPlugs,
4220
4783
  {
4221
4784
  size: 20,
@@ -4230,15 +4793,15 @@ var ConnectToBasculeButton = ({
4230
4793
  var bascule_connection_button_default = ConnectToBasculeButton;
4231
4794
 
4232
4795
  // src/draggable-paper/index.tsx
4233
- var import_material27 = require("@mui/material");
4234
- var import_react29 = require("react");
4796
+ var import_material29 = require("@mui/material");
4797
+ var import_react31 = require("react");
4235
4798
  var import_react_draggable = __toESM(require("react-draggable"));
4236
4799
  function DraggablePaper({
4237
4800
  handle = "#draggable-dialog",
4238
4801
  cancel = '[class*="MuiDialogContent-root"]',
4239
4802
  ...props
4240
4803
  }) {
4241
- const nodeRef = (0, import_react29.useRef)(null);
4804
+ const nodeRef = (0, import_react31.useRef)(null);
4242
4805
  return /* @__PURE__ */ React.createElement(
4243
4806
  import_react_draggable.default,
4244
4807
  {
@@ -4248,7 +4811,7 @@ function DraggablePaper({
4248
4811
  bounds: "parent",
4249
4812
  defaultPosition: { x: 0, y: 0 }
4250
4813
  },
4251
- /* @__PURE__ */ React.createElement(import_material27.Paper, { ref: nodeRef, ...props })
4814
+ /* @__PURE__ */ React.createElement(import_material29.Paper, { ref: nodeRef, ...props })
4252
4815
  );
4253
4816
  }
4254
4817
  // Annotate the CommonJS export names for ESM import in node:
@@ -4266,6 +4829,7 @@ function DraggablePaper({
4266
4829
  DateTimePicker,
4267
4830
  DateTimeRangePicker,
4268
4831
  DraggablePaper,
4832
+ EnhancedUploadImage,
4269
4833
  FormInputNumber,
4270
4834
  FormInputText,
4271
4835
  HorizontalStepper,