@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,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. */
@@ -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>>;
@@ -42,7 +42,11 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
42
42
  * keeps what the format leaves out, such as seconds and the date.
43
43
  */
44
44
  parse?: (s: string) => Date | null;
45
- /** BCP-47 locale tag for Intl formatting. */
45
+ /**
46
+ * BCP-47 locale tag for Intl formatting. Unset, it is the `locale` of a
47
+ * `LocaleProvider` around the picker, and with neither, `Intl` uses the
48
+ * runtime's own locale.
49
+ */
46
50
  locale?: string;
47
51
  /** Render the spinner inline (no popover). */
48
52
  inline?: boolean;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { type PortalLocale } from '../../helpers/LocaleProvider.js';
2
3
  import { PickerPosition } from './pickerTypes.js';
3
4
  export interface PickerPopoverProps {
4
5
  isOpen: boolean;
@@ -29,6 +30,11 @@ export interface PickerPopoverProps {
29
30
  * nothing matches, or the match can't take focus, the first tab stop does.
30
31
  */
31
32
  initialFocusSelector?: string;
33
+ /**
34
+ * The `dir` and `lang` the panel carries when it portals, in place of a
35
+ * `LocaleProvider`'s: the picker's own, from `usePickerLocaleScope`.
36
+ */
37
+ localeScope?: PortalLocale;
32
38
  }
33
39
  export declare const PickerPopover: React.FC<PickerPopoverProps>;
34
40
  export default PickerPopover;
@@ -0,0 +1,49 @@
1
+ import { type PortalLocale } from '../../helpers/LocaleProvider.js';
2
+ import type { DayOfWeek } from './pickerTypes.js';
3
+ /**
4
+ * A picker's locale: its own `locale`, else the one a `LocaleProvider` around
5
+ * it sets, else `undefined`, which leaves `Intl` to use the runtime's.
6
+ */
7
+ export declare function usePickerLocale(own: string | undefined): string | undefined;
8
+ /** Where a picker's own language and direction go, inside a `LocaleProvider`. */
9
+ export interface PickerLocaleScope {
10
+ /**
11
+ * The `lang` and `dir` for the picker's root, so what renders inside it,
12
+ * an inline calendar or a popover in place, follows them. Empty unless the
13
+ * picker has a `locale` of its own.
14
+ */
15
+ rootAttrs: {
16
+ lang?: string;
17
+ dir?: string;
18
+ };
19
+ /** What its portaled panel carries; unset outside a provider. */
20
+ panel?: PortalLocale;
21
+ }
22
+ /**
23
+ * A picker's language and direction inside a `LocaleProvider`, by the rule a
24
+ * nested provider follows: its `lang` is its own `locale`, else the
25
+ * provider's, and its `dir` is the `dir` passed to it, else its own locale's
26
+ * direction when it has one, else the provider's. Outside a provider it
27
+ * changes nothing. A `locale` `Intl` refuses counts as none here, since the
28
+ * picker's own formatting reports it.
29
+ */
30
+ export declare function usePickerLocaleScope(ownLocale: string | undefined, ownDir: string | undefined): PickerLocaleScope;
31
+ /**
32
+ * Whether a picker's `dayNames` replace the calendar's own, which `Calendar`
33
+ * does only for a full week of seven.
34
+ */
35
+ export declare function hasOwnDayNames(dayNames: string[] | undefined): boolean;
36
+ /**
37
+ * The day a picker's week starts on: its own `firstDayOfWeek`, else, inside a
38
+ * `LocaleProvider`, the first day of the locale the picker uses, else Sunday.
39
+ * Outside a provider it stays Sunday whatever the locale, as it always has,
40
+ * and so does a picker inside one with no locale from either, since the
41
+ * runtime's own differs between the server and the browser.
42
+ *
43
+ * It also stays Sunday for a picker that brings its own `dayNames`. The
44
+ * calendar shows those exactly as given, in calendar order, and before the
45
+ * provider an unset `firstDayOfWeek` was always Sunday, so names written
46
+ * Sunday first would sit a day or more off their columns if the week moved
47
+ * under them.
48
+ */
49
+ export declare function usePickerFirstDayOfWeek(own: DayOfWeek | undefined, locale: string | undefined, hasDayNames: boolean): DayOfWeek;
@@ -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 {};
@@ -0,0 +1,128 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps } from './useBulmaClasses.js';
3
+ /** A writing direction. */
4
+ export type TextDirection = 'ltr' | 'rtl';
5
+ /** What the nearest `LocaleProvider` sets, both `undefined` outside one. */
6
+ export interface LocaleContextValue {
7
+ /**
8
+ * The locale, as a canonical BCP 47 tag such as `"ar-EG"`: the provider's
9
+ * own, else the one an outer provider sets.
10
+ */
11
+ locale?: string;
12
+ /**
13
+ * The direction: the provider's own `dir`, else its own locale's, else the
14
+ * one an outer provider sets.
15
+ */
16
+ dir?: TextDirection;
17
+ }
18
+ /**
19
+ * Props for the LocaleProvider component. The helper props, the other
20
+ * attributes and the `ref` land on its `<div>`.
21
+ */
22
+ export interface LocaleProviderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'dir' | 'lang' | 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
23
+ /**
24
+ * A BCP 47 language tag, such as `"de"` or `"ar-EG"`. It becomes the
25
+ * wrapper's `lang`, the default `locale` of the date and time pickers
26
+ * inside, and, with no `dir`, the direction, from the way its script is
27
+ * written. Unset, a nested provider keeps the outer one's. A tag `Intl`
28
+ * refuses is ignored, with a warning in development.
29
+ */
30
+ locale?: string;
31
+ /**
32
+ * The direction, whatever the locale. Unset, it follows this provider's
33
+ * `locale`, else an outer provider's direction, else the page's.
34
+ */
35
+ dir?: TextDirection;
36
+ /** The part of the app it covers. */
37
+ children?: React.ReactNode;
38
+ }
39
+ /**
40
+ * Sets the language and writing direction for the part of the app inside it, on a wrapper `<div>` and on what the library portals out of it.
41
+ *
42
+ * The wrapper carries `dir` and `lang`, so CSS and the components that read
43
+ * the computed direction follow it, as they follow `<html dir>`. A `locale`
44
+ * alone sets the direction of its script, and a `dir` sets the direction
45
+ * whatever the locale. A nested provider keeps whatever it leaves unset.
46
+ *
47
+ * Inside it, the date and time pickers take its `locale` unless given their
48
+ * own, and their week starts on the first day of the locale they use unless
49
+ * `firstDayOfWeek` is set, and a picker with a `locale` of its own is read
50
+ * like a nested provider. The library's portaled content, such as a
51
+ * `Popover` panel, a `Modal` with `portal`, a `Toast` or a `Portal`'s
52
+ * children, keeps the same `dir` and `lang` though it renders outside the
53
+ * wrapper: in a container outside the wrapper, it sits in a
54
+ * `display: contents` element that carries them. Without a provider none of
55
+ * this changes.
56
+ *
57
+ * @function
58
+ * @param {LocaleProviderProps} props - Props for the LocaleProvider.
59
+ * @returns {JSX.Element} The wrapper, inside the context.
60
+ *
61
+ * @example
62
+ * <LocaleProvider locale="ar-EG">
63
+ * <App />
64
+ * </LocaleProvider>
65
+ */
66
+ export declare const LocaleProvider: React.ForwardRefExoticComponent<LocaleProviderProps & React.RefAttributes<HTMLDivElement>>;
67
+ /**
68
+ * The locale and direction the nearest `LocaleProvider` sets, for an app's own `Intl` calls or its own portaled content; both are `undefined` outside one.
69
+ *
70
+ * It isn't the page's direction: with no provider, or one that sets no
71
+ * direction, the page's `<html dir>` still decides. To act on the direction
72
+ * an element is laid out in, read `getComputedStyle(element).direction`, as
73
+ * the library's components do.
74
+ *
75
+ * @function
76
+ * @returns {LocaleContextValue} The nearest provider's `locale` and `dir`.
77
+ *
78
+ * @example
79
+ * const { locale } = useLocale();
80
+ * const price = new Intl.NumberFormat(locale, {
81
+ * style: 'currency',
82
+ * currency: 'EUR',
83
+ * }).format(12.5);
84
+ */
85
+ export declare function useLocale(): LocaleContextValue;
86
+ /**
87
+ * INTERNAL, deliberately not exported from `src/index.ts`. The nearest
88
+ * provider's settings, or `null` outside any provider, so a caller can tell
89
+ * "no provider" from "a provider that sets nothing".
90
+ */
91
+ export declare function useLocaleScope(): LocaleContextValue | null;
92
+ /** The `dir` and `lang` portaled content carries: a provider's, or a picker's own. */
93
+ export interface PortalLocale {
94
+ /** The `lang` to carry, unset for none. */
95
+ locale?: string;
96
+ /** The `dir` to carry, unset for none. */
97
+ dir?: string;
98
+ }
99
+ /**
100
+ * INTERNAL, deliberately not exported from `src/index.ts`. Keeps the `dir`
101
+ * and `lang` of the nearest provider, or the `scope` given in their place,
102
+ * on content the library portals into `target`, which has left the
103
+ * provider's wrapper behind.
104
+ *
105
+ * A target inside the provider's own wrapper gets the content as it is: it
106
+ * inherits from the wrapper, and follows it when the provider changes.
107
+ * Content that must be its container's direct child, a `<tr>` portaled into
108
+ * a `<tbody>` there, stays one. Any other target, `document.body` included,
109
+ * gets the content inside a `display: contents` element carrying the
110
+ * values, which adds no box. So does content with a `scope` of its own, a
111
+ * picker's panel, since the provider's values aren't its own.
112
+ *
113
+ * Which of the two is decided once, when the content mounts, and kept while
114
+ * it stays: switching between them would put a different element in its
115
+ * place and remount everything inside, losing typed text, focus and timers.
116
+ * A change of locale or direction updates the wrapper's attributes instead.
117
+ * A target is never left bare because something else, such as `<html>`,
118
+ * happens to carry the same values, since that can stop being true without
119
+ * the content remounting. Outside a provider it renders the children alone,
120
+ * so nothing changes there.
121
+ */
122
+ export declare function LocalePortalScope({ children, target, scope, }: {
123
+ children: React.ReactNode;
124
+ /** The element the content is portaled into. */
125
+ target: Element;
126
+ /** Values to carry in place of the provider's, such as a picker's own. */
127
+ scope?: PortalLocale;
128
+ }): React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type { DayOfWeek } from '../form/_pickerInternals/pickerTypes.js';
2
+ /**
3
+ * The canonical form of a BCP 47 tag (`"en-us"` becomes `"en-US"`), or
4
+ * `undefined` for an empty or missing one. Throws a `RangeError` for a tag
5
+ * `Intl` refuses, as `Intl.DateTimeFormat` would.
6
+ */
7
+ export declare function canonicalLocale(tag: string | undefined): string | undefined;
8
+ /**
9
+ * The direction a locale's script is written in: from `Intl.Locale`'s text
10
+ * info, else from the script `maximize()` fills in, else from the language.
11
+ *
12
+ * @param locale - A canonical tag, as `canonicalLocale` returns.
13
+ */
14
+ export declare function localeDirection(locale: string): 'ltr' | 'rtl';
15
+ /**
16
+ * The day a locale's week starts on, 0 for Sunday, as `getWeekInfo()` reads
17
+ * it: the tag's `-u-fw-` keyword, else the region its `-u-rg-` keyword names,
18
+ * else its own region or the one `maximize()` fills in, looked up in CLDR's
19
+ * week data, where a region not listed starts on Monday.
20
+ *
21
+ * @param locale - A canonical tag, as `canonicalLocale` returns.
22
+ */
23
+ export declare function localeFirstDay(locale: string): DayOfWeek;
@@ -75,6 +75,17 @@ export interface PortalProps {
75
75
  * also reaches what the library's components portal, such as Popover's
76
76
  * `appendToBody` panel or a `Modal` with `portal`.
77
77
  *
78
+ * Inside a `LocaleProvider`, the children keep its `dir` and `lang`. A
79
+ * container inside the provider's own wrapper takes the children as they
80
+ * are, and they follow the provider through the page. Any other,
81
+ * `document.body` included, gets them inside one `<div>` carrying the
82
+ * provider's values, with `display: contents` so it adds no box. It is
83
+ * still an element, so content that must be the container's direct child,
84
+ * a `<tr>` in a `<tbody>`, or that a direct-child selector styles, belongs
85
+ * in a container inside the provider. Which of the two is settled when the
86
+ * children mount, so a change of locale updates them in place rather than
87
+ * remounting them.
88
+ *
78
89
  * Tab order and focus follow the DOM too. Content portaled from inside a
79
90
  * focus trap is no longer inside the trapped element, so the trap neither
80
91
  * reaches it nor holds focus there: render nested overlays inside the
@@ -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';
@@ -73,11 +74,14 @@ export * from './elements/Title.js';
73
74
  export * from './elements/Tr.js';
74
75
  export * from './elements/UnorderedList.js';
75
76
  export * from './form/Checkbox.js';
77
+ export * from './form/CheckboxCard.js';
76
78
  export * from './form/Checkboxes.js';
77
79
  export * from './form/Control.js';
78
80
  export * from './form/Field.js';
81
+ export * from './form/Fieldset.js';
79
82
  export * from './form/File.js';
80
83
  export * from './form/Radio.js';
84
+ export * from './form/RadioCard.js';
81
85
  export * from './form/Radios.js';
82
86
  export * from './form/Switch.js';
83
87
  export * from './form/Slider.js';
@@ -130,6 +134,8 @@ export type { ClientOnlyProps } from './helpers/ClientOnly.js';
130
134
  export { useIsHydrated } from './helpers/useIsHydrated.js';
131
135
  export { Portal } from './helpers/portal.js';
132
136
  export type { PortalProps } from './helpers/portal.js';
137
+ export { LocaleProvider, useLocale } from './helpers/LocaleProvider.js';
138
+ export type { LocaleContextValue, LocaleProviderProps, TextDirection, } from './helpers/LocaleProvider.js';
133
139
  export { useFocusTrap } from './helpers/useFocusTrap.js';
134
140
  export type { UseFocusTrapOptions } from './helpers/useFocusTrap.js';
135
141
  export * from './layout/Container.js';