@allxsmith/bestax-bulma 5.52.0 → 5.54.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 (145) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Avatars.js +7 -2
  4. package/dist/esm/components/Avatars.js.map +1 -1
  5. package/dist/esm/components/Badge.js +7 -2
  6. package/dist/esm/components/Badge.js.map +1 -1
  7. package/dist/esm/components/Command.js +19 -9
  8. package/dist/esm/components/Command.js.map +1 -1
  9. package/dist/esm/components/Modal.js +2 -1
  10. package/dist/esm/components/Modal.js.map +1 -1
  11. package/dist/esm/components/Pagination.js +9 -1
  12. package/dist/esm/components/Pagination.js.map +1 -1
  13. package/dist/esm/components/Sidebar.js +3 -1
  14. package/dist/esm/components/Sidebar.js.map +1 -1
  15. package/dist/esm/components/Steps.js +5 -1
  16. package/dist/esm/components/Steps.js.map +1 -1
  17. package/dist/esm/components/Toast.js +8 -5
  18. package/dist/esm/components/Toast.js.map +1 -1
  19. package/dist/esm/elements/Notification.js +4 -2
  20. package/dist/esm/elements/Notification.js.map +1 -1
  21. package/dist/esm/elements/RingProgress.js +6 -1
  22. package/dist/esm/elements/RingProgress.js.map +1 -1
  23. package/dist/esm/form/Autocomplete.js +7 -2
  24. package/dist/esm/form/Autocomplete.js.map +1 -1
  25. package/dist/esm/form/Checkbox.js +3 -2
  26. package/dist/esm/form/Checkbox.js.map +1 -1
  27. package/dist/esm/form/CheckboxCard.js +3 -2
  28. package/dist/esm/form/CheckboxCard.js.map +1 -1
  29. package/dist/esm/form/Combobox.js +10 -4
  30. package/dist/esm/form/Combobox.js.map +1 -1
  31. package/dist/esm/form/DateInputBase.js +15 -6
  32. package/dist/esm/form/DateInputBase.js.map +1 -1
  33. package/dist/esm/form/DateRangeInputBase.js +15 -5
  34. package/dist/esm/form/DateRangeInputBase.js.map +1 -1
  35. package/dist/esm/form/DateTimeInputBase.js +15 -6
  36. package/dist/esm/form/DateTimeInputBase.js.map +1 -1
  37. package/dist/esm/form/Fieldset.js +64 -0
  38. package/dist/esm/form/Fieldset.js.map +1 -0
  39. package/dist/esm/form/File.js +4 -1
  40. package/dist/esm/form/File.js.map +1 -1
  41. package/dist/esm/form/FormContext.js +17 -1
  42. package/dist/esm/form/FormContext.js.map +1 -1
  43. package/dist/esm/form/InputBase.js +3 -2
  44. package/dist/esm/form/InputBase.js.map +1 -1
  45. package/dist/esm/form/Numberinput.js +3 -2
  46. package/dist/esm/form/Numberinput.js.map +1 -1
  47. package/dist/esm/form/PinInput.js +3 -2
  48. package/dist/esm/form/PinInput.js.map +1 -1
  49. package/dist/esm/form/Radio.js +3 -2
  50. package/dist/esm/form/Radio.js.map +1 -1
  51. package/dist/esm/form/RadioCard.js +3 -2
  52. package/dist/esm/form/RadioCard.js.map +1 -1
  53. package/dist/esm/form/Rate.js +12 -3
  54. package/dist/esm/form/Rate.js.map +1 -1
  55. package/dist/esm/form/SelectBase.js +3 -2
  56. package/dist/esm/form/SelectBase.js.map +1 -1
  57. package/dist/esm/form/Slider.js +10 -6
  58. package/dist/esm/form/Slider.js.map +1 -1
  59. package/dist/esm/form/Switch.js +3 -1
  60. package/dist/esm/form/Switch.js.map +1 -1
  61. package/dist/esm/form/Taginput.js +12 -5
  62. package/dist/esm/form/Taginput.js.map +1 -1
  63. package/dist/esm/form/TextAreaBase.js +3 -2
  64. package/dist/esm/form/TextAreaBase.js.map +1 -1
  65. package/dist/esm/form/TimeInputBase.js +13 -6
  66. package/dist/esm/form/TimeInputBase.js.map +1 -1
  67. package/dist/esm/form/_pickerInternals/PickerPopover.js +4 -2
  68. package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -1
  69. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js +80 -0
  70. package/dist/esm/form/_pickerInternals/useLocaleDefaults.js.map +1 -0
  71. package/dist/esm/helpers/LocaleProvider.js +156 -0
  72. package/dist/esm/helpers/LocaleProvider.js.map +1 -0
  73. package/dist/esm/helpers/localeFormat.js +108 -0
  74. package/dist/esm/helpers/localeFormat.js.map +1 -0
  75. package/dist/esm/helpers/localeInfo.js +109 -0
  76. package/dist/esm/helpers/localeInfo.js.map +1 -0
  77. package/dist/esm/helpers/portal.js +14 -1
  78. package/dist/esm/helpers/portal.js.map +1 -1
  79. package/dist/extras.css +1 -1
  80. package/dist/extras.css.map +1 -1
  81. package/dist/index.cjs +690 -73
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.esm.js +2 -0
  84. package/dist/index.esm.js.map +1 -1
  85. package/dist/types/components/Avatars.d.ts +1 -1
  86. package/dist/types/components/Badge.d.ts +1 -1
  87. package/dist/types/components/Command.d.ts +4 -2
  88. package/dist/types/components/Pagination.d.ts +3 -0
  89. package/dist/types/components/Steps.d.ts +4 -1
  90. package/dist/types/elements/RingProgress.d.ts +3 -2
  91. package/dist/types/form/Autocomplete.d.ts +6 -1
  92. package/dist/types/form/Combobox.d.ts +3 -2
  93. package/dist/types/form/DateInputBase.d.ts +25 -3
  94. package/dist/types/form/DateRangeInputBase.d.ts +25 -3
  95. package/dist/types/form/DateTimeInputBase.d.ts +25 -3
  96. package/dist/types/form/Fieldset.d.ts +86 -0
  97. package/dist/types/form/File.d.ts +2 -1
  98. package/dist/types/form/FormContext.d.ts +12 -0
  99. package/dist/types/form/Rate.d.ts +4 -1
  100. package/dist/types/form/Slider.d.ts +9 -2
  101. package/dist/types/form/Taginput.d.ts +8 -2
  102. package/dist/types/form/TimeInputBase.d.ts +5 -1
  103. package/dist/types/form/_pickerInternals/PickerPopover.d.ts +6 -0
  104. package/dist/types/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  105. package/dist/types/helpers/LocaleProvider.d.ts +131 -0
  106. package/dist/types/helpers/localeFormat.d.ts +26 -0
  107. package/dist/types/helpers/localeInfo.d.ts +23 -0
  108. package/dist/types/helpers/portal.d.ts +11 -0
  109. package/dist/types/index.d.ts +3 -0
  110. package/dist/types-cjs/components/Avatars.d.ts +1 -1
  111. package/dist/types-cjs/components/Badge.d.ts +1 -1
  112. package/dist/types-cjs/components/Command.d.ts +4 -2
  113. package/dist/types-cjs/components/Pagination.d.ts +3 -0
  114. package/dist/types-cjs/components/Steps.d.ts +4 -1
  115. package/dist/types-cjs/elements/RingProgress.d.ts +3 -2
  116. package/dist/types-cjs/form/Autocomplete.d.ts +6 -1
  117. package/dist/types-cjs/form/Combobox.d.ts +3 -2
  118. package/dist/types-cjs/form/DateInputBase.d.ts +25 -3
  119. package/dist/types-cjs/form/DateRangeInputBase.d.ts +25 -3
  120. package/dist/types-cjs/form/DateTimeInputBase.d.ts +25 -3
  121. package/dist/types-cjs/form/Fieldset.d.ts +86 -0
  122. package/dist/types-cjs/form/File.d.ts +2 -1
  123. package/dist/types-cjs/form/FormContext.d.ts +12 -0
  124. package/dist/types-cjs/form/Rate.d.ts +4 -1
  125. package/dist/types-cjs/form/Slider.d.ts +9 -2
  126. package/dist/types-cjs/form/Taginput.d.ts +8 -2
  127. package/dist/types-cjs/form/TimeInputBase.d.ts +5 -1
  128. package/dist/types-cjs/form/_pickerInternals/PickerPopover.d.ts +6 -0
  129. package/dist/types-cjs/form/_pickerInternals/useLocaleDefaults.d.ts +49 -0
  130. package/dist/types-cjs/helpers/LocaleProvider.d.ts +131 -0
  131. package/dist/types-cjs/helpers/localeFormat.d.ts +26 -0
  132. package/dist/types-cjs/helpers/localeInfo.d.ts +23 -0
  133. package/dist/types-cjs/helpers/portal.d.ts +11 -0
  134. package/dist/types-cjs/index.d.ts +3 -0
  135. package/dist/versions/bestax-no-dark-mode.css +1 -1
  136. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  137. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  138. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  139. package/dist/versions/bestax-no-helpers.css +1 -1
  140. package/dist/versions/bestax-no-helpers.css.map +1 -1
  141. package/dist/versions/bestax-prefixed.css +1 -1
  142. package/dist/versions/bestax-prefixed.css.map +1 -1
  143. package/package.json +1 -1
  144. package/src/scss/form/_fieldset.scss +108 -0
  145. package/src/scss/form/_index.scss +1 -0
@@ -0,0 +1,131 @@
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. With a `locale`, the numbers the library writes,
51
+ * such as page numbers and badge counts, follow it, and so does the
52
+ * filtering in `Combobox`, `Autocomplete`, `Taginput` and `Command`, which then ignores
53
+ * accents where the language treats letters as the same. The library's
54
+ * portaled content, such as a `Popover` panel, a `Modal` with `portal`, a
55
+ * `Toast` or a `Portal`'s children, keeps the same `dir` and `lang` though
56
+ * it renders outside the wrapper: in a container outside the wrapper, it
57
+ * sits in a `display: contents` element that carries them. Without a
58
+ * provider none of this changes.
59
+ *
60
+ * @function
61
+ * @param {LocaleProviderProps} props - Props for the LocaleProvider.
62
+ * @returns {JSX.Element} The wrapper, inside the context.
63
+ *
64
+ * @example
65
+ * <LocaleProvider locale="ar-EG">
66
+ * <App />
67
+ * </LocaleProvider>
68
+ */
69
+ export declare const LocaleProvider: React.ForwardRefExoticComponent<LocaleProviderProps & React.RefAttributes<HTMLDivElement>>;
70
+ /**
71
+ * 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.
72
+ *
73
+ * It isn't the page's direction: with no provider, or one that sets no
74
+ * direction, the page's `<html dir>` still decides. To act on the direction
75
+ * an element is laid out in, read `getComputedStyle(element).direction`, as
76
+ * the library's components do.
77
+ *
78
+ * @function
79
+ * @returns {LocaleContextValue} The nearest provider's `locale` and `dir`.
80
+ *
81
+ * @example
82
+ * const { locale } = useLocale();
83
+ * const price = new Intl.NumberFormat(locale, {
84
+ * style: 'currency',
85
+ * currency: 'EUR',
86
+ * }).format(12.5);
87
+ */
88
+ export declare function useLocale(): LocaleContextValue;
89
+ /**
90
+ * INTERNAL, deliberately not exported from `src/index.ts`. The nearest
91
+ * provider's settings, or `null` outside any provider, so a caller can tell
92
+ * "no provider" from "a provider that sets nothing".
93
+ */
94
+ export declare function useLocaleScope(): LocaleContextValue | null;
95
+ /** The `dir` and `lang` portaled content carries: a provider's, or a picker's own. */
96
+ export interface PortalLocale {
97
+ /** The `lang` to carry, unset for none. */
98
+ locale?: string;
99
+ /** The `dir` to carry, unset for none. */
100
+ dir?: string;
101
+ }
102
+ /**
103
+ * INTERNAL, deliberately not exported from `src/index.ts`. Keeps the `dir`
104
+ * and `lang` of the nearest provider, or the `scope` given in their place,
105
+ * on content the library portals into `target`, which has left the
106
+ * provider's wrapper behind.
107
+ *
108
+ * A target inside the provider's own wrapper gets the content as it is: it
109
+ * inherits from the wrapper, and follows it when the provider changes.
110
+ * Content that must be its container's direct child, a `<tr>` portaled into
111
+ * a `<tbody>` there, stays one. Any other target, `document.body` included,
112
+ * gets the content inside a `display: contents` element carrying the
113
+ * values, which adds no box. So does content with a `scope` of its own, a
114
+ * picker's panel, since the provider's values aren't its own.
115
+ *
116
+ * Which of the two is decided once, when the content mounts, and kept while
117
+ * it stays: switching between them would put a different element in its
118
+ * place and remount everything inside, losing typed text, focus and timers.
119
+ * A change of locale or direction updates the wrapper's attributes instead.
120
+ * A target is never left bare because something else, such as `<html>`,
121
+ * happens to carry the same values, since that can stop being true without
122
+ * the content remounting. Outside a provider it renders the children alone,
123
+ * so nothing changes there.
124
+ */
125
+ export declare function LocalePortalScope({ children, target, scope, }: {
126
+ children: React.ReactNode;
127
+ /** The element the content is portaled into. */
128
+ target: Element;
129
+ /** Values to carry in place of the provider's, such as a picker's own. */
130
+ scope?: PortalLocale;
131
+ }): React.JSX.Element;
@@ -0,0 +1,26 @@
1
+ /** Formats a number for display, with `Intl.NumberFormat` options. */
2
+ export type NumberFormatter = (value: number, options?: Intl.NumberFormatOptions) => string;
3
+ /** Whether `text` contains `query`, as the locale compares letters. */
4
+ export type TextMatcher = (text: string, query: string) => boolean;
5
+ /**
6
+ * A formatter for numbers shown on screen, in the locale of the
7
+ * `LocaleProvider` around the component, or `null` outside one that gives a
8
+ * locale. Formatters are kept per set of options, since building one is the
9
+ * expensive part.
10
+ *
11
+ * @param own - The component's own locale, such as a picker's `locale`,
12
+ * which wins inside a provider.
13
+ */
14
+ export declare function useNumberFormat(own?: string): NumberFormatter | null;
15
+ /**
16
+ * A matcher for filtering a list by what was typed, in the locale of the
17
+ * `LocaleProvider` around the component, or `null` outside one that gives a
18
+ * locale. It compares with `Intl.Collator` at `usage: 'search'` and
19
+ * `sensitivity: 'base'`, so it ignores case and accents where the language
20
+ * treats the letters as the same: "cafe" finds "Café", while in Swedish "a"
21
+ * doesn't find "å", a letter of its own there. Marks the language ignores
22
+ * count for nothing on either side, so in Arabic محمد finds مُحَمَّد and the
23
+ * other way round. An empty query, or one of nothing but such marks,
24
+ * matches everything.
25
+ */
26
+ export declare function useLocaleMatcher(): TextMatcher | null;
@@ -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';