yet-another-react-lightbox 3.19.0 → 3.20.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.
@@ -19,6 +19,8 @@ declare module "yet-another-react-lightbox" {
19
19
  captions?: {
20
20
  /** Captions plugin ref */
21
21
  ref?: React.ForwardedRef<CaptionsRef>;
22
+ /** if `true`, captions are hidden when the lightbox opens */
23
+ hidden?: boolean;
22
24
  /** if `true`, show Captions Toggle button in the toolbar */
23
25
  showToggle?: boolean;
24
26
  /** description text alignment */
@@ -8,6 +8,7 @@ const defaultCaptionsProps = {
8
8
  descriptionTextAlign: "start",
9
9
  descriptionMaxLines: 3,
10
10
  showToggle: false,
11
+ hidden: false,
11
12
  };
12
13
  const resolveCaptionsProps = (captions) => ({
13
14
  ...defaultCaptionsProps,
@@ -21,8 +22,8 @@ function useCaptionsProps() {
21
22
  const CaptionsContext = React.createContext(null);
22
23
  const useCaptions = makeUseContext("useCaptions", "CaptionsContext", CaptionsContext);
23
24
  function CaptionsContextProvider({ captions, children }) {
24
- const { ref } = resolveCaptionsProps(captions);
25
- const [visible, setVisible] = React.useState(true);
25
+ const { ref, hidden } = resolveCaptionsProps(captions);
26
+ const [visible, setVisible] = React.useState(!hidden);
26
27
  const context = React.useMemo(() => ({
27
28
  visible,
28
29
  show: () => setVisible(true),
@@ -36,6 +36,8 @@ declare module "yet-another-react-lightbox" {
36
36
  imageFit?: ImageFit;
37
37
  /** if `true`, show the vignette effect on the edges of the thumbnails track */
38
38
  vignette?: boolean;
39
+ /** if `true`, thumbnails are hidden when the lightbox opens */
40
+ hidden?: boolean;
39
41
  /** if `true`, show the Toggle Thumbnails button in the toolbar */
40
42
  showToggle?: boolean;
41
43
  };
@@ -13,6 +13,8 @@ const defaultThumbnailsProps = {
13
13
  gap: 16,
14
14
  imageFit: "contain",
15
15
  vignette: true,
16
+ hidden: false,
17
+ showToggle: false,
16
18
  };
17
19
  const resolveThumbnailsProps = (thumbnails) => ({
18
20
  ...defaultThumbnailsProps,
@@ -205,9 +207,9 @@ function ThumbnailsTrack({ visible, containerRef }) {
205
207
  const ThumbnailsContext = React.createContext(null);
206
208
  const useThumbnails = makeUseContext("useThumbnails", "ThumbnailsContext", ThumbnailsContext);
207
209
  function ThumbnailsContextProvider({ children, ...props }) {
208
- const [visible, setVisible] = React.useState(true);
210
+ const { ref, position, hidden } = resolveThumbnailsProps(props.thumbnails);
211
+ const [visible, setVisible] = React.useState(!hidden);
209
212
  const containerRef = React.useRef(null);
210
- const { ref, position } = resolveThumbnailsProps(props.thumbnails);
211
213
  const context = React.useMemo(() => ({
212
214
  visible,
213
215
  show: () => setVisible(true),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "3.19.0",
3
+ "version": "3.20.0",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",