@allxsmith/bestax-bulma 5.52.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 (103) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Modal.js +2 -1
  4. package/dist/esm/components/Modal.js.map +1 -1
  5. package/dist/esm/components/Sidebar.js +3 -1
  6. package/dist/esm/components/Sidebar.js.map +1 -1
  7. package/dist/esm/components/Toast.js +8 -5
  8. package/dist/esm/components/Toast.js.map +1 -1
  9. package/dist/esm/elements/Notification.js +4 -2
  10. package/dist/esm/elements/Notification.js.map +1 -1
  11. package/dist/esm/form/Autocomplete.js +3 -2
  12. package/dist/esm/form/Autocomplete.js.map +1 -1
  13. package/dist/esm/form/Checkbox.js +3 -2
  14. package/dist/esm/form/Checkbox.js.map +1 -1
  15. package/dist/esm/form/CheckboxCard.js +3 -2
  16. package/dist/esm/form/CheckboxCard.js.map +1 -1
  17. package/dist/esm/form/Combobox.js +3 -2
  18. package/dist/esm/form/Combobox.js.map +1 -1
  19. package/dist/esm/form/DateInputBase.js +15 -6
  20. package/dist/esm/form/DateInputBase.js.map +1 -1
  21. package/dist/esm/form/DateRangeInputBase.js +15 -5
  22. package/dist/esm/form/DateRangeInputBase.js.map +1 -1
  23. package/dist/esm/form/DateTimeInputBase.js +15 -6
  24. package/dist/esm/form/DateTimeInputBase.js.map +1 -1
  25. package/dist/esm/form/Fieldset.js +64 -0
  26. package/dist/esm/form/Fieldset.js.map +1 -0
  27. package/dist/esm/form/FormContext.js +17 -1
  28. package/dist/esm/form/FormContext.js.map +1 -1
  29. package/dist/esm/form/InputBase.js +3 -2
  30. package/dist/esm/form/InputBase.js.map +1 -1
  31. package/dist/esm/form/Numberinput.js +3 -2
  32. package/dist/esm/form/Numberinput.js.map +1 -1
  33. package/dist/esm/form/PinInput.js +3 -2
  34. package/dist/esm/form/PinInput.js.map +1 -1
  35. package/dist/esm/form/Radio.js +3 -2
  36. package/dist/esm/form/Radio.js.map +1 -1
  37. package/dist/esm/form/RadioCard.js +3 -2
  38. package/dist/esm/form/RadioCard.js.map +1 -1
  39. package/dist/esm/form/Rate.js +3 -2
  40. package/dist/esm/form/Rate.js.map +1 -1
  41. package/dist/esm/form/SelectBase.js +3 -2
  42. package/dist/esm/form/SelectBase.js.map +1 -1
  43. package/dist/esm/form/Slider.js +3 -2
  44. package/dist/esm/form/Slider.js.map +1 -1
  45. package/dist/esm/form/Switch.js +3 -1
  46. package/dist/esm/form/Switch.js.map +1 -1
  47. package/dist/esm/form/Taginput.js +3 -2
  48. package/dist/esm/form/Taginput.js.map +1 -1
  49. package/dist/esm/form/TextAreaBase.js +3 -2
  50. package/dist/esm/form/TextAreaBase.js.map +1 -1
  51. package/dist/esm/form/TimeInputBase.js +13 -6
  52. package/dist/esm/form/TimeInputBase.js.map +1 -1
  53. package/dist/esm/form/_pickerInternals/PickerPopover.js +4 -2
  54. package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -1
  55. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js +80 -0
  56. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js.map +1 -0
  57. package/dist/esm/helpers/LocaleProvider.js +153 -0
  58. package/dist/esm/helpers/LocaleProvider.js.map +1 -0
  59. package/dist/esm/helpers/localeInfo.js +109 -0
  60. package/dist/esm/helpers/localeInfo.js.map +1 -0
  61. package/dist/esm/helpers/portal.js +14 -1
  62. package/dist/esm/helpers/portal.js.map +1 -1
  63. package/dist/extras.css +1 -1
  64. package/dist/extras.css.map +1 -1
  65. package/dist/index.cjs +504 -46
  66. package/dist/index.cjs.map +1 -1
  67. package/dist/index.esm.js +2 -0
  68. package/dist/index.esm.js.map +1 -1
  69. package/dist/types/form/DateInputBase.d.ts +25 -3
  70. package/dist/types/form/DateRangeInputBase.d.ts +25 -3
  71. package/dist/types/form/DateTimeInputBase.d.ts +25 -3
  72. package/dist/types/form/Fieldset.d.ts +86 -0
  73. package/dist/types/form/FormContext.d.ts +12 -0
  74. package/dist/types/form/TimeInputBase.d.ts +5 -1
  75. package/dist/types/form/_pickerInternals/PickerPopover.d.ts +6 -0
  76. package/dist/types/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  77. package/dist/types/helpers/LocaleProvider.d.ts +128 -0
  78. package/dist/types/helpers/localeInfo.d.ts +23 -0
  79. package/dist/types/helpers/portal.d.ts +11 -0
  80. package/dist/types/index.d.ts +3 -0
  81. package/dist/types-cjs/form/DateInputBase.d.ts +25 -3
  82. package/dist/types-cjs/form/DateRangeInputBase.d.ts +25 -3
  83. package/dist/types-cjs/form/DateTimeInputBase.d.ts +25 -3
  84. package/dist/types-cjs/form/Fieldset.d.ts +86 -0
  85. package/dist/types-cjs/form/FormContext.d.ts +12 -0
  86. package/dist/types-cjs/form/TimeInputBase.d.ts +5 -1
  87. package/dist/types-cjs/form/_pickerInternals/PickerPopover.d.ts +6 -0
  88. package/dist/types-cjs/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  89. package/dist/types-cjs/helpers/LocaleProvider.d.ts +128 -0
  90. package/dist/types-cjs/helpers/localeInfo.d.ts +23 -0
  91. package/dist/types-cjs/helpers/portal.d.ts +11 -0
  92. package/dist/types-cjs/index.d.ts +3 -0
  93. package/dist/versions/bestax-no-dark-mode.css +1 -1
  94. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  95. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  96. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  97. package/dist/versions/bestax-no-helpers.css +1 -1
  98. package/dist/versions/bestax-no-helpers.css.map +1 -1
  99. package/dist/versions/bestax-prefixed.css +1 -1
  100. package/dist/versions/bestax-prefixed.css.map +1 -1
  101. package/package.json +1 -1
  102. package/src/scss/form/_fieldset.scss +108 -0
  103. package/src/scss/form/_index.scss +1 -0
package/dist/index.esm.js CHANGED
@@ -79,6 +79,7 @@ export { CheckboxCard } from './esm/form/CheckboxCard.js';
79
79
  export { Checkboxes } from './esm/form/Checkboxes.js';
80
80
  export { Control } from './esm/form/Control.js';
81
81
  export { Field, FieldBody, FieldLabel } from './esm/form/Field.js';
82
+ export { Fieldset } from './esm/form/Fieldset.js';
82
83
  export { File } from './esm/form/File.js';
83
84
  export { Radio, radioColors, radioSizes } from './esm/form/Radio.js';
84
85
  export { RadioCard } from './esm/form/RadioCard.js';
@@ -116,6 +117,7 @@ export { ConfigProvider, useClassPrefix, useConfig, useIconLibrary, usePrefixedC
116
117
  export { ClientOnly } from './esm/helpers/ClientOnly.js';
117
118
  export { useIsHydrated } from './esm/helpers/useIsHydrated.js';
118
119
  export { Portal } from './esm/helpers/portal.js';
120
+ export { LocaleProvider, useLocale } from './esm/helpers/LocaleProvider.js';
119
121
  export { useFocusTrap } from './esm/helpers/useFocusTrap.js';
120
122
  export { Container } from './esm/layout/Container.js';
121
123
  export { Footer } from './esm/layout/Footer.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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. */
@@ -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,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
@@ -78,6 +78,7 @@ export * from './form/CheckboxCard.js';
78
78
  export * from './form/Checkboxes.js';
79
79
  export * from './form/Control.js';
80
80
  export * from './form/Field.js';
81
+ export * from './form/Fieldset.js';
81
82
  export * from './form/File.js';
82
83
  export * from './form/Radio.js';
83
84
  export * from './form/RadioCard.js';
@@ -133,6 +134,8 @@ export type { ClientOnlyProps } from './helpers/ClientOnly.js';
133
134
  export { useIsHydrated } from './helpers/useIsHydrated.js';
134
135
  export { Portal } from './helpers/portal.js';
135
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';
136
139
  export { useFocusTrap } from './helpers/useFocusTrap.js';
137
140
  export type { UseFocusTrapOptions } from './helpers/useFocusTrap.js';
138
141
  export * from './layout/Container.js';
@@ -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[];