@allxsmith/bestax-bulma 5.63.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.
- package/dist/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/esm/components/Carousel.js +12 -66
- package/dist/esm/components/Carousel.js.map +1 -1
- package/dist/esm/components/Lightbox.js +756 -0
- package/dist/esm/components/Lightbox.js.map +1 -0
- package/dist/esm/components/Reveal.js +1 -24
- package/dist/esm/components/Reveal.js.map +1 -1
- package/dist/esm/components/ScrollArea.js +7 -7
- package/dist/esm/components/ScrollArea.js.map +1 -1
- package/dist/esm/components/TableOfContents.js +85 -0
- package/dist/esm/components/TableOfContents.js.map +1 -0
- package/dist/esm/form/PasswordInput.js +105 -0
- package/dist/esm/form/PasswordInput.js.map +1 -0
- package/dist/esm/form/PasswordInputBase.js +177 -0
- package/dist/esm/form/PasswordInputBase.js.map +1 -0
- package/dist/esm/helpers/chevronIcons.js +24 -0
- package/dist/esm/helpers/chevronIcons.js.map +1 -0
- package/dist/esm/helpers/usePrefersReducedMotion.js +34 -0
- package/dist/esm/helpers/usePrefersReducedMotion.js.map +1 -0
- package/dist/esm/helpers/useScrollSpy.js +286 -0
- package/dist/esm/helpers/useScrollSpy.js.map +1 -0
- package/dist/esm/helpers/useSwipe.js +82 -0
- package/dist/esm/helpers/useSwipe.js.map +1 -0
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +1582 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +5 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Lightbox.d.ts +244 -0
- package/dist/types/components/TableOfContents.d.ts +87 -0
- package/dist/types/form/PasswordInput.d.ts +98 -0
- package/dist/types/form/PasswordInputBase.d.ts +91 -0
- package/dist/types/helpers/chevronIcons.d.ts +14 -0
- package/dist/types/helpers/usePrefersReducedMotion.d.ts +10 -0
- package/dist/types/helpers/useScrollSpy.d.ts +61 -0
- package/dist/types/helpers/useSwipe.d.ts +66 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types-cjs/components/Lightbox.d.ts +244 -0
- package/dist/types-cjs/components/TableOfContents.d.ts +87 -0
- package/dist/types-cjs/form/PasswordInput.d.ts +98 -0
- package/dist/types-cjs/form/PasswordInputBase.d.ts +91 -0
- package/dist/types-cjs/helpers/chevronIcons.d.ts +14 -0
- package/dist/types-cjs/helpers/usePrefersReducedMotion.d.ts +10 -0
- package/dist/types-cjs/helpers/useScrollSpy.d.ts +61 -0
- package/dist/types-cjs/helpers/useSwipe.d.ts +66 -0
- package/dist/types-cjs/index.d.ts +6 -0
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +1 -1
- package/src/scss/CLAUDE.md +3 -0
- package/src/scss/_input-trigger.scss +76 -0
- package/src/scss/components/_index.scss +2 -0
- package/src/scss/components/_lightbox.scss +392 -0
- package/src/scss/components/_tableofcontents.scss +42 -0
- package/src/scss/form/_index.scss +1 -0
- package/src/scss/form/_passwordinput.scss +112 -0
- package/src/scss/form/_picker-popover.scss +24 -63
|
@@ -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>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -28,12 +28,14 @@ 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';
|
|
34
35
|
export * from './components/Command.js';
|
|
35
36
|
export * from './components/DataTable.js';
|
|
36
37
|
export * from './components/Affix.js';
|
|
38
|
+
export * from './components/TableOfContents.js';
|
|
37
39
|
export * from './elements/Block.js';
|
|
38
40
|
export * from './elements/Box.js';
|
|
39
41
|
export * from './elements/Button.js';
|
|
@@ -108,12 +110,16 @@ export { SelectBase } from './form/SelectBase.js';
|
|
|
108
110
|
export type { SelectBaseProps } from './form/SelectBase.js';
|
|
109
111
|
export { TextAreaBase } from './form/TextAreaBase.js';
|
|
110
112
|
export type { TextAreaBaseProps } from './form/TextAreaBase.js';
|
|
113
|
+
export { PasswordInputBase } from './form/PasswordInputBase.js';
|
|
114
|
+
export type { PasswordInputBaseProps, PasswordInputLabels, PasswordInputVariant, } from './form/PasswordInputBase.js';
|
|
111
115
|
export { Input } from './form/Input.js';
|
|
112
116
|
export type { InputProps } from './form/Input.js';
|
|
113
117
|
export { Select } from './form/Select.js';
|
|
114
118
|
export type { SelectProps } from './form/Select.js';
|
|
115
119
|
export { TextArea } from './form/TextArea.js';
|
|
116
120
|
export type { TextAreaProps } from './form/TextArea.js';
|
|
121
|
+
export { PasswordInput } from './form/PasswordInput.js';
|
|
122
|
+
export type { PasswordInputProps } from './form/PasswordInput.js';
|
|
117
123
|
export { DateInputBase } from './form/DateInputBase.js';
|
|
118
124
|
export type { DateInputBaseProps } from './form/DateInputBase.js';
|
|
119
125
|
export { DateInput } from './form/DateInput.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,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
export { useScrollSpy } from '../helpers/useScrollSpy.js';
|
|
4
|
+
export type { UseScrollSpyOptions } from '../helpers/useScrollSpy.js';
|
|
5
|
+
/** One entry in a TableOfContents. */
|
|
6
|
+
export interface TableOfContentsItem {
|
|
7
|
+
/** **Required.** The `id` of the section or heading it links to, without the `#`. Unique on the page. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** **Required.** What the link says, usually the heading's own text. */
|
|
10
|
+
label: React.ReactNode;
|
|
11
|
+
/** Entries under this one, drawn as a nested list. */
|
|
12
|
+
children?: TableOfContentsItem[];
|
|
13
|
+
}
|
|
14
|
+
/** The visible strings, in your app's language. */
|
|
15
|
+
export interface TableOfContentsLabels {
|
|
16
|
+
/**
|
|
17
|
+
* The list's visible title, which also names its `<nav>`.
|
|
18
|
+
* @defaultValue 'On this page'
|
|
19
|
+
*/
|
|
20
|
+
title?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Props for the TableOfContents component. The helper props, the other
|
|
24
|
+
* attributes and the `ref` land on the `<nav>`.
|
|
25
|
+
*
|
|
26
|
+
* @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<nav>`.
|
|
27
|
+
*/
|
|
28
|
+
export interface TableOfContentsProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color' | 'children'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
29
|
+
/** Additional CSS classes to apply. */
|
|
30
|
+
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* **Required.** The sections, in page order, as links to their ids. Each
|
|
33
|
+
* link is a plain `<a href="#id">`, so following one is the browser's own
|
|
34
|
+
* jump: put `scroll-padding-top` on the page to land clear of a sticky
|
|
35
|
+
* header, and smooth scrolling, if you want it, in page CSS inside
|
|
36
|
+
* `@media (prefers-reduced-motion: no-preference)`.
|
|
37
|
+
*/
|
|
38
|
+
items: TableOfContentsItem[];
|
|
39
|
+
/**
|
|
40
|
+
* Called with the current section's id when it changes, or `null` above
|
|
41
|
+
* the first section. Never called on the server or before hydration.
|
|
42
|
+
*/
|
|
43
|
+
onCurrentChange?: (id: string | null) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Pixels from the viewport's top where a section counts as reached.
|
|
46
|
+
* Unset, it's the page's `scroll-padding-top`, so the highlight agrees
|
|
47
|
+
* with where a jump lands under a sticky header.
|
|
48
|
+
*/
|
|
49
|
+
offset?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Sticks to the top of the viewport as the page scrolls, at
|
|
52
|
+
* `--bulma-table-of-contents-sticky-top`, and scrolls itself when it's
|
|
53
|
+
* taller than the viewport. Adds `is-sticky`.
|
|
54
|
+
*/
|
|
55
|
+
isSticky?: boolean;
|
|
56
|
+
/** The visible strings, in your app's language. */
|
|
57
|
+
labels?: TableOfContentsLabels;
|
|
58
|
+
/** Text color helper. */
|
|
59
|
+
textColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
60
|
+
/** Background color helper. */
|
|
61
|
+
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The `TableOfContents` component lists a long page's sections as links in Bulma's menu look, and marks the one being read.
|
|
65
|
+
*
|
|
66
|
+
* It's a `<nav>` named by its title, holding `MenuList` and `MenuItem` links
|
|
67
|
+
* to each `#id`, rendered in full on the server. `useScrollSpy` picks the
|
|
68
|
+
* current section, and its link alone gets `is-active` and
|
|
69
|
+
* `aria-current="location"`. Use the hook on its own to mark the section in
|
|
70
|
+
* view somewhere else, such as an app's nav `Menu`.
|
|
71
|
+
*
|
|
72
|
+
* @function
|
|
73
|
+
* @param {TableOfContentsProps} props - Props for the TableOfContents component.
|
|
74
|
+
* @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<nav>`.
|
|
75
|
+
* @returns {JSX.Element} The rendered table of contents.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* <TableOfContents
|
|
79
|
+
* isSticky
|
|
80
|
+
* items={[
|
|
81
|
+
* { id: 'install', label: 'Install' },
|
|
82
|
+
* { id: 'usage', label: 'Usage', children: [{ id: 'props', label: 'Props' }] },
|
|
83
|
+
* ]}
|
|
84
|
+
* />
|
|
85
|
+
*/
|
|
86
|
+
export declare const TableOfContents: React.ForwardRefExoticComponent<TableOfContentsProps & React.RefAttributes<HTMLElement>>;
|
|
87
|
+
export default TableOfContents;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldProps } from './Field.js';
|
|
3
|
+
import { ControlBaseProps } from './Control.js';
|
|
4
|
+
import { PasswordInputBaseProps } from './PasswordInputBase.js';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the PasswordInput component: PasswordInputBase's, plus Input's
|
|
7
|
+
* Field and Control props, except the right icon, whose place the toggle
|
|
8
|
+
* takes. Inside an existing `Control` it renders no `Control` of its own, so
|
|
9
|
+
* its Control-level props do nothing there and warn in development; set them
|
|
10
|
+
* on that `Control` instead. Inside an outer `Field`, or a `Control` with no
|
|
11
|
+
* `Field` around it, it renders no `Field` of its own either. The exception
|
|
12
|
+
* is `label`, `message`, `horizontal` or `fieldClassName` in that bare
|
|
13
|
+
* `Control`: it keeps a `Field` for them, nested in the `.control`, and warns
|
|
14
|
+
* in development. Wrap the `Control` in a `Field` instead, and set the
|
|
15
|
+
* `label`, `horizontal` and class name on that `Field`.
|
|
16
|
+
*
|
|
17
|
+
* @helperProps Helper props go on the `.password-input-container` `<div>`, with
|
|
18
|
+
* `className` and `style`, so they move and size the field and its toggle
|
|
19
|
+
* together. The other attributes go on the `<input>`.
|
|
20
|
+
* @extraProp {string} [autoComplete="current-password"] - Tells the browser and password managers this is an existing password. Pass `"new-password"` where the user makes one up, on a sign-up or change-password form.
|
|
21
|
+
* @extraProp {boolean} [spellCheck=false] - Off, so a browser's spellcheck never sees the password once it shows.
|
|
22
|
+
* @extraProp {string} [autoCorrect="off"] - Off, so a phone's keyboard doesn't change what's typed.
|
|
23
|
+
* @extraProp {string} [autoCapitalize="none"] - Off, so a phone's keyboard doesn't capitalize the first letter.
|
|
24
|
+
* @extraProp {string} [value] - The password, controlled. React writes a controlled input's value into its `value` attribute, as it does on any input, so the password sits in the page's markup. Uncontrolled, read with `FormData`, the field never puts what's typed there.
|
|
25
|
+
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Ref forwarded to the `<input>`.
|
|
26
|
+
*/
|
|
27
|
+
export interface PasswordInputProps extends PasswordInputBaseProps {
|
|
28
|
+
/** Field label. Automatically associated with the input via `htmlFor`, using your `id` when provided, otherwise a generated one. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`) and you set no `id` here. */
|
|
29
|
+
label?: React.ReactNode;
|
|
30
|
+
/** Size for the label. */
|
|
31
|
+
labelSize?: FieldProps['labelSize'];
|
|
32
|
+
/** Props for the label element when the component renders its own `Field`; dropped inside an outer `Field` (use that `Field`'s `labelProps` instead). An explicit `htmlFor` key, even `undefined`, overrides the automatic association and no id is generated. */
|
|
33
|
+
labelProps?: FieldProps['labelProps'];
|
|
34
|
+
/** Horizontal field layout. */
|
|
35
|
+
horizontal?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Icon props for the left icon.
|
|
38
|
+
* Bulma gives control icons `pointer-events: none`, so a clickable node here
|
|
39
|
+
* never receives a click.
|
|
40
|
+
*/
|
|
41
|
+
iconLeft?: ControlBaseProps['iconLeft'];
|
|
42
|
+
/** Shortcut for the left icon's name. */
|
|
43
|
+
iconLeftName?: string;
|
|
44
|
+
/** Shortcut for the left icon's size. */
|
|
45
|
+
iconLeftSize?: ControlBaseProps['iconLeftSize'];
|
|
46
|
+
/** Force the left icon container. */
|
|
47
|
+
hasIconsLeft?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Shows a loading spinner on the `Control` it renders, at the edge the
|
|
50
|
+
* toggle uses, so the toggle isn't drawn meanwhile, and a shown password is
|
|
51
|
+
* hidden until it's back. Inside your own
|
|
52
|
+
* `Control` it renders none, so this draws nothing and warns in
|
|
53
|
+
* development; set `isLoading` on that `Control`, which hides the toggle
|
|
54
|
+
* too.
|
|
55
|
+
*/
|
|
56
|
+
isLoading?: boolean;
|
|
57
|
+
/** Expand the control. */
|
|
58
|
+
isExpanded?: boolean;
|
|
59
|
+
/** Control size. */
|
|
60
|
+
controlSize?: ControlBaseProps['size'];
|
|
61
|
+
/** Help/validation message below the input. */
|
|
62
|
+
message?: React.ReactNode;
|
|
63
|
+
/** Bulma color for the message. */
|
|
64
|
+
messageColor?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
|
|
65
|
+
/** Additional CSS classes for the Field. */
|
|
66
|
+
fieldClassName?: string;
|
|
67
|
+
/** Additional CSS classes for the Control. */
|
|
68
|
+
controlClassName?: string;
|
|
69
|
+
/** Not offered: the toggle takes the right icon's place. Warns in development if passed. @internal */
|
|
70
|
+
iconRight?: never;
|
|
71
|
+
/** Not offered, as `iconRight`. @internal */
|
|
72
|
+
iconRightName?: never;
|
|
73
|
+
/** Not offered, as `iconRight`. @internal */
|
|
74
|
+
iconRightSize?: never;
|
|
75
|
+
/** Not offered, as `iconRight`. @internal */
|
|
76
|
+
hasIconsRight?: never;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The `PasswordInput` component is a password field with a button inside it that shows what was typed.
|
|
80
|
+
*
|
|
81
|
+
* By default the button is an eye named "Show password" that reports
|
|
82
|
+
* whether the password shows with `aria-pressed`; `variant="text"` makes it
|
|
83
|
+
* the words "Show" and "Hide". The field asks for
|
|
84
|
+
* `autocomplete="current-password"` and no spellcheck, and hides the
|
|
85
|
+
* password again when its form submits.
|
|
86
|
+
*
|
|
87
|
+
* @function
|
|
88
|
+
* @param {PasswordInputProps} props - Props for PasswordInput.
|
|
89
|
+
* @returns {JSX.Element} The composed field element.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* <PasswordInput label="Password" />
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* <PasswordInput label="New password" autoComplete="new-password" variant="text" />
|
|
96
|
+
*/
|
|
97
|
+
export declare const PasswordInput: React.ForwardRefExoticComponent<PasswordInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
98
|
+
export default PasswordInput;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { InputBaseProps } from './InputBase.js';
|
|
2
|
+
/** How PasswordInput's visibility toggle draws itself. */
|
|
3
|
+
export type PasswordInputVariant = 'icon' | 'text';
|
|
4
|
+
/** The strings PasswordInput's toggle shows and announces, for translating. */
|
|
5
|
+
export interface PasswordInputLabels {
|
|
6
|
+
/**
|
|
7
|
+
* The toggle's name. With the `icon` variant it's the name in both states,
|
|
8
|
+
* and `aria-pressed` says whether the password shows. With `text`, it's the
|
|
9
|
+
* name while the password is hidden, and it has to contain `show`, the word
|
|
10
|
+
* on the button.
|
|
11
|
+
* @defaultValue 'Show password'
|
|
12
|
+
*/
|
|
13
|
+
showPassword?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The `text` variant's name while the password shows. It has to contain
|
|
16
|
+
* `hide`.
|
|
17
|
+
* @defaultValue 'Hide password'
|
|
18
|
+
*/
|
|
19
|
+
hidePassword?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The `text` variant's word while the password is hidden.
|
|
22
|
+
* @defaultValue 'Show'
|
|
23
|
+
*/
|
|
24
|
+
show?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The `text` variant's word while the password shows.
|
|
27
|
+
* @defaultValue 'Hide'
|
|
28
|
+
*/
|
|
29
|
+
hide?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Props for PasswordInputBase, the input and its toggle without a Field or a
|
|
33
|
+
* Control.
|
|
34
|
+
*
|
|
35
|
+
* @helperProps Helper props go on the `.password-input-container` `<div>`, with
|
|
36
|
+
* `className` and `style`, so they move and size the field and its toggle
|
|
37
|
+
* together. The other attributes go on the `<input>`.
|
|
38
|
+
* @extraProp {string} [autoComplete="current-password"] - Tells the browser and password managers this is an existing password. Pass `"new-password"` where the user makes one up, on a sign-up or change-password form.
|
|
39
|
+
* @extraProp {boolean} [spellCheck=false] - Off, so a browser's spellcheck never sees the password once it shows.
|
|
40
|
+
* @extraProp {string} [autoCorrect="off"] - Off, so a phone's keyboard doesn't change what's typed.
|
|
41
|
+
* @extraProp {string} [autoCapitalize="none"] - Off, so a phone's keyboard doesn't capitalize the first letter.
|
|
42
|
+
* @extraProp {string} [value] - The password, controlled. React writes a controlled input's value into its `value` attribute, as it does on any input, so the password sits in the page's markup. Uncontrolled, read with `FormData`, the field never puts what's typed there.
|
|
43
|
+
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Ref forwarded to the `<input>`.
|
|
44
|
+
*/
|
|
45
|
+
export interface PasswordInputBaseProps extends Omit<InputBaseProps, 'type'> {
|
|
46
|
+
/**
|
|
47
|
+
* Whether the password shows, when you hold the state. Setting it makes
|
|
48
|
+
* the visibility controlled: the toggle only calls `onVisibleChange`, and
|
|
49
|
+
* so does hiding again on its own. Apply that `false` and the field is a
|
|
50
|
+
* password field by the time the form reads it; keep `visible` true and
|
|
51
|
+
* the field stays shown.
|
|
52
|
+
*/
|
|
53
|
+
visible?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the password shows at first, when the input holds its own state.
|
|
56
|
+
* @defaultValue false
|
|
57
|
+
*/
|
|
58
|
+
defaultVisible?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Called with the new visibility on each toggle, and with `false` when the
|
|
61
|
+
* form submits or resets, or the page is left, which it also is on the way
|
|
62
|
+
* into the back-forward cache. React renders those hides at once, a state
|
|
63
|
+
* update you make here included, so the form reads a password field. One
|
|
64
|
+
* that fires while React is rendering or committing, which includes your
|
|
65
|
+
* `useEffect` and `useLayoutEffect` callbacks, such as a `requestSubmit()`
|
|
66
|
+
* from an effect, can't render there, and lands just after the form is
|
|
67
|
+
* read: hide the password first, or submit from an event handler.
|
|
68
|
+
*/
|
|
69
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
70
|
+
/**
|
|
71
|
+
* How the toggle draws itself: an eye icon with a fixed name and
|
|
72
|
+
* `aria-pressed`, or the words "Show" and "Hide" with a name that follows
|
|
73
|
+
* them.
|
|
74
|
+
* @defaultValue 'icon'
|
|
75
|
+
*/
|
|
76
|
+
variant?: PasswordInputVariant;
|
|
77
|
+
/** Translations for the toggle. */
|
|
78
|
+
labels?: PasswordInputLabels;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The raw PasswordInput: a password field with a button inside it that shows what was typed, without Field/Control wrapping.
|
|
82
|
+
*
|
|
83
|
+
* Use `PasswordInput` for the convenience wrapper.
|
|
84
|
+
*
|
|
85
|
+
* @function
|
|
86
|
+
* @param {PasswordInputBaseProps} props - Props for PasswordInputBase.
|
|
87
|
+
* @param {React.Ref<HTMLInputElement>} ref - Forwarded ref to the `<input>`.
|
|
88
|
+
* @returns {JSX.Element} The input and its toggle, in a container.
|
|
89
|
+
*/
|
|
90
|
+
export declare const PasswordInputBase: import("react").ForwardRefExoticComponent<PasswordInputBaseProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
91
|
+
export default PasswordInputBase;
|
|
@@ -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;
|