@allxsmith/bestax-bulma 5.54.0 → 5.55.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/Command.js +22 -22
- package/dist/esm/components/Command.js.map +1 -1
- package/dist/esm/components/DataTable.js +215 -0
- package/dist/esm/components/DataTable.js.map +1 -0
- package/dist/esm/components/useDataTable.js +482 -0
- package/dist/esm/components/useDataTable.js.map +1 -0
- package/dist/esm/elements/ColorSwatch.js +49 -0
- package/dist/esm/elements/ColorSwatch.js.map +1 -0
- package/dist/esm/elements/RingProgress.js +3 -3
- package/dist/esm/elements/Td.js +4 -2
- package/dist/esm/elements/Td.js.map +1 -1
- package/dist/esm/elements/Th.js +13 -5
- package/dist/esm/elements/Th.js.map +1 -1
- package/dist/esm/elements/Tr.js.map +1 -1
- package/dist/esm/form/ColorPicker.js +540 -0
- package/dist/esm/form/ColorPicker.js.map +1 -0
- package/dist/esm/form/Combobox.js +18 -18
- package/dist/esm/form/Combobox.js.map +1 -1
- package/dist/esm/form/Dropzone.js +524 -0
- package/dist/esm/form/Dropzone.js.map +1 -0
- package/dist/esm/form/File.js.map +1 -1
- package/dist/esm/form/_colorInternals/colorMath.js +292 -0
- package/dist/esm/form/_colorInternals/colorMath.js.map +1 -0
- package/dist/esm/form/_colorInternals/pickerState.js +160 -0
- package/dist/esm/form/_colorInternals/pickerState.js.map +1 -0
- package/dist/esm/helpers/statusRegion.js +3 -3
- package/dist/esm/helpers/statusRegion.js.map +1 -1
- package/dist/esm/helpers/useFocusTrap.js +2 -2
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +2986 -796
- 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/DataTable.d.ts +120 -0
- package/dist/types/components/useDataTable.d.ts +445 -0
- package/dist/types/elements/ColorSwatch.d.ts +54 -0
- package/dist/types/elements/Td.d.ts +9 -1
- package/dist/types/elements/Th.d.ts +14 -2
- package/dist/types/elements/Tr.d.ts +10 -1
- package/dist/types/form/ColorPicker.d.ts +266 -0
- package/dist/types/form/Dropzone.d.ts +138 -0
- package/dist/types/form/File.d.ts +2 -0
- package/dist/types/form/_colorInternals/colorMath.d.ts +63 -0
- package/dist/types/form/_colorInternals/pickerState.d.ts +62 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types-cjs/components/DataTable.d.ts +120 -0
- package/dist/types-cjs/components/useDataTable.d.ts +445 -0
- package/dist/types-cjs/elements/ColorSwatch.d.ts +54 -0
- package/dist/types-cjs/elements/Td.d.ts +9 -1
- package/dist/types-cjs/elements/Th.d.ts +14 -2
- package/dist/types-cjs/elements/Tr.d.ts +10 -1
- package/dist/types-cjs/form/ColorPicker.d.ts +266 -0
- package/dist/types-cjs/form/Dropzone.d.ts +138 -0
- package/dist/types-cjs/form/File.d.ts +2 -0
- package/dist/types-cjs/form/_colorInternals/colorMath.d.ts +63 -0
- package/dist/types-cjs/form/_colorInternals/pickerState.d.ts +62 -0
- package/dist/types-cjs/index.d.ts +4 -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/components/_datatable.scss +152 -0
- package/src/scss/components/_index.scss +1 -0
- package/src/scss/elements/_colorswatch.scss +100 -0
- package/src/scss/elements/_index.scss +1 -0
- package/src/scss/form/_checkbox.scss +53 -0
- package/src/scss/form/_colorpicker.scss +354 -0
- package/src/scss/form/_dropzone.scss +233 -0
- package/src/scss/form/_file.scss +29 -1
- package/src/scss/form/_index.scss +2 -0
|
@@ -10,7 +10,16 @@ import { TableColor } from './Td.js';
|
|
|
10
10
|
export interface TrProps extends Omit<React.HTMLAttributes<HTMLTableRowElement>, 'color'>, Omit<BulmaClassesProps, 'backgroundColor' | 'color'> {
|
|
11
11
|
/** Additional CSS classes to apply. */
|
|
12
12
|
className?: string;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Whether the row is selected (adds Bulma's is-selected class). It's a look
|
|
15
|
+
* only: it says nothing to assistive tech, so pair it with a checkbox named
|
|
16
|
+
* for the row when the selection matters. A bestax `Checkbox` placed
|
|
17
|
+
* straight in one of the row's cells takes the row's text color, so a
|
|
18
|
+
* checked box shows on the row's fill. One in a menu or a table nested in a
|
|
19
|
+
* cell, or in a cell with a `color` of its own, keeps its own colors, since
|
|
20
|
+
* it sits on that surface instead, and so does every one in a row with a
|
|
21
|
+
* `color`, whose cells paint that color over the fill.
|
|
22
|
+
*/
|
|
14
23
|
isSelected?: boolean;
|
|
15
24
|
/** Bulma color modifier for the table row. */
|
|
16
25
|
color?: TableColor;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
import { ColorFormat } from './_colorInternals/colorMath.js';
|
|
4
|
+
import { FormFieldProps } from './fieldProps.js';
|
|
5
|
+
export type { ColorFormat } from './_colorInternals/colorMath.js';
|
|
6
|
+
/**
|
|
7
|
+
* A preset color for a picker's swatches: a CSS color, or a CSS color with
|
|
8
|
+
* a name. The name labels the swatch for a screen reader and shows as its
|
|
9
|
+
* tooltip; without one, the color as written does.
|
|
10
|
+
*/
|
|
11
|
+
export type ColorPickerSwatch = string | {
|
|
12
|
+
color: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The strings a color picker says, each with an English default. A key
|
|
17
|
+
* left out, or set to an empty string, keeps its default.
|
|
18
|
+
*/
|
|
19
|
+
export interface ColorPickerLabels {
|
|
20
|
+
/**
|
|
21
|
+
* Names the saturation and brightness square.
|
|
22
|
+
* @defaultValue 'Saturation and brightness'
|
|
23
|
+
*/
|
|
24
|
+
area?: string;
|
|
25
|
+
/**
|
|
26
|
+
* What a screen reader calls the square in place of "slider".
|
|
27
|
+
* @defaultValue '2D slider'
|
|
28
|
+
*/
|
|
29
|
+
areaRoleDescription?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The square's horizontal channel, in its value text.
|
|
32
|
+
* @defaultValue 'Saturation'
|
|
33
|
+
*/
|
|
34
|
+
saturation?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The square's vertical channel, in its value text.
|
|
37
|
+
* @defaultValue 'Brightness'
|
|
38
|
+
*/
|
|
39
|
+
brightness?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Names the hue slider.
|
|
42
|
+
* @defaultValue 'Hue'
|
|
43
|
+
*/
|
|
44
|
+
hue?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Names the alpha slider.
|
|
47
|
+
* @defaultValue 'Alpha'
|
|
48
|
+
*/
|
|
49
|
+
alpha?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The unit after the hue's number in its value text, "171 degrees".
|
|
52
|
+
* Inside a `LocaleProvider` with a `locale`, that locale writes the number
|
|
53
|
+
* and its unit, and this isn't used.
|
|
54
|
+
* @defaultValue 'degrees'
|
|
55
|
+
*/
|
|
56
|
+
degrees?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Names the field that shows the value as text.
|
|
59
|
+
* @defaultValue 'Color value'
|
|
60
|
+
*/
|
|
61
|
+
value?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Names the group of swatches.
|
|
64
|
+
* @defaultValue 'Swatches'
|
|
65
|
+
*/
|
|
66
|
+
swatches?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Names the eye dropper button.
|
|
69
|
+
* @defaultValue 'Pick a color from the screen'
|
|
70
|
+
*/
|
|
71
|
+
eyeDropper?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Props for ColorPicker.Area. The helper props, the other attributes and the
|
|
75
|
+
* `ref` land on the square's `<div>`.
|
|
76
|
+
*
|
|
77
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the square's `<div>`.
|
|
78
|
+
*/
|
|
79
|
+
export interface ColorPickerAreaProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
80
|
+
/** Additional CSS classes to apply. */
|
|
81
|
+
className?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The saturation and brightness square, operated by pointer or by keyboard as one 2D slider.
|
|
85
|
+
*
|
|
86
|
+
* @function
|
|
87
|
+
* @param {ColorPickerAreaProps} props - Props for ColorPicker.Area.
|
|
88
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the square's `<div>`.
|
|
89
|
+
* @returns {JSX.Element | null} The square, or nothing outside a ColorPicker.
|
|
90
|
+
*/
|
|
91
|
+
export declare const ColorPickerArea: React.ForwardRefExoticComponent<ColorPickerAreaProps & React.RefAttributes<HTMLDivElement>>;
|
|
92
|
+
/**
|
|
93
|
+
* Props for ColorPicker.HueSlider and ColorPicker.AlphaSlider. The helper
|
|
94
|
+
* props, the other attributes and the `ref` land on the slider's `<div>`.
|
|
95
|
+
*
|
|
96
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the slider's `<div>`.
|
|
97
|
+
*/
|
|
98
|
+
export interface ColorPickerSliderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
99
|
+
/** Additional CSS classes to apply. */
|
|
100
|
+
className?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The hue slider, from red round the spectrum and back to red.
|
|
104
|
+
*
|
|
105
|
+
* @function
|
|
106
|
+
* @param {ColorPickerSliderProps} props - Props for ColorPicker.HueSlider.
|
|
107
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the slider's `<div>`.
|
|
108
|
+
* @returns {JSX.Element | null} The slider, or nothing outside a ColorPicker.
|
|
109
|
+
*/
|
|
110
|
+
export declare const ColorPickerHueSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
|
|
111
|
+
/**
|
|
112
|
+
* The alpha slider, from see-through to solid.
|
|
113
|
+
*
|
|
114
|
+
* @function
|
|
115
|
+
* @param {ColorPickerSliderProps} props - Props for ColorPicker.AlphaSlider.
|
|
116
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the slider's `<div>`.
|
|
117
|
+
* @returns {JSX.Element | null} The slider, or nothing outside a ColorPicker.
|
|
118
|
+
*/
|
|
119
|
+
export declare const ColorPickerAlphaSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
|
|
120
|
+
/**
|
|
121
|
+
* Props for ColorPicker.Swatches. The helper props, the other attributes and
|
|
122
|
+
* the `ref` land on the group's `<div>`.
|
|
123
|
+
*
|
|
124
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the group's `<div>`.
|
|
125
|
+
*/
|
|
126
|
+
export interface ColorPickerSwatchesProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
127
|
+
/** Additional CSS classes to apply. */
|
|
128
|
+
className?: string;
|
|
129
|
+
/**
|
|
130
|
+
* The colors to offer, in place of the picker's own `swatches`: a list,
|
|
131
|
+
* or `"bulma"` for the page's theme colors.
|
|
132
|
+
*/
|
|
133
|
+
swatches?: ColorPickerSwatch[] | 'bulma';
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The swatches, a radio group of preset colors that sets the picker's color.
|
|
137
|
+
*
|
|
138
|
+
* @function
|
|
139
|
+
* @param {ColorPickerSwatchesProps} props - Props for ColorPicker.Swatches.
|
|
140
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the group's `<div>`.
|
|
141
|
+
* @returns {JSX.Element | null} The swatches, or nothing outside a ColorPicker or with none to show.
|
|
142
|
+
*/
|
|
143
|
+
export declare const ColorPickerSwatches: React.ForwardRefExoticComponent<ColorPickerSwatchesProps & React.RefAttributes<HTMLDivElement>>;
|
|
144
|
+
/**
|
|
145
|
+
* Props for ColorPicker.Input. The helper props, the other attributes and
|
|
146
|
+
* the `ref` land on the row's `<div>`.
|
|
147
|
+
*
|
|
148
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the row's `<div>`.
|
|
149
|
+
*/
|
|
150
|
+
export interface ColorPickerInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
151
|
+
/** Additional CSS classes to apply. */
|
|
152
|
+
className?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The value as text you can type in, beside a preview swatch, with the eye dropper when the picker has `eyeDropper`.
|
|
156
|
+
*
|
|
157
|
+
* @function
|
|
158
|
+
* @param {ColorPickerInputProps} props - Props for ColorPicker.Input.
|
|
159
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the row's `<div>`.
|
|
160
|
+
* @returns {JSX.Element | null} The row, or nothing outside a ColorPicker.
|
|
161
|
+
*/
|
|
162
|
+
export declare const ColorPickerInput: React.ForwardRefExoticComponent<ColorPickerInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
163
|
+
/**
|
|
164
|
+
* Props for the ColorPicker component. The helper props, the other
|
|
165
|
+
* attributes and the `ref` land on the picker's `<div>`, inside the `Field`
|
|
166
|
+
* and `Control` it renders when it isn't already in them.
|
|
167
|
+
*
|
|
168
|
+
* Inside an existing `Control` it renders no `Control` of its own. Inside an
|
|
169
|
+
* outer `Field`, or a `Control` with no `Field` around it, it renders no
|
|
170
|
+
* `Field` of its own either. The exception is `label`, `message`,
|
|
171
|
+
* `horizontal` or `fieldClassName` in that bare `Control`: it keeps a
|
|
172
|
+
* `Field` for them, nested in the `.control`, and warns in development.
|
|
173
|
+
* Wrap the `Control` in a `Field` instead, and set the `label`, `horizontal`
|
|
174
|
+
* and class name on that `Field`.
|
|
175
|
+
*
|
|
176
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the picker's `<div>`.
|
|
177
|
+
* @extraProp {string} [aria-label] - Names the picker's group when there's no `label`.
|
|
178
|
+
*/
|
|
179
|
+
export interface ColorPickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'color' | 'role'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'>, FormFieldProps {
|
|
180
|
+
/** Additional CSS classes to apply. */
|
|
181
|
+
className?: string;
|
|
182
|
+
/** Field label naming the picker's group, through `aria-labelledby`. Dropped inside an outer `Field`, whose own label names it instead. An `aria-label` or `aria-labelledby` you set wins over either. */
|
|
183
|
+
label?: React.ReactNode;
|
|
184
|
+
/** Props for the label element. An explicit `id` here is used as the `aria-labelledby` target instead of a generated one; any `htmlFor` is ignored (a group label names the group, never a single control). */
|
|
185
|
+
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
186
|
+
[key: string]: unknown;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* The color, controlled: any CSS color the picker reads (hex, `rgb()`,
|
|
190
|
+
* `hsl()` or a color name), in any format, since `onChange` hands back
|
|
191
|
+
* the `format` asked for. One it can't read leaves the picker showing the
|
|
192
|
+
* last color it could. A value it gave you comes back without moving the
|
|
193
|
+
* thumbs, and a gray or black keeps the hue and saturation the user had.
|
|
194
|
+
*/
|
|
195
|
+
value?: string;
|
|
196
|
+
/** The color to start with, uncontrolled. Black without one. */
|
|
197
|
+
defaultValue?: string;
|
|
198
|
+
/**
|
|
199
|
+
* Called with the color, in `format`, as it changes: on every step of a
|
|
200
|
+
* drag, and on a key, a swatch, a typed value or the eye dropper.
|
|
201
|
+
*/
|
|
202
|
+
onChange?: (value: string) => void;
|
|
203
|
+
/**
|
|
204
|
+
* Called with the color, in `format`, once a change is done: when a drag
|
|
205
|
+
* ends, and with `onChange` for a key, a swatch, a typed value or the eye
|
|
206
|
+
* dropper. The place to save it.
|
|
207
|
+
*/
|
|
208
|
+
onChangeEnd?: (value: string) => void;
|
|
209
|
+
/**
|
|
210
|
+
* How the value is written: `'hsl'` (`hsl(171, 100%, 41%)`), Bulma's own
|
|
211
|
+
* color space and what `Theme`'s `primaryH`, `primaryS` and `primaryL`
|
|
212
|
+
* take, `'hex'` (`#00d1b2`) or `'rgb'` (`rgb(0, 209, 178)`). With `alpha`,
|
|
213
|
+
* `hsla()`, `#rrggbbaa` and `rgba()`.
|
|
214
|
+
* @defaultValue 'hsl'
|
|
215
|
+
*/
|
|
216
|
+
format?: ColorFormat;
|
|
217
|
+
/**
|
|
218
|
+
* Adds an alpha slider and writes the alpha into the value. Without it,
|
|
219
|
+
* the value is always solid.
|
|
220
|
+
*/
|
|
221
|
+
alpha?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Preset colors shown as a radio group under the picker: a list of CSS
|
|
224
|
+
* colors, each a string or `{ color, label }`, or `"bulma"` for the page's
|
|
225
|
+
* primary, link, info, success, warning and danger, from Bulma's CSS
|
|
226
|
+
* variables, so a themed app shows its own. A color the picker can't read
|
|
227
|
+
* as written, such as a `var()`, is read off the page each time the picker
|
|
228
|
+
* renders, so after a theme change the swatches show the new colors at
|
|
229
|
+
* once and the chosen one is marked again on the picker's next render,
|
|
230
|
+
* which a `Theme` around it causes. The `"bulma"` names are English; for
|
|
231
|
+
* others, pass the list yourself, such as
|
|
232
|
+
* `{ color: 'var(--bulma-primary)', label: 'Primär' }`.
|
|
233
|
+
*/
|
|
234
|
+
swatches?: ColorPickerSwatch[] | 'bulma';
|
|
235
|
+
/**
|
|
236
|
+
* Adds a button that picks a color from anywhere on the screen, where the
|
|
237
|
+
* browser has the EyeDropper API (desktop Chromium today). Elsewhere, and
|
|
238
|
+
* until the page hydrates, it isn't shown.
|
|
239
|
+
*/
|
|
240
|
+
eyeDropper?: boolean;
|
|
241
|
+
/** Disables every part. A disabled `Fieldset` around it does too. */
|
|
242
|
+
disabled?: boolean;
|
|
243
|
+
/** Form field name. When set, a hidden input carries the value. */
|
|
244
|
+
name?: string;
|
|
245
|
+
/** The id of the form the hidden input belongs to. */
|
|
246
|
+
form?: string;
|
|
247
|
+
/** The strings it says, each with an English default. */
|
|
248
|
+
labels?: ColorPickerLabels;
|
|
249
|
+
/**
|
|
250
|
+
* Parts for a layout of your own: `ColorPicker.Area`,
|
|
251
|
+
* `ColorPicker.HueSlider`, `ColorPicker.AlphaSlider`,
|
|
252
|
+
* `ColorPicker.Swatches` and `ColorPicker.Input`, with anything else
|
|
253
|
+
* between them. Without children, the picker shows the square, the hue
|
|
254
|
+
* slider, the alpha slider with `alpha`, the value, and the swatches when
|
|
255
|
+
* there are some.
|
|
256
|
+
*/
|
|
257
|
+
children?: React.ReactNode;
|
|
258
|
+
}
|
|
259
|
+
export declare const ColorPicker: React.ForwardRefExoticComponent<ColorPickerProps & React.RefAttributes<HTMLDivElement>> & {
|
|
260
|
+
Area: React.ForwardRefExoticComponent<ColorPickerAreaProps & React.RefAttributes<HTMLDivElement>>;
|
|
261
|
+
HueSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
|
|
262
|
+
AlphaSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
|
|
263
|
+
Swatches: React.ForwardRefExoticComponent<ColorPickerSwatchesProps & React.RefAttributes<HTMLDivElement>>;
|
|
264
|
+
Input: React.ForwardRefExoticComponent<ColorPickerInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
265
|
+
};
|
|
266
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
import { FormFieldProps } from './fieldProps.js';
|
|
4
|
+
/** Why a Dropzone refused a file. */
|
|
5
|
+
export type DropzoneRejectionCode = 'file-invalid-type' | 'file-too-large' | 'too-many-files';
|
|
6
|
+
/** A file a Dropzone refused, and why. */
|
|
7
|
+
export interface DropzoneRejection {
|
|
8
|
+
/** The file. */
|
|
9
|
+
file: File;
|
|
10
|
+
/**
|
|
11
|
+
* Why it was refused: `file-invalid-type` when `accept` doesn't take it, or
|
|
12
|
+
* it's a folder; `file-too-large` when it's over `maxSize`; `too-many-files`
|
|
13
|
+
* when the list is full.
|
|
14
|
+
*/
|
|
15
|
+
code: DropzoneRejectionCode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Props for the Dropzone component.
|
|
19
|
+
*
|
|
20
|
+
* @helperProps Helper props go on the `.dropzone` root `<div>`, with
|
|
21
|
+
* `className`. The other attributes go on the `<input>`.
|
|
22
|
+
* @extraProp {string} [accept] - File types it takes, as the native attribute writes them (`.pdf`, `image/*`, `application/pdf`). The picker offers them, and Dropzone checks every pick, drop and paste against them by the same rules, since browsers don't check a dropped file. It goes by a file's name and type, not its contents.
|
|
23
|
+
* @extraProp {boolean} [multiple=false] - Takes several files, and each pick, drop or paste adds to the list. Without it, a new file replaces the one chosen.
|
|
24
|
+
* @extraProp {string} [name] - The files' name in the form's data. The input holds the chosen files, so a plain form submit, `FormData` and React 19 actions all carry them.
|
|
25
|
+
* @extraProp {boolean} [required=false] - The browser's own check: a form won't submit with no file chosen.
|
|
26
|
+
* @extraProp {boolean} [disabled=false] - Disables the input, hides the remove buttons and takes no drops. A disabled `Fieldset` around it does the same.
|
|
27
|
+
* @extraProp {(event: React.ChangeEvent<HTMLInputElement>) => void} [onChange] - Called on the input's `change`, after each pick, drop, paste or removal that changes the files, with `event.target.files` holding the new list.
|
|
28
|
+
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Forwarded to the `<input>`, so `ref.current.showPicker()` opens the picker from a button of your own. A script that writes the input through it, such as `value = ''` to clear it or a form library setting `files`, changes what the input holds and what the next pick, drop or paste adds to, but no event reports the write, so the list shows it only from the next change. To clear the list at once, reset the form, or control it with `files` and set that to `[]`.
|
|
29
|
+
*/
|
|
30
|
+
export interface DropzoneProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'color' | 'type' | 'children' | 'value' | 'defaultValue'>, Omit<BulmaClassesProps, 'color'>, FormFieldProps {
|
|
31
|
+
/** Field label, rendered above the zone. It names the input along with the zone's own text, through `htmlFor` (your `id` when you pass one). Inside an outer `Field` it's dropped, and that `Field`'s label names the input. */
|
|
32
|
+
label?: React.ReactNode;
|
|
33
|
+
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). */
|
|
34
|
+
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
/** Bulma color modifier for the zone, as `File` takes it. */
|
|
38
|
+
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger' | 'black' | 'dark' | 'light' | 'white';
|
|
39
|
+
/** Size modifier for the zone. */
|
|
40
|
+
size?: 'small' | 'medium' | 'large';
|
|
41
|
+
/**
|
|
42
|
+
* The zone's text. It's the input's accessible name, so keep it short, and
|
|
43
|
+
* put details such as "PDF up to 5 MB" in `hint`. Default: "Choose or drop
|
|
44
|
+
* a file", or "Choose or drop files" with `multiple`.
|
|
45
|
+
*/
|
|
46
|
+
buttonLabel?: React.ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* An icon above the zone's text. It sits inside the `<label>` that names
|
|
49
|
+
* the input, so leave an `Icon` here unnamed (`<Icon name="upload" />`).
|
|
50
|
+
*/
|
|
51
|
+
icon?: React.ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* A line under the zone that describes the input through
|
|
54
|
+
* `aria-describedby`, such as "PDF up to 5 MB".
|
|
55
|
+
*/
|
|
56
|
+
hint?: React.ReactNode;
|
|
57
|
+
/** The largest file it takes, in bytes. A bigger one is refused with `file-too-large`. */
|
|
58
|
+
maxSize?: number;
|
|
59
|
+
/**
|
|
60
|
+
* With `multiple`, how many files the list holds at most. A drop that would
|
|
61
|
+
* go over adds files up to the limit and refuses the rest with
|
|
62
|
+
* `too-many-files`.
|
|
63
|
+
*/
|
|
64
|
+
maxFiles?: number;
|
|
65
|
+
/**
|
|
66
|
+
* The chosen files, to control the list. The input and the list follow it,
|
|
67
|
+
* and a change you don't take through `onFilesChange` is undone. Setting it
|
|
68
|
+
* to `[]` clears both.
|
|
69
|
+
*/
|
|
70
|
+
files?: File[];
|
|
71
|
+
/** Called with the whole list of chosen files each time it changes. */
|
|
72
|
+
onFilesChange?: (files: File[]) => void;
|
|
73
|
+
/** Called with the files a pick, drop or paste refused, and why. */
|
|
74
|
+
onReject?: (rejections: DropzoneRejection[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Shows the chosen files under the zone, each with its size and a remove
|
|
77
|
+
* button. Turn it off to show them your own way from `onFilesChange`. The
|
|
78
|
+
* refusals still show.
|
|
79
|
+
*/
|
|
80
|
+
showFileList?: boolean;
|
|
81
|
+
/** Takes files pasted while the input has focus, through the same checks as a drop. */
|
|
82
|
+
allowPaste?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* While it's on the page, stops the browser opening a file dropped outside
|
|
85
|
+
* any drop target, which would leave the page. Drops on other file inputs
|
|
86
|
+
* and on editable fields are left alone.
|
|
87
|
+
*/
|
|
88
|
+
preventDocumentDrop?: boolean;
|
|
89
|
+
/** Names a file's remove button, for localization. Default: `` `Remove ${file.name}` ``. */
|
|
90
|
+
removeLabel?: (file: File) => string;
|
|
91
|
+
/**
|
|
92
|
+
* The text shown and announced for a refused file, for localization.
|
|
93
|
+
* Default: the file's name and the reason, such as "photo.png: only PDF
|
|
94
|
+
* files".
|
|
95
|
+
*/
|
|
96
|
+
rejectionMessage?: (rejection: DropzoneRejection) => string;
|
|
97
|
+
/**
|
|
98
|
+
* What's announced when files are added, for localization. Default: the
|
|
99
|
+
* file's name and "added", or a count ("2 files added").
|
|
100
|
+
*/
|
|
101
|
+
addedMessage?: (files: File[]) => string;
|
|
102
|
+
/** What's announced when a file is removed, for localization. Default: `` `${file.name} removed` ``. */
|
|
103
|
+
removedMessage?: (file: File) => string;
|
|
104
|
+
/**
|
|
105
|
+
* Help or validation message under the Dropzone. It describes the input
|
|
106
|
+
* through `aria-describedby`, after the hint and any refusals.
|
|
107
|
+
*/
|
|
108
|
+
message?: React.ReactNode;
|
|
109
|
+
/** Additional CSS classes for the root. */
|
|
110
|
+
className?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The `Dropzone` component is an area to drop files on or click to pick
|
|
114
|
+
* them, which checks each file and lists the chosen ones with a way to remove
|
|
115
|
+
* each.
|
|
116
|
+
*
|
|
117
|
+
* It's Bulma's boxed, full-width file widget with the real
|
|
118
|
+
* `<input type="file">` lying over it, so the input is the one tab stop, the
|
|
119
|
+
* click target and the drop target, and Enter and Space open the picker. The
|
|
120
|
+
* input holds the chosen files: a pick, drop or paste that passes the checks
|
|
121
|
+
* is written to it, so a form submits the files under `name`. It doesn't
|
|
122
|
+
* upload anything.
|
|
123
|
+
*
|
|
124
|
+
* @function
|
|
125
|
+
* @param {DropzoneProps} props - Props for the Dropzone component.
|
|
126
|
+
* @returns {JSX.Element} The rendered dropzone.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* <Dropzone
|
|
130
|
+
* label="CV"
|
|
131
|
+
* name="cv"
|
|
132
|
+
* accept=".pdf,application/pdf"
|
|
133
|
+
* maxSize={5_000_000}
|
|
134
|
+
* hint="PDF up to 5 MB"
|
|
135
|
+
* />
|
|
136
|
+
*/
|
|
137
|
+
export declare const Dropzone: React.ForwardRefExoticComponent<DropzoneProps & React.RefAttributes<HTMLInputElement>>;
|
|
138
|
+
export default Dropzone;
|
|
@@ -12,6 +12,8 @@ import { FormFieldProps } from './fieldProps.js';
|
|
|
12
12
|
*
|
|
13
13
|
* @helperProps Helper props go on the `.file` wrapper `<div>`, with
|
|
14
14
|
* `className`. The other attributes go on the `<input>`.
|
|
15
|
+
* @extraProp {string} [accept] - File types the picker offers, as the native attribute takes them (`.pdf`, `image/*`, `application/pdf`). Browsers apply it in the picker only: a file dropped on the input lands whatever its type, so check `files` in `onChange` when the type matters.
|
|
16
|
+
* @extraProp {(event: React.ChangeEvent<HTMLInputElement>) => void} [onChange] - Called when the user picks files, or drops them on the input. With the extras stylesheet loaded, a drop does what a pick does: it replaces what was picked and fires `input` and `change`. A drop of several files lands only with `multiple`.
|
|
15
17
|
*/
|
|
16
18
|
export interface FileProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'color' | 'type'>, Omit<BulmaClassesProps, 'color'>, FormFieldProps {
|
|
17
19
|
/** Field label. Automatically associated with the file input via `htmlFor` — uses your `id` when provided, otherwise a generated one. The input then has two labels (this one plus the wrapping `file-label`); assistive tech reads both. 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. */
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** The formats a color picker writes its value in. */
|
|
2
|
+
export type ColorFormat = 'hsl' | 'hex' | 'rgb';
|
|
3
|
+
/**
|
|
4
|
+
* A color as the picker holds it: hue in degrees from 0 to 360, saturation
|
|
5
|
+
* and value (brightness) from 0 to 100, and alpha from 0 to 1.
|
|
6
|
+
*/
|
|
7
|
+
export interface Hsva {
|
|
8
|
+
h: number;
|
|
9
|
+
s: number;
|
|
10
|
+
v: number;
|
|
11
|
+
a: number;
|
|
12
|
+
}
|
|
13
|
+
/** Red, green and blue from 0 to 255, and alpha from 0 to 1. */
|
|
14
|
+
export interface Rgba {
|
|
15
|
+
r: number;
|
|
16
|
+
g: number;
|
|
17
|
+
b: number;
|
|
18
|
+
a: number;
|
|
19
|
+
}
|
|
20
|
+
/** HSV to RGB, each channel unrounded. */
|
|
21
|
+
export declare function hsvaToRgba({ h, s, v, a }: Hsva): Rgba;
|
|
22
|
+
/** RGB to HSV. A gray has no hue, so it gets 0. */
|
|
23
|
+
export declare function rgbaToHsva({ r, g, b, a }: Rgba): Hsva;
|
|
24
|
+
/** HSL (saturation and lightness from 0 to 100) to HSV, keeping the hue. */
|
|
25
|
+
export declare function hslaToHsva(h: number, s: number, l: number, a: number): Hsva;
|
|
26
|
+
/** HSV to HSL, saturation and lightness from 0 to 100, keeping the hue. */
|
|
27
|
+
export declare function hsvaToHsla({ h, s, v, a }: Hsva): {
|
|
28
|
+
h: number;
|
|
29
|
+
s: number;
|
|
30
|
+
l: number;
|
|
31
|
+
a: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Writes a color in a format: `hsl(171, 100%, 41%)`, `#00d1b2` or
|
|
35
|
+
* `rgb(0, 209, 178)`, with alpha as `hsla(…)`, `#00d1b2ff` and `rgba(…)`.
|
|
36
|
+
* Channels are whole numbers, and the legacy comma form is used, which every
|
|
37
|
+
* CSS parser and color library reads.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatColor(color: Hsva, format: ColorFormat, alpha: boolean): string;
|
|
40
|
+
/** Whether two colors are the same once written as 8-bit RGB with alpha. */
|
|
41
|
+
export declare const sameColor: (one: Hsva, other: Hsva) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The relative luminance of a color, from 0 for black to 1 for white, as
|
|
44
|
+
* WCAG defines it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function luminance(color: Hsva): number;
|
|
47
|
+
/**
|
|
48
|
+
* Whether black reads better than white on a color, by WCAG contrast
|
|
49
|
+
* ratio. Used for the check on a chosen swatch.
|
|
50
|
+
*/
|
|
51
|
+
export declare function prefersDarkInk(color: Hsva): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a color's text names its own hue, as `hsl()` and `hsla()` do even
|
|
54
|
+
* for a gray, where hex, `rgb()` and the color names leave it out.
|
|
55
|
+
*/
|
|
56
|
+
export declare const namesHue: (text: string) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Reads a CSS color: hex (with or without `#`), `rgb()`, `rgba()`, `hsl()`
|
|
59
|
+
* and `hsla()` in either syntax, the named colors, and `transparent`. Null
|
|
60
|
+
* for anything else, such as `oklch()` or `var(--x)`, which only the
|
|
61
|
+
* browser can resolve.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseColor(input: string | null | undefined): Hsva | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ColorFormat, Hsva } from './colorMath.js';
|
|
2
|
+
import type { ColorPickerLabels, ColorPickerSwatch } from '../ColorPicker.js';
|
|
3
|
+
/** The labels with each one left out, or empty, at its default. */
|
|
4
|
+
export declare const mergeColorLabels: (labels: ColorPickerLabels | undefined) => Required<ColorPickerLabels>;
|
|
5
|
+
export declare const BLACK: Hsva;
|
|
6
|
+
/**
|
|
7
|
+
* A color read from outside the picker, written as `source`, with the hue
|
|
8
|
+
* and saturation the picker had where the new color has none, so the thumbs
|
|
9
|
+
* don't jump to 0. A gray written as hex, `rgb()` or a name has no hue, so
|
|
10
|
+
* it keeps the picker's; one written as `hsl()` names its hue, which wins.
|
|
11
|
+
* Black has no saturation in the square either way, and keeps the picker's,
|
|
12
|
+
* which writes no differently.
|
|
13
|
+
*/
|
|
14
|
+
export declare const keepingChannels: (next: Hsva, previous: Hsva, source: string) => Hsva;
|
|
15
|
+
/** What a picker's parts read from the picker around them. */
|
|
16
|
+
export interface ColorPickerContextValue {
|
|
17
|
+
/** The color shown, alpha at 1 unless the picker takes alpha. */
|
|
18
|
+
color: Hsva;
|
|
19
|
+
/** The color written in the picker's format. */
|
|
20
|
+
text: string;
|
|
21
|
+
format: ColorFormat;
|
|
22
|
+
alpha: boolean;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
labels: Required<ColorPickerLabels>;
|
|
25
|
+
swatches: ColorPickerSwatch[] | 'bulma' | undefined;
|
|
26
|
+
eyeDropper: boolean;
|
|
27
|
+
/** Whether a touch screen reader is likely, so both square inputs show. */
|
|
28
|
+
touch: boolean;
|
|
29
|
+
/** Writes a percentage, in the locale of a LocaleProvider when there is one. */
|
|
30
|
+
percent: (value: number) => string;
|
|
31
|
+
/** Writes a hue in degrees, in the locale of a LocaleProvider when there is one. */
|
|
32
|
+
degrees: (value: number) => string;
|
|
33
|
+
/** Sets the color: `onChange`, and `onChangeEnd` too when `end` is set. */
|
|
34
|
+
change: (next: Hsva, end?: boolean) => void;
|
|
35
|
+
/** Ends a drag: `onChangeEnd` with the latest value. */
|
|
36
|
+
end: () => void;
|
|
37
|
+
}
|
|
38
|
+
export declare const ColorPickerContext: import("react").Context<ColorPickerContextValue | null>;
|
|
39
|
+
/** Does nothing, for a part outside a picker and a cancelled eye dropper. */
|
|
40
|
+
export declare const noop: () => void;
|
|
41
|
+
export declare const standalone: ColorPickerContextValue;
|
|
42
|
+
/** The picker around a part, or null with a development warning. */
|
|
43
|
+
export declare function usePicker(part: string): ColorPickerContextValue | null;
|
|
44
|
+
/** What a picker is given: ColorPicker's props, or the ones ColorInput passes on. */
|
|
45
|
+
export interface PickerOptions {
|
|
46
|
+
value: string | undefined;
|
|
47
|
+
defaultValue: string | undefined;
|
|
48
|
+
onChange: ((value: string) => void) | undefined;
|
|
49
|
+
onChangeEnd: ((value: string) => void) | undefined;
|
|
50
|
+
format: ColorFormat;
|
|
51
|
+
alpha: boolean;
|
|
52
|
+
disabled: boolean;
|
|
53
|
+
swatches: ColorPickerSwatch[] | 'bulma' | undefined;
|
|
54
|
+
eyeDropper: boolean;
|
|
55
|
+
labels: ColorPickerLabels | undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Holds a picker's color and builds what its parts read. Controlled, the
|
|
59
|
+
* color shown follows `value`; a value the picker handed out comes back as
|
|
60
|
+
* the exact color it was, thumbs and all.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useColorPicker({ value, defaultValue, onChange, onChangeEnd, format, alpha, disabled, swatches, eyeDropper, labels, }: PickerOptions): ColorPickerContextValue;
|
|
@@ -32,6 +32,7 @@ export * from './components/Reveal.js';
|
|
|
32
32
|
export * from './components/TreeView.js';
|
|
33
33
|
export * from './components/ScrollArea.js';
|
|
34
34
|
export * from './components/Command.js';
|
|
35
|
+
export * from './components/DataTable.js';
|
|
35
36
|
export * from './elements/Block.js';
|
|
36
37
|
export * from './elements/Box.js';
|
|
37
38
|
export * from './elements/Button.js';
|
|
@@ -39,6 +40,7 @@ export * from './elements/Buttons.js';
|
|
|
39
40
|
export * from './elements/LinkButton.js';
|
|
40
41
|
export * from './elements/ToggleButton.js';
|
|
41
42
|
export * from './elements/Code.js';
|
|
43
|
+
export * from './elements/ColorSwatch.js';
|
|
42
44
|
export * from './elements/Content.js';
|
|
43
45
|
export * from './elements/Delete.js';
|
|
44
46
|
export * from './elements/DescriptionList.js';
|
|
@@ -77,6 +79,7 @@ export * from './form/Checkbox.js';
|
|
|
77
79
|
export * from './form/CheckboxCard.js';
|
|
78
80
|
export * from './form/Checkboxes.js';
|
|
79
81
|
export * from './form/Control.js';
|
|
82
|
+
export * from './form/Dropzone.js';
|
|
80
83
|
export * from './form/Field.js';
|
|
81
84
|
export * from './form/Fieldset.js';
|
|
82
85
|
export * from './form/File.js';
|
|
@@ -91,6 +94,7 @@ export * from './form/Rate.js';
|
|
|
91
94
|
export * from './form/Autocomplete.js';
|
|
92
95
|
export * from './form/Combobox.js';
|
|
93
96
|
export * from './form/Taginput.js';
|
|
97
|
+
export * from './form/ColorPicker.js';
|
|
94
98
|
export { InputBase } from './form/InputBase.js';
|
|
95
99
|
export type { InputBaseProps } from './form/InputBase.js';
|
|
96
100
|
export { SelectBase } from './form/SelectBase.js';
|