@allxsmith/bestax-bulma 5.54.1 → 5.56.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 +509 -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/ColorInput.js +68 -0
- package/dist/esm/form/ColorInput.js.map +1 -0
- package/dist/esm/form/ColorInputBase.js +198 -0
- package/dist/esm/form/ColorInputBase.js.map +1 -0
- package/dist/esm/form/ColorPicker.js +524 -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/_colorInternals/EyeDropperButton.js +40 -0
- package/dist/esm/form/_colorInternals/EyeDropperButton.js.map +1 -0
- 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 +3054 -586
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +7 -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 +481 -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/ColorInput.d.ts +76 -0
- package/dist/types/form/ColorInputBase.d.ts +108 -0
- package/dist/types/form/ColorPicker.d.ts +271 -0
- package/dist/types/form/Dropzone.d.ts +138 -0
- package/dist/types/form/_colorInternals/EyeDropperButton.d.ts +8 -0
- package/dist/types/form/_colorInternals/colorMath.d.ts +63 -0
- package/dist/types/form/_colorInternals/pickerState.d.ts +68 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types-cjs/components/DataTable.d.ts +120 -0
- package/dist/types-cjs/components/useDataTable.d.ts +481 -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/ColorInput.d.ts +76 -0
- package/dist/types-cjs/form/ColorInputBase.d.ts +108 -0
- package/dist/types-cjs/form/ColorPicker.d.ts +271 -0
- package/dist/types-cjs/form/Dropzone.d.ts +138 -0
- package/dist/types-cjs/form/_colorInternals/EyeDropperButton.d.ts +8 -0
- package/dist/types-cjs/form/_colorInternals/colorMath.d.ts +63 -0
- package/dist/types-cjs/form/_colorInternals/pickerState.d.ts +68 -0
- package/dist/types-cjs/index.d.ts +8 -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/_colorinput.scss +109 -0
- package/src/scss/form/_colorpicker.scss +354 -0
- package/src/scss/form/_dropzone.scss +233 -0
- package/src/scss/form/_index.scss +3 -0
|
@@ -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;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A button that picks a color from anywhere on the screen, for the picker
|
|
3
|
+
* around it. It renders only once the page has hydrated, where the browser
|
|
4
|
+
* has the EyeDropper API, and inside a picker that asked for it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function EyeDropperButton({ className }: {
|
|
7
|
+
className?: string;
|
|
8
|
+
}): import("react").JSX.Element | null;
|
|
@@ -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,68 @@
|
|
|
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
|
+
* Whether the field the picker serves is empty, as ColorInput's can be.
|
|
58
|
+
* The picker still shows a color then, and any change, even to that same
|
|
59
|
+
* color, is reported, so it fills the field.
|
|
60
|
+
*/
|
|
61
|
+
empty?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Holds a picker's color and builds what its parts read. Controlled, the
|
|
65
|
+
* color shown follows `value`; a value the picker handed out comes back as
|
|
66
|
+
* the exact color it was, thumbs and all.
|
|
67
|
+
*/
|
|
68
|
+
export declare function useColorPicker({ value, defaultValue, onChange, onChangeEnd, format, alpha, disabled, swatches, eyeDropper, labels, empty, }: PickerOptions): ColorPickerContextValue;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -119,6 +123,10 @@ export { DateRangeInputBase } from './form/DateRangeInputBase.js';
|
|
|
119
123
|
export type { DateRangeInputBaseProps, DateRangeValue, } from './form/DateRangeInputBase.js';
|
|
120
124
|
export { DateRangeInput } from './form/DateRangeInput.js';
|
|
121
125
|
export type { DateRangeInputProps } from './form/DateRangeInput.js';
|
|
126
|
+
export { ColorInputBase } from './form/ColorInputBase.js';
|
|
127
|
+
export type { ColorInputBaseProps } from './form/ColorInputBase.js';
|
|
128
|
+
export { ColorInput } from './form/ColorInput.js';
|
|
129
|
+
export type { ColorInputProps } from './form/ColorInput.js';
|
|
122
130
|
export { useInsideField, useInsideControl } from './form/FormContext.js';
|
|
123
131
|
export type { FormFieldProps } from './form/fieldProps.js';
|
|
124
132
|
export * from './grid/Cell.js';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
import { TrProps } from '../elements/Tr.js';
|
|
4
|
+
import { type DataTableColumn, type DataTableModel, type DataTableStateOptions } from './useDataTable.js';
|
|
5
|
+
export { useDataTable } from './useDataTable.js';
|
|
6
|
+
export type { DataTableCSVOptions, DataTableCellContext, DataTableCellProps, DataTableCheckboxProps, DataTableColumn, DataTableColumnMeta, DataTableFilters, DataTableHeaderCellProps, DataTableLabels, DataTableModel, DataTablePaginationProps, DataTableResolvedLabels, DataTableRowScope, DataTableSearchProps, DataTableSelectionMode, DataTableSort, DataTableSortButtonProps, DataTableSortDirection, DataTableState, DataTableStateOptions, UseDataTableOptions, } from './useDataTable.js';
|
|
7
|
+
/**
|
|
8
|
+
* Props for the DataTable component. The helper props, `className`, the
|
|
9
|
+
* `ref` and the other attributes go on the wrapper `<div>`, which holds the
|
|
10
|
+
* toolbar, the table and the pager. `aria-label` and `aria-labelledby` name
|
|
11
|
+
* the `<table>` itself.
|
|
12
|
+
*
|
|
13
|
+
* @extraProp {string} [aria-label] - Names the table, in place of a `caption`. A table needs a name, so pass a `caption`, this or `aria-labelledby`, and a development build warns when it has none.
|
|
14
|
+
* @extraProp {string} [aria-labelledby] - The id of a visible heading that names the table, in place of a `caption`.
|
|
15
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the wrapper `<div>`.
|
|
16
|
+
*/
|
|
17
|
+
export interface DataTableProps<TRow> extends DataTableStateOptions<TRow>, Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
18
|
+
/**
|
|
19
|
+
* The columns, in the order they're shown. Required unless `table` is
|
|
20
|
+
* given. Keep the array the same from one render to the next, defined
|
|
21
|
+
* outside the component or in `useMemo`: a new one has every cell's text
|
|
22
|
+
* worked out again.
|
|
23
|
+
*/
|
|
24
|
+
columns?: DataTableColumn<TRow>[];
|
|
25
|
+
/** The rows, as records of your own. Required unless `table` is given. */
|
|
26
|
+
data?: TRow[];
|
|
27
|
+
/**
|
|
28
|
+
* A table made by `useDataTable`, rendered in place of one made from
|
|
29
|
+
* `columns`, `data` and the state props, which are then left unread. Use
|
|
30
|
+
* it to put a toolbar, a count or an export button elsewhere on the page.
|
|
31
|
+
*/
|
|
32
|
+
table?: DataTableModel<TRow>;
|
|
33
|
+
/**
|
|
34
|
+
* Names the table, as a visible `<caption>`. A table needs a name: this,
|
|
35
|
+
* `aria-label` or `aria-labelledby`.
|
|
36
|
+
*/
|
|
37
|
+
caption?: React.ReactNode;
|
|
38
|
+
/** Adds borders to all cells. */
|
|
39
|
+
isBordered?: boolean;
|
|
40
|
+
/** Adds zebra-striping to rows. */
|
|
41
|
+
isStriped?: boolean;
|
|
42
|
+
/** Makes the table more compact by cutting cell padding in half. */
|
|
43
|
+
isNarrow?: boolean;
|
|
44
|
+
/** Adds a hover effect on rows. */
|
|
45
|
+
isHoverable?: boolean;
|
|
46
|
+
/** Makes the table span the full width of its wrapper. */
|
|
47
|
+
isFullwidth?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Scrolls a table wider than its wrapper sideways, in a `ScrollArea`
|
|
50
|
+
* named after the table, which can be scrolled from the keyboard while it
|
|
51
|
+
* overflows.
|
|
52
|
+
*/
|
|
53
|
+
isResponsive?: boolean;
|
|
54
|
+
/** Shows a search field in the toolbar, labelled by `labels.search`. */
|
|
55
|
+
hasSearch?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* More of the toolbar, after the search field: buttons for the selected
|
|
58
|
+
* rows, a filter, a download. Given the table.
|
|
59
|
+
*/
|
|
60
|
+
toolbar?: (table: DataTableModel<TRow>) => React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Shows a page of skeleton rows under the header in place of the rows,
|
|
63
|
+
* and marks the table busy. For data on its way, as from a server with
|
|
64
|
+
* `manual`.
|
|
65
|
+
*/
|
|
66
|
+
loading?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* What the table shows when it has no rows at all, in one cell across
|
|
69
|
+
* every column. A small `EmptyState` saying `labels.empty` by default. A
|
|
70
|
+
* title of your own sits under the heading the table does, so give it the
|
|
71
|
+
* next level down with `titleAs`.
|
|
72
|
+
*/
|
|
73
|
+
empty?: React.ReactNode;
|
|
74
|
+
/**
|
|
75
|
+
* What the table shows when the search and filters let no row through, in
|
|
76
|
+
* one cell across every column. A small `EmptyState` saying
|
|
77
|
+
* `labels.noResults` by default. A button that clears the search goes
|
|
78
|
+
* away with it, so send focus back to the search field when it's pressed.
|
|
79
|
+
*/
|
|
80
|
+
noResults?: React.ReactNode;
|
|
81
|
+
/**
|
|
82
|
+
* Props of your own for a row's `Tr`, such as a handler or a class. The
|
|
83
|
+
* table's own (`isSelected`) win. To wrap a row in a `ContextMenu`, build
|
|
84
|
+
* the table from `useDataTable`'s props instead.
|
|
85
|
+
*/
|
|
86
|
+
rowProps?: (row: TRow) => DataTableRowProps;
|
|
87
|
+
/** Additional CSS classes, on the wrapper `<div>`. */
|
|
88
|
+
className?: string;
|
|
89
|
+
}
|
|
90
|
+
/** What `rowProps` gives a row's `Tr`: any of its props but the ones the table sets. */
|
|
91
|
+
export type DataTableRowProps = Omit<TrProps, 'isSelected' | 'children'>;
|
|
92
|
+
/** The type of `DataTable`, generic in the row. */
|
|
93
|
+
export type DataTableComponent = (<TRow>(props: DataTableProps<TRow> & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null) & {
|
|
94
|
+
displayName?: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* The `DataTable` component is a table of records that people can sort,
|
|
98
|
+
* search, page through and select rows from, rendered with bestax's own
|
|
99
|
+
* `Table` parts, `Checkbox` and `Pagination`.
|
|
100
|
+
*
|
|
101
|
+
* It's a native table, as in the WAI-ARIA Authoring Practices' sortable
|
|
102
|
+
* table: a sortable header holds a button, the sorted one carries
|
|
103
|
+
* `aria-sort`, and each row's checkbox is named for the row. It runs on
|
|
104
|
+
* `useDataTable`, which custom markup can use too.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* <DataTable
|
|
108
|
+
* caption="Users"
|
|
109
|
+
* columns={[
|
|
110
|
+
* { id: 'name', header: 'Name', sortable: true, isRowHeader: true },
|
|
111
|
+
* { id: 'role', header: 'Role', sortable: true },
|
|
112
|
+
* ]}
|
|
113
|
+
* data={users}
|
|
114
|
+
* selectionMode="multiple"
|
|
115
|
+
* pageSize={10}
|
|
116
|
+
* hasSearch
|
|
117
|
+
* />
|
|
118
|
+
*/
|
|
119
|
+
export declare const DataTable: DataTableComponent;
|
|
120
|
+
export default DataTable;
|