@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.
Files changed (87) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Command.js +22 -22
  4. package/dist/esm/components/Command.js.map +1 -1
  5. package/dist/esm/components/DataTable.js +215 -0
  6. package/dist/esm/components/DataTable.js.map +1 -0
  7. package/dist/esm/components/useDataTable.js +509 -0
  8. package/dist/esm/components/useDataTable.js.map +1 -0
  9. package/dist/esm/elements/ColorSwatch.js +49 -0
  10. package/dist/esm/elements/ColorSwatch.js.map +1 -0
  11. package/dist/esm/elements/RingProgress.js +3 -3
  12. package/dist/esm/elements/Td.js +4 -2
  13. package/dist/esm/elements/Td.js.map +1 -1
  14. package/dist/esm/elements/Th.js +13 -5
  15. package/dist/esm/elements/Th.js.map +1 -1
  16. package/dist/esm/elements/Tr.js.map +1 -1
  17. package/dist/esm/form/ColorInput.js +68 -0
  18. package/dist/esm/form/ColorInput.js.map +1 -0
  19. package/dist/esm/form/ColorInputBase.js +198 -0
  20. package/dist/esm/form/ColorInputBase.js.map +1 -0
  21. package/dist/esm/form/ColorPicker.js +524 -0
  22. package/dist/esm/form/ColorPicker.js.map +1 -0
  23. package/dist/esm/form/Combobox.js +18 -18
  24. package/dist/esm/form/Combobox.js.map +1 -1
  25. package/dist/esm/form/Dropzone.js +524 -0
  26. package/dist/esm/form/Dropzone.js.map +1 -0
  27. package/dist/esm/form/_colorInternals/EyeDropperButton.js +40 -0
  28. package/dist/esm/form/_colorInternals/EyeDropperButton.js.map +1 -0
  29. package/dist/esm/form/_colorInternals/colorMath.js +292 -0
  30. package/dist/esm/form/_colorInternals/colorMath.js.map +1 -0
  31. package/dist/esm/form/_colorInternals/pickerState.js +160 -0
  32. package/dist/esm/form/_colorInternals/pickerState.js.map +1 -0
  33. package/dist/esm/helpers/statusRegion.js +3 -3
  34. package/dist/esm/helpers/statusRegion.js.map +1 -1
  35. package/dist/esm/helpers/useFocusTrap.js +2 -2
  36. package/dist/extras.css +1 -1
  37. package/dist/extras.css.map +1 -1
  38. package/dist/index.cjs +3054 -586
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.esm.js +7 -0
  41. package/dist/index.esm.js.map +1 -1
  42. package/dist/types/components/DataTable.d.ts +120 -0
  43. package/dist/types/components/useDataTable.d.ts +481 -0
  44. package/dist/types/elements/ColorSwatch.d.ts +54 -0
  45. package/dist/types/elements/Td.d.ts +9 -1
  46. package/dist/types/elements/Th.d.ts +14 -2
  47. package/dist/types/elements/Tr.d.ts +10 -1
  48. package/dist/types/form/ColorInput.d.ts +76 -0
  49. package/dist/types/form/ColorInputBase.d.ts +108 -0
  50. package/dist/types/form/ColorPicker.d.ts +271 -0
  51. package/dist/types/form/Dropzone.d.ts +138 -0
  52. package/dist/types/form/_colorInternals/EyeDropperButton.d.ts +8 -0
  53. package/dist/types/form/_colorInternals/colorMath.d.ts +63 -0
  54. package/dist/types/form/_colorInternals/pickerState.d.ts +68 -0
  55. package/dist/types/index.d.ts +8 -0
  56. package/dist/types-cjs/components/DataTable.d.ts +120 -0
  57. package/dist/types-cjs/components/useDataTable.d.ts +481 -0
  58. package/dist/types-cjs/elements/ColorSwatch.d.ts +54 -0
  59. package/dist/types-cjs/elements/Td.d.ts +9 -1
  60. package/dist/types-cjs/elements/Th.d.ts +14 -2
  61. package/dist/types-cjs/elements/Tr.d.ts +10 -1
  62. package/dist/types-cjs/form/ColorInput.d.ts +76 -0
  63. package/dist/types-cjs/form/ColorInputBase.d.ts +108 -0
  64. package/dist/types-cjs/form/ColorPicker.d.ts +271 -0
  65. package/dist/types-cjs/form/Dropzone.d.ts +138 -0
  66. package/dist/types-cjs/form/_colorInternals/EyeDropperButton.d.ts +8 -0
  67. package/dist/types-cjs/form/_colorInternals/colorMath.d.ts +63 -0
  68. package/dist/types-cjs/form/_colorInternals/pickerState.d.ts +68 -0
  69. package/dist/types-cjs/index.d.ts +8 -0
  70. package/dist/versions/bestax-no-dark-mode.css +1 -1
  71. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  72. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  73. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  74. package/dist/versions/bestax-no-helpers.css +1 -1
  75. package/dist/versions/bestax-no-helpers.css.map +1 -1
  76. package/dist/versions/bestax-prefixed.css +1 -1
  77. package/dist/versions/bestax-prefixed.css.map +1 -1
  78. package/package.json +1 -1
  79. package/src/scss/components/_datatable.scss +152 -0
  80. package/src/scss/components/_index.scss +1 -0
  81. package/src/scss/elements/_colorswatch.scss +100 -0
  82. package/src/scss/elements/_index.scss +1 -0
  83. package/src/scss/form/_checkbox.scss +53 -0
  84. package/src/scss/form/_colorinput.scss +109 -0
  85. package/src/scss/form/_colorpicker.scss +354 -0
  86. package/src/scss/form/_dropzone.scss +233 -0
  87. package/src/scss/form/_index.scss +3 -0
@@ -0,0 +1,76 @@
1
+ import React from 'react';
2
+ import { FieldProps } from './Field.js';
3
+ import { ControlBaseProps } from './Control.js';
4
+ import { ColorInputBaseProps } from './ColorInputBase.js';
5
+ /**
6
+ * Props for the ColorInput convenience wrapper. Extends
7
+ * `ColorInputBaseProps` with Field-level (label, horizontal, message) and
8
+ * Control-level (loading, expanded) props. Inside an existing `Control` it
9
+ * renders no `Control` of its own, so its Control-level props do nothing
10
+ * there and warn in development; set them on that `Control` instead. Inside
11
+ * an outer `Field`, or a `Control` with no `Field` around it, it renders no
12
+ * `Field` of its own either. The exception is `label`, `message`,
13
+ * `horizontal` or `fieldClassName` in that bare `Control`: it keeps a `Field`
14
+ * for them, nested in the `.control`, and warns in development. Wrap the
15
+ * `Control` in a `Field` instead, and set the `label`, `horizontal` and class
16
+ * name on that `Field`.
17
+ *
18
+ * @helperProps Helper props go on the `.colorinput` `<div>`, with
19
+ * `className`. The other attributes go on the text `<input>`.
20
+ * @extraProp {string} [name] - Form field name. The field submits the text it shows, the value in `format`, or nothing when it's empty.
21
+ * @extraProp {boolean} [required=false] - Marks the field required, so an empty one fails the form's constraint validation.
22
+ * @extraProp {React.Ref<HTMLInputElement>} [ref] - Forwarded to the text `<input>`.
23
+ */
24
+ export interface ColorInputProps extends ColorInputBaseProps {
25
+ /** Field label (component auto-wraps in a `Field` if not already inside). Automatically associated with the text field 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. */
26
+ label?: React.ReactNode;
27
+ /** Size for the label. */
28
+ labelSize?: FieldProps['labelSize'];
29
+ /** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). */
30
+ labelProps?: FieldProps['labelProps'];
31
+ /** Render the field with horizontal layout. */
32
+ horizontal?: boolean;
33
+ /**
34
+ * Shows a loading spinner on the `Control` it renders, and hides the
35
+ * launcher (`triggerIcon`) while it does. Inside your own `Control` it
36
+ * renders none, so this draws nothing and warns in development; set
37
+ * `isLoading` on that `Control`.
38
+ */
39
+ isLoading?: boolean;
40
+ /**
41
+ * Shows the launcher on the field's end that toggles the panel. Hidden by
42
+ * default while a spinner shows at the same edge: this component's
43
+ * `isLoading` when it renders its own `Control`, or the enclosing
44
+ * `Control`'s `isLoading` inside one.
45
+ * @defaultValue true
46
+ */
47
+ triggerIcon?: boolean;
48
+ /** Expand the control to fill its container. */
49
+ isExpanded?: boolean;
50
+ /** Size of the wrapping Control. */
51
+ controlSize?: ControlBaseProps['size'];
52
+ /** Help/validation text below the field. */
53
+ message?: React.ReactNode;
54
+ /** Color modifier for the help message. */
55
+ messageColor?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
56
+ /** Additional CSS classes for the Field wrapper. */
57
+ fieldClassName?: string;
58
+ /** Additional CSS classes for the Control wrapper. */
59
+ controlClassName?: string;
60
+ }
61
+ /**
62
+ * The `ColorInput` component is a form field for a color: type it, or open a color picker from its launcher or its swatch.
63
+ *
64
+ * The value is a CSS color string, HSL by default, or empty. The panel is
65
+ * the `ColorPicker`'s square, hue slider and, when asked for, alpha slider,
66
+ * swatches and eye dropper, in the same popover the date pickers use.
67
+ *
68
+ * @function
69
+ * @param {ColorInputProps} props - Props for the ColorInput.
70
+ * @returns {JSX.Element}
71
+ *
72
+ * @example
73
+ * <ColorInput label="Brand color" defaultValue="hsl(202, 67%, 36%)" swatches="bulma" />
74
+ */
75
+ export declare const ColorInput: React.ForwardRefExoticComponent<ColorInputProps & React.RefAttributes<HTMLInputElement>>;
76
+ export default ColorInput;
@@ -0,0 +1,108 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
3
+ import { type ColorFormat, type ColorPickerLabels, type ColorPickerSwatch } from './ColorPicker.js';
4
+ import { type PickerPosition } from './_pickerInternals/pickerTypes.js';
5
+ /**
6
+ * Props for the raw ColorInput base. Use the higher-level `ColorInput` for
7
+ * Field/Control composition; `ColorInputBase` is the field and its popover
8
+ * only.
9
+ *
10
+ * @helperProps Helper props go on the `.colorinput` `<div>`, with
11
+ * `className`. The other attributes go on the text `<input>`.
12
+ * @extraProp {string} [name] - Form field name. The field submits the text it shows, the value in `format`, or nothing when it's empty.
13
+ * @extraProp {boolean} [required=false] - Marks the field required, so an empty one fails the form's constraint validation.
14
+ * @extraProp {React.Ref<HTMLInputElement>} [ref] - Forwarded to the text `<input>`.
15
+ */
16
+ export interface ColorInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'size' | 'color' | 'type' | 'popover'>, Omit<BulmaClassesProps, 'color'> {
17
+ /**
18
+ * The color, controlled, as a CSS color the picker reads (hex, `rgb()`,
19
+ * `hsl()` or a color name), or `''` for none.
20
+ */
21
+ value?: string;
22
+ /** The color to start with, uncontrolled; empty without one. */
23
+ defaultValue?: string;
24
+ /**
25
+ * Called with the color, in `format`, as it changes: on every step of a
26
+ * drag in the panel, on a key or a swatch, and when typed text is
27
+ * committed. Clearing the field calls it with `''`.
28
+ */
29
+ onChange?: (value: string) => void;
30
+ /**
31
+ * Called with the color, in `format`, once a change is done: when a drag
32
+ * ends, and with `onChange` for everything else. The place to save it.
33
+ */
34
+ onChangeEnd?: (value: string) => void;
35
+ /**
36
+ * How the value is written: `'hsl'` (`hsl(171, 100%, 41%)`), `'hex'` or
37
+ * `'rgb'`, with alpha as `hsla()`, `#rrggbbaa` and `rgba()`. Typed text in
38
+ * any of them is written back in this one.
39
+ * @defaultValue 'hsl'
40
+ */
41
+ format?: ColorFormat;
42
+ /** Adds an alpha slider to the panel and writes the alpha into the value. */
43
+ alpha?: boolean;
44
+ /**
45
+ * Preset colors in the panel: a list of CSS colors, each a string or
46
+ * `{ color, label }`, or `"bulma"` for the page's theme colors.
47
+ */
48
+ swatches?: ColorPickerSwatch[] | 'bulma';
49
+ /**
50
+ * Adds a button to the panel that picks a color from anywhere on the
51
+ * screen, where the browser has the EyeDropper API.
52
+ */
53
+ eyeDropper?: boolean;
54
+ /** Fired when the panel opens. */
55
+ onOpen?: () => void;
56
+ /** Fired when the panel closes. */
57
+ onClose?: () => void;
58
+ /**
59
+ * Opens the panel when the field takes focus, and moves focus into it.
60
+ * Off by default, since typing a value is the quick way in and the
61
+ * launcher, a click on the swatch or Alt+ArrowDown open it.
62
+ */
63
+ openOnFocus?: boolean;
64
+ /** Closes the panel once a swatch is chosen. */
65
+ closeOnSwatchClick?: boolean;
66
+ /** The panel's place relative to the field. */
67
+ position?: PickerPosition;
68
+ /**
69
+ * Renders the panel through a portal, into the `portalContainer` a
70
+ * `ConfigProvider` sets, `document.body` by default.
71
+ */
72
+ appendToBody?: boolean;
73
+ /** Bulma color modifier for the field. */
74
+ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
75
+ /** The field's size. */
76
+ size?: 'small' | 'medium' | 'large';
77
+ /** Renders the field with rounded ends. */
78
+ isRounded?: boolean;
79
+ /** Disables the field and its panel. A disabled `Fieldset` does too. */
80
+ disabled?: boolean;
81
+ /** Makes the field read-only, with no panel. */
82
+ readOnly?: boolean;
83
+ /** Text shown while the field is empty. */
84
+ placeholder?: string;
85
+ /**
86
+ * Shows the launcher on the field's end that toggles the panel. Hidden by
87
+ * default while a `Control` it sits in shows its `isLoading` spinner,
88
+ * which shares that edge.
89
+ * @defaultValue true
90
+ */
91
+ triggerIcon?: boolean;
92
+ /** The launcher's glyph. */
93
+ triggerIconName?: string;
94
+ /** The strings it says, each with an English default. */
95
+ labels?: ColorPickerLabels;
96
+ }
97
+ /**
98
+ * The raw ColorInput: a text field with a swatch and a launcher that opens a color picker in a popover, without Field/Control wrapping.
99
+ *
100
+ * Use `ColorInput` for the convenience wrapper.
101
+ *
102
+ * @function
103
+ * @param {ColorInputBaseProps} props - Props for ColorInputBase.
104
+ * @param {React.Ref<HTMLInputElement>} ref - Forwarded ref to the text `<input>`.
105
+ * @returns {JSX.Element} The rendered field.
106
+ */
107
+ export declare const ColorInputBase: React.ForwardRefExoticComponent<ColorInputBaseProps & React.RefAttributes<HTMLInputElement>>;
108
+ export default ColorInputBase;
@@ -0,0 +1,271 @@
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
+ * Names `ColorInput`'s launcher and the panel it opens.
74
+ * @defaultValue 'Choose color'
75
+ */
76
+ chooseColor?: string;
77
+ }
78
+ /**
79
+ * Props for ColorPicker.Area. The helper props, the other attributes and the
80
+ * `ref` land on the square's `<div>`.
81
+ *
82
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the square's `<div>`.
83
+ */
84
+ export interface ColorPickerAreaProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
85
+ /** Additional CSS classes to apply. */
86
+ className?: string;
87
+ }
88
+ /**
89
+ * The saturation and brightness square, operated by pointer or by keyboard as one 2D slider.
90
+ *
91
+ * @function
92
+ * @param {ColorPickerAreaProps} props - Props for ColorPicker.Area.
93
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the square's `<div>`.
94
+ * @returns {JSX.Element | null} The square, or nothing outside a ColorPicker.
95
+ */
96
+ export declare const ColorPickerArea: React.ForwardRefExoticComponent<ColorPickerAreaProps & React.RefAttributes<HTMLDivElement>>;
97
+ /**
98
+ * Props for ColorPicker.HueSlider and ColorPicker.AlphaSlider. The helper
99
+ * props, the other attributes and the `ref` land on the slider's `<div>`.
100
+ *
101
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the slider's `<div>`.
102
+ */
103
+ export interface ColorPickerSliderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
104
+ /** Additional CSS classes to apply. */
105
+ className?: string;
106
+ }
107
+ /**
108
+ * The hue slider, from red round the spectrum and back to red.
109
+ *
110
+ * @function
111
+ * @param {ColorPickerSliderProps} props - Props for ColorPicker.HueSlider.
112
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the slider's `<div>`.
113
+ * @returns {JSX.Element | null} The slider, or nothing outside a ColorPicker.
114
+ */
115
+ export declare const ColorPickerHueSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
116
+ /**
117
+ * The alpha slider, from see-through to solid.
118
+ *
119
+ * @function
120
+ * @param {ColorPickerSliderProps} props - Props for ColorPicker.AlphaSlider.
121
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the slider's `<div>`.
122
+ * @returns {JSX.Element | null} The slider, or nothing outside a ColorPicker.
123
+ */
124
+ export declare const ColorPickerAlphaSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
125
+ /**
126
+ * Props for ColorPicker.Swatches. The helper props, the other attributes and
127
+ * the `ref` land on the group's `<div>`.
128
+ *
129
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the group's `<div>`.
130
+ */
131
+ export interface ColorPickerSwatchesProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
132
+ /** Additional CSS classes to apply. */
133
+ className?: string;
134
+ /**
135
+ * The colors to offer, in place of the picker's own `swatches`: a list,
136
+ * or `"bulma"` for the page's theme colors.
137
+ */
138
+ swatches?: ColorPickerSwatch[] | 'bulma';
139
+ }
140
+ /**
141
+ * The swatches, a radio group of preset colors that sets the picker's color.
142
+ *
143
+ * @function
144
+ * @param {ColorPickerSwatchesProps} props - Props for ColorPicker.Swatches.
145
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the group's `<div>`.
146
+ * @returns {JSX.Element | null} The swatches, or nothing outside a ColorPicker or with none to show.
147
+ */
148
+ export declare const ColorPickerSwatches: React.ForwardRefExoticComponent<ColorPickerSwatchesProps & React.RefAttributes<HTMLDivElement>>;
149
+ /**
150
+ * Props for ColorPicker.Input. The helper props, the other attributes and
151
+ * the `ref` land on the row's `<div>`.
152
+ *
153
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the row's `<div>`.
154
+ */
155
+ export interface ColorPickerInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
156
+ /** Additional CSS classes to apply. */
157
+ className?: string;
158
+ }
159
+ /**
160
+ * The value as text you can type in, beside a preview swatch, with the eye dropper when the picker has `eyeDropper`.
161
+ *
162
+ * @function
163
+ * @param {ColorPickerInputProps} props - Props for ColorPicker.Input.
164
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the row's `<div>`.
165
+ * @returns {JSX.Element | null} The row, or nothing outside a ColorPicker.
166
+ */
167
+ export declare const ColorPickerInput: React.ForwardRefExoticComponent<ColorPickerInputProps & React.RefAttributes<HTMLDivElement>>;
168
+ /**
169
+ * Props for the ColorPicker component. The helper props, the other
170
+ * attributes and the `ref` land on the picker's `<div>`, inside the `Field`
171
+ * and `Control` it renders when it isn't already in them.
172
+ *
173
+ * Inside an existing `Control` it renders no `Control` of its own. Inside an
174
+ * outer `Field`, or a `Control` with no `Field` around it, it renders no
175
+ * `Field` of its own either. The exception is `label`, `message`,
176
+ * `horizontal` or `fieldClassName` in that bare `Control`: it keeps a
177
+ * `Field` for them, nested in the `.control`, and warns in development.
178
+ * Wrap the `Control` in a `Field` instead, and set the `label`, `horizontal`
179
+ * and class name on that `Field`.
180
+ *
181
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the picker's `<div>`.
182
+ * @extraProp {string} [aria-label] - Names the picker's group when there's no `label`.
183
+ */
184
+ export interface ColorPickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'color' | 'role'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'>, FormFieldProps {
185
+ /** Additional CSS classes to apply. */
186
+ className?: string;
187
+ /** 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. */
188
+ label?: React.ReactNode;
189
+ /** 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). */
190
+ labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
191
+ [key: string]: unknown;
192
+ };
193
+ /**
194
+ * The color, controlled: any CSS color the picker reads (hex, `rgb()`,
195
+ * `hsl()` or a color name), in any format, since `onChange` hands back
196
+ * the `format` asked for. One it can't read leaves the picker showing the
197
+ * last color it could. A value it gave you comes back without moving the
198
+ * thumbs, and a gray or black keeps the hue and saturation the user had.
199
+ */
200
+ value?: string;
201
+ /** The color to start with, uncontrolled. Black without one. */
202
+ defaultValue?: string;
203
+ /**
204
+ * Called with the color, in `format`, as it changes: on every step of a
205
+ * drag, and on a key, a swatch, a typed value or the eye dropper.
206
+ */
207
+ onChange?: (value: string) => void;
208
+ /**
209
+ * Called with the color, in `format`, once a change is done: when a drag
210
+ * ends, and with `onChange` for a key, a swatch, a typed value or the eye
211
+ * dropper. The place to save it.
212
+ */
213
+ onChangeEnd?: (value: string) => void;
214
+ /**
215
+ * How the value is written: `'hsl'` (`hsl(171, 100%, 41%)`), Bulma's own
216
+ * color space and what `Theme`'s `primaryH`, `primaryS` and `primaryL`
217
+ * take, `'hex'` (`#00d1b2`) or `'rgb'` (`rgb(0, 209, 178)`). With `alpha`,
218
+ * `hsla()`, `#rrggbbaa` and `rgba()`.
219
+ * @defaultValue 'hsl'
220
+ */
221
+ format?: ColorFormat;
222
+ /**
223
+ * Adds an alpha slider and writes the alpha into the value. Without it,
224
+ * the value is always solid.
225
+ */
226
+ alpha?: boolean;
227
+ /**
228
+ * Preset colors shown as a radio group under the picker: a list of CSS
229
+ * colors, each a string or `{ color, label }`, or `"bulma"` for the page's
230
+ * primary, link, info, success, warning and danger, from Bulma's CSS
231
+ * variables, so a themed app shows its own. A color the picker can't read
232
+ * as written, such as a `var()`, is read off the page each time the picker
233
+ * renders, so after a theme change the swatches show the new colors at
234
+ * once and the chosen one is marked again on the picker's next render,
235
+ * which a `Theme` around it causes. The `"bulma"` names are English; for
236
+ * others, pass the list yourself, such as
237
+ * `{ color: 'var(--bulma-primary)', label: 'Primär' }`.
238
+ */
239
+ swatches?: ColorPickerSwatch[] | 'bulma';
240
+ /**
241
+ * Adds a button that picks a color from anywhere on the screen, where the
242
+ * browser has the EyeDropper API (desktop Chromium today). Elsewhere, and
243
+ * until the page hydrates, it isn't shown.
244
+ */
245
+ eyeDropper?: boolean;
246
+ /** Disables every part. A disabled `Fieldset` around it does too. */
247
+ disabled?: boolean;
248
+ /** Form field name. When set, a hidden input carries the value. */
249
+ name?: string;
250
+ /** The id of the form the hidden input belongs to. */
251
+ form?: string;
252
+ /** The strings it says, each with an English default. */
253
+ labels?: ColorPickerLabels;
254
+ /**
255
+ * Parts for a layout of your own: `ColorPicker.Area`,
256
+ * `ColorPicker.HueSlider`, `ColorPicker.AlphaSlider`,
257
+ * `ColorPicker.Swatches` and `ColorPicker.Input`, with anything else
258
+ * between them. Without children, the picker shows the square, the hue
259
+ * slider, the alpha slider with `alpha`, the value, and the swatches when
260
+ * there are some.
261
+ */
262
+ children?: React.ReactNode;
263
+ }
264
+ export declare const ColorPicker: React.ForwardRefExoticComponent<ColorPickerProps & React.RefAttributes<HTMLDivElement>> & {
265
+ Area: React.ForwardRefExoticComponent<ColorPickerAreaProps & React.RefAttributes<HTMLDivElement>>;
266
+ HueSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
267
+ AlphaSlider: React.ForwardRefExoticComponent<ColorPickerSliderProps & React.RefAttributes<HTMLDivElement>>;
268
+ Swatches: React.ForwardRefExoticComponent<ColorPickerSwatchesProps & React.RefAttributes<HTMLDivElement>>;
269
+ Input: React.ForwardRefExoticComponent<ColorPickerInputProps & React.RefAttributes<HTMLDivElement>>;
270
+ };
271
+ 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;
@@ -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;