datasync-blob 1.1.4 → 1.1.6

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.
File without changes
package/dist/DsBlob.js CHANGED
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { Component } from "react";
12
+ import "./DsBlob.css";
12
13
  export class DsBlob extends Component {
13
14
  constructor(props) {
14
15
  super(props);
@@ -131,39 +132,12 @@ export class DsBlob extends Component {
131
132
  this.debugging = false;
132
133
  }
133
134
  render() {
134
- const upload_picture_label = {
135
- cursor: "pointer"
136
- };
137
- const upload_picture_label_input = {
138
- opacity: "0",
139
- width: "0px",
140
- height: "0px"
141
- };
142
- const div_show_image_hover = {
143
- position: "relative",
144
- margin: "0px",
145
- opacity: "0.5"
146
- };
147
- const div_show_image = {
148
- position: "relative",
149
- margin: "0px"
150
- };
151
- const div_show_image_hover_input = {
152
- display: "block",
153
- top: "0px",
154
- left: "0px",
155
- position: "absolute"
156
- };
157
- const div_show_image_input = {
158
- position: "absolute",
159
- display: "none",
160
- cursor: "pointer"
161
- };
135
+ // Styles moved to external CSS file: DsBlob.css
162
136
  return (_jsxs("div", { children: [(!this.props.data) &&
163
- _jsxs("label", { id: "upload-picture-label", className: this.props.buttonStyle, style: upload_picture_label, children: [this.props.Caption, _jsx("input", { style: upload_picture_label_input, id: "nested-input", type: "file", accept: "image/*", onChange: this.onInputChange, multiple: true })] }), (this.props.data && this.props.data.length > 0) &&
164
- _jsxs("div", { className: "show-image", style: div_show_image, onMouseOver: () => { this.setState({ hover_input: true, hover_image: true }, () => { if (this.debugging)
137
+ _jsxs("label", { id: "upload-picture-label", className: `upload-picture-label ${this.props.buttonStyle}`, children: [this.props.Caption, _jsx("input", { className: "upload-picture-label-input", id: "nested-input", type: "file", accept: "image/*", onChange: this.onInputChange, multiple: true })] }), (this.props.data && this.props.data.length > 0) &&
138
+ _jsxs("div", { className: "show-image", onMouseOver: () => { this.setState({ hover_input: true, hover_image: true }, () => { if (this.debugging)
165
139
  console.log("onMouseOver"); }); }, onMouseLeave: () => { this.setState({ hover_input: false, hover_image: false }, () => { if (this.debugging)
166
- console.log("onMouseLeave"); }); }, children: [_jsx("img", { style: this.state.hover_image ? div_show_image_hover : div_show_image, src: (this.props.removebase64) ? "data:image/png;base64" : "" + this.props.data, className: this.props.pictureStyle }), !this.props.readOnly &&
167
- _jsx("input", { style: this.state.hover_input ? div_show_image_hover_input : div_show_image_input, className: "btn btn-primary delete", type: "button", value: "Effacer", onClick: this.resetUpload })] })] }));
140
+ console.log("onMouseLeave"); }); }, children: [_jsx("img", { className: `${this.state.hover_image ? "div-show-image-hover" : "div-show-image"} ${this.props.pictureStyle}`, src: (this.props.removebase64) ? "data:image/png;base64" : "" + this.props.data, alt: this.props.Caption || "uploaded image" }), !this.props.readOnly &&
141
+ _jsx("input", { className: `btn btn-primary delete ${this.state.hover_input ? "div-show-image-hover-input" : "div-show-image-input"}`, type: "button", value: "Effacer", onClick: this.resetUpload })] })] }));
168
142
  }
169
143
  }
@@ -1,4 +1,5 @@
1
1
  import { Component, ChangeEvent } from "react";
2
+ import "./DsBlob.css";
2
3
  interface DsBlobProps {
3
4
  width?: number;
4
5
  height?: number;
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "datasync-blob",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Datasync Blob component",
5
- "main": "./dist/DsBlob.js",
6
- "module": "./dist/DsBlob.js",
7
- "types": "./types/DsBlob.d.ts",
8
- "files": ["./dist"],
5
+ "main": "dist/DsBlob.js",
6
+ "module": "dist/DsBlob.js",
7
+ "types": "dist/types/DsBlob.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "https://github.com/pmabiala/datasync-blob.git"
@@ -27,6 +29,7 @@
27
29
  "react": "^18.2.0",
28
30
  "react-pdf": "^10.0.1",
29
31
  "tsup": "^8.5.0",
32
+ "typescript": "^5.9.2",
30
33
  "webpack": "^5.99.9",
31
34
  "webpack-cli": "^6.0.1",
32
35
  "webpack-node-externals": "^3.0.0",
@@ -36,9 +39,7 @@
36
39
  "react": "^ 18.2.0"
37
40
  },
38
41
  "scripts": {
39
- "hybrid":"tsc",
40
- "tsup": "tsup",
41
- "build_old": "rm -r dist && babel src -d dist --ignore src/**/*.test.jsx && npm run copy-files",
42
+ "hybrid": "tsc",
42
43
  "build": "rm -r dist && babel src -d dist --ignore src/**/*.test.jsx && npm run copy-files && webpack --config webpack.config.js",
43
44
  "copy-files": "cp ./src/*.css dist/",
44
45
  "test": "jest --config jest.config.json"
@@ -1,169 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { Component } from "react";
12
- export class DsBlob extends Component {
13
- constructor(props) {
14
- super(props);
15
- //-----------------------------------------------------------------------------------------------------------------------------------------
16
- this.reduceImage = (e) => {
17
- let imageSource = (e.path && e.path[0]) || e.srcElement; //Safari compliancy
18
- if (this.debugging)
19
- console.log("imageSource = ", imageSource);
20
- var canvas = document.createElement('canvas'), context, width = imageSource.width, height = imageSource.height;
21
- //Exact size props are set
22
- if (this.props.width && this.props.height) {
23
- //Check image size
24
- if (width > this.props.width || height > this.props.height) {
25
- alert("L'image est trop grande, le format requis est " + this.props.width + "x" + this.props.height);
26
- return;
27
- }
28
- //Check image size
29
- if (width < this.props.width || height < this.props.height) {
30
- alert("L'image est trop petite, le format requis est " + this.props.width + "x" + this.props.height);
31
- return;
32
- }
33
- }
34
- //Max size props are set
35
- if (this.props.maxWidth && this.props.maxHeight) {
36
- if (width > height) {
37
- //Check resize is enabled
38
- if (!this.props.reduceImage) {
39
- alert("L'image est trop large ! la largeur maximale est de " + this.props.maxWidth);
40
- return;
41
- }
42
- if (width > this.props.maxWidth) {
43
- height *= this.props.maxWidth / width;
44
- width = this.props.maxWidth;
45
- }
46
- }
47
- else {
48
- if (height > this.props.maxHeight) {
49
- //Check resize is enabled
50
- if (!this.props.reduceImage) {
51
- alert("L'image est trop haute, la hauteur maximale est de " + this.props.maxHeight);
52
- return;
53
- }
54
- width *= this.props.maxHeight / height;
55
- height = this.props.maxHeight;
56
- }
57
- }
58
- }
59
- //Build 2d picture
60
- canvas.width = width;
61
- canvas.height = height;
62
- context = canvas.getContext('2d');
63
- context.drawImage(imageSource, 0, 0, width, height);
64
- //Jpeg conversion
65
- let jpegCompressionRatio = (this.props.jpegQuality && this.props.jpegQuality > 0 && this.props.jpegQuality < 1) ? this.props.jpegQuality : 1;
66
- let canvasData = canvas.toDataURL('image/jpg', jpegCompressionRatio); //Jpeg conversion
67
- if (this.debugging)
68
- console.log("jpegCompressionRatio->", jpegCompressionRatio, " canvasData.length = ", canvasData.length);
69
- if (this.props.removebase64) {
70
- //remove base64 prefix if property is set
71
- this.props.uploadPicture({ data: canvasData ? canvasData.substring("data:image/png;base64".length) : "", item_id: this.props.item_id });
72
- }
73
- else {
74
- //Keep base 64 prefix as it is
75
- this.props.uploadPicture({ data: canvasData ? canvasData : "", item_id: this.props.item_id });
76
- }
77
- };
78
- //-----------------------------------------------------------------------------------------------------------------------------------------
79
- this.storeImageToImg = (e) => {
80
- var image = document.createElement('img');
81
- image.onload = this.reduceImage;
82
- image.src = e.currentTarget.result;
83
- };
84
- //-----------------------------------------------------------------------------------------------------------------------------------------
85
- this.readImage = (aPictureFile) => __awaiter(this, void 0, void 0, function* () {
86
- let _reader = new FileReader();
87
- _reader.onload = this.storeImageToImg;
88
- _reader.readAsDataURL(aPictureFile);
89
- });
90
- //-----------------------------------------------------------------------------------------------------------------------------------------
91
- this.resetUpload = () => {
92
- this.props.uploadPicture({ data: "", item_id: this.props.item_id });
93
- };
94
- //-----------------------------------------------------------------------------------------------------------------------------------------
95
- this.onInputChange = (e) => {
96
- const errs = [];
97
- const files = Array.from(e.target.files || []);
98
- const types = ['image/png', 'image/jpeg', 'image/gif'];
99
- const _1Mo = 1024 * 1024;
100
- const SizeLimit = 9;
101
- //Reset input cache value - to assure trigger if user select the same file again
102
- e.target.value = "";
103
- if (this.debugging)
104
- console.log("onInputChange");
105
- if (files.length > 1) {
106
- const msg = 'Pas plus d\'une image à la fois';
107
- alert(msg);
108
- return;
109
- }
110
- files.forEach((file, i) => {
111
- let errCount = errs.length;
112
- if (types.every(type => file.type !== type)) {
113
- errs.push(`'${file.type}' : format non supporté`);
114
- }
115
- if (file.size > (SizeLimit * _1Mo)) {
116
- errs.push(`'${file.name}' image trop volumineuse (max:${SizeLimit}Méga-octets)`);
117
- }
118
- if (this.debugging)
119
- console.log(`errCount = ${errCount} vs errs.length = ${errs.length}`);
120
- if (errCount == errs.length) { //None new error occurs
121
- if (this.debugging)
122
- console.log("readImage::", file.name);
123
- this.readImage(file);
124
- }
125
- });
126
- if (errs.length) {
127
- return errs.forEach(err => alert(err));
128
- }
129
- };
130
- this.state = { hover_input: false, hover_image: false };
131
- this.debugging = false;
132
- }
133
- render() {
134
- const upload_picture_label = {
135
- cursor: "pointer"
136
- };
137
- const upload_picture_label_input = {
138
- opacity: "0",
139
- width: "0px",
140
- height: "0px"
141
- };
142
- const div_show_image_hover = {
143
- position: "relative",
144
- margin: "0px",
145
- opacity: "0.5"
146
- };
147
- const div_show_image = {
148
- position: "relative",
149
- margin: "0px"
150
- };
151
- const div_show_image_hover_input = {
152
- display: "block",
153
- top: "0px",
154
- left: "0px",
155
- position: "absolute"
156
- };
157
- const div_show_image_input = {
158
- position: "absolute",
159
- display: "none",
160
- cursor: "pointer"
161
- };
162
- return (_jsxs("div", { children: [(!this.props.data) &&
163
- _jsxs("label", { id: "upload-picture-label", className: this.props.buttonStyle, style: upload_picture_label, children: [this.props.Caption, _jsx("input", { style: upload_picture_label_input, id: "nested-input", type: "file", accept: "image/*", onChange: this.onInputChange, multiple: true })] }), (this.props.data && this.props.data.length > 0) &&
164
- _jsxs("div", { className: "show-image", style: div_show_image, onMouseOver: () => { this.setState({ hover_input: true, hover_image: true }, () => { if (this.debugging)
165
- console.log("onMouseOver"); }); }, onMouseLeave: () => { this.setState({ hover_input: false, hover_image: false }, () => { if (this.debugging)
166
- console.log("onMouseLeave"); }); }, children: [_jsx("img", { style: this.state.hover_image ? div_show_image_hover : div_show_image, src: (this.props.removebase64) ? "data:image/png;base64" : "" + this.props.data, className: this.props.pictureStyle }), !this.props.readOnly &&
167
- _jsx("input", { style: this.state.hover_input ? div_show_image_hover_input : div_show_image_input, className: "btn btn-primary delete", type: "button", value: "Effacer", onClick: this.resetUpload })] })] }));
168
- }
169
- }
package/dist/index.d.mts DELETED
@@ -1,38 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Component, ChangeEvent } from 'react';
3
-
4
- interface DsBlobProps {
5
- width?: number;
6
- height?: number;
7
- maxWidth?: number;
8
- maxHeight?: number;
9
- reduceImage?: boolean;
10
- jpegQuality?: number;
11
- removebase64?: boolean;
12
- uploadPicture: (data: {
13
- data: string;
14
- item_id: any;
15
- }) => void;
16
- item_id: any;
17
- data?: string;
18
- buttonStyle?: string;
19
- Caption?: string;
20
- pictureStyle?: string;
21
- readOnly?: boolean;
22
- }
23
- interface DsBlobState {
24
- hover_input: boolean;
25
- hover_image: boolean;
26
- }
27
- declare class DsBlob extends Component<DsBlobProps, DsBlobState> {
28
- private debugging;
29
- constructor(props: DsBlobProps);
30
- reduceImage: (e: Event) => void;
31
- storeImageToImg: (e: ProgressEvent<FileReader>) => void;
32
- readImage: (aPictureFile: File) => Promise<void>;
33
- resetUpload: () => void;
34
- onInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
35
- render(): react_jsx_runtime.JSX.Element;
36
- }
37
-
38
- export { DsBlob };
package/dist/index.d.ts DELETED
@@ -1,38 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Component, ChangeEvent } from 'react';
3
-
4
- interface DsBlobProps {
5
- width?: number;
6
- height?: number;
7
- maxWidth?: number;
8
- maxHeight?: number;
9
- reduceImage?: boolean;
10
- jpegQuality?: number;
11
- removebase64?: boolean;
12
- uploadPicture: (data: {
13
- data: string;
14
- item_id: any;
15
- }) => void;
16
- item_id: any;
17
- data?: string;
18
- buttonStyle?: string;
19
- Caption?: string;
20
- pictureStyle?: string;
21
- readOnly?: boolean;
22
- }
23
- interface DsBlobState {
24
- hover_input: boolean;
25
- hover_image: boolean;
26
- }
27
- declare class DsBlob extends Component<DsBlobProps, DsBlobState> {
28
- private debugging;
29
- constructor(props: DsBlobProps);
30
- reduceImage: (e: Event) => void;
31
- storeImageToImg: (e: ProgressEvent<FileReader>) => void;
32
- readImage: (aPictureFile: File) => Promise<void>;
33
- resetUpload: () => void;
34
- onInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
35
- render(): react_jsx_runtime.JSX.Element;
36
- }
37
-
38
- export { DsBlob };
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- export { DsBlob } from './DsBlob';
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/components/DsBlob.tsx"],"sourcesContent":["export {DsBlob} from './components/DsBlob';","\nimport React, { Component, ChangeEvent, MouseEvent } from \"react\";\n\ninterface DsBlobProps {\n width?: number;\n height?: number;\n maxWidth?: number;\n maxHeight?: number;\n reduceImage?: boolean;\n jpegQuality?: number;\n removebase64?: boolean;\n uploadPicture: (data: { data: string; item_id: any }) => void;\n item_id: any;\n data?: string;\n buttonStyle?: string;\n Caption?: string;\n pictureStyle?: string;\n readOnly?: boolean;\n}\n\ninterface DsBlobState {\n hover_input: boolean;\n hover_image: boolean;\n}\n\nexport class DsBlob extends Component<DsBlobProps, DsBlobState> {\n private debugging: boolean;\n\n constructor(props: DsBlobProps) {\n super(props);\n this.state = { hover_input: false, hover_image: false };\n this.debugging = false;\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n reduceImage = (e: Event) => {\n let imageSource = ((e as any).path && (e as any).path[0]) || (e as any).srcElement as HTMLImageElement; //Safari compliancy\n\n if (this.debugging) console.log(\"imageSource = \", imageSource);\n var canvas = document.createElement('canvas'),\n context: CanvasRenderingContext2D | null,\n width = imageSource.width,\n height = imageSource.height;\n\n //Exact size props are set\n if (this.props.width && this.props.height) {\n //Check image size\n if (width > this.props.width || height > this.props.height) {\n alert(\"L'image est trop grande, le format requis est \" + this.props.width + \"x\" + this.props.height);\n return\n }\n\n //Check image size\n if (width < this.props.width || height < this.props.height) {\n alert(\"L'image est trop petite, le format requis est \" + this.props.width + \"x\" + this.props.height);\n return\n }\n }\n\n //Max size props are set\n if (this.props.maxWidth && this.props.maxHeight) {\n if (width > height) {\n //Check resize is enabled\n if (!this.props.reduceImage) {\n alert(\"L'image est trop large ! la largeur maximale est de \" + this.props.maxWidth);\n return\n }\n if (width > this.props.maxWidth) {\n height *= this.props.maxWidth / width;\n width = this.props.maxWidth;\n }\n } else {\n if (height > this.props.maxHeight) {\n //Check resize is enabled\n if (!this.props.reduceImage) {\n alert(\"L'image est trop haute, la hauteur maximale est de \" + this.props.maxHeight);\n return\n }\n\n width *= this.props.maxHeight / height;\n height = this.props.maxHeight;\n }\n }\n }\n\n //Build 2d picture\n canvas.width = width;\n canvas.height = height;\n context = canvas.getContext('2d');\n context!.drawImage(imageSource, 0, 0, width, height);\n\n\n //Jpeg conversion\n let jpegCompressionRatio = (this.props.jpegQuality && this.props.jpegQuality > 0 && this.props.jpegQuality < 1) ? this.props.jpegQuality : 1\n let canvasData = canvas.toDataURL('image/jpg', jpegCompressionRatio);//Jpeg conversion\n\n if (this.debugging)\n console.log(\"jpegCompressionRatio->\", jpegCompressionRatio, \" canvasData.length = \", canvasData.length);\n\n if (this.props.removebase64) {\n //remove base64 prefix if property is set\n this.props.uploadPicture({ data: canvasData ? canvasData.substring(\"data:image/png;base64\".length) : \"\", item_id: this.props.item_id });\n }\n else {\n //Keep base 64 prefix as it is\n this.props.uploadPicture({ data: canvasData ? canvasData : \"\", item_id: this.props.item_id });\n }\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n storeImageToImg = (e: ProgressEvent<FileReader>) => {\n var image = document.createElement('img');\n image.onload = this.reduceImage;\n\n image.src = (e.currentTarget as FileReader).result as string;\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n readImage = async (aPictureFile: File) => {\n let _reader = new FileReader();\n\n _reader.onload = this.storeImageToImg;\n _reader.readAsDataURL(aPictureFile);\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n resetUpload = () => {\n this.props.uploadPicture({ data: \"\", item_id: this.props.item_id });\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n const errs: string[] = []\n const files = Array.from(e.target.files || [])\n const types = ['image/png', 'image/jpeg', 'image/gif']\n const _1Mo = 1024 * 1024\n const SizeLimit = 9\n\n //Reset input cache value - to assure trigger if user select the same file again\n e.target.value = \"\"\n\n if (this.debugging)\n console.log(\"onInputChange\")\n\n if (files.length > 1) {\n const msg = 'Pas plus d\\'une image à la fois'\n alert(msg);\n return;\n }\n\n files.forEach((file: File, i: number) => {\n let errCount = errs.length\n if (types.every(type => file.type !== type)) {\n errs.push(`'${file.type}' : format non supporté`)\n }\n\n if (file.size > (SizeLimit * _1Mo)) {\n errs.push(`'${file.name}' image trop volumineuse (max:${SizeLimit}Méga-octets)`)\n }\n\n if (this.debugging)\n console.log(`errCount = ${errCount} vs errs.length = ${errs.length}`)\n\n if (errCount == errs.length) { //None new error occurs\n if (this.debugging)\n console.log(\"readImage::\", file.name);\n this.readImage(file);\n }\n })\n\n if (errs.length) {\n return errs.forEach(err => alert(err))\n }\n }\n\n render() {\n\n const upload_picture_label: React.CSSProperties = {\n cursor: \"pointer\"\n }\n\n const upload_picture_label_input: React.CSSProperties = {\n opacity: \"0\",\n width: \"0px\",\n height: \"0px\"\n }\n\n const div_show_image_hover: React.CSSProperties = {\n position: \"relative\",\n margin: \"0px\",\n opacity: \"0.5\"\n }\n\n const div_show_image: React.CSSProperties = {\n position: \"relative\",\n margin: \"0px\"\n }\n\n const div_show_image_hover_input: React.CSSProperties = {\n display: \"block\",\n top: \"0px\",\n left: \"0px\",\n position: \"absolute\"\n }\n\n const div_show_image_input: React.CSSProperties = {\n position: \"absolute\",\n display: \"none\",\n cursor: \"pointer\"\n }\n\n return (\n <div>\n {(!this.props.data) &&\n <label\n id=\"upload-picture-label\"\n className={this.props.buttonStyle} style={upload_picture_label}>{this.props.Caption}\n <input style={upload_picture_label_input} id=\"nested-input\" type=\"file\" accept=\"image/*\" onChange={this.onInputChange} multiple />\n </label>}\n\n {(this.props.data && this.props.data.length > 0) &&\n <div className=\"show-image\"\n style={div_show_image}\n\n onMouseOver={() => { this.setState({ hover_input: true, hover_image: true }, () => { if (this.debugging) console.log(\"onMouseOver\") }) }}\n onMouseLeave={() => { this.setState({ hover_input: false, hover_image: false }, () => { if (this.debugging) console.log(\"onMouseLeave\") }) }}>\n\n <img\n style={this.state.hover_image ? div_show_image_hover : div_show_image}\n src={(this.props.removebase64) ? \"data:image/png;base64\" : \"\" + this.props.data}\n className={this.props.pictureStyle}\n />\n {!this.props.readOnly &&\n <input\n style={this.state.hover_input ? div_show_image_hover_input : div_show_image_input}\n className=\"btn btn-primary delete\" type=\"button\" value=\"Effacer\"\n onClick={this.resetUpload} />}\n </div>\n }\n </div>);\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;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AAAA;AAAA,MACvC;AAAA,OAER;AAAA,EACR;AACJ;","names":[]}
package/dist/index.mjs DELETED
@@ -1,217 +0,0 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
-
22
- // src/components/DsBlob.tsx
23
- import { Component } from "react";
24
- import { jsx, jsxs } from "react/jsx-runtime";
25
- var DsBlob = class extends Component {
26
- constructor(props) {
27
- super(props);
28
- //-----------------------------------------------------------------------------------------------------------------------------------------
29
- this.reduceImage = (e) => {
30
- let imageSource = e.path && e.path[0] || e.srcElement;
31
- if (this.debugging) console.log("imageSource = ", imageSource);
32
- var canvas = document.createElement("canvas"), context, width = imageSource.width, height = imageSource.height;
33
- if (this.props.width && this.props.height) {
34
- if (width > this.props.width || height > this.props.height) {
35
- alert("L'image est trop grande, le format requis est " + this.props.width + "x" + this.props.height);
36
- return;
37
- }
38
- if (width < this.props.width || height < this.props.height) {
39
- alert("L'image est trop petite, le format requis est " + this.props.width + "x" + this.props.height);
40
- return;
41
- }
42
- }
43
- if (this.props.maxWidth && this.props.maxHeight) {
44
- if (width > height) {
45
- if (!this.props.reduceImage) {
46
- alert("L'image est trop large ! la largeur maximale est de " + this.props.maxWidth);
47
- return;
48
- }
49
- if (width > this.props.maxWidth) {
50
- height *= this.props.maxWidth / width;
51
- width = this.props.maxWidth;
52
- }
53
- } else {
54
- if (height > this.props.maxHeight) {
55
- if (!this.props.reduceImage) {
56
- alert("L'image est trop haute, la hauteur maximale est de " + this.props.maxHeight);
57
- return;
58
- }
59
- width *= this.props.maxHeight / height;
60
- height = this.props.maxHeight;
61
- }
62
- }
63
- }
64
- canvas.width = width;
65
- canvas.height = height;
66
- context = canvas.getContext("2d");
67
- context.drawImage(imageSource, 0, 0, width, height);
68
- let jpegCompressionRatio = this.props.jpegQuality && this.props.jpegQuality > 0 && this.props.jpegQuality < 1 ? this.props.jpegQuality : 1;
69
- let canvasData = canvas.toDataURL("image/jpg", jpegCompressionRatio);
70
- if (this.debugging)
71
- console.log("jpegCompressionRatio->", jpegCompressionRatio, " canvasData.length = ", canvasData.length);
72
- if (this.props.removebase64) {
73
- this.props.uploadPicture({ data: canvasData ? canvasData.substring("data:image/png;base64".length) : "", item_id: this.props.item_id });
74
- } else {
75
- this.props.uploadPicture({ data: canvasData ? canvasData : "", item_id: this.props.item_id });
76
- }
77
- };
78
- //-----------------------------------------------------------------------------------------------------------------------------------------
79
- this.storeImageToImg = (e) => {
80
- var image = document.createElement("img");
81
- image.onload = this.reduceImage;
82
- image.src = e.currentTarget.result;
83
- };
84
- //-----------------------------------------------------------------------------------------------------------------------------------------
85
- this.readImage = (aPictureFile) => __async(this, null, function* () {
86
- let _reader = new FileReader();
87
- _reader.onload = this.storeImageToImg;
88
- _reader.readAsDataURL(aPictureFile);
89
- });
90
- //-----------------------------------------------------------------------------------------------------------------------------------------
91
- this.resetUpload = () => {
92
- this.props.uploadPicture({ data: "", item_id: this.props.item_id });
93
- };
94
- //-----------------------------------------------------------------------------------------------------------------------------------------
95
- this.onInputChange = (e) => {
96
- const errs = [];
97
- const files = Array.from(e.target.files || []);
98
- const types = ["image/png", "image/jpeg", "image/gif"];
99
- const _1Mo = 1024 * 1024;
100
- const SizeLimit = 9;
101
- e.target.value = "";
102
- if (this.debugging)
103
- console.log("onInputChange");
104
- if (files.length > 1) {
105
- const msg = "Pas plus d'une image \xE0 la fois";
106
- alert(msg);
107
- return;
108
- }
109
- files.forEach((file, i) => {
110
- let errCount = errs.length;
111
- if (types.every((type) => file.type !== type)) {
112
- errs.push(`'${file.type}' : format non support\xE9`);
113
- }
114
- if (file.size > SizeLimit * _1Mo) {
115
- errs.push(`'${file.name}' image trop volumineuse (max:${SizeLimit}M\xE9ga-octets)`);
116
- }
117
- if (this.debugging)
118
- console.log(`errCount = ${errCount} vs errs.length = ${errs.length}`);
119
- if (errCount == errs.length) {
120
- if (this.debugging)
121
- console.log("readImage::", file.name);
122
- this.readImage(file);
123
- }
124
- });
125
- if (errs.length) {
126
- return errs.forEach((err) => alert(err));
127
- }
128
- };
129
- this.state = { hover_input: false, hover_image: false };
130
- this.debugging = false;
131
- }
132
- render() {
133
- const upload_picture_label = {
134
- cursor: "pointer"
135
- };
136
- const upload_picture_label_input = {
137
- opacity: "0",
138
- width: "0px",
139
- height: "0px"
140
- };
141
- const div_show_image_hover = {
142
- position: "relative",
143
- margin: "0px",
144
- opacity: "0.5"
145
- };
146
- const div_show_image = {
147
- position: "relative",
148
- margin: "0px"
149
- };
150
- const div_show_image_hover_input = {
151
- display: "block",
152
- top: "0px",
153
- left: "0px",
154
- position: "absolute"
155
- };
156
- const div_show_image_input = {
157
- position: "absolute",
158
- display: "none",
159
- cursor: "pointer"
160
- };
161
- return /* @__PURE__ */ jsxs("div", { children: [
162
- !this.props.data && /* @__PURE__ */ jsxs(
163
- "label",
164
- {
165
- id: "upload-picture-label",
166
- className: this.props.buttonStyle,
167
- style: upload_picture_label,
168
- children: [
169
- this.props.Caption,
170
- /* @__PURE__ */ jsx("input", { style: upload_picture_label_input, id: "nested-input", type: "file", accept: "image/*", onChange: this.onInputChange, multiple: true })
171
- ]
172
- }
173
- ),
174
- this.props.data && this.props.data.length > 0 && /* @__PURE__ */ jsxs(
175
- "div",
176
- {
177
- className: "show-image",
178
- style: div_show_image,
179
- onMouseOver: () => {
180
- this.setState({ hover_input: true, hover_image: true }, () => {
181
- if (this.debugging) console.log("onMouseOver");
182
- });
183
- },
184
- onMouseLeave: () => {
185
- this.setState({ hover_input: false, hover_image: false }, () => {
186
- if (this.debugging) console.log("onMouseLeave");
187
- });
188
- },
189
- children: [
190
- /* @__PURE__ */ jsx(
191
- "img",
192
- {
193
- style: this.state.hover_image ? div_show_image_hover : div_show_image,
194
- src: this.props.removebase64 ? "data:image/png;base64" : "" + this.props.data,
195
- className: this.props.pictureStyle
196
- }
197
- ),
198
- !this.props.readOnly && /* @__PURE__ */ jsx(
199
- "input",
200
- {
201
- style: this.state.hover_input ? div_show_image_hover_input : div_show_image_input,
202
- className: "btn btn-primary delete",
203
- type: "button",
204
- value: "Effacer",
205
- onClick: this.resetUpload
206
- }
207
- )
208
- ]
209
- }
210
- )
211
- ] });
212
- }
213
- };
214
- export {
215
- DsBlob
216
- };
217
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/DsBlob.tsx"],"sourcesContent":["\nimport React, { Component, ChangeEvent, MouseEvent } from \"react\";\n\ninterface DsBlobProps {\n width?: number;\n height?: number;\n maxWidth?: number;\n maxHeight?: number;\n reduceImage?: boolean;\n jpegQuality?: number;\n removebase64?: boolean;\n uploadPicture: (data: { data: string; item_id: any }) => void;\n item_id: any;\n data?: string;\n buttonStyle?: string;\n Caption?: string;\n pictureStyle?: string;\n readOnly?: boolean;\n}\n\ninterface DsBlobState {\n hover_input: boolean;\n hover_image: boolean;\n}\n\nexport class DsBlob extends Component<DsBlobProps, DsBlobState> {\n private debugging: boolean;\n\n constructor(props: DsBlobProps) {\n super(props);\n this.state = { hover_input: false, hover_image: false };\n this.debugging = false;\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n reduceImage = (e: Event) => {\n let imageSource = ((e as any).path && (e as any).path[0]) || (e as any).srcElement as HTMLImageElement; //Safari compliancy\n\n if (this.debugging) console.log(\"imageSource = \", imageSource);\n var canvas = document.createElement('canvas'),\n context: CanvasRenderingContext2D | null,\n width = imageSource.width,\n height = imageSource.height;\n\n //Exact size props are set\n if (this.props.width && this.props.height) {\n //Check image size\n if (width > this.props.width || height > this.props.height) {\n alert(\"L'image est trop grande, le format requis est \" + this.props.width + \"x\" + this.props.height);\n return\n }\n\n //Check image size\n if (width < this.props.width || height < this.props.height) {\n alert(\"L'image est trop petite, le format requis est \" + this.props.width + \"x\" + this.props.height);\n return\n }\n }\n\n //Max size props are set\n if (this.props.maxWidth && this.props.maxHeight) {\n if (width > height) {\n //Check resize is enabled\n if (!this.props.reduceImage) {\n alert(\"L'image est trop large ! la largeur maximale est de \" + this.props.maxWidth);\n return\n }\n if (width > this.props.maxWidth) {\n height *= this.props.maxWidth / width;\n width = this.props.maxWidth;\n }\n } else {\n if (height > this.props.maxHeight) {\n //Check resize is enabled\n if (!this.props.reduceImage) {\n alert(\"L'image est trop haute, la hauteur maximale est de \" + this.props.maxHeight);\n return\n }\n\n width *= this.props.maxHeight / height;\n height = this.props.maxHeight;\n }\n }\n }\n\n //Build 2d picture\n canvas.width = width;\n canvas.height = height;\n context = canvas.getContext('2d');\n context!.drawImage(imageSource, 0, 0, width, height);\n\n\n //Jpeg conversion\n let jpegCompressionRatio = (this.props.jpegQuality && this.props.jpegQuality > 0 && this.props.jpegQuality < 1) ? this.props.jpegQuality : 1\n let canvasData = canvas.toDataURL('image/jpg', jpegCompressionRatio);//Jpeg conversion\n\n if (this.debugging)\n console.log(\"jpegCompressionRatio->\", jpegCompressionRatio, \" canvasData.length = \", canvasData.length);\n\n if (this.props.removebase64) {\n //remove base64 prefix if property is set\n this.props.uploadPicture({ data: canvasData ? canvasData.substring(\"data:image/png;base64\".length) : \"\", item_id: this.props.item_id });\n }\n else {\n //Keep base 64 prefix as it is\n this.props.uploadPicture({ data: canvasData ? canvasData : \"\", item_id: this.props.item_id });\n }\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n storeImageToImg = (e: ProgressEvent<FileReader>) => {\n var image = document.createElement('img');\n image.onload = this.reduceImage;\n\n image.src = (e.currentTarget as FileReader).result as string;\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n readImage = async (aPictureFile: File) => {\n let _reader = new FileReader();\n\n _reader.onload = this.storeImageToImg;\n _reader.readAsDataURL(aPictureFile);\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n resetUpload = () => {\n this.props.uploadPicture({ data: \"\", item_id: this.props.item_id });\n }\n\n //-----------------------------------------------------------------------------------------------------------------------------------------\n onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n const errs: string[] = []\n const files = Array.from(e.target.files || [])\n const types = ['image/png', 'image/jpeg', 'image/gif']\n const _1Mo = 1024 * 1024\n const SizeLimit = 9\n\n //Reset input cache value - to assure trigger if user select the same file again\n e.target.value = \"\"\n\n if (this.debugging)\n console.log(\"onInputChange\")\n\n if (files.length > 1) {\n const msg = 'Pas plus d\\'une image à la fois'\n alert(msg);\n return;\n }\n\n files.forEach((file: File, i: number) => {\n let errCount = errs.length\n if (types.every(type => file.type !== type)) {\n errs.push(`'${file.type}' : format non supporté`)\n }\n\n if (file.size > (SizeLimit * _1Mo)) {\n errs.push(`'${file.name}' image trop volumineuse (max:${SizeLimit}Méga-octets)`)\n }\n\n if (this.debugging)\n console.log(`errCount = ${errCount} vs errs.length = ${errs.length}`)\n\n if (errCount == errs.length) { //None new error occurs\n if (this.debugging)\n console.log(\"readImage::\", file.name);\n this.readImage(file);\n }\n })\n\n if (errs.length) {\n return errs.forEach(err => alert(err))\n }\n }\n\n render() {\n\n const upload_picture_label: React.CSSProperties = {\n cursor: \"pointer\"\n }\n\n const upload_picture_label_input: React.CSSProperties = {\n opacity: \"0\",\n width: \"0px\",\n height: \"0px\"\n }\n\n const div_show_image_hover: React.CSSProperties = {\n position: \"relative\",\n margin: \"0px\",\n opacity: \"0.5\"\n }\n\n const div_show_image: React.CSSProperties = {\n position: \"relative\",\n margin: \"0px\"\n }\n\n const div_show_image_hover_input: React.CSSProperties = {\n display: \"block\",\n top: \"0px\",\n left: \"0px\",\n position: \"absolute\"\n }\n\n const div_show_image_input: React.CSSProperties = {\n position: \"absolute\",\n display: \"none\",\n cursor: \"pointer\"\n }\n\n return (\n <div>\n {(!this.props.data) &&\n <label\n id=\"upload-picture-label\"\n className={this.props.buttonStyle} style={upload_picture_label}>{this.props.Caption}\n <input style={upload_picture_label_input} id=\"nested-input\" type=\"file\" accept=\"image/*\" onChange={this.onInputChange} multiple />\n </label>}\n\n {(this.props.data && this.props.data.length > 0) &&\n <div className=\"show-image\"\n style={div_show_image}\n\n onMouseOver={() => { this.setState({ hover_input: true, hover_image: true }, () => { if (this.debugging) console.log(\"onMouseOver\") }) }}\n onMouseLeave={() => { this.setState({ hover_input: false, hover_image: false }, () => { if (this.debugging) console.log(\"onMouseLeave\") }) }}>\n\n <img\n style={this.state.hover_image ? div_show_image_hover : div_show_image}\n src={(this.props.removebase64) ? \"data:image/png;base64\" : \"\" + this.props.data}\n className={this.props.pictureStyle}\n />\n {!this.props.readOnly &&\n <input\n style={this.state.hover_input ? div_show_image_hover_input : div_show_image_input}\n className=\"btn btn-primary delete\" type=\"button\" value=\"Effacer\"\n onClick={this.resetUpload} />}\n </div>\n }\n </div>);\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,SAAgB,iBAA0C;AAqNtC,SAGI,KAHJ;AA7Lb,IAAM,SAAN,cAAqB,UAAoC;AAAA,EAG5D,YAAY,OAAoB;AAC5B,UAAM,KAAK;AAMf;AAAA,uBAAc,CAAC,MAAa;AACxB,UAAI,cAAgB,EAAU,QAAS,EAAU,KAAK,CAAC,KAAO,EAAU;AAExE,UAAI,KAAK,UAAW,SAAQ,IAAI,kBAAkB,WAAW;AAC7D,UAAI,SAAS,SAAS,cAAc,QAAQ,GACxC,SACA,QAAQ,YAAY,OACpB,SAAS,YAAY;AAGzB,UAAI,KAAK,MAAM,SAAS,KAAK,MAAM,QAAQ;AAEvC,YAAI,QAAQ,KAAK,MAAM,SAAS,SAAS,KAAK,MAAM,QAAQ;AACxD,gBAAM,mDAAmD,KAAK,MAAM,QAAQ,MAAM,KAAK,MAAM,MAAM;AACnG;AAAA,QACJ;AAGA,YAAI,QAAQ,KAAK,MAAM,SAAS,SAAS,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I,aAAa;AAAA,YAAE,CAAC;AAAA,UAAE;AAAA,UACvI,cAAc,MAAM;AAAE,iBAAK,SAAS,EAAE,aAAa,OAAO,aAAa,MAAM,GAAG,MAAM;AAAE,kBAAI,KAAK,UAAW,SAAQ,IAAI,cAAc;AAAA,YAAE,CAAC;AAAA,UAAE;AAAA,UAE3I;AAAA;AAAA,cAAC;AAAA;AAAA,gBACG,OAAO,KAAK,MAAM,cAAc,uBAAuB;AAAA,gBACvD,KAAM,KAAK,MAAM,eAAgB,0BAA0B,KAAK,KAAK,MAAM;AAAA,gBAC3E,WAAW,KAAK,MAAM;AAAA;AAAA,YAC1B;AAAA,YACC,CAAC,KAAK,MAAM,YACT;AAAA,cAAC;AAAA;AAAA,gBACG,OAAO,KAAK,MAAM,cAAc,6BAA6B;AAAA,gBAC7D,WAAU;AAAA,gBAAyB,MAAK;AAAA,gBAAS,OAAM;AAAA,gBACvD,SAAS,KAAK;AAAA;AAAA,YAAa;AAAA;AAAA;AAAA,MACvC;AAAA,OAER;AAAA,EACR;AACJ;","names":[]}
@@ -1,35 +0,0 @@
1
- import { Component, ChangeEvent } from "react";
2
- interface DsBlobProps {
3
- width?: number;
4
- height?: number;
5
- maxWidth?: number;
6
- maxHeight?: number;
7
- reduceImage?: boolean;
8
- jpegQuality?: number;
9
- removebase64?: boolean;
10
- uploadPicture: (data: {
11
- data: string;
12
- item_id: any;
13
- }) => void;
14
- item_id: any;
15
- data?: string;
16
- buttonStyle?: string;
17
- Caption?: string;
18
- pictureStyle?: string;
19
- readOnly?: boolean;
20
- }
21
- interface DsBlobState {
22
- hover_input: boolean;
23
- hover_image: boolean;
24
- }
25
- export declare class DsBlob extends Component<DsBlobProps, DsBlobState> {
26
- private debugging;
27
- constructor(props: DsBlobProps);
28
- reduceImage: (e: Event) => void;
29
- storeImageToImg: (e: ProgressEvent<FileReader>) => void;
30
- readImage: (aPictureFile: File) => Promise<void>;
31
- resetUpload: () => void;
32
- onInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
33
- render(): import("react/jsx-runtime").JSX.Element;
34
- }
35
- export {};
@@ -1 +0,0 @@
1
- export { DsBlob } from './DsBlob';