@allxsmith/bestax-bulma 5.27.5 → 5.27.7
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/elements/Notification.js +1 -0
- package/dist/esm/elements/Notification.js.map +1 -1
- package/dist/esm/form/Autocomplete.js +9 -9
- package/dist/esm/form/Autocomplete.js.map +1 -1
- package/dist/esm/form/DateRangeInputBase.js +18 -3
- package/dist/esm/form/DateRangeInputBase.js.map +1 -1
- package/dist/esm/form/Field.js +22 -12
- package/dist/esm/form/Field.js.map +1 -1
- package/dist/esm/form/FormContext.js +18 -13
- package/dist/esm/form/FormContext.js.map +1 -1
- package/dist/esm/form/Slider.js.map +1 -1
- package/dist/esm/form/useAutoLabelId.js +6 -5
- package/dist/esm/form/useAutoLabelId.js.map +1 -1
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +73 -42
- package/dist/index.cjs.map +1 -1
- package/dist/types/elements/Notification.d.ts +5 -0
- package/dist/types/form/Autocomplete.d.ts +2 -2
- package/dist/types/form/DateRangeInputBase.d.ts +5 -0
- package/dist/types/form/Field.d.ts +8 -3
- package/dist/types/form/FormContext.d.ts +26 -14
- package/dist/types/form/Slider.d.ts +1 -1
- package/dist/types/form/useAutoLabelId.d.ts +7 -5
- package/dist/types-cjs/elements/Notification.d.ts +5 -0
- package/dist/types-cjs/form/Autocomplete.d.ts +2 -2
- package/dist/types-cjs/form/DateRangeInputBase.d.ts +5 -0
- package/dist/types-cjs/form/Field.d.ts +8 -3
- package/dist/types-cjs/form/FormContext.d.ts +26 -14
- package/dist/types-cjs/form/Slider.d.ts +1 -1
- package/dist/types-cjs/form/useAutoLabelId.d.ts +7 -5
- 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/elements/_index.scss +1 -0
- package/src/scss/elements/_notification.scss +69 -0
|
@@ -23,6 +23,11 @@ export interface NotificationProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
|
23
23
|
/**
|
|
24
24
|
* Shows a close (delete) button in the notification. It renders
|
|
25
25
|
* `type="button"`, so it does not submit a form around it.
|
|
26
|
+
*
|
|
27
|
+
* The notification also takes `has-delete`, which pads its end by
|
|
28
|
+
* `--bulma-notification-delete-padding-inline-end` so the text clears the
|
|
29
|
+
* button. That rule ships in bestax's stylesheets, not Bulma's, so an app
|
|
30
|
+
* styled by Bulma's CSS alone keeps Bulma's padding.
|
|
26
31
|
*/
|
|
27
32
|
hasDelete?: boolean;
|
|
28
33
|
/** Callback fired when the delete button is clicked. */
|
|
@@ -19,9 +19,9 @@ export interface AutocompleteItem {
|
|
|
19
19
|
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Ref forwarded to the input element.
|
|
20
20
|
*/
|
|
21
21
|
export interface AutocompleteProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect' | 'onInput'>, Omit<BulmaClassesProps, 'color'>, FormFieldProps {
|
|
22
|
-
/** Field label
|
|
22
|
+
/** Field label, associated with the text input via `htmlFor`: through your `id` when provided, otherwise a generated one. Dropped inside an outer `Field`, whose label names the input instead when it points at it. The `Field` points its label there itself when the Autocomplete has no `id` and no inner `Field` sits between them (and the `Field` is not `grouped` or `hasAddons`); a label you wire by hand with `labelProps.htmlFor` points at the input with that `id`. The label naming the input also names the open suggestion list, through `aria-labelledby`, when it has an id: this label always does, and an outer `Field`'s does unless you wired it by hand without an `id` in its `labelProps`. Otherwise the list is named "Suggestions". */
|
|
23
23
|
label?: React.ReactNode;
|
|
24
|
-
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id
|
|
24
|
+
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (the input then gets no generated id). While the label names the input, the suggestion list's `aria-labelledby` points at it, through an `id` here when you give one and a generated one otherwise. */
|
|
25
25
|
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
26
26
|
[key: string]: unknown;
|
|
27
27
|
};
|
|
@@ -163,6 +163,11 @@ export interface DateRangeInputBaseProps extends Omit<React.HTMLAttributes<HTMLD
|
|
|
163
163
|
/**
|
|
164
164
|
* Raw DateRangeInput: the two inputs and the popover calendar without
|
|
165
165
|
* Field/Control wrapping. Use `DateRangeInput` for the convenience wrapper.
|
|
166
|
+
* Composed in a labeled `Field`, its `role="group"` root points
|
|
167
|
+
* `aria-labelledby` at that `Field`'s label, `inline` too, as the wrapper's
|
|
168
|
+
* does, and each input keeps its own name. An `aria-label` or
|
|
169
|
+
* `aria-labelledby` you give it wins over the label, and an `aria-labelledby`
|
|
170
|
+
* key counts even when undefined, since it is spread over the group's own.
|
|
166
171
|
*
|
|
167
172
|
* @function
|
|
168
173
|
* @param {DateRangeInputBaseProps} props
|
|
@@ -12,11 +12,11 @@ export interface FieldProps extends React.HTMLAttributes<HTMLDivElement>, Omit<B
|
|
|
12
12
|
hasAddons?: boolean | 'centered' | 'right';
|
|
13
13
|
/** Constrains the field to its content's width (used inside horizontal field bodies). */
|
|
14
14
|
narrow?: boolean;
|
|
15
|
-
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. Nothing else takes the label: `Checkbox`, `Radio` and `Switch` are named by their own children. Only the single inputs take the `htmlFor`, so with a group or any other content it matches nothing. Pass `labelProps={{ htmlFor }}` to wire your own `id`, or `labelProps={{ htmlFor: undefined }}` to opt out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
15
|
+
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete` also names its open suggestion list after the label through `aria-labelledby`. Nothing else takes the label: `Checkbox`, `Radio` and `Switch` are named by their own children. Only the single inputs take the `htmlFor`, so with a group or any other content it matches nothing. Pass `labelProps={{ htmlFor }}` to wire your own `id`, or `labelProps={{ htmlFor: undefined }}` to opt out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
17
|
/** Size for the label. */
|
|
18
18
|
labelSize?: 'small' | 'normal' | 'medium' | 'large';
|
|
19
|
-
/** Props for the label element. An explicit `htmlFor` key — even set to `undefined` — takes over the association.
|
|
19
|
+
/** Props for the label element. An explicit `htmlFor` key — even set to `undefined` — takes over the association. While the association is on, the label renders with the `id` given here, or a generated one, and a group control, a range `Slider`'s thumbs and an `Autocomplete`'s suggestion list point `aria-labelledby` at it. A label you take over gets no generated id, and no group points at it on its own. With an `id` here, though, a range `Slider` or an `Autocomplete` whose `id` your `htmlFor` names still points its thumbs or its suggestion list at it, in a `grouped` or `hasAddons` Field too. To point a group in an inner `Field` at this label by hand, pass that `id` with `htmlFor: undefined`, or the label keeps a generated `htmlFor` that nothing takes. */
|
|
20
20
|
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
21
21
|
[key: string]: unknown;
|
|
22
22
|
};
|
|
@@ -69,7 +69,12 @@ export interface FieldBodyProps extends React.HTMLAttributes<HTMLDivElement>, Om
|
|
|
69
69
|
* not a `<label>`, so text placed straight in it names nothing. Put a `<label>`
|
|
70
70
|
* with the `label` class inside it and point its `htmlFor` at the control's
|
|
71
71
|
* `id`, or give the horizontal `Field` a `label` prop, which renders this
|
|
72
|
-
* column and its `<label>` for you.
|
|
72
|
+
* column and its `<label>` for you. A `<label>` you put here names the
|
|
73
|
+
* control through its `htmlFor` alone: a range `Slider`'s thumbs and an
|
|
74
|
+
* `Autocomplete`'s suggestion list point `aria-labelledby` at a `Field`'s
|
|
75
|
+
* label only when its `label` prop renders it and it names the control.
|
|
76
|
+
* Where it would not name the control on its own, as in an inner `Field`,
|
|
77
|
+
* pass `labelProps={{ htmlFor, id }}` with a matching `id` on the control.
|
|
73
78
|
*
|
|
74
79
|
* @function
|
|
75
80
|
* @param {FieldLabelProps} props - Props for the FieldLabel component.
|
|
@@ -115,27 +115,39 @@ export declare const useFieldLabelId: () => string | undefined;
|
|
|
115
115
|
export declare const FieldLabelIdProvider: React.Provider<string | undefined>;
|
|
116
116
|
/**
|
|
117
117
|
* The id of a labeled Field's own `<label>`, for a group control (Radios,
|
|
118
|
-
* Checkboxes, Rate, DateRangeInput) to point
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* `useAutoLabelId`.
|
|
118
|
+
* Checkboxes, Rate, DateRangeInput and DateRangeInputBase) to point
|
|
119
|
+
* `aria-labelledby` at, since a group cannot take the label's `htmlFor`
|
|
120
|
+
* (#939, #1005). Set under the same conditions as
|
|
121
|
+
* {@link useFieldLabelId}. Consumed through `useAutoLabelledBy`.
|
|
123
122
|
* Internal; not part of the public API.
|
|
124
123
|
*/
|
|
125
124
|
export declare const useFieldLabelElementId: () => string | undefined;
|
|
126
125
|
/** Provider for the Field label's own id, used internally by Field. */
|
|
127
126
|
export declare const FieldLabelElementIdProvider: React.Provider<string | undefined>;
|
|
127
|
+
/** The nearest labeled Field's `<label>`, as {@link useFieldLabelFor} reads it. */
|
|
128
|
+
export interface FieldLabelFor {
|
|
129
|
+
/** What the label's `htmlFor` points at, generated or the caller's. */
|
|
130
|
+
htmlFor?: string;
|
|
131
|
+
/** The id the label renders with, the caller's or a generated one, if any. */
|
|
132
|
+
id?: string;
|
|
133
|
+
}
|
|
128
134
|
/**
|
|
129
|
-
*
|
|
130
|
-
* generated
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
+
* The nearest labeled Field's `<label>`: what it points `htmlFor` at, the id
|
|
136
|
+
* it generated or the caller's own `labelProps.htmlFor`, and the id the label
|
|
137
|
+
* renders with, if it has one. An unlabeled Field passes both through
|
|
138
|
+
* together, so a control in the inner Field of a horizontal layout can tell
|
|
139
|
+
* the outer label names it, and point at that label by its id, as a range
|
|
140
|
+
* Slider's thumbs (#981) and Autocomplete's suggestion list (#998) do. The
|
|
141
|
+
* `htmlFor` is only ever compared with a control's own id, never adopted, so
|
|
142
|
+
* it hands out no id for a control. The `id` is set only while that label
|
|
143
|
+
* renders with it. Unlike {@link useFieldLabelId}, it is set in a `grouped`
|
|
144
|
+
* or `hasAddons` Field too, so a label wired by hand names the control its
|
|
145
|
+
* `for` picks in those rows as well. Consumed through `useAutoLabelId`.
|
|
146
|
+
* Internal; not part of the public API.
|
|
135
147
|
*/
|
|
136
|
-
export declare const useFieldLabelFor: () =>
|
|
137
|
-
/** Provider for the Field label's `htmlFor` target, used internally by Field. */
|
|
138
|
-
export declare const FieldLabelForProvider: React.Provider<
|
|
148
|
+
export declare const useFieldLabelFor: () => FieldLabelFor;
|
|
149
|
+
/** Provider for the Field label's `htmlFor` target and id, used internally by Field. */
|
|
150
|
+
export declare const FieldLabelForProvider: React.Provider<FieldLabelFor>;
|
|
139
151
|
/**
|
|
140
152
|
* Shape of the Radios group context. The group provides:
|
|
141
153
|
* - `name`: shared form field name (Stage 1)
|
|
@@ -22,7 +22,7 @@ export interface SliderMark {
|
|
|
22
22
|
* Shared base props for single and range Slider modes.
|
|
23
23
|
*/
|
|
24
24
|
interface SliderBaseProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'color' | 'size' | 'onChange' | 'value' | 'defaultValue'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'>, FormFieldProps {
|
|
25
|
-
/** Field label. Automatically associated with the slider input via `htmlFor` — uses your `id` when provided, otherwise a generated one. In range mode the `htmlFor` targets the low (minimum) thumb, and the label also starts each thumb's name through `aria-labelledby`, as in "Price Minimum value" and "Price Maximum value", unless an `aria-label` or `aria-labelledby` on the Slider takes its place there. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`), naming a range Slider's thumbs the same way. */
|
|
25
|
+
/** Field label. Automatically associated with the slider input via `htmlFor` — uses your `id` when provided, otherwise a generated one. In range mode the `htmlFor` targets the low (minimum) thumb, and the label also starts each thumb's name through `aria-labelledby`, as in "Price Minimum value" and "Price Maximum value", unless an `aria-label` or `aria-labelledby` on the Slider takes its place there. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`), naming a range Slider's thumbs the same way. A `Field` label you wire by hand to the low thumb with `labelProps.htmlFor` names the thumbs too when you also give it an `id` there, since the `Field` generates none for it. */
|
|
26
26
|
label?: React.ReactNode;
|
|
27
27
|
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). In range mode an `id` here is the one the thumbs' `aria-labelledby` points at, in place of a generated one. */
|
|
28
28
|
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
@@ -20,9 +20,10 @@ interface UseAutoLabelIdOptions {
|
|
|
20
20
|
hasInput?: boolean;
|
|
21
21
|
/**
|
|
22
22
|
* True when the control also points `aria-labelledby` at the label, as a
|
|
23
|
-
* range Slider's thumbs
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* range Slider's thumbs (#981) and Autocomplete's suggestion list (#998)
|
|
24
|
+
* do, so it needs the label's own id. Its own label then gets one
|
|
25
|
+
* (`labelProps.id` when given, otherwise a generated one), and the hook
|
|
26
|
+
* returns it, or a surrounding Field's, as `labelId`.
|
|
26
27
|
*/
|
|
27
28
|
needsLabelId?: boolean;
|
|
28
29
|
}
|
|
@@ -45,8 +46,9 @@ export declare function useAutoLabelId({ label, id, labelProps, rendersLabel, ha
|
|
|
45
46
|
labelled: boolean;
|
|
46
47
|
/**
|
|
47
48
|
* With `needsLabelId`, the id of the label that names `controlId`, its own
|
|
48
|
-
* or a surrounding Field's. Undefined when no label names it, or when
|
|
49
|
-
* Field's label
|
|
49
|
+
* or a surrounding Field's. Undefined when no label names it, or when a
|
|
50
|
+
* Field's label wired by hand names it without an `id` in its labelProps,
|
|
51
|
+
* since the Field generates none for a label wired by hand.
|
|
50
52
|
*/
|
|
51
53
|
labelId: string | undefined;
|
|
52
54
|
};
|
|
@@ -23,6 +23,11 @@ export interface NotificationProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
|
23
23
|
/**
|
|
24
24
|
* Shows a close (delete) button in the notification. It renders
|
|
25
25
|
* `type="button"`, so it does not submit a form around it.
|
|
26
|
+
*
|
|
27
|
+
* The notification also takes `has-delete`, which pads its end by
|
|
28
|
+
* `--bulma-notification-delete-padding-inline-end` so the text clears the
|
|
29
|
+
* button. That rule ships in bestax's stylesheets, not Bulma's, so an app
|
|
30
|
+
* styled by Bulma's CSS alone keeps Bulma's padding.
|
|
26
31
|
*/
|
|
27
32
|
hasDelete?: boolean;
|
|
28
33
|
/** Callback fired when the delete button is clicked. */
|
|
@@ -19,9 +19,9 @@ export interface AutocompleteItem {
|
|
|
19
19
|
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Ref forwarded to the input element.
|
|
20
20
|
*/
|
|
21
21
|
export interface AutocompleteProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect' | 'onInput'>, Omit<BulmaClassesProps, 'color'>, FormFieldProps {
|
|
22
|
-
/** Field label
|
|
22
|
+
/** Field label, associated with the text input via `htmlFor`: through your `id` when provided, otherwise a generated one. Dropped inside an outer `Field`, whose label names the input instead when it points at it. The `Field` points its label there itself when the Autocomplete has no `id` and no inner `Field` sits between them (and the `Field` is not `grouped` or `hasAddons`); a label you wire by hand with `labelProps.htmlFor` points at the input with that `id`. The label naming the input also names the open suggestion list, through `aria-labelledby`, when it has an id: this label always does, and an outer `Field`'s does unless you wired it by hand without an `id` in its `labelProps`. Otherwise the list is named "Suggestions". */
|
|
23
23
|
label?: React.ReactNode;
|
|
24
|
-
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id
|
|
24
|
+
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (the input then gets no generated id). While the label names the input, the suggestion list's `aria-labelledby` points at it, through an `id` here when you give one and a generated one otherwise. */
|
|
25
25
|
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
26
26
|
[key: string]: unknown;
|
|
27
27
|
};
|
|
@@ -163,6 +163,11 @@ export interface DateRangeInputBaseProps extends Omit<React.HTMLAttributes<HTMLD
|
|
|
163
163
|
/**
|
|
164
164
|
* Raw DateRangeInput: the two inputs and the popover calendar without
|
|
165
165
|
* Field/Control wrapping. Use `DateRangeInput` for the convenience wrapper.
|
|
166
|
+
* Composed in a labeled `Field`, its `role="group"` root points
|
|
167
|
+
* `aria-labelledby` at that `Field`'s label, `inline` too, as the wrapper's
|
|
168
|
+
* does, and each input keeps its own name. An `aria-label` or
|
|
169
|
+
* `aria-labelledby` you give it wins over the label, and an `aria-labelledby`
|
|
170
|
+
* key counts even when undefined, since it is spread over the group's own.
|
|
166
171
|
*
|
|
167
172
|
* @function
|
|
168
173
|
* @param {DateRangeInputBaseProps} props
|
|
@@ -12,11 +12,11 @@ export interface FieldProps extends React.HTMLAttributes<HTMLDivElement>, Omit<B
|
|
|
12
12
|
hasAddons?: boolean | 'centered' | 'right';
|
|
13
13
|
/** Constrains the field to its content's width (used inside horizontal field bodies). */
|
|
14
14
|
narrow?: boolean;
|
|
15
|
-
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. Nothing else takes the label: `Checkbox`, `Radio` and `Switch` are named by their own children. Only the single inputs take the `htmlFor`, so with a group or any other content it matches nothing. Pass `labelProps={{ htmlFor }}` to wire your own `id`, or `labelProps={{ htmlFor: undefined }}` to opt out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
15
|
+
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete` also names its open suggestion list after the label through `aria-labelledby`. Nothing else takes the label: `Checkbox`, `Radio` and `Switch` are named by their own children. Only the single inputs take the `htmlFor`, so with a group or any other content it matches nothing. Pass `labelProps={{ htmlFor }}` to wire your own `id`, or `labelProps={{ htmlFor: undefined }}` to opt out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
17
|
/** Size for the label. */
|
|
18
18
|
labelSize?: 'small' | 'normal' | 'medium' | 'large';
|
|
19
|
-
/** Props for the label element. An explicit `htmlFor` key — even set to `undefined` — takes over the association.
|
|
19
|
+
/** Props for the label element. An explicit `htmlFor` key — even set to `undefined` — takes over the association. While the association is on, the label renders with the `id` given here, or a generated one, and a group control, a range `Slider`'s thumbs and an `Autocomplete`'s suggestion list point `aria-labelledby` at it. A label you take over gets no generated id, and no group points at it on its own. With an `id` here, though, a range `Slider` or an `Autocomplete` whose `id` your `htmlFor` names still points its thumbs or its suggestion list at it, in a `grouped` or `hasAddons` Field too. To point a group in an inner `Field` at this label by hand, pass that `id` with `htmlFor: undefined`, or the label keeps a generated `htmlFor` that nothing takes. */
|
|
20
20
|
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
21
21
|
[key: string]: unknown;
|
|
22
22
|
};
|
|
@@ -69,7 +69,12 @@ export interface FieldBodyProps extends React.HTMLAttributes<HTMLDivElement>, Om
|
|
|
69
69
|
* not a `<label>`, so text placed straight in it names nothing. Put a `<label>`
|
|
70
70
|
* with the `label` class inside it and point its `htmlFor` at the control's
|
|
71
71
|
* `id`, or give the horizontal `Field` a `label` prop, which renders this
|
|
72
|
-
* column and its `<label>` for you.
|
|
72
|
+
* column and its `<label>` for you. A `<label>` you put here names the
|
|
73
|
+
* control through its `htmlFor` alone: a range `Slider`'s thumbs and an
|
|
74
|
+
* `Autocomplete`'s suggestion list point `aria-labelledby` at a `Field`'s
|
|
75
|
+
* label only when its `label` prop renders it and it names the control.
|
|
76
|
+
* Where it would not name the control on its own, as in an inner `Field`,
|
|
77
|
+
* pass `labelProps={{ htmlFor, id }}` with a matching `id` on the control.
|
|
73
78
|
*
|
|
74
79
|
* @function
|
|
75
80
|
* @param {FieldLabelProps} props - Props for the FieldLabel component.
|
|
@@ -115,27 +115,39 @@ export declare const useFieldLabelId: () => string | undefined;
|
|
|
115
115
|
export declare const FieldLabelIdProvider: React.Provider<string | undefined>;
|
|
116
116
|
/**
|
|
117
117
|
* The id of a labeled Field's own `<label>`, for a group control (Radios,
|
|
118
|
-
* Checkboxes, Rate, DateRangeInput) to point
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* `useAutoLabelId`.
|
|
118
|
+
* Checkboxes, Rate, DateRangeInput and DateRangeInputBase) to point
|
|
119
|
+
* `aria-labelledby` at, since a group cannot take the label's `htmlFor`
|
|
120
|
+
* (#939, #1005). Set under the same conditions as
|
|
121
|
+
* {@link useFieldLabelId}. Consumed through `useAutoLabelledBy`.
|
|
123
122
|
* Internal; not part of the public API.
|
|
124
123
|
*/
|
|
125
124
|
export declare const useFieldLabelElementId: () => string | undefined;
|
|
126
125
|
/** Provider for the Field label's own id, used internally by Field. */
|
|
127
126
|
export declare const FieldLabelElementIdProvider: React.Provider<string | undefined>;
|
|
127
|
+
/** The nearest labeled Field's `<label>`, as {@link useFieldLabelFor} reads it. */
|
|
128
|
+
export interface FieldLabelFor {
|
|
129
|
+
/** What the label's `htmlFor` points at, generated or the caller's. */
|
|
130
|
+
htmlFor?: string;
|
|
131
|
+
/** The id the label renders with, the caller's or a generated one, if any. */
|
|
132
|
+
id?: string;
|
|
133
|
+
}
|
|
128
134
|
/**
|
|
129
|
-
*
|
|
130
|
-
* generated
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
+
* The nearest labeled Field's `<label>`: what it points `htmlFor` at, the id
|
|
136
|
+
* it generated or the caller's own `labelProps.htmlFor`, and the id the label
|
|
137
|
+
* renders with, if it has one. An unlabeled Field passes both through
|
|
138
|
+
* together, so a control in the inner Field of a horizontal layout can tell
|
|
139
|
+
* the outer label names it, and point at that label by its id, as a range
|
|
140
|
+
* Slider's thumbs (#981) and Autocomplete's suggestion list (#998) do. The
|
|
141
|
+
* `htmlFor` is only ever compared with a control's own id, never adopted, so
|
|
142
|
+
* it hands out no id for a control. The `id` is set only while that label
|
|
143
|
+
* renders with it. Unlike {@link useFieldLabelId}, it is set in a `grouped`
|
|
144
|
+
* or `hasAddons` Field too, so a label wired by hand names the control its
|
|
145
|
+
* `for` picks in those rows as well. Consumed through `useAutoLabelId`.
|
|
146
|
+
* Internal; not part of the public API.
|
|
135
147
|
*/
|
|
136
|
-
export declare const useFieldLabelFor: () =>
|
|
137
|
-
/** Provider for the Field label's `htmlFor` target, used internally by Field. */
|
|
138
|
-
export declare const FieldLabelForProvider: React.Provider<
|
|
148
|
+
export declare const useFieldLabelFor: () => FieldLabelFor;
|
|
149
|
+
/** Provider for the Field label's `htmlFor` target and id, used internally by Field. */
|
|
150
|
+
export declare const FieldLabelForProvider: React.Provider<FieldLabelFor>;
|
|
139
151
|
/**
|
|
140
152
|
* Shape of the Radios group context. The group provides:
|
|
141
153
|
* - `name`: shared form field name (Stage 1)
|
|
@@ -22,7 +22,7 @@ export interface SliderMark {
|
|
|
22
22
|
* Shared base props for single and range Slider modes.
|
|
23
23
|
*/
|
|
24
24
|
interface SliderBaseProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'color' | 'size' | 'onChange' | 'value' | 'defaultValue'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'>, FormFieldProps {
|
|
25
|
-
/** Field label. Automatically associated with the slider input via `htmlFor` — uses your `id` when provided, otherwise a generated one. In range mode the `htmlFor` targets the low (minimum) thumb, and the label also starts each thumb's name through `aria-labelledby`, as in "Price Minimum value" and "Price Maximum value", unless an `aria-label` or `aria-labelledby` on the Slider takes its place there. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`), naming a range Slider's thumbs the same way. */
|
|
25
|
+
/** Field label. Automatically associated with the slider input via `htmlFor` — uses your `id` when provided, otherwise a generated one. In range mode the `htmlFor` targets the low (minimum) thumb, and the label also starts each thumb's name through `aria-labelledby`, as in "Price Minimum value" and "Price Maximum value", unless an `aria-label` or `aria-labelledby` on the Slider takes its place there. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`), naming a range Slider's thumbs the same way. A `Field` label you wire by hand to the low thumb with `labelProps.htmlFor` names the thumbs too when you also give it an `id` there, since the `Field` generates none for it. */
|
|
26
26
|
label?: React.ReactNode;
|
|
27
27
|
/** Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). In range mode an `id` here is the one the thumbs' `aria-labelledby` points at, in place of a generated one. */
|
|
28
28
|
labelProps?: React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
@@ -20,9 +20,10 @@ interface UseAutoLabelIdOptions {
|
|
|
20
20
|
hasInput?: boolean;
|
|
21
21
|
/**
|
|
22
22
|
* True when the control also points `aria-labelledby` at the label, as a
|
|
23
|
-
* range Slider's thumbs
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* range Slider's thumbs (#981) and Autocomplete's suggestion list (#998)
|
|
24
|
+
* do, so it needs the label's own id. Its own label then gets one
|
|
25
|
+
* (`labelProps.id` when given, otherwise a generated one), and the hook
|
|
26
|
+
* returns it, or a surrounding Field's, as `labelId`.
|
|
26
27
|
*/
|
|
27
28
|
needsLabelId?: boolean;
|
|
28
29
|
}
|
|
@@ -45,8 +46,9 @@ export declare function useAutoLabelId({ label, id, labelProps, rendersLabel, ha
|
|
|
45
46
|
labelled: boolean;
|
|
46
47
|
/**
|
|
47
48
|
* With `needsLabelId`, the id of the label that names `controlId`, its own
|
|
48
|
-
* or a surrounding Field's. Undefined when no label names it, or when
|
|
49
|
-
* Field's label
|
|
49
|
+
* or a surrounding Field's. Undefined when no label names it, or when a
|
|
50
|
+
* Field's label wired by hand names it without an `id` in its labelProps,
|
|
51
|
+
* since the Field generates none for a label wired by hand.
|
|
50
52
|
*/
|
|
51
53
|
labelId: string | undefined;
|
|
52
54
|
};
|