px-react-ui-components 1.0.2 → 1.0.5

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.
@@ -1,14 +1,25 @@
1
- import React, { useEffect, useState, useRef } from "react";
2
- import { PiCamera, PiFileArrowUpLight } from "react-icons/pi";
3
- import Resizer from "react-image-file-resizer";
4
- import Camera, { FACING_MODES, IMAGE_TYPES } from "react-html5-camera-photo";
5
- import "react-html5-camera-photo/build/css/index.css";
6
- import MyWaiting from "../MyWaiting/MyWaiting";
7
- import { MyAlert, MyAlertType } from "../MyAlert/MyAlert";
8
- import styles from "./MyFileUpload.module.css";
9
- import MyModal from "../MyModal/MyModal";
10
- import { MdOutlineAttachFile } from "react-icons/md";
11
- export const AcceptType = {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AcceptType = void 0;
7
+ exports.default = MyFileUpload;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _pi = require("react-icons/pi");
10
+ var _reactImageFileResizer = _interopRequireDefault(require("react-image-file-resizer"));
11
+ var _reactHtml5CameraPhoto = _interopRequireWildcard(require("react-html5-camera-photo"));
12
+ require("react-html5-camera-photo/build/css/index.css");
13
+ var _MyWaiting = _interopRequireDefault(require("../MyWaiting/MyWaiting"));
14
+ var _MyAlert = require("../MyAlert/MyAlert");
15
+ var _MyFileUploadModule = _interopRequireDefault(require("./MyFileUpload.module.css"));
16
+ var _MyModal = _interopRequireDefault(require("../MyModal/MyModal"));
17
+ var _md = require("react-icons/md");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ const AcceptType = exports.AcceptType = {
12
23
  ALL: "all",
13
24
  FILE: "file",
14
25
  IMAGE: "image",
@@ -16,8 +27,8 @@ export const AcceptType = {
16
27
  PDF: "pdf",
17
28
  IMAGEPDF: "imagepdf"
18
29
  };
19
- Object.freeze(MyAlertType);
20
- export default function MyFileUpload({
30
+ Object.freeze(_MyAlert.MyAlertType);
31
+ function MyFileUpload({
21
32
  multiple = false,
22
33
  accept = AcceptType.ALL,
23
34
  className = null,
@@ -25,18 +36,18 @@ export default function MyFileUpload({
25
36
  maxSizeMB = 50,
26
37
  onData
27
38
  }) {
28
- const [loading, setLoading] = useState(false);
29
- const [accepttypes, setAccepttypes] = useState(AcceptType.ALL);
30
- const [acceptlabel, setAcceptlabel] = useState(AcceptType.ALL);
31
- const [cameraopen, setCameraopen] = useState(false);
32
- const [cameraopened, setCameraopened] = useState(false);
33
- const [devices, setDevices] = useState([]);
34
- const [selectedDeviceId, setSelectedDeviceId] = useState("");
35
- const fileInputRef = useRef(null);
39
+ const [loading, setLoading] = (0, _react.useState)(false);
40
+ const [accepttypes, setAccepttypes] = (0, _react.useState)(AcceptType.ALL);
41
+ const [acceptlabel, setAcceptlabel] = (0, _react.useState)(AcceptType.ALL);
42
+ const [cameraopen, setCameraopen] = (0, _react.useState)(false);
43
+ const [cameraopened, setCameraopened] = (0, _react.useState)(false);
44
+ const [devices, setDevices] = (0, _react.useState)([]);
45
+ const [selectedDeviceId, setSelectedDeviceId] = (0, _react.useState)("");
46
+ const fileInputRef = (0, _react.useRef)(null);
36
47
  let type_files = ".pdf,.rar,.zip,.doc,.docx,.xls,.xlsx,.ppt,.pptx,msword,msexcel,vnd.ms-excel,vnd.openxmlformats-officedocument.spreadsheetml.sheet,vnd.openxmlformats-officedocument.wordprocessingml.document";
37
48
  let type_image = ".jpg,.jpeg,.png";
38
49
  let type_media = ".mp3,.mp4,.avi,.wav";
39
- useEffect(() => {
50
+ (0, _react.useEffect)(() => {
40
51
  switch (accept) {
41
52
  case AcceptType.ALL:
42
53
  setAccepttypes(type_files + "," + type_image + "," + type_media);
@@ -76,7 +87,7 @@ export default function MyFileUpload({
76
87
  let message = _error.map((e, i) => {
77
88
  return i + 1 + ".) <b><i>" + e.filename + "</i></b><br/>---- " + e.message + "<br/>";
78
89
  });
79
- MyAlert("<br/><br/><div style='display: block;font-size:13px;width: 100%;text-align: left;'>" + message + "</div>", MyAlertType.WARNING);
90
+ (0, _MyAlert.MyAlert)("<br/><br/><div style='display: block;font-size:13px;width: 100%;text-align: left;'>" + message + "</div>", _MyAlert.MyAlertType.WARNING);
80
91
  }
81
92
  if (onData && (Array.isArray(resdata) && resdata.length > 0 || !Array.isArray(resdata) && resdata)) onData(resdata);
82
93
  setLoading(false);
@@ -145,7 +156,7 @@ export default function MyFileUpload({
145
156
  ext: file_ext,
146
157
  type_image: type_image
147
158
  };
148
- Resizer.imageFileResizer(file, 2600, 2600, "JPEG", 100, 0, uri => {
159
+ _reactImageFileResizer.default.imageFileResizer(file, 2600, 2600, "JPEG", 100, 0, uri => {
149
160
  fileReaderCalc++;
150
161
  let fileitem = {
151
162
  base64: uri,
@@ -170,7 +181,7 @@ export default function MyFileUpload({
170
181
 
171
182
  // responseData(response_files, _error);
172
183
  };
173
- useEffect(() => {
184
+ (0, _react.useEffect)(() => {
174
185
  if (!cameraopen) {
175
186
  setCameraopened(false);
176
187
  }
@@ -207,81 +218,100 @@ export default function MyFileUpload({
207
218
  const handleCameraStop = () => {
208
219
  // setCameraopened(false);
209
220
  };
210
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MyWaiting, {
211
- show: loading,
212
- message: ""
213
- }), /*#__PURE__*/React.createElement("div", {
214
- className: className
215
- }, /*#__PURE__*/React.createElement("div", {
216
- className: styles.myFileUploadContainer
217
- }, /*#__PURE__*/React.createElement("div", {
218
- className: styles.myFileUploadContainerItem
219
- }, /*#__PURE__*/React.createElement("div", {
220
- className: styles.myFileUploadContainerItemIcon
221
- }, /*#__PURE__*/React.createElement(PiFileArrowUpLight, {
222
- className: styles.Icon
223
- }), /*#__PURE__*/React.createElement("h2", {
224
- className: styles.myFileUploadContainerItemIconText
225
- }, acceptlabel, /*#__PURE__*/React.createElement("br", null), " ", maxSizeMB, " MB")), /*#__PURE__*/React.createElement("div", {
226
- className: styles.myFileUploadContainerItemFile
227
- }, /*#__PURE__*/React.createElement("input", {
228
- type: "file",
229
- hidden: true,
230
- ref: fileInputRef,
231
- onChange: handleFileInputChange,
232
- multiple: multiple,
233
- accept: accepttypes
234
- }), /*#__PURE__*/React.createElement("div", {
235
- className: styles.myFileUploadButton,
236
- onClick: () => fileInputRef.current.click()
237
- }, /*#__PURE__*/React.createElement(MdOutlineAttachFile, null)))), camera && /*#__PURE__*/React.createElement("div", {
238
- className: styles.myFileUploadContainerItem
239
- }, /*#__PURE__*/React.createElement("div", {
240
- className: styles.myFileUploadContainerItemIcon
241
- }, /*#__PURE__*/React.createElement(PiCamera, {
242
- className: styles.Icon
243
- }), /*#__PURE__*/React.createElement("div", {
244
- className: styles.myFileUploadContainerItemIconText
245
- }, /*#__PURE__*/React.createElement("span", null, "You can take a photo from the camera."))), /*#__PURE__*/React.createElement("div", {
246
- className: styles.myFileUploadContainerItemFile
247
- }, /*#__PURE__*/React.createElement("button", {
248
- type: "button",
249
- className: styles.myFileUploadButton,
250
- onClick: () => setCameraopen(true)
251
- }, /*#__PURE__*/React.createElement(PiCamera, null)))))), /*#__PURE__*/React.createElement(MyModal, {
252
- show: cameraopen,
253
- onClose: () => setCameraopen(false),
254
- title: t("Fotoğraf Çek"),
255
- closeOnEsc: false,
256
- closeOnBackdropClick: false
257
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Camera, {
258
- videoConstraints: {
259
- deviceId: selectedDeviceId ? {
260
- exact: selectedDeviceId
261
- } : undefined
262
- },
263
- onTakePhoto: dataUri => {
264
- console.log(dataUri);
265
- handleTakePhoto(dataUri);
266
- },
267
- onCameraError: handleCameraError,
268
- onCameraStart: stream => {
269
- handleCameraStart(stream);
270
- },
271
- onCameraStop: () => {
272
- handleCameraStop();
273
- },
274
- idealFacingMode: FACING_MODES.ENVIRONMENT,
275
- idealResolution: {
276
- width: 1024,
277
- height: 1024
278
- },
279
- imageType: IMAGE_TYPES.JPG,
280
- isMaxResolution: true,
281
- isImageMirror: false,
282
- isSilentMode: false,
283
- isDisplayStartCameraError: true,
284
- isFullscreen: false,
285
- sizeFactor: 1
286
- }))));
221
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
222
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_MyWaiting.default, {
223
+ show: loading,
224
+ message: ""
225
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
226
+ className: className,
227
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
228
+ className: _MyFileUploadModule.default.myFileUploadContainer,
229
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
230
+ className: _MyFileUploadModule.default.myFileUploadContainerItem,
231
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
232
+ className: _MyFileUploadModule.default.myFileUploadContainerItemIcon,
233
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_pi.PiFileArrowUpLight, {
234
+ className: _MyFileUploadModule.default.Icon
235
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("h2", {
236
+ className: _MyFileUploadModule.default.myFileUploadContainerItemIconText,
237
+ children: [acceptlabel, /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), " ", maxSizeMB, " MB"]
238
+ })]
239
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
240
+ className: _MyFileUploadModule.default.myFileUploadContainerItemFile,
241
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
242
+ type: "file",
243
+ hidden: true,
244
+ ref: fileInputRef,
245
+ onChange: handleFileInputChange,
246
+ multiple: multiple,
247
+ accept: accepttypes
248
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
249
+ className: _MyFileUploadModule.default.myFileUploadButton,
250
+ onClick: () => fileInputRef.current.click(),
251
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_md.MdOutlineAttachFile, {})
252
+ })]
253
+ })]
254
+ }), camera && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
255
+ className: _MyFileUploadModule.default.myFileUploadContainerItem,
256
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
257
+ className: _MyFileUploadModule.default.myFileUploadContainerItemIcon,
258
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_pi.PiCamera, {
259
+ className: _MyFileUploadModule.default.Icon
260
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
261
+ className: _MyFileUploadModule.default.myFileUploadContainerItemIconText,
262
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
263
+ children: "You can take a photo from the camera."
264
+ })
265
+ })]
266
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
267
+ className: _MyFileUploadModule.default.myFileUploadContainerItemFile,
268
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
269
+ type: "button",
270
+ className: _MyFileUploadModule.default.myFileUploadButton,
271
+ onClick: () => setCameraopen(true),
272
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_pi.PiCamera, {})
273
+ })
274
+ })]
275
+ })]
276
+ })
277
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_MyModal.default, {
278
+ show: cameraopen,
279
+ onClose: () => setCameraopen(false),
280
+ title: t("Fotoğraf Çek"),
281
+ closeOnEsc: false,
282
+ closeOnBackdropClick: false,
283
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
284
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHtml5CameraPhoto.default, {
285
+ videoConstraints: {
286
+ deviceId: selectedDeviceId ? {
287
+ exact: selectedDeviceId
288
+ } : undefined
289
+ },
290
+ onTakePhoto: dataUri => {
291
+ console.log(dataUri);
292
+ handleTakePhoto(dataUri);
293
+ },
294
+ onCameraError: handleCameraError,
295
+ onCameraStart: stream => {
296
+ handleCameraStart(stream);
297
+ },
298
+ onCameraStop: () => {
299
+ handleCameraStop();
300
+ },
301
+ idealFacingMode: _reactHtml5CameraPhoto.FACING_MODES.ENVIRONMENT,
302
+ idealResolution: {
303
+ width: 1024,
304
+ height: 1024
305
+ },
306
+ imageType: _reactHtml5CameraPhoto.IMAGE_TYPES.JPG,
307
+ isMaxResolution: true,
308
+ isImageMirror: false,
309
+ isSilentMode: false,
310
+ isDisplayStartCameraError: true,
311
+ isFullscreen: false,
312
+ sizeFactor: 1
313
+ })
314
+ })
315
+ })]
316
+ });
287
317
  }
@@ -1,13 +1,23 @@
1
- import React, { useState } from "react";
2
- import ReactCrop from "react-image-crop";
3
- import "react-image-crop/dist/ReactCrop.css";
4
- import MyImageZoom from "../MyZoomImage/MyZoomImage";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactImageCrop = _interopRequireDefault(require("react-image-crop"));
9
+ require("react-image-crop/dist/ReactCrop.css");
10
+ var _MyZoomImage = _interopRequireDefault(require("../MyZoomImage/MyZoomImage"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
5
15
  const MyImageCropper = ({
6
16
  image,
7
17
  style = null,
8
18
  onChange = null
9
19
  }) => {
10
- const [crop, setCrop] = useState({
20
+ const [crop, setCrop] = (0, _react.useState)({
11
21
  x: 0,
12
22
  y: 0,
13
23
  width: 0,
@@ -15,13 +25,13 @@ const MyImageCropper = ({
15
25
  aspect: 1
16
26
  });
17
27
  // const [croppedImageUrl, setCroppedImageUrl] = useState(null);
18
- const [imageRef, setImageRef] = useState(null);
19
- const [zoom, setZoom] = useState({
28
+ const [imageRef, setImageRef] = (0, _react.useState)(null);
29
+ const [zoom, setZoom] = (0, _react.useState)({
20
30
  scale: 1,
21
31
  positionX: 0,
22
32
  positionY: 0
23
33
  }); // Zoom seviyesini saklamak için state
24
- const [scaleFactor, setScaleFactor] = useState(1.5);
34
+ const [scaleFactor, setScaleFactor] = (0, _react.useState)(1.5);
25
35
 
26
36
  // Görüntü yüklendiğinde çağrılır
27
37
  const handleImageLoad = e => {
@@ -76,20 +86,23 @@ const MyImageCropper = ({
76
86
  });
77
87
  }
78
88
  };
79
- return /*#__PURE__*/React.createElement("div", {
80
- style: style
81
- }, image && /*#__PURE__*/React.createElement(ReactCrop, {
82
- crop: crop,
83
- onComplete: onCropComplete,
84
- onChange: newCrop => setCrop(newCrop),
85
- style: style
86
- }, /*#__PURE__*/React.createElement(MyImageZoom, {
87
- onZoomChange: handleZoomChange
88
- }, /*#__PURE__*/React.createElement("img", {
89
- src: image,
90
- alt: "Crop preview",
91
- onLoad: handleImageLoad,
92
- className: "rounded-e-md"
93
- }))));
89
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
90
+ style: style,
91
+ children: image && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactImageCrop.default, {
92
+ crop: crop,
93
+ onComplete: onCropComplete,
94
+ onChange: newCrop => setCrop(newCrop),
95
+ style: style,
96
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MyZoomImage.default, {
97
+ onZoomChange: handleZoomChange,
98
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
99
+ src: image,
100
+ alt: "Crop preview",
101
+ onLoad: handleImageLoad,
102
+ className: "rounded-e-md"
103
+ })
104
+ })
105
+ })
106
+ });
94
107
  };
95
- export default MyImageCropper;
108
+ var _default = exports.default = MyImageCropper;