@allxsmith/bestax-bulma 5.51.0 → 5.53.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 (133) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Command.js +637 -0
  4. package/dist/esm/components/Command.js.map +1 -0
  5. package/dist/esm/components/Modal.js +2 -1
  6. package/dist/esm/components/Modal.js.map +1 -1
  7. package/dist/esm/components/Sidebar.js +3 -1
  8. package/dist/esm/components/Sidebar.js.map +1 -1
  9. package/dist/esm/components/Toast.js +8 -5
  10. package/dist/esm/components/Toast.js.map +1 -1
  11. package/dist/esm/elements/Notification.js +4 -2
  12. package/dist/esm/elements/Notification.js.map +1 -1
  13. package/dist/esm/form/Autocomplete.js +5 -4
  14. package/dist/esm/form/Autocomplete.js.map +1 -1
  15. package/dist/esm/form/Checkbox.js +3 -2
  16. package/dist/esm/form/Checkbox.js.map +1 -1
  17. package/dist/esm/form/CheckboxCard.js +119 -0
  18. package/dist/esm/form/CheckboxCard.js.map +1 -0
  19. package/dist/esm/form/Checkboxes.js +14 -3
  20. package/dist/esm/form/Checkboxes.js.map +1 -1
  21. package/dist/esm/form/Combobox.js +3 -2
  22. package/dist/esm/form/Combobox.js.map +1 -1
  23. package/dist/esm/form/DateInputBase.js +15 -6
  24. package/dist/esm/form/DateInputBase.js.map +1 -1
  25. package/dist/esm/form/DateRangeInputBase.js +15 -5
  26. package/dist/esm/form/DateRangeInputBase.js.map +1 -1
  27. package/dist/esm/form/DateTimeInputBase.js +15 -6
  28. package/dist/esm/form/DateTimeInputBase.js.map +1 -1
  29. package/dist/esm/form/Fieldset.js +64 -0
  30. package/dist/esm/form/Fieldset.js.map +1 -0
  31. package/dist/esm/form/FormContext.js +17 -1
  32. package/dist/esm/form/FormContext.js.map +1 -1
  33. package/dist/esm/form/InputBase.js +3 -2
  34. package/dist/esm/form/InputBase.js.map +1 -1
  35. package/dist/esm/form/Numberinput.js +3 -2
  36. package/dist/esm/form/Numberinput.js.map +1 -1
  37. package/dist/esm/form/PinInput.js +3 -2
  38. package/dist/esm/form/PinInput.js.map +1 -1
  39. package/dist/esm/form/Radio.js +3 -2
  40. package/dist/esm/form/Radio.js.map +1 -1
  41. package/dist/esm/form/RadioCard.js +86 -0
  42. package/dist/esm/form/RadioCard.js.map +1 -0
  43. package/dist/esm/form/Radios.js +14 -3
  44. package/dist/esm/form/Radios.js.map +1 -1
  45. package/dist/esm/form/Rate.js +3 -2
  46. package/dist/esm/form/Rate.js.map +1 -1
  47. package/dist/esm/form/SelectBase.js +3 -2
  48. package/dist/esm/form/SelectBase.js.map +1 -1
  49. package/dist/esm/form/Slider.js +3 -2
  50. package/dist/esm/form/Slider.js.map +1 -1
  51. package/dist/esm/form/Switch.js +3 -1
  52. package/dist/esm/form/Switch.js.map +1 -1
  53. package/dist/esm/form/Taginput.js +3 -2
  54. package/dist/esm/form/Taginput.js.map +1 -1
  55. package/dist/esm/form/TextAreaBase.js +3 -2
  56. package/dist/esm/form/TextAreaBase.js.map +1 -1
  57. package/dist/esm/form/TimeInputBase.js +13 -6
  58. package/dist/esm/form/TimeInputBase.js.map +1 -1
  59. package/dist/esm/form/_pickerInternals/PickerPopover.js +4 -2
  60. package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -1
  61. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js +80 -0
  62. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js.map +1 -0
  63. package/dist/esm/form/groupFieldset.js +38 -0
  64. package/dist/esm/form/groupFieldset.js.map +1 -0
  65. package/dist/esm/form/useAutoLabelId.js +1 -1
  66. package/dist/esm/helpers/LocaleProvider.js +153 -0
  67. package/dist/esm/helpers/LocaleProvider.js.map +1 -0
  68. package/dist/esm/helpers/localeInfo.js +109 -0
  69. package/dist/esm/helpers/localeInfo.js.map +1 -0
  70. package/dist/esm/helpers/portal.js +14 -1
  71. package/dist/esm/helpers/portal.js.map +1 -1
  72. package/dist/esm/helpers/useComboboxEngine.js +3 -3
  73. package/dist/esm/helpers/useFocusTrap.js +2 -2
  74. package/dist/esm/helpers/useFocusTrap.js.map +1 -1
  75. package/dist/extras.css +1 -1
  76. package/dist/extras.css.map +1 -1
  77. package/dist/index.cjs +4905 -3584
  78. package/dist/index.cjs.map +1 -1
  79. package/dist/index.esm.js +5 -0
  80. package/dist/index.esm.js.map +1 -1
  81. package/dist/types/components/Command.d.ts +318 -0
  82. package/dist/types/form/CheckboxCard.d.ts +94 -0
  83. package/dist/types/form/Checkboxes.d.ts +13 -0
  84. package/dist/types/form/DateInputBase.d.ts +25 -3
  85. package/dist/types/form/DateRangeInputBase.d.ts +25 -3
  86. package/dist/types/form/DateTimeInputBase.d.ts +25 -3
  87. package/dist/types/form/Fieldset.d.ts +86 -0
  88. package/dist/types/form/FormContext.d.ts +12 -0
  89. package/dist/types/form/RadioCard.d.ts +81 -0
  90. package/dist/types/form/Radios.d.ts +13 -0
  91. package/dist/types/form/TimeInputBase.d.ts +5 -1
  92. package/dist/types/form/_pickerInternals/PickerPopover.d.ts +6 -0
  93. package/dist/types/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  94. package/dist/types/form/groupFieldset.d.ts +32 -0
  95. package/dist/types/helpers/LocaleProvider.d.ts +128 -0
  96. package/dist/types/helpers/localeInfo.d.ts +23 -0
  97. package/dist/types/helpers/portal.d.ts +11 -0
  98. package/dist/types/index.d.ts +6 -0
  99. package/dist/types-cjs/components/Command.d.ts +318 -0
  100. package/dist/types-cjs/form/CheckboxCard.d.ts +94 -0
  101. package/dist/types-cjs/form/Checkboxes.d.ts +13 -0
  102. package/dist/types-cjs/form/DateInputBase.d.ts +25 -3
  103. package/dist/types-cjs/form/DateRangeInputBase.d.ts +25 -3
  104. package/dist/types-cjs/form/DateTimeInputBase.d.ts +25 -3
  105. package/dist/types-cjs/form/Fieldset.d.ts +86 -0
  106. package/dist/types-cjs/form/FormContext.d.ts +12 -0
  107. package/dist/types-cjs/form/RadioCard.d.ts +81 -0
  108. package/dist/types-cjs/form/Radios.d.ts +13 -0
  109. package/dist/types-cjs/form/TimeInputBase.d.ts +5 -1
  110. package/dist/types-cjs/form/_pickerInternals/PickerPopover.d.ts +6 -0
  111. package/dist/types-cjs/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  112. package/dist/types-cjs/form/groupFieldset.d.ts +32 -0
  113. package/dist/types-cjs/helpers/LocaleProvider.d.ts +128 -0
  114. package/dist/types-cjs/helpers/localeInfo.d.ts +23 -0
  115. package/dist/types-cjs/helpers/portal.d.ts +11 -0
  116. package/dist/types-cjs/index.d.ts +6 -0
  117. package/dist/versions/bestax-no-dark-mode.css +1 -1
  118. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  119. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  120. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  121. package/dist/versions/bestax-no-helpers.css +1 -1
  122. package/dist/versions/bestax-no-helpers.css.map +1 -1
  123. package/dist/versions/bestax-prefixed.css +1 -1
  124. package/dist/versions/bestax-prefixed.css.map +1 -1
  125. package/package.json +1 -1
  126. package/src/scss/components/_command.scss +259 -0
  127. package/src/scss/components/_index.scss +1 -0
  128. package/src/scss/form/_checkbox.scss +44 -0
  129. package/src/scss/form/_checkboxcard.scss +355 -0
  130. package/src/scss/form/_fieldset.scss +108 -0
  131. package/src/scss/form/_index.scss +3 -0
  132. package/src/scss/form/_radio.scss +44 -0
  133. package/src/scss/form/_radiocard.scss +291 -0
@@ -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,94 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ declare const checkboxCardColors: readonly ["primary", "link", "info", "success", "warning", "danger"];
4
+ /**
5
+ * Props for the CheckboxCard 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. Inside `Checkboxes`, the group's `name` when this is unset.
10
+ * @extraProp {string} [value] - What a form sends for the card when it's checked. Inside a `Checkboxes` group that takes `value`, `defaultValue` or `onChange`, the card is checked while the group's value holds it.
11
+ */
12
+ export interface CheckboxCardProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type' | 'color' | 'title'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'> {
13
+ /**
14
+ * What the option is, such as "Daily backups". It names the checkbox, so
15
+ * a screen reader says it with the state. Without it, the card's whole
16
+ * text names the checkbox, 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 checkbox's description when `title`, `aria-label` or
22
+ * `aria-labelledby` names it. Without one of those it's part of the name
23
+ * already, so it 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 toggle the card, but a button or another input can't
30
+ * go inside a label at all. It isn't read when the checkbox takes focus,
31
+ * so put what a screen reader should hear in `title` and `description`.
32
+ */
33
+ children?: React.ReactNode;
34
+ /**
35
+ * Shows the checkbox at the start of the card. Without it, the card's
36
+ * edge alone shows the selection, and it's thicker when checked, so the
37
+ * selection never rests on color.
38
+ */
39
+ hasIndicator?: boolean;
40
+ /** The color of the checkbox and of a checked card's edge. */
41
+ color?: (typeof checkboxCardColors)[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 leaves the Tab order. */
48
+ disabled?: boolean;
49
+ /**
50
+ * Shows the mixed state, as in a "Select all" card when some of what it
51
+ * covers is checked. It's a look and an announcement only: `checked` is
52
+ * still the value, and a click still toggles `checked`. Set to `true` or
53
+ * `false`, it's controlled: a browser clears the mixed state on a click,
54
+ * so the component sets it again from this prop after every click and
55
+ * every render. Unset isn't `false`. The component leaves the input's own
56
+ * `indeterminate` property alone, so a ref can set it, and going from set
57
+ * to unset clears it once and hands it back. It has no HTML attribute, so
58
+ * server-rendered markup can't carry it, and a mixed card renders unmixed
59
+ * until hydration.
60
+ */
61
+ indeterminate?: boolean;
62
+ /**
63
+ * Additional CSS classes, on the outer `<label>`, the card. That's the
64
+ * element that declares the `--bulma-checkbox-card-*` variables, and
65
+ * Bulma's `--bulma-card-*` ones, so a class is how to set one: `style` and
66
+ * the other input attributes go to the `<input>`. Name `.checkbox-card`
67
+ * beside your class in the selector, so it beats the card's own
68
+ * declaration whatever order the stylesheets load in. A `color` prop
69
+ * declares the active color again on `.checkbox-card.is-<color>`, which
70
+ * ties that selector, so leave `color` unset when a class sets it.
71
+ */
72
+ className?: string;
73
+ }
74
+ /**
75
+ * The `CheckboxCard` component is a checkbox drawn as a card, with a title and a description, that toggles wherever you click it.
76
+ *
77
+ * It's a `<label>` around a real checkbox, so it sends its `value` with a
78
+ * form and Space toggles it. The title names the checkbox and the
79
+ * description describes it. Alone it's one choice; inside `Checkboxes` it
80
+ * takes the group's name and selection, as `Checkbox` does.
81
+ *
82
+ * @function
83
+ * @param {CheckboxCardProps} props - Props for the CheckboxCard component.
84
+ * @param {React.Ref<HTMLInputElement>} ref - Forwarded ref to the `<input>`.
85
+ * @returns {JSX.Element} The rendered card.
86
+ *
87
+ * @example
88
+ * <Checkboxes label="Add-ons" name="extras" defaultValue={['backups']}>
89
+ * <CheckboxCard value="backups" title="Daily backups" description="Kept for 30 days." />
90
+ * <CheckboxCard value="domain" title="Custom domain" description="Bring your own." />
91
+ * </Checkboxes>
92
+ */
93
+ export declare const CheckboxCard: React.ForwardRefExoticComponent<CheckboxCardProps & React.RefAttributes<HTMLInputElement>>;
94
+ export default CheckboxCard;
@@ -30,6 +30,19 @@ export interface CheckboxesProps extends Omit<BulmaClassesProps, 'color'>, FormF
30
30
  onChange?: (values: string[]) => void;
31
31
  /** Checkbox 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>`. Where the group renders a `Field` of its own, that `Field`
36
+ * is the `<fieldset>` and the `label` is its `<legend>`, in the label
37
+ * column when `horizontal`, so the legend names the group with no ids to
38
+ * wire. Your other attributes then go on the `<fieldset>`, while
39
+ * `className` and the helper props stay on the box that lays out the
40
+ * checkboxes. Inside an outer `Field` there's no legend: the group element
41
+ * itself is the `<fieldset>`, named by that `Field`'s label as before.
42
+ * `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 Checkboxes: React.FC<CheckboxesProps> & {
35
48
  Checkbox: React.ForwardRefExoticComponent<import("./Checkbox.js").CheckboxProps & React.RefAttributes<HTMLInputElement>>;
@@ -68,7 +68,15 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
68
68
  * format leaves out, such as the time of day.
69
69
  */
70
70
  parse?: (s: string) => Date | null;
71
- /** BCP-47 locale tag for day/month names and Intl formatting. */
71
+ /**
72
+ * BCP-47 locale tag for day/month names and Intl formatting. Unset, it is
73
+ * the `locale` of a `LocaleProvider` around the picker, and with neither,
74
+ * `Intl` uses the runtime's own locale. On a server render that is the
75
+ * server's, so an `inline` calendar rendered there names its days in the
76
+ * server's language and the browser's own render names them in the
77
+ * browser's: give it a locale, here or through a `LocaleProvider`, where
78
+ * the two can differ.
79
+ */
72
80
  locale?: string;
73
81
  /** Render the calendar inline (no popover). */
74
82
  inline?: boolean;
@@ -119,9 +127,23 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
119
127
  shouldDisableDate?: (d: Date) => boolean;
120
128
  /** Convenience array of disabled dates; merged with `shouldDisableDate`. Matched by calendar day and also rejected during manual typing. */
121
129
  unselectableDates?: Date[];
122
- /** Day the week starts on (0 = Sunday). */
130
+ /**
131
+ * Day the week starts on (0 = Sunday). Unset inside a `LocaleProvider`,
132
+ * it is the first day of the week in the picker's locale, its own `locale`
133
+ * or else the provider's, such as Monday for `"de"`. Elsewhere, with no
134
+ * locale from either, or with seven `dayNames` of your own, it is Sunday:
135
+ * set it with `dayNames` to start the week on another day.
136
+ * @defaultValue 0
137
+ */
123
138
  firstDayOfWeek?: DayOfWeek;
124
- /** Override the 7 day-name labels (in calendar order, post-rotation). */
139
+ /**
140
+ * Override the 7 day-name labels (in calendar order, post-rotation). They
141
+ * are shown exactly as given, from the first column, so they have to start
142
+ * on the day the week does. With them, an unset `firstDayOfWeek` stays
143
+ * Sunday even inside a `LocaleProvider`, so names written Sunday first keep
144
+ * matching their columns; to start on the locale's day, set
145
+ * `firstDayOfWeek` too and list the names from that day.
146
+ */
125
147
  dayNames?: string[];
126
148
  /** Override the 12 month-name labels. */
127
149
  monthNames?: string[];
@@ -52,7 +52,15 @@ export interface DateRangeInputBaseProps extends Omit<React.HTMLAttributes<HTMLD
52
52
  * Enter and leaving an input call it only if the user changed its text.
53
53
  */
54
54
  parse?: (s: string) => Date | null;
55
- /** BCP-47 locale tag for day/month names and Intl formatting. */
55
+ /**
56
+ * BCP-47 locale tag for day/month names and Intl formatting. Unset, it is
57
+ * the `locale` of a `LocaleProvider` around the picker, and with neither,
58
+ * `Intl` uses the runtime's own locale. On a server render that is the
59
+ * server's, so an `inline` calendar rendered there names its days in the
60
+ * server's language and the browser's own render names them in the
61
+ * browser's: give it a locale, here or through a `LocaleProvider`, where
62
+ * the two can differ.
63
+ */
56
64
  locale?: string;
57
65
  /**
58
66
  * Render the calendar inline, with no inputs and no popover. The hidden
@@ -115,9 +123,23 @@ export interface DateRangeInputBaseProps extends Omit<React.HTMLAttributes<HTMLD
115
123
  * between, so off, a span too long to walk is refused as well.
116
124
  */
117
125
  allowDisabledInRange?: boolean;
118
- /** Day the week starts on (0 = Sunday). */
126
+ /**
127
+ * Day the week starts on (0 = Sunday). Unset inside a `LocaleProvider`,
128
+ * it is the first day of the week in the picker's locale, its own `locale`
129
+ * or else the provider's, such as Monday for `"de"`. Elsewhere, with no
130
+ * locale from either, or with seven `dayNames` of your own, it is Sunday:
131
+ * set it with `dayNames` to start the week on another day.
132
+ * @defaultValue 0
133
+ */
119
134
  firstDayOfWeek?: DayOfWeek;
120
- /** Override the 7 day-name labels (in calendar order, post-rotation). */
135
+ /**
136
+ * Override the 7 day-name labels (in calendar order, post-rotation). They
137
+ * are shown exactly as given, from the first column, so they have to start
138
+ * on the day the week does. With them, an unset `firstDayOfWeek` stays
139
+ * Sunday even inside a `LocaleProvider`, so names written Sunday first keep
140
+ * matching their columns; to start on the locale's day, set
141
+ * `firstDayOfWeek` too and list the names from that day.
142
+ */
121
143
  dayNames?: string[];
122
144
  /** Override the 12 month-name labels. */
123
145
  monthNames?: string[];
@@ -49,7 +49,15 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
49
49
  * keeps what the format leaves out, such as seconds.
50
50
  */
51
51
  parse?: (s: string) => Date | null;
52
- /** BCP-47 locale tag. */
52
+ /**
53
+ * BCP-47 locale tag for day/month names and Intl formatting. Unset, it is
54
+ * the `locale` of a `LocaleProvider` around the picker, and with neither,
55
+ * `Intl` uses the runtime's own locale. On a server render that is the
56
+ * server's, so an `inline` calendar rendered there names its days in the
57
+ * server's language and the browser's own render names them in the
58
+ * browser's: give it a locale, here or through a `LocaleProvider`, where
59
+ * the two can differ.
60
+ */
53
61
  locale?: string;
54
62
  /** Render the panel inline (no popover). */
55
63
  inline?: boolean;
@@ -96,9 +104,23 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
96
104
  shouldDisableDate?: (d: Date) => boolean;
97
105
  /** Convenience array of disabled dates, matched by calendar day; also rejected by manual typing. */
98
106
  unselectableDates?: Date[];
99
- /** Day the calendar week starts on. */
107
+ /**
108
+ * Day the week starts on (0 = Sunday). Unset inside a `LocaleProvider`,
109
+ * it is the first day of the week in the picker's locale, its own `locale`
110
+ * or else the provider's, such as Monday for `"de"`. Elsewhere, with no
111
+ * locale from either, or with seven `dayNames` of your own, it is Sunday:
112
+ * set it with `dayNames` to start the week on another day.
113
+ * @defaultValue 0
114
+ */
100
115
  firstDayOfWeek?: DayOfWeek;
101
- /** Override the 7 day-name labels. */
116
+ /**
117
+ * Override the 7 day-name labels (in calendar order, post-rotation). They
118
+ * are shown exactly as given, from the first column, so they have to start
119
+ * on the day the week does. With them, an unset `firstDayOfWeek` stays
120
+ * Sunday even inside a `LocaleProvider`, so names written Sunday first keep
121
+ * matching their columns; to start on the locale's day, set
122
+ * `firstDayOfWeek` too and list the names from that day.
123
+ */
102
124
  dayNames?: string[];
103
125
  /** Override the 12 month-name labels. */
104
126
  monthNames?: string[];
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ import type { FormFieldProps } from './fieldProps.js';
4
+ /** The looks a Fieldset comes in. */
5
+ export type FieldsetVariant = 'default' | 'filled' | 'unstyled';
6
+ /**
7
+ * Props for the Fieldset component. The helper props, the other attributes
8
+ * and the `ref` land on its `<fieldset>`.
9
+ *
10
+ * @extraProp {React.Ref<HTMLFieldSetElement>} [ref] - Ref forwarded to the `<fieldset>`, whose `elements` lists the controls inside.
11
+ * @extraProp {string} [aria-describedby] - Ids of more text that describes the group. The `message`'s id is added after them.
12
+ * @extraProp {string} [name] - The fieldset's name in its form's `elements`. Nothing is submitted under it.
13
+ */
14
+ export interface FieldsetProps extends Omit<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
15
+ /**
16
+ * The group's name, shown in a `<legend>`, which names the fieldset with no
17
+ * ids to wire. The `default` and `filled` variants draw it on the border,
18
+ * and `unstyled` above the content. Controls you put in it, such as a
19
+ * `Checkbox` that turns the section on, stay enabled when the Fieldset is
20
+ * disabled, as the browser leaves them.
21
+ */
22
+ legend?: React.ReactNode;
23
+ /** Props for the `<legend>`, such as an `id` or a `className`. */
24
+ legendProps?: React.HTMLAttributes<HTMLLegendElement>;
25
+ /**
26
+ * The look: `default` draws a border round the group, `filled` adds a
27
+ * tinted background, and `unstyled` draws no box at all, which suits a
28
+ * Fieldset that's there to name or disable a group.
29
+ */
30
+ variant?: FieldsetVariant;
31
+ /**
32
+ * Disables every control inside. The browser disables the native ones and
33
+ * leaves them out of the form's data, and each bestax input with a
34
+ * `disabled` prop takes this as that prop's default, which also stops
35
+ * widgets the browser doesn't reach, such as `Rate`'s stars and the time
36
+ * wheels, and gives them their disabled look. An input's own `disabled`
37
+ * still wins when you set it, though the browser keeps its native parts
38
+ * disabled whatever it says. Links and `LinkButton`s stay operable, as in
39
+ * plain HTML.
40
+ */
41
+ disabled?: boolean;
42
+ /**
43
+ * Help text under the group. It describes the fieldset through
44
+ * `aria-describedby`, alongside any ids you pass there. Nothing passes it
45
+ * to the inputs, so each still shows its own errors.
46
+ */
47
+ message?: React.ReactNode;
48
+ /** Bulma color for the message. */
49
+ messageColor?: FormFieldProps['messageColor'];
50
+ /** Text color helper, for the text in the group. The legend keeps its own color. */
51
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
52
+ /** Background color helper. */
53
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
54
+ /** Additional CSS classes. */
55
+ className?: string;
56
+ /** The group's content, such as `Field`s and inputs. */
57
+ children?: React.ReactNode;
58
+ }
59
+ /**
60
+ * The `Fieldset` component groups a section of a form in a native
61
+ * `<fieldset>`, named by its `legend`, which a `disabled` switches off as a
62
+ * whole.
63
+ *
64
+ * It starts its own Field scope: inside it, nothing reads as inside a
65
+ * `Field` or `Control`, so the convenience inputs render their own `Field`,
66
+ * and a labeled `Field` around the Fieldset names nothing in it.
67
+ *
68
+ * @function
69
+ * @param {FieldsetProps} props - Props for the Fieldset component.
70
+ * @returns {JSX.Element} The rendered fieldset.
71
+ *
72
+ * @example
73
+ * <Fieldset legend="Shipping address" message="We only ship within the EU.">
74
+ * <Input label="Street" name="street" />
75
+ * <Input label="City" name="city" />
76
+ * </Fieldset>
77
+ *
78
+ * @example
79
+ * // A form that's saving
80
+ * <Fieldset disabled={saving} variant="unstyled">
81
+ * <Input label="Name" name="name" />
82
+ * <Rate label="Rating" name="rating" />
83
+ * </Fieldset>
84
+ */
85
+ export declare const Fieldset: React.ForwardRefExoticComponent<FieldsetProps & React.RefAttributes<HTMLFieldSetElement>>;
86
+ export default Fieldset;
@@ -14,6 +14,18 @@ export declare const useInsideControl: () => boolean;
14
14
  export declare const FieldProvider: React.Provider<boolean>;
15
15
  /** Provider for Control context — used internally by Control component. */
16
16
  export declare const ControlProvider: React.Provider<boolean>;
17
+ /**
18
+ * An input's `disabled`: its own prop when the caller set one, otherwise
19
+ * whether a disabled `Fieldset` holds it. A `<fieldset disabled>` disables the
20
+ * native controls inside on its own, and this carries the same state to what
21
+ * the browser doesn't reach, such as Rate's stars, the time wheels, and the
22
+ * `is-disabled` classes. The content of a Fieldset's legend reads the state
23
+ * from outside that Fieldset, as the browser leaves the first legend's
24
+ * controls enabled. Internal; not part of the public API.
25
+ */
26
+ export declare const useFieldsetDisabled: (disabled: boolean | undefined) => boolean;
27
+ /** Provider for a Fieldset's disabled state, used internally by Fieldset. */
28
+ export declare const FieldsetDisabledProvider: React.Provider<boolean>;
17
29
  /** The wrapper props that change what its own `Field` renders. */
18
30
  interface FieldShapingProps {
19
31
  /** Rendered as the `Field`'s label. */