@rubenpazch/image-viewer 0.0.0-stage → 1.2.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/README.md +42 -2
- package/dist/ImageViewer.d.ts +85 -0
- package/dist/ImageViewer.d.ts.map +1 -0
- package/dist/index.cjs.js +803 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +798 -0
- package/package.json +56 -3
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var require$$0 = require('react');
|
|
6
|
+
var shared = require('@rubenpazch/shared');
|
|
7
|
+
var reactDom = require('react-dom');
|
|
8
|
+
|
|
9
|
+
var jsxRuntime = {exports: {}};
|
|
10
|
+
|
|
11
|
+
var reactJsxRuntime_production = {};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @license React
|
|
15
|
+
* react-jsx-runtime.production.js
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the MIT license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
var hasRequiredReactJsxRuntime_production;
|
|
24
|
+
|
|
25
|
+
function requireReactJsxRuntime_production () {
|
|
26
|
+
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
27
|
+
hasRequiredReactJsxRuntime_production = 1;
|
|
28
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
29
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
30
|
+
function jsxProd(type, config, maybeKey) {
|
|
31
|
+
var key = null;
|
|
32
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
33
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
34
|
+
if ("key" in config) {
|
|
35
|
+
maybeKey = {};
|
|
36
|
+
for (var propName in config)
|
|
37
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
38
|
+
} else maybeKey = config;
|
|
39
|
+
config = maybeKey.ref;
|
|
40
|
+
return {
|
|
41
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
42
|
+
type: type,
|
|
43
|
+
key: key,
|
|
44
|
+
ref: void 0 !== config ? config : null,
|
|
45
|
+
props: maybeKey
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
49
|
+
reactJsxRuntime_production.jsx = jsxProd;
|
|
50
|
+
reactJsxRuntime_production.jsxs = jsxProd;
|
|
51
|
+
return reactJsxRuntime_production;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var reactJsxRuntime_development = {};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @license React
|
|
58
|
+
* react-jsx-runtime.development.js
|
|
59
|
+
*
|
|
60
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
61
|
+
*
|
|
62
|
+
* This source code is licensed under the MIT license found in the
|
|
63
|
+
* LICENSE file in the root directory of this source tree.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
var hasRequiredReactJsxRuntime_development;
|
|
67
|
+
|
|
68
|
+
function requireReactJsxRuntime_development () {
|
|
69
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
70
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
71
|
+
"production" !== process.env.NODE_ENV &&
|
|
72
|
+
(function () {
|
|
73
|
+
function getComponentNameFromType(type) {
|
|
74
|
+
if (null == type) return null;
|
|
75
|
+
if ("function" === typeof type)
|
|
76
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE
|
|
77
|
+
? null
|
|
78
|
+
: type.displayName || type.name || null;
|
|
79
|
+
if ("string" === typeof type) return type;
|
|
80
|
+
switch (type) {
|
|
81
|
+
case REACT_FRAGMENT_TYPE:
|
|
82
|
+
return "Fragment";
|
|
83
|
+
case REACT_PROFILER_TYPE:
|
|
84
|
+
return "Profiler";
|
|
85
|
+
case REACT_STRICT_MODE_TYPE:
|
|
86
|
+
return "StrictMode";
|
|
87
|
+
case REACT_SUSPENSE_TYPE:
|
|
88
|
+
return "Suspense";
|
|
89
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
90
|
+
return "SuspenseList";
|
|
91
|
+
case REACT_ACTIVITY_TYPE:
|
|
92
|
+
return "Activity";
|
|
93
|
+
}
|
|
94
|
+
if ("object" === typeof type)
|
|
95
|
+
switch (
|
|
96
|
+
("number" === typeof type.tag &&
|
|
97
|
+
console.error(
|
|
98
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
99
|
+
),
|
|
100
|
+
type.$$typeof)
|
|
101
|
+
) {
|
|
102
|
+
case REACT_PORTAL_TYPE:
|
|
103
|
+
return "Portal";
|
|
104
|
+
case REACT_CONTEXT_TYPE:
|
|
105
|
+
return type.displayName || "Context";
|
|
106
|
+
case REACT_CONSUMER_TYPE:
|
|
107
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
108
|
+
case REACT_FORWARD_REF_TYPE:
|
|
109
|
+
var innerType = type.render;
|
|
110
|
+
type = type.displayName;
|
|
111
|
+
type ||
|
|
112
|
+
((type = innerType.displayName || innerType.name || ""),
|
|
113
|
+
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
|
|
114
|
+
return type;
|
|
115
|
+
case REACT_MEMO_TYPE:
|
|
116
|
+
return (
|
|
117
|
+
(innerType = type.displayName || null),
|
|
118
|
+
null !== innerType
|
|
119
|
+
? innerType
|
|
120
|
+
: getComponentNameFromType(type.type) || "Memo"
|
|
121
|
+
);
|
|
122
|
+
case REACT_LAZY_TYPE:
|
|
123
|
+
innerType = type._payload;
|
|
124
|
+
type = type._init;
|
|
125
|
+
try {
|
|
126
|
+
return getComponentNameFromType(type(innerType));
|
|
127
|
+
} catch (x) {}
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function testStringCoercion(value) {
|
|
132
|
+
return "" + value;
|
|
133
|
+
}
|
|
134
|
+
function checkKeyStringCoercion(value) {
|
|
135
|
+
try {
|
|
136
|
+
testStringCoercion(value);
|
|
137
|
+
var JSCompiler_inline_result = !1;
|
|
138
|
+
} catch (e) {
|
|
139
|
+
JSCompiler_inline_result = true;
|
|
140
|
+
}
|
|
141
|
+
if (JSCompiler_inline_result) {
|
|
142
|
+
JSCompiler_inline_result = console;
|
|
143
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
144
|
+
var JSCompiler_inline_result$jscomp$0 =
|
|
145
|
+
("function" === typeof Symbol &&
|
|
146
|
+
Symbol.toStringTag &&
|
|
147
|
+
value[Symbol.toStringTag]) ||
|
|
148
|
+
value.constructor.name ||
|
|
149
|
+
"Object";
|
|
150
|
+
JSCompiler_temp_const.call(
|
|
151
|
+
JSCompiler_inline_result,
|
|
152
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
153
|
+
JSCompiler_inline_result$jscomp$0
|
|
154
|
+
);
|
|
155
|
+
return testStringCoercion(value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function getTaskName(type) {
|
|
159
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
160
|
+
if (
|
|
161
|
+
"object" === typeof type &&
|
|
162
|
+
null !== type &&
|
|
163
|
+
type.$$typeof === REACT_LAZY_TYPE
|
|
164
|
+
)
|
|
165
|
+
return "<...>";
|
|
166
|
+
try {
|
|
167
|
+
var name = getComponentNameFromType(type);
|
|
168
|
+
return name ? "<" + name + ">" : "<...>";
|
|
169
|
+
} catch (x) {
|
|
170
|
+
return "<...>";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function getOwner() {
|
|
174
|
+
var dispatcher = ReactSharedInternals.A;
|
|
175
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
176
|
+
}
|
|
177
|
+
function UnknownOwner() {
|
|
178
|
+
return Error("react-stack-top-frame");
|
|
179
|
+
}
|
|
180
|
+
function hasValidKey(config) {
|
|
181
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
182
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
183
|
+
if (getter && getter.isReactWarning) return false;
|
|
184
|
+
}
|
|
185
|
+
return void 0 !== config.key;
|
|
186
|
+
}
|
|
187
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
188
|
+
function warnAboutAccessingKey() {
|
|
189
|
+
specialPropKeyWarningShown ||
|
|
190
|
+
((specialPropKeyWarningShown = true),
|
|
191
|
+
console.error(
|
|
192
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
193
|
+
displayName
|
|
194
|
+
));
|
|
195
|
+
}
|
|
196
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
197
|
+
Object.defineProperty(props, "key", {
|
|
198
|
+
get: warnAboutAccessingKey,
|
|
199
|
+
configurable: true
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
203
|
+
var componentName = getComponentNameFromType(this.type);
|
|
204
|
+
didWarnAboutElementRef[componentName] ||
|
|
205
|
+
((didWarnAboutElementRef[componentName] = true),
|
|
206
|
+
console.error(
|
|
207
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
208
|
+
));
|
|
209
|
+
componentName = this.props.ref;
|
|
210
|
+
return void 0 !== componentName ? componentName : null;
|
|
211
|
+
}
|
|
212
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
213
|
+
var refProp = props.ref;
|
|
214
|
+
type = {
|
|
215
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
216
|
+
type: type,
|
|
217
|
+
key: key,
|
|
218
|
+
props: props,
|
|
219
|
+
_owner: owner
|
|
220
|
+
};
|
|
221
|
+
null !== (void 0 !== refProp ? refProp : null)
|
|
222
|
+
? Object.defineProperty(type, "ref", {
|
|
223
|
+
enumerable: false,
|
|
224
|
+
get: elementRefGetterWithDeprecationWarning
|
|
225
|
+
})
|
|
226
|
+
: Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
227
|
+
type._store = {};
|
|
228
|
+
Object.defineProperty(type._store, "validated", {
|
|
229
|
+
configurable: false,
|
|
230
|
+
enumerable: false,
|
|
231
|
+
writable: true,
|
|
232
|
+
value: 0
|
|
233
|
+
});
|
|
234
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
235
|
+
configurable: false,
|
|
236
|
+
enumerable: false,
|
|
237
|
+
writable: true,
|
|
238
|
+
value: null
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(type, "_debugStack", {
|
|
241
|
+
configurable: false,
|
|
242
|
+
enumerable: false,
|
|
243
|
+
writable: true,
|
|
244
|
+
value: debugStack
|
|
245
|
+
});
|
|
246
|
+
Object.defineProperty(type, "_debugTask", {
|
|
247
|
+
configurable: false,
|
|
248
|
+
enumerable: false,
|
|
249
|
+
writable: true,
|
|
250
|
+
value: debugTask
|
|
251
|
+
});
|
|
252
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
253
|
+
return type;
|
|
254
|
+
}
|
|
255
|
+
function jsxDEVImpl(
|
|
256
|
+
type,
|
|
257
|
+
config,
|
|
258
|
+
maybeKey,
|
|
259
|
+
isStaticChildren,
|
|
260
|
+
debugStack,
|
|
261
|
+
debugTask
|
|
262
|
+
) {
|
|
263
|
+
var children = config.children;
|
|
264
|
+
if (void 0 !== children)
|
|
265
|
+
if (isStaticChildren)
|
|
266
|
+
if (isArrayImpl(children)) {
|
|
267
|
+
for (
|
|
268
|
+
isStaticChildren = 0;
|
|
269
|
+
isStaticChildren < children.length;
|
|
270
|
+
isStaticChildren++
|
|
271
|
+
)
|
|
272
|
+
validateChildKeys(children[isStaticChildren]);
|
|
273
|
+
Object.freeze && Object.freeze(children);
|
|
274
|
+
} else
|
|
275
|
+
console.error(
|
|
276
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
277
|
+
);
|
|
278
|
+
else validateChildKeys(children);
|
|
279
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
280
|
+
children = getComponentNameFromType(type);
|
|
281
|
+
var keys = Object.keys(config).filter(function (k) {
|
|
282
|
+
return "key" !== k;
|
|
283
|
+
});
|
|
284
|
+
isStaticChildren =
|
|
285
|
+
0 < keys.length
|
|
286
|
+
? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
|
|
287
|
+
: "{key: someKey}";
|
|
288
|
+
didWarnAboutKeySpread[children + isStaticChildren] ||
|
|
289
|
+
((keys =
|
|
290
|
+
0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
|
|
291
|
+
console.error(
|
|
292
|
+
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
293
|
+
isStaticChildren,
|
|
294
|
+
children,
|
|
295
|
+
keys,
|
|
296
|
+
children
|
|
297
|
+
),
|
|
298
|
+
(didWarnAboutKeySpread[children + isStaticChildren] = true));
|
|
299
|
+
}
|
|
300
|
+
children = null;
|
|
301
|
+
void 0 !== maybeKey &&
|
|
302
|
+
(checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
|
|
303
|
+
hasValidKey(config) &&
|
|
304
|
+
(checkKeyStringCoercion(config.key), (children = "" + config.key));
|
|
305
|
+
if ("key" in config) {
|
|
306
|
+
maybeKey = {};
|
|
307
|
+
for (var propName in config)
|
|
308
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
309
|
+
} else maybeKey = config;
|
|
310
|
+
children &&
|
|
311
|
+
defineKeyPropWarningGetter(
|
|
312
|
+
maybeKey,
|
|
313
|
+
"function" === typeof type
|
|
314
|
+
? type.displayName || type.name || "Unknown"
|
|
315
|
+
: type
|
|
316
|
+
);
|
|
317
|
+
return ReactElement(
|
|
318
|
+
type,
|
|
319
|
+
children,
|
|
320
|
+
maybeKey,
|
|
321
|
+
getOwner(),
|
|
322
|
+
debugStack,
|
|
323
|
+
debugTask
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
function validateChildKeys(node) {
|
|
327
|
+
isValidElement(node)
|
|
328
|
+
? node._store && (node._store.validated = 1)
|
|
329
|
+
: "object" === typeof node &&
|
|
330
|
+
null !== node &&
|
|
331
|
+
node.$$typeof === REACT_LAZY_TYPE &&
|
|
332
|
+
("fulfilled" === node._payload.status
|
|
333
|
+
? isValidElement(node._payload.value) &&
|
|
334
|
+
node._payload.value._store &&
|
|
335
|
+
(node._payload.value._store.validated = 1)
|
|
336
|
+
: node._store && (node._store.validated = 1));
|
|
337
|
+
}
|
|
338
|
+
function isValidElement(object) {
|
|
339
|
+
return (
|
|
340
|
+
"object" === typeof object &&
|
|
341
|
+
null !== object &&
|
|
342
|
+
object.$$typeof === REACT_ELEMENT_TYPE
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
var React = require$$0,
|
|
346
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
347
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
348
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
349
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
350
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
351
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
352
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
353
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
354
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
355
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
356
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
357
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
358
|
+
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
359
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
360
|
+
ReactSharedInternals =
|
|
361
|
+
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
362
|
+
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
363
|
+
isArrayImpl = Array.isArray,
|
|
364
|
+
createTask = console.createTask
|
|
365
|
+
? console.createTask
|
|
366
|
+
: function () {
|
|
367
|
+
return null;
|
|
368
|
+
};
|
|
369
|
+
React = {
|
|
370
|
+
react_stack_bottom_frame: function (callStackForError) {
|
|
371
|
+
return callStackForError();
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
var specialPropKeyWarningShown;
|
|
375
|
+
var didWarnAboutElementRef = {};
|
|
376
|
+
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
|
|
377
|
+
React,
|
|
378
|
+
UnknownOwner
|
|
379
|
+
)();
|
|
380
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
381
|
+
var didWarnAboutKeySpread = {};
|
|
382
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
383
|
+
reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
|
|
384
|
+
var trackActualOwner =
|
|
385
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
386
|
+
return jsxDEVImpl(
|
|
387
|
+
type,
|
|
388
|
+
config,
|
|
389
|
+
maybeKey,
|
|
390
|
+
false,
|
|
391
|
+
trackActualOwner
|
|
392
|
+
? Error("react-stack-top-frame")
|
|
393
|
+
: unknownOwnerDebugStack,
|
|
394
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
395
|
+
);
|
|
396
|
+
};
|
|
397
|
+
reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
|
|
398
|
+
var trackActualOwner =
|
|
399
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
400
|
+
return jsxDEVImpl(
|
|
401
|
+
type,
|
|
402
|
+
config,
|
|
403
|
+
maybeKey,
|
|
404
|
+
true,
|
|
405
|
+
trackActualOwner
|
|
406
|
+
? Error("react-stack-top-frame")
|
|
407
|
+
: unknownOwnerDebugStack,
|
|
408
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
})();
|
|
412
|
+
return reactJsxRuntime_development;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
var hasRequiredJsxRuntime;
|
|
416
|
+
|
|
417
|
+
function requireJsxRuntime () {
|
|
418
|
+
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
419
|
+
hasRequiredJsxRuntime = 1;
|
|
420
|
+
|
|
421
|
+
if (process.env.NODE_ENV === 'production') {
|
|
422
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
423
|
+
} else {
|
|
424
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
425
|
+
}
|
|
426
|
+
return jsxRuntime.exports;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
430
|
+
|
|
431
|
+
var e$6={exports:{}};
|
|
432
|
+
|
|
433
|
+
var r$2={};
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @license React
|
|
437
|
+
* react-jsx-runtime.production.js
|
|
438
|
+
*
|
|
439
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
440
|
+
*
|
|
441
|
+
* This source code is licensed under the MIT license found in the
|
|
442
|
+
* LICENSE file in the root directory of this source tree.
|
|
443
|
+
*/var e$5;function t$2(){if(e$5)return r$2;e$5=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function n(r,e,o){var n=null;if(void 0!==o&&(n=""+o),void 0!==e.key&&(n=""+e.key),"key"in e)for(var i in o={},e)"key"!==i&&(o[i]=e[i]);else o=e;return e=o.ref,{$$typeof:t,type:r,key:n,ref:void 0!==e?e:null,props:o}}return r$2.Fragment=o,r$2.jsx=n,r$2.jsxs=n,r$2}
|
|
444
|
+
|
|
445
|
+
var r$1={};
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* @license React
|
|
449
|
+
* react-jsx-runtime.development.js
|
|
450
|
+
*
|
|
451
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
452
|
+
*
|
|
453
|
+
* This source code is licensed under the MIT license found in the
|
|
454
|
+
* LICENSE file in the root directory of this source tree.
|
|
455
|
+
*/var t$1;function n(){return t$1||(t$1=1,"production"!==process.env.NODE_ENV&&function(){function t(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===N?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case d:return "Fragment";case _:return "Profiler";case b:return "StrictMode";case S:return "Suspense";case j:return "SuspenseList";case w:return "Activity"}if("object"==typeof e)switch("number"==typeof e.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case m:return "Portal";case g:return e.displayName||"Context";case v:return (e._context.displayName||"Context")+".Consumer";case k:var r=e.render;return (e=e.displayName)||(e=""!==(e=r.displayName||r.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case h:return null!==(r=e.displayName||null)?r:t(e.type)||"Memo";case O:r=e._payload,e=e._init;try{return t(e(r))}catch(e){}}return null}function n(e){return ""+e}function o(e){try{n(e);var r=!1;}catch(e){r=true;}if(r){var t=(r=console).error,o="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),n(e)}}function a(e){if(e===d)return "<>";if("object"==typeof e&&null!==e&&e.$$typeof===O)return "<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch(e){return "<...>"}}function l(){return Error("react-stack-top-frame")}function i(){var e=t(this.type);return P[e]||(P[e]=true,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(e=this.props.ref)?e:null}function c(e,r,n,a,l,c){var u,y=r.children;if(void 0!==y)if(a)if(x(y)){for(a=0;a<y.length;a++)s(y[a]);Object.freeze&&Object.freeze(y);}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else s(y);if(T.call(r,"key")){y=t(e);var m=Object.keys(r).filter(function(e){return "key"!==e});a=0<m.length?"{key: someKey, "+m.join(": ..., ")+": ...}":"{key: someKey}",C[y+a]||(m=0<m.length?"{"+m.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',a,y,m,y),C[y+a]=true);}if(y=null,void 0!==n&&(o(n),y=""+n),function(e){if(T.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return false}return void 0!==e.key}(r)&&(o(r.key),y=""+r.key),"key"in r)for(var d in n={},r)"key"!==d&&(n[d]=r[d]);else n=r;return y&&function(e,r){function t(){f||(f=true,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r));}t.isReactWarning=true,Object.defineProperty(e,"key",{get:t,configurable:true});}(n,"function"==typeof e?e.displayName||e.name||"Unknown":e),function(e,r,t,n,o,a){var l=t.ref;return e={$$typeof:p,type:e,key:r,props:t,_owner:n},null!==(void 0!==l?l:null)?Object.defineProperty(e,"ref",{enumerable:false,get:i}):Object.defineProperty(e,"ref",{enumerable:false,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:false,enumerable:false,writable:true,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:false,enumerable:false,writable:true,value:null}),Object.defineProperty(e,"_debugStack",{configurable:false,enumerable:false,writable:true,value:o}),Object.defineProperty(e,"_debugTask",{configurable:false,enumerable:false,writable:true,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(e,y,n,null===(u=R.A)?null:u.getOwner(),l,c)}function s(e){u(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===O&&("fulfilled"===e._payload.status?u(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1));}function u(e){return "object"==typeof e&&null!==e&&e.$$typeof===p}var f,y=require$$0,p=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),g=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),w=Symbol.for("react.activity"),N=Symbol.for("react.client.reference"),R=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,T=Object.prototype.hasOwnProperty,x=Array.isArray,E=console.createTask?console.createTask:function(){return null},P={},$=(y={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(y,l)(),A=E(a(l)),C={};r$1.Fragment=d,r$1.jsx=function(e,r,t){var n=1e4>R.recentlyCreatedOwnerStacks++;return c(e,r,t,false,n?Error("react-stack-top-frame"):$,n?E(a(e)):A)},r$1.jsxs=function(e,r,t){var n=1e4>R.recentlyCreatedOwnerStacks++;return c(e,r,t,true,n?Error("react-stack-top-frame"):$,n?E(a(e)):A)};}()),r$1}
|
|
456
|
+
|
|
457
|
+
var t;function s(){return t||(t=1,"production"===process.env.NODE_ENV?e$6.exports=t$2():e$6.exports=n()),e$6.exports}
|
|
458
|
+
|
|
459
|
+
var r=s();
|
|
460
|
+
|
|
461
|
+
const o=({className:o="",size:e="md",color:r$1="currentColor",direction:s="down"})=>{const i={sm:16,md:20,lg:24};return r.jsx("svg",{width:i[e],height:i[e],className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[e]} ${{up:"rotate-180",down:"",left:"rotate-90",right:"-rotate-90"}[s]} ${o}`,fill:"none",stroke:r$1,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M6 9l6 6 6-6"})})};
|
|
462
|
+
|
|
463
|
+
function e$4({className:e="",size:o="md",color:r$1="currentColor"}){const t={sm:16,md:20,lg:24};return r.jsx("svg",{width:t[o],height:t[o],className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[o]} ${e}`,fill:"none",stroke:r$1,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})}
|
|
464
|
+
|
|
465
|
+
const e$3=({className:e="",size:o="md",color:r$1="currentColor"})=>{const t={sm:16,md:20,lg:24};return r.jsx("svg",{width:t[o],height:t[o],className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[o]} ${e}`,fill:"none",stroke:r$1,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})})};
|
|
466
|
+
|
|
467
|
+
const e$2=({className:e="",size:r$1="md",color:i="currentColor"})=>{const o={sm:16,md:20,lg:24};return r.jsxs("svg",{width:o[r$1],height:o[r$1],className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[r$1]} ${e}`,fill:"none",stroke:i,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"}),r.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),r.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})};
|
|
468
|
+
|
|
469
|
+
const e$1=({className:e="",size:r$1="md",color:o="currentColor"})=>{const t={sm:16,md:20,lg:24};return r.jsxs("svg",{width:t[r$1],height:t[r$1],className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[r$1]} ${e}`,fill:"none",stroke:o,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"}),r.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})};
|
|
470
|
+
|
|
471
|
+
const e={sm:16,md:20,lg:24};function i({size:i="md",title:s,...o}){return r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:e[i],height:e[i],fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",role:s?"img":void 0,"aria-hidden":!s||void 0,focusable:"false",...o,children:[s&&r.jsx("title",{children:s}),r.jsx("path",{d:"M15 3h6v6"}),r.jsx("path",{d:"M10 14 21 3"}),r.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}
|
|
472
|
+
|
|
473
|
+
function styleInject(css, ref) {
|
|
474
|
+
if ( ref === void 0 ) ref = {};
|
|
475
|
+
var insertAt = ref.insertAt;
|
|
476
|
+
|
|
477
|
+
if (typeof document === 'undefined') { return; }
|
|
478
|
+
|
|
479
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
480
|
+
var style = document.createElement('style');
|
|
481
|
+
style.type = 'text/css';
|
|
482
|
+
|
|
483
|
+
if (insertAt === 'top') {
|
|
484
|
+
if (head.firstChild) {
|
|
485
|
+
head.insertBefore(style, head.firstChild);
|
|
486
|
+
} else {
|
|
487
|
+
head.appendChild(style);
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
head.appendChild(style);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (style.styleSheet) {
|
|
494
|
+
style.styleSheet.cssText = css;
|
|
495
|
+
} else {
|
|
496
|
+
style.appendChild(document.createTextNode(css));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
var css_248z = "/* Visor a pantalla completa, siempre oscuro (como cualquier visor de fotos) */\n.ImageViewer-module_viewer__v3SKG {\n --iv-fg: var(--lb-color-neutral-50);\n --iv-bg: var(--lb-color-neutral-900);\n --iv-soft: color-mix(in srgb, var(--iv-fg) 12%, transparent);\n --iv-hover: color-mix(in srgb, var(--iv-fg) 20%, transparent);\n --iv-muted: color-mix(in srgb, var(--iv-fg) 70%, transparent);\n\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: flex;\n flex-direction: column;\n background: var(--iv-bg);\n color: var(--iv-fg);\n font-family: var(--lb-font-sans);\n}\n\n.ImageViewer-module_topBar__4-SPt {\n display: flex;\n align-items: center;\n gap: var(--lb-space-2);\n padding: var(--lb-space-2);\n}\n\n.ImageViewer-module_titleBlock__SjK5s {\n flex: 1;\n min-width: 0;\n}\n\n.ImageViewer-module_caption__PGC81 {\n margin: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n}\n\n.ImageViewer-module_counter__876EK {\n margin: 0;\n font-size: var(--lb-font-size-xs);\n color: var(--iv-muted);\n}\n\n/* Botones de 44 px: cómodos para el dedo */\n.ImageViewer-module_toolButton__I3tsO,\n.ImageViewer-module_textButton__X4vCS,\n.ImageViewer-module_zoomLevel__WMnO8,\n.ImageViewer-module_navButton__GjdVy {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--lb-space-1);\n min-width: 2.75rem;\n height: 2.75rem;\n padding: 0 var(--lb-space-2);\n border: 0;\n border-radius: var(--lb-radius-full);\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: var(--lb-font-size-sm);\n cursor: pointer;\n}\n\n.ImageViewer-module_toolButton__I3tsO:hover:not(:disabled),\n.ImageViewer-module_textButton__X4vCS:hover,\n.ImageViewer-module_zoomLevel__WMnO8:hover {\n background: var(--iv-hover);\n}\n\n.ImageViewer-module_toolButton__I3tsO:focus-visible,\n.ImageViewer-module_textButton__X4vCS:focus-visible,\n.ImageViewer-module_zoomLevel__WMnO8:focus-visible,\n.ImageViewer-module_navButton__GjdVy:focus-visible {\n outline: 2px solid var(--iv-fg);\n outline-offset: 2px;\n}\n\n.ImageViewer-module_toolButton__I3tsO:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.ImageViewer-module_textButton__X4vCS {\n display: none;\n padding: 0 var(--lb-space-3);\n}\n\n.ImageViewer-module_stage__FSXpq {\n position: relative;\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: zoom-in;\n}\n\n.ImageViewer-module_stageZoomed__MKYnY {\n cursor: grab;\n}\n\n.ImageViewer-module_stageZoomed__MKYnY:active {\n cursor: grabbing;\n}\n\n.ImageViewer-module_image__N9r-N {\n max-width: 100%;\n max-height: 100%;\n object-fit: contain;\n will-change: transform;\n transition: transform 120ms ease-out;\n}\n\n.ImageViewer-module_message__9cqSZ {\n margin: 0;\n padding: 0 var(--lb-space-6);\n text-align: center;\n font-size: var(--lb-font-size-sm);\n color: var(--iv-muted);\n}\n\n.ImageViewer-module_spinner__UnShS {\n width: 2.5rem;\n height: 2.5rem;\n border: 2px solid var(--iv-fg);\n border-top-color: transparent;\n border-radius: var(--lb-radius-full);\n animation: ImageViewer-module_ivSpin__bmC5x 0.8s linear infinite;\n}\n\n@keyframes ImageViewer-module_ivSpin__bmC5x {\n to {\n transform: rotate(360deg);\n }\n}\n\n.ImageViewer-module_navButton__GjdVy {\n position: absolute;\n top: 50%;\n width: 3rem;\n height: 3rem;\n transform: translateY(-50%);\n background: color-mix(in srgb, var(--iv-bg) 55%, transparent);\n}\n\n.ImageViewer-module_navButton__GjdVy:hover {\n background: color-mix(in srgb, var(--iv-bg) 80%, transparent);\n}\n\n.ImageViewer-module_navPrevious__HoaU- {\n left: var(--lb-space-2);\n}\n\n.ImageViewer-module_navNext__MTxYT {\n right: var(--lb-space-2);\n}\n\n.ImageViewer-module_bottomBar__4YMQv {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--lb-space-1);\n padding: var(--lb-space-2) var(--lb-space-2)\n max(var(--lb-space-3), env(safe-area-inset-bottom));\n}\n\n.ImageViewer-module_zoomGroup__7o0RD {\n display: flex;\n align-items: center;\n gap: var(--lb-space-1);\n padding: 0 var(--lb-space-1);\n border-radius: var(--lb-radius-full);\n background: var(--iv-soft);\n}\n\n.ImageViewer-module_zoomLevel__WMnO8 {\n min-width: 4rem;\n font-variant-numeric: tabular-nums;\n}\n\n.ImageViewer-module_hint__DkWO1 {\n margin: 0;\n text-align: center;\n font-size: var(--lb-font-size-xs);\n color: var(--iv-muted);\n}\n\n@media (min-width: 640px) {\n .ImageViewer-module_topBar__4-SPt {\n padding: var(--lb-space-2) var(--lb-space-4);\n }\n\n .ImageViewer-module_textButton__X4vCS {\n display: inline-flex;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ImageViewer-module_image__N9r-N {\n transition: none;\n }\n\n .ImageViewer-module_spinner__UnShS {\n animation-duration: 2s;\n }\n}\n";
|
|
501
|
+
var styles = {"viewer":"ImageViewer-module_viewer__v3SKG","topBar":"ImageViewer-module_topBar__4-SPt","titleBlock":"ImageViewer-module_titleBlock__SjK5s","caption":"ImageViewer-module_caption__PGC81","counter":"ImageViewer-module_counter__876EK","toolButton":"ImageViewer-module_toolButton__I3tsO","textButton":"ImageViewer-module_textButton__X4vCS","zoomLevel":"ImageViewer-module_zoomLevel__WMnO8","navButton":"ImageViewer-module_navButton__GjdVy","stage":"ImageViewer-module_stage__FSXpq","stageZoomed":"ImageViewer-module_stageZoomed__MKYnY","image":"ImageViewer-module_image__N9r-N","message":"ImageViewer-module_message__9cqSZ","spinner":"ImageViewer-module_spinner__UnShS","navPrevious":"ImageViewer-module_navPrevious__HoaU-","navNext":"ImageViewer-module_navNext__MTxYT","bottomBar":"ImageViewer-module_bottomBar__4YMQv","zoomGroup":"ImageViewer-module_zoomGroup__7o0RD","hint":"ImageViewer-module_hint__DkWO1"};
|
|
502
|
+
styleInject(css_248z);
|
|
503
|
+
|
|
504
|
+
/** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
|
|
505
|
+
const DEFAULT_IMAGE_VIEWER_LABELS = shared.uiMessagesEs.imageViewer;
|
|
506
|
+
const MIN_SCALE = 1;
|
|
507
|
+
const MAX_SCALE = 5;
|
|
508
|
+
const BUTTON_STEP = 1.5;
|
|
509
|
+
const DOUBLE_TAP_SCALE = 2.5;
|
|
510
|
+
const DOUBLE_TAP_MS = 300;
|
|
511
|
+
const TAP_SLOP_PX = 10;
|
|
512
|
+
const SWIPE_PX = 60;
|
|
513
|
+
const SNAP_TO_FIT = 1.05;
|
|
514
|
+
const IDENTITY = { scale: 1, x: 0, y: 0 };
|
|
515
|
+
const interpolate = (template, values) => template.replace(/\{(\w+)\}/g, (_, key) => String(values[key] ?? ""));
|
|
516
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
517
|
+
// Celulares y tablets reciben instrucciones de pellizco; las computadoras, de mouse
|
|
518
|
+
const isTouchDevice = () => typeof window !== "undefined" &&
|
|
519
|
+
!!window.matchMedia?.("(pointer: coarse)").matches;
|
|
520
|
+
/**
|
|
521
|
+
* Mantiene la imagen ampliada cubriendo el área visible: no se puede arrastrar
|
|
522
|
+
* fuera de la vista. `image` es el tamaño mostrado al 100 %, `stage` el área.
|
|
523
|
+
*/
|
|
524
|
+
const clampView = (view, image, stage) => {
|
|
525
|
+
const scale = clamp(view.scale, MIN_SCALE, MAX_SCALE);
|
|
526
|
+
// Cerca del 100 % (tras la rueda o un pellizco) vuelve al 100 %
|
|
527
|
+
if (scale <= MIN_SCALE * SNAP_TO_FIT)
|
|
528
|
+
return IDENTITY;
|
|
529
|
+
const maxX = Math.max(0, (image.width * scale - stage.width) / 2);
|
|
530
|
+
const maxY = Math.max(0, (image.height * scale - stage.height) / 2);
|
|
531
|
+
return {
|
|
532
|
+
scale,
|
|
533
|
+
x: clamp(view.x, -maxX, maxX),
|
|
534
|
+
y: clamp(view.y, -maxY, maxY),
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* Amplía a `scale` manteniendo fijo el punto bajo `anchor` (relativo al centro
|
|
539
|
+
* del área), así el zoom sigue al cursor o a los dedos.
|
|
540
|
+
*/
|
|
541
|
+
const zoomAround = (from, scale, anchor) => {
|
|
542
|
+
const next = clamp(scale, MIN_SCALE, MAX_SCALE);
|
|
543
|
+
const ratio = next / from.scale;
|
|
544
|
+
return {
|
|
545
|
+
scale: next,
|
|
546
|
+
x: anchor.x - (anchor.x - from.x) * ratio,
|
|
547
|
+
y: anchor.y - (anchor.y - from.y) * ratio,
|
|
548
|
+
};
|
|
549
|
+
};
|
|
550
|
+
const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
551
|
+
const midpoint = (a, b) => ({
|
|
552
|
+
x: (a.x + b.x) / 2,
|
|
553
|
+
y: (a.y + b.y) / 2,
|
|
554
|
+
});
|
|
555
|
+
/**
|
|
556
|
+
* Visor de imágenes a pantalla completa con zoom, para mouse y pantalla táctil:
|
|
557
|
+
* botones (+, −, 100 %), rueda del mouse, pellizco con dos dedos, doble clic o
|
|
558
|
+
* doble toque, arrastrar para moverse cuando está ampliada y deslizar para
|
|
559
|
+
* cambiar de imagen. Teclado: ← → cambian de imagen, + − hacen zoom, 0
|
|
560
|
+
* restablece y Escape cierra (sin llegar a lo que está debajo, como un Drawer).
|
|
561
|
+
*/
|
|
562
|
+
const ImageViewer = ({ images, initialIndex = 0, index: controlledIndex, onIndexChange, onClose, onDownload, onOpenInNewTab, labels: labelsProp, }) => {
|
|
563
|
+
const labels = shared.useUiMessages("imageViewer", labelsProp);
|
|
564
|
+
const last = Math.max(0, images.length - 1);
|
|
565
|
+
const [ownIndex, setOwnIndex] = require$$0.useState(() => clamp(initialIndex, 0, last));
|
|
566
|
+
const index = clamp(controlledIndex ?? ownIndex, 0, last);
|
|
567
|
+
// La vista (zoom y posición) guarda a qué imagen pertenece: al cambiar de
|
|
568
|
+
// imagen vuelve sola al 100 %, sin efectos que reinicien el estado.
|
|
569
|
+
const [stored, setStored] = require$$0.useState({
|
|
570
|
+
index,
|
|
571
|
+
view: IDENTITY,
|
|
572
|
+
});
|
|
573
|
+
const view = stored.index === index ? stored.view : IDENTITY;
|
|
574
|
+
const viewRef = require$$0.useRef(stored);
|
|
575
|
+
// Mientras hay un gesto, el zoom sigue al dedo sin animación
|
|
576
|
+
const [dragging, setDragging] = require$$0.useState(false);
|
|
577
|
+
const stageRef = require$$0.useRef(null);
|
|
578
|
+
const imageRef = require$$0.useRef(null);
|
|
579
|
+
const closeRef = require$$0.useRef(null);
|
|
580
|
+
const pointers = require$$0.useRef(new Map());
|
|
581
|
+
const gesture = require$$0.useRef(null);
|
|
582
|
+
const lastTap = require$$0.useRef(null);
|
|
583
|
+
const lastPointerType = require$$0.useRef("mouse");
|
|
584
|
+
const [failedSrc, setFailedSrc] = require$$0.useState(null);
|
|
585
|
+
const image = images[index];
|
|
586
|
+
const hasMany = images.length > 1;
|
|
587
|
+
const failed = image?.status === "error" || (!!image?.src && failedSrc === image.src);
|
|
588
|
+
const src = image?.status === "loading" ? undefined : image?.src;
|
|
589
|
+
const stageCenter = () => {
|
|
590
|
+
const rect = stageRef.current?.getBoundingClientRect();
|
|
591
|
+
return rect
|
|
592
|
+
? { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }
|
|
593
|
+
: { x: 0, y: 0 };
|
|
594
|
+
};
|
|
595
|
+
// Coordenadas de pantalla → relativas al centro del área
|
|
596
|
+
const toStage = (point) => {
|
|
597
|
+
const center = stageCenter();
|
|
598
|
+
return { x: point.x - center.x, y: point.y - center.y };
|
|
599
|
+
};
|
|
600
|
+
const currentView = require$$0.useCallback(() => (viewRef.current.index === index ? viewRef.current.view : IDENTITY), [index]);
|
|
601
|
+
const setView = require$$0.useCallback((next) => {
|
|
602
|
+
const stage = stageRef.current;
|
|
603
|
+
const img = imageRef.current;
|
|
604
|
+
const clamped = stage && img && img.offsetWidth
|
|
605
|
+
? clampView(next, { width: img.offsetWidth, height: img.offsetHeight }, { width: stage.clientWidth, height: stage.clientHeight })
|
|
606
|
+
: next.scale <= MIN_SCALE
|
|
607
|
+
? IDENTITY
|
|
608
|
+
: { ...next, scale: clamp(next.scale, MIN_SCALE, MAX_SCALE) };
|
|
609
|
+
viewRef.current = { index, view: clamped };
|
|
610
|
+
setStored({ index, view: clamped });
|
|
611
|
+
}, [index]);
|
|
612
|
+
const zoomBy = require$$0.useCallback((factor, anchor = { x: 0, y: 0 }) => setView(zoomAround(currentView(), currentView().scale * factor, anchor)), [setView, currentView]);
|
|
613
|
+
const reset = require$$0.useCallback(() => setView(IDENTITY), [setView]);
|
|
614
|
+
const go = require$$0.useCallback((step) => {
|
|
615
|
+
if (!hasMany)
|
|
616
|
+
return;
|
|
617
|
+
const next = (index + step + images.length) % images.length;
|
|
618
|
+
if (controlledIndex === undefined)
|
|
619
|
+
setOwnIndex(next);
|
|
620
|
+
onIndexChange?.(next);
|
|
621
|
+
}, [hasMany, index, images.length, controlledIndex, onIndexChange]);
|
|
622
|
+
// Teclado, foco y bloqueo del desplazamiento de la página mientras está abierto
|
|
623
|
+
require$$0.useEffect(() => {
|
|
624
|
+
const previousOverflow = document.body.style.overflow;
|
|
625
|
+
const previousFocus = document.activeElement;
|
|
626
|
+
document.body.style.overflow = "hidden";
|
|
627
|
+
closeRef.current?.focus();
|
|
628
|
+
const actions = {
|
|
629
|
+
Escape: onClose,
|
|
630
|
+
ArrowRight: () => go(1),
|
|
631
|
+
ArrowLeft: () => go(-1),
|
|
632
|
+
"+": () => zoomBy(BUTTON_STEP),
|
|
633
|
+
"=": () => zoomBy(BUTTON_STEP),
|
|
634
|
+
"-": () => zoomBy(1 / BUTTON_STEP),
|
|
635
|
+
"0": reset,
|
|
636
|
+
};
|
|
637
|
+
const onKey = (event) => {
|
|
638
|
+
const action = actions[event.key];
|
|
639
|
+
if (!action)
|
|
640
|
+
return;
|
|
641
|
+
// El visor atiende la tecla y no llega a lo que está debajo
|
|
642
|
+
// (Escape también cerraría un Drawer desde el que se abrió)
|
|
643
|
+
event.stopPropagation();
|
|
644
|
+
action();
|
|
645
|
+
};
|
|
646
|
+
// Fase de captura en window: corre antes que los oyentes de document
|
|
647
|
+
window.addEventListener("keydown", onKey, true);
|
|
648
|
+
return () => {
|
|
649
|
+
window.removeEventListener("keydown", onKey, true);
|
|
650
|
+
document.body.style.overflow = previousOverflow;
|
|
651
|
+
previousFocus?.focus?.();
|
|
652
|
+
};
|
|
653
|
+
}, [go, onClose, reset, zoomBy]);
|
|
654
|
+
// Zoom con la rueda hacia el cursor (no pasivo: la página no se mueve)
|
|
655
|
+
require$$0.useEffect(() => {
|
|
656
|
+
const stage = stageRef.current;
|
|
657
|
+
if (!stage)
|
|
658
|
+
return;
|
|
659
|
+
const onWheel = (event) => {
|
|
660
|
+
event.preventDefault();
|
|
661
|
+
zoomBy(Math.exp(-event.deltaY * 0.002), toStage({ x: event.clientX, y: event.clientY }));
|
|
662
|
+
};
|
|
663
|
+
stage.addEventListener("wheel", onWheel, { passive: false });
|
|
664
|
+
return () => stage.removeEventListener("wheel", onWheel);
|
|
665
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
666
|
+
}, [zoomBy]);
|
|
667
|
+
const startPan = (point, pointerType, afterPinch = false) => {
|
|
668
|
+
gesture.current = {
|
|
669
|
+
type: "pan",
|
|
670
|
+
start: point,
|
|
671
|
+
origin: currentView(),
|
|
672
|
+
moved: false,
|
|
673
|
+
pointerType,
|
|
674
|
+
afterPinch,
|
|
675
|
+
};
|
|
676
|
+
};
|
|
677
|
+
const toggleZoomAt = (client) => {
|
|
678
|
+
if (currentView().scale > MIN_SCALE)
|
|
679
|
+
reset();
|
|
680
|
+
else
|
|
681
|
+
setView(zoomAround(currentView(), DOUBLE_TAP_SCALE, toStage(client)));
|
|
682
|
+
};
|
|
683
|
+
const handlePointerDown = (event) => {
|
|
684
|
+
if (event.pointerType === "mouse" && event.button !== 0)
|
|
685
|
+
return;
|
|
686
|
+
lastPointerType.current = event.pointerType;
|
|
687
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
688
|
+
const point = { x: event.clientX, y: event.clientY };
|
|
689
|
+
pointers.current.set(event.pointerId, point);
|
|
690
|
+
setDragging(true);
|
|
691
|
+
if (pointers.current.size === 1) {
|
|
692
|
+
startPan(point, event.pointerType);
|
|
693
|
+
}
|
|
694
|
+
else if (pointers.current.size === 2) {
|
|
695
|
+
const [a, b] = Array.from(pointers.current.values());
|
|
696
|
+
gesture.current = {
|
|
697
|
+
type: "pinch",
|
|
698
|
+
startDistance: Math.max(1, distance(a, b)),
|
|
699
|
+
startMid: toStage(midpoint(a, b)),
|
|
700
|
+
origin: currentView(),
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
const handlePointerMove = (event) => {
|
|
705
|
+
if (!pointers.current.has(event.pointerId))
|
|
706
|
+
return;
|
|
707
|
+
const point = { x: event.clientX, y: event.clientY };
|
|
708
|
+
pointers.current.set(event.pointerId, point);
|
|
709
|
+
const current = gesture.current;
|
|
710
|
+
if (!current)
|
|
711
|
+
return;
|
|
712
|
+
if (current.type === "pinch" && pointers.current.size >= 2) {
|
|
713
|
+
const [a, b] = Array.from(pointers.current.values());
|
|
714
|
+
const scale = current.origin.scale * (distance(a, b) / current.startDistance);
|
|
715
|
+
const mid = toStage(midpoint(a, b));
|
|
716
|
+
// Zoom alrededor de donde empezaron los dedos, luego los sigue
|
|
717
|
+
const zoomed = zoomAround(current.origin, scale, current.startMid);
|
|
718
|
+
setView({
|
|
719
|
+
...zoomed,
|
|
720
|
+
x: zoomed.x + (mid.x - current.startMid.x),
|
|
721
|
+
y: zoomed.y + (mid.y - current.startMid.y),
|
|
722
|
+
});
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
if (current.type === "pan") {
|
|
726
|
+
const dx = point.x - current.start.x;
|
|
727
|
+
const dy = point.y - current.start.y;
|
|
728
|
+
if (Math.hypot(dx, dy) > TAP_SLOP_PX)
|
|
729
|
+
current.moved = true;
|
|
730
|
+
if (currentView().scale > MIN_SCALE) {
|
|
731
|
+
setView({
|
|
732
|
+
...current.origin,
|
|
733
|
+
x: current.origin.x + dx,
|
|
734
|
+
y: current.origin.y + dy,
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
const handlePointerEnd = (event) => {
|
|
740
|
+
const point = { x: event.clientX, y: event.clientY };
|
|
741
|
+
const current = gesture.current;
|
|
742
|
+
pointers.current.delete(event.pointerId);
|
|
743
|
+
if (current?.type === "pinch") {
|
|
744
|
+
// El dedo que queda sigue moviendo desde donde está
|
|
745
|
+
const remaining = Array.from(pointers.current.values())[0];
|
|
746
|
+
if (remaining)
|
|
747
|
+
startPan(remaining, "touch", true);
|
|
748
|
+
else {
|
|
749
|
+
gesture.current = null;
|
|
750
|
+
setDragging(false);
|
|
751
|
+
}
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
gesture.current = null;
|
|
755
|
+
setDragging(false);
|
|
756
|
+
if (current?.type !== "pan" ||
|
|
757
|
+
current.afterPinch ||
|
|
758
|
+
event.type === "pointercancel")
|
|
759
|
+
return;
|
|
760
|
+
const dx = point.x - current.start.x;
|
|
761
|
+
const dy = point.y - current.start.y;
|
|
762
|
+
// Deslizar cambia de imagen (solo al 100 %; ampliada, arrastrar la mueve)
|
|
763
|
+
if (current.origin.scale <= MIN_SCALE &&
|
|
764
|
+
Math.abs(dx) > SWIPE_PX &&
|
|
765
|
+
Math.abs(dx) > Math.abs(dy)) {
|
|
766
|
+
go(dx < 0 ? 1 : -1);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
// Doble toque (táctil o lápiz; el mouse usa onDoubleClick)
|
|
770
|
+
if (current.pointerType !== "mouse" && !current.moved) {
|
|
771
|
+
const now = Date.now();
|
|
772
|
+
const previous = lastTap.current;
|
|
773
|
+
if (previous &&
|
|
774
|
+
now - previous.time < DOUBLE_TAP_MS &&
|
|
775
|
+
distance(previous.point, point) < TAP_SLOP_PX * 3) {
|
|
776
|
+
lastTap.current = null;
|
|
777
|
+
toggleZoomAt(point);
|
|
778
|
+
}
|
|
779
|
+
else {
|
|
780
|
+
lastTap.current = { time: now, point };
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
if (!image || typeof document === "undefined")
|
|
785
|
+
return null;
|
|
786
|
+
const percent = `${Math.round(view.scale * 100)} %`;
|
|
787
|
+
const zoomed = view.scale > MIN_SCALE;
|
|
788
|
+
return reactDom.createPortal(jsxRuntimeExports.jsxs("div", { role: "dialog", "aria-modal": "true", "aria-label": interpolate(labels.title, { name: image.caption }), className: styles.viewer, "data-testid": "image-viewer", children: [jsxRuntimeExports.jsxs("div", { className: styles.topBar, children: [jsxRuntimeExports.jsxs("div", { className: styles.titleBlock, children: [jsxRuntimeExports.jsx("p", { className: styles.caption, title: image.caption, children: image.caption }), hasMany && (jsxRuntimeExports.jsx("p", { className: styles.counter, "data-testid": "image-viewer-counter", children: interpolate(labels.counter, {
|
|
789
|
+
current: index + 1,
|
|
790
|
+
total: images.length,
|
|
791
|
+
}) }))] }), onDownload && (jsxRuntimeExports.jsx("button", { type: "button", className: styles.toolButton, onClick: () => onDownload(image, index), "aria-label": labels.download, title: labels.download, children: jsxRuntimeExports.jsx(e$3, { size: "md" }) })), onOpenInNewTab && (jsxRuntimeExports.jsxs("button", { type: "button", className: styles.textButton, onClick: () => onOpenInNewTab(image, index), children: [jsxRuntimeExports.jsx(i, { size: "sm" }), labels.openInNewTab] })), jsxRuntimeExports.jsx("button", { ref: closeRef, type: "button", className: styles.toolButton, onClick: onClose, "aria-label": labels.close, title: labels.close, "data-testid": "image-viewer-close", children: jsxRuntimeExports.jsx(e$4, { size: "md" }) })] }), jsxRuntimeExports.jsxs("div", { ref: stageRef, className: `${styles.stage} ${zoomed ? styles.stageZoomed : ""}`, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerEnd, onPointerCancel: handlePointerEnd, onDoubleClick: (event) => {
|
|
792
|
+
// Los celulares también disparan dblclick tras el doble toque
|
|
793
|
+
if (lastPointerType.current !== "mouse")
|
|
794
|
+
return;
|
|
795
|
+
toggleZoomAt({ x: event.clientX, y: event.clientY });
|
|
796
|
+
}, "data-testid": "image-viewer-stage", children: [failed ? (jsxRuntimeExports.jsx("p", { className: styles.message, children: labels.loadFailed })) : src ? (jsxRuntimeExports.jsx("img", { ref: imageRef, src: src, alt: image.caption, draggable: false, className: styles.image, onError: () => setFailedSrc(src), style: {
|
|
797
|
+
transform: `translate3d(${view.x}px, ${view.y}px, 0) scale(${view.scale})`,
|
|
798
|
+
transition: dragging ? "none" : undefined,
|
|
799
|
+
} }, image.id ?? index)) : (jsxRuntimeExports.jsx("span", { role: "status", "aria-label": labels.loading, className: styles.spinner })), hasMany && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("button", { type: "button", className: `${styles.navButton} ${styles.navPrevious}`, onClick: () => go(-1), onPointerDown: (event) => event.stopPropagation(), "aria-label": labels.previous, children: jsxRuntimeExports.jsx(o, { size: "md", direction: "left" }) }), jsxRuntimeExports.jsx("button", { type: "button", className: `${styles.navButton} ${styles.navNext}`, onClick: () => go(1), onPointerDown: (event) => event.stopPropagation(), "aria-label": labels.next, children: jsxRuntimeExports.jsx(o, { size: "md", direction: "right" }) })] }))] }), jsxRuntimeExports.jsxs("div", { className: styles.bottomBar, children: [jsxRuntimeExports.jsxs("div", { className: styles.zoomGroup, children: [jsxRuntimeExports.jsx("button", { type: "button", className: styles.toolButton, onClick: () => zoomBy(1 / BUTTON_STEP), disabled: view.scale <= MIN_SCALE, "aria-label": labels.zoomOut, title: labels.zoomOut, children: jsxRuntimeExports.jsx(e$1, { size: "md" }) }), jsxRuntimeExports.jsx("button", { type: "button", className: styles.zoomLevel, onClick: reset, "aria-label": labels.reset, title: labels.reset, "data-testid": "image-viewer-zoom-level", children: percent }), jsxRuntimeExports.jsx("button", { type: "button", className: styles.toolButton, onClick: () => zoomBy(BUTTON_STEP), disabled: view.scale >= MAX_SCALE, "aria-label": labels.zoomIn, title: labels.zoomIn, children: jsxRuntimeExports.jsx(e$2, { size: "md" }) })] }), jsxRuntimeExports.jsx("p", { className: styles.hint, children: isTouchDevice() ? labels.hintTouch : labels.hintMouse })] })] }), document.body);
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
exports.DEFAULT_IMAGE_VIEWER_LABELS = DEFAULT_IMAGE_VIEWER_LABELS;
|
|
803
|
+
exports.default = ImageViewer;
|