@allxsmith/bestax-bulma 5.57.5 → 5.59.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 (112) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Avatars.js +2 -2
  4. package/dist/esm/components/Avatars.js.map +1 -1
  5. package/dist/esm/components/Badge.js +2 -2
  6. package/dist/esm/components/Badge.js.map +1 -1
  7. package/dist/esm/components/Pagination.js +2 -2
  8. package/dist/esm/components/Pagination.js.map +1 -1
  9. package/dist/esm/components/Steps.js +2 -2
  10. package/dist/esm/components/Steps.js.map +1 -1
  11. package/dist/esm/components/TreeView.js +7 -5
  12. package/dist/esm/components/TreeView.js.map +1 -1
  13. package/dist/esm/components/useDataTable.js +2 -2
  14. package/dist/esm/components/useDataTable.js.map +1 -1
  15. package/dist/esm/elements/Buttons.js +2 -0
  16. package/dist/esm/elements/Buttons.js.map +1 -1
  17. package/dist/esm/elements/IconButton.js +114 -0
  18. package/dist/esm/elements/IconButton.js.map +1 -0
  19. package/dist/esm/elements/NumberFormatter.js +42 -0
  20. package/dist/esm/elements/NumberFormatter.js.map +1 -0
  21. package/dist/esm/elements/RingProgress.js +2 -2
  22. package/dist/esm/elements/RingProgress.js.map +1 -1
  23. package/dist/esm/form/Dropzone.js +2 -2
  24. package/dist/esm/form/Dropzone.js.map +1 -1
  25. package/dist/esm/form/File.js +2 -2
  26. package/dist/esm/form/File.js.map +1 -1
  27. package/dist/esm/form/Rate.js +2 -2
  28. package/dist/esm/form/Rate.js.map +1 -1
  29. package/dist/esm/form/Slider.js +2 -2
  30. package/dist/esm/form/Slider.js.map +1 -1
  31. package/dist/esm/form/Taginput.js +2 -2
  32. package/dist/esm/form/Taginput.js.map +1 -1
  33. package/dist/esm/form/_colorInternals/pickerState.js +2 -2
  34. package/dist/esm/form/_colorInternals/pickerState.js.map +1 -1
  35. package/dist/esm/helpers/LocaleProvider.js +13 -6
  36. package/dist/esm/helpers/LocaleProvider.js.map +1 -1
  37. package/dist/esm/helpers/containerBreakpoints.js +14 -0
  38. package/dist/esm/helpers/containerBreakpoints.js.map +1 -0
  39. package/dist/esm/helpers/localeFormat.js +196 -36
  40. package/dist/esm/helpers/localeFormat.js.map +1 -1
  41. package/dist/esm/helpers/polymorphic.js.map +1 -1
  42. package/dist/esm/helpers/stackLayout.js +30 -0
  43. package/dist/esm/helpers/stackLayout.js.map +1 -0
  44. package/dist/esm/helpers/useBulmaClasses.js +8 -2
  45. package/dist/esm/helpers/useBulmaClasses.js.map +1 -1
  46. package/dist/esm/helpers/useFlexboxClasses.js +17 -4
  47. package/dist/esm/helpers/useFlexboxClasses.js.map +1 -1
  48. package/dist/esm/helpers/useTreeView.js +54 -20
  49. package/dist/esm/helpers/useTreeView.js.map +1 -1
  50. package/dist/esm/layout/Center.js +33 -0
  51. package/dist/esm/layout/Center.js.map +1 -0
  52. package/dist/esm/layout/Container.js +2 -6
  53. package/dist/esm/layout/Container.js.map +1 -1
  54. package/dist/esm/layout/Flex.js +34 -0
  55. package/dist/esm/layout/Flex.js.map +1 -0
  56. package/dist/esm/layout/Group.js +43 -0
  57. package/dist/esm/layout/Group.js.map +1 -0
  58. package/dist/esm/layout/Stack.js +34 -0
  59. package/dist/esm/layout/Stack.js.map +1 -0
  60. package/dist/extras.css +1 -1
  61. package/dist/extras.css.map +1 -1
  62. package/dist/index.cjs +712 -212
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.esm.js +7 -0
  65. package/dist/index.esm.js.map +1 -1
  66. package/dist/types/components/TreeView.d.ts +20 -11
  67. package/dist/types/elements/Buttons.d.ts +1 -0
  68. package/dist/types/elements/IconButton.d.ts +110 -0
  69. package/dist/types/elements/NumberFormatter.d.ts +62 -0
  70. package/dist/types/helpers/LocaleProvider.d.ts +7 -0
  71. package/dist/types/helpers/containerBreakpoints.d.ts +2 -0
  72. package/dist/types/helpers/localeFormat.d.ts +30 -8
  73. package/dist/types/helpers/polymorphic.d.ts +19 -0
  74. package/dist/types/helpers/stackLayout.d.ts +62 -0
  75. package/dist/types/helpers/useBulmaClasses.d.ts +8 -2
  76. package/dist/types/helpers/useFlexboxClasses.d.ts +26 -3
  77. package/dist/types/helpers/useTreeView.d.ts +12 -6
  78. package/dist/types/index.d.ts +10 -1
  79. package/dist/types/layout/Center.d.ts +54 -0
  80. package/dist/types/layout/Flex.d.ts +92 -0
  81. package/dist/types/layout/Group.d.ts +86 -0
  82. package/dist/types/layout/Stack.d.ts +63 -0
  83. package/dist/types-cjs/components/TreeView.d.ts +20 -11
  84. package/dist/types-cjs/elements/Buttons.d.ts +1 -0
  85. package/dist/types-cjs/elements/IconButton.d.ts +110 -0
  86. package/dist/types-cjs/elements/NumberFormatter.d.ts +62 -0
  87. package/dist/types-cjs/helpers/LocaleProvider.d.ts +7 -0
  88. package/dist/types-cjs/helpers/containerBreakpoints.d.ts +2 -0
  89. package/dist/types-cjs/helpers/localeFormat.d.ts +30 -8
  90. package/dist/types-cjs/helpers/polymorphic.d.ts +19 -0
  91. package/dist/types-cjs/helpers/stackLayout.d.ts +62 -0
  92. package/dist/types-cjs/helpers/useBulmaClasses.d.ts +8 -2
  93. package/dist/types-cjs/helpers/useFlexboxClasses.d.ts +26 -3
  94. package/dist/types-cjs/helpers/useTreeView.d.ts +12 -6
  95. package/dist/types-cjs/index.d.ts +10 -1
  96. package/dist/types-cjs/layout/Center.d.ts +54 -0
  97. package/dist/types-cjs/layout/Flex.d.ts +92 -0
  98. package/dist/types-cjs/layout/Group.d.ts +86 -0
  99. package/dist/types-cjs/layout/Stack.d.ts +63 -0
  100. package/dist/versions/bestax-no-dark-mode.css +1 -1
  101. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  102. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  103. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  104. package/dist/versions/bestax-no-helpers.css +1 -1
  105. package/dist/versions/bestax-no-helpers.css.map +1 -1
  106. package/dist/versions/bestax-prefixed.css +1 -1
  107. package/dist/versions/bestax-prefixed.css.map +1 -1
  108. package/package.json +1 -1
  109. package/src/scss/elements/_iconbutton.scss +36 -0
  110. package/src/scss/elements/_index.scss +1 -0
  111. package/src/scss/layout/_index.scss +1 -0
  112. package/src/scss/layout/_stack.scss +145 -0
package/dist/index.esm.js CHANGED
@@ -49,6 +49,7 @@ export { Divider } from './esm/elements/Divider.js';
49
49
  export { Emphasis } from './esm/elements/Emphasis.js';
50
50
  export { Figure } from './esm/elements/Figure.js';
51
51
  export { Icon } from './esm/elements/Icon.js';
52
+ export { IconButton } from './esm/elements/IconButton.js';
52
53
  export { IconText } from './esm/elements/IconText.js';
53
54
  export { Image } from './esm/elements/Image.js';
54
55
  export { Kbd, KbdGroup } from './esm/elements/Kbd.js';
@@ -56,6 +57,7 @@ export { Link } from './esm/elements/Link.js';
56
57
  export { ListItem } from './esm/elements/ListItem.js';
57
58
  export { Loader } from './esm/elements/Loader.js';
58
59
  export { Notification, NotificationContainer, notification } from './esm/elements/Notification.js';
60
+ export { NumberFormatter } from './esm/elements/NumberFormatter.js';
59
61
  export { OrderedList } from './esm/elements/OrderedList.js';
60
62
  export { Paragraph } from './esm/elements/Paragraph.js';
61
63
  export { Pre } from './esm/elements/Pre.js';
@@ -124,14 +126,19 @@ export { ClientOnly } from './esm/helpers/ClientOnly.js';
124
126
  export { useIsHydrated } from './esm/helpers/useIsHydrated.js';
125
127
  export { Portal } from './esm/helpers/portal.js';
126
128
  export { LocaleProvider, useLocale } from './esm/helpers/LocaleProvider.js';
129
+ export { useNumberFormat } from './esm/helpers/localeFormat.js';
127
130
  export { useFocusTrap } from './esm/helpers/useFocusTrap.js';
131
+ export { Center } from './esm/layout/Center.js';
128
132
  export { Container } from './esm/layout/Container.js';
133
+ export { Flex } from './esm/layout/Flex.js';
129
134
  export { Footer } from './esm/layout/Footer.js';
135
+ export { Group } from './esm/layout/Group.js';
130
136
  export { Hero, HeroBody, HeroFoot, HeroHead } from './esm/layout/Hero.js';
131
137
  export { Level, LevelItem, LevelLeft, LevelRight } from './esm/layout/Level.js';
132
138
  export { Media, MediaContent, MediaLeft, MediaRight } from './esm/layout/Media.js';
133
139
  export { Section } from './esm/layout/Section.js';
134
140
  export { Splitter, SplitterPane } from './esm/layout/Splitter.js';
141
+ export { Stack } from './esm/layout/Stack.js';
135
142
  export { useColorClasses, useColorStyles } from './esm/helpers/useColorClasses.js';
136
143
  export { useDataTable } from './esm/components/useDataTable.js';
137
144
  export { useFlexboxClasses } from './esm/helpers/useFlexboxClasses.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,9 +2,11 @@ import React from 'react';
2
2
  import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
3
3
  /**
4
4
  * How items are picked: `none`, nothing is; `single`, one item at a time;
5
- * `checkbox`, any number, with a box on every item and mixed parents.
5
+ * `checkbox`, any number, with a box on every item and mixed parents;
6
+ * `checkbox-independent`, any number, with a box on every item that checks
7
+ * that item alone.
6
8
  */
7
- export type TreeViewSelectionMode = 'none' | 'single' | 'checkbox';
9
+ export type TreeViewSelectionMode = 'none' | 'single' | 'checkbox' | 'checkbox-independent';
8
10
  /**
9
11
  * Props for the TreeView component. The helper props, the other attributes
10
12
  * and the `ref` land on the `<ul role="tree">`.
@@ -25,6 +27,9 @@ export interface TreeViewProps extends Omit<React.HTMLAttributes<HTMLUListElemen
25
27
  * `single`: one item, picked with Enter, Space or a click.
26
28
  * `checkbox`: any number, checked with Space or a click. A check reaches
27
29
  * every enabled item under it, and a parent with some of them checked is mixed.
30
+ * `checkbox-independent`: any number, checked with Space or a click, each
31
+ * box for its own item. A check reaches nothing under it, and no parent is
32
+ * mixed (Mantine's and Ant Design's `checkStrictly`).
28
33
  */
29
34
  selectionMode?: TreeViewSelectionMode;
30
35
  /**
@@ -42,18 +47,22 @@ export interface TreeViewProps extends Omit<React.HTMLAttributes<HTMLUListElemen
42
47
  onSelectedChange?: (value: string) => void;
43
48
  /**
44
49
  * The checked items' values when you hold the state. Read with `checkbox`
45
- * only. A value checks its item, and an enabled item also counts as checked
46
- * when any item above it is in the list, so a parent's value stands for its
47
- * whole branch, loaded or not. A disabled item is checked only by its own value.
50
+ * and `checkbox-independent` only. A value checks its item. In `checkbox`,
51
+ * an enabled item also counts as checked when any item above it is in the
52
+ * list, so a parent's value stands for its whole branch, loaded or not, and
53
+ * a disabled item is checked only by its own value. In
54
+ * `checkbox-independent`, a value checks its own item and nothing else.
48
55
  */
49
56
  checked?: string[];
50
- /** The values checked to begin with, when the tree holds its own state. Read with `checkbox` only. */
57
+ /** The values checked to begin with, when the tree holds its own state. Read with `checkbox` and `checkbox-independent` only. */
51
58
  defaultChecked?: string[];
52
59
  /**
53
- * Called after a check or an uncheck with every item that now shows
54
- * checked, parents included, plus any earlier value that matches no item
55
- * the tree knows, left as it was. The order means nothing. Passed back as
56
- * `checked`, the list shows the same boxes.
60
+ * Called after a check or an uncheck. In `checkbox`, with every item that
61
+ * now shows checked, parents included, plus any earlier value that matches
62
+ * no item the tree knows, left as it was, and the order means nothing. In
63
+ * `checkbox-independent`, with the list as it was, the item's value added
64
+ * at the end or every copy of it taken out, and everything else in the
65
+ * same order. Passed back as `checked`, the list shows the same boxes.
57
66
  */
58
67
  onCheckedChange?: (checked: string[]) => void;
59
68
  /**
@@ -103,7 +112,7 @@ export interface TreeViewItemProps extends Omit<React.LiHTMLAttributes<HTMLLIEle
103
112
  icon?: React.ReactNode;
104
113
  /**
105
114
  * `TreeView.Item`s under this one. Render them whenever you have them,
106
- * open or not: the tree hides them while it's closed, and a checkbox tree
115
+ * open or not: the tree hides them while it's closed, and a `checkbox` tree
107
116
  * needs them to know what a check reaches.
108
117
  */
109
118
  children?: React.ReactNode;
@@ -37,5 +37,6 @@ export declare const Buttons: React.FC<ButtonsProps> & {
37
37
  Button: import("../index.js").PolymorphicComponent<import("./Button.js").ButtonOwnProps, "button", never>;
38
38
  LinkButton: import("../index.js").PolymorphicComponent<import("./LinkButton.js").LinkButtonOwnProps, "button", never>;
39
39
  ToggleButton: React.ForwardRefExoticComponent<import("./ToggleButton.js").ToggleButtonProps & React.RefAttributes<HTMLButtonElement>>;
40
+ IconButton: import("../index.js").PolymorphicComponent<import("./IconButton.js").IconButtonOwnProps & import("./IconButton.js").IconButtonName, "button", never>;
40
41
  };
41
42
  export {};
@@ -0,0 +1,110 @@
1
+ import React from 'react';
2
+ import { type ButtonOwnProps } from './Button.js';
3
+ import type { PolymorphicComponent } from '../helpers/polymorphic.js';
4
+ /**
5
+ * The IconButton component's own props: everything `Button` takes, plus the
6
+ * icon.
7
+ */
8
+ export interface IconButtonOwnProps extends ButtonOwnProps {
9
+ /**
10
+ * The glyph. A string is an `Icon` name, drawn from the icon library
11
+ * `ConfigProvider` sets. An `<Icon>` renders as given, so it can carry its
12
+ * own `variant` or `library`. Any other node, such as an SVG or a component
13
+ * from an icon package, goes inside an `Icon`, which gives it the `.icon`
14
+ * wrapper Bulma keeps square. It's decorative: the button's name says what
15
+ * it does. Give the glyph here or as `children`, not both: with both, it
16
+ * draws `icon` and warns in development. With neither, such as an empty
17
+ * string from `cond ? 'trash' : ''`, the button is an empty square, and that
18
+ * warns in development too.
19
+ */
20
+ icon?: React.ReactNode;
21
+ /**
22
+ * The glyph as children, the way Mantine, MUI and Chakra take it: an
23
+ * `<Icon>` renders as given, and any other node, such as an SVG, goes
24
+ * inside an `Icon`, as with `icon`. Left out when `icon` is given, which
25
+ * warns in development. Text warns too, since `aria-label` replaces it as
26
+ * the name: a button with text is a `Button`.
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Makes the button a circle the size of its square. The circle comes from
31
+ * bestax's CSS, in `bestax.css` and its variants, or in `extras.css` next
32
+ * to your own Bulma. Without it, Bulma's `is-rounded` draws a pill a little
33
+ * wider than it is tall.
34
+ */
35
+ isRounded?: boolean;
36
+ }
37
+ /** Names an IconButton by the text of another element. */
38
+ export interface IconButtonLabelledBy {
39
+ /** The id of the element whose text names the button, in place of `aria-label`. */
40
+ 'aria-labelledby': string;
41
+ /**
42
+ * @internal Not with `aria-labelledby`, which already names the button.
43
+ * Declared so the two can't be passed together.
44
+ */
45
+ 'aria-label'?: undefined;
46
+ }
47
+ /** Names an IconButton with `aria-label`, the usual way. */
48
+ export interface IconButtonLabel {
49
+ /**
50
+ * The button's name: what a screen reader announces and what a voice
51
+ * control user says to press it. Required, or `aria-labelledby` in its
52
+ * place, since an icon has no text to name it by. Name the action
53
+ * ("Delete"), not the picture ("Trash"). An empty or blank one warns in
54
+ * development.
55
+ */
56
+ 'aria-label': string;
57
+ /**
58
+ * @internal Not with `aria-label`. Declared so the two can't be passed
59
+ * together.
60
+ */
61
+ 'aria-labelledby'?: undefined;
62
+ }
63
+ /**
64
+ * How an IconButton gets its name: `aria-label`, or `aria-labelledby` in its
65
+ * place. `IconButtonLabel` comes last because TypeScript names the union's
66
+ * last member when neither is given: under "No overload matches this call",
67
+ * each overload's error ends "Property ''aria-label'' is missing … but
68
+ * required in type 'IconButtonLabel'".
69
+ */
70
+ export type IconButtonName = IconButtonLabelledBy | IconButtonLabel;
71
+ /**
72
+ * Props for the IconButton component. The DOM attributes and the `ref` follow
73
+ * `as`, exactly as they do on `Button`.
74
+ *
75
+ * @extraProp {string} [type='button'] - On a `<button>`, `'button'`, `'submit'` or `'reset'`, and `'button'` unless you pass one of the other two, so it never submits a form by accident. With another `as`, whatever that element or component takes, passed through as given, such as an `<a>`'s MIME type.
76
+ * @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the element `as` renders, typed from `as`.
77
+ */
78
+ export type IconButtonProps<T extends React.ElementType = 'button'> = IconButtonOwnProps & IconButtonName & Omit<React.ComponentPropsWithoutRef<T>, keyof IconButtonOwnProps | 'aria-label' | 'aria-labelledby' | 'as'> & {
79
+ /**
80
+ * Render as a `<button>`, an `<a>`, or a custom component such as a
81
+ * router `Link`, as on `Button`.
82
+ * @defaultValue 'button'
83
+ */
84
+ as?: T;
85
+ };
86
+ /**
87
+ * The `IconButton` component renders a button that shows only an icon, and requires a name for it.
88
+ *
89
+ * It renders through `Button`, so it takes everything `Button` takes, and
90
+ * adds the icon and a name the types require: `aria-label`, or
91
+ * `aria-labelledby` in its place. Bulma keeps a button whose only child is an
92
+ * `.icon` square at every size, and `isRounded` makes it a circle. It has no
93
+ * tooltip of its own: wrap it in `Tooltip` for a description.
94
+ *
95
+ * @function
96
+ * @param {IconButtonProps} props - Props for the IconButton component.
97
+ * @param {React.Ref} ref - Forwarded ref to the element `as` renders.
98
+ * @returns {JSX.Element} The rendered button, anchor, or custom element.
99
+ * @see {@link https://bulma.io/documentation/elements/button/ | Bulma Button documentation}
100
+ *
101
+ * @example
102
+ * <IconButton icon="trash" aria-label="Delete" color="danger" />
103
+ *
104
+ * @example
105
+ * <IconButton aria-label="Settings">
106
+ * <Icon name="cog" />
107
+ * </IconButton>
108
+ */
109
+ export declare const IconButton: PolymorphicComponent<IconButtonOwnProps & IconButtonName, "button">;
110
+ export default IconButton;
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ /**
4
+ * Props for the NumberFormatter component. The helper props, the other
5
+ * attributes and the `ref` land on the `<data>`.
6
+ *
7
+ * @extraProp {React.Ref<HTMLDataElement>} [ref] - Ref forwarded to the `<data>`.
8
+ */
9
+ export interface NumberFormatterProps extends Omit<React.DataHTMLAttributes<HTMLDataElement>, 'value' | 'color' | 'children'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
10
+ /** Additional CSS classes to apply. */
11
+ className?: string;
12
+ /**
13
+ * The number. The text is what `Intl.NumberFormat` writes for it, `NaN`
14
+ * and `Infinity` included. The `<data>` element's `value` attribute holds
15
+ * it as `String()` writes it, except that `-0` keeps its sign, so
16
+ * `Number()` reads it back: `1234.5`, `1e+21` for a very large one and
17
+ * `1e-7` for a very small one, `NaN`, `Infinity` and `-0`.
18
+ */
19
+ value: number;
20
+ /**
21
+ * `Intl.NumberFormat` options: a currency, a percentage, a unit, compact
22
+ * notation, the fraction digits, the sign. Options `Intl` refuses, such as
23
+ * `style: 'currency'` with no `currency`, throw its error.
24
+ */
25
+ format?: Intl.NumberFormatOptions;
26
+ /**
27
+ * BCP 47 locale tag. Unset, it's the `locale` of a `LocaleProvider` around
28
+ * it, and with neither, the runtime's own. On a server render that's the
29
+ * server's, so give it a locale, here or through a `LocaleProvider`, where
30
+ * the server's and the browser's can differ. A tag `Intl` refuses, such as
31
+ * `"en_US"`, is ignored, with a warning in development, as
32
+ * `LocaleProvider` ignores one.
33
+ */
34
+ locale?: string;
35
+ /** Text color helper. */
36
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
37
+ /** Background color helper. */
38
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
39
+ }
40
+ /**
41
+ * The `NumberFormatter` component writes a number the way a locale writes it, such as a price, a percentage or a count, in a `<data>` element that keeps the number itself in its `value`.
42
+ *
43
+ * It formats with `Intl.NumberFormat`, in its own `locale`, else the
44
+ * `LocaleProvider`'s around it, else the runtime's, with `format` as the
45
+ * options. The `<data>` has no role and no class of its own, so a screen
46
+ * reader reads the formatted text and it takes the look of the text around
47
+ * it. For text outside JSX, such as an `aria-label`, `useNumberFormat`
48
+ * gives the same formatting as a function.
49
+ *
50
+ * @function
51
+ * @param {NumberFormatterProps} props - Props for the NumberFormatter component.
52
+ * @param {React.Ref<HTMLDataElement>} ref - Forwarded ref to the `<data>`.
53
+ * @returns {JSX.Element} The rendered number.
54
+ *
55
+ * @example
56
+ * <NumberFormatter
57
+ * value={8456.4}
58
+ * format={{ style: 'currency', currency: 'USD' }}
59
+ * />
60
+ */
61
+ export declare const NumberFormatter: React.ForwardRefExoticComponent<NumberFormatterProps & React.RefAttributes<HTMLDataElement>>;
62
+ export default NumberFormatter;
@@ -36,6 +36,13 @@ export interface LocaleProviderProps extends Omit<React.HTMLAttributes<HTMLDivEl
36
36
  /** The part of the app it covers. */
37
37
  children?: React.ReactNode;
38
38
  }
39
+ /**
40
+ * INTERNAL, deliberately not exported from `src/index.ts`. A tag in
41
+ * canonical form, or `undefined` for an empty or missing one and for one
42
+ * `Intl` refuses, which `refused` reports: by default the provider's own
43
+ * development warning, once per tag.
44
+ */
45
+ export declare function validLocale(tag: string | undefined, refused?: (tag: string) => void): string | undefined;
39
46
  /**
40
47
  * 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
48
  *
@@ -0,0 +1,2 @@
1
+ import type { ContainerBreakpoint } from '../layout/Container.js';
2
+ export declare const CONTAINER_BREAKPOINTS: readonly ContainerBreakpoint[];
@@ -1,17 +1,39 @@
1
1
  /** Formats a number for display, with `Intl.NumberFormat` options. */
2
- export type NumberFormatter = (value: number, options?: Intl.NumberFormatOptions) => string;
2
+ export type NumberFormatFunction = (value: number, options?: Intl.NumberFormatOptions) => string;
3
3
  /** Whether `text` contains `query`, as the locale compares letters. */
4
4
  export type TextMatcher = (text: string, query: string) => boolean;
5
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.
6
+ * A function that writes numbers for display in a locale: `locale` when given, else the `LocaleProvider`'s around the component, else the runtime's.
7
+ *
8
+ * Formatters are kept per locale and set of options, since building one is
9
+ * the expensive part, and shared, so many numbers written the same way build
10
+ * one. The function is the same from one render to the next for the same
11
+ * locale, so it's safe in a dependency array. Use it for text outside JSX,
12
+ * such as an `aria-label`, a `placeholder` or a chart's axis; in JSX,
13
+ * `NumberFormatter` also marks the number up. On a server render the
14
+ * runtime's locale is the server's, so give it a locale, here or through a
15
+ * `LocaleProvider`, where the server's and the browser's can differ. A tag
16
+ * `Intl` refuses is ignored, with a warning in development, as
17
+ * `LocaleProvider` ignores one. Options `Intl` refuses throw its error when
18
+ * the function is called.
19
+ *
20
+ * @function
21
+ * @param locale - A BCP 47 locale tag, which wins over the provider's.
22
+ * @returns {NumberFormatFunction} Writes `value` with `Intl.NumberFormat` options.
10
23
  *
11
- * @param own - The component's own locale, such as a picker's `locale`,
12
- * which wins inside a provider.
24
+ * @example
25
+ * const format = useNumberFormat();
26
+ * const placeholder = format(1500, { style: 'currency', currency: 'EUR' });
27
+ */
28
+ export declare function useNumberFormat(locale?: string): NumberFormatFunction;
29
+ /**
30
+ * INTERNAL, deliberately not exported from `src/index.ts`. Number formatting
31
+ * for a component that shows a number in passing, as `useNumberFormat`
32
+ * writes it in the `LocaleProvider`'s locale, or `null` outside a provider
33
+ * and inside one that gives no locale, as a provider with only a `dir`
34
+ * doesn't, where the component keeps the formatting it has always had.
13
35
  */
14
- export declare function useNumberFormat(own?: string): NumberFormatter | null;
36
+ export declare function useScopedNumberFormat(): NumberFormatFunction | null;
15
37
  /**
16
38
  * A matcher for filtering a list by what was typed, in the locale of the
17
39
  * `LocaleProvider` around the component, or `null` outside one that gives a
@@ -170,3 +170,22 @@ export interface ConstrainedPolymorphicComponentWithoutRef<Own, Allowed extends
170
170
  (props: PolymorphicProps<Default, Own, Forwarded>): React.ReactElement | null;
171
171
  displayName?: string;
172
172
  }
173
+ /**
174
+ * `ConstrainedPolymorphicComponentWithoutRef` with a forwarded ref: the props
175
+ * and the ref both follow `as`, and `as` is one of `Allowed`.
176
+ *
177
+ * For a component whose `as` is a closed set of tags that don't share one
178
+ * prop surface. `Stack` renders a `<div>`, a `<form>`, an `<ol>` or a
179
+ * `<fieldset>` among others, which take different attributes (`action`,
180
+ * `start`, `disabled`) and give the ref a different element, so pinning them
181
+ * all to `HTMLAttributes<HTMLElement>` would refuse attributes that work.
182
+ */
183
+ export interface ConstrainedPolymorphicComponent<Own, Allowed extends React.ElementType, Default extends Allowed, Forwarded extends keyof Own = never> {
184
+ <T extends Allowed = Default>(props: PolymorphicProps<T, Own, Forwarded> & {
185
+ ref?: PolymorphicRef<T>;
186
+ }): React.ReactElement | null;
187
+ (props: PolymorphicProps<Default, Own, Forwarded> & {
188
+ ref?: PolymorphicRef<Default>;
189
+ }): React.ReactElement | null;
190
+ displayName?: string;
191
+ }
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { type BulmaClassesProps, type validColors, type validFlexDirections } from './useBulmaClasses.js';
3
+ /**
4
+ * The elements Stack, Group, Center and Flex can render as: Container's
5
+ * landmarks and sections, a list, a form or a fieldset.
6
+ */
7
+ export type LayoutElement = 'div' | 'main' | 'section' | 'article' | 'aside' | 'header' | 'footer' | 'nav' | 'ul' | 'ol' | 'form' | 'fieldset';
8
+ /**
9
+ * What Stack, Group, Center and Flex take in common. The helper props, the
10
+ * other attributes and the `ref` land on the root.
11
+ *
12
+ * @flexContainer The root is a flex container by its own stylesheet, so the
13
+ * flex container helper props apply with no `display` prop. The API docs
14
+ * extractor reads this tag off a component's props type or its bases, and
15
+ * the ESLint plugin's `no-inert-flex-props` takes its flex containers from it.
16
+ */
17
+ export interface LayoutOwnProps extends Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'flexDirection'> {
18
+ /**
19
+ * Not accepted. `color` here would be the deprecated presentational HTML
20
+ * attribute. Use `textColor`.
21
+ * @internal
22
+ */
23
+ color?: never;
24
+ /**
25
+ * Not accepted under this name. Use `bgColor`.
26
+ * @internal
27
+ */
28
+ backgroundColor?: never;
29
+ /** Additional CSS classes. */
30
+ className?: string;
31
+ /**
32
+ * What it lays out. The top and bottom margins Bulma gives them are
33
+ * zeroed, so `gap` is the only space between them, and a spacing helper
34
+ * such as `mt="2"` still adds to it. A `Columns` child keeps its own top and side
35
+ * margins, and takes at the bottom the one Bulma gives the last Columns in
36
+ * a container, the column gap pulled back in (none when gapless), so its
37
+ * columns line up. A `Pagination` child keeps its negative margins too,
38
+ * so its links line up.
39
+ */
40
+ children?: React.ReactNode;
41
+ /** Text color helper. */
42
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
43
+ /** Background color helper. */
44
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
45
+ }
46
+ /** The props `StackLayout` reads, from whichever of the four renders it. */
47
+ export interface StackLayoutProps extends LayoutOwnProps, Omit<React.HTMLAttributes<HTMLElement>, 'color'> {
48
+ /** The element to render. */
49
+ as?: LayoutElement;
50
+ /** Flex's direction. The other three pass `undefined`, so they never reorder. */
51
+ flexDirection?: (typeof validFlexDirections)[number];
52
+ /** The modifier classes beside `stack`, as `usePrefixedClassNames` takes them. */
53
+ modifiers?: Record<string, boolean | undefined>;
54
+ }
55
+ /**
56
+ * The `.stack` element behind Stack, Group, Center and Flex.
57
+ *
58
+ * With `as="ul"` or `as="ol"` it renders `role="list"`, which Safari needs:
59
+ * WebKit stops exposing a list as one once its markers are hidden, and
60
+ * Bulma's reset hides a `<ul>`'s. Menu.List restates it for the same reason.
61
+ */
62
+ export declare const StackLayout: React.ForwardRefExoticComponent<StackLayoutProps & React.RefAttributes<HTMLElement>>;
@@ -4,7 +4,7 @@ import { BulmaColorProps, BulmaColorPropsWithScheme } from './useColorClasses.js
4
4
  import { BulmaSpacingProps } from './useSpacingClasses.js';
5
5
  import { BulmaTypographyProps } from './useTypographyClasses.js';
6
6
  import { BulmaVisibilityProps } from './useVisibilityClasses.js';
7
- import { BulmaFlexboxProps } from './useFlexboxClasses.js';
7
+ import { BulmaFlexboxProps, type UseFlexboxClassesOptions } from './useFlexboxClasses.js';
8
8
  import { BulmaOtherProps } from './useOtherClasses.js';
9
9
  /**
10
10
  * Props for applying Bulma helper classes to components.
@@ -31,8 +31,14 @@ export type BulmaClassesPropsWithScheme = Omit<BulmaClassesProps, keyof BulmaCol
31
31
  * `background-color: var(--bulma-scheme-*)` style (`undefined` for all other
32
32
  * inputs). Merge it with a user `style` prop via `mergeBulmaStyles`.
33
33
  *
34
+ * The flex container props (`flexDirection`, `flexWrap`, `justifyContent`,
35
+ * `alignContent`, `alignItems`) emit a class only on a flex container: when a
36
+ * `display` prop is `flex` or `inline-flex`, or when `options.flexContainer`
37
+ * says the element's own stylesheet makes it one.
38
+ *
34
39
  * @function useBulmaClasses
35
40
  * @param props - Combination of BulmaClassesPropsWithScheme and additional props.
41
+ * @param options - Passed to `useFlexboxClasses`: whether the element is a flex container without a display prop.
36
42
  * @returns An object containing the Bulma helper classes, optional helper
37
43
  * styles, and unhandled props.
38
44
  * @example
@@ -45,7 +51,7 @@ export type BulmaClassesPropsWithScheme = Omit<BulmaClassesProps, keyof BulmaCol
45
51
  * // bulmaHelperStyles: { backgroundColor: 'var(--bulma-scheme-main-bis)' }
46
52
  * // rest: { className: 'custom-class' }
47
53
  */
48
- export declare const useBulmaClasses: <T extends object>(props: BulmaClassesPropsWithScheme & T) => {
54
+ export declare const useBulmaClasses: <T extends object>(props: BulmaClassesPropsWithScheme & T, options?: UseFlexboxClassesOptions) => {
49
55
  bulmaHelperClasses: string;
50
56
  bulmaHelperStyles?: CSSProperties;
51
57
  rest: Omit<T, keyof BulmaClassesProps>;
@@ -22,11 +22,25 @@ export interface BulmaFlexboxProps extends BulmaDisplayProps {
22
22
  /** Flex shrink value (e.g., '0', '1', '2', '3', '4', '5'). */
23
23
  flexShrink?: (typeof validFlexGrowShrink)[number];
24
24
  }
25
+ /**
26
+ * Options for `useFlexboxClasses`, which `useBulmaClasses` passes through.
27
+ */
28
+ export interface UseFlexboxClassesOptions {
29
+ /**
30
+ * Whether the element is a flex container by its own CSS, as `Stack` and
31
+ * `Group` are, so the container helpers apply with no `display` prop. It
32
+ * adds no display class: the element's own stylesheet has to make it a flex
33
+ * container.
34
+ * @defaultValue false
35
+ */
36
+ flexContainer?: boolean;
37
+ }
25
38
  /**
26
39
  * A hook that generates Bulma flexbox helper classes. Flex container helpers
27
40
  * (direction, wrap, justify/align content, align items) are only emitted when
28
- * one of the display props indicates a flex display; flex item helpers
29
- * (align self, grow, shrink) are always emitted.
41
+ * one of the display props indicates a flex display, or when `options` says
42
+ * the element is a flex container by its own CSS; flex item helpers (align
43
+ * self, grow, shrink) are always emitted.
30
44
  *
31
45
  * Note: this hook reads the display props purely as a gate and never emits
32
46
  * display classes — `is-flex` and friends come from useVisibilityClasses (or
@@ -34,6 +48,7 @@ export interface BulmaFlexboxProps extends BulmaDisplayProps {
34
48
  *
35
49
  * @function useFlexboxClasses
36
50
  * @param props - Flexbox-related Bulma helper props.
51
+ * @param options - Whether the element is a flex container without a display prop.
37
52
  * @returns A space-separated string of flexbox helper classes.
38
53
  * @example
39
54
  * const flexboxClasses = useFlexboxClasses({
@@ -42,5 +57,13 @@ export interface BulmaFlexboxProps extends BulmaDisplayProps {
42
57
  * });
43
58
  * // flexboxClasses: 'is-justify-content-center'
44
59
  * // ('is-flex' itself comes from useVisibilityClasses/useBulmaClasses)
60
+ *
61
+ * @example
62
+ * // An element whose own stylesheet makes it a flex container
63
+ * const flexboxClasses = useFlexboxClasses(
64
+ * { alignItems: 'center' },
65
+ * { flexContainer: true }
66
+ * );
67
+ * // flexboxClasses: 'is-align-items-center'
45
68
  */
46
- export declare const useFlexboxClasses: (props: BulmaFlexboxProps) => string;
69
+ export declare const useFlexboxClasses: (props: BulmaFlexboxProps, options?: UseFlexboxClassesOptions) => string;
@@ -30,7 +30,8 @@ export interface TreeViewPosition {
30
30
  }
31
31
  /**
32
32
  * What an item shows of the selection: `selected` in a `single` tree,
33
- * `checked` in a `checkbox` tree, and neither with `none`.
33
+ * `checked` in a `checkbox` or `checkbox-independent` tree, and neither with
34
+ * `none`.
34
35
  */
35
36
  export interface TreeViewItemState {
36
37
  selected?: boolean;
@@ -55,9 +56,12 @@ export interface TreeViewEngine {
55
56
  treeRef: React.MutableRefObject<HTMLUListElement | null>;
56
57
  /**
57
58
  * Whether a closed item still renders its children, drawing nothing, so a
58
- * check knows everything under it. Only a checkbox tree needs to.
59
+ * check knows everything under it. Only a `checkbox` tree needs to: a check
60
+ * in a `checkbox-independent` tree reaches nothing under it.
59
61
  */
60
62
  rendersClosed: boolean;
63
+ /** Whether any number of items can be checked, in either checkbox mode. */
64
+ multiselectable: boolean;
61
65
  /** The item that holds `tabIndex={0}`. */
62
66
  tabStop: string | null;
63
67
  isOpen: (value: string) => boolean;
@@ -97,10 +101,12 @@ export interface TreeViewEngine {
97
101
  * browser (#1171), read off the page once the tree has mounted.
98
102
  *
99
103
  * Every item registers its value, its parent and whether it's disabled from
100
- * a layout effect. In a checkbox tree a closed item's children still render
101
- * and register while drawing nothing, so the registry knows every item and a
102
- * check reaches all of them. The keys read the items on the page, in
103
- * document order, each time they need them.
104
+ * a layout effect. In a `checkbox` tree a closed item's children still
105
+ * render and register while drawing nothing, so the registry knows every item
106
+ * and a check reaches all of them. A `checkbox-independent` tree reads each
107
+ * box off the checked list alone, so a check adds or takes out its own value
108
+ * and nothing else. The keys read the items on the page, in document order,
109
+ * each time they need them.
104
110
  *
105
111
  * @function useTreeView
106
112
  * @param options - The TreeView's props.
@@ -48,6 +48,7 @@ export * from './elements/Divider.js';
48
48
  export * from './elements/Emphasis.js';
49
49
  export * from './elements/Figure.js';
50
50
  export * from './elements/Icon.js';
51
+ export * from './elements/IconButton.js';
51
52
  export * from './elements/IconText.js';
52
53
  export * from './elements/Image.js';
53
54
  export * from './elements/Kbd.js';
@@ -55,6 +56,7 @@ export * from './elements/Link.js';
55
56
  export * from './elements/ListItem.js';
56
57
  export * from './elements/Loader.js';
57
58
  export * from './elements/Notification.js';
59
+ export * from './elements/NumberFormatter.js';
58
60
  export * from './elements/OrderedList.js';
59
61
  export * from './elements/Paragraph.js';
60
62
  export * from './elements/Pre.js';
@@ -132,7 +134,7 @@ export type { FormFieldProps } from './form/fieldProps.js';
132
134
  export * from './grid/Cell.js';
133
135
  export * from './grid/Grid.js';
134
136
  export * from './helpers/classNames.js';
135
- export type { ConstrainedPolymorphicComponentWithoutRef, PolymorphicComponent, PolymorphicComponentWithoutRef, PolymorphicProps, PolymorphicRef, } from './helpers/polymorphic.js';
137
+ export type { ConstrainedPolymorphicComponent, ConstrainedPolymorphicComponentWithoutRef, PolymorphicComponent, PolymorphicComponentWithoutRef, PolymorphicProps, PolymorphicRef, } from './helpers/polymorphic.js';
136
138
  export * from './helpers/mergeBulmaStyles.js';
137
139
  export * from './helpers/useBulmaClasses.js';
138
140
  export * from './helpers/Theme.js';
@@ -144,12 +146,19 @@ export { Portal } from './helpers/portal.js';
144
146
  export type { PortalProps } from './helpers/portal.js';
145
147
  export { LocaleProvider, useLocale } from './helpers/LocaleProvider.js';
146
148
  export type { LocaleContextValue, LocaleProviderProps, TextDirection, } from './helpers/LocaleProvider.js';
149
+ export { useNumberFormat } from './helpers/localeFormat.js';
150
+ export type { NumberFormatFunction } from './helpers/localeFormat.js';
147
151
  export { useFocusTrap } from './helpers/useFocusTrap.js';
148
152
  export type { UseFocusTrapOptions } from './helpers/useFocusTrap.js';
153
+ export * from './layout/Center.js';
149
154
  export * from './layout/Container.js';
155
+ export * from './layout/Flex.js';
150
156
  export * from './layout/Footer.js';
157
+ export * from './layout/Group.js';
151
158
  export * from './layout/Hero.js';
152
159
  export * from './layout/Level.js';
153
160
  export * from './layout/Media.js';
154
161
  export * from './layout/Section.js';
155
162
  export * from './layout/Splitter.js';
163
+ export * from './layout/Stack.js';
164
+ export type { LayoutElement } from './helpers/stackLayout.js';