@rubenpazch/image-viewer 1.1.0 → 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 CHANGED
@@ -34,6 +34,8 @@ restablece y Escape cierra (sin llegar a lo que está debajo, como un Drawer).
34
34
 
35
35
  ## DEFAULT_IMAGE_VIEWER_LABELS
36
36
 
37
+ Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos.
38
+
37
39
  _Sin props documentadas._
38
40
 
39
41
  Tipos: `ImageViewerProps`, `ImageViewerItem`, `ImageViewerLabels`.
@@ -30,6 +30,7 @@ export interface ImageViewerLabels {
30
30
  hintTouch: string;
31
31
  hintMouse: string;
32
32
  }
33
+ /** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
33
34
  export declare const DEFAULT_IMAGE_VIEWER_LABELS: ImageViewerLabels;
34
35
  export interface ImageViewerProps {
35
36
  /** Imágenes que se pueden recorrer. */
@@ -1 +1 @@
1
- {"version":3,"file":"ImageViewer.d.ts","sourceRoot":"","sources":["../src/ImageViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAYxE,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IAC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
5
  var require$$0 = require('react');
6
+ var shared = require('@rubenpazch/shared');
6
7
  var reactDom = require('react-dom');
7
8
 
8
9
  var jsxRuntime = {exports: {}};
@@ -500,22 +501,8 @@ var css_248z = "/* Visor a pantalla completa, siempre oscuro (como cualquier vis
500
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"};
501
502
  styleInject(css_248z);
502
503
 
503
- const DEFAULT_IMAGE_VIEWER_LABELS = {
504
- title: "Vista previa de {name}",
505
- counter: "{current} de {total}",
506
- close: "Cerrar",
507
- download: "Descargar",
508
- openInNewTab: "Abrir en una pestaña nueva",
509
- zoomIn: "Acercar",
510
- zoomOut: "Alejar",
511
- reset: "Restablecer zoom",
512
- previous: "Imagen anterior",
513
- next: "Imagen siguiente",
514
- loading: "Cargando imagen…",
515
- loadFailed: "No se pudo cargar la imagen.",
516
- hintTouch: "Pellizca o haz doble toque para hacer zoom. Arrastra para moverte.",
517
- hintMouse: "Usa la rueda del mouse, doble clic o los botones para hacer zoom. Arrastra para moverte.",
518
- };
504
+ /** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
505
+ const DEFAULT_IMAGE_VIEWER_LABELS = shared.uiMessagesEs.imageViewer;
519
506
  const MIN_SCALE = 1;
520
507
  const MAX_SCALE = 5;
521
508
  const BUTTON_STEP = 1.5;
@@ -573,7 +560,7 @@ const midpoint = (a, b) => ({
573
560
  * restablece y Escape cierra (sin llegar a lo que está debajo, como un Drawer).
574
561
  */
575
562
  const ImageViewer = ({ images, initialIndex = 0, index: controlledIndex, onIndexChange, onClose, onDownload, onOpenInNewTab, labels: labelsProp, }) => {
576
- const labels = { ...DEFAULT_IMAGE_VIEWER_LABELS, ...labelsProp };
563
+ const labels = shared.useUiMessages("imageViewer", labelsProp);
577
564
  const last = Math.max(0, images.length - 1);
578
565
  const [ownIndex, setOwnIndex] = require$$0.useState(() => clamp(initialIndex, 0, last));
579
566
  const index = clamp(controlledIndex ?? ownIndex, 0, last);
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ interface ImageViewerLabels {
31
31
  hintTouch: string;
32
32
  hintMouse: string;
33
33
  }
34
+ /** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
34
35
  declare const DEFAULT_IMAGE_VIEWER_LABELS: ImageViewerLabels;
35
36
  interface ImageViewerProps {
36
37
  /** Imágenes que se pueden recorrer. */
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import require$$0, { useState, useRef, useCallback, useEffect } from 'react';
2
+ import { uiMessagesEs, useUiMessages } from '@rubenpazch/shared';
2
3
  import { createPortal } from 'react-dom';
3
4
 
4
5
  var jsxRuntime = {exports: {}};
@@ -496,22 +497,8 @@ var css_248z = "/* Visor a pantalla completa, siempre oscuro (como cualquier vis
496
497
  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"};
497
498
  styleInject(css_248z);
498
499
 
499
- const DEFAULT_IMAGE_VIEWER_LABELS = {
500
- title: "Vista previa de {name}",
501
- counter: "{current} de {total}",
502
- close: "Cerrar",
503
- download: "Descargar",
504
- openInNewTab: "Abrir en una pestaña nueva",
505
- zoomIn: "Acercar",
506
- zoomOut: "Alejar",
507
- reset: "Restablecer zoom",
508
- previous: "Imagen anterior",
509
- next: "Imagen siguiente",
510
- loading: "Cargando imagen…",
511
- loadFailed: "No se pudo cargar la imagen.",
512
- hintTouch: "Pellizca o haz doble toque para hacer zoom. Arrastra para moverte.",
513
- hintMouse: "Usa la rueda del mouse, doble clic o los botones para hacer zoom. Arrastra para moverte.",
514
- };
500
+ /** Textos en castellano (los del diccionario `es`). Con `UiLocaleProvider` cambian solos. */
501
+ const DEFAULT_IMAGE_VIEWER_LABELS = uiMessagesEs.imageViewer;
515
502
  const MIN_SCALE = 1;
516
503
  const MAX_SCALE = 5;
517
504
  const BUTTON_STEP = 1.5;
@@ -569,7 +556,7 @@ const midpoint = (a, b) => ({
569
556
  * restablece y Escape cierra (sin llegar a lo que está debajo, como un Drawer).
570
557
  */
571
558
  const ImageViewer = ({ images, initialIndex = 0, index: controlledIndex, onIndexChange, onClose, onDownload, onOpenInNewTab, labels: labelsProp, }) => {
572
- const labels = { ...DEFAULT_IMAGE_VIEWER_LABELS, ...labelsProp };
559
+ const labels = useUiMessages("imageViewer", labelsProp);
573
560
  const last = Math.max(0, images.length - 1);
574
561
  const [ownIndex, setOwnIndex] = useState(() => clamp(initialIndex, 0, last));
575
562
  const index = clamp(controlledIndex ?? ownIndex, 0, last);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/image-viewer",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "ImageViewer component",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",
@@ -32,12 +32,13 @@
32
32
  "@rubenpazch/tokens": "0.5.0"
33
33
  },
34
34
  "dependencies": {
35
- "@rubenpazch/icons": "^6.6.0"
35
+ "@rubenpazch/icons": "^6.6.1",
36
+ "@rubenpazch/shared": "5.4.0"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@rubenpazch/eslint-config": "4.0.0",
39
40
  "@rubenpazch/typescript-config": "3.0.0",
40
- "@rubenpazch/button": "^6.2.5"
41
+ "@rubenpazch/button": "^6.2.6"
41
42
  },
42
43
  "publishConfig": {
43
44
  "access": "public"