@raketa-builder/image-input 1.3.5 → 1.3.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.
- package/dist/{index.js → index.mjs} +138 -175
- package/package.json +5 -5
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
1
|
var __defProp = Object.defineProperty;
|
|
4
2
|
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -34,46 +29,15 @@ var __objRest = (source, exclude) => {
|
|
|
34
29
|
}
|
|
35
30
|
return target;
|
|
36
31
|
};
|
|
37
|
-
var __export = (target, all) => {
|
|
38
|
-
for (var name in all)
|
|
39
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
-
};
|
|
41
|
-
var __copyProps = (to, from, except, desc) => {
|
|
42
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
-
for (let key of __getOwnPropNames(from))
|
|
44
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
-
}
|
|
47
|
-
return to;
|
|
48
|
-
};
|
|
49
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
-
mod
|
|
56
|
-
));
|
|
57
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
-
|
|
59
|
-
// src/index.js
|
|
60
|
-
var index_exports = {};
|
|
61
|
-
__export(index_exports, {
|
|
62
|
-
ImageInput: () => ImageInput_default,
|
|
63
|
-
ImagePicker: () => ImagePicker_default,
|
|
64
|
-
MediaManager: () => MediaManager,
|
|
65
|
-
MediaManagerContext: () => MediaManagerContext_default
|
|
66
|
-
});
|
|
67
|
-
module.exports = __toCommonJS(index_exports);
|
|
68
32
|
|
|
69
33
|
// src/pickers/ImagePicker/ImagePicker.js
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
34
|
+
import React8 from "react";
|
|
35
|
+
import { cn as cn6 } from "@raketa-builder/ui";
|
|
36
|
+
import { Image as Image2 } from "@raketa-builder/support";
|
|
73
37
|
|
|
74
38
|
// src/forms/TextInput.js
|
|
75
|
-
|
|
76
|
-
|
|
39
|
+
import React from "react";
|
|
40
|
+
import { FormGroup, Label, Input, Textarea, P } from "@raketa-builder/ui";
|
|
77
41
|
|
|
78
42
|
// src/lists/index.js
|
|
79
43
|
var removeByIndex = (items, idx) => [
|
|
@@ -87,7 +51,7 @@ var removeById = (items, id, idField = "id") => removeByIndex(
|
|
|
87
51
|
var randomString = (length) => Math.random().toString(36).substring(length);
|
|
88
52
|
|
|
89
53
|
// src/forms/TextInput.js
|
|
90
|
-
|
|
54
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
91
55
|
var TextField = (props) => {
|
|
92
56
|
const id = randomString();
|
|
93
57
|
const { label, hint, multiline, onChange } = props;
|
|
@@ -96,20 +60,20 @@ var TextField = (props) => {
|
|
|
96
60
|
delete inputProps.hint;
|
|
97
61
|
delete inputProps.multiline;
|
|
98
62
|
delete inputProps.onChange;
|
|
99
|
-
const Component = multiline ?
|
|
100
|
-
return /* @__PURE__ */
|
|
101
|
-
label ? /* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
63
|
+
const Component = multiline ? Textarea : Input;
|
|
64
|
+
return /* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
65
|
+
label ? /* @__PURE__ */ jsx(Label, { htmlFor: id, error: props.error, children: label }) : "",
|
|
66
|
+
/* @__PURE__ */ jsx(
|
|
103
67
|
Component,
|
|
104
68
|
__spreadValues({
|
|
105
69
|
id,
|
|
106
70
|
onChange: (e) => onChange(e.target.value)
|
|
107
71
|
}, inputProps)
|
|
108
72
|
),
|
|
109
|
-
hint ? /* @__PURE__ */
|
|
73
|
+
hint ? /* @__PURE__ */ jsx(P, { children: hint }) : ""
|
|
110
74
|
] });
|
|
111
75
|
};
|
|
112
|
-
var TextInput = ({ label, onChange, value = "", placeholder = "" }) => /* @__PURE__ */
|
|
76
|
+
var TextInput = ({ label, onChange, value = "", placeholder = "" }) => /* @__PURE__ */ jsx(
|
|
113
77
|
TextField,
|
|
114
78
|
{
|
|
115
79
|
label,
|
|
@@ -121,24 +85,24 @@ var TextInput = ({ label, onChange, value = "", placeholder = "" }) => /* @__PUR
|
|
|
121
85
|
var TextInput_default = TextInput;
|
|
122
86
|
|
|
123
87
|
// src/dialogs/Dialog.js
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
88
|
+
import React2 from "react";
|
|
89
|
+
import { Modal, Button, cn } from "@raketa-builder/ui";
|
|
90
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
127
91
|
var ModalContent = (_a) => {
|
|
128
92
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
129
|
-
return /* @__PURE__ */ (
|
|
93
|
+
return /* @__PURE__ */ jsx2(
|
|
130
94
|
"div",
|
|
131
95
|
__spreadValues({
|
|
132
|
-
className:
|
|
96
|
+
className: cn("r-reset", "r-image-picker-modal-content", className)
|
|
133
97
|
}, rest)
|
|
134
98
|
);
|
|
135
99
|
};
|
|
136
100
|
var ModalFooter = (_a) => {
|
|
137
101
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
138
|
-
return /* @__PURE__ */ (
|
|
102
|
+
return /* @__PURE__ */ jsx2(
|
|
139
103
|
"div",
|
|
140
104
|
__spreadValues({
|
|
141
|
-
className:
|
|
105
|
+
className: cn("r-reset", "r-image-picker-modal-footer", className)
|
|
142
106
|
}, rest)
|
|
143
107
|
);
|
|
144
108
|
};
|
|
@@ -149,35 +113,35 @@ var Dialog = ({
|
|
|
149
113
|
primaryLabel,
|
|
150
114
|
secondaryLabel = "Cancel",
|
|
151
115
|
onPrimary
|
|
152
|
-
}) => /* @__PURE__ */ (
|
|
153
|
-
/* @__PURE__ */ (
|
|
154
|
-
(primaryLabel || secondaryLabel) && /* @__PURE__ */ (
|
|
155
|
-
primaryLabel && /* @__PURE__ */ (
|
|
156
|
-
secondaryLabel && /* @__PURE__ */ (
|
|
116
|
+
}) => /* @__PURE__ */ jsxs2(Modal, { title, onClose, children: [
|
|
117
|
+
/* @__PURE__ */ jsx2(ModalContent, { children }),
|
|
118
|
+
(primaryLabel || secondaryLabel) && /* @__PURE__ */ jsxs2(ModalFooter, { children: [
|
|
119
|
+
primaryLabel && /* @__PURE__ */ jsx2(Button, { type: "button", variant: "primary", onClick: onPrimary, children: primaryLabel }),
|
|
120
|
+
secondaryLabel && /* @__PURE__ */ jsx2(Button, { type: "button", variant: "secondary", onClick: onClose, children: secondaryLabel })
|
|
157
121
|
] })
|
|
158
122
|
] });
|
|
159
123
|
var Dialog_default = Dialog;
|
|
160
124
|
|
|
161
125
|
// src/pickers/ImagePicker/BrowseTab.js
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
126
|
+
import React3 from "react";
|
|
127
|
+
import { Button as Button2, Stack, H, cn as cn2 } from "@raketa-builder/ui";
|
|
128
|
+
import { Image } from "@raketa-builder/support";
|
|
129
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
166
130
|
var ImageList = (_a) => {
|
|
167
131
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
168
|
-
return /* @__PURE__ */ (
|
|
132
|
+
return /* @__PURE__ */ jsx3(
|
|
169
133
|
"div",
|
|
170
134
|
__spreadValues({
|
|
171
|
-
className: (
|
|
135
|
+
className: cn2("r-reset", "r-image-picker-image-list", className)
|
|
172
136
|
}, rest)
|
|
173
137
|
);
|
|
174
138
|
};
|
|
175
139
|
var Thumb = (_a) => {
|
|
176
140
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
177
|
-
return /* @__PURE__ */ (
|
|
141
|
+
return /* @__PURE__ */ jsx3(
|
|
178
142
|
"div",
|
|
179
143
|
__spreadProps(__spreadValues({
|
|
180
|
-
className: (
|
|
144
|
+
className: cn2("r-reset", "r-image-picker-thumb", className)
|
|
181
145
|
}, rest), {
|
|
182
146
|
style: {
|
|
183
147
|
borderColor: rest.selected ? "var(--r-success)" : "transparent"
|
|
@@ -187,10 +151,10 @@ var Thumb = (_a) => {
|
|
|
187
151
|
};
|
|
188
152
|
var ImageWrapper = (_a) => {
|
|
189
153
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
190
|
-
return /* @__PURE__ */ (
|
|
154
|
+
return /* @__PURE__ */ jsx3(
|
|
191
155
|
"div",
|
|
192
156
|
__spreadValues({
|
|
193
|
-
className: (
|
|
157
|
+
className: cn2("r-reset", "r-image-picker-image-wrapper", className)
|
|
194
158
|
}, rest)
|
|
195
159
|
);
|
|
196
160
|
};
|
|
@@ -201,14 +165,14 @@ var getPreviewImage = (image) => {
|
|
|
201
165
|
}
|
|
202
166
|
return image;
|
|
203
167
|
};
|
|
204
|
-
var ImageItem = ({ image, selected, onSelect, onFastSelect }) => /* @__PURE__ */ (
|
|
168
|
+
var ImageItem = ({ image, selected, onSelect, onFastSelect }) => /* @__PURE__ */ jsx3(
|
|
205
169
|
Thumb,
|
|
206
170
|
{
|
|
207
171
|
selected: selected ? "selected" : "",
|
|
208
172
|
onClick: () => onSelect(image),
|
|
209
173
|
onDoubleClick: () => onFastSelect(image),
|
|
210
|
-
children: /* @__PURE__ */ (
|
|
211
|
-
|
|
174
|
+
children: /* @__PURE__ */ jsx3(ImageWrapper, { title: image.name, children: /* @__PURE__ */ jsx3(
|
|
175
|
+
Image,
|
|
212
176
|
{
|
|
213
177
|
src: getPreviewImage(image),
|
|
214
178
|
variant: "thumb",
|
|
@@ -220,19 +184,19 @@ var ImageItem = ({ image, selected, onSelect, onFastSelect }) => /* @__PURE__ */
|
|
|
220
184
|
);
|
|
221
185
|
var ImagePreviewWrapper = (_a) => {
|
|
222
186
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
223
|
-
return /* @__PURE__ */ (
|
|
187
|
+
return /* @__PURE__ */ jsx3(
|
|
224
188
|
"div",
|
|
225
189
|
__spreadValues({
|
|
226
|
-
className: (
|
|
190
|
+
className: cn2("r-reset", "r-image-picker-image-preview-wrapper", className)
|
|
227
191
|
}, rest)
|
|
228
192
|
);
|
|
229
193
|
};
|
|
230
194
|
var ImageInspector = (_a) => {
|
|
231
195
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
232
|
-
return /* @__PURE__ */ (
|
|
196
|
+
return /* @__PURE__ */ jsx3(
|
|
233
197
|
"div",
|
|
234
198
|
__spreadValues({
|
|
235
|
-
className: (
|
|
199
|
+
className: cn2("r-reset", "r-image-picker-image-inspector", className)
|
|
236
200
|
}, rest)
|
|
237
201
|
);
|
|
238
202
|
};
|
|
@@ -244,12 +208,12 @@ var isImageEditable = (image) => {
|
|
|
244
208
|
return true;
|
|
245
209
|
};
|
|
246
210
|
var ImagePreview = ({ image, onDelete }) => {
|
|
247
|
-
return /* @__PURE__ */ (
|
|
248
|
-
/* @__PURE__ */ (
|
|
249
|
-
/* @__PURE__ */ (
|
|
250
|
-
isImageEditable(image) && /* @__PURE__ */ (
|
|
251
|
-
/* @__PURE__ */ (
|
|
252
|
-
|
|
211
|
+
return /* @__PURE__ */ jsxs3(ImageInspector, { children: [
|
|
212
|
+
/* @__PURE__ */ jsxs3(ImagePreviewWrapper, { children: [
|
|
213
|
+
/* @__PURE__ */ jsx3(Image, { src: image, variant: "original", alt: "" }),
|
|
214
|
+
isImageEditable(image) && /* @__PURE__ */ jsxs3(React3.Fragment, { children: [
|
|
215
|
+
/* @__PURE__ */ jsx3(
|
|
216
|
+
H,
|
|
253
217
|
{
|
|
254
218
|
size: "regular",
|
|
255
219
|
style: {
|
|
@@ -261,7 +225,7 @@ var ImagePreview = ({ image, onDelete }) => {
|
|
|
261
225
|
children: image.name
|
|
262
226
|
}
|
|
263
227
|
),
|
|
264
|
-
/* @__PURE__ */ (
|
|
228
|
+
/* @__PURE__ */ jsxs3("div", { style: { opacity: 0.5 }, children: [
|
|
265
229
|
(image.size / 1024).toFixed(2),
|
|
266
230
|
" KB / ",
|
|
267
231
|
image.width,
|
|
@@ -270,8 +234,8 @@ var ImagePreview = ({ image, onDelete }) => {
|
|
|
270
234
|
] })
|
|
271
235
|
] })
|
|
272
236
|
] }),
|
|
273
|
-
isImageEditable(image) && /* @__PURE__ */ (
|
|
274
|
-
|
|
237
|
+
isImageEditable(image) && /* @__PURE__ */ jsx3(React3.Fragment, { children: /* @__PURE__ */ jsx3(
|
|
238
|
+
Button2,
|
|
275
239
|
{
|
|
276
240
|
type: "button",
|
|
277
241
|
variant: "danger",
|
|
@@ -295,14 +259,14 @@ var BrowseTab = ({
|
|
|
295
259
|
onSearch,
|
|
296
260
|
onSearchTermChange
|
|
297
261
|
}) => {
|
|
298
|
-
const [selectedImage, setSelectedImage] =
|
|
262
|
+
const [selectedImage, setSelectedImage] = React3.useState(initialImage);
|
|
299
263
|
const handleSelectImage = (newSelected) => {
|
|
300
264
|
setSelectedImage(newSelected);
|
|
301
265
|
onSelect(newSelected);
|
|
302
266
|
};
|
|
303
|
-
return /* @__PURE__ */ (
|
|
304
|
-
/* @__PURE__ */ (
|
|
305
|
-
/* @__PURE__ */ (
|
|
267
|
+
return /* @__PURE__ */ jsxs3(React3.Fragment, { children: [
|
|
268
|
+
/* @__PURE__ */ jsxs3(Stack, { className: "r-stack-align-center r-stack-justify-start", children: [
|
|
269
|
+
/* @__PURE__ */ jsx3(
|
|
306
270
|
TextInput_default,
|
|
307
271
|
{
|
|
308
272
|
label: "Search images",
|
|
@@ -310,10 +274,10 @@ var BrowseTab = ({
|
|
|
310
274
|
onChange: (term) => onSearchTermChange(term)
|
|
311
275
|
}
|
|
312
276
|
),
|
|
313
|
-
/* @__PURE__ */ (
|
|
277
|
+
/* @__PURE__ */ jsx3(Button2, { type: "button", variant: "secondary", onClick: () => onSearch(), children: "Search" })
|
|
314
278
|
] }),
|
|
315
|
-
/* @__PURE__ */ (
|
|
316
|
-
/* @__PURE__ */ (
|
|
279
|
+
/* @__PURE__ */ jsxs3(Stack, { children: [
|
|
280
|
+
/* @__PURE__ */ jsx3(ImageList, { children: images.map((image) => /* @__PURE__ */ jsx3(
|
|
317
281
|
ImageItem,
|
|
318
282
|
{
|
|
319
283
|
image,
|
|
@@ -323,7 +287,7 @@ var BrowseTab = ({
|
|
|
323
287
|
},
|
|
324
288
|
image.id
|
|
325
289
|
)) }),
|
|
326
|
-
selectedImage && /* @__PURE__ */ (
|
|
290
|
+
selectedImage && /* @__PURE__ */ jsx3(
|
|
327
291
|
ImagePreview,
|
|
328
292
|
{
|
|
329
293
|
image: selectedImage,
|
|
@@ -340,43 +304,43 @@ var LARGE_FILE_PLACEHOLDER = "data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBo
|
|
|
340
304
|
var BrowseTab_default = BrowseTab;
|
|
341
305
|
|
|
342
306
|
// src/pickers/ImagePicker/UploadTab.js
|
|
343
|
-
|
|
344
|
-
|
|
307
|
+
import React6 from "react";
|
|
308
|
+
import { cn as cn5 } from "@raketa-builder/ui";
|
|
345
309
|
|
|
346
310
|
// src/lib/Dropbox.js
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
311
|
+
import React4 from "react";
|
|
312
|
+
import { H as H2, Button as Button3, cn as cn3 } from "@raketa-builder/ui";
|
|
313
|
+
import Dropzone from "react-dropzone";
|
|
314
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
351
315
|
var StyledDropzone = (_a) => {
|
|
352
316
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
353
|
-
return /* @__PURE__ */ (
|
|
317
|
+
return /* @__PURE__ */ jsx4(
|
|
354
318
|
"div",
|
|
355
319
|
__spreadValues({
|
|
356
|
-
className: (
|
|
320
|
+
className: cn3("r-reset", "r-image-picker-dropzone", className)
|
|
357
321
|
}, rest)
|
|
358
322
|
);
|
|
359
323
|
};
|
|
360
324
|
var DropzoneLabel = (_a) => {
|
|
361
325
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
362
|
-
return /* @__PURE__ */ (
|
|
326
|
+
return /* @__PURE__ */ jsx4(
|
|
363
327
|
"div",
|
|
364
328
|
__spreadValues({
|
|
365
|
-
className: (
|
|
329
|
+
className: cn3("r-reset", "r-image-picker-dropzone-label", className)
|
|
366
330
|
}, rest)
|
|
367
331
|
);
|
|
368
332
|
};
|
|
369
333
|
var Dropbox = ({ buttonLabel = "Select files...", onDrop }) => {
|
|
370
|
-
const dropzoneRef =
|
|
334
|
+
const dropzoneRef = React4.createRef();
|
|
371
335
|
const handleOpen = () => dropzoneRef.current.open();
|
|
372
|
-
return /* @__PURE__ */ (
|
|
373
|
-
/* @__PURE__ */ (
|
|
374
|
-
/* @__PURE__ */ (
|
|
375
|
-
/* @__PURE__ */ (
|
|
376
|
-
/* @__PURE__ */ (
|
|
336
|
+
return /* @__PURE__ */ jsxs4(React4.Fragment, { children: [
|
|
337
|
+
/* @__PURE__ */ jsx4(StyledDropzone, { children: /* @__PURE__ */ jsx4(Dropzone, { ref: dropzoneRef, onDrop, children: ({ getRootProps, getInputProps }) => /* @__PURE__ */ jsxs4(DropzoneLabel, __spreadProps(__spreadValues({}, getRootProps()), { children: [
|
|
338
|
+
/* @__PURE__ */ jsx4(H2, { size: "large", children: "Select files from your computer" }),
|
|
339
|
+
/* @__PURE__ */ jsx4("small", { children: "or drag and drop here" }),
|
|
340
|
+
/* @__PURE__ */ jsx4("input", __spreadValues({}, getInputProps()))
|
|
377
341
|
] })) }) }),
|
|
378
|
-
/* @__PURE__ */ (
|
|
379
|
-
|
|
342
|
+
/* @__PURE__ */ jsx4(
|
|
343
|
+
Button3,
|
|
380
344
|
{
|
|
381
345
|
type: "button",
|
|
382
346
|
variant: "success",
|
|
@@ -390,30 +354,30 @@ var Dropbox = ({ buttonLabel = "Select files...", onDrop }) => {
|
|
|
390
354
|
var Dropbox_default = Dropbox;
|
|
391
355
|
|
|
392
356
|
// src/lib/ProgressBar.js
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
357
|
+
import React5 from "react";
|
|
358
|
+
import { cn as cn4 } from "@raketa-builder/ui";
|
|
359
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
396
360
|
var ProgressWrapper = (_a) => {
|
|
397
361
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
398
|
-
return /* @__PURE__ */ (
|
|
362
|
+
return /* @__PURE__ */ jsx5(
|
|
399
363
|
"div",
|
|
400
364
|
__spreadValues({
|
|
401
|
-
className: (
|
|
365
|
+
className: cn4("r-reset", "r-image-picker-progress-wrapper", className)
|
|
402
366
|
}, rest)
|
|
403
367
|
);
|
|
404
368
|
};
|
|
405
369
|
var Progress = (_a) => {
|
|
406
370
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
407
|
-
return /* @__PURE__ */ (
|
|
371
|
+
return /* @__PURE__ */ jsx5(
|
|
408
372
|
"div",
|
|
409
373
|
__spreadValues({
|
|
410
|
-
className: (
|
|
374
|
+
className: cn4("r-reset", "r-image-picker-progress", className)
|
|
411
375
|
}, rest)
|
|
412
376
|
);
|
|
413
377
|
};
|
|
414
378
|
var ProgressBar = ({ total, done }) => {
|
|
415
379
|
const progress = 100 / total * done;
|
|
416
|
-
return /* @__PURE__ */ (
|
|
380
|
+
return /* @__PURE__ */ jsx5(ProgressWrapper, { children: /* @__PURE__ */ jsxs5(Progress, { style: { width: `${progress}%` }, children: [
|
|
417
381
|
done,
|
|
418
382
|
"/",
|
|
419
383
|
total
|
|
@@ -422,35 +386,35 @@ var ProgressBar = ({ total, done }) => {
|
|
|
422
386
|
var ProgressBar_default = ProgressBar;
|
|
423
387
|
|
|
424
388
|
// src/pickers/ImagePicker/UploadTab.js
|
|
425
|
-
|
|
426
|
-
var FileItem = ({ file }) => /* @__PURE__ */ (
|
|
427
|
-
/* @__PURE__ */ (
|
|
428
|
-
/* @__PURE__ */ (
|
|
389
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
390
|
+
var FileItem = ({ file }) => /* @__PURE__ */ jsxs6("div", { children: [
|
|
391
|
+
/* @__PURE__ */ jsx6("strong", { children: file.name }),
|
|
392
|
+
/* @__PURE__ */ jsx6("span", { children: "Completed" })
|
|
429
393
|
] });
|
|
430
|
-
var FileList = ({ files }) => /* @__PURE__ */ (
|
|
394
|
+
var FileList = ({ files }) => /* @__PURE__ */ jsx6("div", { children: files.map((file) => /* @__PURE__ */ jsx6(FileItem, { file }, file.id)) });
|
|
431
395
|
var ImageUploader = (_a) => {
|
|
432
396
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
433
|
-
return /* @__PURE__ */ (
|
|
397
|
+
return /* @__PURE__ */ jsx6(
|
|
434
398
|
"div",
|
|
435
399
|
__spreadValues({
|
|
436
|
-
className: (
|
|
400
|
+
className: cn5("r-reset", "r-image-picker-image-uploader", className)
|
|
437
401
|
}, rest)
|
|
438
402
|
);
|
|
439
403
|
};
|
|
440
|
-
var UploadTab = class extends
|
|
404
|
+
var UploadTab = class extends React6.Component {
|
|
441
405
|
isUploading() {
|
|
442
406
|
return this.props.filesToUpload !== this.props.filesUploaded;
|
|
443
407
|
}
|
|
444
408
|
renderProgress() {
|
|
445
409
|
const { filesToUpload, filesUploaded, files } = this.props;
|
|
446
|
-
return /* @__PURE__ */ (
|
|
447
|
-
/* @__PURE__ */ (
|
|
448
|
-
/* @__PURE__ */ (
|
|
410
|
+
return /* @__PURE__ */ jsxs6("div", { children: [
|
|
411
|
+
/* @__PURE__ */ jsx6(ProgressBar_default, { total: filesToUpload, done: filesUploaded }),
|
|
412
|
+
/* @__PURE__ */ jsx6(FileList, { files })
|
|
449
413
|
] });
|
|
450
414
|
}
|
|
451
415
|
render() {
|
|
452
|
-
return /* @__PURE__ */ (
|
|
453
|
-
!this.isUploading() ? /* @__PURE__ */ (
|
|
416
|
+
return /* @__PURE__ */ jsxs6(ImageUploader, { children: [
|
|
417
|
+
!this.isUploading() ? /* @__PURE__ */ jsx6(
|
|
454
418
|
Dropbox_default,
|
|
455
419
|
{
|
|
456
420
|
onDrop: (files) => this.props.onUpload(files),
|
|
@@ -464,39 +428,39 @@ var UploadTab = class extends import_react6.default.Component {
|
|
|
464
428
|
var UploadTab_default = UploadTab;
|
|
465
429
|
|
|
466
430
|
// src/pickers/ImagePicker/ImagePicker.js
|
|
467
|
-
|
|
431
|
+
import { FormGroup as FormGroup2, Label as Label2, Button as Button4, Tabs, Stack as Stack2 } from "@raketa-builder/ui";
|
|
468
432
|
|
|
469
433
|
// src/MediaManagerContext.js
|
|
470
|
-
|
|
471
|
-
var MediaManagerContext =
|
|
434
|
+
import React7 from "react";
|
|
435
|
+
var MediaManagerContext = React7.createContext({});
|
|
472
436
|
var MediaManagerContext_default = MediaManagerContext;
|
|
473
437
|
|
|
474
438
|
// src/pickers/ImagePicker/ImagePicker.js
|
|
475
|
-
|
|
439
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
476
440
|
var ImagePlaceholder = (_a) => {
|
|
477
441
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
478
|
-
return /* @__PURE__ */ (
|
|
442
|
+
return /* @__PURE__ */ jsx7(
|
|
479
443
|
"div",
|
|
480
444
|
__spreadValues({
|
|
481
|
-
className: (
|
|
445
|
+
className: cn6("r-reset", "r-image-picker-placeholder", className)
|
|
482
446
|
}, rest)
|
|
483
447
|
);
|
|
484
448
|
};
|
|
485
449
|
var ImageWrapper2 = (_a) => {
|
|
486
450
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
487
|
-
return /* @__PURE__ */ (
|
|
451
|
+
return /* @__PURE__ */ jsx7(
|
|
488
452
|
"div",
|
|
489
453
|
__spreadValues({
|
|
490
|
-
className: (
|
|
454
|
+
className: cn6("r-reset", "r-image-picker-image-wrapper-2", className)
|
|
491
455
|
}, rest)
|
|
492
456
|
);
|
|
493
457
|
};
|
|
494
458
|
var ImageControl = (_a) => {
|
|
495
459
|
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
496
|
-
return /* @__PURE__ */ (
|
|
460
|
+
return /* @__PURE__ */ jsx7(
|
|
497
461
|
"div",
|
|
498
462
|
__spreadValues({
|
|
499
|
-
className: (
|
|
463
|
+
className: cn6("r-reset", "r-image-picker-image-control", className)
|
|
500
464
|
}, rest)
|
|
501
465
|
);
|
|
502
466
|
};
|
|
@@ -526,9 +490,9 @@ var ImagePicker = ({
|
|
|
526
490
|
value,
|
|
527
491
|
onChange
|
|
528
492
|
}) => {
|
|
529
|
-
const contextMediaManager =
|
|
530
|
-
const [open, setOpen] =
|
|
531
|
-
const [state, setState] =
|
|
493
|
+
const contextMediaManager = React8.useContext(MediaManagerContext_default);
|
|
494
|
+
const [open, setOpen] = React8.useState(false);
|
|
495
|
+
const [state, setState] = React8.useState({
|
|
532
496
|
selectedImage: fetchImage(value),
|
|
533
497
|
alt: fetchAlt(value),
|
|
534
498
|
filesToUpload: 0,
|
|
@@ -608,17 +572,17 @@ var ImagePicker = ({
|
|
|
608
572
|
};
|
|
609
573
|
const { filesToUpload, filesUploaded, images, selectedImage, files, q } = state;
|
|
610
574
|
const image = fetchImage(value);
|
|
611
|
-
return /* @__PURE__ */ (
|
|
612
|
-
/* @__PURE__ */ (
|
|
613
|
-
/* @__PURE__ */ (
|
|
614
|
-
image && /* @__PURE__ */ (
|
|
615
|
-
!image && /* @__PURE__ */ (
|
|
575
|
+
return /* @__PURE__ */ jsxs7("div", { children: [
|
|
576
|
+
/* @__PURE__ */ jsxs7(ImageControl, { children: [
|
|
577
|
+
/* @__PURE__ */ jsxs7(ImageWrapper2, { children: [
|
|
578
|
+
image && /* @__PURE__ */ jsx7(Image2, { src: image, variant: "thumb", title: image.name, alt: "" }),
|
|
579
|
+
!image && /* @__PURE__ */ jsx7(ImagePlaceholder, {})
|
|
616
580
|
] }),
|
|
617
|
-
/* @__PURE__ */ (
|
|
618
|
-
/* @__PURE__ */ (
|
|
619
|
-
/* @__PURE__ */ (
|
|
620
|
-
/* @__PURE__ */ (
|
|
621
|
-
|
|
581
|
+
/* @__PURE__ */ jsxs7(FormGroup2, { children: [
|
|
582
|
+
/* @__PURE__ */ jsx7(Label2, { children: label }),
|
|
583
|
+
/* @__PURE__ */ jsxs7("div", { style: { marginBottom: "0.5rem" }, children: [
|
|
584
|
+
/* @__PURE__ */ jsx7(
|
|
585
|
+
Button4,
|
|
622
586
|
{
|
|
623
587
|
type: "button",
|
|
624
588
|
variant: "secondary",
|
|
@@ -626,8 +590,8 @@ var ImagePicker = ({
|
|
|
626
590
|
children: "Browse..."
|
|
627
591
|
}
|
|
628
592
|
),
|
|
629
|
-
/* @__PURE__ */ (
|
|
630
|
-
|
|
593
|
+
/* @__PURE__ */ jsx7(
|
|
594
|
+
Button4,
|
|
631
595
|
{
|
|
632
596
|
type: "button",
|
|
633
597
|
variant: "secondary",
|
|
@@ -636,7 +600,7 @@ var ImagePicker = ({
|
|
|
636
600
|
}
|
|
637
601
|
)
|
|
638
602
|
] }),
|
|
639
|
-
/* @__PURE__ */ (
|
|
603
|
+
/* @__PURE__ */ jsx7("div", { style: { width: "200px" }, children: /* @__PURE__ */ jsx7(
|
|
640
604
|
TextInput_default,
|
|
641
605
|
{
|
|
642
606
|
label: false,
|
|
@@ -647,7 +611,7 @@ var ImagePicker = ({
|
|
|
647
611
|
) })
|
|
648
612
|
] })
|
|
649
613
|
] }),
|
|
650
|
-
open && /* @__PURE__ */ (
|
|
614
|
+
open && /* @__PURE__ */ jsx7(
|
|
651
615
|
Dialog_default,
|
|
652
616
|
{
|
|
653
617
|
open: true,
|
|
@@ -655,8 +619,8 @@ var ImagePicker = ({
|
|
|
655
619
|
title: "Image Browser",
|
|
656
620
|
primaryLabel: "Select",
|
|
657
621
|
onPrimary: handleSelectImage,
|
|
658
|
-
children: /* @__PURE__ */ (
|
|
659
|
-
/* @__PURE__ */ (
|
|
622
|
+
children: /* @__PURE__ */ jsxs7(Tabs, { children: [
|
|
623
|
+
/* @__PURE__ */ jsx7("div", { title: "Browse", children: /* @__PURE__ */ jsx7(
|
|
660
624
|
BrowseTab_default,
|
|
661
625
|
{
|
|
662
626
|
images,
|
|
@@ -669,7 +633,7 @@ var ImagePicker = ({
|
|
|
669
633
|
onDelete: handleDeleteImage
|
|
670
634
|
}
|
|
671
635
|
) }),
|
|
672
|
-
/* @__PURE__ */ (
|
|
636
|
+
/* @__PURE__ */ jsx7("div", { title: "Upload", children: /* @__PURE__ */ jsx7(
|
|
673
637
|
UploadTab_default,
|
|
674
638
|
{
|
|
675
639
|
filesToUpload,
|
|
@@ -686,9 +650,9 @@ var ImagePicker = ({
|
|
|
686
650
|
var ImagePicker_default = ImagePicker;
|
|
687
651
|
|
|
688
652
|
// src/pickers/ImagePicker/ImageInput.js
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
var ImageInput = class extends
|
|
653
|
+
import React9 from "react";
|
|
654
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
655
|
+
var ImageInput = class extends React9.Component {
|
|
692
656
|
constructor(props) {
|
|
693
657
|
super(props);
|
|
694
658
|
this.state = {
|
|
@@ -703,8 +667,8 @@ var ImageInput = class extends import_react9.default.Component {
|
|
|
703
667
|
render() {
|
|
704
668
|
const { name, mediaManager } = this.props;
|
|
705
669
|
const { selectedImage } = this.state;
|
|
706
|
-
return /* @__PURE__ */ (
|
|
707
|
-
/* @__PURE__ */ (
|
|
670
|
+
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
671
|
+
/* @__PURE__ */ jsx8(
|
|
708
672
|
ImagePicker_default,
|
|
709
673
|
{
|
|
710
674
|
mediaManager,
|
|
@@ -712,7 +676,7 @@ var ImageInput = class extends import_react9.default.Component {
|
|
|
712
676
|
onChange: (selectedImage2) => this.handleChange(selectedImage2)
|
|
713
677
|
}
|
|
714
678
|
),
|
|
715
|
-
/* @__PURE__ */ (
|
|
679
|
+
/* @__PURE__ */ jsx8(
|
|
716
680
|
"input",
|
|
717
681
|
{
|
|
718
682
|
type: "hidden",
|
|
@@ -788,10 +752,9 @@ var MediaManager = class {
|
|
|
788
752
|
).then((r) => r.json()).then((image2) => callback(image2));
|
|
789
753
|
}
|
|
790
754
|
};
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
ImagePicker,
|
|
755
|
+
export {
|
|
756
|
+
ImageInput_default as ImageInput,
|
|
757
|
+
ImagePicker_default as ImagePicker,
|
|
795
758
|
MediaManager,
|
|
796
|
-
MediaManagerContext
|
|
797
|
-
}
|
|
759
|
+
MediaManagerContext_default as MediaManagerContext
|
|
760
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-builder/image-input",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsup src/index.js --format
|
|
9
|
-
"dev": "tsup src/index.js --format
|
|
8
|
+
"build": "tsup src/index.js --format esm --loader \".js=jsx\"",
|
|
9
|
+
"dev": "tsup src/index.js --format esm --loader \".js=jsx\" --watch",
|
|
10
10
|
"format": "prettier --write .",
|
|
11
11
|
"lint": "biome lint --max-diagnostics=5000 ."
|
|
12
12
|
},
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"react-dropzone": "14.3.8",
|
|
19
|
-
"@raketa-builder/support": "1.3.
|
|
20
|
-
"@raketa-builder/ui": "1.3.
|
|
19
|
+
"@raketa-builder/support": "1.3.6",
|
|
20
|
+
"@raketa-builder/ui": "1.3.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@biomejs/biome": "1.9.4",
|