@allxsmith/bestax-bulma 5.64.0 → 5.65.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.
Files changed (41) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Carousel.js +12 -66
  4. package/dist/esm/components/Carousel.js.map +1 -1
  5. package/dist/esm/components/Lightbox.js +756 -0
  6. package/dist/esm/components/Lightbox.js.map +1 -0
  7. package/dist/esm/components/Reveal.js +1 -24
  8. package/dist/esm/components/Reveal.js.map +1 -1
  9. package/dist/esm/helpers/chevronIcons.js +24 -0
  10. package/dist/esm/helpers/chevronIcons.js.map +1 -0
  11. package/dist/esm/helpers/usePrefersReducedMotion.js +34 -0
  12. package/dist/esm/helpers/usePrefersReducedMotion.js.map +1 -0
  13. package/dist/esm/helpers/useSwipe.js +82 -0
  14. package/dist/esm/helpers/useSwipe.js.map +1 -0
  15. package/dist/extras.css +1 -1
  16. package/dist/extras.css.map +1 -1
  17. package/dist/index.cjs +924 -149
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.esm.js +1 -0
  20. package/dist/index.esm.js.map +1 -1
  21. package/dist/types/components/Lightbox.d.ts +244 -0
  22. package/dist/types/helpers/chevronIcons.d.ts +14 -0
  23. package/dist/types/helpers/usePrefersReducedMotion.d.ts +10 -0
  24. package/dist/types/helpers/useSwipe.d.ts +66 -0
  25. package/dist/types/index.d.ts +1 -0
  26. package/dist/types-cjs/components/Lightbox.d.ts +244 -0
  27. package/dist/types-cjs/helpers/chevronIcons.d.ts +14 -0
  28. package/dist/types-cjs/helpers/usePrefersReducedMotion.d.ts +10 -0
  29. package/dist/types-cjs/helpers/useSwipe.d.ts +66 -0
  30. package/dist/types-cjs/index.d.ts +1 -0
  31. package/dist/versions/bestax-no-dark-mode.css +1 -1
  32. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  33. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  34. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  35. package/dist/versions/bestax-no-helpers.css +1 -1
  36. package/dist/versions/bestax-no-helpers.css.map +1 -1
  37. package/dist/versions/bestax-prefixed.css +1 -1
  38. package/dist/versions/bestax-prefixed.css.map +1 -1
  39. package/package.json +1 -1
  40. package/src/scss/components/_index.scss +1 -0
  41. package/src/scss/components/_lightbox.scss +392 -0
package/dist/index.esm.js CHANGED
@@ -29,6 +29,7 @@ export { Sidebar } from './esm/components/Sidebar.js';
29
29
  export { Toast, ToastContainer, toast } from './esm/components/Toast.js';
30
30
  export { Dialog, DialogContainer, dialog } from './esm/components/Dialog.js';
31
31
  export { Carousel, CarouselItem } from './esm/components/Carousel.js';
32
+ export { Lightbox, LightboxTrigger } from './esm/components/Lightbox.js';
32
33
  export { Reveal } from './esm/components/Reveal.js';
33
34
  export { TreeView, TreeViewItem } from './esm/components/TreeView.js';
34
35
  export { ScrollArea } from './esm/components/ScrollArea.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,244 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
3
+ import { type PolymorphicRef } from '../helpers/polymorphic.js';
4
+ /** One image a Lightbox shows. */
5
+ export interface LightboxItem {
6
+ /** The full-size image's URL. */
7
+ src: string;
8
+ /**
9
+ * The image's text alternative, which the status line reads after each
10
+ * move. In a viewer the image is the content, so `''` is almost never
11
+ * right; a development build warns once for an item without one.
12
+ */
13
+ alt: string;
14
+ /** Shown under the image as its `<figcaption>`. */
15
+ caption?: React.ReactNode;
16
+ /** The `<img>`'s `srcSet`, so the browser picks a size for the screen. Preloading uses it too. */
17
+ srcSet?: string;
18
+ /** The `<img>`'s `sizes`, read with `srcSet`. */
19
+ sizes?: string;
20
+ }
21
+ /**
22
+ * The words a Lightbox writes. Each is English unless you give your own,
23
+ * and the numbers in the default progress line are written in the
24
+ * `LocaleProvider`'s locale.
25
+ */
26
+ export interface LightboxLabels {
27
+ /**
28
+ * The close button's name.
29
+ * @defaultValue 'Close'
30
+ */
31
+ close?: string;
32
+ /**
33
+ * The previous button's name.
34
+ * @defaultValue 'Previous image'
35
+ */
36
+ previous?: string;
37
+ /**
38
+ * The next button's name.
39
+ * @defaultValue 'Next image'
40
+ */
41
+ next?: string;
42
+ /**
43
+ * The zoom-in button's name.
44
+ * @defaultValue 'Zoom in'
45
+ */
46
+ zoomIn?: string;
47
+ /**
48
+ * The zoom-out button's name.
49
+ * @defaultValue 'Zoom out'
50
+ */
51
+ zoomOut?: string;
52
+ /**
53
+ * The button that fits the image again.
54
+ * @defaultValue 'Reset zoom'
55
+ */
56
+ resetZoom?: string;
57
+ /**
58
+ * The `Loader`'s name while an image loads.
59
+ * @defaultValue 'Loading image'
60
+ */
61
+ loading?: string;
62
+ /**
63
+ * Shown, above the alt text, when an image fails to load. The status line
64
+ * for a failed image starts with it, then a space and the line a loaded
65
+ * image gets, so write it as a whole sentence, punctuated as your language
66
+ * does.
67
+ * @defaultValue "This image didn't load."
68
+ */
69
+ loadError?: string;
70
+ /**
71
+ * The button that tries a failed image again.
72
+ * @defaultValue 'Retry'
73
+ */
74
+ retry?: string;
75
+ /**
76
+ * The start of the status line read after each move, which goes on with
77
+ * a colon and the image's alt: "Image 3 of 10: Harbour at dusk". For a
78
+ * failed image, `loadError` and a space come first. It gets the image's
79
+ * place counting from 1, and the number of images.
80
+ * @defaultValue (current, total) => 'Image ' + current + ' of ' + total
81
+ */
82
+ progress?: (current: number, total: number) => string;
83
+ }
84
+ /**
85
+ * Props for the Lightbox component. Its children render where it stands,
86
+ * with no wrapper. The helper props, the other attributes and the `ref`
87
+ * land on the viewer's `.modal` element while it's open.
88
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the viewer's `.modal` element, `null` while it's closed.
89
+ */
90
+ export interface LightboxProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
91
+ /** **Required.** The images, in order. */
92
+ items: LightboxItem[];
93
+ /** Rendered in place: usually `Lightbox.Trigger`s, in whatever layout you like. */
94
+ children?: React.ReactNode;
95
+ /** Whether the viewer is open (controlled). With no `items` it shows nothing. */
96
+ open?: boolean;
97
+ /**
98
+ * Whether the viewer starts open (uncontrolled).
99
+ * @defaultValue false
100
+ */
101
+ defaultOpen?: boolean;
102
+ /**
103
+ * Called when a trigger, the close button, Escape, a click on the
104
+ * background or a swipe down opens or closes the viewer, and with `false`
105
+ * when `items` goes from some to none while it's open.
106
+ */
107
+ onOpenChange?: (open: boolean) => void;
108
+ /**
109
+ * The index of the image shown (controlled). A value past either end is
110
+ * shown as the last or the first image, or wrapped round with `repeat`,
111
+ * without calling `onChange`.
112
+ */
113
+ value?: number;
114
+ /**
115
+ * The image an uncontrolled viewer shows when something other than a
116
+ * trigger opens it. A trigger opens at its own `index`.
117
+ * @defaultValue 0
118
+ */
119
+ defaultValue?: number;
120
+ /**
121
+ * Called with the new index when an arrow, a key or a swipe changes the
122
+ * image, and when a trigger opens the viewer, with the trigger's `index`
123
+ * even when that's the image already shown, before `onOpenChange(true)`.
124
+ * A parent that opens the viewer from `value` hears the trigger that way.
125
+ */
126
+ onChange?: (value: number) => void;
127
+ /**
128
+ * Go from the last image to the first and back, as Carousel does. Off,
129
+ * the previous and next buttons are `aria-disabled` at the ends.
130
+ * @defaultValue true
131
+ */
132
+ repeat?: boolean;
133
+ /**
134
+ * Zoom with the buttons, the wheel, a double click or tap, pinch and the
135
+ * `+`, `-` and `0` keys, and pan a zoomed image by dragging or with the
136
+ * arrow keys. Zoom waits for the image to load. `false` drops the zoom
137
+ * buttons and all of it.
138
+ * @defaultValue true
139
+ */
140
+ zoomable?: boolean;
141
+ /**
142
+ * How far an image zooms, as a multiple of its fitted size. The smallest
143
+ * zoom is always the fitted size.
144
+ * @defaultValue 3
145
+ */
146
+ maxZoom?: number;
147
+ /**
148
+ * Close on Escape. Only the topmost open overlay answers, as with Modal.
149
+ * @defaultValue true
150
+ */
151
+ closeOnEscape?: boolean;
152
+ /**
153
+ * Close on a click on the dark background around the image. The space
154
+ * around the image, beside the toolbar's buttons and under the caption is
155
+ * all background.
156
+ * @defaultValue true
157
+ */
158
+ closeOnClickOutside?: boolean;
159
+ /**
160
+ * Renders the viewer into a portal: `true` for the `ConfigProvider`'s
161
+ * `portalContainer` (`document.body` by default), a selector string, or an
162
+ * element. `false` renders it in place. It's on by default, unlike Modal's,
163
+ * Dialog's and Command.Dialog's, because its triggers sit in gallery
164
+ * cells, and a cell with a transform or a filter would trap a viewer
165
+ * rendered in place.
166
+ * @defaultValue true
167
+ */
168
+ portal?: boolean | string | HTMLElement;
169
+ /**
170
+ * The dialog's accessible name. It stays the same from image to image;
171
+ * the status line says which image is shown.
172
+ * @defaultValue 'Image viewer'
173
+ */
174
+ ariaLabel?: string;
175
+ /** The words it writes, for another language. */
176
+ labels?: LightboxLabels;
177
+ }
178
+ /**
179
+ * The Lightbox.Trigger component's own props, on top of the attributes of
180
+ * whatever element `as` renders.
181
+ */
182
+ export interface LightboxTriggerOwnProps extends Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
183
+ /** **Required.** The index in `items` the viewer opens at. */
184
+ index: number;
185
+ /**
186
+ * What the button shows: a thumbnail, or text such as "View all photos".
187
+ * A ratio `Image` here takes `as="div"`, since its `<figure>` would keep
188
+ * the image's alt from naming the button.
189
+ */
190
+ children?: React.ReactNode;
191
+ /** Additional CSS classes. */
192
+ className?: string;
193
+ }
194
+ /**
195
+ * Props for Lightbox.Trigger, a `<button type="button"
196
+ * aria-haspopup="dialog">` that opens the viewer. Its content names it, so
197
+ * give the thumbnail inside a real `alt`. A ratio `Image` renders a
198
+ * `<figure>`, and an image inside a figure doesn't name the button around
199
+ * it, so give that `Image` `as="div"`. A development build warns for a
200
+ * trigger outside a `Lightbox` or with no name.
201
+ * @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the element `as` renders: the `<button>`, or what `Button` renders.
202
+ */
203
+ export type LightboxTriggerProps<T extends React.ElementType = 'button'> = LightboxTriggerOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof LightboxTriggerOwnProps | 'as' | ElementColor<T>> & {
204
+ /**
205
+ * Renders the trigger through another component, which gets its class,
206
+ * `aria-haspopup`, `type="button"`, click handler and ref along with
207
+ * its own props. `as={Button} color="link"` draws it as Bulma's link
208
+ * button. `color` is taken only with a component: on an element it
209
+ * would be HTML's old presentational attribute.
210
+ */
211
+ as?: T;
212
+ };
213
+ /**
214
+ * `color`, for an element `as`: a `<button>` or another tag takes no
215
+ * `color`, as Link and Navbar.Item take none, while a component such as
216
+ * Button keeps its own.
217
+ */
218
+ type ElementColor<T extends React.ElementType> = T extends string ? 'color' : never;
219
+ /**
220
+ * Lightbox.Trigger's call signatures, those of `PolymorphicComponent` over
221
+ * `LightboxTriggerProps`, so `color` follows `as` as described there.
222
+ */
223
+ interface LightboxTriggerComponent {
224
+ <T extends React.ElementType = 'button'>(props: LightboxTriggerProps<T> & {
225
+ ref?: PolymorphicRef<T>;
226
+ }): React.ReactElement | null;
227
+ (props: LightboxTriggerProps & {
228
+ ref?: PolymorphicRef<'button'>;
229
+ }): React.ReactElement | null;
230
+ displayName?: string;
231
+ }
232
+ /**
233
+ * A button around a thumbnail, or a line of text, that opens the viewer at its `index`.
234
+ *
235
+ * @function
236
+ * @param {LightboxTriggerProps} props - Props for the trigger.
237
+ * @param {React.Ref} ref - Forwarded ref to the element `as` renders.
238
+ * @returns {JSX.Element} The rendered button.
239
+ */
240
+ export declare const LightboxTrigger: LightboxTriggerComponent;
241
+ export declare const Lightbox: React.ForwardRefExoticComponent<LightboxProps & React.RefAttributes<HTMLDivElement>> & {
242
+ Trigger: LightboxTriggerComponent;
243
+ };
244
+ export default Lightbox;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Chevron pointing left, for a previous button.
3
+ *
4
+ * @function
5
+ * @returns {JSX.Element} The rendered SVG chevron-left icon.
6
+ */
7
+ export declare const ChevronPrevIcon: () => import("react").JSX.Element;
8
+ /**
9
+ * Chevron pointing right, for a next button.
10
+ *
11
+ * @function
12
+ * @returns {JSX.Element} The rendered SVG chevron-right icon.
13
+ */
14
+ export declare const ChevronNextIcon: () => import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Detects the user's `prefers-reduced-motion` preference, for motion that
3
+ * runs in script, where a stylesheet's media query can't reach it. Always
4
+ * `false` on the server and on the very first client render, so SSR output
5
+ * and the initial hydration pass always agree.
6
+ *
7
+ * @function
8
+ * @returns {boolean} Whether the user has requested reduced motion.
9
+ */
10
+ export declare function usePrefersReducedMotion(): boolean;
@@ -0,0 +1,66 @@
1
+ import type React from 'react';
2
+ /** Which way a finished swipe went, on screen: where the pointer travelled. */
3
+ export type SwipeDirection = 'left' | 'right' | 'up' | 'down';
4
+ /** Options for `useSwipe`. */
5
+ export interface UseSwipeOptions {
6
+ /**
7
+ * Whether a press starts a drag. Off, the handlers leave a press alone,
8
+ * `preventDefault()` included. A drag already under way still finishes.
9
+ * @defaultValue true
10
+ */
11
+ enabled?: boolean;
12
+ /**
13
+ * Follow the vertical axis too, so a swipe up or down is reported. Off,
14
+ * only the horizontal distance counts and `offsetY` stays `0`.
15
+ * @defaultValue false
16
+ */
17
+ vertical?: boolean;
18
+ /**
19
+ * Called when a drag ends more than 50px from where it started along an
20
+ * axis. With `vertical`, the axis it travelled further along decides.
21
+ * The direction is physical, so a caller that follows the reading
22
+ * direction maps it itself.
23
+ */
24
+ onSwipe: (direction: SwipeDirection) => void;
25
+ }
26
+ /** The mouse and touch handlers `useSwipe` hands back, to spread on the surface. */
27
+ export interface SwipeHandlers<T extends Element = Element> {
28
+ /** Starts a drag. Calls `preventDefault()` while enabled, so the press neither selects text nor drags an image. */
29
+ onMouseDown: (event: React.MouseEvent<T>) => void;
30
+ /** Follows a drag. */
31
+ onMouseMove: (event: React.MouseEvent<T>) => void;
32
+ /** Ends a drag. */
33
+ onMouseUp: () => void;
34
+ /** Ends a drag when the pointer leaves the surface, as a release would. */
35
+ onMouseLeave: () => void;
36
+ /** Starts a drag with the first finger. */
37
+ onTouchStart: (event: React.TouchEvent<T>) => void;
38
+ /** Follows the first finger. */
39
+ onTouchMove: (event: React.TouchEvent<T>) => void;
40
+ /** Ends a drag. */
41
+ onTouchEnd: () => void;
42
+ }
43
+ /** What `useSwipe` returns. */
44
+ export interface UseSwipeResult<T extends Element = Element> {
45
+ /** Whether a drag is under way. */
46
+ isSwiping: boolean;
47
+ /** How far the drag has gone across, in CSS pixels, `0` between drags. */
48
+ offsetX: number;
49
+ /** How far the drag has gone down (up is negative), `0` without `vertical`. */
50
+ offsetY: number;
51
+ /** The handlers to put on the surface that takes the drag. */
52
+ handlers: SwipeHandlers<T>;
53
+ /** Drops the drag under way without reporting a swipe, as when a second finger lands. */
54
+ cancel: () => void;
55
+ }
56
+ /**
57
+ * Follows a mouse or touch drag on a surface and reports a swipe when it
58
+ * ends far enough from where it started. Carousel's drag, shared: it hands
59
+ * back the handlers to put on the surface and the live offset to draw the
60
+ * drag with, and leaves what a swipe does to the component.
61
+ *
62
+ * @function
63
+ * @param {UseSwipeOptions} options - Whether it's on, the axes, and the callback.
64
+ * @returns {UseSwipeResult} The drag's state, its handlers, and a way to drop it.
65
+ */
66
+ export declare function useSwipe<T extends Element = Element>({ enabled, vertical, onSwipe, }: UseSwipeOptions): UseSwipeResult<T>;
@@ -28,6 +28,7 @@ export * from './components/Sidebar.js';
28
28
  export * from './components/Toast.js';
29
29
  export * from './components/Dialog.js';
30
30
  export * from './components/Carousel.js';
31
+ export * from './components/Lightbox.js';
31
32
  export * from './components/Reveal.js';
32
33
  export * from './components/TreeView.js';
33
34
  export * from './components/ScrollArea.js';
@@ -0,0 +1,244 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
3
+ import { type PolymorphicRef } from '../helpers/polymorphic.js';
4
+ /** One image a Lightbox shows. */
5
+ export interface LightboxItem {
6
+ /** The full-size image's URL. */
7
+ src: string;
8
+ /**
9
+ * The image's text alternative, which the status line reads after each
10
+ * move. In a viewer the image is the content, so `''` is almost never
11
+ * right; a development build warns once for an item without one.
12
+ */
13
+ alt: string;
14
+ /** Shown under the image as its `<figcaption>`. */
15
+ caption?: React.ReactNode;
16
+ /** The `<img>`'s `srcSet`, so the browser picks a size for the screen. Preloading uses it too. */
17
+ srcSet?: string;
18
+ /** The `<img>`'s `sizes`, read with `srcSet`. */
19
+ sizes?: string;
20
+ }
21
+ /**
22
+ * The words a Lightbox writes. Each is English unless you give your own,
23
+ * and the numbers in the default progress line are written in the
24
+ * `LocaleProvider`'s locale.
25
+ */
26
+ export interface LightboxLabels {
27
+ /**
28
+ * The close button's name.
29
+ * @defaultValue 'Close'
30
+ */
31
+ close?: string;
32
+ /**
33
+ * The previous button's name.
34
+ * @defaultValue 'Previous image'
35
+ */
36
+ previous?: string;
37
+ /**
38
+ * The next button's name.
39
+ * @defaultValue 'Next image'
40
+ */
41
+ next?: string;
42
+ /**
43
+ * The zoom-in button's name.
44
+ * @defaultValue 'Zoom in'
45
+ */
46
+ zoomIn?: string;
47
+ /**
48
+ * The zoom-out button's name.
49
+ * @defaultValue 'Zoom out'
50
+ */
51
+ zoomOut?: string;
52
+ /**
53
+ * The button that fits the image again.
54
+ * @defaultValue 'Reset zoom'
55
+ */
56
+ resetZoom?: string;
57
+ /**
58
+ * The `Loader`'s name while an image loads.
59
+ * @defaultValue 'Loading image'
60
+ */
61
+ loading?: string;
62
+ /**
63
+ * Shown, above the alt text, when an image fails to load. The status line
64
+ * for a failed image starts with it, then a space and the line a loaded
65
+ * image gets, so write it as a whole sentence, punctuated as your language
66
+ * does.
67
+ * @defaultValue "This image didn't load."
68
+ */
69
+ loadError?: string;
70
+ /**
71
+ * The button that tries a failed image again.
72
+ * @defaultValue 'Retry'
73
+ */
74
+ retry?: string;
75
+ /**
76
+ * The start of the status line read after each move, which goes on with
77
+ * a colon and the image's alt: "Image 3 of 10: Harbour at dusk". For a
78
+ * failed image, `loadError` and a space come first. It gets the image's
79
+ * place counting from 1, and the number of images.
80
+ * @defaultValue (current, total) => 'Image ' + current + ' of ' + total
81
+ */
82
+ progress?: (current: number, total: number) => string;
83
+ }
84
+ /**
85
+ * Props for the Lightbox component. Its children render where it stands,
86
+ * with no wrapper. The helper props, the other attributes and the `ref`
87
+ * land on the viewer's `.modal` element while it's open.
88
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the viewer's `.modal` element, `null` while it's closed.
89
+ */
90
+ export interface LightboxProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
91
+ /** **Required.** The images, in order. */
92
+ items: LightboxItem[];
93
+ /** Rendered in place: usually `Lightbox.Trigger`s, in whatever layout you like. */
94
+ children?: React.ReactNode;
95
+ /** Whether the viewer is open (controlled). With no `items` it shows nothing. */
96
+ open?: boolean;
97
+ /**
98
+ * Whether the viewer starts open (uncontrolled).
99
+ * @defaultValue false
100
+ */
101
+ defaultOpen?: boolean;
102
+ /**
103
+ * Called when a trigger, the close button, Escape, a click on the
104
+ * background or a swipe down opens or closes the viewer, and with `false`
105
+ * when `items` goes from some to none while it's open.
106
+ */
107
+ onOpenChange?: (open: boolean) => void;
108
+ /**
109
+ * The index of the image shown (controlled). A value past either end is
110
+ * shown as the last or the first image, or wrapped round with `repeat`,
111
+ * without calling `onChange`.
112
+ */
113
+ value?: number;
114
+ /**
115
+ * The image an uncontrolled viewer shows when something other than a
116
+ * trigger opens it. A trigger opens at its own `index`.
117
+ * @defaultValue 0
118
+ */
119
+ defaultValue?: number;
120
+ /**
121
+ * Called with the new index when an arrow, a key or a swipe changes the
122
+ * image, and when a trigger opens the viewer, with the trigger's `index`
123
+ * even when that's the image already shown, before `onOpenChange(true)`.
124
+ * A parent that opens the viewer from `value` hears the trigger that way.
125
+ */
126
+ onChange?: (value: number) => void;
127
+ /**
128
+ * Go from the last image to the first and back, as Carousel does. Off,
129
+ * the previous and next buttons are `aria-disabled` at the ends.
130
+ * @defaultValue true
131
+ */
132
+ repeat?: boolean;
133
+ /**
134
+ * Zoom with the buttons, the wheel, a double click or tap, pinch and the
135
+ * `+`, `-` and `0` keys, and pan a zoomed image by dragging or with the
136
+ * arrow keys. Zoom waits for the image to load. `false` drops the zoom
137
+ * buttons and all of it.
138
+ * @defaultValue true
139
+ */
140
+ zoomable?: boolean;
141
+ /**
142
+ * How far an image zooms, as a multiple of its fitted size. The smallest
143
+ * zoom is always the fitted size.
144
+ * @defaultValue 3
145
+ */
146
+ maxZoom?: number;
147
+ /**
148
+ * Close on Escape. Only the topmost open overlay answers, as with Modal.
149
+ * @defaultValue true
150
+ */
151
+ closeOnEscape?: boolean;
152
+ /**
153
+ * Close on a click on the dark background around the image. The space
154
+ * around the image, beside the toolbar's buttons and under the caption is
155
+ * all background.
156
+ * @defaultValue true
157
+ */
158
+ closeOnClickOutside?: boolean;
159
+ /**
160
+ * Renders the viewer into a portal: `true` for the `ConfigProvider`'s
161
+ * `portalContainer` (`document.body` by default), a selector string, or an
162
+ * element. `false` renders it in place. It's on by default, unlike Modal's,
163
+ * Dialog's and Command.Dialog's, because its triggers sit in gallery
164
+ * cells, and a cell with a transform or a filter would trap a viewer
165
+ * rendered in place.
166
+ * @defaultValue true
167
+ */
168
+ portal?: boolean | string | HTMLElement;
169
+ /**
170
+ * The dialog's accessible name. It stays the same from image to image;
171
+ * the status line says which image is shown.
172
+ * @defaultValue 'Image viewer'
173
+ */
174
+ ariaLabel?: string;
175
+ /** The words it writes, for another language. */
176
+ labels?: LightboxLabels;
177
+ }
178
+ /**
179
+ * The Lightbox.Trigger component's own props, on top of the attributes of
180
+ * whatever element `as` renders.
181
+ */
182
+ export interface LightboxTriggerOwnProps extends Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
183
+ /** **Required.** The index in `items` the viewer opens at. */
184
+ index: number;
185
+ /**
186
+ * What the button shows: a thumbnail, or text such as "View all photos".
187
+ * A ratio `Image` here takes `as="div"`, since its `<figure>` would keep
188
+ * the image's alt from naming the button.
189
+ */
190
+ children?: React.ReactNode;
191
+ /** Additional CSS classes. */
192
+ className?: string;
193
+ }
194
+ /**
195
+ * Props for Lightbox.Trigger, a `<button type="button"
196
+ * aria-haspopup="dialog">` that opens the viewer. Its content names it, so
197
+ * give the thumbnail inside a real `alt`. A ratio `Image` renders a
198
+ * `<figure>`, and an image inside a figure doesn't name the button around
199
+ * it, so give that `Image` `as="div"`. A development build warns for a
200
+ * trigger outside a `Lightbox` or with no name.
201
+ * @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the element `as` renders: the `<button>`, or what `Button` renders.
202
+ */
203
+ export type LightboxTriggerProps<T extends React.ElementType = 'button'> = LightboxTriggerOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof LightboxTriggerOwnProps | 'as' | ElementColor<T>> & {
204
+ /**
205
+ * Renders the trigger through another component, which gets its class,
206
+ * `aria-haspopup`, `type="button"`, click handler and ref along with
207
+ * its own props. `as={Button} color="link"` draws it as Bulma's link
208
+ * button. `color` is taken only with a component: on an element it
209
+ * would be HTML's old presentational attribute.
210
+ */
211
+ as?: T;
212
+ };
213
+ /**
214
+ * `color`, for an element `as`: a `<button>` or another tag takes no
215
+ * `color`, as Link and Navbar.Item take none, while a component such as
216
+ * Button keeps its own.
217
+ */
218
+ type ElementColor<T extends React.ElementType> = T extends string ? 'color' : never;
219
+ /**
220
+ * Lightbox.Trigger's call signatures, those of `PolymorphicComponent` over
221
+ * `LightboxTriggerProps`, so `color` follows `as` as described there.
222
+ */
223
+ interface LightboxTriggerComponent {
224
+ <T extends React.ElementType = 'button'>(props: LightboxTriggerProps<T> & {
225
+ ref?: PolymorphicRef<T>;
226
+ }): React.ReactElement | null;
227
+ (props: LightboxTriggerProps & {
228
+ ref?: PolymorphicRef<'button'>;
229
+ }): React.ReactElement | null;
230
+ displayName?: string;
231
+ }
232
+ /**
233
+ * A button around a thumbnail, or a line of text, that opens the viewer at its `index`.
234
+ *
235
+ * @function
236
+ * @param {LightboxTriggerProps} props - Props for the trigger.
237
+ * @param {React.Ref} ref - Forwarded ref to the element `as` renders.
238
+ * @returns {JSX.Element} The rendered button.
239
+ */
240
+ export declare const LightboxTrigger: LightboxTriggerComponent;
241
+ export declare const Lightbox: React.ForwardRefExoticComponent<LightboxProps & React.RefAttributes<HTMLDivElement>> & {
242
+ Trigger: LightboxTriggerComponent;
243
+ };
244
+ export default Lightbox;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Chevron pointing left, for a previous button.
3
+ *
4
+ * @function
5
+ * @returns {JSX.Element} The rendered SVG chevron-left icon.
6
+ */
7
+ export declare const ChevronPrevIcon: () => import("react").JSX.Element;
8
+ /**
9
+ * Chevron pointing right, for a next button.
10
+ *
11
+ * @function
12
+ * @returns {JSX.Element} The rendered SVG chevron-right icon.
13
+ */
14
+ export declare const ChevronNextIcon: () => import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Detects the user's `prefers-reduced-motion` preference, for motion that
3
+ * runs in script, where a stylesheet's media query can't reach it. Always
4
+ * `false` on the server and on the very first client render, so SSR output
5
+ * and the initial hydration pass always agree.
6
+ *
7
+ * @function
8
+ * @returns {boolean} Whether the user has requested reduced motion.
9
+ */
10
+ export declare function usePrefersReducedMotion(): boolean;