@allxsmith/bestax-bulma 5.50.0 → 5.52.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 +637 -0
- package/dist/esm/components/Command.js.map +1 -0
- package/dist/esm/components/EmptyState.js +2 -2
- package/dist/esm/components/Timeline.js +5 -5
- package/dist/esm/components/TreeView.js +3 -3
- package/dist/esm/components/TreeView.js.map +1 -1
- package/dist/esm/elements/DescriptionList.js +133 -0
- package/dist/esm/elements/DescriptionList.js.map +1 -0
- package/dist/esm/form/Autocomplete.js +2 -2
- package/dist/esm/form/CheckboxCard.js +118 -0
- package/dist/esm/form/CheckboxCard.js.map +1 -0
- package/dist/esm/form/Checkboxes.js +14 -3
- package/dist/esm/form/Checkboxes.js.map +1 -1
- package/dist/esm/form/RadioCard.js +85 -0
- package/dist/esm/form/RadioCard.js.map +1 -0
- package/dist/esm/form/Radios.js +14 -3
- package/dist/esm/form/Radios.js.map +1 -1
- package/dist/esm/form/groupFieldset.js +38 -0
- package/dist/esm/form/groupFieldset.js.map +1 -0
- package/dist/esm/form/useAutoLabelId.js +1 -1
- package/dist/esm/helpers/useComboboxEngine.js +3 -3
- package/dist/esm/helpers/useFocusTrap.js +2 -2
- package/dist/esm/helpers/useFocusTrap.js.map +1 -1
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +2685 -1694
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +4 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Command.d.ts +318 -0
- package/dist/types/elements/DescriptionList.d.ts +185 -0
- package/dist/types/form/CheckboxCard.d.ts +94 -0
- package/dist/types/form/Checkboxes.d.ts +13 -0
- package/dist/types/form/RadioCard.d.ts +81 -0
- package/dist/types/form/Radios.d.ts +13 -0
- package/dist/types/form/groupFieldset.d.ts +32 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types-cjs/components/Command.d.ts +318 -0
- package/dist/types-cjs/elements/DescriptionList.d.ts +185 -0
- package/dist/types-cjs/form/CheckboxCard.d.ts +94 -0
- package/dist/types-cjs/form/Checkboxes.d.ts +13 -0
- package/dist/types-cjs/form/RadioCard.d.ts +81 -0
- package/dist/types-cjs/form/Radios.d.ts +13 -0
- package/dist/types-cjs/form/groupFieldset.d.ts +32 -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/_command.scss +259 -0
- package/src/scss/components/_index.scss +1 -0
- package/src/scss/elements/_descriptionlist.scss +153 -0
- package/src/scss/elements/_index.scss +1 -0
- package/src/scss/form/_checkbox.scss +44 -0
- package/src/scss/form/_checkboxcard.scss +355 -0
- package/src/scss/form/_index.scss +2 -0
- package/src/scss/form/_radio.scss +44 -0
- package/src/scss/form/_radiocard.scss +291 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
declare const radioCardColors: readonly ["primary", "link", "info", "success", "warning", "danger"];
|
|
4
|
+
/**
|
|
5
|
+
* Props for the RadioCard component.
|
|
6
|
+
*
|
|
7
|
+
* @helperProps Helper props go on the outer `<label>`, the `.card`, with
|
|
8
|
+
* `className`. The other attributes go on the `<input>`.
|
|
9
|
+
* @extraProp {string} [name] - The form field name, which the cards of one choice share, so the arrow keys move between them. Inside `Radios`, the group's `name` when this is unset.
|
|
10
|
+
* @extraProp {string} [value] - What a form sends when this card is the one picked. Inside a `Radios` group that takes `value`, `defaultValue` or `onChange`, the card is checked while the group's value is this.
|
|
11
|
+
*/
|
|
12
|
+
export interface RadioCardProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type' | 'color' | 'title'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'> {
|
|
13
|
+
/**
|
|
14
|
+
* What the option is, such as "Express". It names the radio, so a screen
|
|
15
|
+
* reader says it with the state and its place in the group. Without it,
|
|
16
|
+
* the card's whole text names the radio, as a label's text does.
|
|
17
|
+
*/
|
|
18
|
+
title?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* A line or two about the option, read after the name and the state. It's
|
|
21
|
+
* the radio's description when `title`, `aria-label` or `aria-labelledby`
|
|
22
|
+
* names it. Without one of those it's part of the name already, so it
|
|
23
|
+
* isn't read twice.
|
|
24
|
+
*/
|
|
25
|
+
description?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Anything else in the card, after the description, such as a price. A
|
|
28
|
+
* label holds phrasing content only, so spans, images and links: a link
|
|
29
|
+
* works and doesn't pick the card, but a button or another input can't go
|
|
30
|
+
* inside a label at all. It isn't read when the radio takes focus, so put
|
|
31
|
+
* what a screen reader should hear in `title` and `description`.
|
|
32
|
+
*/
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Shows the radio at the start of the card. Without it, the card's edge
|
|
36
|
+
* alone shows the selection, and it's thicker when picked, so the
|
|
37
|
+
* selection never rests on color.
|
|
38
|
+
*/
|
|
39
|
+
hasIndicator?: boolean;
|
|
40
|
+
/** The color of the radio and of a picked card's edge. */
|
|
41
|
+
color?: (typeof radioCardColors)[number];
|
|
42
|
+
/**
|
|
43
|
+
* Text color helper, on the card. The title and the children take it, and
|
|
44
|
+
* the description keeps its own color.
|
|
45
|
+
*/
|
|
46
|
+
textColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
47
|
+
/** Whether the card is disabled. A disabled card dims, takes no clicks, and the arrow keys skip it. */
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Additional CSS classes, on the outer `<label>`, the card. That's the
|
|
51
|
+
* element that declares the `--bulma-radio-card-*` variables, and Bulma's
|
|
52
|
+
* `--bulma-card-*` ones, so a class is how to set one: `style` and the
|
|
53
|
+
* other input attributes go to the `<input>`. Name `.radio-card` beside
|
|
54
|
+
* your class in the selector, so it beats the card's own declaration
|
|
55
|
+
* whatever order the stylesheets load in. A `color` prop declares the
|
|
56
|
+
* active color again on `.radio-card.is-<color>`, which ties that
|
|
57
|
+
* selector, so leave `color` unset when a class sets it.
|
|
58
|
+
*/
|
|
59
|
+
className?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The `RadioCard` component is a radio button drawn as a card, with a title and a description, picked wherever you click it.
|
|
63
|
+
*
|
|
64
|
+
* It's a `<label>` around a real radio, so it sends its `value` with a form,
|
|
65
|
+
* and the cards that share a `name` are one choice the arrow keys move
|
|
66
|
+
* through. The title names the radio and the description describes it.
|
|
67
|
+
* Inside `Radios` it takes the group's name and selection, as `Radio` does.
|
|
68
|
+
*
|
|
69
|
+
* @function
|
|
70
|
+
* @param {RadioCardProps} props - Props for the RadioCard component.
|
|
71
|
+
* @param {React.Ref<HTMLInputElement>} ref - Forwarded ref to the `<input>`.
|
|
72
|
+
* @returns {JSX.Element} The rendered card.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* <Radios label="Shipping" name="shipping" defaultValue="standard">
|
|
76
|
+
* <RadioCard value="standard" title="Standard" description="Arrives in 4 to 6 days." />
|
|
77
|
+
* <RadioCard value="express" title="Express" description="Arrives tomorrow." />
|
|
78
|
+
* </Radios>
|
|
79
|
+
*/
|
|
80
|
+
export declare const RadioCard: React.ForwardRefExoticComponent<RadioCardProps & React.RefAttributes<HTMLInputElement>>;
|
|
81
|
+
export default RadioCard;
|
|
@@ -30,6 +30,19 @@ export interface RadiosProps extends Omit<BulmaClassesProps, 'color'>, FormField
|
|
|
30
30
|
onChange?: (value: string) => void;
|
|
31
31
|
/** Radio elements to render in the group. */
|
|
32
32
|
children: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* The element the group renders as. With `fieldset` it's a native
|
|
35
|
+
* `<fieldset>` that keeps `role="radiogroup"`. Where the group renders a
|
|
36
|
+
* `Field` of its own, that `Field` is the `<fieldset>` and the `label` is
|
|
37
|
+
* its `<legend>`, in the label column when `horizontal`, so the legend names
|
|
38
|
+
* the group with no ids to wire. Your other attributes then go on the
|
|
39
|
+
* `<fieldset>`, while `className` and the helper props stay on the box that
|
|
40
|
+
* lays out the radios. Inside an outer `Field` there's no legend: the group
|
|
41
|
+
* element itself is the `<fieldset>`, named by that `Field`'s label as
|
|
42
|
+
* before. `div`, the default, renders the group as it always has.
|
|
43
|
+
* @defaultValue 'div'
|
|
44
|
+
*/
|
|
45
|
+
as?: 'div' | 'fieldset';
|
|
33
46
|
}
|
|
34
47
|
export declare const Radios: React.FC<RadiosProps> & {
|
|
35
48
|
Radio: React.ForwardRefExoticComponent<import("./Radio.js").RadioProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FormFieldProps } from './fieldProps.js';
|
|
3
|
+
interface GroupFieldsetProps {
|
|
4
|
+
/** The group's label, rendered as the `<legend>`. */
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
/** Sizes the legend's label column when `horizontal`. */
|
|
7
|
+
labelSize?: FormFieldProps['labelSize'];
|
|
8
|
+
/** Props for the element that shows the label; any `htmlFor` is dropped. */
|
|
9
|
+
labelProps?: FormFieldProps['labelProps'];
|
|
10
|
+
/** Puts the legend in the label column and the rest in the body. */
|
|
11
|
+
horizontal?: boolean;
|
|
12
|
+
/** Set on the `<fieldset>` beside its `field` class. */
|
|
13
|
+
fieldClassName?: string;
|
|
14
|
+
/** The group's role, when it isn't the fieldset's own `group`. */
|
|
15
|
+
role?: 'radiogroup';
|
|
16
|
+
/** The group's own attributes: they describe the group, so they go on the `<fieldset>`. */
|
|
17
|
+
attributes: object;
|
|
18
|
+
/** The group's help text, after the content. */
|
|
19
|
+
message: React.ReactNode;
|
|
20
|
+
/** The group's content: its `Control` and the box of choices. */
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The `Field` a `Checkboxes` or `Radios` with `as="fieldset"` renders of its
|
|
25
|
+
* own, as a native `<fieldset>`: Bulma's field markup, with its label as the
|
|
26
|
+
* `<legend>` (inside the `field-label` column when horizontal), so the legend
|
|
27
|
+
* names the group and needs no id. It holds a `Field`'s place for what is
|
|
28
|
+
* inside, so the choices read as inside a `Field`. Internal; not part of the
|
|
29
|
+
* public API.
|
|
30
|
+
*/
|
|
31
|
+
export declare const GroupFieldset: React.FC<GroupFieldsetProps>;
|
|
32
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from './components/Carousel.js';
|
|
|
31
31
|
export * from './components/Reveal.js';
|
|
32
32
|
export * from './components/TreeView.js';
|
|
33
33
|
export * from './components/ScrollArea.js';
|
|
34
|
+
export * from './components/Command.js';
|
|
34
35
|
export * from './elements/Block.js';
|
|
35
36
|
export * from './elements/Box.js';
|
|
36
37
|
export * from './elements/Button.js';
|
|
@@ -40,6 +41,7 @@ export * from './elements/ToggleButton.js';
|
|
|
40
41
|
export * from './elements/Code.js';
|
|
41
42
|
export * from './elements/Content.js';
|
|
42
43
|
export * from './elements/Delete.js';
|
|
44
|
+
export * from './elements/DescriptionList.js';
|
|
43
45
|
export * from './elements/Divider.js';
|
|
44
46
|
export * from './elements/Emphasis.js';
|
|
45
47
|
export * from './elements/Figure.js';
|
|
@@ -72,11 +74,13 @@ export * from './elements/Title.js';
|
|
|
72
74
|
export * from './elements/Tr.js';
|
|
73
75
|
export * from './elements/UnorderedList.js';
|
|
74
76
|
export * from './form/Checkbox.js';
|
|
77
|
+
export * from './form/CheckboxCard.js';
|
|
75
78
|
export * from './form/Checkboxes.js';
|
|
76
79
|
export * from './form/Control.js';
|
|
77
80
|
export * from './form/Field.js';
|
|
78
81
|
export * from './form/File.js';
|
|
79
82
|
export * from './form/Radio.js';
|
|
83
|
+
export * from './form/RadioCard.js';
|
|
80
84
|
export * from './form/Radios.js';
|
|
81
85
|
export * from './form/Switch.js';
|
|
82
86
|
export * from './form/Slider.js';
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
import { InputProps } from '../form/Input.js';
|
|
4
|
+
/** One action in a Command's `actions`. */
|
|
5
|
+
export interface CommandAction {
|
|
6
|
+
/** Unique within the Command. It's the item's `value`, so `onSelect` hands it back. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** What the item shows, and what typing matches first. */
|
|
9
|
+
label: string;
|
|
10
|
+
/**
|
|
11
|
+
* A line under the label, such as what the action does or where it goes.
|
|
12
|
+
* Typing matches it too, after the labels. A screen reader hears it after
|
|
13
|
+
* the label, as the item's description.
|
|
14
|
+
*/
|
|
15
|
+
description?: string;
|
|
16
|
+
/**
|
|
17
|
+
* More words typing matches, after the labels, such as `['theme']` for
|
|
18
|
+
* "Dark mode". They aren't shown.
|
|
19
|
+
*/
|
|
20
|
+
keywords?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* The heading the action goes under. Groups show in the order the matches
|
|
23
|
+
* first name them, so the best match is always on top, and the actions with
|
|
24
|
+
* no group show together where the first of them is.
|
|
25
|
+
*/
|
|
26
|
+
group?: string;
|
|
27
|
+
/** Shown before the label, and hidden from assistive tech. */
|
|
28
|
+
icon?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Shown at the end of the row, such as the action's own keyboard shortcut in
|
|
31
|
+
* a `Kbd.Group`, or a `Tag`. It only shows: nothing listens for a shortcut
|
|
32
|
+
* written here. A screen reader hears it after the label, with the
|
|
33
|
+
* description.
|
|
34
|
+
*/
|
|
35
|
+
hint?: React.ReactNode;
|
|
36
|
+
/** Shown, and reached with the arrows so a screen reader user finds it, but never run. */
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/** Runs the action, when it's picked with Enter or a click, before the Command's `onSelect`. */
|
|
39
|
+
onSelect?: () => void;
|
|
40
|
+
}
|
|
41
|
+
/** What a Command takes whether it's given `actions` or built from parts. */
|
|
42
|
+
interface CommandBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color' | 'onSelect'>, Omit<BulmaClassesProps, 'color'> {
|
|
43
|
+
/**
|
|
44
|
+
* What the Command is for, such as "Commands" or "Settings". It's never
|
|
45
|
+
* shown: it names the search field and the list for assistive tech, and in
|
|
46
|
+
* `Command.Dialog` the dialog too. An empty string counts as none.
|
|
47
|
+
* @defaultValue 'Commands'
|
|
48
|
+
*/
|
|
49
|
+
label?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The search, controlled: the text in the field. Pair it with
|
|
52
|
+
* `onQueryChange`.
|
|
53
|
+
*/
|
|
54
|
+
query?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The search to start with when uncontrolled.
|
|
57
|
+
* @defaultValue ''
|
|
58
|
+
*/
|
|
59
|
+
defaultQuery?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Called with the search as the user types it. Built from parts, this is
|
|
62
|
+
* where the app filters its items.
|
|
63
|
+
*/
|
|
64
|
+
onQueryChange?: (query: string) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Called with the picked item's `value`, an action's `id`, when it's run
|
|
67
|
+
* with Enter or a click, after the item's own `onSelect`. A disabled item
|
|
68
|
+
* is never run.
|
|
69
|
+
*/
|
|
70
|
+
onSelect?: (value: string) => void;
|
|
71
|
+
}
|
|
72
|
+
/** Props for a Command given `actions`. */
|
|
73
|
+
export interface CommandActionsProps extends CommandBaseProps {
|
|
74
|
+
/**
|
|
75
|
+
* The actions, for a Command that renders the field, the list, the groups
|
|
76
|
+
* and the empty message itself. Typing filters them by label, keywords and
|
|
77
|
+
* description, ignoring case, with label matches first. Leave it out to
|
|
78
|
+
* build the Command from parts.
|
|
79
|
+
*/
|
|
80
|
+
actions: CommandAction[];
|
|
81
|
+
/**
|
|
82
|
+
* Takes over the filtering, with `actions`: it's handed the search as typed
|
|
83
|
+
* and every action, and returns the ones to show, in the order to show
|
|
84
|
+
* them, which is how to plug in fuzzy matching or cut the list short. It's
|
|
85
|
+
* called with an empty search too.
|
|
86
|
+
*/
|
|
87
|
+
filter?: (query: string, actions: CommandAction[]) => CommandAction[];
|
|
88
|
+
/** The field's placeholder, with `actions`. */
|
|
89
|
+
placeholder?: string;
|
|
90
|
+
/**
|
|
91
|
+
* What shows in place of the list, with `actions`, when nothing matches.
|
|
92
|
+
* It's announced the way `Command.Empty` is. `null` shows nothing.
|
|
93
|
+
* @defaultValue 'No results'
|
|
94
|
+
*/
|
|
95
|
+
empty?: React.ReactNode;
|
|
96
|
+
/** @internal With `actions`, the Command renders its own parts. */
|
|
97
|
+
children?: never;
|
|
98
|
+
}
|
|
99
|
+
/** Props for a Command built from parts. */
|
|
100
|
+
export interface CommandPartsProps extends CommandBaseProps {
|
|
101
|
+
/**
|
|
102
|
+
* The parts, in order: `Command.Input`, then `Command.List` while there are
|
|
103
|
+
* items and `Command.Empty` while there aren't. Nothing filters them, so
|
|
104
|
+
* render the items that match the search `onQueryChange` reports. With
|
|
105
|
+
* `actions` there are none to give: children given with it are ignored,
|
|
106
|
+
* with a warning in development.
|
|
107
|
+
*/
|
|
108
|
+
children?: React.ReactNode;
|
|
109
|
+
/** @internal Built from parts, the app renders the items. */
|
|
110
|
+
actions?: never;
|
|
111
|
+
/** @internal Built from parts, the app filters. */
|
|
112
|
+
filter?: never;
|
|
113
|
+
/** @internal Built from parts, `Command.Input` takes the placeholder. */
|
|
114
|
+
placeholder?: never;
|
|
115
|
+
/** @internal Built from parts, `Command.Empty` is the empty message. */
|
|
116
|
+
empty?: never;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Props for the Command component: given `actions`, it renders, filters and
|
|
120
|
+
* groups them itself, and without them it's built from parts. The helper
|
|
121
|
+
* props, the other attributes and the `ref` land on the `div.command` around
|
|
122
|
+
* the field and the list.
|
|
123
|
+
*
|
|
124
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the `div.command` around the field and the list.
|
|
125
|
+
*/
|
|
126
|
+
export type CommandProps = CommandActionsProps | CommandPartsProps;
|
|
127
|
+
/** What Command.Dialog takes on top of a Command's props. */
|
|
128
|
+
interface CommandDialogOwnProps {
|
|
129
|
+
/** Controlled open state. When set, opening and closing only report through `onOpenChange`. */
|
|
130
|
+
open?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Initial open state when uncontrolled.
|
|
133
|
+
* @defaultValue false
|
|
134
|
+
*/
|
|
135
|
+
defaultOpen?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Called with the open state asked for: `true` from the `shortcut`, and
|
|
138
|
+
* `false` from Escape, a click on the background, or a pick while
|
|
139
|
+
* `closeOnSelect` is on. Fires in controlled and uncontrolled use.
|
|
140
|
+
*/
|
|
141
|
+
onOpenChange?: (open: boolean) => void;
|
|
142
|
+
/**
|
|
143
|
+
* A key combination that opens the dialog from anywhere on the page, such
|
|
144
|
+
* as `"mod+k"`: modifiers and a key joined by `+`, where `mod` is Ctrl or
|
|
145
|
+
* ⌘ (either one, on every platform), and the others are `ctrl`, `meta`,
|
|
146
|
+
* `alt` and `shift`. It's ignored while the user is typing in a text field,
|
|
147
|
+
* a select or editable content, while an IME is composing, while a modal
|
|
148
|
+
* overlay is open (a `Modal`, a `Dialog`, a `Sidebar` with its overlay or a
|
|
149
|
+
* full-page `Loading`), and when something else has already used the key.
|
|
150
|
+
* It only opens the dialog. Off unless given.
|
|
151
|
+
*/
|
|
152
|
+
shortcut?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Closes the dialog once an item has run. Turn it off for an item that
|
|
155
|
+
* opens another page of the palette, and close it yourself with `open`.
|
|
156
|
+
* @defaultValue true
|
|
157
|
+
*/
|
|
158
|
+
closeOnSelect?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Clears the search when the dialog closes: an uncontrolled one itself,
|
|
161
|
+
* and a controlled one through `onQueryChange('')`.
|
|
162
|
+
* @defaultValue true
|
|
163
|
+
*/
|
|
164
|
+
clearOnClose?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Renders the dialog into a portal target instead of inline. Forwarded to
|
|
167
|
+
* the underlying `Modal`; see its `portal` prop for the accepted values.
|
|
168
|
+
* @defaultValue false
|
|
169
|
+
*/
|
|
170
|
+
portal?: boolean | string | HTMLElement;
|
|
171
|
+
}
|
|
172
|
+
/** Props for a Command.Dialog given `actions`. */
|
|
173
|
+
export interface CommandDialogActionsProps extends CommandActionsProps, CommandDialogOwnProps {
|
|
174
|
+
}
|
|
175
|
+
/** Props for a Command.Dialog built from parts. */
|
|
176
|
+
export interface CommandDialogPartsProps extends CommandPartsProps, CommandDialogOwnProps {
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Props for Command.Dialog, the Command in a modal: a Command's props, given
|
|
180
|
+
* `actions` or built from parts, and the dialog's own. The helper props, the
|
|
181
|
+
* other attributes and the `ref` land on the `div.command` that is the
|
|
182
|
+
* dialog.
|
|
183
|
+
*
|
|
184
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the `div.command` that is the dialog.
|
|
185
|
+
*/
|
|
186
|
+
export type CommandDialogProps = CommandDialogActionsProps | CommandDialogPartsProps;
|
|
187
|
+
/**
|
|
188
|
+
* Props for Command.Input, the search field. It renders `Input`, so its
|
|
189
|
+
* icons, `isLoading` and `color` work as they do there. Its text is the
|
|
190
|
+
* Command's `query`, and it's `autoComplete="off"`, so the browser's own
|
|
191
|
+
* suggestions don't open over the list: neither is yours to set.
|
|
192
|
+
*/
|
|
193
|
+
export type CommandInputProps = Omit<InputProps, 'label' | 'labelSize' | 'labelProps' | 'horizontal' | 'message' | 'messageColor' | 'fieldClassName' | 'role' | 'autoComplete' | 'value' | 'defaultValue'>;
|
|
194
|
+
/**
|
|
195
|
+
* Props for Command.List, the list. Its `id` is the one the field's
|
|
196
|
+
* `aria-controls` names, so it isn't yours to set.
|
|
197
|
+
*/
|
|
198
|
+
export interface CommandListProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'role' | 'id'> {
|
|
199
|
+
/** `Command.Item`s and `Command.Group`s, in the order they're shown. */
|
|
200
|
+
children?: React.ReactNode;
|
|
201
|
+
}
|
|
202
|
+
/** Props for Command.Group, items under a heading. */
|
|
203
|
+
export interface CommandGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'role'> {
|
|
204
|
+
/**
|
|
205
|
+
* The heading, which also names the group for assistive tech, unless you
|
|
206
|
+
* give the group an `aria-label` or `aria-labelledby` of its own.
|
|
207
|
+
*/
|
|
208
|
+
label: React.ReactNode;
|
|
209
|
+
/** The group's `Command.Item`s. */
|
|
210
|
+
children?: React.ReactNode;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Props for Command.Item, one thing to do in the list. Its `id` follows from
|
|
214
|
+
* its `value`, since the field's `aria-activedescendant` names it, so it
|
|
215
|
+
* isn't yours to set.
|
|
216
|
+
*/
|
|
217
|
+
export interface CommandItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'role' | 'onSelect' | 'id'> {
|
|
218
|
+
/** What the Command's `onSelect` hands back. Unique within the Command. */
|
|
219
|
+
value: string;
|
|
220
|
+
/**
|
|
221
|
+
* Can't be run. The arrows still reach it, so a screen reader user finds
|
|
222
|
+
* it, and it's never `aria-selected`.
|
|
223
|
+
* @defaultValue false
|
|
224
|
+
*/
|
|
225
|
+
disabled?: boolean;
|
|
226
|
+
/** Runs the item, when it's picked with Enter or a click, before the Command's `onSelect`. */
|
|
227
|
+
onSelect?: () => void;
|
|
228
|
+
/** Shown before the label, and hidden from assistive tech. */
|
|
229
|
+
icon?: React.ReactNode;
|
|
230
|
+
/**
|
|
231
|
+
* A line under the label. A screen reader hears it after the label, as the
|
|
232
|
+
* item's description.
|
|
233
|
+
*/
|
|
234
|
+
description?: React.ReactNode;
|
|
235
|
+
/**
|
|
236
|
+
* Shown at the end of the row, such as a keyboard shortcut in a
|
|
237
|
+
* `Kbd.Group`, or a `Tag`. It only shows. A screen reader hears it after
|
|
238
|
+
* the label, with the description.
|
|
239
|
+
*/
|
|
240
|
+
hint?: React.ReactNode;
|
|
241
|
+
/** The label, which names the item. */
|
|
242
|
+
children?: React.ReactNode;
|
|
243
|
+
}
|
|
244
|
+
/** Props for Command.Empty, the message shown in place of the list. */
|
|
245
|
+
export interface CommandEmptyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
246
|
+
/**
|
|
247
|
+
* The message, such as "No commands match". Its text is announced when
|
|
248
|
+
* typing brings it on screen and isn't read again while it stays, so a
|
|
249
|
+
* message that names the search is heard for the first search only.
|
|
250
|
+
*/
|
|
251
|
+
children?: React.ReactNode;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The search field, with the combobox role and the keys, rendered as an `Input` with a search icon.
|
|
255
|
+
*
|
|
256
|
+
* @function
|
|
257
|
+
* @param {CommandInputProps} props - Props for the Command.Input component.
|
|
258
|
+
* @param {React.Ref<HTMLInputElement>} ref - Forwarded ref to the `<input>`.
|
|
259
|
+
* @returns {JSX.Element} The field in its Control.
|
|
260
|
+
*/
|
|
261
|
+
export declare const CommandInput: React.ForwardRefExoticComponent<CommandInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
262
|
+
/**
|
|
263
|
+
* The list of items, a `listbox` named by the Command's `label`.
|
|
264
|
+
*
|
|
265
|
+
* @function
|
|
266
|
+
* @param {CommandListProps} props - Props for the Command.List component.
|
|
267
|
+
* @returns {JSX.Element} The listbox.
|
|
268
|
+
*/
|
|
269
|
+
export declare const CommandList: React.FC<CommandListProps>;
|
|
270
|
+
/**
|
|
271
|
+
* Items under a heading, a `group` named by it.
|
|
272
|
+
*
|
|
273
|
+
* @function
|
|
274
|
+
* @param {CommandGroupProps} props - Props for the Command.Group component.
|
|
275
|
+
* @returns {JSX.Element} The group and its heading.
|
|
276
|
+
*/
|
|
277
|
+
export declare const CommandGroup: React.FC<CommandGroupProps>;
|
|
278
|
+
/**
|
|
279
|
+
* One thing to do in the list, named by its label and described by its description and hint.
|
|
280
|
+
*
|
|
281
|
+
* @function
|
|
282
|
+
* @param {CommandItemProps} props - Props for the Command.Item component.
|
|
283
|
+
* @returns {JSX.Element} The item.
|
|
284
|
+
*/
|
|
285
|
+
export declare const CommandItem: React.FC<CommandItemProps>;
|
|
286
|
+
/**
|
|
287
|
+
* The message shown in place of the list when nothing matches, announced when typing brings it on screen.
|
|
288
|
+
*
|
|
289
|
+
* @function
|
|
290
|
+
* @param {CommandEmptyProps} props - Props for the Command.Empty component.
|
|
291
|
+
* @returns {JSX.Element} The message.
|
|
292
|
+
*/
|
|
293
|
+
export declare const CommandEmpty: React.FC<CommandEmptyProps>;
|
|
294
|
+
/**
|
|
295
|
+
* The Command in a modal, a command palette, opened by its `shortcut` or by `open`, that closes once an item has run.
|
|
296
|
+
*
|
|
297
|
+
* It renders nothing while it's closed. Open, it's a `Modal` with a
|
|
298
|
+
* background and the Command's box as the `dialog`, named by `label`:
|
|
299
|
+
* focus goes to the search field, Tab stays inside, Escape and a click on
|
|
300
|
+
* the background close it, the page behind it doesn't scroll, and focus goes
|
|
301
|
+
* back to where it was when it closes.
|
|
302
|
+
*
|
|
303
|
+
* @function
|
|
304
|
+
* @param {CommandDialogProps} props - Props for the Command.Dialog component.
|
|
305
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the `div.command` that is the dialog.
|
|
306
|
+
* @returns {JSX.Element | null} The dialog, or nothing while it's closed.
|
|
307
|
+
*/
|
|
308
|
+
export declare const CommandDialog: React.ForwardRefExoticComponent<CommandDialogProps & React.RefAttributes<HTMLDivElement>>;
|
|
309
|
+
/** Command with Input, List, Group, Item, Empty and Dialog sub-components. */
|
|
310
|
+
export declare const Command: React.ForwardRefExoticComponent<CommandProps & React.RefAttributes<HTMLDivElement>> & {
|
|
311
|
+
Input: React.ForwardRefExoticComponent<CommandInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
312
|
+
List: React.FC<CommandListProps>;
|
|
313
|
+
Group: React.FC<CommandGroupProps>;
|
|
314
|
+
Item: React.FC<CommandItemProps>;
|
|
315
|
+
Empty: React.FC<CommandEmptyProps>;
|
|
316
|
+
Dialog: React.ForwardRefExoticComponent<CommandDialogProps & React.RefAttributes<HTMLDivElement>>;
|
|
317
|
+
};
|
|
318
|
+
export default Command;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
declare const validDescriptionListOrientations: readonly ["vertical", "horizontal"];
|
|
4
|
+
/** Whether each label sits above its value (`vertical`) or beside it (`horizontal`). */
|
|
5
|
+
export type DescriptionListOrientation = (typeof validDescriptionListOrientations)[number];
|
|
6
|
+
/**
|
|
7
|
+
* Props for the DescriptionList component. The helper props, the other
|
|
8
|
+
* attributes and the `ref` land on the `<dl>`.
|
|
9
|
+
*
|
|
10
|
+
* @extraProp {React.Ref<HTMLDListElement>} [ref] - Ref forwarded to the `<dl>`.
|
|
11
|
+
* @extraProp {string} [aria-labelledby] - The id of the heading above the list, which names it.
|
|
12
|
+
*/
|
|
13
|
+
export interface DescriptionListProps extends Omit<React.HTMLAttributes<HTMLDListElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
14
|
+
/** Additional CSS classes to apply. */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** `DescriptionList.Item`s, one for each fact. */
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Whether each label sits above its value or beside it, at every width no
|
|
20
|
+
* `orientation<Viewport>` prop covers. Those props read the way a
|
|
21
|
+
* `Column`'s `size<Viewport>` props do: `orientationMobile` applies below
|
|
22
|
+
* Bulma's tablet breakpoint, each of the others from its own breakpoint
|
|
23
|
+
* up, and where several apply the widest one wins. With none of them,
|
|
24
|
+
* labels sit above their values below the tablet breakpoint and beside
|
|
25
|
+
* them from it up. Beside, the labels share one column as wide as the
|
|
26
|
+
* longest label, up to `--bulma-description-list-label-max-width`, so the
|
|
27
|
+
* values line up.
|
|
28
|
+
*/
|
|
29
|
+
orientation?: DescriptionListOrientation;
|
|
30
|
+
/**
|
|
31
|
+
* The orientation below Bulma's tablet breakpoint (769px). Falls back to
|
|
32
|
+
* `orientation`, then to `vertical`.
|
|
33
|
+
*/
|
|
34
|
+
orientationMobile?: DescriptionListOrientation;
|
|
35
|
+
/**
|
|
36
|
+
* The orientation from Bulma's tablet breakpoint (769px) up, until a wider
|
|
37
|
+
* viewport's prop takes over. Falls back to `orientation`, then to
|
|
38
|
+
* `horizontal`.
|
|
39
|
+
*/
|
|
40
|
+
orientationTablet?: DescriptionListOrientation;
|
|
41
|
+
/**
|
|
42
|
+
* The orientation from Bulma's desktop breakpoint (1024px) up, until a
|
|
43
|
+
* wider viewport's prop takes over. Falls back to `orientationTablet`, and
|
|
44
|
+
* on down.
|
|
45
|
+
*/
|
|
46
|
+
orientationDesktop?: DescriptionListOrientation;
|
|
47
|
+
/**
|
|
48
|
+
* The orientation from Bulma's widescreen breakpoint (1216px) up, until
|
|
49
|
+
* `orientationFullhd` takes over. Falls back to `orientationDesktop`, and
|
|
50
|
+
* on down.
|
|
51
|
+
*/
|
|
52
|
+
orientationWidescreen?: DescriptionListOrientation;
|
|
53
|
+
/**
|
|
54
|
+
* The orientation from Bulma's fullhd breakpoint (1408px) up. Falls back to
|
|
55
|
+
* `orientationWidescreen`, and on down.
|
|
56
|
+
*/
|
|
57
|
+
orientationFullhd?: DescriptionListOrientation;
|
|
58
|
+
/**
|
|
59
|
+
* Draws a line between items, which helps the eye from a label to its
|
|
60
|
+
* value across a wide list, and shows where each item ends to someone
|
|
61
|
+
* zoomed in.
|
|
62
|
+
*/
|
|
63
|
+
hasDividers?: boolean;
|
|
64
|
+
/** Text color helper. It colors the values; the labels keep their own color. */
|
|
65
|
+
textColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
66
|
+
/** Background color helper. */
|
|
67
|
+
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Props for DescriptionList.Item, one fact. The helper props, the other
|
|
71
|
+
* attributes and the `ref` land on its `<div>`.
|
|
72
|
+
*
|
|
73
|
+
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the `<div>`.
|
|
74
|
+
*/
|
|
75
|
+
export interface DescriptionListItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
76
|
+
/** Additional CSS classes to apply. */
|
|
77
|
+
className?: string;
|
|
78
|
+
/**
|
|
79
|
+
* The label, such as "Order", as a `DescriptionList.Label` before the
|
|
80
|
+
* children.
|
|
81
|
+
*/
|
|
82
|
+
label?: React.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* The value, such as "#1234", as a `DescriptionList.Value` after the
|
|
85
|
+
* children. Text, a link, a `Tag`: anything that renders. `undefined`,
|
|
86
|
+
* `null` and `''` render nothing, so when a value is missing, say so in
|
|
87
|
+
* words, such as "Not given", rather than leave a label with nothing after
|
|
88
|
+
* it.
|
|
89
|
+
*/
|
|
90
|
+
value?: React.ReactNode;
|
|
91
|
+
/**
|
|
92
|
+
* `DescriptionList.Label`s and `DescriptionList.Value`s, for what `label`
|
|
93
|
+
* and `value` don't cover, such as a label with an info tip or several
|
|
94
|
+
* values. They render between the two, so a `Label` here reads before
|
|
95
|
+
* `value`, and a `Value` here after `label`.
|
|
96
|
+
*/
|
|
97
|
+
children?: React.ReactNode;
|
|
98
|
+
/** Text color helper. */
|
|
99
|
+
textColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
100
|
+
/** Background color helper. */
|
|
101
|
+
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Props for DescriptionList.Label. The helper props, the other attributes and
|
|
105
|
+
* the `ref` land on its `<dt>`.
|
|
106
|
+
*
|
|
107
|
+
* @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dt>`.
|
|
108
|
+
*/
|
|
109
|
+
export interface DescriptionListLabelProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
110
|
+
/** Additional CSS classes to apply. */
|
|
111
|
+
className?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The label. A button may sit in it, such as one that opens a `Popover`
|
|
114
|
+
* about the label, but not a heading, which HTML doesn't allow here.
|
|
115
|
+
*/
|
|
116
|
+
children?: React.ReactNode;
|
|
117
|
+
/** Text color helper. */
|
|
118
|
+
textColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
119
|
+
/** Background color helper. */
|
|
120
|
+
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Props for DescriptionList.Value. The helper props, the other attributes and
|
|
124
|
+
* the `ref` land on its `<dd>`.
|
|
125
|
+
*
|
|
126
|
+
* @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dd>`.
|
|
127
|
+
*/
|
|
128
|
+
export interface DescriptionListValueProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
129
|
+
/** Additional CSS classes to apply. */
|
|
130
|
+
className?: string;
|
|
131
|
+
/** The value. Anything goes, a list or a paragraph included. */
|
|
132
|
+
children?: React.ReactNode;
|
|
133
|
+
/** Text color helper. */
|
|
134
|
+
textColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
135
|
+
/** Background color helper. */
|
|
136
|
+
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A label, the name of a fact: a `<dt>`, in the weaker text color.
|
|
140
|
+
*
|
|
141
|
+
* @function
|
|
142
|
+
* @param {DescriptionListLabelProps} props - Props for DescriptionList.Label.
|
|
143
|
+
* @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dt>`.
|
|
144
|
+
* @returns {JSX.Element} The rendered label.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* <DescriptionList.Label>Placed on</DescriptionList.Label>
|
|
148
|
+
*/
|
|
149
|
+
export declare const DescriptionListLabel: React.ForwardRefExoticComponent<DescriptionListLabelProps & React.RefAttributes<HTMLElement>>;
|
|
150
|
+
/**
|
|
151
|
+
* A value, what the label says about the thing: a `<dd>`. An item may have several.
|
|
152
|
+
*
|
|
153
|
+
* @function
|
|
154
|
+
* @param {DescriptionListValueProps} props - Props for DescriptionList.Value.
|
|
155
|
+
* @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.
|
|
156
|
+
* @returns {JSX.Element} The rendered value.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* <DescriptionList.Value>14 October 2026</DescriptionList.Value>
|
|
160
|
+
*/
|
|
161
|
+
export declare const DescriptionListValue: React.ForwardRefExoticComponent<DescriptionListValueProps & React.RefAttributes<HTMLElement>>;
|
|
162
|
+
/**
|
|
163
|
+
* One fact: its label and its value, in a `<div>`, from the `label` and `value` props or from `Label` and `Value` children.
|
|
164
|
+
*
|
|
165
|
+
* @function
|
|
166
|
+
* @param {DescriptionListItemProps} props - Props for DescriptionList.Item.
|
|
167
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the `<div>`.
|
|
168
|
+
* @returns {JSX.Element} The rendered item.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* <DescriptionList.Item label="Order" value="#1234" />
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* <DescriptionList.Item label="Tags">
|
|
175
|
+
* <DescriptionList.Value>Gift</DescriptionList.Value>
|
|
176
|
+
* <DescriptionList.Value>Priority</DescriptionList.Value>
|
|
177
|
+
* </DescriptionList.Item>
|
|
178
|
+
*/
|
|
179
|
+
export declare const DescriptionListItem: React.ForwardRefExoticComponent<DescriptionListItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
180
|
+
export declare const DescriptionList: React.ForwardRefExoticComponent<DescriptionListProps & React.RefAttributes<HTMLDListElement>> & {
|
|
181
|
+
Item: React.ForwardRefExoticComponent<DescriptionListItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
182
|
+
Label: React.ForwardRefExoticComponent<DescriptionListLabelProps & React.RefAttributes<HTMLElement>>;
|
|
183
|
+
Value: React.ForwardRefExoticComponent<DescriptionListValueProps & React.RefAttributes<HTMLElement>>;
|
|
184
|
+
};
|
|
185
|
+
export default DescriptionList;
|