yet-another-react-lightbox 3.8.3 → 3.9.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.
@@ -2,12 +2,17 @@ import * as React from 'react';
2
2
  import { PluginProps } from '../../types.js';
3
3
 
4
4
  /** Counter plugin */
5
- declare function Counter({ addChild }: PluginProps): void;
5
+ declare function Counter({ augment, addChild }: PluginProps): void;
6
6
 
7
7
  declare module "../../types.js" {
8
8
  interface LightboxProps {
9
- /** HTML div element attributes to be passed to the Counter plugin container */
10
- counter?: React.HTMLAttributes<HTMLDivElement>;
9
+ /** Counter plugin settings */
10
+ counter?: React.HTMLAttributes<HTMLDivElement> & {
11
+ /** custom separator */
12
+ separator?: string;
13
+ /** counter container HTML attributes */
14
+ container?: React.HTMLAttributes<HTMLDivElement>;
15
+ };
11
16
  }
12
17
  }
13
18
 
@@ -2,16 +2,32 @@ import * as React from 'react';
2
2
  import { useLightboxState, clsx, cssClass, createModule } from '../../index.js';
3
3
  import { MODULE_CONTROLLER, PLUGIN_COUNTER } from '../../types.js';
4
4
 
5
- function CounterComponent({ counter: { className, ...rest } = {} }) {
5
+ const defaultCounterProps = {
6
+ separator: "/",
7
+ container: {},
8
+ };
9
+ const resolveCounterProps = (counter) => ({
10
+ ...defaultCounterProps,
11
+ ...counter,
12
+ });
13
+
14
+ function CounterComponent({ counter }) {
6
15
  const { slides, currentIndex } = useLightboxState();
16
+ const { separator, container: { className, ...rest }, className: legacyClassName, ...legacyRest } = resolveCounterProps(counter);
7
17
  if (slides.length === 0)
8
18
  return null;
9
- return (React.createElement("div", { className: clsx(cssClass("counter"), className), ...rest },
19
+ return (React.createElement("div", { className: clsx(cssClass("counter"), className || legacyClassName), ...legacyRest, ...rest },
10
20
  currentIndex + 1,
11
- " / ",
21
+ " ",
22
+ separator,
23
+ " ",
12
24
  slides.length));
13
25
  }
14
- function Counter({ addChild }) {
26
+ function Counter({ augment, addChild }) {
27
+ augment(({ counter, ...restProps }) => ({
28
+ counter: resolveCounterProps(counter),
29
+ ...restProps,
30
+ }));
15
31
  addChild(MODULE_CONTROLLER, createModule(PLUGIN_COUNTER, CounterComponent));
16
32
  }
17
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "3.8.3",
3
+ "version": "3.9.0",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",