@mamrp/components 1.2.3 → 1.3.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.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +578 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +594 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -12
package/dist/index.mjs
CHANGED
|
@@ -4009,6 +4009,578 @@ var UploadImage = ({
|
|
|
4009
4009
|
};
|
|
4010
4010
|
var upload_image_default = UploadImage;
|
|
4011
4011
|
|
|
4012
|
+
// src/enhanced-upload-image/index.tsx
|
|
4013
|
+
import { Delete as Delete2 } from "@mamrp/icons";
|
|
4014
|
+
import {
|
|
4015
|
+
alpha,
|
|
4016
|
+
Box as Box20,
|
|
4017
|
+
Button as Button12,
|
|
4018
|
+
Fade,
|
|
4019
|
+
IconButton as IconButton8,
|
|
4020
|
+
Stack as Stack6,
|
|
4021
|
+
Tooltip as Tooltip2,
|
|
4022
|
+
Typography as Typography16,
|
|
4023
|
+
useTheme as useTheme6
|
|
4024
|
+
} from "@mui/material";
|
|
4025
|
+
import Image5 from "next/image";
|
|
4026
|
+
import React27, { useState as useState13 } from "react";
|
|
4027
|
+
import {
|
|
4028
|
+
Controller as Controller13
|
|
4029
|
+
} from "react-hook-form";
|
|
4030
|
+
import { GrGallery as GrGallery2 } from "react-icons/gr";
|
|
4031
|
+
import { MdAddPhotoAlternate, MdOutlineCameraAlt as MdOutlineCameraAlt2 } from "react-icons/md";
|
|
4032
|
+
|
|
4033
|
+
// src/enhanced-upload-image/ImageViewer.tsx
|
|
4034
|
+
import {
|
|
4035
|
+
Box as Box19,
|
|
4036
|
+
CircularProgress as CircularProgress8,
|
|
4037
|
+
Dialog as Dialog6,
|
|
4038
|
+
IconButton as IconButton7,
|
|
4039
|
+
Typography as Typography15
|
|
4040
|
+
} from "@mui/material";
|
|
4041
|
+
import Image4 from "next/image";
|
|
4042
|
+
import { useCallback, useEffect as useEffect9, useState as useState12 } from "react";
|
|
4043
|
+
import {
|
|
4044
|
+
MdClose as MdClose4,
|
|
4045
|
+
MdRotateLeft,
|
|
4046
|
+
MdRotateRight,
|
|
4047
|
+
MdZoomIn,
|
|
4048
|
+
MdZoomOut
|
|
4049
|
+
} from "react-icons/md";
|
|
4050
|
+
function ImageViewer({
|
|
4051
|
+
open,
|
|
4052
|
+
handleClose,
|
|
4053
|
+
src,
|
|
4054
|
+
isLoading,
|
|
4055
|
+
title = "",
|
|
4056
|
+
noResetBtn = false,
|
|
4057
|
+
noRotate = false,
|
|
4058
|
+
noZoom = false
|
|
4059
|
+
}) {
|
|
4060
|
+
const [zoom, setZoom] = useState12(1);
|
|
4061
|
+
const [rotate, setRotate] = useState12(0);
|
|
4062
|
+
const [loading, setLoading] = useState12(true);
|
|
4063
|
+
const [viewerOpen, setViewerOpen] = useState12(false);
|
|
4064
|
+
const [viewerSrc, setViewerSrc] = useState12("");
|
|
4065
|
+
const [position, setPosition] = useState12({ x: 0, y: 0 });
|
|
4066
|
+
const [dragging, setDragging] = useState12(false);
|
|
4067
|
+
const [startMouse, setStartMouse] = useState12({ x: 0, y: 0 });
|
|
4068
|
+
const [startOffset, setStartOffset] = useState12({ x: 0, y: 0 });
|
|
4069
|
+
const reset = () => {
|
|
4070
|
+
setZoom(1);
|
|
4071
|
+
setRotate(0);
|
|
4072
|
+
setPosition({ x: 0, y: 0 });
|
|
4073
|
+
};
|
|
4074
|
+
const handleWheel = useCallback((e) => {
|
|
4075
|
+
e.preventDefault();
|
|
4076
|
+
const delta = -e.deltaY * 1e-3;
|
|
4077
|
+
setZoom((z) => Math.min(5, Math.max(0.2, z + delta)));
|
|
4078
|
+
}, []);
|
|
4079
|
+
const handleMouseDown = (e) => {
|
|
4080
|
+
setDragging(true);
|
|
4081
|
+
setStartMouse({ x: e.clientX, y: e.clientY });
|
|
4082
|
+
setStartOffset({ ...position });
|
|
4083
|
+
};
|
|
4084
|
+
const handleMouseMove = (e) => {
|
|
4085
|
+
if (!dragging) return;
|
|
4086
|
+
const dx = e.clientX - startMouse.x;
|
|
4087
|
+
const dy = e.clientY - startMouse.y;
|
|
4088
|
+
setPosition({
|
|
4089
|
+
x: startOffset.x - dx,
|
|
4090
|
+
y: startOffset.y + dy
|
|
4091
|
+
});
|
|
4092
|
+
};
|
|
4093
|
+
const handleMouseUp = () => setDragging(false);
|
|
4094
|
+
useEffect9(() => {
|
|
4095
|
+
if (dragging) {
|
|
4096
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
4097
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
4098
|
+
} else {
|
|
4099
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
4100
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
4101
|
+
}
|
|
4102
|
+
return () => {
|
|
4103
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
4104
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
4105
|
+
};
|
|
4106
|
+
}, [dragging, startMouse, startOffset]);
|
|
4107
|
+
useEffect9(() => {
|
|
4108
|
+
if (open) reset();
|
|
4109
|
+
}, [open]);
|
|
4110
|
+
return /* @__PURE__ */ React.createElement(
|
|
4111
|
+
Dialog6,
|
|
4112
|
+
{
|
|
4113
|
+
open,
|
|
4114
|
+
onClose: handleClose,
|
|
4115
|
+
maxWidth: "xl",
|
|
4116
|
+
fullWidth: true,
|
|
4117
|
+
sx: {
|
|
4118
|
+
"& .MuiPaper-root": {
|
|
4119
|
+
borderRadius: 3,
|
|
4120
|
+
backgroundColor: "transparent"
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
},
|
|
4124
|
+
/* @__PURE__ */ React.createElement(
|
|
4125
|
+
Box19,
|
|
4126
|
+
{
|
|
4127
|
+
sx: {
|
|
4128
|
+
position: "relative",
|
|
4129
|
+
width: "100%",
|
|
4130
|
+
height: "90vh",
|
|
4131
|
+
bgcolor: "rgba(17,17,17,0.9)",
|
|
4132
|
+
overflow: "hidden",
|
|
4133
|
+
display: "flex",
|
|
4134
|
+
justifyContent: "center",
|
|
4135
|
+
alignItems: "center"
|
|
4136
|
+
},
|
|
4137
|
+
onWheel: handleWheel
|
|
4138
|
+
},
|
|
4139
|
+
/* @__PURE__ */ React.createElement(
|
|
4140
|
+
Box19,
|
|
4141
|
+
{
|
|
4142
|
+
sx: {
|
|
4143
|
+
position: "absolute",
|
|
4144
|
+
top: 10,
|
|
4145
|
+
left: 10,
|
|
4146
|
+
zIndex: 20,
|
|
4147
|
+
display: "flex",
|
|
4148
|
+
gap: 1,
|
|
4149
|
+
alignItems: "center"
|
|
4150
|
+
}
|
|
4151
|
+
},
|
|
4152
|
+
/* @__PURE__ */ React.createElement(IconButton7, { onClick: handleClose }, /* @__PURE__ */ React.createElement(MdClose4, { color: "white" })),
|
|
4153
|
+
!noResetBtn && /* @__PURE__ */ React.createElement(IconButton7, { onClick: reset }, /* @__PURE__ */ React.createElement("span", { style: { color: "white", fontSize: "0.9rem" } }, "\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u06CC")),
|
|
4154
|
+
!noRotate && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(IconButton7, { onClick: () => setRotate((r) => r - 90) }, /* @__PURE__ */ React.createElement(MdRotateLeft, { color: "white" })), /* @__PURE__ */ React.createElement(IconButton7, { onClick: () => setRotate((r) => r + 90) }, /* @__PURE__ */ React.createElement(MdRotateRight, { color: "white" }))),
|
|
4155
|
+
!noZoom && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(IconButton7, { onClick: () => setZoom((z) => z + 0.2) }, /* @__PURE__ */ React.createElement(MdZoomIn, { color: "white" })), /* @__PURE__ */ React.createElement(
|
|
4156
|
+
IconButton7,
|
|
4157
|
+
{
|
|
4158
|
+
onClick: () => setZoom((z) => Math.max(0.2, z - 0.2))
|
|
4159
|
+
},
|
|
4160
|
+
/* @__PURE__ */ React.createElement(MdZoomOut, { color: "white" })
|
|
4161
|
+
)),
|
|
4162
|
+
/* @__PURE__ */ React.createElement(Typography15, { color: "white" }, title)
|
|
4163
|
+
),
|
|
4164
|
+
(isLoading || loading) && /* @__PURE__ */ React.createElement(
|
|
4165
|
+
Box19,
|
|
4166
|
+
{
|
|
4167
|
+
sx: {
|
|
4168
|
+
position: "absolute",
|
|
4169
|
+
zIndex: 10,
|
|
4170
|
+
top: "50%",
|
|
4171
|
+
left: "50%",
|
|
4172
|
+
transform: "translate(-50%, -50%)",
|
|
4173
|
+
color: "white"
|
|
4174
|
+
}
|
|
4175
|
+
},
|
|
4176
|
+
/* @__PURE__ */ React.createElement(CircularProgress8, { color: "inherit" })
|
|
4177
|
+
),
|
|
4178
|
+
/* @__PURE__ */ React.createElement(
|
|
4179
|
+
Box19,
|
|
4180
|
+
{
|
|
4181
|
+
onMouseDown: handleMouseDown,
|
|
4182
|
+
sx: {
|
|
4183
|
+
position: "relative",
|
|
4184
|
+
width: "100%",
|
|
4185
|
+
height: "78vh",
|
|
4186
|
+
cursor: dragging ? "grabbing" : "grab",
|
|
4187
|
+
display: "flex",
|
|
4188
|
+
justifyContent: "center",
|
|
4189
|
+
alignItems: "center",
|
|
4190
|
+
overflow: "hidden"
|
|
4191
|
+
}
|
|
4192
|
+
},
|
|
4193
|
+
src && !isLoading && /* @__PURE__ */ React.createElement(
|
|
4194
|
+
Image4,
|
|
4195
|
+
{
|
|
4196
|
+
src,
|
|
4197
|
+
alt: title,
|
|
4198
|
+
fill: true,
|
|
4199
|
+
style: {
|
|
4200
|
+
objectFit: "contain",
|
|
4201
|
+
transform: `translate(${position.x}px, ${position.y}px) scale(${zoom}) rotate(${rotate}deg)`,
|
|
4202
|
+
transition: dragging ? "none" : "transform 0.3s ease"
|
|
4203
|
+
},
|
|
4204
|
+
onLoadingComplete: () => setLoading(false)
|
|
4205
|
+
}
|
|
4206
|
+
)
|
|
4207
|
+
)
|
|
4208
|
+
),
|
|
4209
|
+
/* @__PURE__ */ React.createElement(
|
|
4210
|
+
ImageViewer,
|
|
4211
|
+
{
|
|
4212
|
+
open: viewerOpen,
|
|
4213
|
+
handleClose: () => setViewerOpen(false),
|
|
4214
|
+
src: src || "",
|
|
4215
|
+
isLoading: false
|
|
4216
|
+
}
|
|
4217
|
+
)
|
|
4218
|
+
);
|
|
4219
|
+
}
|
|
4220
|
+
|
|
4221
|
+
// src/enhanced-upload-image/index.tsx
|
|
4222
|
+
var UploadImage2 = ({
|
|
4223
|
+
placeholder,
|
|
4224
|
+
name,
|
|
4225
|
+
selectedImage,
|
|
4226
|
+
setSelectedImage,
|
|
4227
|
+
control,
|
|
4228
|
+
errors,
|
|
4229
|
+
setValue,
|
|
4230
|
+
height = "280px",
|
|
4231
|
+
allowGallery = false,
|
|
4232
|
+
imageFit = "cover"
|
|
4233
|
+
}) => {
|
|
4234
|
+
const theme2 = useTheme6();
|
|
4235
|
+
const [viewerOpen, setViewerOpen] = useState13(false);
|
|
4236
|
+
const [viewerSrc, setViewerSrc] = useState13("");
|
|
4237
|
+
const compressImage = (file, quality = 0.9, maxWidth = 1600, maxHeight = 1600) => {
|
|
4238
|
+
return new Promise((resolve) => {
|
|
4239
|
+
const reader = new FileReader();
|
|
4240
|
+
reader.readAsDataURL(file);
|
|
4241
|
+
reader.onload = (event) => {
|
|
4242
|
+
const img = new window.Image();
|
|
4243
|
+
img.src = event.target?.result;
|
|
4244
|
+
img.onload = () => {
|
|
4245
|
+
const canvas = document.createElement("canvas");
|
|
4246
|
+
let width = img.width;
|
|
4247
|
+
let height2 = img.height;
|
|
4248
|
+
if (width > maxWidth) {
|
|
4249
|
+
height2 *= maxWidth / width;
|
|
4250
|
+
width = maxWidth;
|
|
4251
|
+
}
|
|
4252
|
+
if (height2 > maxHeight) {
|
|
4253
|
+
width *= maxHeight / height2;
|
|
4254
|
+
height2 = maxHeight;
|
|
4255
|
+
}
|
|
4256
|
+
canvas.width = width;
|
|
4257
|
+
canvas.height = height2;
|
|
4258
|
+
const ctx = canvas.getContext("2d");
|
|
4259
|
+
if (ctx) {
|
|
4260
|
+
ctx.drawImage(img, 0, 0, width, height2);
|
|
4261
|
+
canvas.toBlob(
|
|
4262
|
+
(blob) => {
|
|
4263
|
+
if (blob) {
|
|
4264
|
+
const compressedFile = new File([blob], file.name, {
|
|
4265
|
+
type: "image/jpeg",
|
|
4266
|
+
lastModified: Date.now()
|
|
4267
|
+
});
|
|
4268
|
+
resolve(compressedFile);
|
|
4269
|
+
} else {
|
|
4270
|
+
resolve(null);
|
|
4271
|
+
}
|
|
4272
|
+
},
|
|
4273
|
+
"image/jpeg",
|
|
4274
|
+
quality
|
|
4275
|
+
);
|
|
4276
|
+
} else {
|
|
4277
|
+
resolve(null);
|
|
4278
|
+
}
|
|
4279
|
+
};
|
|
4280
|
+
};
|
|
4281
|
+
});
|
|
4282
|
+
};
|
|
4283
|
+
const handleImageChange = async (event) => {
|
|
4284
|
+
const file = event.target.files?.[0];
|
|
4285
|
+
if (file) {
|
|
4286
|
+
console.log("Original file size (KB):", (file.size / 1024).toFixed(2));
|
|
4287
|
+
const compressedFile = await compressImage(file);
|
|
4288
|
+
if (compressedFile) {
|
|
4289
|
+
console.log(
|
|
4290
|
+
"Compressed file size (KB):",
|
|
4291
|
+
(compressedFile.size / 1024).toFixed(2)
|
|
4292
|
+
);
|
|
4293
|
+
const objectURL = URL.createObjectURL(compressedFile);
|
|
4294
|
+
setSelectedImage(objectURL);
|
|
4295
|
+
setValue(name, compressedFile);
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
};
|
|
4299
|
+
const handleRemoveImage = () => {
|
|
4300
|
+
setSelectedImage(null);
|
|
4301
|
+
setValue(name, null);
|
|
4302
|
+
const galleryInput = document.getElementById(
|
|
4303
|
+
"gallery-upload"
|
|
4304
|
+
);
|
|
4305
|
+
const cameraInput = document.getElementById(
|
|
4306
|
+
"camera-upload"
|
|
4307
|
+
);
|
|
4308
|
+
const fileInput = document.getElementById(
|
|
4309
|
+
"file-upload"
|
|
4310
|
+
);
|
|
4311
|
+
if (galleryInput) galleryInput.value = "";
|
|
4312
|
+
if (cameraInput) cameraInput.value = "";
|
|
4313
|
+
if (fileInput) fileInput.value = "";
|
|
4314
|
+
};
|
|
4315
|
+
return /* @__PURE__ */ React27.createElement(
|
|
4316
|
+
Controller13,
|
|
4317
|
+
{
|
|
4318
|
+
name,
|
|
4319
|
+
control,
|
|
4320
|
+
render: ({ field }) => /* @__PURE__ */ React27.createElement(Box20, { sx: { width: "100%" } }, /* @__PURE__ */ React27.createElement(
|
|
4321
|
+
Box20,
|
|
4322
|
+
{
|
|
4323
|
+
sx: {
|
|
4324
|
+
position: "relative",
|
|
4325
|
+
width: "100%",
|
|
4326
|
+
height,
|
|
4327
|
+
borderRadius: 3,
|
|
4328
|
+
overflow: "hidden",
|
|
4329
|
+
backgroundColor: selectedImage ? "transparent" : alpha(theme2.palette.primary.main, 0.02),
|
|
4330
|
+
border: selectedImage ? `2px solid ${alpha(theme2.palette.primary.main, 0.1)}` : `2px dashed ${alpha(theme2.palette.primary.main, 0.2)}`,
|
|
4331
|
+
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
4332
|
+
cursor: allowGallery ? "default" : "pointer",
|
|
4333
|
+
"&:hover": {
|
|
4334
|
+
borderColor: selectedImage ? alpha(theme2.palette.primary.main, 0.3) : alpha(theme2.palette.primary.main, 0.4),
|
|
4335
|
+
backgroundColor: selectedImage ? "transparent" : alpha(theme2.palette.primary.main, 0.04)
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4338
|
+
},
|
|
4339
|
+
selectedImage ? /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement(
|
|
4340
|
+
Image5,
|
|
4341
|
+
{
|
|
4342
|
+
src: selectedImage,
|
|
4343
|
+
alt: "Preview",
|
|
4344
|
+
width: 900,
|
|
4345
|
+
height: 600,
|
|
4346
|
+
style: {
|
|
4347
|
+
maxWidth: "100%",
|
|
4348
|
+
maxHeight: "250px",
|
|
4349
|
+
borderRadius: "8px",
|
|
4350
|
+
border: "1px solid #ccc",
|
|
4351
|
+
objectFit: "contain",
|
|
4352
|
+
cursor: "pointer"
|
|
4353
|
+
},
|
|
4354
|
+
onClick: () => {
|
|
4355
|
+
setViewerSrc(selectedImage);
|
|
4356
|
+
setViewerOpen(true);
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
), /* @__PURE__ */ React27.createElement(Fade, { in: true }, /* @__PURE__ */ React27.createElement(Tooltip2, { title: "\u062D\u0630\u0641" }, /* @__PURE__ */ React27.createElement(
|
|
4360
|
+
IconButton8,
|
|
4361
|
+
{
|
|
4362
|
+
onClick: (e) => {
|
|
4363
|
+
e.preventDefault();
|
|
4364
|
+
e.stopPropagation();
|
|
4365
|
+
handleRemoveImage();
|
|
4366
|
+
},
|
|
4367
|
+
sx: {
|
|
4368
|
+
position: "absolute",
|
|
4369
|
+
top: 12,
|
|
4370
|
+
right: 12,
|
|
4371
|
+
backgroundColor: alpha(theme2.palette.error.main, 0.9),
|
|
4372
|
+
color: "white",
|
|
4373
|
+
width: 40,
|
|
4374
|
+
height: 40,
|
|
4375
|
+
"&:hover": {
|
|
4376
|
+
backgroundColor: theme2.palette.error.main,
|
|
4377
|
+
transform: "scale(1.1)"
|
|
4378
|
+
},
|
|
4379
|
+
transition: "all 0.2s ease",
|
|
4380
|
+
boxShadow: `0 4px 12px ${alpha(
|
|
4381
|
+
theme2.palette.error.main,
|
|
4382
|
+
0.3
|
|
4383
|
+
)}`
|
|
4384
|
+
}
|
|
4385
|
+
},
|
|
4386
|
+
/* @__PURE__ */ React27.createElement(Delete2, { size: 18 })
|
|
4387
|
+
)))) : /* @__PURE__ */ React27.createElement(
|
|
4388
|
+
Stack6,
|
|
4389
|
+
{
|
|
4390
|
+
spacing: 3,
|
|
4391
|
+
sx: {
|
|
4392
|
+
height: "100%",
|
|
4393
|
+
justifyContent: "center",
|
|
4394
|
+
alignItems: "center",
|
|
4395
|
+
p: 3
|
|
4396
|
+
}
|
|
4397
|
+
},
|
|
4398
|
+
/* @__PURE__ */ React27.createElement(Stack6, { spacing: 2, alignItems: "center" }, /* @__PURE__ */ React27.createElement(
|
|
4399
|
+
Box20,
|
|
4400
|
+
{
|
|
4401
|
+
sx: {
|
|
4402
|
+
width: 64,
|
|
4403
|
+
height: 64,
|
|
4404
|
+
borderRadius: "50%",
|
|
4405
|
+
backgroundColor: alpha(
|
|
4406
|
+
theme2.palette.successLight.main,
|
|
4407
|
+
0.1
|
|
4408
|
+
),
|
|
4409
|
+
display: "flex",
|
|
4410
|
+
alignItems: "center",
|
|
4411
|
+
justifyContent: "center",
|
|
4412
|
+
transition: "all 0.3s ease"
|
|
4413
|
+
}
|
|
4414
|
+
},
|
|
4415
|
+
/* @__PURE__ */ React27.createElement(
|
|
4416
|
+
MdAddPhotoAlternate,
|
|
4417
|
+
{
|
|
4418
|
+
size: 32,
|
|
4419
|
+
color: theme2.palette.successLight.main,
|
|
4420
|
+
style: { opacity: 0.8 }
|
|
4421
|
+
}
|
|
4422
|
+
)
|
|
4423
|
+
), /* @__PURE__ */ React27.createElement(
|
|
4424
|
+
Typography16,
|
|
4425
|
+
{
|
|
4426
|
+
variant: "h6",
|
|
4427
|
+
sx: {
|
|
4428
|
+
color: theme2.palette.text.primary,
|
|
4429
|
+
fontWeight: 500,
|
|
4430
|
+
textAlign: "center",
|
|
4431
|
+
mb: 1
|
|
4432
|
+
}
|
|
4433
|
+
},
|
|
4434
|
+
placeholder
|
|
4435
|
+
), /* @__PURE__ */ React27.createElement(
|
|
4436
|
+
Typography16,
|
|
4437
|
+
{
|
|
4438
|
+
variant: "body2",
|
|
4439
|
+
sx: {
|
|
4440
|
+
color: theme2.palette.text.secondary,
|
|
4441
|
+
textAlign: "center",
|
|
4442
|
+
fontSize: "0.875rem"
|
|
4443
|
+
}
|
|
4444
|
+
},
|
|
4445
|
+
"PNG, JPG \u06CC\u0627 WEBP \u067E\u0634\u062A\u06CC\u0628\u0627\u0646\u06CC \u0645\u06CC\u200C\u0634\u0648\u062F"
|
|
4446
|
+
)),
|
|
4447
|
+
allowGallery && /* @__PURE__ */ React27.createElement(Stack6, { direction: "row", spacing: 2 }, /* @__PURE__ */ React27.createElement(
|
|
4448
|
+
Button12,
|
|
4449
|
+
{
|
|
4450
|
+
variant: "contained",
|
|
4451
|
+
startIcon: /* @__PURE__ */ React27.createElement(MdOutlineCameraAlt2, { size: 16 }),
|
|
4452
|
+
onClick: (e) => {
|
|
4453
|
+
e.preventDefault();
|
|
4454
|
+
document.getElementById("camera-upload")?.click();
|
|
4455
|
+
},
|
|
4456
|
+
sx: {
|
|
4457
|
+
borderRadius: 2,
|
|
4458
|
+
px: 2.5,
|
|
4459
|
+
textTransform: "none",
|
|
4460
|
+
fontWeight: 600,
|
|
4461
|
+
boxShadow: `0 4px 12px ${alpha(
|
|
4462
|
+
theme2.palette.successLight.main,
|
|
4463
|
+
0.3
|
|
4464
|
+
)}`,
|
|
4465
|
+
zIndex: 1,
|
|
4466
|
+
transition: "all 0.2s ease",
|
|
4467
|
+
"&:hover": {
|
|
4468
|
+
boxShadow: `0 6px 20px ${alpha(
|
|
4469
|
+
theme2.palette.successLight.main,
|
|
4470
|
+
0.4
|
|
4471
|
+
)}`,
|
|
4472
|
+
transform: "translateY(-1px)"
|
|
4473
|
+
}
|
|
4474
|
+
},
|
|
4475
|
+
color: "successLight"
|
|
4476
|
+
},
|
|
4477
|
+
"\u062F\u0648\u0631\u0628\u06CC\u0646"
|
|
4478
|
+
), /* @__PURE__ */ React27.createElement(
|
|
4479
|
+
Button12,
|
|
4480
|
+
{
|
|
4481
|
+
variant: "outlined",
|
|
4482
|
+
startIcon: /* @__PURE__ */ React27.createElement(GrGallery2, { size: 16 }),
|
|
4483
|
+
onClick: (e) => {
|
|
4484
|
+
e.preventDefault();
|
|
4485
|
+
document.getElementById("gallery-upload")?.click();
|
|
4486
|
+
},
|
|
4487
|
+
sx: {
|
|
4488
|
+
borderRadius: 2,
|
|
4489
|
+
px: 2.5,
|
|
4490
|
+
textTransform: "none",
|
|
4491
|
+
fontWeight: 600,
|
|
4492
|
+
borderWidth: 2,
|
|
4493
|
+
transition: "all 0.2s ease",
|
|
4494
|
+
"&:hover": {
|
|
4495
|
+
boxShadow: `0 6px 20px ${alpha(
|
|
4496
|
+
theme2.palette.successLight.main,
|
|
4497
|
+
0.4
|
|
4498
|
+
)}`,
|
|
4499
|
+
transform: "translateY(-1px)"
|
|
4500
|
+
}
|
|
4501
|
+
},
|
|
4502
|
+
color: "successLight"
|
|
4503
|
+
},
|
|
4504
|
+
"\u06AF\u0627\u0644\u0631\u06CC"
|
|
4505
|
+
))
|
|
4506
|
+
)
|
|
4507
|
+
), !allowGallery && /* @__PURE__ */ React27.createElement(
|
|
4508
|
+
"input",
|
|
4509
|
+
{
|
|
4510
|
+
id: "file-upload",
|
|
4511
|
+
type: "file",
|
|
4512
|
+
accept: "image/*",
|
|
4513
|
+
capture: "environment",
|
|
4514
|
+
onChange: (event) => {
|
|
4515
|
+
handleImageChange(event);
|
|
4516
|
+
field.onChange(event.target.files?.[0] || null);
|
|
4517
|
+
},
|
|
4518
|
+
style: { display: "none" }
|
|
4519
|
+
}
|
|
4520
|
+
), /* @__PURE__ */ React27.createElement(
|
|
4521
|
+
"input",
|
|
4522
|
+
{
|
|
4523
|
+
id: "gallery-upload",
|
|
4524
|
+
type: "file",
|
|
4525
|
+
accept: "image/*",
|
|
4526
|
+
onChange: (event) => {
|
|
4527
|
+
handleImageChange(event);
|
|
4528
|
+
field.onChange(event.target.files?.[0] || null);
|
|
4529
|
+
},
|
|
4530
|
+
style: { display: "none" }
|
|
4531
|
+
}
|
|
4532
|
+
), /* @__PURE__ */ React27.createElement(
|
|
4533
|
+
"input",
|
|
4534
|
+
{
|
|
4535
|
+
id: "camera-upload",
|
|
4536
|
+
type: "file",
|
|
4537
|
+
accept: "image/*",
|
|
4538
|
+
capture: "environment",
|
|
4539
|
+
onChange: (event) => {
|
|
4540
|
+
handleImageChange(event);
|
|
4541
|
+
field.onChange(event.target.files?.[0] || null);
|
|
4542
|
+
},
|
|
4543
|
+
style: { display: "none" }
|
|
4544
|
+
}
|
|
4545
|
+
), errors[name] && /* @__PURE__ */ React27.createElement(Fade, { in: true }, /* @__PURE__ */ React27.createElement(
|
|
4546
|
+
Box20,
|
|
4547
|
+
{
|
|
4548
|
+
sx: {
|
|
4549
|
+
mt: 1.5,
|
|
4550
|
+
p: 1.5,
|
|
4551
|
+
borderRadius: 1,
|
|
4552
|
+
backgroundColor: alpha(theme2.palette.error.main, 0.05),
|
|
4553
|
+
border: `1px solid ${alpha(theme2.palette.error.main, 0.2)}`
|
|
4554
|
+
}
|
|
4555
|
+
},
|
|
4556
|
+
/* @__PURE__ */ React27.createElement(
|
|
4557
|
+
Typography16,
|
|
4558
|
+
{
|
|
4559
|
+
color: "error",
|
|
4560
|
+
variant: "body2",
|
|
4561
|
+
sx: {
|
|
4562
|
+
fontWeight: 500,
|
|
4563
|
+
display: "flex",
|
|
4564
|
+
alignItems: "center",
|
|
4565
|
+
gap: 1
|
|
4566
|
+
}
|
|
4567
|
+
},
|
|
4568
|
+
String(errors[name]?.message || "")
|
|
4569
|
+
)
|
|
4570
|
+
)), /* @__PURE__ */ React27.createElement(
|
|
4571
|
+
ImageViewer,
|
|
4572
|
+
{
|
|
4573
|
+
open: viewerOpen,
|
|
4574
|
+
handleClose: () => setViewerOpen(false),
|
|
4575
|
+
src: viewerSrc,
|
|
4576
|
+
isLoading: false
|
|
4577
|
+
}
|
|
4578
|
+
))
|
|
4579
|
+
}
|
|
4580
|
+
);
|
|
4581
|
+
};
|
|
4582
|
+
var enhanced_upload_image_default = UploadImage2;
|
|
4583
|
+
|
|
4012
4584
|
// src/accordion/index.tsx
|
|
4013
4585
|
import { styled as styled3 } from "@mui/material/styles";
|
|
4014
4586
|
import { IoIosArrowForward } from "react-icons/io";
|
|
@@ -4018,9 +4590,9 @@ import MuiAccordionSummary, {
|
|
|
4018
4590
|
} from "@mui/material/AccordionSummary";
|
|
4019
4591
|
import MuiAccordionDetails from "@mui/material/AccordionDetails";
|
|
4020
4592
|
import {
|
|
4021
|
-
Typography as
|
|
4593
|
+
Typography as Typography17
|
|
4022
4594
|
} from "@mui/material";
|
|
4023
|
-
import { useState as
|
|
4595
|
+
import { useState as useState14 } from "react";
|
|
4024
4596
|
function Page({
|
|
4025
4597
|
data
|
|
4026
4598
|
}) {
|
|
@@ -4050,7 +4622,7 @@ function Page({
|
|
|
4050
4622
|
padding: theme2.spacing(2),
|
|
4051
4623
|
borderTop: "1px solid rgba(0, 0, 0, .125)"
|
|
4052
4624
|
}));
|
|
4053
|
-
const [expanded, setExpanded] =
|
|
4625
|
+
const [expanded, setExpanded] = useState14("");
|
|
4054
4626
|
const handleChange = (panel) => (event, newExpanded) => {
|
|
4055
4627
|
setExpanded(newExpanded ? panel : false);
|
|
4056
4628
|
};
|
|
@@ -4074,7 +4646,7 @@ function Page({
|
|
|
4074
4646
|
}
|
|
4075
4647
|
}
|
|
4076
4648
|
},
|
|
4077
|
-
/* @__PURE__ */ React.createElement(
|
|
4649
|
+
/* @__PURE__ */ React.createElement(Typography17, { component: "span" }, item.title)
|
|
4078
4650
|
),
|
|
4079
4651
|
/* @__PURE__ */ React.createElement(AccordionDetails, null, item.body)
|
|
4080
4652
|
);
|
|
@@ -4082,18 +4654,18 @@ function Page({
|
|
|
4082
4654
|
}
|
|
4083
4655
|
|
|
4084
4656
|
// src/switch-button/index.tsx
|
|
4085
|
-
import { Box as
|
|
4657
|
+
import { Box as Box21, FormControlLabel as FormControlLabel3, Switch } from "@mui/material";
|
|
4086
4658
|
import { styled as styled4 } from "@mui/system";
|
|
4087
|
-
import
|
|
4659
|
+
import React28 from "react";
|
|
4088
4660
|
import { PiCardsDuotone, PiTableDuotone } from "react-icons/pi";
|
|
4089
|
-
import { useTheme as
|
|
4661
|
+
import { useTheme as useTheme7 } from "@mui/material";
|
|
4090
4662
|
var SwitchButton = ({
|
|
4091
4663
|
checked,
|
|
4092
4664
|
handleChange,
|
|
4093
4665
|
iconChecked,
|
|
4094
4666
|
iconUnchecked
|
|
4095
4667
|
}) => {
|
|
4096
|
-
const theme2 =
|
|
4668
|
+
const theme2 = useTheme7();
|
|
4097
4669
|
const isDarkMode = theme2.palette.mode === "dark";
|
|
4098
4670
|
const CustomSwitch = styled4(Switch)(({ theme: theme3 }) => ({
|
|
4099
4671
|
"& .MuiSwitch-switchBase.Mui-checked": {
|
|
@@ -4108,7 +4680,7 @@ var SwitchButton = ({
|
|
|
4108
4680
|
border: isDarkMode ? "2px solid white" : "2px solid rgba(80,80,80, 1)"
|
|
4109
4681
|
}
|
|
4110
4682
|
}));
|
|
4111
|
-
const BoxContainer = styled4(
|
|
4683
|
+
const BoxContainer = styled4(Box21)(({ theme: theme3 }) => ({
|
|
4112
4684
|
display: "flex",
|
|
4113
4685
|
alignItems: "center",
|
|
4114
4686
|
backgroundColor: "rgba(188,188,188, 0.1)",
|
|
@@ -4123,10 +4695,10 @@ var SwitchButton = ({
|
|
|
4123
4695
|
transition: "all 0.2s ease",
|
|
4124
4696
|
color: isDarkMode ? "rgba(220,220,220, 1)" : "rgba(160,160,160, 1)"
|
|
4125
4697
|
});
|
|
4126
|
-
return /* @__PURE__ */
|
|
4698
|
+
return /* @__PURE__ */ React28.createElement(BoxContainer, null, /* @__PURE__ */ React28.createElement(
|
|
4127
4699
|
FormControlLabel3,
|
|
4128
4700
|
{
|
|
4129
|
-
control: /* @__PURE__ */
|
|
4701
|
+
control: /* @__PURE__ */ React28.createElement(
|
|
4130
4702
|
CustomSwitch,
|
|
4131
4703
|
{
|
|
4132
4704
|
checked,
|
|
@@ -4134,15 +4706,15 @@ var SwitchButton = ({
|
|
|
4134
4706
|
name: "switch"
|
|
4135
4707
|
}
|
|
4136
4708
|
),
|
|
4137
|
-
label: /* @__PURE__ */
|
|
4709
|
+
label: /* @__PURE__ */ React28.createElement(LabelContainer, null, checked ? iconChecked ? iconChecked : /* @__PURE__ */ React28.createElement(PiTableDuotone, { size: 30 }) : iconUnchecked ? iconUnchecked : /* @__PURE__ */ React28.createElement(PiCardsDuotone, { size: 30 }))
|
|
4138
4710
|
}
|
|
4139
4711
|
));
|
|
4140
4712
|
};
|
|
4141
4713
|
var switch_button_default = SwitchButton;
|
|
4142
4714
|
|
|
4143
4715
|
// src/bascule-connection-button/index.tsx
|
|
4144
|
-
import { Box as
|
|
4145
|
-
import
|
|
4716
|
+
import { Box as Box22, Button as Button13 } from "@mui/material";
|
|
4717
|
+
import React29, { useRef as useRef4, useState as useState15 } from "react";
|
|
4146
4718
|
import toast from "react-hot-toast";
|
|
4147
4719
|
import { PiPlugs, PiPlugsConnected } from "react-icons/pi";
|
|
4148
4720
|
var ConnectToBasculeButton = ({
|
|
@@ -4152,7 +4724,7 @@ var ConnectToBasculeButton = ({
|
|
|
4152
4724
|
parity = "none",
|
|
4153
4725
|
flowControl = "none"
|
|
4154
4726
|
}) => {
|
|
4155
|
-
const [connected, setConnected] =
|
|
4727
|
+
const [connected, setConnected] = useState15(false);
|
|
4156
4728
|
const portRef = useRef4(null);
|
|
4157
4729
|
const connectToBascule = async () => {
|
|
4158
4730
|
if (!("serial" in navigator)) {
|
|
@@ -4171,7 +4743,7 @@ var ConnectToBasculeButton = ({
|
|
|
4171
4743
|
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.");
|
|
4172
4744
|
}
|
|
4173
4745
|
};
|
|
4174
|
-
return /* @__PURE__ */
|
|
4746
|
+
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement("style", null, `
|
|
4175
4747
|
@keyframes jumpAnimation {
|
|
4176
4748
|
0% { transform: translateY(1px); }
|
|
4177
4749
|
12.5% { transform: translateY(-2px); }
|
|
@@ -4180,16 +4752,16 @@ var ConnectToBasculeButton = ({
|
|
|
4180
4752
|
50% { transform: translateY(0); }
|
|
4181
4753
|
100% { transform: translateY(0); }
|
|
4182
4754
|
}
|
|
4183
|
-
`), /* @__PURE__ */
|
|
4184
|
-
|
|
4755
|
+
`), /* @__PURE__ */ React29.createElement(
|
|
4756
|
+
Button13,
|
|
4185
4757
|
{
|
|
4186
4758
|
variant: "contained",
|
|
4187
4759
|
onClick: connectToBascule,
|
|
4188
4760
|
disabled: connected,
|
|
4189
4761
|
sx: { minWidth: "11rem" }
|
|
4190
4762
|
},
|
|
4191
|
-
/* @__PURE__ */
|
|
4192
|
-
|
|
4763
|
+
/* @__PURE__ */ React29.createElement(
|
|
4764
|
+
Box22,
|
|
4193
4765
|
{
|
|
4194
4766
|
sx: {
|
|
4195
4767
|
display: "flex",
|
|
@@ -4198,7 +4770,7 @@ var ConnectToBasculeButton = ({
|
|
|
4198
4770
|
fontSize: 16
|
|
4199
4771
|
}
|
|
4200
4772
|
},
|
|
4201
|
-
connected ? /* @__PURE__ */
|
|
4773
|
+
connected ? /* @__PURE__ */ React29.createElement(React29.Fragment, null, "\u0645\u062A\u0635\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ React29.createElement(PiPlugsConnected, { size: 20 })) : /* @__PURE__ */ React29.createElement(React29.Fragment, null, "\u0627\u062A\u0635\u0627\u0644 \u0628\u0647 \u0628\u0627\u0633\u06A9\u0648\u0644", /* @__PURE__ */ React29.createElement(
|
|
4202
4774
|
PiPlugs,
|
|
4203
4775
|
{
|
|
4204
4776
|
size: 20,
|
|
@@ -4248,6 +4820,7 @@ export {
|
|
|
4248
4820
|
date_time_picker_default as DateTimePicker,
|
|
4249
4821
|
date_time_range_picker_default as DateTimeRangePicker,
|
|
4250
4822
|
DraggablePaper,
|
|
4823
|
+
enhanced_upload_image_default as EnhancedUploadImage,
|
|
4251
4824
|
number_type_default as FormInputNumber,
|
|
4252
4825
|
text_type_default as FormInputText,
|
|
4253
4826
|
HorizontalStepper,
|