infinity-forge 11.4.4 → 11.4.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.
- package/dist/test/index.js +1 -94
- package/dist/test/index.js.map +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-actions/crop-actions.d.ts +9 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-actions/crop-actions.js +12 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-actions/crop-actions.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-actions/index.d.ts +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-actions/index.js +6 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-actions/index.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-canvas/crop-canvas.d.ts +12 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-canvas/crop-canvas.js +54 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-canvas/crop-canvas.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-canvas/index.d.ts +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-canvas/index.js +6 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-canvas/index.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/crop-interface.d.ts +9 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/crop-interface.js +56 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/crop-interface.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/index.d.ts +1 -9
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/index.js +3 -233
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/index.js.map +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/styles.js +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-interface/styles.js.map +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-styles/crop-styles.d.ts +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-styles/crop-styles.js +13 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-styles/crop-styles.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-styles/index.d.ts +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-styles/index.js +6 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/crop-styles/index.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/preview-panel/index.d.ts +3 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/preview-panel/index.js +13 -9
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/preview-panel/index.js.map +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/preview-panel/interfaces.d.ts +2 -2
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/preview-panel/styles.js +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/components/preview-panel/styles.js.map +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/index.d.ts +3 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/index.js +10 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/index.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-interactions.d.ts +13 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-interactions.js +190 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-interactions.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-operations.d.ts +14 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-operations.js +82 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-operations.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-state.d.ts +16 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-state.js +84 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-state.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/index.js +2 -11
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/index.js.map +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/shared/types.d.ts +15 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/shared/{interfaces.js → types.js} +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/shared/types.js.map +1 -0
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/utils/crop-utils.d.ts +3 -3
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/utils/crop-utils.js +2 -2
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/utils/crop-utils.js.map +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/index.js +8 -42
- package/dist/ui/components/form/input-file/input-crop-image/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/shared/interfaces.d.ts +0 -6
- package/dist/ui/components/form/input-file/input-crop-image/crop-image/shared/interfaces.js.map +0 -1
- package/dist/ui/components/form/input-file/input-crop-image/styles.d.ts +0 -1
- package/dist/ui/components/form/input-file/input-crop-image/styles.js +0 -14
- package/dist/ui/components/form/input-file/input-crop-image/styles.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-crop-operations.js","sourceRoot":"","sources":["../../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-operations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,8CA4BC;AAzCD,+BAA6C;AAE7C,kDAA+C;AAW/C,SAAgB,iBAAiB,CAAC,EAA0E;IAA5G,iBA4BC;QA5BmC,IAAI,UAAA,EAAE,QAAQ,cAAA,EAAE,WAAW,iBAAA,EAAE,QAAQ,cAAA,EAAE,OAAO,aAAA;IAC1E,IAAA,KAA4B,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAA;IAEjD,IAAM,eAAe,GAAG,IAAA,mBAAW,EAAC;;;;;oBAClC,IAAI,CAAC,IAAI;wBAAE,sBAAM;;;;oBAGf,YAAY,CAAC,IAAI,CAAC,CAAA;oBAEE,qBAAM,IAAA,sBAAS,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,GAAG,CAAC,EAAA;;oBAA9D,WAAW,GAAG,SAAgD;oBAEpE,IAAI,WAAW,EAAE,CAAC;wBAChB,WAAW,CAAC,WAAW,CAAC,CAAA;oBAC1B,CAAC;oBAED,QAAQ,EAAE,CAAA;;;;oBAEV,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,OAAK,CAAC,CAAA;oBAC5C,OAAO,CAAC,6CAA6C,CAAC,CAAA;;;oBAEtD,YAAY,CAAC,KAAK,CAAC,CAAA;;;;;SAEtB,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;IAEpD,OAAO;QACL,SAAS,WAAA;QACT,eAAe,iBAAA;KAChB,CAAA;AACH,CAAC"}
|
package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-state.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FileSystemType } from '../../../../../../../ui/index.js';
|
|
2
|
+
import { ImageDimensions, DisplayCropArea } from '../shared/types.js';
|
|
3
|
+
interface UseCropStateProps {
|
|
4
|
+
file: FileSystemType | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function useCropState({ file }: UseCropStateProps): {
|
|
7
|
+
imageDimensions: ImageDimensions;
|
|
8
|
+
cropArea: DisplayCropArea;
|
|
9
|
+
setCropArea: import("react").Dispatch<import("react").SetStateAction<DisplayCropArea>>;
|
|
10
|
+
aspectRatio: number;
|
|
11
|
+
setAspectRatio: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
12
|
+
restoreOriginal: () => void;
|
|
13
|
+
setAspectRatioPreset: (ratio: string) => void;
|
|
14
|
+
originalCropArea: DisplayCropArea;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-state.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.useCropState = useCropState;
|
|
15
|
+
var react_1 = require("react");
|
|
16
|
+
function useCropState(_a) {
|
|
17
|
+
var file = _a.file;
|
|
18
|
+
var _b = (0, react_1.useState)({ width: 0, height: 0 }), imageDimensions = _b[0], setImageDimensions = _b[1];
|
|
19
|
+
var _c = (0, react_1.useState)({
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0,
|
|
22
|
+
width: 0,
|
|
23
|
+
height: 0,
|
|
24
|
+
}), cropArea = _c[0], setCropArea = _c[1];
|
|
25
|
+
var _d = (0, react_1.useState)(null), aspectRatio = _d[0], setAspectRatio = _d[1];
|
|
26
|
+
var _e = (0, react_1.useState)(null), originalCropArea = _e[0], setOriginalCropArea = _e[1];
|
|
27
|
+
var imageDimensionsRef = (0, react_1.useRef)(imageDimensions);
|
|
28
|
+
var originalCropAreaRef = (0, react_1.useRef)(originalCropArea);
|
|
29
|
+
imageDimensionsRef.current = imageDimensions;
|
|
30
|
+
originalCropAreaRef.current = originalCropArea;
|
|
31
|
+
(0, react_1.useEffect)(function () {
|
|
32
|
+
if (file === null || file === void 0 ? void 0 : file.url) {
|
|
33
|
+
var img_1 = new Image();
|
|
34
|
+
img_1.onload = function () {
|
|
35
|
+
var dimensions = { width: img_1.naturalWidth, height: img_1.naturalHeight };
|
|
36
|
+
setImageDimensions(dimensions);
|
|
37
|
+
var initialCropArea = {
|
|
38
|
+
x: dimensions.width * 0.15,
|
|
39
|
+
y: dimensions.height * 0.15,
|
|
40
|
+
width: dimensions.width * 0.7,
|
|
41
|
+
height: dimensions.height * 0.6,
|
|
42
|
+
};
|
|
43
|
+
setCropArea(initialCropArea);
|
|
44
|
+
setOriginalCropArea(initialCropArea);
|
|
45
|
+
};
|
|
46
|
+
img_1.src = file.url;
|
|
47
|
+
}
|
|
48
|
+
}, [file]);
|
|
49
|
+
var restoreOriginal = (0, react_1.useCallback)(function () {
|
|
50
|
+
if (originalCropAreaRef.current) {
|
|
51
|
+
setCropArea(originalCropAreaRef.current);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setCropArea({
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0,
|
|
57
|
+
width: imageDimensionsRef.current.width,
|
|
58
|
+
height: imageDimensionsRef.current.height,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
setAspectRatio(null);
|
|
62
|
+
}, []);
|
|
63
|
+
var setAspectRatioPreset = (0, react_1.useCallback)(function (ratio) {
|
|
64
|
+
if (ratio === 'free') {
|
|
65
|
+
setAspectRatio(null);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
var _a = ratio.split(':').map(Number), w = _a[0], h = _a[1];
|
|
69
|
+
var newAspectRatio = w / h;
|
|
70
|
+
setAspectRatio(newAspectRatio);
|
|
71
|
+
setCropArea(function (prev) { return (__assign(__assign({}, prev), { height: prev.width / newAspectRatio })); });
|
|
72
|
+
}, []);
|
|
73
|
+
return {
|
|
74
|
+
imageDimensions: imageDimensions,
|
|
75
|
+
cropArea: cropArea,
|
|
76
|
+
setCropArea: setCropArea,
|
|
77
|
+
aspectRatio: aspectRatio,
|
|
78
|
+
setAspectRatio: setAspectRatio,
|
|
79
|
+
restoreOriginal: restoreOriginal,
|
|
80
|
+
setAspectRatioPreset: setAspectRatioPreset,
|
|
81
|
+
originalCropArea: originalCropArea,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=use-crop-state.js.map
|
package/dist/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-state.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-crop-state.js","sourceRoot":"","sources":["../../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/hooks/use-crop-state.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAQA,oCA+EC;AAvFD,+BAAgE;AAQhE,SAAgB,YAAY,CAAC,EAA2B;QAAzB,IAAI,UAAA;IAC3B,IAAA,KAAwC,IAAA,gBAAQ,EAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAzF,eAAe,QAAA,EAAE,kBAAkB,QAAsD,CAAA;IAC1F,IAAA,KAA0B,IAAA,gBAAQ,EAAkB;QACxD,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;QACJ,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV,CAAC,EALK,QAAQ,QAAA,EAAE,WAAW,QAK1B,CAAA;IACI,IAAA,KAAgC,IAAA,gBAAQ,EAAgB,IAAI,CAAC,EAA5D,WAAW,QAAA,EAAE,cAAc,QAAiC,CAAA;IAC7D,IAA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C;aAAM,CAAC;YACN,WAAW,CAAC;gBACV,CAAC,EAAE,CAAC;gBACJ,CAAC,EAAE,CAAC;gBACJ,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK;gBACvC,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,MAAM;aAC1C,CAAC,CAAA;QACJ,CAAC;QACD,cAAc,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,IAAM,oBAAoB,GAAG,IAAA,mBAAW,EAAC,UAAC,KAAa;QACrD,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,cAAc,CAAC,IAAI,CAAC,CAAA;YACpB,OAAM;QACR,CAAC;QAEK,IAAA,KAAS,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAApC,CAAC,QAAA,EAAE,CAAC,QAAgC,CAAA;QAC3C,IAAM,cAAc,GAAG,CAAC,GAAG,CAAC,CAAA;QAC5B,cAAc,CAAC,cAAc,CAAC,CAAA;QAE9B,WAAW,CAAC,UAAC,IAAI,IAAK,OAAA,uBACjB,IAAI,KACP,MAAM,EAAE,IAAI,CAAC,KAAK,GAAG,cAAc,IACnC,EAHoB,CAGpB,CAAC,CAAA;IACL,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACL,eAAe,iBAAA;QACf,QAAQ,UAAA;QACR,WAAW,aAAA;QACX,WAAW,aAAA;QACX,cAAc,gBAAA;QACd,eAAe,iBAAA;QACf,oBAAoB,sBAAA;QACpB,gBAAgB,kBAAA;KACjB,CAAA;AACH,CAAC"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.CropImage = CropImage;
|
|
8
4
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
5
|
var ui_1 = require("../../../../../../ui/index.js");
|
|
10
|
-
var styled_components_1 = require("styled-components");
|
|
11
6
|
var styles_1 = require("./styles.js");
|
|
12
7
|
var crop_interface_1 = require("./components/crop-interface/index.js");
|
|
13
|
-
var
|
|
14
|
-
var styles_3 = require("./components/preview-panel/styles.js");
|
|
15
|
-
//TODO Remover e adicionar apenas uma prop de passar um custom styled pra dentro do modal
|
|
16
|
-
var GlobalStyles = (0, styled_components_1.createGlobalStyle)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n \n @media (max-width: 1024px) {\n .ReactModal__Content {\n max-width: 95vw !important;\n max-height: 95vh !important;\n border-radius: 1rem !important;\n }\n \n .ReactModal__Overlay {\n border-radius: 1rem !important;\n }\n }\n \n @media (max-width: 768px) {\n .ReactModal__Content {\n max-width: 100vw !important;\n max-height: 100vh !important;\n border-radius: 0 !important;\n margin: 0 !important;\n }\n \n .ReactModal__Overlay {\n border-radius: 0 !important;\n }\n }\n"], ["\n ", "\n ", "\n \n @media (max-width: 1024px) {\n .ReactModal__Content {\n max-width: 95vw !important;\n max-height: 95vh !important;\n border-radius: 1rem !important;\n }\n \n .ReactModal__Overlay {\n border-radius: 1rem !important;\n }\n }\n \n @media (max-width: 768px) {\n .ReactModal__Content {\n max-width: 100vw !important;\n max-height: 100vh !important;\n border-radius: 0 !important;\n margin: 0 !important;\n }\n \n .ReactModal__Overlay {\n border-radius: 0 !important;\n }\n }\n"])), styles_2.cropInterfaceStyles, styles_3.previewPanelStyles);
|
|
8
|
+
var crop_styles_1 = require("./components/crop-styles/index.js");
|
|
17
9
|
function CropImage(_a) {
|
|
18
10
|
var file = _a.file, setFile = _a.setFile, onApplyCrop = _a.onApplyCrop;
|
|
19
11
|
var handleCancel = function () {
|
|
@@ -25,7 +17,6 @@ function CropImage(_a) {
|
|
|
25
17
|
}
|
|
26
18
|
setFile(null);
|
|
27
19
|
};
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(ui_1.Modal, { hideCloseButton: true, stylesContent: styles_1.modalStyles.content, styles: styles_1.modalStyles.modal, open: !!file, onClose: handleCancel, children: [(0, jsx_runtime_1.jsx)(
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(ui_1.Modal, { hideCloseButton: true, stylesContent: styles_1.modalStyles.content, styles: styles_1.modalStyles.modal, open: !!file, onClose: handleCancel, children: [(0, jsx_runtime_1.jsx)(crop_styles_1.CropGlobalStyles, {}), (0, jsx_runtime_1.jsx)(crop_interface_1.CropInterface, { file: file, onCancel: handleCancel, onError: function () { }, onApplyCrop: handleApplyCrop })] }));
|
|
29
21
|
}
|
|
30
|
-
var templateObject_1;
|
|
31
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/index.tsx"],"names":[],"mappings":";;AAYA,8BAwBC;;AApCD,2BAA4C;AAE5C,mCAAsC;AACtC,8DAA2D;AAC3D,wDAA2D;AAQ3D,SAAgB,SAAS,CAAC,EAA8C;QAA5C,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,WAAW,iBAAA;IACpD,IAAM,YAAY,GAAG;QACnB,OAAO,CAAC,IAAI,CAAC,CAAA;IACf,CAAC,CAAA;IAED,IAAM,eAAe,GAAG,UAAC,WAA2B;QAClD,IAAI,WAAW,EAAE,CAAC;YAChB,WAAW,CAAC,WAAW,CAAC,CAAA;QAC1B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAA;IACf,CAAC,CAAA;IAED,OAAO,CACL,wBAAC,UAAK,IACJ,eAAe,QACf,aAAa,EAAE,oBAAW,CAAC,OAAO,EAClC,MAAM,EAAE,oBAAW,CAAC,KAAK,EACzB,IAAI,EAAE,CAAC,CAAC,IAAI,EACZ,OAAO,EAAE,YAAY,aAErB,uBAAC,8BAAgB,KAAG,EACpB,uBAAC,8BAAa,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,cAAO,CAAC,EAAE,WAAW,EAAE,eAAe,GAAI,IAChG,CACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ImageDimensions {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export interface DisplayCropArea {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface DragStart {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}
|
|
15
|
+
export type ResizeDirection = 'n' | 's' | 'e' | 'w' | 'nw' | 'ne' | 'sw' | 'se';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/shared/types.ts"],"names":[],"mappings":""}
|
package/dist/ui/components/form/input-file/input-crop-image/crop-image/utils/crop-utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CropArea } from '../shared/interfaces.js';
|
|
2
1
|
import { FileSystemType } from '../../../../../../../ui/index.js';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
2
|
+
import { DisplayCropArea } from '../shared/types.js';
|
|
3
|
+
export declare function getCropPreview(file: FileSystemType, cropArea: DisplayCropArea, maxSize?: number): Promise<string>;
|
|
4
|
+
export declare function applyCrop(file: FileSystemType, cropArea: DisplayCropArea, format?: 'png' | 'jpg' | 'webp', quality?: number): Promise<FileSystemType>;
|
|
@@ -27,7 +27,7 @@ function getCropPreview(file, cropArea, maxSize) {
|
|
|
27
27
|
ctx.drawImage(img, cropArea.x, cropArea.y, cropArea.width, cropArea.height, 0, 0, previewWidth, previewHeight);
|
|
28
28
|
resolve(canvas.toDataURL('image/png'));
|
|
29
29
|
};
|
|
30
|
-
img.src = (
|
|
30
|
+
img.src = (file === null || file === void 0 ? void 0 : file.url) || '';
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function applyCrop(file, cropArea, format, quality) {
|
|
@@ -59,7 +59,7 @@ function applyCrop(file, cropArea, format, quality) {
|
|
|
59
59
|
resolve(croppedFileSystem);
|
|
60
60
|
}, "image/".concat(format), quality);
|
|
61
61
|
};
|
|
62
|
-
img.src = (
|
|
62
|
+
img.src = (file === null || file === void 0 ? void 0 : file.url) || '';
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
//# sourceMappingURL=crop-utils.js.map
|
package/dist/ui/components/form/input-file/input-crop-image/crop-image/utils/crop-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crop-utils.js","sourceRoot":"","sources":["../../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/utils/crop-utils.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"crop-utils.js","sourceRoot":"","sources":["../../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/utils/crop-utils.ts"],"names":[],"mappings":";;AAGA,wCAqCC;AAED,8BAgDC;AA1FD,2BAA8D;AAG9D,SAAgB,cAAc,CAC5B,IAAoB,EACpB,QAAyB,EACzB,OAAqB;IAArB,wBAAA,EAAA,aAAqB;IAErB,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,IAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;QACvB,GAAG,CAAC,WAAW,GAAG,WAAW,CAAA;QAE7B,GAAG,CAAC,MAAM,GAAG;YACX,IAAM,MAAM,GAAG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AAE,IAAI,EAAE,gBAAS,MAAM,CAAE,EAAE,CAAC,CAAA;gBAElF,IAAM,iBAAiB,GAAmB,IAAA,4BAAuB,EAAC,WAAW,CAAC,CAAA;gBAE9E,OAAO,CAAC,iBAAiB,CAAC,CAAA;YAC5B,CAAC,EACD,gBAAS,MAAM,CAAE,EACjB,OAAO,CACR,CAAA;QACH,CAAC,CAAA;QAED,GAAG,CAAC,GAAG,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,KAAI,EAAE,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -10,39 +10,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
-
var ownKeys = function(o) {
|
|
31
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
-
var ar = [];
|
|
33
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
-
return ar;
|
|
35
|
-
};
|
|
36
|
-
return ownKeys(o);
|
|
37
|
-
};
|
|
38
|
-
return function (mod) {
|
|
39
|
-
if (mod && mod.__esModule) return mod;
|
|
40
|
-
var result = {};
|
|
41
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
-
__setModuleDefault(result, mod);
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
})();
|
|
46
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
14
|
exports.useCropImage = useCropImage;
|
|
48
15
|
exports.InputCropImage = InputCropImage;
|
|
@@ -50,7 +17,6 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
50
17
|
var react_1 = require("react");
|
|
51
18
|
var ui_1 = require("../../../../../ui/index.js");
|
|
52
19
|
var crop_image_1 = require("./crop-image/index.js");
|
|
53
|
-
var S = __importStar(require("./styles.js"));
|
|
54
20
|
function useCropImage(props) {
|
|
55
21
|
var propsFile = __assign(__assign({}, props), { multiple: false, isAccumalativeFile: false, accept: '.png, .jpg, .jpeg, .pdf' });
|
|
56
22
|
return (0, ui_1.useFile)(propsFile);
|
|
@@ -58,14 +24,14 @@ function useCropImage(props) {
|
|
|
58
24
|
function InputCropImage(props) {
|
|
59
25
|
var _a = (0, react_1.useState)(null), file = _a[0], setFile = _a[1];
|
|
60
26
|
if (!props.cropControl) {
|
|
61
|
-
throw new Error(
|
|
27
|
+
throw new Error('Set cropControl https://infinity-forge.com.br/errors/input-file/input-crop-image/crop-control');
|
|
62
28
|
}
|
|
63
|
-
return ((0, jsx_runtime_1.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(props.cropControl.InputFile, { visible: false, onChangeInputFile: function (fileSystemType) {
|
|
30
|
+
setFile(fileSystemType);
|
|
31
|
+
} }), (0, jsx_runtime_1.jsx)(crop_image_1.CropImage, { file: file, setFile: setFile, onApplyCrop: function (croppedFile) {
|
|
32
|
+
var dataTransfer = new DataTransfer();
|
|
33
|
+
dataTransfer.items.add(croppedFile.file);
|
|
34
|
+
props.cropControl.onChangeInputFile({ currentTarget: { files: dataTransfer.files } });
|
|
35
|
+
} }), (0, jsx_runtime_1.jsx)(props.cropControl.LabelFileArea, { children: props === null || props === void 0 ? void 0 : props.children })] }));
|
|
70
36
|
}
|
|
71
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/ui/components/form/input-file/input-crop-image/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/ui/components/form/input-file/input-crop-image/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAMA,oCASC;AAED,wCA+BC;;AAhDD,+BAAgC;AAEhC,2BAAsF;AAEtF,2CAAwC;AAExC,SAAgB,YAAY,CAAC,KAAiB;IAC5C,IAAM,SAAS,GAAG,sBACb,KAAK,KACR,QAAQ,EAAE,KAAK,EACf,kBAAkB,EAAE,KAAK,EACzB,MAAM,EAAE,yBAAyB,GACpB,CAAA;IAEf,OAAO,IAAA,YAAO,EAAC,SAAS,CAAC,CAAA;AAC3B,CAAC;AAED,SAAgB,cAAc,CAC5B,KAA0F;IAEpF,IAAA,KAAkB,IAAA,gBAAQ,EAAwB,IAAI,CAAC,EAAtD,IAAI,QAAA,EAAE,OAAO,QAAyC,CAAA;IAE7D,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAA;IAClH,CAAC;IAED,OAAO,CACL,6DACE,uBAAC,KAAK,CAAC,WAAW,CAAC,SAAS,IAC1B,OAAO,EAAE,KAAK,EACd,iBAAiB,EAAE,UAAC,cAAc;oBAChC,OAAO,CAAC,cAAc,CAAC,CAAA;gBACzB,CAAC,GACD,EAEF,uBAAC,sBAAS,IACR,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,UAAC,WAAW;oBACvB,IAAI,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;oBACrC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;oBACxC,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;gBACvF,CAAC,GACD,EAEF,uBAAC,KAAK,CAAC,WAAW,CAAC,aAAa,cAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,GAAmC,IACnF,CACJ,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
package/dist/ui/components/form/input-file/input-crop-image/crop-image/shared/interfaces.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../../../../src/ui/components/form/input-file/input-crop-image/crop-image/shared/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const UploadCertificatesStyles: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, never>> & string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.UploadCertificatesStyles = void 0;
|
|
11
|
-
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
-
exports.UploadCertificatesStyles = (0, styled_components_1.default)('div')(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n label {\n display: flex;\n height: 96px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n text-align: center;\n gap: 10px;\n align-self: stretch;\n border-radius: 10px;\n color: #50c0bb;\n border: 2px dashed #50c0bb;\n min-height: 96px;\n }\n\n p {\n color: #999;\n margin-top: 1rem;\n }\n\n .list {\n display: flex;\n flex-direction: column;\n gap: clamp(1rem, 1.24vw, 2.4rem);\n }\n"], ["\n label {\n display: flex;\n height: 96px;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n text-align: center;\n gap: 10px;\n align-self: stretch;\n border-radius: 10px;\n color: #50c0bb;\n border: 2px dashed #50c0bb;\n min-height: 96px;\n }\n\n p {\n color: #999;\n margin-top: 1rem;\n }\n\n .list {\n display: flex;\n flex-direction: column;\n gap: clamp(1rem, 1.24vw, 2.4rem);\n }\n"])));
|
|
13
|
-
var templateObject_1;
|
|
14
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../../src/ui/components/form/input-file/input-crop-image/styles.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wEAAsC;AAEzB,QAAA,wBAAwB,GAAG,IAAA,2BAAM,EAAC,KAAK,CAAC,8hBAAA,2dA0BpD,KAAA"}
|