img-upload-kit 0.0.0-stage → 2.0.0
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/CHANGELOG.md +89 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +192 -0
- package/README.md +242 -2
- package/dist/bin.js +1186 -0
- package/dist/bin.js.map +1 -0
- package/dist/blur.cjs +41 -0
- package/dist/blur.cjs.map +1 -0
- package/dist/blur.d.cts +17 -0
- package/dist/blur.d.ts +17 -0
- package/dist/blur.js +41 -0
- package/dist/blur.js.map +1 -0
- package/dist/blurDataUtils-DveBRtqE.d.cts +43 -0
- package/dist/blurDataUtils-yx9Q6HlU.d.ts +43 -0
- package/dist/blurService-D5TpMNji.d.ts +83 -0
- package/dist/blurService-DacwylJx.d.cts +83 -0
- package/dist/chunk-2OVNXHTN.cjs +514 -0
- package/dist/chunk-2OVNXHTN.cjs.map +1 -0
- package/dist/chunk-3ICG2SLL.cjs +135 -0
- package/dist/chunk-3ICG2SLL.cjs.map +1 -0
- package/dist/chunk-4ASFG3KB.js +514 -0
- package/dist/chunk-4ASFG3KB.js.map +1 -0
- package/dist/chunk-AI3JJLSA.js +2370 -0
- package/dist/chunk-AI3JJLSA.js.map +1 -0
- package/dist/chunk-CV23O4YU.js +145 -0
- package/dist/chunk-CV23O4YU.js.map +1 -0
- package/dist/chunk-G7LLSKBV.js +158 -0
- package/dist/chunk-G7LLSKBV.js.map +1 -0
- package/dist/chunk-IB3TEDLR.js +294 -0
- package/dist/chunk-IB3TEDLR.js.map +1 -0
- package/dist/chunk-KJVYWKIG.cjs +158 -0
- package/dist/chunk-KJVYWKIG.cjs.map +1 -0
- package/dist/chunk-NEDBIIE3.cjs +226 -0
- package/dist/chunk-NEDBIIE3.cjs.map +1 -0
- package/dist/chunk-QHU7FUO4.cjs +37 -0
- package/dist/chunk-QHU7FUO4.cjs.map +1 -0
- package/dist/chunk-QQHZJKNA.js +135 -0
- package/dist/chunk-QQHZJKNA.js.map +1 -0
- package/dist/chunk-S2IFAWJK.js +37 -0
- package/dist/chunk-S2IFAWJK.js.map +1 -0
- package/dist/chunk-TT5C7K3Q.js +226 -0
- package/dist/chunk-TT5C7K3Q.js.map +1 -0
- package/dist/chunk-U2TWTEBY.cjs +2370 -0
- package/dist/chunk-U2TWTEBY.cjs.map +1 -0
- package/dist/chunk-WISG74VL.cjs +294 -0
- package/dist/chunk-WISG74VL.cjs.map +1 -0
- package/dist/chunk-YRXXQUDE.cjs +145 -0
- package/dist/chunk-YRXXQUDE.cjs.map +1 -0
- package/dist/cli.cjs +1241 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +99 -0
- package/dist/cli.d.ts +99 -0
- package/dist/cli.js +1194 -0
- package/dist/cli.js.map +1 -0
- package/dist/headless.cjs +27 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.cts +4 -0
- package/dist/headless.d.ts +4 -0
- package/dist/headless.js +27 -0
- package/dist/headless.js.map +1 -0
- package/dist/index-BIdnqtW8.d.ts +234 -0
- package/dist/index-Brk_uHs6.d.cts +234 -0
- package/dist/index-CPMlaQsC.d.ts +635 -0
- package/dist/index-DHINe-rA.d.cts +635 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/memoryAdapter-Ck0ccZbF.d.cts +25 -0
- package/dist/memoryAdapter-DxEKaG0b.d.ts +25 -0
- package/dist/placeholders-C4ftwaII.d.ts +5 -0
- package/dist/placeholders-x_3rt65M.d.cts +5 -0
- package/dist/react.cjs +3779 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +476 -0
- package/dist/react.d.ts +476 -0
- package/dist/react.js +3779 -0
- package/dist/react.js.map +1 -0
- package/dist/server-handler.cjs +14 -0
- package/dist/server-handler.cjs.map +1 -0
- package/dist/server-handler.d.cts +3 -0
- package/dist/server-handler.d.ts +3 -0
- package/dist/server-handler.js +14 -0
- package/dist/server-handler.js.map +1 -0
- package/dist/server.cjs +1801 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +142 -0
- package/dist/server.d.ts +142 -0
- package/dist/server.js +1801 -0
- package/dist/server.js.map +1 -0
- package/dist/storage.cjs +447 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +163 -0
- package/dist/storage.d.ts +163 -0
- package/dist/storage.js +447 -0
- package/dist/storage.js.map +1 -0
- package/dist/styles/animated-image.css +112 -0
- package/dist/styles/dropzone-and-tiles.css +247 -0
- package/dist/styles/modals-and-dock.css +248 -0
- package/dist/styles/primitives.css +197 -0
- package/dist/styles/quality-and-inputs.css +184 -0
- package/dist/styles/tokens.css +123 -0
- package/dist/styles.css +1122 -0
- package/dist/types-BrP-o9nd.d.cts +85 -0
- package/dist/types-sZ3KoFQY.d.ts +85 -0
- package/dist/types-yShGNQnW.d.cts +61 -0
- package/dist/types-yShGNQnW.d.ts +61 -0
- package/dist/upload-C5Trd6Dh.d.cts +154 -0
- package/dist/upload-C5Trd6Dh.d.ts +154 -0
- package/package.json +198 -4
package/dist/react.js
ADDED
|
@@ -0,0 +1,3779 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_PLACEHOLDERS,
|
|
4
|
+
blurService
|
|
5
|
+
} from "./chunk-IB3TEDLR.js";
|
|
6
|
+
import {
|
|
7
|
+
decodeBlurHashToDataURL
|
|
8
|
+
} from "./chunk-QQHZJKNA.js";
|
|
9
|
+
import {
|
|
10
|
+
ARABIC_UPLOAD_TRANSLATIONS,
|
|
11
|
+
DEFAULT_UPLOAD_TRANSLATIONS,
|
|
12
|
+
HIDDEN_INPUT_STYLE,
|
|
13
|
+
HeadlessMultiUpload,
|
|
14
|
+
HeadlessSingleUpload,
|
|
15
|
+
ImageUploadProvider,
|
|
16
|
+
appendCacheBuster,
|
|
17
|
+
arTranslations,
|
|
18
|
+
buildUploadFormData,
|
|
19
|
+
createUploadAbortError,
|
|
20
|
+
cx,
|
|
21
|
+
enTranslations,
|
|
22
|
+
extractClipboardImageFiles,
|
|
23
|
+
formatNeedsAltMessage,
|
|
24
|
+
formatSkippedImagesMessage,
|
|
25
|
+
formatUploadingCount,
|
|
26
|
+
isUploadAbortError,
|
|
27
|
+
normalizeUploadLocale,
|
|
28
|
+
parseErrorPayload,
|
|
29
|
+
resolveSlotClass,
|
|
30
|
+
resolveSlotStyle,
|
|
31
|
+
resolveTranslations,
|
|
32
|
+
resolveUploadDataState,
|
|
33
|
+
selectPluralCategory,
|
|
34
|
+
toFileListLike,
|
|
35
|
+
uploadText,
|
|
36
|
+
uploadViaXhr,
|
|
37
|
+
useClipboardPaste,
|
|
38
|
+
useDragAndDrop,
|
|
39
|
+
useFilePreview,
|
|
40
|
+
useImageUpload,
|
|
41
|
+
useImageUploadContext,
|
|
42
|
+
useMultiImageState,
|
|
43
|
+
useMultiUpload,
|
|
44
|
+
useSingleImageState,
|
|
45
|
+
useSingleUpload
|
|
46
|
+
} from "./chunk-AI3JJLSA.js";
|
|
47
|
+
import {
|
|
48
|
+
QUALITY_PRESETS,
|
|
49
|
+
estimateOutputSize,
|
|
50
|
+
formatFileSize
|
|
51
|
+
} from "./chunk-G7LLSKBV.js";
|
|
52
|
+
import {
|
|
53
|
+
STANDARD_PRESETS,
|
|
54
|
+
normalizeColorInput,
|
|
55
|
+
rgbToHex
|
|
56
|
+
} from "./chunk-TT5C7K3Q.js";
|
|
57
|
+
|
|
58
|
+
// src/react/hooks/index.ts
|
|
59
|
+
import { useEffect as useEffect2 } from "react";
|
|
60
|
+
|
|
61
|
+
// src/react/hooks/useBlurService.ts
|
|
62
|
+
import { useMemo } from "react";
|
|
63
|
+
function useBlurDataURL(imageSrc, options = {}) {
|
|
64
|
+
const { type = "default", size = "small" } = options;
|
|
65
|
+
return useMemo(() => {
|
|
66
|
+
if (!imageSrc) return DEFAULT_PLACEHOLDERS[type];
|
|
67
|
+
return blurService.getBlurDataURL(imageSrc, { type, size });
|
|
68
|
+
}, [imageSrc, type, size]);
|
|
69
|
+
}
|
|
70
|
+
function useBulkBlurData(imageSrcs, options = {}) {
|
|
71
|
+
const { type = "default", size = "small" } = options;
|
|
72
|
+
return useMemo(() => {
|
|
73
|
+
return blurService.getBulkBlurData(imageSrcs, { type, size });
|
|
74
|
+
}, [imageSrcs, type, size]);
|
|
75
|
+
}
|
|
76
|
+
function useProgressiveBlur(imageSrc, size = "small") {
|
|
77
|
+
return useMemo(() => {
|
|
78
|
+
if (!imageSrc) {
|
|
79
|
+
return {
|
|
80
|
+
color: "#E5E7EB",
|
|
81
|
+
blur: DEFAULT_PLACEHOLDERS.default,
|
|
82
|
+
hasBlur: false
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return blurService.getProgressiveData(imageSrc, size);
|
|
86
|
+
}, [imageSrc, size]);
|
|
87
|
+
}
|
|
88
|
+
function useHasBlurHash(imageSrc) {
|
|
89
|
+
return useMemo(() => {
|
|
90
|
+
if (!imageSrc) return false;
|
|
91
|
+
return blurService.hasBlurHash(imageSrc);
|
|
92
|
+
}, [imageSrc]);
|
|
93
|
+
}
|
|
94
|
+
function useDominantColor(imageSrc) {
|
|
95
|
+
return useMemo(() => {
|
|
96
|
+
if (!imageSrc) return "#E5E7EB";
|
|
97
|
+
return blurService.getDominantColor(imageSrc);
|
|
98
|
+
}, [imageSrc]);
|
|
99
|
+
}
|
|
100
|
+
function useBlurMetadata() {
|
|
101
|
+
return useMemo(() => {
|
|
102
|
+
return blurService.getMetadata();
|
|
103
|
+
}, []);
|
|
104
|
+
}
|
|
105
|
+
function useBlurHash(imageSrc) {
|
|
106
|
+
return useMemo(() => {
|
|
107
|
+
if (!imageSrc) return null;
|
|
108
|
+
return blurService.getBlurHash(imageSrc);
|
|
109
|
+
}, [imageSrc]);
|
|
110
|
+
}
|
|
111
|
+
function useBlurDataWithColor(imageSrc, size = "small") {
|
|
112
|
+
return useMemo(() => {
|
|
113
|
+
if (!imageSrc) {
|
|
114
|
+
return {
|
|
115
|
+
blurDataUrl: DEFAULT_PLACEHOLDERS.default,
|
|
116
|
+
blurColor: "#E5E7EB",
|
|
117
|
+
hasBlur: false
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const progressive = blurService.getProgressiveData(imageSrc, size);
|
|
121
|
+
return {
|
|
122
|
+
blurDataUrl: progressive.blur,
|
|
123
|
+
blurColor: progressive.color,
|
|
124
|
+
hasBlur: progressive.hasBlur
|
|
125
|
+
};
|
|
126
|
+
}, [imageSrc, size]);
|
|
127
|
+
}
|
|
128
|
+
function useBlurVariant(imageSrc, size = "small", type = "default") {
|
|
129
|
+
return useMemo(() => {
|
|
130
|
+
if (!imageSrc) return DEFAULT_PLACEHOLDERS[type];
|
|
131
|
+
return blurService.getBlurDataURL(imageSrc, { type, size });
|
|
132
|
+
}, [imageSrc, size, type]);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/react/hooks/useDialog.ts
|
|
136
|
+
import { useEffect, useId, useRef } from "react";
|
|
137
|
+
var FOCUSABLE_SELECTOR = [
|
|
138
|
+
"button:not(:disabled)",
|
|
139
|
+
"[href]",
|
|
140
|
+
'input:not(:disabled):not([type="hidden"])',
|
|
141
|
+
"select:not(:disabled)",
|
|
142
|
+
"textarea:not(:disabled)",
|
|
143
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
144
|
+
].join(", ");
|
|
145
|
+
function useDialog({
|
|
146
|
+
isOpen,
|
|
147
|
+
onClose,
|
|
148
|
+
initialFocusRef,
|
|
149
|
+
lockScroll = true
|
|
150
|
+
}) {
|
|
151
|
+
const dialogRef = useRef(null);
|
|
152
|
+
const onCloseRef = useRef(onClose);
|
|
153
|
+
onCloseRef.current = onClose;
|
|
154
|
+
const titleId = useId();
|
|
155
|
+
const descriptionId = useId();
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (!isOpen || typeof document === "undefined") return;
|
|
158
|
+
const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
159
|
+
const prevOverflow = document.body.style.overflow;
|
|
160
|
+
if (lockScroll) {
|
|
161
|
+
document.body.style.overflow = "hidden";
|
|
162
|
+
}
|
|
163
|
+
const focusInitial = () => {
|
|
164
|
+
const container = dialogRef.current;
|
|
165
|
+
if (!container) return;
|
|
166
|
+
if (initialFocusRef?.current) {
|
|
167
|
+
initialFocusRef.current.focus();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (document.activeElement && container.contains(document.activeElement)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const focusables = Array.from(
|
|
174
|
+
container.querySelectorAll(FOCUSABLE_SELECTOR)
|
|
175
|
+
);
|
|
176
|
+
if (focusables.length > 0) {
|
|
177
|
+
focusables[0].focus();
|
|
178
|
+
} else {
|
|
179
|
+
container.focus();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
focusInitial();
|
|
183
|
+
const handleKeyDown = (event) => {
|
|
184
|
+
if (event.key === "Escape" && onCloseRef.current) {
|
|
185
|
+
event.stopPropagation();
|
|
186
|
+
onCloseRef.current();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (event.key !== "Tab") return;
|
|
190
|
+
const container = dialogRef.current;
|
|
191
|
+
if (!container) return;
|
|
192
|
+
const focusables = Array.from(
|
|
193
|
+
container.querySelectorAll(FOCUSABLE_SELECTOR)
|
|
194
|
+
);
|
|
195
|
+
if (focusables.length === 0) {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const first = focusables[0];
|
|
200
|
+
const last = focusables[focusables.length - 1];
|
|
201
|
+
const active = document.activeElement;
|
|
202
|
+
if (event.shiftKey) {
|
|
203
|
+
if (!active || active === first || !container.contains(active)) {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
last.focus();
|
|
206
|
+
}
|
|
207
|
+
} else if (!active || active === last || !container.contains(active)) {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
first.focus();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
213
|
+
return () => {
|
|
214
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
215
|
+
if (lockScroll) {
|
|
216
|
+
document.body.style.overflow = prevOverflow;
|
|
217
|
+
}
|
|
218
|
+
if (previouslyFocused && typeof previouslyFocused.focus === "function") {
|
|
219
|
+
try {
|
|
220
|
+
previouslyFocused.focus();
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}, [isOpen, lockScroll, initialFocusRef]);
|
|
226
|
+
return {
|
|
227
|
+
dialogRef,
|
|
228
|
+
titleId,
|
|
229
|
+
descriptionId
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/react/hooks/index.ts
|
|
234
|
+
var useProgressiveImage = useProgressiveBlur;
|
|
235
|
+
function useBlurPreload(imageSrcs, size = "small") {
|
|
236
|
+
useEffect2(() => {
|
|
237
|
+
if (imageSrcs.length > 0) {
|
|
238
|
+
blurService.preloadBlurData(imageSrcs, size);
|
|
239
|
+
}
|
|
240
|
+
}, [imageSrcs, size]);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/react/icons.tsx
|
|
244
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
245
|
+
function createIcon(name, nodes) {
|
|
246
|
+
const Icon = ({
|
|
247
|
+
size = 24,
|
|
248
|
+
strokeWidth = 2,
|
|
249
|
+
color = "currentColor",
|
|
250
|
+
className,
|
|
251
|
+
children,
|
|
252
|
+
...rest
|
|
253
|
+
}) => {
|
|
254
|
+
const labelled = rest["aria-label"] !== void 0 || rest["aria-labelledby"] !== void 0;
|
|
255
|
+
const baseClass = `iuk-icon iuk-icon--${name}`;
|
|
256
|
+
return /* @__PURE__ */ jsxs(
|
|
257
|
+
"svg",
|
|
258
|
+
{
|
|
259
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
260
|
+
width: size,
|
|
261
|
+
height: size,
|
|
262
|
+
viewBox: "0 0 24 24",
|
|
263
|
+
fill: "none",
|
|
264
|
+
stroke: color,
|
|
265
|
+
strokeWidth,
|
|
266
|
+
strokeLinecap: "round",
|
|
267
|
+
strokeLinejoin: "round",
|
|
268
|
+
className: className ? `${baseClass} ${className}` : baseClass,
|
|
269
|
+
"aria-hidden": labelled ? void 0 : true,
|
|
270
|
+
focusable: "false",
|
|
271
|
+
...rest,
|
|
272
|
+
children: [
|
|
273
|
+
nodes.map(([Tag, attrs], index) => /* @__PURE__ */ jsx(Tag, { ...attrs }, index)),
|
|
274
|
+
children
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
Icon.displayName = `Icon(${name})`;
|
|
280
|
+
return Icon;
|
|
281
|
+
}
|
|
282
|
+
var p = (d) => ["path", { d }];
|
|
283
|
+
var c = (cx2, cy, r, fill) => {
|
|
284
|
+
const attrs = { cx: cx2, cy, r };
|
|
285
|
+
if (fill) attrs.fill = fill;
|
|
286
|
+
return ["circle", attrs];
|
|
287
|
+
};
|
|
288
|
+
var UPLOAD_TRAY = "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4";
|
|
289
|
+
var UploadIcon = createIcon("upload", [
|
|
290
|
+
p("M12 3v12"),
|
|
291
|
+
p("m17 8-5-5-5 5"),
|
|
292
|
+
p(UPLOAD_TRAY)
|
|
293
|
+
]);
|
|
294
|
+
var DownloadIcon = createIcon("download", [
|
|
295
|
+
p("M12 15V3"),
|
|
296
|
+
p(UPLOAD_TRAY),
|
|
297
|
+
p("m7 10 5 5 5-5")
|
|
298
|
+
]);
|
|
299
|
+
var ImagePlusIcon = createIcon("image-plus", [
|
|
300
|
+
p("M16 5h6"),
|
|
301
|
+
p("M19 2v6"),
|
|
302
|
+
p("M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"),
|
|
303
|
+
p("m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),
|
|
304
|
+
c("9", "9", "2")
|
|
305
|
+
]);
|
|
306
|
+
var XIcon = createIcon("x", [p("M18 6 6 18"), p("m6 6 12 12")]);
|
|
307
|
+
var CheckIcon = createIcon("check", [p("M20 6 9 17l-5-5")]);
|
|
308
|
+
var MinusIcon = createIcon("minus", [p("M5 12h14")]);
|
|
309
|
+
var LoaderIcon = createIcon("loader", [
|
|
310
|
+
p("M21 12a9 9 0 1 1-6.219-8.56")
|
|
311
|
+
]);
|
|
312
|
+
var ChevronUpIcon = createIcon("chevron-up", [p("m18 15-6-6-6 6")]);
|
|
313
|
+
var ChevronDownIcon = createIcon("chevron-down", [p("m6 9 6 6 6-6")]);
|
|
314
|
+
var AlertTriangleIcon = createIcon("alert-triangle", [
|
|
315
|
+
p("m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"),
|
|
316
|
+
p("M12 9v4"),
|
|
317
|
+
p("M12 17h.01")
|
|
318
|
+
]);
|
|
319
|
+
var SaveIcon = createIcon("save", [
|
|
320
|
+
p(
|
|
321
|
+
"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"
|
|
322
|
+
),
|
|
323
|
+
p("M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"),
|
|
324
|
+
p("M7 3v4a1 1 0 0 0 1 1h7")
|
|
325
|
+
]);
|
|
326
|
+
var EyeIcon = createIcon("eye", [
|
|
327
|
+
p(
|
|
328
|
+
"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"
|
|
329
|
+
),
|
|
330
|
+
c("12", "12", "3")
|
|
331
|
+
]);
|
|
332
|
+
var InfoIcon = createIcon("info", [
|
|
333
|
+
c("12", "12", "10"),
|
|
334
|
+
p("M12 16v-4"),
|
|
335
|
+
p("M12 8h.01")
|
|
336
|
+
]);
|
|
337
|
+
var ZapIcon = createIcon("zap", [
|
|
338
|
+
p(
|
|
339
|
+
"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"
|
|
340
|
+
)
|
|
341
|
+
]);
|
|
342
|
+
var CheckCircleIcon = createIcon("check-circle", [
|
|
343
|
+
c("12", "12", "10"),
|
|
344
|
+
p("m9 12 2 2 4-4")
|
|
345
|
+
]);
|
|
346
|
+
var XCircleIcon = createIcon("x-circle", [
|
|
347
|
+
c("12", "12", "10"),
|
|
348
|
+
p("m15 9-6 6"),
|
|
349
|
+
p("m9 9 6 6")
|
|
350
|
+
]);
|
|
351
|
+
var TypeIcon = createIcon("type", [
|
|
352
|
+
p("M12 4v16"),
|
|
353
|
+
p("M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"),
|
|
354
|
+
p("M9 20h6")
|
|
355
|
+
]);
|
|
356
|
+
var FolderOpenIcon = createIcon("folder-open", [
|
|
357
|
+
p(
|
|
358
|
+
"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"
|
|
359
|
+
)
|
|
360
|
+
]);
|
|
361
|
+
var PenToolIcon = createIcon("pen-tool", [
|
|
362
|
+
p(
|
|
363
|
+
"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"
|
|
364
|
+
),
|
|
365
|
+
p(
|
|
366
|
+
"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18"
|
|
367
|
+
),
|
|
368
|
+
p("m2.3 2.3 7.286 7.286"),
|
|
369
|
+
c("11", "11", "2")
|
|
370
|
+
]);
|
|
371
|
+
var WandIcon = createIcon("wand", [
|
|
372
|
+
p(
|
|
373
|
+
"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72"
|
|
374
|
+
),
|
|
375
|
+
p("m14 7 3 3"),
|
|
376
|
+
p("M5 6v4"),
|
|
377
|
+
p("M19 14v4"),
|
|
378
|
+
p("M10 2v2"),
|
|
379
|
+
p("M7 8H3"),
|
|
380
|
+
p("M21 16h-4"),
|
|
381
|
+
p("M11 3H9")
|
|
382
|
+
]);
|
|
383
|
+
var TrashIcon = createIcon("trash", [
|
|
384
|
+
p("M10 11v6"),
|
|
385
|
+
p("M14 11v6"),
|
|
386
|
+
p("M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"),
|
|
387
|
+
p("M3 6h18"),
|
|
388
|
+
p("M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2")
|
|
389
|
+
]);
|
|
390
|
+
var PaletteIcon = createIcon("palette", [
|
|
391
|
+
p(
|
|
392
|
+
"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"
|
|
393
|
+
),
|
|
394
|
+
c("13.5", "6.5", ".5", "currentColor"),
|
|
395
|
+
c("17.5", "10.5", ".5", "currentColor"),
|
|
396
|
+
c("6.5", "12.5", ".5", "currentColor"),
|
|
397
|
+
c("8.5", "7.5", ".5", "currentColor")
|
|
398
|
+
]);
|
|
399
|
+
|
|
400
|
+
// src/react/components/AltTextInput.tsx
|
|
401
|
+
import { useId as useId2 } from "react";
|
|
402
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
403
|
+
function AltTextInput({
|
|
404
|
+
value,
|
|
405
|
+
onChange,
|
|
406
|
+
disabled = false,
|
|
407
|
+
placeholder,
|
|
408
|
+
maxLength = 200,
|
|
409
|
+
label,
|
|
410
|
+
showHint = true,
|
|
411
|
+
locale: propLocale,
|
|
412
|
+
translations,
|
|
413
|
+
unstyled: propUnstyled
|
|
414
|
+
}) {
|
|
415
|
+
const ctx = useImageUploadContext();
|
|
416
|
+
const isUnstyled = propUnstyled ?? ctx.unstyled;
|
|
417
|
+
const locale = normalizeUploadLocale(propLocale || ctx.locale);
|
|
418
|
+
const ui = resolveTranslations(locale, translations || ctx.translations);
|
|
419
|
+
const resolvedPlaceholder = placeholder || ui.describeImagePlaceholder;
|
|
420
|
+
const resolvedLabel = label || ui.addImageDescription;
|
|
421
|
+
const inputId = useId2();
|
|
422
|
+
const hintId = showHint ? `${inputId}-hint` : void 0;
|
|
423
|
+
const cls = (defaultClass) => resolveSlotClass(defaultClass, isUnstyled);
|
|
424
|
+
return /* @__PURE__ */ jsxs2(
|
|
425
|
+
"div",
|
|
426
|
+
{
|
|
427
|
+
"data-slot": "alt-input",
|
|
428
|
+
"data-unstyled": isUnstyled || void 0,
|
|
429
|
+
className: cls("iuk-alt-input"),
|
|
430
|
+
dir: locale === "ar" ? "rtl" : "ltr",
|
|
431
|
+
children: [
|
|
432
|
+
/* @__PURE__ */ jsxs2("div", { className: cls("iuk-alt-input__header"), children: [
|
|
433
|
+
/* @__PURE__ */ jsx2(TypeIcon, { size: 16 }),
|
|
434
|
+
/* @__PURE__ */ jsx2("label", { htmlFor: inputId, className: cls("iuk-alt-input__label"), children: resolvedLabel })
|
|
435
|
+
] }),
|
|
436
|
+
/* @__PURE__ */ jsx2(
|
|
437
|
+
"input",
|
|
438
|
+
{
|
|
439
|
+
id: inputId,
|
|
440
|
+
type: "text",
|
|
441
|
+
value,
|
|
442
|
+
onChange: (e) => onChange(e.target.value),
|
|
443
|
+
placeholder: resolvedPlaceholder,
|
|
444
|
+
className: cls("iuk-alt-input__field"),
|
|
445
|
+
disabled,
|
|
446
|
+
maxLength,
|
|
447
|
+
"aria-describedby": hintId
|
|
448
|
+
}
|
|
449
|
+
),
|
|
450
|
+
showHint && /* @__PURE__ */ jsxs2("p", { className: cls("iuk-alt-input__hint"), id: hintId, children: [
|
|
451
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
452
|
+
value.length,
|
|
453
|
+
"/",
|
|
454
|
+
maxLength,
|
|
455
|
+
" ",
|
|
456
|
+
ui.characters
|
|
457
|
+
] }),
|
|
458
|
+
/* @__PURE__ */ jsx2("span", { children: ui.usedForA11ySeo })
|
|
459
|
+
] })
|
|
460
|
+
]
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// src/react/components/AltTextModal.tsx
|
|
466
|
+
import { useRef as useRef3, useState as useState2 } from "react";
|
|
467
|
+
import { createPortal } from "react-dom";
|
|
468
|
+
|
|
469
|
+
// src/react/components/BlurImage.tsx
|
|
470
|
+
import {
|
|
471
|
+
useEffect as useEffect3,
|
|
472
|
+
useMemo as useMemo2,
|
|
473
|
+
useRef as useRef2,
|
|
474
|
+
useState
|
|
475
|
+
} from "react";
|
|
476
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
477
|
+
function BlurImage({
|
|
478
|
+
src,
|
|
479
|
+
alt,
|
|
480
|
+
blurDataUrl,
|
|
481
|
+
blurColor,
|
|
482
|
+
blurHash,
|
|
483
|
+
objectFit = "cover",
|
|
484
|
+
className = "",
|
|
485
|
+
imageClassName = "",
|
|
486
|
+
style,
|
|
487
|
+
renderImage: propRenderImage,
|
|
488
|
+
onImageLoad
|
|
489
|
+
}) {
|
|
490
|
+
const ctx = useImageUploadContext();
|
|
491
|
+
const renderImage = propRenderImage || ctx.renderImage;
|
|
492
|
+
const [loadedSrc, setLoadedSrc] = useState(null);
|
|
493
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
494
|
+
const imgRef = useRef2(null);
|
|
495
|
+
const onImageLoadRef = useRef2(onImageLoad);
|
|
496
|
+
onImageLoadRef.current = onImageLoad;
|
|
497
|
+
const decodedHashUrl = useMemo2(() => {
|
|
498
|
+
if (blurDataUrl || !blurHash) return null;
|
|
499
|
+
return decodeBlurHashToDataURL(blurHash, 32, 32);
|
|
500
|
+
}, [blurDataUrl, blurHash]);
|
|
501
|
+
const effectiveBlurUrl = blurDataUrl || decodedHashUrl || void 0;
|
|
502
|
+
const isLoaded = loadedSrc === src;
|
|
503
|
+
const hasFailed = failedSrc === src;
|
|
504
|
+
useEffect3(() => {
|
|
505
|
+
const el = imgRef.current;
|
|
506
|
+
if (el && el.complete && el.naturalWidth > 0) {
|
|
507
|
+
setLoadedSrc(src);
|
|
508
|
+
onImageLoadRef.current?.(el);
|
|
509
|
+
}
|
|
510
|
+
}, [src]);
|
|
511
|
+
const imgStyle = {
|
|
512
|
+
width: "100%",
|
|
513
|
+
height: "100%",
|
|
514
|
+
objectFit,
|
|
515
|
+
opacity: isLoaded || hasFailed || !effectiveBlurUrl ? 1 : 0,
|
|
516
|
+
transition: "opacity 0.28s ease-out"
|
|
517
|
+
};
|
|
518
|
+
const escapedBlurUrl = effectiveBlurUrl ? effectiveBlurUrl.replace(/"/g, '\\"') : void 0;
|
|
519
|
+
return /* @__PURE__ */ jsxs3(
|
|
520
|
+
"div",
|
|
521
|
+
{
|
|
522
|
+
className: `iuk-blur-image-wrap ${className}`.trim(),
|
|
523
|
+
style: {
|
|
524
|
+
backgroundColor: blurColor || "var(--iuk-placeholder-bg, #f3f4f6)",
|
|
525
|
+
...style
|
|
526
|
+
},
|
|
527
|
+
children: [
|
|
528
|
+
escapedBlurUrl && /* @__PURE__ */ jsx3(
|
|
529
|
+
"div",
|
|
530
|
+
{
|
|
531
|
+
"aria-hidden": "true",
|
|
532
|
+
className: `iuk-blur-image-backdrop ${isLoaded ? "iuk-blur-image-backdrop--hidden" : ""}`,
|
|
533
|
+
style: {
|
|
534
|
+
backgroundImage: `url("${escapedBlurUrl}")`,
|
|
535
|
+
backgroundSize: objectFit === "contain" ? "contain" : "cover"
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
),
|
|
539
|
+
renderImage ? renderImage({
|
|
540
|
+
src,
|
|
541
|
+
alt,
|
|
542
|
+
className: `iuk-blur-image-el ${imageClassName}`.trim(),
|
|
543
|
+
style: imgStyle,
|
|
544
|
+
onLoad: (el) => {
|
|
545
|
+
setLoadedSrc(src);
|
|
546
|
+
onImageLoadRef.current?.(el);
|
|
547
|
+
}
|
|
548
|
+
}) : /* @__PURE__ */ jsx3(
|
|
549
|
+
"img",
|
|
550
|
+
{
|
|
551
|
+
ref: imgRef,
|
|
552
|
+
src,
|
|
553
|
+
alt,
|
|
554
|
+
loading: "lazy",
|
|
555
|
+
decoding: "async",
|
|
556
|
+
className: `iuk-blur-image-el ${imageClassName}`.trim(),
|
|
557
|
+
style: imgStyle,
|
|
558
|
+
onLoad: (e) => {
|
|
559
|
+
setLoadedSrc(src);
|
|
560
|
+
onImageLoadRef.current?.(e.currentTarget);
|
|
561
|
+
},
|
|
562
|
+
onError: () => {
|
|
563
|
+
setFailedSrc(src);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
)
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/react/components/AltTextModal.tsx
|
|
573
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
574
|
+
function AltTextModal({
|
|
575
|
+
imageUrl,
|
|
576
|
+
initialAltText = "",
|
|
577
|
+
onSave,
|
|
578
|
+
onClose,
|
|
579
|
+
locale: propLocale,
|
|
580
|
+
translations,
|
|
581
|
+
renderImage,
|
|
582
|
+
unstyled: propUnstyled
|
|
583
|
+
}) {
|
|
584
|
+
const ctx = useImageUploadContext();
|
|
585
|
+
const isUnstyled = propUnstyled ?? ctx.unstyled;
|
|
586
|
+
const locale = normalizeUploadLocale(propLocale || ctx.locale);
|
|
587
|
+
const ui = resolveTranslations(locale, translations || ctx.translations);
|
|
588
|
+
const [localAltText, setLocalAltText] = useState2(initialAltText);
|
|
589
|
+
const inputRef = useRef3(null);
|
|
590
|
+
const { dialogRef, titleId, descriptionId } = useDialog({
|
|
591
|
+
isOpen: true,
|
|
592
|
+
onClose,
|
|
593
|
+
initialFocusRef: inputRef
|
|
594
|
+
});
|
|
595
|
+
const cls = (defaultClass) => resolveSlotClass(defaultClass, isUnstyled);
|
|
596
|
+
const handleSave = () => {
|
|
597
|
+
onSave(localAltText);
|
|
598
|
+
onClose();
|
|
599
|
+
};
|
|
600
|
+
const content = /* @__PURE__ */ jsx4(
|
|
601
|
+
"div",
|
|
602
|
+
{
|
|
603
|
+
"data-slot": "alt-modal-backdrop",
|
|
604
|
+
"data-unstyled": isUnstyled || void 0,
|
|
605
|
+
className: cls("iuk-modal-backdrop"),
|
|
606
|
+
dir: locale === "ar" ? "rtl" : "ltr",
|
|
607
|
+
onClick: onClose,
|
|
608
|
+
role: "dialog",
|
|
609
|
+
"aria-modal": "true",
|
|
610
|
+
"aria-labelledby": titleId,
|
|
611
|
+
"aria-describedby": descriptionId,
|
|
612
|
+
children: /* @__PURE__ */ jsxs4(
|
|
613
|
+
"div",
|
|
614
|
+
{
|
|
615
|
+
ref: dialogRef,
|
|
616
|
+
"data-slot": "alt-modal",
|
|
617
|
+
className: cls("iuk-alt-modal"),
|
|
618
|
+
onClick: (e) => e.stopPropagation(),
|
|
619
|
+
children: [
|
|
620
|
+
/* @__PURE__ */ jsxs4("div", { className: cls("iuk-alt-modal__header"), children: [
|
|
621
|
+
/* @__PURE__ */ jsxs4("div", { className: cls("iuk-alt-modal__title"), children: [
|
|
622
|
+
/* @__PURE__ */ jsx4(TypeIcon, { size: 18 }),
|
|
623
|
+
/* @__PURE__ */ jsx4("span", { id: titleId, children: ui.addImageDescription })
|
|
624
|
+
] }),
|
|
625
|
+
/* @__PURE__ */ jsx4(
|
|
626
|
+
"button",
|
|
627
|
+
{
|
|
628
|
+
type: "button",
|
|
629
|
+
className: cls("iuk-icon-btn"),
|
|
630
|
+
onClick: onClose,
|
|
631
|
+
title: ui.close,
|
|
632
|
+
"aria-label": ui.close,
|
|
633
|
+
children: /* @__PURE__ */ jsx4(XIcon, { size: 18 })
|
|
634
|
+
}
|
|
635
|
+
)
|
|
636
|
+
] }),
|
|
637
|
+
/* @__PURE__ */ jsx4("div", { className: cls("iuk-alt-modal__preview"), children: /* @__PURE__ */ jsx4(
|
|
638
|
+
BlurImage,
|
|
639
|
+
{
|
|
640
|
+
src: imageUrl,
|
|
641
|
+
alt: ui.previewAlt,
|
|
642
|
+
objectFit: "contain",
|
|
643
|
+
renderImage
|
|
644
|
+
}
|
|
645
|
+
) }),
|
|
646
|
+
/* @__PURE__ */ jsx4(
|
|
647
|
+
"input",
|
|
648
|
+
{
|
|
649
|
+
ref: inputRef,
|
|
650
|
+
type: "text",
|
|
651
|
+
className: cls("iuk-alt-input__field"),
|
|
652
|
+
value: localAltText,
|
|
653
|
+
onChange: (e) => setLocalAltText(e.target.value),
|
|
654
|
+
onKeyDown: (e) => {
|
|
655
|
+
if (e.key === "Enter") {
|
|
656
|
+
e.preventDefault();
|
|
657
|
+
handleSave();
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
placeholder: ui.describeImagePlaceholder,
|
|
661
|
+
maxLength: 200,
|
|
662
|
+
"aria-labelledby": titleId,
|
|
663
|
+
"aria-describedby": descriptionId
|
|
664
|
+
}
|
|
665
|
+
),
|
|
666
|
+
/* @__PURE__ */ jsxs4("div", { id: descriptionId, className: cls("iuk-alt-input__hint"), children: [
|
|
667
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
668
|
+
localAltText.length,
|
|
669
|
+
"/200 ",
|
|
670
|
+
ui.characters
|
|
671
|
+
] }),
|
|
672
|
+
/* @__PURE__ */ jsx4("span", { children: ui.usedForA11ySeo })
|
|
673
|
+
] }),
|
|
674
|
+
/* @__PURE__ */ jsxs4("div", { className: cls("iuk-alt-modal__actions"), children: [
|
|
675
|
+
/* @__PURE__ */ jsx4(
|
|
676
|
+
"button",
|
|
677
|
+
{
|
|
678
|
+
type: "button",
|
|
679
|
+
className: cls("iuk-btn iuk-btn--secondary"),
|
|
680
|
+
onClick: onClose,
|
|
681
|
+
children: ui.cancel
|
|
682
|
+
}
|
|
683
|
+
),
|
|
684
|
+
/* @__PURE__ */ jsxs4(
|
|
685
|
+
"button",
|
|
686
|
+
{
|
|
687
|
+
type: "button",
|
|
688
|
+
className: cls("iuk-btn iuk-btn--primary"),
|
|
689
|
+
onClick: handleSave,
|
|
690
|
+
children: [
|
|
691
|
+
/* @__PURE__ */ jsx4(CheckCircleIcon, { size: 16 }),
|
|
692
|
+
/* @__PURE__ */ jsx4("span", { children: ui.saveDescription })
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
)
|
|
696
|
+
] })
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
)
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
if (typeof document !== "undefined") {
|
|
703
|
+
return createPortal(content, document.body);
|
|
704
|
+
}
|
|
705
|
+
return content;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// src/react/components/AnimatedImage/AnimatedImage.tsx
|
|
709
|
+
import { useMemo as useMemo3 } from "react";
|
|
710
|
+
|
|
711
|
+
// src/react/components/AnimatedImage/placeholder.ts
|
|
712
|
+
var DEFAULT_NEUTRAL_COLORS = [
|
|
713
|
+
"#1a1a1a",
|
|
714
|
+
"#121212",
|
|
715
|
+
"#000000",
|
|
716
|
+
"#000",
|
|
717
|
+
"#e5e7eb",
|
|
718
|
+
"#ffffff",
|
|
719
|
+
"#fff"
|
|
720
|
+
];
|
|
721
|
+
var HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
722
|
+
var FUNC_COLOR = /^(?:rgb|rgba|hsl|hsla|oklch|oklab)\([\d\s.,%/+-]+\)$/i;
|
|
723
|
+
var CSS_VAR_COLOR = /^var\(--[a-zA-Z0-9_-]+(?:\s*,\s*[^;{}<>()]+)?\)$/;
|
|
724
|
+
function isNeutralColor(value, neutralColors) {
|
|
725
|
+
if (neutralColors.length === 0) return false;
|
|
726
|
+
const lower = value.toLowerCase();
|
|
727
|
+
for (const item of neutralColors) {
|
|
728
|
+
if (item.toLowerCase() === lower) return true;
|
|
729
|
+
}
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
function resolveMeaningfulColor(color, neutralColors = DEFAULT_NEUTRAL_COLORS) {
|
|
733
|
+
const value = color?.trim();
|
|
734
|
+
if (!value) return void 0;
|
|
735
|
+
if (isNeutralColor(value, neutralColors)) return void 0;
|
|
736
|
+
if (!HEX_COLOR.test(value) && !FUNC_COLOR.test(value)) return void 0;
|
|
737
|
+
return value;
|
|
738
|
+
}
|
|
739
|
+
function resolveBackgroundColor(color, neutralColors = DEFAULT_NEUTRAL_COLORS) {
|
|
740
|
+
const value = color?.trim();
|
|
741
|
+
if (!value) return void 0;
|
|
742
|
+
if (isNeutralColor(value, neutralColors)) return void 0;
|
|
743
|
+
if (HEX_COLOR.test(value) || FUNC_COLOR.test(value) || CSS_VAR_COLOR.test(value)) {
|
|
744
|
+
return value;
|
|
745
|
+
}
|
|
746
|
+
return void 0;
|
|
747
|
+
}
|
|
748
|
+
function createFallbackBlurSvg(color, neutralColors = DEFAULT_NEUTRAL_COLORS) {
|
|
749
|
+
const meaningful = resolveMeaningfulColor(color, neutralColors);
|
|
750
|
+
const stop1 = meaningful ?? "#2c3340";
|
|
751
|
+
const stop2 = meaningful ? "#0f172a" : "#1e242d";
|
|
752
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="100%" height="100%"><defs><linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="${stop1}" stop-opacity="1"/><stop offset="55%" stop-color="${stop1}" stop-opacity="0.78"/><stop offset="100%" stop-color="${stop2}" stop-opacity="0.96"/></linearGradient><radialGradient id="h" cx="24%" cy="22%" r="65%"><stop offset="0%" stop-color="#ffffff" stop-opacity="0.22"/><stop offset="100%" stop-color="#ffffff" stop-opacity="0"/></radialGradient></defs><rect width="100%" height="100%" fill="url(#g)"/><rect width="100%" height="100%" fill="url(#h)"/></svg>`;
|
|
753
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
754
|
+
}
|
|
755
|
+
function resolveIntrinsicPlaceholderUrl({
|
|
756
|
+
blurDataUrl,
|
|
757
|
+
blurHash
|
|
758
|
+
}) {
|
|
759
|
+
const dataUrl = blurDataUrl?.trim();
|
|
760
|
+
if (dataUrl) return dataUrl;
|
|
761
|
+
if (blurHash && typeof document !== "undefined") {
|
|
762
|
+
try {
|
|
763
|
+
const decoded = decodeBlurHashToDataURL(blurHash, 32, 32);
|
|
764
|
+
if (decoded) return decoded;
|
|
765
|
+
} catch {
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return void 0;
|
|
769
|
+
}
|
|
770
|
+
function resolvePlaceholderUrl({
|
|
771
|
+
blurDataUrl,
|
|
772
|
+
blurHash,
|
|
773
|
+
blurColor,
|
|
774
|
+
neutralColors = DEFAULT_NEUTRAL_COLORS
|
|
775
|
+
}) {
|
|
776
|
+
const intrinsic = resolveIntrinsicPlaceholderUrl({ blurDataUrl, blurHash });
|
|
777
|
+
if (intrinsic) return intrinsic;
|
|
778
|
+
return createFallbackBlurSvg(blurColor, neutralColors);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// src/react/components/AnimatedImage/useImageReveal.ts
|
|
782
|
+
import { useCallback, useEffect as useEffect4, useRef as useRef4, useState as useState3 } from "react";
|
|
783
|
+
var PLACEHOLDER_UNMOUNT_BUFFER_MS = 50;
|
|
784
|
+
function useImageReveal({
|
|
785
|
+
srcKey,
|
|
786
|
+
fallbackSrc,
|
|
787
|
+
animationDuration,
|
|
788
|
+
onLoad
|
|
789
|
+
}) {
|
|
790
|
+
const [prevSrc, setPrevSrc] = useState3(srcKey);
|
|
791
|
+
const [usingFallback, setUsingFallback] = useState3(false);
|
|
792
|
+
const [retryKey, setRetryKey] = useState3(0);
|
|
793
|
+
const [isLoaded, setIsLoaded] = useState3(false);
|
|
794
|
+
const [showPlaceholder, setShowPlaceholder] = useState3(true);
|
|
795
|
+
const [hasError, setHasError] = useState3(false);
|
|
796
|
+
const [node, setNode] = useState3(null);
|
|
797
|
+
const timeoutRef = useRef4(null);
|
|
798
|
+
const mountedRef = useRef4(true);
|
|
799
|
+
const activeSrc = usingFallback && fallbackSrc ? fallbackSrc : srcKey;
|
|
800
|
+
const activeSrcRef = useRef4(activeSrc);
|
|
801
|
+
const onLoadRef = useRef4(onLoad);
|
|
802
|
+
useEffect4(() => {
|
|
803
|
+
onLoadRef.current = onLoad;
|
|
804
|
+
}, [onLoad]);
|
|
805
|
+
const clearTimer = useCallback(() => {
|
|
806
|
+
if (timeoutRef.current) {
|
|
807
|
+
clearTimeout(timeoutRef.current);
|
|
808
|
+
timeoutRef.current = null;
|
|
809
|
+
}
|
|
810
|
+
}, []);
|
|
811
|
+
if (prevSrc !== srcKey) {
|
|
812
|
+
setPrevSrc(srcKey);
|
|
813
|
+
setUsingFallback(false);
|
|
814
|
+
setIsLoaded(false);
|
|
815
|
+
setShowPlaceholder(true);
|
|
816
|
+
setHasError(false);
|
|
817
|
+
}
|
|
818
|
+
useEffect4(() => {
|
|
819
|
+
activeSrcRef.current = activeSrc;
|
|
820
|
+
clearTimer();
|
|
821
|
+
}, [activeSrc, clearTimer]);
|
|
822
|
+
useEffect4(() => {
|
|
823
|
+
mountedRef.current = true;
|
|
824
|
+
return () => {
|
|
825
|
+
mountedRef.current = false;
|
|
826
|
+
clearTimer();
|
|
827
|
+
};
|
|
828
|
+
}, [clearTimer]);
|
|
829
|
+
const handleLoad = useCallback(
|
|
830
|
+
(img) => {
|
|
831
|
+
const el = img ?? node;
|
|
832
|
+
const loadedFor = activeSrcRef.current;
|
|
833
|
+
const reveal = () => {
|
|
834
|
+
if (!mountedRef.current || loadedFor !== activeSrcRef.current) return;
|
|
835
|
+
setHasError(false);
|
|
836
|
+
setIsLoaded(true);
|
|
837
|
+
clearTimer();
|
|
838
|
+
const duration = Math.max(0, animationDuration);
|
|
839
|
+
timeoutRef.current = setTimeout(() => {
|
|
840
|
+
if (mountedRef.current) setShowPlaceholder(false);
|
|
841
|
+
timeoutRef.current = null;
|
|
842
|
+
}, duration + PLACEHOLDER_UNMOUNT_BUFFER_MS);
|
|
843
|
+
onLoadRef.current?.(el ?? null);
|
|
844
|
+
};
|
|
845
|
+
if (el && typeof el.decode === "function") {
|
|
846
|
+
el.decode().then(reveal, reveal);
|
|
847
|
+
} else {
|
|
848
|
+
reveal();
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
[animationDuration, clearTimer, node]
|
|
852
|
+
);
|
|
853
|
+
const handleError = useCallback(() => {
|
|
854
|
+
if (!mountedRef.current) return false;
|
|
855
|
+
clearTimer();
|
|
856
|
+
if (fallbackSrc && !usingFallback && fallbackSrc !== srcKey) {
|
|
857
|
+
setUsingFallback(true);
|
|
858
|
+
setIsLoaded(false);
|
|
859
|
+
setShowPlaceholder(true);
|
|
860
|
+
setHasError(false);
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
setHasError(true);
|
|
864
|
+
setIsLoaded(false);
|
|
865
|
+
setShowPlaceholder(true);
|
|
866
|
+
return true;
|
|
867
|
+
}, [clearTimer, fallbackSrc, srcKey, usingFallback]);
|
|
868
|
+
const retry = useCallback(() => {
|
|
869
|
+
clearTimer();
|
|
870
|
+
setUsingFallback(false);
|
|
871
|
+
setHasError(false);
|
|
872
|
+
setIsLoaded(false);
|
|
873
|
+
setShowPlaceholder(true);
|
|
874
|
+
setRetryKey((prev) => prev + 1);
|
|
875
|
+
}, [clearTimer]);
|
|
876
|
+
useEffect4(() => {
|
|
877
|
+
if (!node || !node.complete || node.naturalWidth === 0) return;
|
|
878
|
+
if (typeof requestAnimationFrame !== "function") {
|
|
879
|
+
handleLoad(node);
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
const rafId = requestAnimationFrame(() => handleLoad(node));
|
|
883
|
+
return () => cancelAnimationFrame(rafId);
|
|
884
|
+
}, [node, activeSrc, retryKey, handleLoad]);
|
|
885
|
+
return {
|
|
886
|
+
activeSrc,
|
|
887
|
+
retryKey,
|
|
888
|
+
isLoaded,
|
|
889
|
+
showPlaceholder,
|
|
890
|
+
hasError,
|
|
891
|
+
imgRef: setNode,
|
|
892
|
+
handleLoad,
|
|
893
|
+
handleError,
|
|
894
|
+
retry
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/react/components/AnimatedImage/AnimatedImage.tsx
|
|
899
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
900
|
+
var preventDrag = (event) => event.preventDefault();
|
|
901
|
+
var cn = (...classes) => cx(...classes) || void 0;
|
|
902
|
+
function AnimatedImage({
|
|
903
|
+
image,
|
|
904
|
+
src: srcProp,
|
|
905
|
+
alt: altProp,
|
|
906
|
+
blurDataUrl: blurDataUrlProp,
|
|
907
|
+
blurHash: blurHashProp,
|
|
908
|
+
blurColor: blurColorProp,
|
|
909
|
+
colorPlaceholder = "flat",
|
|
910
|
+
neutralColors = DEFAULT_NEUTRAL_COLORS,
|
|
911
|
+
width: widthProp,
|
|
912
|
+
height: heightProp,
|
|
913
|
+
fill = false,
|
|
914
|
+
priority,
|
|
915
|
+
quality,
|
|
916
|
+
objectFit = "cover",
|
|
917
|
+
objectPosition = "center",
|
|
918
|
+
showShimmer = false,
|
|
919
|
+
animationDuration = 600,
|
|
920
|
+
revealScale = 1.02,
|
|
921
|
+
fallbackSrc,
|
|
922
|
+
renderError,
|
|
923
|
+
as: ImageComponent,
|
|
924
|
+
imageComponentProps,
|
|
925
|
+
unstyled = false,
|
|
926
|
+
wrapperClassName,
|
|
927
|
+
wrapperStyle,
|
|
928
|
+
wrapperProps,
|
|
929
|
+
placeholderClassName,
|
|
930
|
+
className,
|
|
931
|
+
style,
|
|
932
|
+
loading: loadingProp,
|
|
933
|
+
decoding = "async",
|
|
934
|
+
draggable = false,
|
|
935
|
+
onLoad,
|
|
936
|
+
onError,
|
|
937
|
+
...imgProps
|
|
938
|
+
}) {
|
|
939
|
+
const src = srcProp ?? image?.url ?? "";
|
|
940
|
+
const alt = altProp ?? image?.altText ?? "";
|
|
941
|
+
const blurDataUrl = blurDataUrlProp ?? image?.blurDataUrl;
|
|
942
|
+
const blurHash = blurHashProp ?? image?.blurHash;
|
|
943
|
+
const blurColor = blurColorProp ?? image?.blurColor;
|
|
944
|
+
const width = widthProp ?? (!fill ? image?.width : void 0);
|
|
945
|
+
const height = heightProp ?? (!fill ? image?.height : void 0);
|
|
946
|
+
const {
|
|
947
|
+
activeSrc,
|
|
948
|
+
retryKey,
|
|
949
|
+
isLoaded,
|
|
950
|
+
showPlaceholder,
|
|
951
|
+
hasError,
|
|
952
|
+
imgRef,
|
|
953
|
+
handleLoad,
|
|
954
|
+
handleError,
|
|
955
|
+
retry
|
|
956
|
+
} = useImageReveal({
|
|
957
|
+
srcKey: src,
|
|
958
|
+
fallbackSrc,
|
|
959
|
+
animationDuration,
|
|
960
|
+
onLoad
|
|
961
|
+
});
|
|
962
|
+
const state = hasError ? "error" : isLoaded ? "loaded" : "loading";
|
|
963
|
+
const resolvedObjectFit = style?.objectFit ?? objectFit;
|
|
964
|
+
const isContain = resolvedObjectFit === "contain";
|
|
965
|
+
const placeholderUrl = useMemo3(
|
|
966
|
+
() => colorPlaceholder === "gradient" || isContain ? resolvePlaceholderUrl({ blurDataUrl, blurHash, blurColor, neutralColors }) : resolveIntrinsicPlaceholderUrl({ blurDataUrl, blurHash }),
|
|
967
|
+
[blurDataUrl, blurHash, blurColor, colorPlaceholder, isContain, neutralColors]
|
|
968
|
+
);
|
|
969
|
+
const cls = (name) => unstyled ? void 0 : name;
|
|
970
|
+
const duration = Math.max(0, animationDuration);
|
|
971
|
+
const placeholderFadeDuration = Math.round(duration * (5 / 6));
|
|
972
|
+
const containerStyle = {
|
|
973
|
+
backgroundColor: resolveBackgroundColor(blurColor, neutralColors) ?? (unstyled ? void 0 : "var(--iuk-animated-image-bg, var(--background-card, rgba(38, 45, 56, 0.4)))"),
|
|
974
|
+
...unstyled ? void 0 : {
|
|
975
|
+
["--iuk-animated-image-duration"]: `${duration}ms`,
|
|
976
|
+
["--iuk-ai-ph-dur"]: `${placeholderFadeDuration}ms`,
|
|
977
|
+
["--iuk-animated-image-reveal-scale"]: String(revealScale)
|
|
978
|
+
},
|
|
979
|
+
...wrapperStyle
|
|
980
|
+
};
|
|
981
|
+
const placeholderStyle = {
|
|
982
|
+
objectFit: "cover",
|
|
983
|
+
transitionDuration: `${placeholderFadeDuration}ms`
|
|
984
|
+
};
|
|
985
|
+
const imageStyle = {
|
|
986
|
+
objectFit: resolvedObjectFit,
|
|
987
|
+
objectPosition,
|
|
988
|
+
transitionDuration: `${duration}ms`,
|
|
989
|
+
...style,
|
|
990
|
+
...hasError ? { opacity: 0, visibility: "hidden" } : void 0
|
|
991
|
+
};
|
|
992
|
+
const isCustom = Boolean(ImageComponent);
|
|
993
|
+
const loadingAttr = priority ? isCustom ? void 0 : "eager" : loadingProp ?? (isCustom ? void 0 : "lazy");
|
|
994
|
+
const priorityProps = isCustom ? {
|
|
995
|
+
...priority !== void 0 ? { priority } : {},
|
|
996
|
+
...quality !== void 0 ? { quality } : {}
|
|
997
|
+
} : priority ? { fetchPriority: "high" } : {};
|
|
998
|
+
const derivedImageSrcSet = !isCustom && activeSrc === src ? image?.srcSet ?? (image?.variants?.length ? [
|
|
999
|
+
...[...image.variants].sort((a, b) => a.width - b.width).map((v) => `${v.url} ${v.width}w`),
|
|
1000
|
+
...image.width ? [`${src} ${image.width}w`] : []
|
|
1001
|
+
].join(", ") : void 0) : void 0;
|
|
1002
|
+
const resolvedSrcSet = imgProps.srcSet ?? derivedImageSrcSet;
|
|
1003
|
+
const resolvedSizes = !isCustom && resolvedSrcSet && fill && imgProps.sizes === void 0 ? "100vw" : imgProps.sizes;
|
|
1004
|
+
const sharedImgProps = {
|
|
1005
|
+
...priorityProps,
|
|
1006
|
+
...imgProps,
|
|
1007
|
+
...resolvedSrcSet !== void 0 ? { srcSet: resolvedSrcSet } : {},
|
|
1008
|
+
...resolvedSizes !== void 0 ? { sizes: resolvedSizes } : {},
|
|
1009
|
+
...width !== void 0 ? { width } : {},
|
|
1010
|
+
...height !== void 0 ? { height } : {},
|
|
1011
|
+
...loadingAttr !== void 0 ? { loading: loadingAttr } : {},
|
|
1012
|
+
src: activeSrc,
|
|
1013
|
+
alt,
|
|
1014
|
+
decoding,
|
|
1015
|
+
draggable,
|
|
1016
|
+
ref: imgRef,
|
|
1017
|
+
className: cn(cls("iuk-animated-image__img"), className),
|
|
1018
|
+
style: imageStyle,
|
|
1019
|
+
"data-state": state,
|
|
1020
|
+
onDragStart: imgProps.onDragStart ?? preventDrag,
|
|
1021
|
+
onLoad: (event) => handleLoad(event.currentTarget),
|
|
1022
|
+
onError: (event) => {
|
|
1023
|
+
const isTerminal = handleError();
|
|
1024
|
+
if (isTerminal) {
|
|
1025
|
+
onError?.(event);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
return /* @__PURE__ */ jsxs5(
|
|
1030
|
+
"div",
|
|
1031
|
+
{
|
|
1032
|
+
...wrapperProps,
|
|
1033
|
+
className: cn(
|
|
1034
|
+
cls("iuk-animated-image"),
|
|
1035
|
+
fill && cls("iuk-animated-image--fill"),
|
|
1036
|
+
isContain && cls("iuk-animated-image--contain"),
|
|
1037
|
+
wrapperClassName,
|
|
1038
|
+
wrapperProps?.className
|
|
1039
|
+
),
|
|
1040
|
+
style: { ...containerStyle, ...wrapperProps?.style },
|
|
1041
|
+
"data-slot": "animated-image",
|
|
1042
|
+
"data-state": state,
|
|
1043
|
+
"aria-busy": state === "loading" || void 0,
|
|
1044
|
+
children: [
|
|
1045
|
+
(showPlaceholder || isContain) && placeholderUrl && /* @__PURE__ */ jsx5(
|
|
1046
|
+
"img",
|
|
1047
|
+
{
|
|
1048
|
+
src: placeholderUrl,
|
|
1049
|
+
alt: "",
|
|
1050
|
+
"aria-hidden": "true",
|
|
1051
|
+
draggable: false,
|
|
1052
|
+
onDragStart: preventDrag,
|
|
1053
|
+
"data-slot": "animated-image-placeholder",
|
|
1054
|
+
className: cn(
|
|
1055
|
+
cls("iuk-animated-image__placeholder"),
|
|
1056
|
+
isLoaded && !isContain && cls("iuk-animated-image__placeholder--hidden"),
|
|
1057
|
+
placeholderClassName
|
|
1058
|
+
),
|
|
1059
|
+
style: placeholderStyle
|
|
1060
|
+
}
|
|
1061
|
+
),
|
|
1062
|
+
showShimmer && !isLoaded && !hasError && /* @__PURE__ */ jsx5(
|
|
1063
|
+
"div",
|
|
1064
|
+
{
|
|
1065
|
+
"aria-hidden": "true",
|
|
1066
|
+
"data-slot": "animated-image-shimmer",
|
|
1067
|
+
className: cn(cls("iuk-animated-image__shimmer"))
|
|
1068
|
+
}
|
|
1069
|
+
),
|
|
1070
|
+
ImageComponent ? /* @__PURE__ */ jsx5(
|
|
1071
|
+
ImageComponent,
|
|
1072
|
+
{
|
|
1073
|
+
...sharedImgProps,
|
|
1074
|
+
...fill ? { fill: true } : {},
|
|
1075
|
+
...imageComponentProps
|
|
1076
|
+
},
|
|
1077
|
+
retryKey > 0 ? retryKey : void 0
|
|
1078
|
+
) : /* @__PURE__ */ jsx5("img", { ...sharedImgProps }, retryKey > 0 ? retryKey : void 0),
|
|
1079
|
+
hasError && renderError ? renderError({ src: activeSrc, retry }) : null
|
|
1080
|
+
]
|
|
1081
|
+
}
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// src/react/components/BlurServiceDebugger.tsx
|
|
1086
|
+
import { useEffect as useEffect5 } from "react";
|
|
1087
|
+
function BlurServiceDebugger() {
|
|
1088
|
+
useEffect5(() => {
|
|
1089
|
+
if (typeof window === "undefined") return void 0;
|
|
1090
|
+
const target = window;
|
|
1091
|
+
target.blurService = blurService;
|
|
1092
|
+
return () => {
|
|
1093
|
+
if (target.blurService === blurService) {
|
|
1094
|
+
delete target.blurService;
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
}, []);
|
|
1098
|
+
return null;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// src/react/components/BlurVisualizationModal.tsx
|
|
1102
|
+
import { useEffect as useEffect6, useId as useId3, useMemo as useMemo4, useRef as useRef5, useState as useState4 } from "react";
|
|
1103
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
1104
|
+
|
|
1105
|
+
// src/react/utils/canvasSampler.ts
|
|
1106
|
+
function drawImageToCanvas(img, canvasRef) {
|
|
1107
|
+
const canvas = canvasRef.current;
|
|
1108
|
+
const ctx = canvas?.getContext("2d");
|
|
1109
|
+
if (!canvas || !ctx) return;
|
|
1110
|
+
const width = img.naturalWidth || img.width;
|
|
1111
|
+
const height = img.naturalHeight || img.height;
|
|
1112
|
+
if (!width || !height) return;
|
|
1113
|
+
canvas.width = width;
|
|
1114
|
+
canvas.height = height;
|
|
1115
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1116
|
+
try {
|
|
1117
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
1118
|
+
} catch {
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
function sampleCanvasPixelHex(event, canvasRef) {
|
|
1122
|
+
const canvas = canvasRef.current;
|
|
1123
|
+
const context = canvas?.getContext("2d");
|
|
1124
|
+
if (!canvas || !context || canvas.width === 0 || canvas.height === 0) {
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1128
|
+
if (!rect.width || !rect.height) return null;
|
|
1129
|
+
const relX = (event.clientX - rect.left) / rect.width;
|
|
1130
|
+
const relY = (event.clientY - rect.top) / rect.height;
|
|
1131
|
+
if (relX < 0 || relY < 0 || relX > 1 || relY > 1) return null;
|
|
1132
|
+
const x = Math.min(
|
|
1133
|
+
Math.max(Math.floor(relX * canvas.width), 0),
|
|
1134
|
+
canvas.width - 1
|
|
1135
|
+
);
|
|
1136
|
+
const y = Math.min(
|
|
1137
|
+
Math.max(Math.floor(relY * canvas.height), 0),
|
|
1138
|
+
canvas.height - 1
|
|
1139
|
+
);
|
|
1140
|
+
let pixel;
|
|
1141
|
+
try {
|
|
1142
|
+
pixel = context.getImageData(x, y, 1, 1).data;
|
|
1143
|
+
} catch {
|
|
1144
|
+
return null;
|
|
1145
|
+
}
|
|
1146
|
+
const [r, g, b, alpha] = pixel;
|
|
1147
|
+
if (alpha === 0) return null;
|
|
1148
|
+
return rgbToHex(r, g, b);
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
// src/react/components/BlurColorControls.tsx
|
|
1152
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1153
|
+
function BlurColorControls({
|
|
1154
|
+
localColor,
|
|
1155
|
+
hexInput,
|
|
1156
|
+
penModeActive,
|
|
1157
|
+
detectedColor,
|
|
1158
|
+
sampledColor,
|
|
1159
|
+
tModal,
|
|
1160
|
+
onColorPickerChange,
|
|
1161
|
+
onHexInputChange,
|
|
1162
|
+
onTogglePenMode,
|
|
1163
|
+
onUseDetectedColor
|
|
1164
|
+
}) {
|
|
1165
|
+
return /* @__PURE__ */ jsxs6("div", { className: "iuk-blur-modal__controls", children: [
|
|
1166
|
+
/* @__PURE__ */ jsx6("h3", { className: "iuk-blur-modal__section-title", children: tModal.adjustColor }),
|
|
1167
|
+
/* @__PURE__ */ jsx6("p", { className: "iuk-blur-modal__subtitle", children: penModeActive ? `\u{1F3A8} ${tModal.clickToSample}` : tModal.pickColorNote }),
|
|
1168
|
+
/* @__PURE__ */ jsxs6("div", { className: "iuk-blur-modal__picker-row", children: [
|
|
1169
|
+
/* @__PURE__ */ jsx6("label", { className: "iuk-blur-modal__color-well", children: /* @__PURE__ */ jsx6(
|
|
1170
|
+
"input",
|
|
1171
|
+
{
|
|
1172
|
+
type: "color",
|
|
1173
|
+
value: localColor,
|
|
1174
|
+
onChange: onColorPickerChange,
|
|
1175
|
+
"aria-label": tModal.adjustColor
|
|
1176
|
+
}
|
|
1177
|
+
) }),
|
|
1178
|
+
/* @__PURE__ */ jsxs6("div", { className: "iuk-blur-modal__hex-group", children: [
|
|
1179
|
+
/* @__PURE__ */ jsxs6("div", { className: "iuk-blur-modal__hex-field", children: [
|
|
1180
|
+
/* @__PURE__ */ jsx6("span", { children: "#" }),
|
|
1181
|
+
/* @__PURE__ */ jsx6(
|
|
1182
|
+
"input",
|
|
1183
|
+
{
|
|
1184
|
+
type: "text",
|
|
1185
|
+
value: hexInput,
|
|
1186
|
+
onChange: onHexInputChange,
|
|
1187
|
+
maxLength: 6,
|
|
1188
|
+
spellCheck: false,
|
|
1189
|
+
"aria-label": tModal.enterHexColor,
|
|
1190
|
+
placeholder: tModal.hexPlaceholder
|
|
1191
|
+
}
|
|
1192
|
+
)
|
|
1193
|
+
] }),
|
|
1194
|
+
/* @__PURE__ */ jsxs6("div", { className: "iuk-blur-modal__swatch-chip", children: [
|
|
1195
|
+
/* @__PURE__ */ jsx6(
|
|
1196
|
+
"span",
|
|
1197
|
+
{
|
|
1198
|
+
className: "iuk-blur-modal__swatch-dot",
|
|
1199
|
+
style: { backgroundColor: localColor },
|
|
1200
|
+
"aria-hidden": "true"
|
|
1201
|
+
}
|
|
1202
|
+
),
|
|
1203
|
+
/* @__PURE__ */ jsx6("code", { children: localColor })
|
|
1204
|
+
] })
|
|
1205
|
+
] })
|
|
1206
|
+
] }),
|
|
1207
|
+
/* @__PURE__ */ jsxs6("div", { className: "iuk-blur-modal__actions-row", children: [
|
|
1208
|
+
/* @__PURE__ */ jsxs6(
|
|
1209
|
+
"button",
|
|
1210
|
+
{
|
|
1211
|
+
type: "button",
|
|
1212
|
+
onClick: onTogglePenMode,
|
|
1213
|
+
className: `iuk-btn iuk-btn--secondary ${penModeActive ? "iuk-btn--active" : ""}`,
|
|
1214
|
+
"aria-label": penModeActive ? tModal.disablePenMode : tModal.enablePenMode,
|
|
1215
|
+
children: [
|
|
1216
|
+
/* @__PURE__ */ jsx6(PenToolIcon, { size: 14 }),
|
|
1217
|
+
/* @__PURE__ */ jsx6("span", { children: penModeActive ? tModal.penModeActive : tModal.enablePenMode })
|
|
1218
|
+
]
|
|
1219
|
+
}
|
|
1220
|
+
),
|
|
1221
|
+
detectedColor && /* @__PURE__ */ jsxs6(
|
|
1222
|
+
"button",
|
|
1223
|
+
{
|
|
1224
|
+
type: "button",
|
|
1225
|
+
className: "iuk-btn iuk-btn--secondary",
|
|
1226
|
+
onClick: onUseDetectedColor,
|
|
1227
|
+
children: [
|
|
1228
|
+
/* @__PURE__ */ jsx6(WandIcon, { size: 14 }),
|
|
1229
|
+
/* @__PURE__ */ jsx6("span", { children: tModal.resetToDetected }),
|
|
1230
|
+
/* @__PURE__ */ jsx6("code", { children: detectedColor.toUpperCase() })
|
|
1231
|
+
]
|
|
1232
|
+
}
|
|
1233
|
+
),
|
|
1234
|
+
sampledColor && /* @__PURE__ */ jsxs6("span", { className: "iuk-badge iuk-badge--accent", children: [
|
|
1235
|
+
/* @__PURE__ */ jsx6(PenToolIcon, { size: 12 }),
|
|
1236
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
1237
|
+
tModal.sampled,
|
|
1238
|
+
" ",
|
|
1239
|
+
sampledColor
|
|
1240
|
+
] })
|
|
1241
|
+
] })
|
|
1242
|
+
] })
|
|
1243
|
+
] });
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// src/react/components/SaveButton.tsx
|
|
1247
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1248
|
+
function SaveButton({
|
|
1249
|
+
icon,
|
|
1250
|
+
unstyled = false,
|
|
1251
|
+
children,
|
|
1252
|
+
className = "",
|
|
1253
|
+
type = "button",
|
|
1254
|
+
...rest
|
|
1255
|
+
}) {
|
|
1256
|
+
return /* @__PURE__ */ jsxs7(
|
|
1257
|
+
"button",
|
|
1258
|
+
{
|
|
1259
|
+
type,
|
|
1260
|
+
className: resolveSlotClass("iuk-save-button", unstyled, className),
|
|
1261
|
+
...rest,
|
|
1262
|
+
children: [
|
|
1263
|
+
icon && /* @__PURE__ */ jsx7("span", { className: resolveSlotClass("iuk-save-button__icon", unstyled), children: icon }),
|
|
1264
|
+
/* @__PURE__ */ jsx7("span", { children })
|
|
1265
|
+
]
|
|
1266
|
+
}
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// src/react/components/BlurVisualizationModal.tsx
|
|
1271
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1272
|
+
var DEBOUNCE_MS = 250;
|
|
1273
|
+
function BlurVisualizationModal({
|
|
1274
|
+
isOpen,
|
|
1275
|
+
onClose,
|
|
1276
|
+
imageUrl,
|
|
1277
|
+
blurDataUrl,
|
|
1278
|
+
blurColor,
|
|
1279
|
+
altText,
|
|
1280
|
+
originalSize,
|
|
1281
|
+
optimizedSize,
|
|
1282
|
+
detectedColor,
|
|
1283
|
+
onChangeColor,
|
|
1284
|
+
onUseDetectedColor,
|
|
1285
|
+
onChangeAltText,
|
|
1286
|
+
locale: propLocale,
|
|
1287
|
+
translations,
|
|
1288
|
+
renderImage,
|
|
1289
|
+
unstyled: propUnstyled
|
|
1290
|
+
}) {
|
|
1291
|
+
const ctx = useImageUploadContext();
|
|
1292
|
+
const isUnstyled = propUnstyled ?? ctx.unstyled;
|
|
1293
|
+
const locale = normalizeUploadLocale(propLocale || ctx.locale);
|
|
1294
|
+
const tModal = resolveTranslations(locale, translations || ctx.translations).blurModal;
|
|
1295
|
+
const cls = (defaultClass) => resolveSlotClass(defaultClass, isUnstyled);
|
|
1296
|
+
const { dialogRef, titleId } = useDialog({ isOpen, onClose });
|
|
1297
|
+
const textareaId = useId3();
|
|
1298
|
+
const baseColor = useMemo4(() => (blurColor || detectedColor || "#F5F5F5").toUpperCase(), [blurColor, detectedColor]);
|
|
1299
|
+
const [localColor, setLocalColor] = useState4(baseColor);
|
|
1300
|
+
const [hexInput, setHexInput] = useState4(baseColor.replace("#", ""));
|
|
1301
|
+
const [sampledColor, setSampledColor] = useState4(null);
|
|
1302
|
+
const [penModeActive, setPenModeActive] = useState4(false);
|
|
1303
|
+
const [localAltText, setLocalAltText] = useState4(altText || "");
|
|
1304
|
+
const liveCanvasRef = useRef5(null);
|
|
1305
|
+
const colorTimerRef = useRef5(null);
|
|
1306
|
+
const altTimerRef = useRef5(null);
|
|
1307
|
+
const pendingColorRef = useRef5(null);
|
|
1308
|
+
const pendingAltRef = useRef5(null);
|
|
1309
|
+
useEffect6(() => {
|
|
1310
|
+
if (!isOpen) return;
|
|
1311
|
+
setLocalColor(baseColor);
|
|
1312
|
+
setHexInput(baseColor.replace("#", ""));
|
|
1313
|
+
setLocalAltText(altText || "");
|
|
1314
|
+
}, [isOpen, baseColor, altText, blurDataUrl, imageUrl, blurColor]);
|
|
1315
|
+
useEffect6(() => () => {
|
|
1316
|
+
if (colorTimerRef.current) clearTimeout(colorTimerRef.current);
|
|
1317
|
+
if (altTimerRef.current) clearTimeout(altTimerRef.current);
|
|
1318
|
+
}, []);
|
|
1319
|
+
useEffect6(() => {
|
|
1320
|
+
if (!isOpen) return;
|
|
1321
|
+
const srcToLoad = imageUrl || blurDataUrl;
|
|
1322
|
+
if (!srcToLoad) return;
|
|
1323
|
+
const img = new window.Image();
|
|
1324
|
+
img.crossOrigin = "anonymous";
|
|
1325
|
+
img.onload = () => drawImageToCanvas(img, liveCanvasRef);
|
|
1326
|
+
img.onerror = () => {
|
|
1327
|
+
if (blurDataUrl && srcToLoad !== blurDataUrl) {
|
|
1328
|
+
const fallbackImg = new window.Image();
|
|
1329
|
+
fallbackImg.onload = () => drawImageToCanvas(fallbackImg, liveCanvasRef);
|
|
1330
|
+
fallbackImg.src = blurDataUrl;
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
img.src = srcToLoad;
|
|
1334
|
+
return () => {
|
|
1335
|
+
img.onload = null;
|
|
1336
|
+
img.onerror = null;
|
|
1337
|
+
};
|
|
1338
|
+
}, [imageUrl, blurDataUrl, isOpen]);
|
|
1339
|
+
useEffect6(() => {
|
|
1340
|
+
if (!sampledColor) return;
|
|
1341
|
+
const timer = window.setTimeout(() => setSampledColor(null), 2e3);
|
|
1342
|
+
return () => window.clearTimeout(timer);
|
|
1343
|
+
}, [sampledColor]);
|
|
1344
|
+
if (!isOpen || typeof document === "undefined") return null;
|
|
1345
|
+
const scheduleColorEmit = (hex) => {
|
|
1346
|
+
pendingColorRef.current = hex;
|
|
1347
|
+
if (colorTimerRef.current) clearTimeout(colorTimerRef.current);
|
|
1348
|
+
colorTimerRef.current = setTimeout(() => {
|
|
1349
|
+
colorTimerRef.current = null;
|
|
1350
|
+
const next = pendingColorRef.current;
|
|
1351
|
+
pendingColorRef.current = null;
|
|
1352
|
+
if (next !== null) onChangeColor?.(next);
|
|
1353
|
+
}, DEBOUNCE_MS);
|
|
1354
|
+
};
|
|
1355
|
+
const scheduleAltEmit = (nextAlt) => {
|
|
1356
|
+
pendingAltRef.current = nextAlt;
|
|
1357
|
+
if (altTimerRef.current) clearTimeout(altTimerRef.current);
|
|
1358
|
+
altTimerRef.current = setTimeout(() => {
|
|
1359
|
+
altTimerRef.current = null;
|
|
1360
|
+
const next = pendingAltRef.current;
|
|
1361
|
+
pendingAltRef.current = null;
|
|
1362
|
+
if (next !== null) onChangeAltText?.(next);
|
|
1363
|
+
}, DEBOUNCE_MS);
|
|
1364
|
+
};
|
|
1365
|
+
const flushPendingChanges = () => {
|
|
1366
|
+
if (colorTimerRef.current) {
|
|
1367
|
+
clearTimeout(colorTimerRef.current);
|
|
1368
|
+
colorTimerRef.current = null;
|
|
1369
|
+
}
|
|
1370
|
+
if (pendingColorRef.current !== null) {
|
|
1371
|
+
onChangeColor?.(pendingColorRef.current);
|
|
1372
|
+
pendingColorRef.current = null;
|
|
1373
|
+
}
|
|
1374
|
+
if (altTimerRef.current) {
|
|
1375
|
+
clearTimeout(altTimerRef.current);
|
|
1376
|
+
altTimerRef.current = null;
|
|
1377
|
+
}
|
|
1378
|
+
if (pendingAltRef.current !== null) {
|
|
1379
|
+
onChangeAltText?.(pendingAltRef.current);
|
|
1380
|
+
pendingAltRef.current = null;
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
const handleClose = () => {
|
|
1384
|
+
flushPendingChanges();
|
|
1385
|
+
onClose();
|
|
1386
|
+
};
|
|
1387
|
+
const syncLocalHex = (hex, notify = true) => {
|
|
1388
|
+
setLocalColor(hex);
|
|
1389
|
+
setHexInput(hex.replace("#", ""));
|
|
1390
|
+
if (notify) scheduleColorEmit(hex);
|
|
1391
|
+
};
|
|
1392
|
+
const handleColorPickerChange = (e) => syncLocalHex(e.target.value.toUpperCase());
|
|
1393
|
+
const handleHexInputChange = (event) => {
|
|
1394
|
+
const sanitized = event.target.value.replace(/[^0-9a-fA-F]/g, "").slice(0, 6);
|
|
1395
|
+
setHexInput(sanitized.toUpperCase());
|
|
1396
|
+
if (sanitized.length === 3 || sanitized.length === 6) {
|
|
1397
|
+
const normalized = normalizeColorInput(`#${sanitized}`);
|
|
1398
|
+
if (normalized) {
|
|
1399
|
+
setLocalColor(normalized);
|
|
1400
|
+
scheduleColorEmit(normalized);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
const handlePenSample = (event) => {
|
|
1405
|
+
if (!penModeActive) {
|
|
1406
|
+
if (event.pointerType === "pen") setPenModeActive(true);
|
|
1407
|
+
else return;
|
|
1408
|
+
}
|
|
1409
|
+
const sampled = sampleCanvasPixelHex(event, liveCanvasRef);
|
|
1410
|
+
if (!sampled) return;
|
|
1411
|
+
setSampledColor(sampled);
|
|
1412
|
+
syncLocalHex(sampled);
|
|
1413
|
+
};
|
|
1414
|
+
const handleUseDetectedColor = () => {
|
|
1415
|
+
if (!detectedColor) return;
|
|
1416
|
+
if (colorTimerRef.current) {
|
|
1417
|
+
clearTimeout(colorTimerRef.current);
|
|
1418
|
+
colorTimerRef.current = null;
|
|
1419
|
+
pendingColorRef.current = null;
|
|
1420
|
+
}
|
|
1421
|
+
const normalized = normalizeColorInput(detectedColor) || detectedColor.toUpperCase();
|
|
1422
|
+
setLocalColor(normalized);
|
|
1423
|
+
setHexInput(normalized.replace("#", ""));
|
|
1424
|
+
if (onUseDetectedColor) onUseDetectedColor();
|
|
1425
|
+
else onChangeColor?.(normalized);
|
|
1426
|
+
};
|
|
1427
|
+
const displayColor = localColor || blurColor || "#F5F5F5";
|
|
1428
|
+
return createPortal2(
|
|
1429
|
+
/* @__PURE__ */ jsx8(
|
|
1430
|
+
"div",
|
|
1431
|
+
{
|
|
1432
|
+
"data-slot": "blur-modal-backdrop",
|
|
1433
|
+
"data-unstyled": isUnstyled || void 0,
|
|
1434
|
+
className: cls("iuk-modal-backdrop"),
|
|
1435
|
+
dir: locale === "ar" ? "rtl" : "ltr",
|
|
1436
|
+
onClick: handleClose,
|
|
1437
|
+
role: "dialog",
|
|
1438
|
+
"aria-modal": "true",
|
|
1439
|
+
"aria-labelledby": titleId,
|
|
1440
|
+
children: /* @__PURE__ */ jsxs8(
|
|
1441
|
+
"div",
|
|
1442
|
+
{
|
|
1443
|
+
ref: dialogRef,
|
|
1444
|
+
"data-slot": "blur-modal",
|
|
1445
|
+
className: cls("iuk-blur-modal"),
|
|
1446
|
+
onClick: (e) => e.stopPropagation(),
|
|
1447
|
+
children: [
|
|
1448
|
+
/* @__PURE__ */ jsxs8("div", { className: cls("iuk-blur-modal__header"), children: [
|
|
1449
|
+
/* @__PURE__ */ jsxs8("div", { className: cls("iuk-blur-modal__title-row"), children: [
|
|
1450
|
+
/* @__PURE__ */ jsx8(EyeIcon, { size: 20, className: cls("iuk-blur-modal__title-icon") }),
|
|
1451
|
+
/* @__PURE__ */ jsx8("h2", { id: titleId, className: cls("iuk-blur-modal__title"), children: tModal.title }),
|
|
1452
|
+
optimizedSize ? /* @__PURE__ */ jsx8("span", { className: cls("iuk-badge"), children: formatFileSize(optimizedSize) }) : null
|
|
1453
|
+
] }),
|
|
1454
|
+
/* @__PURE__ */ jsx8("button", { type: "button", onClick: handleClose, className: cls("iuk-icon-btn"), "aria-label": tModal.closeModal, children: /* @__PURE__ */ jsx8(XIcon, { size: 18 }) })
|
|
1455
|
+
] }),
|
|
1456
|
+
/* @__PURE__ */ jsxs8("div", { className: cls("iuk-blur-modal__body"), children: [
|
|
1457
|
+
/* @__PURE__ */ jsxs8("div", { className: cls("iuk-blur-modal__grid"), children: [
|
|
1458
|
+
/* @__PURE__ */ jsx8(
|
|
1459
|
+
BlurColorControls,
|
|
1460
|
+
{
|
|
1461
|
+
localColor,
|
|
1462
|
+
hexInput,
|
|
1463
|
+
penModeActive,
|
|
1464
|
+
detectedColor,
|
|
1465
|
+
sampledColor,
|
|
1466
|
+
tModal,
|
|
1467
|
+
onColorPickerChange: handleColorPickerChange,
|
|
1468
|
+
onHexInputChange: handleHexInputChange,
|
|
1469
|
+
onTogglePenMode: () => setPenModeActive((prev) => !prev),
|
|
1470
|
+
onUseDetectedColor: handleUseDetectedColor
|
|
1471
|
+
}
|
|
1472
|
+
),
|
|
1473
|
+
/* @__PURE__ */ jsxs8("div", { className: cls("iuk-blur-modal__preview-col"), children: [
|
|
1474
|
+
/* @__PURE__ */ jsx8("h3", { className: cls("iuk-blur-modal__section-title"), children: tModal.livePreview }),
|
|
1475
|
+
/* @__PURE__ */ jsxs8(
|
|
1476
|
+
"div",
|
|
1477
|
+
{
|
|
1478
|
+
className: cls(`iuk-blur-modal__stage ${penModeActive ? "iuk-blur-modal__stage--sampling" : ""}`.trim()),
|
|
1479
|
+
style: { backgroundColor: displayColor },
|
|
1480
|
+
onPointerDown: handlePenSample,
|
|
1481
|
+
children: [
|
|
1482
|
+
/* @__PURE__ */ jsx8(
|
|
1483
|
+
BlurImage,
|
|
1484
|
+
{
|
|
1485
|
+
src: imageUrl,
|
|
1486
|
+
alt: altText || tModal.livePreview,
|
|
1487
|
+
blurDataUrl,
|
|
1488
|
+
blurColor: displayColor,
|
|
1489
|
+
objectFit: "contain",
|
|
1490
|
+
renderImage,
|
|
1491
|
+
onImageLoad: (img) => {
|
|
1492
|
+
if (img) drawImageToCanvas(img, liveCanvasRef);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
),
|
|
1496
|
+
!blurDataUrl && /* @__PURE__ */ jsx8("div", { className: cls("iuk-blur-modal__no-blur-note"), children: tModal.showingOriginal })
|
|
1497
|
+
]
|
|
1498
|
+
}
|
|
1499
|
+
),
|
|
1500
|
+
optimizedSize && originalSize && originalSize > optimizedSize ? /* @__PURE__ */ jsxs8("div", { className: cls("iuk-blur-modal__savings"), children: [
|
|
1501
|
+
/* @__PURE__ */ jsx8("span", { children: tModal.saved }),
|
|
1502
|
+
/* @__PURE__ */ jsxs8("strong", { children: [
|
|
1503
|
+
formatFileSize(originalSize - optimizedSize),
|
|
1504
|
+
" (",
|
|
1505
|
+
Math.round((originalSize - optimizedSize) / originalSize * 100),
|
|
1506
|
+
"%)"
|
|
1507
|
+
] })
|
|
1508
|
+
] }) : null
|
|
1509
|
+
] })
|
|
1510
|
+
] }),
|
|
1511
|
+
/* @__PURE__ */ jsxs8("div", { className: cls("iuk-blur-modal__alt-section"), children: [
|
|
1512
|
+
/* @__PURE__ */ jsxs8("label", { htmlFor: textareaId, className: cls("iuk-blur-modal__section-title"), children: [
|
|
1513
|
+
tModal.accessibility,
|
|
1514
|
+
" \u2014 ",
|
|
1515
|
+
tModal.altText
|
|
1516
|
+
] }),
|
|
1517
|
+
/* @__PURE__ */ jsx8(
|
|
1518
|
+
"textarea",
|
|
1519
|
+
{
|
|
1520
|
+
id: textareaId,
|
|
1521
|
+
value: localAltText,
|
|
1522
|
+
onChange: (e) => {
|
|
1523
|
+
setLocalAltText(e.target.value);
|
|
1524
|
+
scheduleAltEmit(e.target.value);
|
|
1525
|
+
},
|
|
1526
|
+
className: cls("iuk-blur-modal__textarea"),
|
|
1527
|
+
placeholder: tModal.altTextPlaceholder,
|
|
1528
|
+
rows: 2
|
|
1529
|
+
}
|
|
1530
|
+
)
|
|
1531
|
+
] }),
|
|
1532
|
+
/* @__PURE__ */ jsx8("canvas", { ref: liveCanvasRef, style: { display: "none" }, "aria-hidden": "true" })
|
|
1533
|
+
] }),
|
|
1534
|
+
/* @__PURE__ */ jsx8("div", { className: cls("iuk-blur-modal__footer"), children: /* @__PURE__ */ jsx8(SaveButton, { unstyled: isUnstyled, onClick: handleClose, children: tModal.saveAndClose }) })
|
|
1535
|
+
]
|
|
1536
|
+
}
|
|
1537
|
+
)
|
|
1538
|
+
}
|
|
1539
|
+
),
|
|
1540
|
+
document.body
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
// src/react/components/ImageUpload.tsx
|
|
1545
|
+
import {
|
|
1546
|
+
forwardRef as forwardRef3,
|
|
1547
|
+
useEffect as useEffect8,
|
|
1548
|
+
useState as useState7
|
|
1549
|
+
} from "react";
|
|
1550
|
+
import { createPortal as createPortal4 } from "react-dom";
|
|
1551
|
+
|
|
1552
|
+
// src/react/components/MultiImageUpload.tsx
|
|
1553
|
+
import {
|
|
1554
|
+
Fragment as Fragment3,
|
|
1555
|
+
forwardRef,
|
|
1556
|
+
useId as useId4,
|
|
1557
|
+
useImperativeHandle,
|
|
1558
|
+
useRef as useRef7
|
|
1559
|
+
} from "react";
|
|
1560
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
1561
|
+
|
|
1562
|
+
// src/react/components/MultiDropzoneViews.tsx
|
|
1563
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1564
|
+
function MultiEmptyDropzone({
|
|
1565
|
+
isDragging,
|
|
1566
|
+
disabled = false,
|
|
1567
|
+
hasError = false,
|
|
1568
|
+
required = false,
|
|
1569
|
+
enablePaste = true,
|
|
1570
|
+
visualState: propVisualState,
|
|
1571
|
+
allowFolder = true,
|
|
1572
|
+
maxSizeMB,
|
|
1573
|
+
ui,
|
|
1574
|
+
dragHandlers,
|
|
1575
|
+
onPaste,
|
|
1576
|
+
onSelectFiles,
|
|
1577
|
+
onSelectFolder,
|
|
1578
|
+
unstyled,
|
|
1579
|
+
providerClassNames: pCls,
|
|
1580
|
+
classNames: cCls,
|
|
1581
|
+
providerStyles: pSty,
|
|
1582
|
+
styles: cSty
|
|
1583
|
+
}) {
|
|
1584
|
+
const visualState = propVisualState ?? resolveUploadDataState({ disabled, hasError, isDragging });
|
|
1585
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, unstyled, pCls?.[slot], cCls?.[slot]);
|
|
1586
|
+
const slotStyle = (slot) => resolveSlotStyle(pSty?.[slot], cSty?.[slot]);
|
|
1587
|
+
const rootClassName = resolveSlotClass(
|
|
1588
|
+
cx(
|
|
1589
|
+
"iuk-multi__empty",
|
|
1590
|
+
isDragging && "iuk-multi__empty--dragging",
|
|
1591
|
+
disabled && "iuk-multi__empty--disabled",
|
|
1592
|
+
hasError && "iuk-multi__empty--error"
|
|
1593
|
+
),
|
|
1594
|
+
unstyled,
|
|
1595
|
+
pCls?.emptyDropzone,
|
|
1596
|
+
cCls?.emptyDropzone,
|
|
1597
|
+
isDragging && pCls?.emptyDropzoneDragging,
|
|
1598
|
+
isDragging && cCls?.emptyDropzoneDragging,
|
|
1599
|
+
disabled && pCls?.emptyDropzoneDisabled,
|
|
1600
|
+
disabled && cCls?.emptyDropzoneDisabled,
|
|
1601
|
+
hasError && pCls?.emptyDropzoneError,
|
|
1602
|
+
hasError && cCls?.emptyDropzoneError
|
|
1603
|
+
);
|
|
1604
|
+
const rootStyle = resolveSlotStyle(
|
|
1605
|
+
pSty?.emptyDropzone,
|
|
1606
|
+
cSty?.emptyDropzone,
|
|
1607
|
+
isDragging ? pSty?.emptyDropzoneDragging : void 0,
|
|
1608
|
+
isDragging ? cSty?.emptyDropzoneDragging : void 0,
|
|
1609
|
+
disabled ? pSty?.emptyDropzoneDisabled : void 0,
|
|
1610
|
+
disabled ? cSty?.emptyDropzoneDisabled : void 0,
|
|
1611
|
+
hasError ? pSty?.emptyDropzoneError : void 0,
|
|
1612
|
+
hasError ? cSty?.emptyDropzoneError : void 0
|
|
1613
|
+
);
|
|
1614
|
+
return /* @__PURE__ */ jsx9(
|
|
1615
|
+
"div",
|
|
1616
|
+
{
|
|
1617
|
+
"data-slot": "empty-dropzone",
|
|
1618
|
+
"data-state": visualState,
|
|
1619
|
+
"data-dragging": isDragging || void 0,
|
|
1620
|
+
"data-disabled": disabled || void 0,
|
|
1621
|
+
"data-error": hasError || void 0,
|
|
1622
|
+
tabIndex: disabled ? -1 : 0,
|
|
1623
|
+
"aria-required": required || void 0,
|
|
1624
|
+
"aria-invalid": hasError || void 0,
|
|
1625
|
+
className: rootClassName,
|
|
1626
|
+
style: rootStyle,
|
|
1627
|
+
onPaste,
|
|
1628
|
+
...dragHandlers,
|
|
1629
|
+
children: /* @__PURE__ */ jsxs9("div", { className: resolveSlotClass("iuk-dropzone__prompt", unstyled), children: [
|
|
1630
|
+
/* @__PURE__ */ jsx9("div", { className: resolveSlotClass("iuk-dropzone__icon", unstyled), children: /* @__PURE__ */ jsx9(ImagePlusIcon, { size: 40, strokeWidth: 1.5 }) }),
|
|
1631
|
+
/* @__PURE__ */ jsx9(
|
|
1632
|
+
"h3",
|
|
1633
|
+
{
|
|
1634
|
+
"data-slot": "empty-title",
|
|
1635
|
+
className: slotClass("emptyTitle", "iuk-multi__title"),
|
|
1636
|
+
style: slotStyle("emptyTitle"),
|
|
1637
|
+
children: isDragging ? ui.dropImagesHere : ui.uploadImages
|
|
1638
|
+
}
|
|
1639
|
+
),
|
|
1640
|
+
/* @__PURE__ */ jsx9(
|
|
1641
|
+
"p",
|
|
1642
|
+
{
|
|
1643
|
+
"data-slot": "empty-hint",
|
|
1644
|
+
className: slotClass("emptyHint", "iuk-dropzone__hint"),
|
|
1645
|
+
style: slotStyle("emptyHint"),
|
|
1646
|
+
children: isDragging ? ui.releaseToUpload : `${ui.dragDropOrChoose}${enablePaste ? ` (${ui.pasteHint})` : ""}`
|
|
1647
|
+
}
|
|
1648
|
+
),
|
|
1649
|
+
!isDragging && /* @__PURE__ */ jsxs9(
|
|
1650
|
+
"div",
|
|
1651
|
+
{
|
|
1652
|
+
"data-slot": "empty-actions",
|
|
1653
|
+
className: slotClass("emptyActions", "iuk-multi__btn-row"),
|
|
1654
|
+
style: slotStyle("emptyActions"),
|
|
1655
|
+
children: [
|
|
1656
|
+
/* @__PURE__ */ jsxs9(
|
|
1657
|
+
"button",
|
|
1658
|
+
{
|
|
1659
|
+
type: "button",
|
|
1660
|
+
onClick: onSelectFiles,
|
|
1661
|
+
className: slotClass("primaryButton", "iuk-btn iuk-btn--primary"),
|
|
1662
|
+
style: slotStyle("primaryButton"),
|
|
1663
|
+
disabled,
|
|
1664
|
+
children: [
|
|
1665
|
+
/* @__PURE__ */ jsx9(UploadIcon, { size: 16 }),
|
|
1666
|
+
/* @__PURE__ */ jsx9("span", { children: ui.selectFiles })
|
|
1667
|
+
]
|
|
1668
|
+
}
|
|
1669
|
+
),
|
|
1670
|
+
allowFolder && /* @__PURE__ */ jsxs9(
|
|
1671
|
+
"button",
|
|
1672
|
+
{
|
|
1673
|
+
type: "button",
|
|
1674
|
+
onClick: onSelectFolder,
|
|
1675
|
+
className: slotClass("secondaryButton", "iuk-btn iuk-btn--secondary"),
|
|
1676
|
+
style: slotStyle("secondaryButton"),
|
|
1677
|
+
disabled,
|
|
1678
|
+
children: [
|
|
1679
|
+
/* @__PURE__ */ jsx9(FolderOpenIcon, { size: 16 }),
|
|
1680
|
+
/* @__PURE__ */ jsx9("span", { children: ui.selectFolder })
|
|
1681
|
+
]
|
|
1682
|
+
}
|
|
1683
|
+
)
|
|
1684
|
+
]
|
|
1685
|
+
}
|
|
1686
|
+
),
|
|
1687
|
+
!isDragging && /* @__PURE__ */ jsxs9(
|
|
1688
|
+
"p",
|
|
1689
|
+
{
|
|
1690
|
+
"data-slot": "empty-subtext",
|
|
1691
|
+
className: slotClass("emptySubtext", "iuk-multi__subtext"),
|
|
1692
|
+
style: slotStyle("emptySubtext"),
|
|
1693
|
+
children: [
|
|
1694
|
+
ui.supportsFormats,
|
|
1695
|
+
" \u2022",
|
|
1696
|
+
" ",
|
|
1697
|
+
ui.maxPerFile.replace("{size}", String(maxSizeMB))
|
|
1698
|
+
]
|
|
1699
|
+
}
|
|
1700
|
+
)
|
|
1701
|
+
] })
|
|
1702
|
+
}
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
function MultiAddMoreTile({
|
|
1706
|
+
isDragging,
|
|
1707
|
+
disabled = false,
|
|
1708
|
+
allowFolder = true,
|
|
1709
|
+
ui,
|
|
1710
|
+
dragHandlers,
|
|
1711
|
+
onSelectFiles,
|
|
1712
|
+
onSelectFolder,
|
|
1713
|
+
unstyled,
|
|
1714
|
+
providerClassNames: pCls,
|
|
1715
|
+
classNames: cCls,
|
|
1716
|
+
providerStyles: pSty,
|
|
1717
|
+
styles: cSty
|
|
1718
|
+
}) {
|
|
1719
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, unstyled, pCls?.[slot], cCls?.[slot]);
|
|
1720
|
+
const slotStyle = (slot) => resolveSlotStyle(pSty?.[slot], cSty?.[slot]);
|
|
1721
|
+
const rootClassName = resolveSlotClass(
|
|
1722
|
+
cx(
|
|
1723
|
+
"iuk-tile iuk-tile--add-more",
|
|
1724
|
+
isDragging && "iuk-tile--dragging",
|
|
1725
|
+
disabled && "iuk-tile--disabled"
|
|
1726
|
+
),
|
|
1727
|
+
unstyled,
|
|
1728
|
+
pCls?.addMoreTile,
|
|
1729
|
+
cCls?.addMoreTile,
|
|
1730
|
+
isDragging && pCls?.addMoreTileDragging,
|
|
1731
|
+
isDragging && cCls?.addMoreTileDragging
|
|
1732
|
+
);
|
|
1733
|
+
const rootStyle = resolveSlotStyle(
|
|
1734
|
+
pSty?.addMoreTile,
|
|
1735
|
+
cSty?.addMoreTile,
|
|
1736
|
+
isDragging ? pSty?.addMoreTileDragging : void 0,
|
|
1737
|
+
isDragging ? cSty?.addMoreTileDragging : void 0
|
|
1738
|
+
);
|
|
1739
|
+
return /* @__PURE__ */ jsx9(
|
|
1740
|
+
"div",
|
|
1741
|
+
{
|
|
1742
|
+
"data-slot": "add-more",
|
|
1743
|
+
"data-dragging": isDragging || void 0,
|
|
1744
|
+
"data-disabled": disabled || void 0,
|
|
1745
|
+
className: rootClassName,
|
|
1746
|
+
style: rootStyle,
|
|
1747
|
+
...dragHandlers,
|
|
1748
|
+
children: /* @__PURE__ */ jsxs9(
|
|
1749
|
+
"div",
|
|
1750
|
+
{
|
|
1751
|
+
"data-slot": "add-more-content",
|
|
1752
|
+
className: slotClass("addMoreContent", "iuk-tile__add-content"),
|
|
1753
|
+
style: slotStyle("addMoreContent"),
|
|
1754
|
+
children: [
|
|
1755
|
+
/* @__PURE__ */ jsx9(ImagePlusIcon, { size: 28, strokeWidth: 1.5 }),
|
|
1756
|
+
/* @__PURE__ */ jsx9("p", { children: isDragging ? ui.dropHere : ui.addMore }),
|
|
1757
|
+
!isDragging && /* @__PURE__ */ jsxs9(
|
|
1758
|
+
"div",
|
|
1759
|
+
{
|
|
1760
|
+
"data-slot": "add-more-actions",
|
|
1761
|
+
className: slotClass("addMoreActions", "iuk-tile__add-btns"),
|
|
1762
|
+
style: slotStyle("addMoreActions"),
|
|
1763
|
+
children: [
|
|
1764
|
+
/* @__PURE__ */ jsxs9(
|
|
1765
|
+
"button",
|
|
1766
|
+
{
|
|
1767
|
+
type: "button",
|
|
1768
|
+
onClick: onSelectFiles,
|
|
1769
|
+
className: slotClass("secondaryButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
|
|
1770
|
+
style: slotStyle("secondaryButton"),
|
|
1771
|
+
disabled,
|
|
1772
|
+
children: [
|
|
1773
|
+
/* @__PURE__ */ jsx9(UploadIcon, { size: 13 }),
|
|
1774
|
+
/* @__PURE__ */ jsx9("span", { children: ui.files })
|
|
1775
|
+
]
|
|
1776
|
+
}
|
|
1777
|
+
),
|
|
1778
|
+
allowFolder && /* @__PURE__ */ jsxs9(
|
|
1779
|
+
"button",
|
|
1780
|
+
{
|
|
1781
|
+
type: "button",
|
|
1782
|
+
onClick: onSelectFolder,
|
|
1783
|
+
className: slotClass("secondaryButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
|
|
1784
|
+
style: slotStyle("secondaryButton"),
|
|
1785
|
+
disabled,
|
|
1786
|
+
children: [
|
|
1787
|
+
/* @__PURE__ */ jsx9(FolderOpenIcon, { size: 13 }),
|
|
1788
|
+
/* @__PURE__ */ jsx9("span", { children: ui.folder })
|
|
1789
|
+
]
|
|
1790
|
+
}
|
|
1791
|
+
)
|
|
1792
|
+
]
|
|
1793
|
+
}
|
|
1794
|
+
)
|
|
1795
|
+
]
|
|
1796
|
+
}
|
|
1797
|
+
)
|
|
1798
|
+
}
|
|
1799
|
+
);
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
// src/react/components/MultiUploadHeaderAlerts.tsx
|
|
1803
|
+
import { Fragment, jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1804
|
+
function MultiUploadHeaderAlerts({
|
|
1805
|
+
label,
|
|
1806
|
+
labelId,
|
|
1807
|
+
inputId,
|
|
1808
|
+
required = false,
|
|
1809
|
+
disabled = false,
|
|
1810
|
+
totalCount,
|
|
1811
|
+
selectedCount,
|
|
1812
|
+
uploadingCount,
|
|
1813
|
+
missingAltCount,
|
|
1814
|
+
isUploading,
|
|
1815
|
+
hasFailedUploads,
|
|
1816
|
+
infoMessage,
|
|
1817
|
+
showMissingAltWarning,
|
|
1818
|
+
uploadStats,
|
|
1819
|
+
locale = "en",
|
|
1820
|
+
translations,
|
|
1821
|
+
ui,
|
|
1822
|
+
onSelectAll,
|
|
1823
|
+
onDeselectAll,
|
|
1824
|
+
onRemoveSelected,
|
|
1825
|
+
onRetryFailed,
|
|
1826
|
+
unstyled,
|
|
1827
|
+
providerClassNames,
|
|
1828
|
+
classNames,
|
|
1829
|
+
providerStyles,
|
|
1830
|
+
styles
|
|
1831
|
+
}) {
|
|
1832
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, unstyled, providerClassNames?.[slot], classNames?.[slot]);
|
|
1833
|
+
const slotStyle = (slot) => resolveSlotStyle(providerStyles?.[slot], styles?.[slot]);
|
|
1834
|
+
return /* @__PURE__ */ jsxs10(Fragment, { children: [
|
|
1835
|
+
/* @__PURE__ */ jsxs10("div", { "data-slot": "header", className: slotClass("header", "iuk-multi__header"), style: slotStyle("header"), children: [
|
|
1836
|
+
(label || ui.uploadImages) && /* @__PURE__ */ jsxs10(
|
|
1837
|
+
"label",
|
|
1838
|
+
{
|
|
1839
|
+
id: labelId,
|
|
1840
|
+
htmlFor: inputId,
|
|
1841
|
+
"data-slot": "label",
|
|
1842
|
+
className: slotClass("label", "iuk-label"),
|
|
1843
|
+
style: slotStyle("label"),
|
|
1844
|
+
children: [
|
|
1845
|
+
/* @__PURE__ */ jsx10("span", { children: label || ui.uploadImages }),
|
|
1846
|
+
required && /* @__PURE__ */ jsx10("span", { className: resolveSlotClass("iuk-required", unstyled), children: "*" }),
|
|
1847
|
+
totalCount > 0 && /* @__PURE__ */ jsxs10("span", { "data-slot": "count", className: slotClass("count", "iuk-multi__count"), style: slotStyle("count"), children: [
|
|
1848
|
+
"(",
|
|
1849
|
+
totalCount,
|
|
1850
|
+
")"
|
|
1851
|
+
] })
|
|
1852
|
+
]
|
|
1853
|
+
}
|
|
1854
|
+
),
|
|
1855
|
+
totalCount > 0 && /* @__PURE__ */ jsx10("div", { "data-slot": "bulk-actions", className: slotClass("bulkActions", "iuk-multi__bulk"), style: slotStyle("bulkActions"), children: selectedCount === 0 ? /* @__PURE__ */ jsx10(
|
|
1856
|
+
"button",
|
|
1857
|
+
{
|
|
1858
|
+
type: "button",
|
|
1859
|
+
onClick: onSelectAll,
|
|
1860
|
+
disabled,
|
|
1861
|
+
className: slotClass("bulkButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
|
|
1862
|
+
style: slotStyle("bulkButton"),
|
|
1863
|
+
children: ui.selectAll
|
|
1864
|
+
}
|
|
1865
|
+
) : /* @__PURE__ */ jsxs10(Fragment, { children: [
|
|
1866
|
+
/* @__PURE__ */ jsxs10(
|
|
1867
|
+
"button",
|
|
1868
|
+
{
|
|
1869
|
+
type: "button",
|
|
1870
|
+
onClick: onDeselectAll,
|
|
1871
|
+
disabled,
|
|
1872
|
+
className: slotClass("bulkButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
|
|
1873
|
+
style: slotStyle("bulkButton"),
|
|
1874
|
+
children: [
|
|
1875
|
+
ui.deselectAll,
|
|
1876
|
+
" (",
|
|
1877
|
+
selectedCount,
|
|
1878
|
+
")"
|
|
1879
|
+
]
|
|
1880
|
+
}
|
|
1881
|
+
),
|
|
1882
|
+
/* @__PURE__ */ jsxs10(
|
|
1883
|
+
"button",
|
|
1884
|
+
{
|
|
1885
|
+
type: "button",
|
|
1886
|
+
onClick: onRemoveSelected,
|
|
1887
|
+
disabled,
|
|
1888
|
+
className: slotClass("bulkDangerButton", "iuk-btn iuk-btn--danger iuk-btn--sm"),
|
|
1889
|
+
style: slotStyle("bulkDangerButton"),
|
|
1890
|
+
children: [
|
|
1891
|
+
/* @__PURE__ */ jsx10(TrashIcon, { size: 14 }),
|
|
1892
|
+
/* @__PURE__ */ jsx10("span", { children: ui.removeSelected })
|
|
1893
|
+
]
|
|
1894
|
+
}
|
|
1895
|
+
)
|
|
1896
|
+
] }) })
|
|
1897
|
+
] }),
|
|
1898
|
+
isUploading && /* @__PURE__ */ jsxs10(
|
|
1899
|
+
"div",
|
|
1900
|
+
{
|
|
1901
|
+
"data-slot": "alert",
|
|
1902
|
+
role: "status",
|
|
1903
|
+
"aria-live": "polite",
|
|
1904
|
+
className: slotClass("alert", "iuk-alert iuk-alert--info"),
|
|
1905
|
+
style: slotStyle("alert"),
|
|
1906
|
+
children: [
|
|
1907
|
+
/* @__PURE__ */ jsxs10("span", { className: resolveSlotClass("iuk-alert__row", unstyled), children: [
|
|
1908
|
+
/* @__PURE__ */ jsx10(LoaderIcon, { size: 16, className: resolveSlotClass("iuk-spin", unstyled) }),
|
|
1909
|
+
/* @__PURE__ */ jsxs10("span", { children: [
|
|
1910
|
+
formatUploadingCount(ui, uploadingCount, locale, translations),
|
|
1911
|
+
"..."
|
|
1912
|
+
] })
|
|
1913
|
+
] }),
|
|
1914
|
+
uploadStats.total > 0 && /* @__PURE__ */ jsxs10("strong", { children: [
|
|
1915
|
+
uploadStats.completed + uploadStats.failed,
|
|
1916
|
+
" / ",
|
|
1917
|
+
uploadStats.total
|
|
1918
|
+
] })
|
|
1919
|
+
]
|
|
1920
|
+
}
|
|
1921
|
+
),
|
|
1922
|
+
hasFailedUploads && /* @__PURE__ */ jsxs10(
|
|
1923
|
+
"div",
|
|
1924
|
+
{
|
|
1925
|
+
"data-slot": "alert",
|
|
1926
|
+
role: "alert",
|
|
1927
|
+
className: slotClass("alert", "iuk-alert iuk-alert--error"),
|
|
1928
|
+
style: slotStyle("alert"),
|
|
1929
|
+
children: [
|
|
1930
|
+
/* @__PURE__ */ jsx10(XCircleIcon, { size: 16 }),
|
|
1931
|
+
/* @__PURE__ */ jsxs10("span", { children: [
|
|
1932
|
+
ui.someUploadsFailed,
|
|
1933
|
+
" ",
|
|
1934
|
+
/* @__PURE__ */ jsx10(
|
|
1935
|
+
"button",
|
|
1936
|
+
{
|
|
1937
|
+
type: "button",
|
|
1938
|
+
onClick: onRetryFailed,
|
|
1939
|
+
disabled: isUploading || disabled,
|
|
1940
|
+
className: resolveSlotClass("iuk-link-btn", unstyled),
|
|
1941
|
+
children: ui.retryFailedUploads
|
|
1942
|
+
}
|
|
1943
|
+
)
|
|
1944
|
+
] })
|
|
1945
|
+
]
|
|
1946
|
+
}
|
|
1947
|
+
),
|
|
1948
|
+
infoMessage && /* @__PURE__ */ jsxs10(
|
|
1949
|
+
"div",
|
|
1950
|
+
{
|
|
1951
|
+
"data-slot": "alert",
|
|
1952
|
+
role: "status",
|
|
1953
|
+
className: slotClass("alert", "iuk-alert iuk-alert--success"),
|
|
1954
|
+
style: slotStyle("alert"),
|
|
1955
|
+
children: [
|
|
1956
|
+
/* @__PURE__ */ jsx10(CheckCircleIcon, { size: 16 }),
|
|
1957
|
+
/* @__PURE__ */ jsx10("span", { children: infoMessage })
|
|
1958
|
+
]
|
|
1959
|
+
}
|
|
1960
|
+
),
|
|
1961
|
+
showMissingAltWarning && missingAltCount > 0 && /* @__PURE__ */ jsxs10(
|
|
1962
|
+
"div",
|
|
1963
|
+
{
|
|
1964
|
+
"data-slot": "alert",
|
|
1965
|
+
role: "alert",
|
|
1966
|
+
className: slotClass("alert", "iuk-alert iuk-alert--warning"),
|
|
1967
|
+
style: slotStyle("alert"),
|
|
1968
|
+
children: [
|
|
1969
|
+
/* @__PURE__ */ jsx10(AlertTriangleIcon, { size: 16 }),
|
|
1970
|
+
/* @__PURE__ */ jsx10("span", { children: formatNeedsAltMessage(ui, missingAltCount, locale) })
|
|
1971
|
+
]
|
|
1972
|
+
}
|
|
1973
|
+
)
|
|
1974
|
+
] });
|
|
1975
|
+
}
|
|
1976
|
+
function MultiFooterSection({
|
|
1977
|
+
helperText,
|
|
1978
|
+
displayError,
|
|
1979
|
+
statusTextId,
|
|
1980
|
+
isOpen,
|
|
1981
|
+
hasPreviews,
|
|
1982
|
+
hasCompletedPreviews,
|
|
1983
|
+
isUploading,
|
|
1984
|
+
disabled,
|
|
1985
|
+
requireAltText,
|
|
1986
|
+
missingAltCount,
|
|
1987
|
+
onSave,
|
|
1988
|
+
ui,
|
|
1989
|
+
unstyled,
|
|
1990
|
+
providerClassNames,
|
|
1991
|
+
classNames,
|
|
1992
|
+
providerStyles,
|
|
1993
|
+
styles
|
|
1994
|
+
}) {
|
|
1995
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, unstyled, providerClassNames?.[slot], classNames?.[slot]);
|
|
1996
|
+
const slotStyle = (slot) => resolveSlotStyle(providerStyles?.[slot], styles?.[slot]);
|
|
1997
|
+
return /* @__PURE__ */ jsxs10(Fragment, { children: [
|
|
1998
|
+
(helperText || displayError) && /* @__PURE__ */ jsx10(
|
|
1999
|
+
"p",
|
|
2000
|
+
{
|
|
2001
|
+
id: statusTextId,
|
|
2002
|
+
role: displayError ? "alert" : void 0,
|
|
2003
|
+
"data-slot": displayError ? "error-text" : "helper-text",
|
|
2004
|
+
className: resolveSlotClass(
|
|
2005
|
+
cx("iuk-helper-text", Boolean(displayError) && "iuk-helper-text--error"),
|
|
2006
|
+
unstyled,
|
|
2007
|
+
providerClassNames?.helperText,
|
|
2008
|
+
classNames?.helperText,
|
|
2009
|
+
Boolean(displayError) && providerClassNames?.errorText,
|
|
2010
|
+
Boolean(displayError) && classNames?.errorText
|
|
2011
|
+
),
|
|
2012
|
+
style: resolveSlotStyle(
|
|
2013
|
+
providerStyles?.helperText,
|
|
2014
|
+
styles?.helperText,
|
|
2015
|
+
displayError ? providerStyles?.errorText : void 0,
|
|
2016
|
+
displayError ? styles?.errorText : void 0
|
|
2017
|
+
),
|
|
2018
|
+
children: displayError || helperText
|
|
2019
|
+
}
|
|
2020
|
+
),
|
|
2021
|
+
isOpen && hasPreviews && /* @__PURE__ */ jsxs10("div", { "data-slot": "commit-bar", className: slotClass("commitBar", "iuk-commit-bar"), style: slotStyle("commitBar"), children: [
|
|
2022
|
+
requireAltText && missingAltCount > 0 && /* @__PURE__ */ jsxs10("div", { className: resolveSlotClass("iuk-badge iuk-badge--warning", unstyled), children: [
|
|
2023
|
+
/* @__PURE__ */ jsx10(AlertTriangleIcon, { size: 13 }),
|
|
2024
|
+
/* @__PURE__ */ jsx10("span", { children: ui.withoutAltText.replace("{count}", String(missingAltCount)) })
|
|
2025
|
+
] }),
|
|
2026
|
+
/* @__PURE__ */ jsx10(
|
|
2027
|
+
SaveButton,
|
|
2028
|
+
{
|
|
2029
|
+
unstyled,
|
|
2030
|
+
className: slotClass("saveButton"),
|
|
2031
|
+
style: slotStyle("saveButton"),
|
|
2032
|
+
onClick: onSave,
|
|
2033
|
+
disabled: isUploading || disabled || !hasCompletedPreviews || requireAltText && missingAltCount > 0,
|
|
2034
|
+
icon: /* @__PURE__ */ jsx10(SaveIcon, { size: 16 }),
|
|
2035
|
+
children: ui.saveImages
|
|
2036
|
+
}
|
|
2037
|
+
)
|
|
2038
|
+
] })
|
|
2039
|
+
] });
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
// src/react/components/PreviewTile.tsx
|
|
2043
|
+
import { useMemo as useMemo5, useState as useState5 } from "react";
|
|
2044
|
+
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2045
|
+
function PreviewTile({
|
|
2046
|
+
preview,
|
|
2047
|
+
onRemove,
|
|
2048
|
+
onCancel,
|
|
2049
|
+
onRetry,
|
|
2050
|
+
disabled = false,
|
|
2051
|
+
blurType = "card",
|
|
2052
|
+
isSelected = false,
|
|
2053
|
+
onToggleSelect,
|
|
2054
|
+
onEditAltText,
|
|
2055
|
+
showCheckbox = true,
|
|
2056
|
+
onAdjustColor,
|
|
2057
|
+
onChangeColor,
|
|
2058
|
+
onChangeAltText,
|
|
2059
|
+
appendCacheBuster: appendBuster = false,
|
|
2060
|
+
locale: propLocale,
|
|
2061
|
+
translations,
|
|
2062
|
+
renderImage,
|
|
2063
|
+
unstyled: propUnstyled,
|
|
2064
|
+
className,
|
|
2065
|
+
style
|
|
2066
|
+
}) {
|
|
2067
|
+
const ctx = useImageUploadContext();
|
|
2068
|
+
const isUnstyled = propUnstyled ?? ctx.unstyled;
|
|
2069
|
+
const locale = normalizeUploadLocale(propLocale || ctx.locale);
|
|
2070
|
+
const ui = resolveTranslations(locale, translations || ctx.translations);
|
|
2071
|
+
const [showBlurModal, setShowBlurModal] = useState5(false);
|
|
2072
|
+
const cls = (defaultClass) => resolveSlotClass(defaultClass, isUnstyled);
|
|
2073
|
+
const isSvg = Boolean(
|
|
2074
|
+
preview.url?.toLowerCase().includes(".svg") || preview.data?.format === "svg" || preview.url?.includes("image/svg+xml")
|
|
2075
|
+
);
|
|
2076
|
+
const displayUrl = useMemo5(
|
|
2077
|
+
() => appendCacheBuster(preview.url, {
|
|
2078
|
+
enabled: appendBuster,
|
|
2079
|
+
token: preview.data?.contentHash || preview.data?.uploadedAt
|
|
2080
|
+
}),
|
|
2081
|
+
[preview.url, preview.data?.contentHash, preview.data?.uploadedAt, appendBuster]
|
|
2082
|
+
);
|
|
2083
|
+
const fallbackBlurDataURL = useBlurDataURL(preview.url, { type: blurType, size: "small" });
|
|
2084
|
+
const actualBlurDataUrl = preview.data?.blurDataUrl || fallbackBlurDataURL;
|
|
2085
|
+
const actualBlurColor = preview.blurColor || preview.data?.blurColor;
|
|
2086
|
+
const isUploading = Boolean(preview.isUploading);
|
|
2087
|
+
const hasError = Boolean(preview.error);
|
|
2088
|
+
const visualState = resolveUploadDataState({
|
|
2089
|
+
disabled,
|
|
2090
|
+
hasError,
|
|
2091
|
+
isUploading,
|
|
2092
|
+
hasContent: true
|
|
2093
|
+
});
|
|
2094
|
+
const isSuccess = Boolean(
|
|
2095
|
+
!isUploading && !hasError && preview.originalSize && preview.optimizedSize
|
|
2096
|
+
);
|
|
2097
|
+
const reductionPercent = isSuccess && preview.originalSize && preview.optimizedSize ? Math.round(
|
|
2098
|
+
(preview.originalSize - preview.optimizedSize) / preview.originalSize * 100
|
|
2099
|
+
) : 0;
|
|
2100
|
+
return /* @__PURE__ */ jsxs11(
|
|
2101
|
+
"div",
|
|
2102
|
+
{
|
|
2103
|
+
"data-slot": "tile",
|
|
2104
|
+
"data-state": visualState,
|
|
2105
|
+
"data-selected": isSelected || void 0,
|
|
2106
|
+
"data-uploading": isUploading || void 0,
|
|
2107
|
+
"data-error": hasError || void 0,
|
|
2108
|
+
className: resolveSlotClass(
|
|
2109
|
+
cx("iuk-tile", isSelected && "iuk-tile--selected", hasError && "iuk-tile--error"),
|
|
2110
|
+
isUnstyled,
|
|
2111
|
+
className
|
|
2112
|
+
),
|
|
2113
|
+
style,
|
|
2114
|
+
onClick: () => onToggleSelect && !disabled && onToggleSelect(preview.id),
|
|
2115
|
+
children: [
|
|
2116
|
+
/* @__PURE__ */ jsxs11("div", { "data-slot": "tile-media", className: cls("iuk-tile__media"), children: [
|
|
2117
|
+
/* @__PURE__ */ jsx11(
|
|
2118
|
+
BlurImage,
|
|
2119
|
+
{
|
|
2120
|
+
src: displayUrl,
|
|
2121
|
+
alt: preview.altText || ui.previewAlt,
|
|
2122
|
+
blurDataUrl: !isSvg ? actualBlurDataUrl : void 0,
|
|
2123
|
+
blurColor: actualBlurColor,
|
|
2124
|
+
blurHash: preview.data?.blurHash,
|
|
2125
|
+
objectFit: isSvg ? "contain" : "cover",
|
|
2126
|
+
style: isSvg ? { padding: "8px" } : void 0,
|
|
2127
|
+
renderImage
|
|
2128
|
+
}
|
|
2129
|
+
),
|
|
2130
|
+
showCheckbox && !disabled && !isUploading && onToggleSelect && /* @__PURE__ */ jsx11(
|
|
2131
|
+
"div",
|
|
2132
|
+
{
|
|
2133
|
+
"data-slot": "tile-checkbox",
|
|
2134
|
+
className: cls("iuk-tile__checkbox"),
|
|
2135
|
+
onClick: (e) => e.stopPropagation(),
|
|
2136
|
+
children: /* @__PURE__ */ jsx11(
|
|
2137
|
+
"input",
|
|
2138
|
+
{
|
|
2139
|
+
type: "checkbox",
|
|
2140
|
+
checked: isSelected,
|
|
2141
|
+
onChange: () => onToggleSelect(preview.id),
|
|
2142
|
+
"aria-label": ui.selectImageAria
|
|
2143
|
+
}
|
|
2144
|
+
)
|
|
2145
|
+
}
|
|
2146
|
+
),
|
|
2147
|
+
!disabled && onEditAltText && /* @__PURE__ */ jsx11(
|
|
2148
|
+
"button",
|
|
2149
|
+
{
|
|
2150
|
+
type: "button",
|
|
2151
|
+
"data-slot": "tile-alt-btn",
|
|
2152
|
+
className: cls(
|
|
2153
|
+
cx(
|
|
2154
|
+
"iuk-tile__action iuk-tile__action--alt",
|
|
2155
|
+
Boolean(preview.altText) && "iuk-tile__action--has-alt"
|
|
2156
|
+
)
|
|
2157
|
+
),
|
|
2158
|
+
onClick: (e) => {
|
|
2159
|
+
e.stopPropagation();
|
|
2160
|
+
onEditAltText(preview.id);
|
|
2161
|
+
},
|
|
2162
|
+
"aria-label": preview.altText ? ui.editAltTextAria : ui.addAltTextAria,
|
|
2163
|
+
title: preview.altText ? ui.editPrefix.replace("{title}", preview.altText) : ui.addDescriptionForA11y,
|
|
2164
|
+
children: preview.altText ? /* @__PURE__ */ jsx11(CheckCircleIcon, { size: 14 }) : /* @__PURE__ */ jsx11(TypeIcon, { size: 14 })
|
|
2165
|
+
}
|
|
2166
|
+
),
|
|
2167
|
+
!disabled && !isUploading && /* @__PURE__ */ jsx11(
|
|
2168
|
+
"button",
|
|
2169
|
+
{
|
|
2170
|
+
type: "button",
|
|
2171
|
+
"data-slot": "tile-blur-btn",
|
|
2172
|
+
className: cls("iuk-tile__action iuk-tile__action--blur"),
|
|
2173
|
+
onClick: (e) => {
|
|
2174
|
+
e.stopPropagation();
|
|
2175
|
+
if (onAdjustColor) onAdjustColor(preview.id);
|
|
2176
|
+
else setShowBlurModal(true);
|
|
2177
|
+
},
|
|
2178
|
+
"aria-label": ui.adjustBlurColorAria,
|
|
2179
|
+
title: ui.adjustBlurColorTitle,
|
|
2180
|
+
children: /* @__PURE__ */ jsx11(PaletteIcon, { size: 14 })
|
|
2181
|
+
}
|
|
2182
|
+
),
|
|
2183
|
+
!disabled && !isUploading && /* @__PURE__ */ jsx11(
|
|
2184
|
+
"button",
|
|
2185
|
+
{
|
|
2186
|
+
type: "button",
|
|
2187
|
+
"data-slot": "tile-remove-btn",
|
|
2188
|
+
className: cls("iuk-tile__action iuk-tile__action--remove"),
|
|
2189
|
+
onClick: (e) => {
|
|
2190
|
+
e.stopPropagation();
|
|
2191
|
+
onRemove(preview.id);
|
|
2192
|
+
},
|
|
2193
|
+
"aria-label": ui.removeImageAria,
|
|
2194
|
+
children: /* @__PURE__ */ jsx11(XIcon, { size: 15 })
|
|
2195
|
+
}
|
|
2196
|
+
),
|
|
2197
|
+
isUploading && /* @__PURE__ */ jsxs11("div", { "data-slot": "tile-overlay", className: cls("iuk-tile__overlay"), children: [
|
|
2198
|
+
/* @__PURE__ */ jsx11(LoaderIcon, { size: 24, className: cls("iuk-spin") }),
|
|
2199
|
+
/* @__PURE__ */ jsx11("p", { className: cls("iuk-tile__status"), children: preview.uploadMessage || `${ui.uploading}...` }),
|
|
2200
|
+
preview.progress !== void 0 && preview.progress > 0 && /* @__PURE__ */ jsx11(
|
|
2201
|
+
"div",
|
|
2202
|
+
{
|
|
2203
|
+
role: "progressbar",
|
|
2204
|
+
"aria-valuenow": Math.round(preview.progress),
|
|
2205
|
+
"aria-valuemin": 0,
|
|
2206
|
+
"aria-valuemax": 100,
|
|
2207
|
+
"aria-label": ui.uploading,
|
|
2208
|
+
className: cls("iuk-progress-bar"),
|
|
2209
|
+
children: /* @__PURE__ */ jsx11(
|
|
2210
|
+
"div",
|
|
2211
|
+
{
|
|
2212
|
+
className: cls("iuk-progress-bar__fill"),
|
|
2213
|
+
style: { width: `${preview.progress}%` }
|
|
2214
|
+
}
|
|
2215
|
+
)
|
|
2216
|
+
}
|
|
2217
|
+
),
|
|
2218
|
+
!disabled && /* @__PURE__ */ jsxs11(
|
|
2219
|
+
"button",
|
|
2220
|
+
{
|
|
2221
|
+
type: "button",
|
|
2222
|
+
"data-slot": "tile-cancel",
|
|
2223
|
+
className: cls("iuk-btn iuk-btn--secondary iuk-btn--sm iuk-tile__cancel-btn"),
|
|
2224
|
+
onClick: (e) => {
|
|
2225
|
+
e.stopPropagation();
|
|
2226
|
+
(onCancel ?? onRemove)(preview.id);
|
|
2227
|
+
},
|
|
2228
|
+
"aria-label": ui.cancelUpload,
|
|
2229
|
+
children: [
|
|
2230
|
+
/* @__PURE__ */ jsx11(XIcon, { size: 13 }),
|
|
2231
|
+
/* @__PURE__ */ jsx11("span", { children: ui.cancelUpload })
|
|
2232
|
+
]
|
|
2233
|
+
}
|
|
2234
|
+
)
|
|
2235
|
+
] }),
|
|
2236
|
+
isSuccess && /* @__PURE__ */ jsxs11("div", { "data-slot": "tile-badge", className: cls("iuk-tile__badge iuk-tile__badge--success"), children: [
|
|
2237
|
+
/* @__PURE__ */ jsx11(CheckCircleIcon, { size: 13 }),
|
|
2238
|
+
reductionPercent > 0 && /* @__PURE__ */ jsxs11("span", { children: [
|
|
2239
|
+
"-",
|
|
2240
|
+
reductionPercent,
|
|
2241
|
+
"%"
|
|
2242
|
+
] })
|
|
2243
|
+
] }),
|
|
2244
|
+
!disabled && !isUploading && !hasError && actualBlurColor && /* @__PURE__ */ jsxs11("div", { "data-slot": "tile-color-badge", className: cls("iuk-tile__badge iuk-tile__badge--color"), children: [
|
|
2245
|
+
/* @__PURE__ */ jsx11("span", { className: cls("iuk-tile__color-dot"), style: { backgroundColor: actualBlurColor } }),
|
|
2246
|
+
/* @__PURE__ */ jsx11("code", { children: actualBlurColor.toUpperCase() })
|
|
2247
|
+
] }),
|
|
2248
|
+
hasError && /* @__PURE__ */ jsxs11(
|
|
2249
|
+
"div",
|
|
2250
|
+
{
|
|
2251
|
+
"data-slot": "tile-error",
|
|
2252
|
+
role: "alert",
|
|
2253
|
+
className: cls("iuk-tile__overlay iuk-tile__overlay--error"),
|
|
2254
|
+
children: [
|
|
2255
|
+
/* @__PURE__ */ jsx11(XCircleIcon, { size: 22 }),
|
|
2256
|
+
/* @__PURE__ */ jsx11("p", { children: preview.error }),
|
|
2257
|
+
!disabled && onRetry && /* @__PURE__ */ jsx11(
|
|
2258
|
+
"button",
|
|
2259
|
+
{
|
|
2260
|
+
type: "button",
|
|
2261
|
+
"data-slot": "tile-retry",
|
|
2262
|
+
className: cls("iuk-btn iuk-btn--secondary iuk-btn--sm iuk-tile__retry-btn"),
|
|
2263
|
+
onClick: (e) => {
|
|
2264
|
+
e.stopPropagation();
|
|
2265
|
+
onRetry(preview.id);
|
|
2266
|
+
},
|
|
2267
|
+
"aria-label": ui.retryUpload,
|
|
2268
|
+
children: /* @__PURE__ */ jsx11("span", { children: ui.retryUpload })
|
|
2269
|
+
}
|
|
2270
|
+
)
|
|
2271
|
+
]
|
|
2272
|
+
}
|
|
2273
|
+
)
|
|
2274
|
+
] }),
|
|
2275
|
+
/* @__PURE__ */ jsx11(
|
|
2276
|
+
BlurVisualizationModal,
|
|
2277
|
+
{
|
|
2278
|
+
isOpen: showBlurModal,
|
|
2279
|
+
onClose: () => setShowBlurModal(false),
|
|
2280
|
+
imageUrl: preview.url,
|
|
2281
|
+
blurDataUrl: actualBlurDataUrl,
|
|
2282
|
+
blurColor: actualBlurColor,
|
|
2283
|
+
detectedColor: preview.data?.blurColor,
|
|
2284
|
+
altText: preview.altText,
|
|
2285
|
+
originalSize: preview.originalSize,
|
|
2286
|
+
optimizedSize: preview.optimizedSize,
|
|
2287
|
+
locale,
|
|
2288
|
+
translations,
|
|
2289
|
+
renderImage,
|
|
2290
|
+
unstyled: isUnstyled,
|
|
2291
|
+
onChangeColor: (hex) => onChangeColor?.(preview.id, hex),
|
|
2292
|
+
onUseDetectedColor: onChangeColor && preview.data?.blurColor ? () => onChangeColor(preview.id, preview.data.blurColor) : void 0,
|
|
2293
|
+
onChangeAltText: (nextAlt) => onChangeAltText?.(preview.id, nextAlt)
|
|
2294
|
+
}
|
|
2295
|
+
)
|
|
2296
|
+
]
|
|
2297
|
+
}
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
// src/react/components/QualitySelector.tsx
|
|
2302
|
+
import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2303
|
+
function formatBytesCompact(bytes) {
|
|
2304
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
2305
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
2306
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
2307
|
+
}
|
|
2308
|
+
function QualitySelector({
|
|
2309
|
+
value,
|
|
2310
|
+
onChange,
|
|
2311
|
+
preset,
|
|
2312
|
+
recommendedLevel,
|
|
2313
|
+
recommendationNote,
|
|
2314
|
+
originalFileSize,
|
|
2315
|
+
locale,
|
|
2316
|
+
translations,
|
|
2317
|
+
disabled = false,
|
|
2318
|
+
unstyled = false
|
|
2319
|
+
}) {
|
|
2320
|
+
const resolvedLocale = normalizeUploadLocale(locale);
|
|
2321
|
+
const isAr = resolvedLocale === "ar";
|
|
2322
|
+
const ui = resolveTranslations(resolvedLocale, translations);
|
|
2323
|
+
const cls = (defaultClass) => resolveSlotClass(defaultClass, unstyled);
|
|
2324
|
+
const standardPreset = preset ? STANDARD_PRESETS[preset] : void 0;
|
|
2325
|
+
const recommended = recommendedLevel || standardPreset?.recommendedQualityLevel || "high";
|
|
2326
|
+
const note = recommendationNote || standardPreset?.recommendationNote;
|
|
2327
|
+
const selected = QUALITY_PRESETS[value];
|
|
2328
|
+
const levels = Object.keys(QUALITY_PRESETS);
|
|
2329
|
+
const estimatedSize = originalFileSize !== void 0 ? estimateOutputSize(originalFileSize, value) : null;
|
|
2330
|
+
const saving = Math.round((1 - selected.compressionRatio) * 100);
|
|
2331
|
+
const handleRadioGroupKeyDown = (event) => {
|
|
2332
|
+
if (disabled) return;
|
|
2333
|
+
const currentIndex = Math.max(0, levels.indexOf(value));
|
|
2334
|
+
let nextIndex = -1;
|
|
2335
|
+
if (event.key === "ArrowRight" || event.key === "ArrowDown") {
|
|
2336
|
+
const step = event.key === "ArrowRight" && isAr ? -1 : 1;
|
|
2337
|
+
nextIndex = (currentIndex + step + levels.length) % levels.length;
|
|
2338
|
+
} else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
|
|
2339
|
+
const step = event.key === "ArrowLeft" && isAr ? 1 : -1;
|
|
2340
|
+
nextIndex = (currentIndex + step + levels.length) % levels.length;
|
|
2341
|
+
} else if (event.key === "Home") {
|
|
2342
|
+
nextIndex = 0;
|
|
2343
|
+
} else if (event.key === "End") {
|
|
2344
|
+
nextIndex = levels.length - 1;
|
|
2345
|
+
}
|
|
2346
|
+
if (nextIndex >= 0) {
|
|
2347
|
+
event.preventDefault();
|
|
2348
|
+
const nextLevel = levels[nextIndex];
|
|
2349
|
+
onChange(nextLevel);
|
|
2350
|
+
const buttons = event.currentTarget.querySelectorAll('[role="radio"]');
|
|
2351
|
+
buttons[nextIndex]?.focus();
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
return /* @__PURE__ */ jsxs12(
|
|
2355
|
+
"div",
|
|
2356
|
+
{
|
|
2357
|
+
"data-slot": "quality-root",
|
|
2358
|
+
"data-unstyled": unstyled || void 0,
|
|
2359
|
+
className: cls("iuk-quality"),
|
|
2360
|
+
dir: isAr ? "rtl" : "ltr",
|
|
2361
|
+
children: [
|
|
2362
|
+
/* @__PURE__ */ jsxs12("div", { className: cls("iuk-quality__header"), children: [
|
|
2363
|
+
/* @__PURE__ */ jsx12("span", { className: cls("iuk-quality__title"), children: ui.qualityTitle }),
|
|
2364
|
+
/* @__PURE__ */ jsxs12("span", { className: cls(`iuk-quality__pill iuk-quality__pill--${value}`), children: [
|
|
2365
|
+
isAr ? selected.labelAr : selected.label,
|
|
2366
|
+
" \xB7 Q",
|
|
2367
|
+
selected.value
|
|
2368
|
+
] })
|
|
2369
|
+
] }),
|
|
2370
|
+
/* @__PURE__ */ jsx12(
|
|
2371
|
+
"div",
|
|
2372
|
+
{
|
|
2373
|
+
className: cls("iuk-quality__tabs"),
|
|
2374
|
+
role: "radiogroup",
|
|
2375
|
+
"aria-label": ui.qualityLevelAria,
|
|
2376
|
+
onKeyDown: handleRadioGroupKeyDown,
|
|
2377
|
+
children: levels.map((level) => {
|
|
2378
|
+
const item = QUALITY_PRESETS[level];
|
|
2379
|
+
const isSelected = value === level;
|
|
2380
|
+
const isRecommended = level === recommended;
|
|
2381
|
+
return /* @__PURE__ */ jsxs12(
|
|
2382
|
+
"button",
|
|
2383
|
+
{
|
|
2384
|
+
type: "button",
|
|
2385
|
+
role: "radio",
|
|
2386
|
+
"aria-checked": isSelected,
|
|
2387
|
+
tabIndex: disabled ? -1 : isSelected ? 0 : -1,
|
|
2388
|
+
disabled,
|
|
2389
|
+
onClick: () => !disabled && onChange(level),
|
|
2390
|
+
className: cls(
|
|
2391
|
+
cx(
|
|
2392
|
+
"iuk-quality__tab",
|
|
2393
|
+
isSelected && "iuk-quality__tab--selected",
|
|
2394
|
+
isRecommended && !isSelected && "iuk-quality__tab--recommended",
|
|
2395
|
+
disabled && "iuk-quality__tab--disabled"
|
|
2396
|
+
)
|
|
2397
|
+
),
|
|
2398
|
+
children: [
|
|
2399
|
+
isSelected && /* @__PURE__ */ jsx12(CheckIcon, { size: 11, strokeWidth: 3, "aria-hidden": "true" }),
|
|
2400
|
+
/* @__PURE__ */ jsx12("span", { children: isAr ? item.labelAr : item.label }),
|
|
2401
|
+
isRecommended && !isSelected && /* @__PURE__ */ jsx12("span", { className: cls("iuk-quality__star"), "aria-hidden": "true", children: "\u2605" })
|
|
2402
|
+
]
|
|
2403
|
+
},
|
|
2404
|
+
level
|
|
2405
|
+
);
|
|
2406
|
+
})
|
|
2407
|
+
}
|
|
2408
|
+
),
|
|
2409
|
+
/* @__PURE__ */ jsxs12("div", { className: cls(`iuk-quality__detail iuk-quality__detail--${value}`), children: [
|
|
2410
|
+
/* @__PURE__ */ jsx12("p", { className: cls("iuk-quality__desc"), children: isAr ? selected.descriptionAr : selected.description }),
|
|
2411
|
+
/* @__PURE__ */ jsxs12("div", { className: cls("iuk-quality__meta"), children: [
|
|
2412
|
+
/* @__PURE__ */ jsxs12("span", { className: cls("iuk-quality__tag"), children: [
|
|
2413
|
+
"Q",
|
|
2414
|
+
selected.value
|
|
2415
|
+
] }),
|
|
2416
|
+
estimatedSize !== null && /* @__PURE__ */ jsxs12(Fragment2, { children: [
|
|
2417
|
+
/* @__PURE__ */ jsx12("span", { className: cls("iuk-quality__dot"), "aria-hidden": "true" }),
|
|
2418
|
+
/* @__PURE__ */ jsx12(ZapIcon, { size: 11, "aria-hidden": "true" }),
|
|
2419
|
+
/* @__PURE__ */ jsxs12("span", { children: [
|
|
2420
|
+
"~",
|
|
2421
|
+
formatBytesCompact(estimatedSize)
|
|
2422
|
+
] }),
|
|
2423
|
+
/* @__PURE__ */ jsx12("span", { className: cls("iuk-quality__dot"), "aria-hidden": "true" }),
|
|
2424
|
+
/* @__PURE__ */ jsxs12("span", { className: cls("iuk-quality__saving"), children: [
|
|
2425
|
+
saving,
|
|
2426
|
+
"% ",
|
|
2427
|
+
ui.qualitySaved
|
|
2428
|
+
] })
|
|
2429
|
+
] }),
|
|
2430
|
+
value === recommended && /* @__PURE__ */ jsxs12("span", { className: cls("iuk-quality__rec-badge"), children: [
|
|
2431
|
+
"\u2B50 ",
|
|
2432
|
+
ui.qualityRecommended
|
|
2433
|
+
] })
|
|
2434
|
+
] })
|
|
2435
|
+
] }),
|
|
2436
|
+
note && /* @__PURE__ */ jsxs12("div", { className: cls("iuk-quality__note"), children: [
|
|
2437
|
+
/* @__PURE__ */ jsx12(InfoIcon, { size: 12, "aria-hidden": "true", className: cls("iuk-quality__note-icon") }),
|
|
2438
|
+
/* @__PURE__ */ jsx12("span", { children: isAr ? note.ar || note.en : note.en })
|
|
2439
|
+
] })
|
|
2440
|
+
]
|
|
2441
|
+
}
|
|
2442
|
+
);
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
// src/react/components/UploadProgressPanel.tsx
|
|
2446
|
+
import { useEffect as useEffect7, useRef as useRef6, useState as useState6 } from "react";
|
|
2447
|
+
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2448
|
+
var PROGRESS_PANEL_DISMISS_DELAY_MS = 2500;
|
|
2449
|
+
function useRetainedProgressItems(uploadingPreviews, previews) {
|
|
2450
|
+
const [retainedItems, setRetainedItems] = useState6(null);
|
|
2451
|
+
const activeBatchRef = useRef6(/* @__PURE__ */ new Map());
|
|
2452
|
+
const dismissTimerRef = useRef6(null);
|
|
2453
|
+
const prevUploadingCountRef = useRef6(0);
|
|
2454
|
+
const isUploading = uploadingPreviews.length > 0;
|
|
2455
|
+
useEffect7(() => {
|
|
2456
|
+
if (isUploading) {
|
|
2457
|
+
if (dismissTimerRef.current) {
|
|
2458
|
+
clearTimeout(dismissTimerRef.current);
|
|
2459
|
+
dismissTimerRef.current = null;
|
|
2460
|
+
activeBatchRef.current.clear();
|
|
2461
|
+
}
|
|
2462
|
+
setRetainedItems(null);
|
|
2463
|
+
for (const p2 of uploadingPreviews) {
|
|
2464
|
+
activeBatchRef.current.set(p2.id, {
|
|
2465
|
+
id: p2.id,
|
|
2466
|
+
url: p2.url,
|
|
2467
|
+
fileName: p2.fileName || p2.file?.name,
|
|
2468
|
+
message: p2.uploadMessage || void 0,
|
|
2469
|
+
progress: p2.progress
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
} else if (prevUploadingCountRef.current > 0 && activeBatchRef.current.size > 0) {
|
|
2473
|
+
const completed = Array.from(activeBatchRef.current.values()).map((it) => {
|
|
2474
|
+
const found = previews.find((p2) => p2.id === it.id);
|
|
2475
|
+
return {
|
|
2476
|
+
...it,
|
|
2477
|
+
progress: found?.progress ?? 100,
|
|
2478
|
+
message: found?.error ? found.error : found?.uploadMessage || void 0
|
|
2479
|
+
};
|
|
2480
|
+
});
|
|
2481
|
+
setRetainedItems(completed);
|
|
2482
|
+
dismissTimerRef.current = setTimeout(() => {
|
|
2483
|
+
setRetainedItems(null);
|
|
2484
|
+
activeBatchRef.current.clear();
|
|
2485
|
+
dismissTimerRef.current = null;
|
|
2486
|
+
}, PROGRESS_PANEL_DISMISS_DELAY_MS);
|
|
2487
|
+
}
|
|
2488
|
+
prevUploadingCountRef.current = uploadingPreviews.length;
|
|
2489
|
+
}, [isUploading, uploadingPreviews, previews]);
|
|
2490
|
+
useEffect7(() => () => {
|
|
2491
|
+
if (dismissTimerRef.current) clearTimeout(dismissTimerRef.current);
|
|
2492
|
+
}, []);
|
|
2493
|
+
return isUploading ? uploadingPreviews.map((p2) => ({
|
|
2494
|
+
id: p2.id,
|
|
2495
|
+
url: p2.url,
|
|
2496
|
+
fileName: p2.fileName || p2.file?.name,
|
|
2497
|
+
message: p2.uploadMessage || void 0,
|
|
2498
|
+
progress: p2.progress
|
|
2499
|
+
})) : retainedItems ?? [];
|
|
2500
|
+
}
|
|
2501
|
+
function UploadProgressPanel({
|
|
2502
|
+
items,
|
|
2503
|
+
completedCount,
|
|
2504
|
+
totalCount,
|
|
2505
|
+
locale: propLocale,
|
|
2506
|
+
translations,
|
|
2507
|
+
renderImage,
|
|
2508
|
+
unstyled: propUnstyled
|
|
2509
|
+
}) {
|
|
2510
|
+
const ctx = useImageUploadContext();
|
|
2511
|
+
const isUnstyled = propUnstyled ?? ctx.unstyled;
|
|
2512
|
+
const locale = normalizeUploadLocale(propLocale || ctx.locale);
|
|
2513
|
+
const effectiveOverrides = translations || ctx.translations;
|
|
2514
|
+
const ui = resolveTranslations(locale, effectiveOverrides);
|
|
2515
|
+
const [isMinimized, setIsMinimized] = useState6(false);
|
|
2516
|
+
const uploadingCount = items.length;
|
|
2517
|
+
const cls = (defaultClass) => resolveSlotClass(defaultClass, isUnstyled);
|
|
2518
|
+
if (uploadingCount === 0) return null;
|
|
2519
|
+
return /* @__PURE__ */ jsx13(
|
|
2520
|
+
"div",
|
|
2521
|
+
{
|
|
2522
|
+
"data-upload-progress-dock": true,
|
|
2523
|
+
"data-slot": "progress-dock",
|
|
2524
|
+
"data-unstyled": isUnstyled || void 0,
|
|
2525
|
+
dir: locale === "ar" ? "rtl" : "ltr",
|
|
2526
|
+
className: cls(
|
|
2527
|
+
cx("iuk-progress-dock", isMinimized && "iuk-progress-dock--collapsed")
|
|
2528
|
+
),
|
|
2529
|
+
children: /* @__PURE__ */ jsxs13(
|
|
2530
|
+
"div",
|
|
2531
|
+
{
|
|
2532
|
+
className: cls(
|
|
2533
|
+
cx("iuk-progress-panel", isMinimized && "iuk-progress-panel--minimized")
|
|
2534
|
+
),
|
|
2535
|
+
children: [
|
|
2536
|
+
/* @__PURE__ */ jsxs13(
|
|
2537
|
+
"button",
|
|
2538
|
+
{
|
|
2539
|
+
type: "button",
|
|
2540
|
+
className: cls("iuk-progress-panel__header"),
|
|
2541
|
+
"aria-expanded": !isMinimized,
|
|
2542
|
+
onClick: () => setIsMinimized((prev) => !prev),
|
|
2543
|
+
children: [
|
|
2544
|
+
/* @__PURE__ */ jsxs13("span", { className: cls("iuk-progress-panel__title"), children: [
|
|
2545
|
+
/* @__PURE__ */ jsx13(LoaderIcon, { size: 16, className: cls("iuk-spin") }),
|
|
2546
|
+
/* @__PURE__ */ jsx13("span", { children: formatUploadingCount(ui, uploadingCount, locale, effectiveOverrides) }),
|
|
2547
|
+
totalCount > 0 && /* @__PURE__ */ jsxs13("span", { className: cls("iuk-progress-panel__count"), children: [
|
|
2548
|
+
"(",
|
|
2549
|
+
completedCount,
|
|
2550
|
+
"/",
|
|
2551
|
+
totalCount,
|
|
2552
|
+
")"
|
|
2553
|
+
] })
|
|
2554
|
+
] }),
|
|
2555
|
+
isMinimized ? /* @__PURE__ */ jsx13(ChevronUpIcon, { size: 18 }) : /* @__PURE__ */ jsx13(ChevronDownIcon, { size: 18 })
|
|
2556
|
+
]
|
|
2557
|
+
}
|
|
2558
|
+
),
|
|
2559
|
+
!isMinimized && /* @__PURE__ */ jsx13("div", { className: cls("iuk-progress-panel__body"), children: items.map((item) => /* @__PURE__ */ jsxs13("div", { className: cls("iuk-progress-item"), children: [
|
|
2560
|
+
/* @__PURE__ */ jsx13("div", { className: cls("iuk-progress-item__thumb"), children: /* @__PURE__ */ jsx13(
|
|
2561
|
+
BlurImage,
|
|
2562
|
+
{
|
|
2563
|
+
src: item.url,
|
|
2564
|
+
alt: ui.uploadingAlt,
|
|
2565
|
+
objectFit: "cover",
|
|
2566
|
+
renderImage
|
|
2567
|
+
}
|
|
2568
|
+
) }),
|
|
2569
|
+
/* @__PURE__ */ jsxs13("div", { className: cls("iuk-progress-item__info"), children: [
|
|
2570
|
+
/* @__PURE__ */ jsx13("div", { className: cls("iuk-progress-item__name"), children: item.fileName || ui.image }),
|
|
2571
|
+
/* @__PURE__ */ jsx13("div", { className: cls("iuk-progress-item__status"), children: item.message || ui.processing }),
|
|
2572
|
+
item.progress !== void 0 && item.progress > 0 && /* @__PURE__ */ jsx13(
|
|
2573
|
+
"div",
|
|
2574
|
+
{
|
|
2575
|
+
role: "progressbar",
|
|
2576
|
+
"aria-valuenow": Math.round(item.progress),
|
|
2577
|
+
"aria-valuemin": 0,
|
|
2578
|
+
"aria-valuemax": 100,
|
|
2579
|
+
"aria-label": item.fileName || ui.uploading,
|
|
2580
|
+
className: cls("iuk-progress-bar"),
|
|
2581
|
+
children: /* @__PURE__ */ jsx13(
|
|
2582
|
+
"div",
|
|
2583
|
+
{
|
|
2584
|
+
className: cls("iuk-progress-bar__fill"),
|
|
2585
|
+
style: { width: `${item.progress}%` }
|
|
2586
|
+
}
|
|
2587
|
+
)
|
|
2588
|
+
}
|
|
2589
|
+
)
|
|
2590
|
+
] })
|
|
2591
|
+
] }, item.id)) })
|
|
2592
|
+
]
|
|
2593
|
+
}
|
|
2594
|
+
)
|
|
2595
|
+
}
|
|
2596
|
+
);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
// src/react/components/MultiImageUpload.tsx
|
|
2600
|
+
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2601
|
+
var DEFAULT_ACCEPT = "image/jpeg,image/png,image/webp,image/avif,image/svg+xml";
|
|
2602
|
+
var FOLDER_INPUT_ATTRS = { webkitdirectory: "", directory: "" };
|
|
2603
|
+
function MultiImageUploadInner(props, ref) {
|
|
2604
|
+
const {
|
|
2605
|
+
preset,
|
|
2606
|
+
translations,
|
|
2607
|
+
renderImage,
|
|
2608
|
+
label,
|
|
2609
|
+
error,
|
|
2610
|
+
helperText,
|
|
2611
|
+
className,
|
|
2612
|
+
style,
|
|
2613
|
+
recommendedQuality,
|
|
2614
|
+
qualityNote,
|
|
2615
|
+
isOpen,
|
|
2616
|
+
maxImages = 999,
|
|
2617
|
+
accept = DEFAULT_ACCEPT,
|
|
2618
|
+
allowFolder = true,
|
|
2619
|
+
disabled = false,
|
|
2620
|
+
required = false,
|
|
2621
|
+
blurType = "card",
|
|
2622
|
+
showQualitySelector = true,
|
|
2623
|
+
capture,
|
|
2624
|
+
enablePaste = true,
|
|
2625
|
+
pasteTarget = "dropzone",
|
|
2626
|
+
name,
|
|
2627
|
+
onBlur,
|
|
2628
|
+
classNames: cCls,
|
|
2629
|
+
styles: cSty,
|
|
2630
|
+
renderHeader,
|
|
2631
|
+
renderEmptyDropzone,
|
|
2632
|
+
renderTile,
|
|
2633
|
+
renderAddMore
|
|
2634
|
+
} = props;
|
|
2635
|
+
const ctx = useImageUploadContext();
|
|
2636
|
+
const isUnstyled = props.unstyled ?? ctx.unstyled;
|
|
2637
|
+
const pCls = ctx.multiClassNames;
|
|
2638
|
+
const pSty = ctx.multiStyles;
|
|
2639
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, isUnstyled, pCls?.[slot], cCls?.[slot]);
|
|
2640
|
+
const slotStyle = (slot) => resolveSlotStyle(pSty?.[slot], cSty?.[slot]);
|
|
2641
|
+
const state = useMultiImageState(props);
|
|
2642
|
+
const { locale, ui, previews, selectedPreviews, uploadingPreviews, imagesWithoutAlt, editingTarget } = state;
|
|
2643
|
+
const rootRef = useRef7(null);
|
|
2644
|
+
const labelId = useId4();
|
|
2645
|
+
const inputId = useId4();
|
|
2646
|
+
const statusTextId = useId4();
|
|
2647
|
+
const fileInputRef = useRef7(null);
|
|
2648
|
+
const folderInputRef = useRef7(null);
|
|
2649
|
+
const dockItems = useRetainedProgressItems(uploadingPreviews, previews);
|
|
2650
|
+
const { isDragging, dragHandlers } = useDragAndDrop({
|
|
2651
|
+
disabled,
|
|
2652
|
+
onDrop: (files) => void state.handleFileSelect(files)
|
|
2653
|
+
});
|
|
2654
|
+
const { onPaste } = useClipboardPaste({
|
|
2655
|
+
enabled: enablePaste,
|
|
2656
|
+
pasteTarget,
|
|
2657
|
+
disabled,
|
|
2658
|
+
multiple: true,
|
|
2659
|
+
onPasteFiles: (files) => {
|
|
2660
|
+
void state.handleFileSelect(files);
|
|
2661
|
+
}
|
|
2662
|
+
});
|
|
2663
|
+
const openFilePicker = () => {
|
|
2664
|
+
if (!disabled) fileInputRef.current?.click();
|
|
2665
|
+
};
|
|
2666
|
+
const openFolderPicker = () => {
|
|
2667
|
+
if (!disabled) folderInputRef.current?.click();
|
|
2668
|
+
};
|
|
2669
|
+
const selectAll = () => state.setSelectedPreviews(new Set(previews.map((p2) => p2.id)));
|
|
2670
|
+
const clearSelection = () => state.setSelectedPreviews(/* @__PURE__ */ new Set());
|
|
2671
|
+
const retryFailed = () => void state.handleRetryFailed();
|
|
2672
|
+
useImperativeHandle(ref, () => ({
|
|
2673
|
+
focus: () => {
|
|
2674
|
+
const focusable = rootRef.current?.querySelector(
|
|
2675
|
+
'[data-slot="empty-dropzone"], [data-slot="empty-actions"] button, [data-slot="add-more"] button'
|
|
2676
|
+
);
|
|
2677
|
+
(focusable ?? rootRef.current)?.focus();
|
|
2678
|
+
},
|
|
2679
|
+
open: openFilePicker,
|
|
2680
|
+
clear: () => state.handleClearAll()
|
|
2681
|
+
}));
|
|
2682
|
+
const handleFilesInputChange = (e) => {
|
|
2683
|
+
if (e.target.files && e.target.files.length > 0) void state.handleFileSelect(e.target.files);
|
|
2684
|
+
e.target.value = "";
|
|
2685
|
+
};
|
|
2686
|
+
const displayError = error || state.validationError;
|
|
2687
|
+
const hasError = Boolean(displayError) || state.hasFailedUploads;
|
|
2688
|
+
const hasStatusText = Boolean(helperText || displayError);
|
|
2689
|
+
const visualState = resolveUploadDataState({
|
|
2690
|
+
disabled,
|
|
2691
|
+
hasError,
|
|
2692
|
+
isUploading: state.isUploading,
|
|
2693
|
+
isDragging,
|
|
2694
|
+
hasContent: previews.length > 0
|
|
2695
|
+
});
|
|
2696
|
+
const dropzoneProps = {
|
|
2697
|
+
...dragHandlers,
|
|
2698
|
+
onPaste,
|
|
2699
|
+
role: "button",
|
|
2700
|
+
tabIndex: disabled ? -1 : 0,
|
|
2701
|
+
"aria-label": ui.selectFilesAria,
|
|
2702
|
+
"aria-disabled": disabled || void 0,
|
|
2703
|
+
"aria-required": required || void 0,
|
|
2704
|
+
"aria-invalid": hasError || void 0,
|
|
2705
|
+
"aria-describedby": hasStatusText ? statusTextId : void 0,
|
|
2706
|
+
"data-state": visualState,
|
|
2707
|
+
onClick: () => {
|
|
2708
|
+
if (!disabled) openFilePicker();
|
|
2709
|
+
},
|
|
2710
|
+
onKeyDown: (event) => {
|
|
2711
|
+
if (!disabled && (event.key === "Enter" || event.key === " ")) {
|
|
2712
|
+
event.preventDefault();
|
|
2713
|
+
openFilePicker();
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
};
|
|
2717
|
+
const slotStylingProps = {
|
|
2718
|
+
unstyled: isUnstyled,
|
|
2719
|
+
providerClassNames: pCls,
|
|
2720
|
+
classNames: cCls,
|
|
2721
|
+
providerStyles: pSty,
|
|
2722
|
+
styles: cSty
|
|
2723
|
+
};
|
|
2724
|
+
const hiddenInputClass = resolveSlotClass("iuk-hidden-input", isUnstyled);
|
|
2725
|
+
const hiddenInputStyle = isUnstyled ? HIDDEN_INPUT_STYLE : void 0;
|
|
2726
|
+
return /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
2727
|
+
/* @__PURE__ */ jsxs14(
|
|
2728
|
+
"div",
|
|
2729
|
+
{
|
|
2730
|
+
ref: rootRef,
|
|
2731
|
+
"data-slot": "multi-root",
|
|
2732
|
+
"data-state": visualState,
|
|
2733
|
+
"data-unstyled": isUnstyled || void 0,
|
|
2734
|
+
className: resolveSlotClass("iuk-multi", isUnstyled, pCls?.root, cCls?.root, className),
|
|
2735
|
+
style: resolveSlotStyle(pSty?.root, cSty?.root, style),
|
|
2736
|
+
dir: locale === "ar" ? "rtl" : "ltr",
|
|
2737
|
+
onPaste,
|
|
2738
|
+
onBlur: onBlur ? (e) => {
|
|
2739
|
+
if (!e.currentTarget.contains(e.relatedTarget)) onBlur();
|
|
2740
|
+
} : void 0,
|
|
2741
|
+
children: [
|
|
2742
|
+
name && /* @__PURE__ */ jsx14("input", { type: "hidden", name, value: state.serializedFormValue, required, "data-slot": "form-input" }),
|
|
2743
|
+
renderHeader ? renderHeader({
|
|
2744
|
+
label,
|
|
2745
|
+
required,
|
|
2746
|
+
disabled,
|
|
2747
|
+
totalCount: previews.length,
|
|
2748
|
+
selectedCount: selectedPreviews.size,
|
|
2749
|
+
uploadingCount: uploadingPreviews.length,
|
|
2750
|
+
isUploading: state.isUploading,
|
|
2751
|
+
hasFailedUploads: state.hasFailedUploads,
|
|
2752
|
+
selectAll,
|
|
2753
|
+
clearSelection,
|
|
2754
|
+
removeSelected: state.handleRemoveSelected,
|
|
2755
|
+
retryFailed,
|
|
2756
|
+
locale,
|
|
2757
|
+
ui
|
|
2758
|
+
}) : /* @__PURE__ */ jsx14(
|
|
2759
|
+
MultiUploadHeaderAlerts,
|
|
2760
|
+
{
|
|
2761
|
+
label,
|
|
2762
|
+
labelId,
|
|
2763
|
+
inputId,
|
|
2764
|
+
required,
|
|
2765
|
+
disabled,
|
|
2766
|
+
totalCount: previews.length,
|
|
2767
|
+
selectedCount: selectedPreviews.size,
|
|
2768
|
+
uploadingCount: uploadingPreviews.length,
|
|
2769
|
+
missingAltCount: imagesWithoutAlt.length,
|
|
2770
|
+
isUploading: state.isUploading,
|
|
2771
|
+
hasFailedUploads: state.hasFailedUploads,
|
|
2772
|
+
infoMessage: state.infoMessage,
|
|
2773
|
+
showMissingAltWarning: state.showMissingAltWarning,
|
|
2774
|
+
uploadStats: state.uploadStats,
|
|
2775
|
+
locale,
|
|
2776
|
+
translations,
|
|
2777
|
+
ui,
|
|
2778
|
+
onSelectAll: selectAll,
|
|
2779
|
+
onDeselectAll: clearSelection,
|
|
2780
|
+
onRemoveSelected: state.handleRemoveSelected,
|
|
2781
|
+
onRetryFailed: retryFailed,
|
|
2782
|
+
...slotStylingProps
|
|
2783
|
+
}
|
|
2784
|
+
),
|
|
2785
|
+
showQualitySelector && /* @__PURE__ */ jsx14("div", { "data-slot": "quality-selector", className: slotClass("qualitySelector"), style: slotStyle("qualitySelector"), children: /* @__PURE__ */ jsx14(
|
|
2786
|
+
QualitySelector,
|
|
2787
|
+
{
|
|
2788
|
+
value: state.qualityLevel,
|
|
2789
|
+
onChange: state.setQualityLevel,
|
|
2790
|
+
preset,
|
|
2791
|
+
recommendedLevel: recommendedQuality,
|
|
2792
|
+
recommendationNote: qualityNote,
|
|
2793
|
+
locale,
|
|
2794
|
+
disabled: state.isUploading || disabled,
|
|
2795
|
+
unstyled: isUnstyled
|
|
2796
|
+
}
|
|
2797
|
+
) }),
|
|
2798
|
+
/* @__PURE__ */ jsx14(
|
|
2799
|
+
"input",
|
|
2800
|
+
{
|
|
2801
|
+
id: inputId,
|
|
2802
|
+
ref: fileInputRef,
|
|
2803
|
+
type: "file",
|
|
2804
|
+
accept,
|
|
2805
|
+
capture,
|
|
2806
|
+
onChange: handleFilesInputChange,
|
|
2807
|
+
className: hiddenInputClass,
|
|
2808
|
+
style: hiddenInputStyle,
|
|
2809
|
+
disabled,
|
|
2810
|
+
multiple: true,
|
|
2811
|
+
"aria-label": ui.selectFilesAria,
|
|
2812
|
+
"aria-invalid": hasError || void 0,
|
|
2813
|
+
"aria-describedby": hasStatusText ? statusTextId : void 0
|
|
2814
|
+
}
|
|
2815
|
+
),
|
|
2816
|
+
/* @__PURE__ */ jsx14(
|
|
2817
|
+
"input",
|
|
2818
|
+
{
|
|
2819
|
+
ref: folderInputRef,
|
|
2820
|
+
type: "file",
|
|
2821
|
+
accept,
|
|
2822
|
+
onChange: handleFilesInputChange,
|
|
2823
|
+
className: hiddenInputClass,
|
|
2824
|
+
style: hiddenInputStyle,
|
|
2825
|
+
disabled,
|
|
2826
|
+
...FOLDER_INPUT_ATTRS,
|
|
2827
|
+
"aria-label": ui.selectFolderAria
|
|
2828
|
+
}
|
|
2829
|
+
),
|
|
2830
|
+
previews.length === 0 ? renderEmptyDropzone ? renderEmptyDropzone({
|
|
2831
|
+
state: visualState,
|
|
2832
|
+
isDragging,
|
|
2833
|
+
disabled,
|
|
2834
|
+
allowFolder,
|
|
2835
|
+
maxSizeMB: state.maxSizeMB,
|
|
2836
|
+
maxImages,
|
|
2837
|
+
error: displayError || void 0,
|
|
2838
|
+
openFileDialog: openFilePicker,
|
|
2839
|
+
openFolderDialog: openFolderPicker,
|
|
2840
|
+
dropzoneProps,
|
|
2841
|
+
locale,
|
|
2842
|
+
ui
|
|
2843
|
+
}) : /* @__PURE__ */ jsx14(
|
|
2844
|
+
MultiEmptyDropzone,
|
|
2845
|
+
{
|
|
2846
|
+
isDragging,
|
|
2847
|
+
disabled,
|
|
2848
|
+
hasError: Boolean(displayError),
|
|
2849
|
+
required,
|
|
2850
|
+
enablePaste,
|
|
2851
|
+
visualState,
|
|
2852
|
+
allowFolder,
|
|
2853
|
+
maxSizeMB: state.maxSizeMB,
|
|
2854
|
+
ui,
|
|
2855
|
+
dragHandlers,
|
|
2856
|
+
onPaste,
|
|
2857
|
+
onSelectFiles: openFilePicker,
|
|
2858
|
+
onSelectFolder: openFolderPicker,
|
|
2859
|
+
...slotStylingProps
|
|
2860
|
+
}
|
|
2861
|
+
) : /* @__PURE__ */ jsxs14("div", { "data-slot": "grid", className: slotClass("grid", "iuk-multi__grid"), style: slotStyle("grid"), children: [
|
|
2862
|
+
previews.map(
|
|
2863
|
+
(item, index) => renderTile ? /* @__PURE__ */ jsx14(Fragment3, { children: renderTile({
|
|
2864
|
+
item,
|
|
2865
|
+
index,
|
|
2866
|
+
isSelected: selectedPreviews.has(item.id),
|
|
2867
|
+
disabled,
|
|
2868
|
+
toggleSelect: () => state.toggleSelect(item.id),
|
|
2869
|
+
remove: () => state.handleRemove(item.id),
|
|
2870
|
+
cancel: () => state.handleCancelUpload(item.id),
|
|
2871
|
+
retry: () => void state.handleRetryUpload(item.id),
|
|
2872
|
+
openAltTextModal: () => state.setEditingAltTextId(item.id),
|
|
2873
|
+
setAltText: (altText) => state.handleAltTextSave(item.id, altText),
|
|
2874
|
+
setBlurColor: (hex) => state.handleColorChange(item.id, hex),
|
|
2875
|
+
locale,
|
|
2876
|
+
ui
|
|
2877
|
+
}) }, item.id) : /* @__PURE__ */ jsx14(
|
|
2878
|
+
PreviewTile,
|
|
2879
|
+
{
|
|
2880
|
+
preview: item,
|
|
2881
|
+
onRemove: state.handleRemove,
|
|
2882
|
+
onCancel: state.handleCancelUpload,
|
|
2883
|
+
onRetry: (id) => void state.handleRetryUpload(id),
|
|
2884
|
+
disabled,
|
|
2885
|
+
blurType,
|
|
2886
|
+
isSelected: selectedPreviews.has(item.id),
|
|
2887
|
+
onToggleSelect: state.toggleSelect,
|
|
2888
|
+
onEditAltText: (id) => state.setEditingAltTextId(id),
|
|
2889
|
+
onChangeAltText: state.handleAltTextSave,
|
|
2890
|
+
onChangeColor: state.handleColorChange,
|
|
2891
|
+
locale,
|
|
2892
|
+
translations,
|
|
2893
|
+
renderImage,
|
|
2894
|
+
unstyled: isUnstyled,
|
|
2895
|
+
className: slotClass("tile"),
|
|
2896
|
+
style: slotStyle("tile")
|
|
2897
|
+
},
|
|
2898
|
+
item.id
|
|
2899
|
+
)
|
|
2900
|
+
),
|
|
2901
|
+
renderAddMore ? renderAddMore({
|
|
2902
|
+
isDragging,
|
|
2903
|
+
disabled,
|
|
2904
|
+
allowFolder,
|
|
2905
|
+
remainingCount: Math.max(0, maxImages - previews.length),
|
|
2906
|
+
openFileDialog: openFilePicker,
|
|
2907
|
+
openFolderDialog: openFolderPicker,
|
|
2908
|
+
dropzoneProps,
|
|
2909
|
+
locale,
|
|
2910
|
+
ui
|
|
2911
|
+
}) : /* @__PURE__ */ jsx14(
|
|
2912
|
+
MultiAddMoreTile,
|
|
2913
|
+
{
|
|
2914
|
+
isDragging,
|
|
2915
|
+
disabled,
|
|
2916
|
+
allowFolder,
|
|
2917
|
+
ui,
|
|
2918
|
+
dragHandlers,
|
|
2919
|
+
onSelectFiles: openFilePicker,
|
|
2920
|
+
onSelectFolder: openFolderPicker,
|
|
2921
|
+
...slotStylingProps
|
|
2922
|
+
}
|
|
2923
|
+
)
|
|
2924
|
+
] }),
|
|
2925
|
+
/* @__PURE__ */ jsx14(
|
|
2926
|
+
MultiFooterSection,
|
|
2927
|
+
{
|
|
2928
|
+
helperText,
|
|
2929
|
+
displayError,
|
|
2930
|
+
statusTextId,
|
|
2931
|
+
isOpen,
|
|
2932
|
+
hasPreviews: previews.length > 0,
|
|
2933
|
+
hasCompletedPreviews: state.completedPreviews.length > 0,
|
|
2934
|
+
isUploading: state.isUploading,
|
|
2935
|
+
disabled,
|
|
2936
|
+
requireAltText: state.requireAltText,
|
|
2937
|
+
missingAltCount: imagesWithoutAlt.length,
|
|
2938
|
+
onSave: state.handleSaveImages,
|
|
2939
|
+
ui,
|
|
2940
|
+
...slotStylingProps
|
|
2941
|
+
}
|
|
2942
|
+
)
|
|
2943
|
+
]
|
|
2944
|
+
}
|
|
2945
|
+
),
|
|
2946
|
+
editingTarget && /* @__PURE__ */ jsx14(
|
|
2947
|
+
AltTextModal,
|
|
2948
|
+
{
|
|
2949
|
+
imageUrl: editingTarget.url,
|
|
2950
|
+
initialAltText: editingTarget.altText,
|
|
2951
|
+
onSave: (nextAlt) => state.handleAltTextSave(editingTarget.id, nextAlt),
|
|
2952
|
+
onClose: () => state.setEditingAltTextId(null),
|
|
2953
|
+
locale,
|
|
2954
|
+
translations,
|
|
2955
|
+
renderImage,
|
|
2956
|
+
unstyled: isUnstyled
|
|
2957
|
+
}
|
|
2958
|
+
),
|
|
2959
|
+
typeof document !== "undefined" && dockItems.length > 0 && createPortal3(
|
|
2960
|
+
/* @__PURE__ */ jsx14(
|
|
2961
|
+
UploadProgressPanel,
|
|
2962
|
+
{
|
|
2963
|
+
items: dockItems,
|
|
2964
|
+
completedCount: state.uploadStats.completed,
|
|
2965
|
+
totalCount: state.uploadStats.total,
|
|
2966
|
+
locale,
|
|
2967
|
+
translations,
|
|
2968
|
+
renderImage,
|
|
2969
|
+
unstyled: isUnstyled
|
|
2970
|
+
}
|
|
2971
|
+
),
|
|
2972
|
+
document.body
|
|
2973
|
+
)
|
|
2974
|
+
] });
|
|
2975
|
+
}
|
|
2976
|
+
var MultiImageUpload = forwardRef(MultiImageUploadInner);
|
|
2977
|
+
|
|
2978
|
+
// src/react/components/SingleImageUpload.tsx
|
|
2979
|
+
import {
|
|
2980
|
+
forwardRef as forwardRef2,
|
|
2981
|
+
useId as useId5,
|
|
2982
|
+
useImperativeHandle as useImperativeHandle2,
|
|
2983
|
+
useRef as useRef8
|
|
2984
|
+
} from "react";
|
|
2985
|
+
|
|
2986
|
+
// src/react/components/SingleDropzoneContent.tsx
|
|
2987
|
+
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2988
|
+
function formatCompactBytes(bytes) {
|
|
2989
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
2990
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
2991
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
2992
|
+
}
|
|
2993
|
+
function resolveSingleDropzoneSlot(flags, styling) {
|
|
2994
|
+
const { isDragging, hasPreview, disabled, hasError } = flags;
|
|
2995
|
+
const { unstyled, providerClassNames: pCls, classNames: cCls, providerStyles: pSty, styles: cSty } = styling;
|
|
2996
|
+
return {
|
|
2997
|
+
className: resolveSlotClass(
|
|
2998
|
+
cx(
|
|
2999
|
+
"iuk-dropzone",
|
|
3000
|
+
isDragging && "iuk-dropzone--dragging",
|
|
3001
|
+
hasPreview && "iuk-dropzone--has-image",
|
|
3002
|
+
disabled && "iuk-dropzone--disabled",
|
|
3003
|
+
hasError && "iuk-dropzone--error"
|
|
3004
|
+
),
|
|
3005
|
+
unstyled,
|
|
3006
|
+
pCls?.dropzone,
|
|
3007
|
+
cCls?.dropzone,
|
|
3008
|
+
isDragging && pCls?.dropzoneDragging,
|
|
3009
|
+
isDragging && cCls?.dropzoneDragging,
|
|
3010
|
+
hasPreview && pCls?.dropzoneHasImage,
|
|
3011
|
+
hasPreview && cCls?.dropzoneHasImage,
|
|
3012
|
+
disabled && pCls?.dropzoneDisabled,
|
|
3013
|
+
disabled && cCls?.dropzoneDisabled,
|
|
3014
|
+
hasError && pCls?.dropzoneError,
|
|
3015
|
+
hasError && cCls?.dropzoneError
|
|
3016
|
+
),
|
|
3017
|
+
style: resolveSlotStyle(
|
|
3018
|
+
pSty?.dropzone,
|
|
3019
|
+
cSty?.dropzone,
|
|
3020
|
+
isDragging ? pSty?.dropzoneDragging : void 0,
|
|
3021
|
+
isDragging ? cSty?.dropzoneDragging : void 0,
|
|
3022
|
+
hasPreview ? pSty?.dropzoneHasImage : void 0,
|
|
3023
|
+
hasPreview ? cSty?.dropzoneHasImage : void 0,
|
|
3024
|
+
disabled ? pSty?.dropzoneDisabled : void 0,
|
|
3025
|
+
disabled ? cSty?.dropzoneDisabled : void 0,
|
|
3026
|
+
hasError ? pSty?.dropzoneError : void 0,
|
|
3027
|
+
hasError ? cSty?.dropzoneError : void 0
|
|
3028
|
+
)
|
|
3029
|
+
};
|
|
3030
|
+
}
|
|
3031
|
+
function SingleDropzoneEmptyPrompt({
|
|
3032
|
+
isUploading,
|
|
3033
|
+
uploadMessage,
|
|
3034
|
+
showProgress,
|
|
3035
|
+
progress,
|
|
3036
|
+
maxSizeMB,
|
|
3037
|
+
enablePaste = true,
|
|
3038
|
+
ui,
|
|
3039
|
+
unstyled,
|
|
3040
|
+
providerClassNames,
|
|
3041
|
+
classNames,
|
|
3042
|
+
providerStyles,
|
|
3043
|
+
styles
|
|
3044
|
+
}) {
|
|
3045
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, unstyled, providerClassNames?.[slot], classNames?.[slot]);
|
|
3046
|
+
const slotStyle = (slot) => resolveSlotStyle(providerStyles?.[slot], styles?.[slot]);
|
|
3047
|
+
return /* @__PURE__ */ jsxs15(
|
|
3048
|
+
"div",
|
|
3049
|
+
{
|
|
3050
|
+
"data-slot": "dropzone-prompt",
|
|
3051
|
+
className: slotClass("dropzonePrompt", "iuk-dropzone__prompt"),
|
|
3052
|
+
style: slotStyle("dropzonePrompt"),
|
|
3053
|
+
children: [
|
|
3054
|
+
/* @__PURE__ */ jsx15(
|
|
3055
|
+
"div",
|
|
3056
|
+
{
|
|
3057
|
+
"data-slot": "dropzone-icon",
|
|
3058
|
+
className: slotClass("dropzoneIcon", "iuk-dropzone__icon"),
|
|
3059
|
+
style: slotStyle("dropzoneIcon"),
|
|
3060
|
+
children: isUploading ? /* @__PURE__ */ jsx15("div", { className: resolveSlotClass("iuk-spinner", unstyled) }) : /* @__PURE__ */ jsx15(ImagePlusIcon, { size: 36, strokeWidth: 1.5 })
|
|
3061
|
+
}
|
|
3062
|
+
),
|
|
3063
|
+
/* @__PURE__ */ jsx15(
|
|
3064
|
+
"p",
|
|
3065
|
+
{
|
|
3066
|
+
"data-slot": "dropzone-text",
|
|
3067
|
+
className: slotClass("dropzoneText", "iuk-dropzone__text"),
|
|
3068
|
+
style: slotStyle("dropzoneText"),
|
|
3069
|
+
children: isUploading ? uploadMessage || `${ui.uploading}...` : ui.dragDropOrClickToUpload
|
|
3070
|
+
}
|
|
3071
|
+
),
|
|
3072
|
+
isUploading && showProgress && progress > 0 && /* @__PURE__ */ jsxs15(
|
|
3073
|
+
"p",
|
|
3074
|
+
{
|
|
3075
|
+
"data-slot": "dropzone-progress",
|
|
3076
|
+
role: "progressbar",
|
|
3077
|
+
"aria-valuenow": Math.round(progress),
|
|
3078
|
+
"aria-valuemin": 0,
|
|
3079
|
+
"aria-valuemax": 100,
|
|
3080
|
+
"aria-label": ui.uploading,
|
|
3081
|
+
className: slotClass("dropzoneProgress", "iuk-dropzone__progress"),
|
|
3082
|
+
style: slotStyle("dropzoneProgress"),
|
|
3083
|
+
children: [
|
|
3084
|
+
progress,
|
|
3085
|
+
"%"
|
|
3086
|
+
]
|
|
3087
|
+
}
|
|
3088
|
+
),
|
|
3089
|
+
!isUploading && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
3090
|
+
/* @__PURE__ */ jsxs15(
|
|
3091
|
+
"p",
|
|
3092
|
+
{
|
|
3093
|
+
"data-slot": "dropzone-hint",
|
|
3094
|
+
className: slotClass("dropzoneHint", "iuk-dropzone__hint"),
|
|
3095
|
+
style: slotStyle("dropzoneHint"),
|
|
3096
|
+
children: [
|
|
3097
|
+
ui.upToSizeMB.replace("{size}", String(maxSizeMB)),
|
|
3098
|
+
enablePaste ? ` \u2022 ${ui.pasteHint}` : ""
|
|
3099
|
+
]
|
|
3100
|
+
}
|
|
3101
|
+
),
|
|
3102
|
+
/* @__PURE__ */ jsxs15(
|
|
3103
|
+
"span",
|
|
3104
|
+
{
|
|
3105
|
+
"data-slot": "browse-button",
|
|
3106
|
+
className: slotClass("browseButton", "iuk-btn iuk-btn--secondary"),
|
|
3107
|
+
style: slotStyle("browseButton"),
|
|
3108
|
+
children: [
|
|
3109
|
+
/* @__PURE__ */ jsx15(UploadIcon, { size: 15 }),
|
|
3110
|
+
/* @__PURE__ */ jsx15("span", { children: ui.browseFiles })
|
|
3111
|
+
]
|
|
3112
|
+
}
|
|
3113
|
+
)
|
|
3114
|
+
] })
|
|
3115
|
+
]
|
|
3116
|
+
}
|
|
3117
|
+
);
|
|
3118
|
+
}
|
|
3119
|
+
function SingleStatusFooter({
|
|
3120
|
+
showMissingAltWarning,
|
|
3121
|
+
hasPreview,
|
|
3122
|
+
hasAltText,
|
|
3123
|
+
uploadMessage,
|
|
3124
|
+
isUploading,
|
|
3125
|
+
sizeInfo,
|
|
3126
|
+
canDownload,
|
|
3127
|
+
onDownload,
|
|
3128
|
+
helperText,
|
|
3129
|
+
displayError,
|
|
3130
|
+
statusTextId,
|
|
3131
|
+
isOpen,
|
|
3132
|
+
requireAltText,
|
|
3133
|
+
disabled,
|
|
3134
|
+
onSave,
|
|
3135
|
+
ui,
|
|
3136
|
+
unstyled,
|
|
3137
|
+
providerClassNames,
|
|
3138
|
+
classNames,
|
|
3139
|
+
providerStyles,
|
|
3140
|
+
styles
|
|
3141
|
+
}) {
|
|
3142
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, unstyled, providerClassNames?.[slot], classNames?.[slot]);
|
|
3143
|
+
const slotStyle = (slot) => resolveSlotStyle(providerStyles?.[slot], styles?.[slot]);
|
|
3144
|
+
return /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
3145
|
+
showMissingAltWarning && hasPreview && !hasAltText && /* @__PURE__ */ jsxs15(
|
|
3146
|
+
"div",
|
|
3147
|
+
{
|
|
3148
|
+
"data-slot": "alert",
|
|
3149
|
+
role: "alert",
|
|
3150
|
+
className: slotClass("alert", "iuk-alert iuk-alert--warning"),
|
|
3151
|
+
style: slotStyle("alert"),
|
|
3152
|
+
children: [
|
|
3153
|
+
/* @__PURE__ */ jsx15(AlertTriangleIcon, { size: 16 }),
|
|
3154
|
+
/* @__PURE__ */ jsx15("span", { children: ui.addAltBeforeSaving })
|
|
3155
|
+
]
|
|
3156
|
+
}
|
|
3157
|
+
),
|
|
3158
|
+
uploadMessage && !isUploading && sizeInfo && /* @__PURE__ */ jsx15(
|
|
3159
|
+
"div",
|
|
3160
|
+
{
|
|
3161
|
+
"data-slot": "alert",
|
|
3162
|
+
role: "status",
|
|
3163
|
+
className: slotClass("alert", "iuk-alert iuk-alert--success"),
|
|
3164
|
+
style: slotStyle("alert"),
|
|
3165
|
+
children: /* @__PURE__ */ jsx15("span", { children: uploadMessage })
|
|
3166
|
+
}
|
|
3167
|
+
),
|
|
3168
|
+
hasPreview && canDownload && /* @__PURE__ */ jsxs15(
|
|
3169
|
+
"button",
|
|
3170
|
+
{
|
|
3171
|
+
type: "button",
|
|
3172
|
+
"data-slot": "download-button",
|
|
3173
|
+
className: slotClass("downloadButton", "iuk-btn iuk-btn--secondary iuk-single__download"),
|
|
3174
|
+
style: slotStyle("downloadButton"),
|
|
3175
|
+
onClick: onDownload,
|
|
3176
|
+
disabled: isUploading,
|
|
3177
|
+
"aria-label": ui.downloadImage,
|
|
3178
|
+
children: [
|
|
3179
|
+
/* @__PURE__ */ jsx15(DownloadIcon, { size: 15, "aria-hidden": "true" }),
|
|
3180
|
+
/* @__PURE__ */ jsx15("span", { children: ui.downloadImage }),
|
|
3181
|
+
sizeInfo && /* @__PURE__ */ jsx15("span", { className: resolveSlotClass("iuk-badge", unstyled), children: formatCompactBytes(sizeInfo.optimized) })
|
|
3182
|
+
]
|
|
3183
|
+
}
|
|
3184
|
+
),
|
|
3185
|
+
(helperText || displayError) && /* @__PURE__ */ jsx15(
|
|
3186
|
+
"p",
|
|
3187
|
+
{
|
|
3188
|
+
id: statusTextId,
|
|
3189
|
+
role: displayError ? "alert" : void 0,
|
|
3190
|
+
"data-slot": displayError ? "error-text" : "helper-text",
|
|
3191
|
+
className: resolveSlotClass(
|
|
3192
|
+
cx("iuk-helper-text", Boolean(displayError) && "iuk-helper-text--error"),
|
|
3193
|
+
unstyled,
|
|
3194
|
+
providerClassNames?.helperText,
|
|
3195
|
+
classNames?.helperText,
|
|
3196
|
+
Boolean(displayError) && providerClassNames?.errorText,
|
|
3197
|
+
Boolean(displayError) && classNames?.errorText
|
|
3198
|
+
),
|
|
3199
|
+
style: resolveSlotStyle(
|
|
3200
|
+
providerStyles?.helperText,
|
|
3201
|
+
styles?.helperText,
|
|
3202
|
+
displayError ? providerStyles?.errorText : void 0,
|
|
3203
|
+
displayError ? styles?.errorText : void 0
|
|
3204
|
+
),
|
|
3205
|
+
children: displayError || helperText
|
|
3206
|
+
}
|
|
3207
|
+
),
|
|
3208
|
+
isOpen && hasPreview && onSave && /* @__PURE__ */ jsxs15(
|
|
3209
|
+
"div",
|
|
3210
|
+
{
|
|
3211
|
+
"data-slot": "commit-bar",
|
|
3212
|
+
className: slotClass("commitBar", "iuk-commit-bar"),
|
|
3213
|
+
style: slotStyle("commitBar"),
|
|
3214
|
+
children: [
|
|
3215
|
+
requireAltText && !hasAltText && /* @__PURE__ */ jsxs15("div", { className: resolveSlotClass("iuk-badge iuk-badge--warning", unstyled), children: [
|
|
3216
|
+
/* @__PURE__ */ jsx15(AlertTriangleIcon, { size: 13 }),
|
|
3217
|
+
/* @__PURE__ */ jsx15("span", { children: ui.missingDescription })
|
|
3218
|
+
] }),
|
|
3219
|
+
/* @__PURE__ */ jsx15(
|
|
3220
|
+
SaveButton,
|
|
3221
|
+
{
|
|
3222
|
+
unstyled,
|
|
3223
|
+
className: slotClass("saveButton"),
|
|
3224
|
+
style: slotStyle("saveButton"),
|
|
3225
|
+
onClick: onSave,
|
|
3226
|
+
disabled: isUploading || disabled || Boolean(requireAltText && !hasAltText),
|
|
3227
|
+
icon: /* @__PURE__ */ jsx15(SaveIcon, { size: 16 }),
|
|
3228
|
+
children: ui.saveImage
|
|
3229
|
+
}
|
|
3230
|
+
)
|
|
3231
|
+
]
|
|
3232
|
+
}
|
|
3233
|
+
)
|
|
3234
|
+
] });
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
// src/react/components/SingleImageUpload.tsx
|
|
3238
|
+
import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3239
|
+
function SingleImageUploadInner(props, ref) {
|
|
3240
|
+
const {
|
|
3241
|
+
preset,
|
|
3242
|
+
translations,
|
|
3243
|
+
renderImage,
|
|
3244
|
+
label,
|
|
3245
|
+
error,
|
|
3246
|
+
helperText,
|
|
3247
|
+
className,
|
|
3248
|
+
style,
|
|
3249
|
+
accept = "image/jpeg,image/png,image/webp,image/avif,image/svg+xml",
|
|
3250
|
+
disabled = false,
|
|
3251
|
+
required = false,
|
|
3252
|
+
blurType = "card",
|
|
3253
|
+
showProgress = false,
|
|
3254
|
+
showQualitySelector = true,
|
|
3255
|
+
recommendedQuality,
|
|
3256
|
+
qualityNote,
|
|
3257
|
+
isOpen,
|
|
3258
|
+
capture,
|
|
3259
|
+
enablePaste = true,
|
|
3260
|
+
pasteTarget = "dropzone",
|
|
3261
|
+
name,
|
|
3262
|
+
onBlur,
|
|
3263
|
+
classNames: cCls,
|
|
3264
|
+
styles: cSty,
|
|
3265
|
+
renderDropzone,
|
|
3266
|
+
renderPreview
|
|
3267
|
+
} = props;
|
|
3268
|
+
const ctx = useImageUploadContext();
|
|
3269
|
+
const isUnstyled = props.unstyled ?? ctx.unstyled;
|
|
3270
|
+
const pCls = ctx.singleClassNames;
|
|
3271
|
+
const pSty = ctx.singleStyles;
|
|
3272
|
+
const slotClass = (slot, defaultClass) => resolveSlotClass(defaultClass, isUnstyled, pCls?.[slot], cCls?.[slot]);
|
|
3273
|
+
const slotStyle = (slot) => resolveSlotStyle(pSty?.[slot], cSty?.[slot]);
|
|
3274
|
+
const state = useSingleImageState(props);
|
|
3275
|
+
const { isDragging, dragHandlers } = useDragAndDrop({ disabled, onDrop: state.handleFileSelect });
|
|
3276
|
+
const { onPaste } = useClipboardPaste({
|
|
3277
|
+
enabled: enablePaste,
|
|
3278
|
+
pasteTarget,
|
|
3279
|
+
disabled,
|
|
3280
|
+
multiple: false,
|
|
3281
|
+
onPasteFiles: (files) => {
|
|
3282
|
+
void state.handleFileSelect(files);
|
|
3283
|
+
}
|
|
3284
|
+
});
|
|
3285
|
+
const dropzoneRef = useRef8(null);
|
|
3286
|
+
const labelId = useId5();
|
|
3287
|
+
const inputId = useId5();
|
|
3288
|
+
const statusTextId = useId5();
|
|
3289
|
+
const openFileDialog = () => {
|
|
3290
|
+
if (!disabled) state.fileInputRef.current?.click();
|
|
3291
|
+
};
|
|
3292
|
+
useImperativeHandle2(ref, () => ({
|
|
3293
|
+
focus: () => {
|
|
3294
|
+
dropzoneRef.current?.focus();
|
|
3295
|
+
},
|
|
3296
|
+
open: openFileDialog,
|
|
3297
|
+
clear: () => state.handleRemoveTile()
|
|
3298
|
+
}));
|
|
3299
|
+
const handleInputChange = (event) => {
|
|
3300
|
+
const files = event.target.files;
|
|
3301
|
+
if (files && files.length > 0) void state.handleFileSelect(files);
|
|
3302
|
+
event.target.value = "";
|
|
3303
|
+
};
|
|
3304
|
+
const displayError = error || state.validationError;
|
|
3305
|
+
const hasPreview = Boolean(state.preview);
|
|
3306
|
+
const hasError = Boolean(displayError);
|
|
3307
|
+
const hasLabel = Boolean(label || state.ui.uploadImage);
|
|
3308
|
+
const hasStatusText = Boolean(helperText || displayError);
|
|
3309
|
+
const visualState = resolveUploadDataState({
|
|
3310
|
+
disabled,
|
|
3311
|
+
hasError,
|
|
3312
|
+
isUploading: state.isUploading,
|
|
3313
|
+
isDragging,
|
|
3314
|
+
hasContent: hasPreview
|
|
3315
|
+
});
|
|
3316
|
+
const dropzoneProps = hasPreview ? { ...dragHandlers, onPaste, "aria-disabled": disabled || void 0 } : {
|
|
3317
|
+
...dragHandlers,
|
|
3318
|
+
onPaste,
|
|
3319
|
+
onClick: () => {
|
|
3320
|
+
if (!disabled) openFileDialog();
|
|
3321
|
+
},
|
|
3322
|
+
onKeyDown: (event) => {
|
|
3323
|
+
if (!disabled && (event.key === "Enter" || event.key === " ")) {
|
|
3324
|
+
event.preventDefault();
|
|
3325
|
+
openFileDialog();
|
|
3326
|
+
}
|
|
3327
|
+
},
|
|
3328
|
+
role: "button",
|
|
3329
|
+
tabIndex: disabled ? -1 : 0,
|
|
3330
|
+
"aria-label": state.ui.uploadImageAria,
|
|
3331
|
+
"aria-labelledby": hasLabel ? labelId : void 0,
|
|
3332
|
+
"aria-required": required || void 0,
|
|
3333
|
+
"aria-invalid": hasError || void 0,
|
|
3334
|
+
"aria-describedby": hasStatusText ? statusTextId : void 0,
|
|
3335
|
+
"aria-disabled": disabled || void 0
|
|
3336
|
+
};
|
|
3337
|
+
const slotStylingProps = {
|
|
3338
|
+
unstyled: isUnstyled,
|
|
3339
|
+
providerClassNames: pCls,
|
|
3340
|
+
classNames: cCls,
|
|
3341
|
+
providerStyles: pSty,
|
|
3342
|
+
styles: cSty
|
|
3343
|
+
};
|
|
3344
|
+
const dropzoneSlot = resolveSingleDropzoneSlot(
|
|
3345
|
+
{ isDragging, hasPreview, disabled, hasError },
|
|
3346
|
+
slotStylingProps
|
|
3347
|
+
);
|
|
3348
|
+
return /* @__PURE__ */ jsxs16(
|
|
3349
|
+
"div",
|
|
3350
|
+
{
|
|
3351
|
+
"data-slot": "single-root",
|
|
3352
|
+
"data-state": visualState,
|
|
3353
|
+
"data-unstyled": isUnstyled || void 0,
|
|
3354
|
+
className: resolveSlotClass("iuk-single", isUnstyled, pCls?.root, cCls?.root, className),
|
|
3355
|
+
style: resolveSlotStyle(pSty?.root, cSty?.root, style),
|
|
3356
|
+
dir: state.locale === "ar" ? "rtl" : "ltr",
|
|
3357
|
+
onBlur: onBlur ? (e) => {
|
|
3358
|
+
if (!e.currentTarget.contains(e.relatedTarget)) onBlur();
|
|
3359
|
+
} : void 0,
|
|
3360
|
+
children: [
|
|
3361
|
+
/* @__PURE__ */ jsx16("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", style: HIDDEN_INPUT_STYLE, children: state.liveAnnouncement }),
|
|
3362
|
+
name && /* @__PURE__ */ jsx16("input", { type: "hidden", name, value: state.serializedFormValue, required, "data-slot": "form-input" }),
|
|
3363
|
+
hasLabel && /* @__PURE__ */ jsxs16("label", { id: labelId, htmlFor: inputId, "data-slot": "label", className: slotClass("label", "iuk-label"), style: slotStyle("label"), children: [
|
|
3364
|
+
/* @__PURE__ */ jsx16("span", { children: label || state.ui.uploadImage }),
|
|
3365
|
+
required && /* @__PURE__ */ jsx16("span", { className: resolveSlotClass("iuk-required", isUnstyled), children: "*" })
|
|
3366
|
+
] }),
|
|
3367
|
+
showQualitySelector && /* @__PURE__ */ jsx16("div", { "data-slot": "quality-selector", className: slotClass("qualitySelector"), style: slotStyle("qualitySelector"), children: /* @__PURE__ */ jsx16(
|
|
3368
|
+
QualitySelector,
|
|
3369
|
+
{
|
|
3370
|
+
value: state.qualityLevel,
|
|
3371
|
+
onChange: state.setQualityLevel,
|
|
3372
|
+
preset,
|
|
3373
|
+
recommendedLevel: recommendedQuality,
|
|
3374
|
+
recommendationNote: qualityNote,
|
|
3375
|
+
originalFileSize: state.selectedFile?.size,
|
|
3376
|
+
locale: state.locale,
|
|
3377
|
+
disabled: disabled || state.isUploading,
|
|
3378
|
+
unstyled: isUnstyled
|
|
3379
|
+
}
|
|
3380
|
+
) }),
|
|
3381
|
+
/* @__PURE__ */ jsx16(
|
|
3382
|
+
"input",
|
|
3383
|
+
{
|
|
3384
|
+
id: inputId,
|
|
3385
|
+
ref: state.fileInputRef,
|
|
3386
|
+
type: "file",
|
|
3387
|
+
accept,
|
|
3388
|
+
capture,
|
|
3389
|
+
onChange: handleInputChange,
|
|
3390
|
+
className: resolveSlotClass("iuk-hidden-input", isUnstyled),
|
|
3391
|
+
style: isUnstyled ? HIDDEN_INPUT_STYLE : void 0,
|
|
3392
|
+
disabled,
|
|
3393
|
+
"aria-label": state.ui.fileInputAria,
|
|
3394
|
+
"aria-invalid": hasError || void 0,
|
|
3395
|
+
"aria-describedby": hasStatusText ? statusTextId : void 0
|
|
3396
|
+
}
|
|
3397
|
+
),
|
|
3398
|
+
!state.preview && renderDropzone ? renderDropzone({
|
|
3399
|
+
state: visualState,
|
|
3400
|
+
isDragging,
|
|
3401
|
+
isUploading: state.isUploading,
|
|
3402
|
+
progress: state.progress,
|
|
3403
|
+
uploadMessage: state.uploadMessage,
|
|
3404
|
+
maxSizeMB: state.maxSizeMB,
|
|
3405
|
+
disabled,
|
|
3406
|
+
error: displayError || void 0,
|
|
3407
|
+
qualityLevel: state.qualityLevel,
|
|
3408
|
+
setQualityLevel: state.setQualityLevel,
|
|
3409
|
+
openFileDialog,
|
|
3410
|
+
dropzoneProps,
|
|
3411
|
+
locale: state.locale,
|
|
3412
|
+
ui: state.ui
|
|
3413
|
+
}) : /* @__PURE__ */ jsx16(
|
|
3414
|
+
"div",
|
|
3415
|
+
{
|
|
3416
|
+
ref: dropzoneRef,
|
|
3417
|
+
"data-slot": "dropzone",
|
|
3418
|
+
"data-state": visualState,
|
|
3419
|
+
"data-dragging": isDragging || void 0,
|
|
3420
|
+
"data-uploading": state.isUploading || void 0,
|
|
3421
|
+
"data-disabled": disabled || void 0,
|
|
3422
|
+
"data-error": hasError || void 0,
|
|
3423
|
+
className: dropzoneSlot.className,
|
|
3424
|
+
style: dropzoneSlot.style,
|
|
3425
|
+
...dropzoneProps,
|
|
3426
|
+
children: state.preview ? /* @__PURE__ */ jsx16(
|
|
3427
|
+
"div",
|
|
3428
|
+
{
|
|
3429
|
+
"data-slot": "preview-wrap",
|
|
3430
|
+
className: slotClass("previewWrap", "iuk-single__preview-wrap"),
|
|
3431
|
+
style: slotStyle("previewWrap"),
|
|
3432
|
+
onClick: (event) => event.stopPropagation(),
|
|
3433
|
+
children: renderPreview ? renderPreview({
|
|
3434
|
+
previewUrl: state.preview,
|
|
3435
|
+
uploadedData: state.uploadedData,
|
|
3436
|
+
altText: state.altText,
|
|
3437
|
+
blurColor: state.uploadedData?.blurColor ?? state.blurColor,
|
|
3438
|
+
blurDataUrl: state.blurDataUrlState || state.currentImageData?.blurDataUrl || "",
|
|
3439
|
+
isUploading: state.isUploading,
|
|
3440
|
+
progress: state.progress,
|
|
3441
|
+
uploadMessage: state.uploadMessage,
|
|
3442
|
+
sizeInfo: state.sizeInfo,
|
|
3443
|
+
disabled,
|
|
3444
|
+
openFileDialog,
|
|
3445
|
+
remove: () => state.handleRemoveTile(),
|
|
3446
|
+
cancel: () => state.handleCancelUpload(),
|
|
3447
|
+
openAltTextModal: () => state.setEditingAltText(true),
|
|
3448
|
+
openBlurInspector: () => state.setIsBlurModalOpen(true),
|
|
3449
|
+
download: state.handleDownload,
|
|
3450
|
+
locale: state.locale,
|
|
3451
|
+
ui: state.ui
|
|
3452
|
+
}) : /* @__PURE__ */ jsx16(
|
|
3453
|
+
PreviewTile,
|
|
3454
|
+
{
|
|
3455
|
+
preview: {
|
|
3456
|
+
id: "single",
|
|
3457
|
+
url: state.preview,
|
|
3458
|
+
altText: state.altText,
|
|
3459
|
+
isUploading: state.isUploading,
|
|
3460
|
+
progress: state.progress,
|
|
3461
|
+
uploadMessage: state.uploadMessage || null,
|
|
3462
|
+
originalSize: state.sizeInfo?.original,
|
|
3463
|
+
optimizedSize: state.sizeInfo?.optimized ?? null,
|
|
3464
|
+
data: state.uploadedData ?? void 0,
|
|
3465
|
+
blurColor: state.uploadedData?.blurColor ?? state.blurColor
|
|
3466
|
+
},
|
|
3467
|
+
onRemove: () => state.handleRemoveTile(),
|
|
3468
|
+
onCancel: () => state.handleCancelUpload(),
|
|
3469
|
+
disabled,
|
|
3470
|
+
blurType,
|
|
3471
|
+
showCheckbox: false,
|
|
3472
|
+
onEditAltText: () => state.setEditingAltText(true),
|
|
3473
|
+
onAdjustColor: () => state.setIsBlurModalOpen(true),
|
|
3474
|
+
locale: state.locale,
|
|
3475
|
+
translations,
|
|
3476
|
+
renderImage,
|
|
3477
|
+
unstyled: isUnstyled,
|
|
3478
|
+
className: slotClass("tile"),
|
|
3479
|
+
style: slotStyle("tile")
|
|
3480
|
+
}
|
|
3481
|
+
)
|
|
3482
|
+
}
|
|
3483
|
+
) : /* @__PURE__ */ jsx16(
|
|
3484
|
+
SingleDropzoneEmptyPrompt,
|
|
3485
|
+
{
|
|
3486
|
+
isUploading: state.isUploading,
|
|
3487
|
+
uploadMessage: state.uploadMessage,
|
|
3488
|
+
showProgress,
|
|
3489
|
+
progress: state.progress,
|
|
3490
|
+
maxSizeMB: state.maxSizeMB,
|
|
3491
|
+
enablePaste,
|
|
3492
|
+
ui: state.ui,
|
|
3493
|
+
...slotStylingProps
|
|
3494
|
+
}
|
|
3495
|
+
)
|
|
3496
|
+
}
|
|
3497
|
+
),
|
|
3498
|
+
/* @__PURE__ */ jsx16(
|
|
3499
|
+
SingleStatusFooter,
|
|
3500
|
+
{
|
|
3501
|
+
showMissingAltWarning: state.showMissingAltWarning,
|
|
3502
|
+
hasPreview,
|
|
3503
|
+
hasAltText: Boolean(state.altText?.trim()),
|
|
3504
|
+
uploadMessage: state.uploadMessage,
|
|
3505
|
+
isUploading: state.isUploading,
|
|
3506
|
+
sizeInfo: state.sizeInfo,
|
|
3507
|
+
canDownload: state.canDownload,
|
|
3508
|
+
onDownload: () => void state.handleDownload(),
|
|
3509
|
+
helperText,
|
|
3510
|
+
displayError,
|
|
3511
|
+
statusTextId,
|
|
3512
|
+
isOpen,
|
|
3513
|
+
requireAltText: state.requireAltText,
|
|
3514
|
+
disabled,
|
|
3515
|
+
onSave: state.handleSaveImage,
|
|
3516
|
+
ui: state.ui,
|
|
3517
|
+
...slotStylingProps
|
|
3518
|
+
}
|
|
3519
|
+
),
|
|
3520
|
+
state.editingAltText && state.preview && /* @__PURE__ */ jsx16(
|
|
3521
|
+
AltTextModal,
|
|
3522
|
+
{
|
|
3523
|
+
imageUrl: state.preview,
|
|
3524
|
+
initialAltText: state.altText,
|
|
3525
|
+
onSave: state.handleAltTextSave,
|
|
3526
|
+
onClose: () => state.setEditingAltText(false),
|
|
3527
|
+
locale: state.locale,
|
|
3528
|
+
translations,
|
|
3529
|
+
renderImage
|
|
3530
|
+
}
|
|
3531
|
+
),
|
|
3532
|
+
state.preview && /* @__PURE__ */ jsx16(
|
|
3533
|
+
BlurVisualizationModal,
|
|
3534
|
+
{
|
|
3535
|
+
isOpen: state.isBlurModalOpen,
|
|
3536
|
+
onClose: () => state.setIsBlurModalOpen(false),
|
|
3537
|
+
imageUrl: state.preview,
|
|
3538
|
+
blurDataUrl: state.blurDataUrlState || state.currentImageData?.blurDataUrl,
|
|
3539
|
+
blurColor: state.blurColor,
|
|
3540
|
+
altText: state.altText,
|
|
3541
|
+
originalSize: state.sizeInfo?.original ?? state.currentImageData?.originalSize,
|
|
3542
|
+
optimizedSize: state.sizeInfo?.optimized ?? state.currentImageData?.size ?? null,
|
|
3543
|
+
detectedColor: state.detectedBlurColor,
|
|
3544
|
+
onChangeColor: (hex) => state.applyBlurColor(hex),
|
|
3545
|
+
onUseDetectedColor: state.handleResetColor,
|
|
3546
|
+
onChangeAltText: (nextAlt) => state.handleAltTextSave(nextAlt),
|
|
3547
|
+
locale: state.locale,
|
|
3548
|
+
translations,
|
|
3549
|
+
renderImage
|
|
3550
|
+
}
|
|
3551
|
+
)
|
|
3552
|
+
]
|
|
3553
|
+
}
|
|
3554
|
+
);
|
|
3555
|
+
}
|
|
3556
|
+
var SingleImageUpload = forwardRef2(SingleImageUploadInner);
|
|
3557
|
+
|
|
3558
|
+
// src/react/components/ImageUpload.tsx
|
|
3559
|
+
import { Fragment as Fragment6, jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3560
|
+
function ImageUploadInner(props, ref) {
|
|
3561
|
+
const ctx = useImageUploadContext();
|
|
3562
|
+
const isUnstyled = props.unstyled ?? ctx.unstyled;
|
|
3563
|
+
const uploadLocale = normalizeUploadLocale(props.locale || ctx.locale);
|
|
3564
|
+
const ui = resolveTranslations(
|
|
3565
|
+
uploadLocale,
|
|
3566
|
+
props.translations || ctx.translations
|
|
3567
|
+
);
|
|
3568
|
+
const dir = uploadLocale === "ar" ? "rtl" : "ltr";
|
|
3569
|
+
const { isOpen, onClose, title, modeVariant } = props;
|
|
3570
|
+
const [isMinimized, setIsMinimized] = useState7(false);
|
|
3571
|
+
const [dockNode, setDockNode] = useState7(null);
|
|
3572
|
+
const cls = (defaultClass) => resolveSlotClass(defaultClass, isUnstyled);
|
|
3573
|
+
useEffect8(() => {
|
|
3574
|
+
if (!isOpen) {
|
|
3575
|
+
setIsMinimized(false);
|
|
3576
|
+
}
|
|
3577
|
+
}, [isOpen]);
|
|
3578
|
+
const { dialogRef, titleId } = useDialog({
|
|
3579
|
+
isOpen: Boolean(isOpen) && !isMinimized,
|
|
3580
|
+
onClose
|
|
3581
|
+
});
|
|
3582
|
+
useEffect8(() => {
|
|
3583
|
+
if (typeof window === "undefined" || !isOpen || !isMinimized) {
|
|
3584
|
+
setDockNode(null);
|
|
3585
|
+
return;
|
|
3586
|
+
}
|
|
3587
|
+
const updateDockReference = () => {
|
|
3588
|
+
const node = document.querySelector("[data-upload-progress-dock]");
|
|
3589
|
+
setDockNode(
|
|
3590
|
+
(prev) => node instanceof HTMLElement ? node === prev ? prev : node : null
|
|
3591
|
+
);
|
|
3592
|
+
};
|
|
3593
|
+
updateDockReference();
|
|
3594
|
+
const observer = new MutationObserver(() => updateDockReference());
|
|
3595
|
+
observer.observe(document.body, {
|
|
3596
|
+
childList: true,
|
|
3597
|
+
subtree: true
|
|
3598
|
+
});
|
|
3599
|
+
return () => observer.disconnect();
|
|
3600
|
+
}, [isOpen, isMinimized]);
|
|
3601
|
+
const content = props.mode === "multiple" ? /* @__PURE__ */ jsx17(MultiImageUpload, { ref, ...props }) : /* @__PURE__ */ jsx17(SingleImageUpload, { ref, ...props });
|
|
3602
|
+
if (isOpen === void 0) {
|
|
3603
|
+
return /* @__PURE__ */ jsx17(
|
|
3604
|
+
"div",
|
|
3605
|
+
{
|
|
3606
|
+
"data-slot": "upload-root",
|
|
3607
|
+
"data-unstyled": isUnstyled || void 0,
|
|
3608
|
+
className: cls("iuk-root"),
|
|
3609
|
+
dir,
|
|
3610
|
+
"data-upload-locale": uploadLocale,
|
|
3611
|
+
children: content
|
|
3612
|
+
}
|
|
3613
|
+
);
|
|
3614
|
+
}
|
|
3615
|
+
if (!isOpen) return null;
|
|
3616
|
+
const minimizedButton = /* @__PURE__ */ jsxs17(
|
|
3617
|
+
"button",
|
|
3618
|
+
{
|
|
3619
|
+
type: "button",
|
|
3620
|
+
"data-slot": "minimized-pill",
|
|
3621
|
+
className: cls("iuk-minimized-pill"),
|
|
3622
|
+
onClick: () => setIsMinimized(false),
|
|
3623
|
+
title: ui.restoreUploadWindow,
|
|
3624
|
+
children: [
|
|
3625
|
+
/* @__PURE__ */ jsx17(LoaderIcon, { size: 16, className: cls("iuk-spin") }),
|
|
3626
|
+
/* @__PURE__ */ jsxs17("span", { className: cls("iuk-minimized-pill__copy"), children: [
|
|
3627
|
+
/* @__PURE__ */ jsx17("span", { className: cls("iuk-minimized-pill__primary"), children: ui.uploadWindow }),
|
|
3628
|
+
/* @__PURE__ */ jsx17("span", { className: cls("iuk-minimized-pill__secondary"), children: ui.tapToResume })
|
|
3629
|
+
] }),
|
|
3630
|
+
/* @__PURE__ */ jsx17(ChevronUpIcon, { size: 16 })
|
|
3631
|
+
]
|
|
3632
|
+
}
|
|
3633
|
+
);
|
|
3634
|
+
return /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
3635
|
+
/* @__PURE__ */ jsx17(
|
|
3636
|
+
"div",
|
|
3637
|
+
{
|
|
3638
|
+
"data-slot": "upload-modal-backdrop",
|
|
3639
|
+
"data-unstyled": isUnstyled || void 0,
|
|
3640
|
+
className: cls(
|
|
3641
|
+
`iuk-root iuk-modal-backdrop ${isMinimized ? "iuk-modal-backdrop--hidden" : ""}`.trim()
|
|
3642
|
+
),
|
|
3643
|
+
dir,
|
|
3644
|
+
"data-upload-locale": uploadLocale,
|
|
3645
|
+
role: "dialog",
|
|
3646
|
+
"aria-modal": !isMinimized,
|
|
3647
|
+
"aria-hidden": isMinimized,
|
|
3648
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
3649
|
+
"aria-label": !title ? ui.uploadWindow : void 0,
|
|
3650
|
+
onClick: () => onClose?.(),
|
|
3651
|
+
children: /* @__PURE__ */ jsxs17(
|
|
3652
|
+
"div",
|
|
3653
|
+
{
|
|
3654
|
+
ref: dialogRef,
|
|
3655
|
+
"data-slot": "upload-dialog",
|
|
3656
|
+
className: cls(
|
|
3657
|
+
`iuk-upload-dialog ${isMinimized ? "iuk-upload-dialog--hidden" : ""}`.trim()
|
|
3658
|
+
),
|
|
3659
|
+
onClick: (e) => e.stopPropagation(),
|
|
3660
|
+
children: [
|
|
3661
|
+
onClose && /* @__PURE__ */ jsxs17("div", { className: cls("iuk-upload-dialog__controls"), children: [
|
|
3662
|
+
/* @__PURE__ */ jsx17(
|
|
3663
|
+
"button",
|
|
3664
|
+
{
|
|
3665
|
+
type: "button",
|
|
3666
|
+
className: cls("iuk-icon-btn iuk-icon-btn--floating"),
|
|
3667
|
+
onClick: () => setIsMinimized(true),
|
|
3668
|
+
"aria-label": ui.minimize,
|
|
3669
|
+
title: ui.minimizeUploader,
|
|
3670
|
+
children: /* @__PURE__ */ jsx17(MinusIcon, { size: 18 })
|
|
3671
|
+
}
|
|
3672
|
+
),
|
|
3673
|
+
/* @__PURE__ */ jsx17(
|
|
3674
|
+
"button",
|
|
3675
|
+
{
|
|
3676
|
+
type: "button",
|
|
3677
|
+
className: cls("iuk-icon-btn iuk-icon-btn--floating"),
|
|
3678
|
+
onClick: onClose,
|
|
3679
|
+
"aria-label": ui.close,
|
|
3680
|
+
children: /* @__PURE__ */ jsx17(XIcon, { size: 18 })
|
|
3681
|
+
}
|
|
3682
|
+
)
|
|
3683
|
+
] }),
|
|
3684
|
+
/* @__PURE__ */ jsxs17(
|
|
3685
|
+
"div",
|
|
3686
|
+
{
|
|
3687
|
+
className: cls("iuk-upload-dialog__card"),
|
|
3688
|
+
onClick: (e) => e.stopPropagation(),
|
|
3689
|
+
children: [
|
|
3690
|
+
title && /* @__PURE__ */ jsx17("h3", { id: titleId, className: cls("iuk-upload-dialog__title"), children: modeVariant === "edit" ? ui.editPrefix.replace("{title}", title) : title }),
|
|
3691
|
+
content
|
|
3692
|
+
]
|
|
3693
|
+
}
|
|
3694
|
+
)
|
|
3695
|
+
]
|
|
3696
|
+
}
|
|
3697
|
+
)
|
|
3698
|
+
}
|
|
3699
|
+
),
|
|
3700
|
+
isMinimized && typeof document !== "undefined" && (dockNode ? createPortal4(
|
|
3701
|
+
/* @__PURE__ */ jsx17("div", { className: cls("iuk-minimized-portal"), children: minimizedButton }),
|
|
3702
|
+
dockNode
|
|
3703
|
+
) : /* @__PURE__ */ jsx17("div", { className: cls("iuk-minimized-dock"), children: minimizedButton }))
|
|
3704
|
+
] });
|
|
3705
|
+
}
|
|
3706
|
+
var ImageUpload = forwardRef3(ImageUploadInner);
|
|
3707
|
+
var UnifiedImageUpload = ImageUpload;
|
|
3708
|
+
export {
|
|
3709
|
+
ARABIC_UPLOAD_TRANSLATIONS,
|
|
3710
|
+
AltTextInput,
|
|
3711
|
+
AltTextModal,
|
|
3712
|
+
AnimatedImage,
|
|
3713
|
+
BlurImage,
|
|
3714
|
+
BlurServiceDebugger,
|
|
3715
|
+
BlurVisualizationModal,
|
|
3716
|
+
DEFAULT_NEUTRAL_COLORS,
|
|
3717
|
+
DEFAULT_PLACEHOLDERS,
|
|
3718
|
+
DEFAULT_UPLOAD_TRANSLATIONS,
|
|
3719
|
+
HIDDEN_INPUT_STYLE,
|
|
3720
|
+
HeadlessMultiUpload,
|
|
3721
|
+
HeadlessSingleUpload,
|
|
3722
|
+
ImageUpload,
|
|
3723
|
+
ImageUploadProvider,
|
|
3724
|
+
MultiImageUpload,
|
|
3725
|
+
PreviewTile,
|
|
3726
|
+
QualitySelector,
|
|
3727
|
+
SaveButton,
|
|
3728
|
+
SingleImageUpload,
|
|
3729
|
+
UnifiedImageUpload,
|
|
3730
|
+
UploadProgressPanel,
|
|
3731
|
+
arTranslations,
|
|
3732
|
+
blurService,
|
|
3733
|
+
buildUploadFormData,
|
|
3734
|
+
createFallbackBlurSvg,
|
|
3735
|
+
createUploadAbortError,
|
|
3736
|
+
cx,
|
|
3737
|
+
enTranslations,
|
|
3738
|
+
extractClipboardImageFiles,
|
|
3739
|
+
formatNeedsAltMessage,
|
|
3740
|
+
formatSkippedImagesMessage,
|
|
3741
|
+
formatUploadingCount,
|
|
3742
|
+
isUploadAbortError,
|
|
3743
|
+
normalizeUploadLocale,
|
|
3744
|
+
parseErrorPayload,
|
|
3745
|
+
resolveBackgroundColor,
|
|
3746
|
+
resolveIntrinsicPlaceholderUrl,
|
|
3747
|
+
resolveMeaningfulColor,
|
|
3748
|
+
resolvePlaceholderUrl,
|
|
3749
|
+
resolveSlotClass,
|
|
3750
|
+
resolveSlotStyle,
|
|
3751
|
+
resolveTranslations,
|
|
3752
|
+
resolveUploadDataState,
|
|
3753
|
+
selectPluralCategory,
|
|
3754
|
+
toFileListLike,
|
|
3755
|
+
uploadText,
|
|
3756
|
+
uploadViaXhr,
|
|
3757
|
+
useBlurDataURL,
|
|
3758
|
+
useBlurDataWithColor,
|
|
3759
|
+
useBlurHash,
|
|
3760
|
+
useBlurMetadata,
|
|
3761
|
+
useBlurPreload,
|
|
3762
|
+
useBlurVariant,
|
|
3763
|
+
useBulkBlurData,
|
|
3764
|
+
useClipboardPaste,
|
|
3765
|
+
useDialog,
|
|
3766
|
+
useDominantColor,
|
|
3767
|
+
useDragAndDrop,
|
|
3768
|
+
useDragAndDrop as useDropzone,
|
|
3769
|
+
useFilePreview,
|
|
3770
|
+
useHasBlurHash,
|
|
3771
|
+
useImageReveal,
|
|
3772
|
+
useImageUpload,
|
|
3773
|
+
useImageUploadContext,
|
|
3774
|
+
useMultiUpload,
|
|
3775
|
+
useProgressiveBlur,
|
|
3776
|
+
useProgressiveImage,
|
|
3777
|
+
useSingleUpload
|
|
3778
|
+
};
|
|
3779
|
+
//# sourceMappingURL=react.js.map
|