@allxsmith/bestax-bulma 5.58.0 → 5.60.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 (82) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Affix.js +46 -0
  4. package/dist/esm/components/Affix.js.map +1 -0
  5. package/dist/esm/components/Dialog.js +2 -6
  6. package/dist/esm/components/Dialog.js.map +1 -1
  7. package/dist/esm/components/Modal.js +12 -24
  8. package/dist/esm/components/Modal.js.map +1 -1
  9. package/dist/esm/elements/Buttons.js +2 -0
  10. package/dist/esm/elements/Buttons.js.map +1 -1
  11. package/dist/esm/elements/IconButton.js +114 -0
  12. package/dist/esm/elements/IconButton.js.map +1 -0
  13. package/dist/esm/helpers/containerBreakpoints.js +14 -0
  14. package/dist/esm/helpers/containerBreakpoints.js.map +1 -0
  15. package/dist/esm/helpers/polymorphic.js.map +1 -1
  16. package/dist/esm/helpers/portal.js +28 -1
  17. package/dist/esm/helpers/portal.js.map +1 -1
  18. package/dist/esm/helpers/stackLayout.js +30 -0
  19. package/dist/esm/helpers/stackLayout.js.map +1 -0
  20. package/dist/esm/helpers/useBulmaClasses.js +8 -2
  21. package/dist/esm/helpers/useBulmaClasses.js.map +1 -1
  22. package/dist/esm/helpers/useFlexboxClasses.js +17 -4
  23. package/dist/esm/helpers/useFlexboxClasses.js.map +1 -1
  24. package/dist/esm/layout/Center.js +33 -0
  25. package/dist/esm/layout/Center.js.map +1 -0
  26. package/dist/esm/layout/Container.js +2 -6
  27. package/dist/esm/layout/Container.js.map +1 -1
  28. package/dist/esm/layout/Flex.js +34 -0
  29. package/dist/esm/layout/Flex.js.map +1 -0
  30. package/dist/esm/layout/Group.js +43 -0
  31. package/dist/esm/layout/Group.js.map +1 -0
  32. package/dist/esm/layout/Stack.js +34 -0
  33. package/dist/esm/layout/Stack.js.map +1 -0
  34. package/dist/extras.css +1 -1
  35. package/dist/extras.css.map +1 -1
  36. package/dist/index.cjs +476 -160
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.esm.js +6 -0
  39. package/dist/index.esm.js.map +1 -1
  40. package/dist/types/components/Affix.d.ts +67 -0
  41. package/dist/types/elements/Buttons.d.ts +1 -0
  42. package/dist/types/elements/IconButton.d.ts +110 -0
  43. package/dist/types/helpers/containerBreakpoints.d.ts +2 -0
  44. package/dist/types/helpers/polymorphic.d.ts +19 -0
  45. package/dist/types/helpers/portal.d.ts +42 -0
  46. package/dist/types/helpers/stackLayout.d.ts +62 -0
  47. package/dist/types/helpers/useBulmaClasses.d.ts +8 -2
  48. package/dist/types/helpers/useFlexboxClasses.d.ts +26 -3
  49. package/dist/types/index.d.ts +8 -1
  50. package/dist/types/layout/Center.d.ts +54 -0
  51. package/dist/types/layout/Flex.d.ts +92 -0
  52. package/dist/types/layout/Group.d.ts +86 -0
  53. package/dist/types/layout/Stack.d.ts +63 -0
  54. package/dist/types-cjs/components/Affix.d.ts +67 -0
  55. package/dist/types-cjs/elements/Buttons.d.ts +1 -0
  56. package/dist/types-cjs/elements/IconButton.d.ts +110 -0
  57. package/dist/types-cjs/helpers/containerBreakpoints.d.ts +2 -0
  58. package/dist/types-cjs/helpers/polymorphic.d.ts +19 -0
  59. package/dist/types-cjs/helpers/portal.d.ts +42 -0
  60. package/dist/types-cjs/helpers/stackLayout.d.ts +62 -0
  61. package/dist/types-cjs/helpers/useBulmaClasses.d.ts +8 -2
  62. package/dist/types-cjs/helpers/useFlexboxClasses.d.ts +26 -3
  63. package/dist/types-cjs/index.d.ts +8 -1
  64. package/dist/types-cjs/layout/Center.d.ts +54 -0
  65. package/dist/types-cjs/layout/Flex.d.ts +92 -0
  66. package/dist/types-cjs/layout/Group.d.ts +86 -0
  67. package/dist/types-cjs/layout/Stack.d.ts +63 -0
  68. package/dist/versions/bestax-no-dark-mode.css +1 -1
  69. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  70. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  71. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  72. package/dist/versions/bestax-no-helpers.css +1 -1
  73. package/dist/versions/bestax-no-helpers.css.map +1 -1
  74. package/dist/versions/bestax-prefixed.css +1 -1
  75. package/dist/versions/bestax-prefixed.css.map +1 -1
  76. package/package.json +1 -1
  77. package/src/scss/components/_affix.scss +74 -0
  78. package/src/scss/components/_index.scss +1 -0
  79. package/src/scss/elements/_iconbutton.scss +36 -0
  80. package/src/scss/elements/_index.scss +1 -0
  81. package/src/scss/layout/_index.scss +1 -0
  82. package/src/scss/layout/_stack.scss +145 -0
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import type { ConstrainedPolymorphicComponent } from '../helpers/polymorphic.js';
3
+ import { type LayoutElement, type LayoutOwnProps } from '../helpers/stackLayout.js';
4
+ import type { BulmaGapStep, validAlignItems, validFlexWraps, validJustifyContents } from '../helpers/useBulmaClasses.js';
5
+ import type { ContainerBreakpoint } from './Container.js';
6
+ /**
7
+ * The Group component's own props, beside the attributes of the element `as`
8
+ * renders.
9
+ */
10
+ export interface GroupOwnProps extends LayoutOwnProps {
11
+ /**
12
+ * Space between children, a step of Bulma's gap scale. Unset, it's
13
+ * `--bulma-stack-horizontal-gap`, half of Bulma's block spacing. Needs
14
+ * Bulma's helper classes: under `bestax-no-helpers.css` the default stays.
15
+ */
16
+ gap?: BulmaGapStep;
17
+ /**
18
+ * How each child sits across the row. While `breakpoint` stacks them, it's
19
+ * where each sits across the column. Needs Bulma's helper classes: under
20
+ * `bestax-no-helpers.css` the default stays.
21
+ * @defaultValue 'center'
22
+ */
23
+ alignItems?: (typeof validAlignItems)[number];
24
+ /**
25
+ * Where the children sit along the row: `'space-between'` pushes the ends
26
+ * apart. Needs Bulma's helper classes: under `bestax-no-helpers.css` the
27
+ * default stays.
28
+ */
29
+ justifyContent?: (typeof validJustifyContents)[number];
30
+ /**
31
+ * Whether children move to a new row when they don't fit. Needs Bulma's
32
+ * helper classes: under `bestax-no-helpers.css` the default stays.
33
+ * @defaultValue 'wrap'
34
+ */
35
+ flexWrap?: (typeof validFlexWraps)[number];
36
+ /**
37
+ * The children share the row equally, and fill the column while
38
+ * `breakpoint` stacks them (Bulma's `is-fullwidth`).
39
+ */
40
+ isFullwidth?: boolean;
41
+ /**
42
+ * Stacks the children below this Bulma breakpoint and sets them in a row
43
+ * from it up, the breakpoints Container's `breakpoint` takes. Unset, a row
44
+ * at every width. It's the job Columns and Level do with booleans:
45
+ * `'tablet'` is where they turn into a row by default, `'desktop'` is
46
+ * Columns' `isDesktop`, and leaving it unset is their `isMobile`.
47
+ */
48
+ breakpoint?: ContainerBreakpoint;
49
+ }
50
+ /**
51
+ * Props for the Group component. The attributes and the `ref` follow `as`, so
52
+ * `as="form"` takes `action` and `as="fieldset"` takes `disabled`.
53
+ *
54
+ * @extraProp {PolymorphicRef<LayoutElement>} [ref] - Ref forwarded to the element `as` renders.
55
+ */
56
+ export type GroupProps<T extends LayoutElement = LayoutElement> = GroupOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof GroupOwnProps | 'as'> & {
57
+ /**
58
+ * The element to render. With `ul` or `ol`, give it `li` children: it
59
+ * restates `role="list"`, which Bulma's list reset takes away in Safari.
60
+ * @defaultValue 'div'
61
+ */
62
+ as?: T;
63
+ };
64
+ /**
65
+ * The `Group` component lays its children out in a row that wraps, centered on each other, with half of Bulma's block spacing between them.
66
+ *
67
+ * Use it for a row of buttons, tags or avatars beside some text, or a toolbar
68
+ * with `justifyContent="space-between"` pushing its ends apart. The children's
69
+ * own block margins are zeroed, so the gap is the only space. With
70
+ * `breakpoint`, it's a column on narrow screens and a row from that
71
+ * breakpoint up. For controls joined into one, with no gap and shared
72
+ * borders, use `hasAddons` on Field or Buttons instead.
73
+ *
74
+ * @function
75
+ * @param {GroupProps} props - Props for the Group component.
76
+ * @param {React.Ref} ref - Forwarded ref to the element `as` renders.
77
+ * @returns {JSX.Element} The rendered group.
78
+ *
79
+ * @example
80
+ * <Group justifyContent="space-between">
81
+ * <Title as="h2" size="4">Invoices</Title>
82
+ * <Button color="primary">New invoice</Button>
83
+ * </Group>
84
+ */
85
+ export declare const Group: ConstrainedPolymorphicComponent<GroupOwnProps, LayoutElement, "div">;
86
+ export default Group;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import type { ConstrainedPolymorphicComponent } from '../helpers/polymorphic.js';
3
+ import { type LayoutElement, type LayoutOwnProps } from '../helpers/stackLayout.js';
4
+ import type { BulmaGapStep, validAlignItems, validJustifyContents } from '../helpers/useBulmaClasses.js';
5
+ /**
6
+ * The Stack component's own props, beside the attributes of the element `as`
7
+ * renders.
8
+ */
9
+ export interface StackOwnProps extends LayoutOwnProps {
10
+ /**
11
+ * Space between children, a step of Bulma's gap scale (`'2'` is 1rem). Unset,
12
+ * it's `--bulma-stack-gap`, Bulma's block spacing. Needs Bulma's helper
13
+ * classes: under `bestax-no-helpers.css` the default stays.
14
+ */
15
+ gap?: BulmaGapStep;
16
+ /**
17
+ * How each child sits across the column. `'stretch'` makes each as wide as
18
+ * the Stack. Needs Bulma's helper classes: under `bestax-no-helpers.css` the
19
+ * default stays.
20
+ * @defaultValue 'stretch'
21
+ */
22
+ alignItems?: (typeof validAlignItems)[number];
23
+ /**
24
+ * Where the children sit down the column, when it's taller than they are.
25
+ * Needs Bulma's helper classes: under `bestax-no-helpers.css` the default
26
+ * stays.
27
+ */
28
+ justifyContent?: (typeof validJustifyContents)[number];
29
+ }
30
+ /**
31
+ * Props for the Stack component. The attributes and the `ref` follow `as`, so
32
+ * `as="form"` takes `action` and `as="fieldset"` takes `disabled`.
33
+ *
34
+ * @extraProp {PolymorphicRef<LayoutElement>} [ref] - Ref forwarded to the element `as` renders.
35
+ */
36
+ export type StackProps<T extends LayoutElement = LayoutElement> = StackOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof StackOwnProps | 'as'> & {
37
+ /**
38
+ * The element to render. With `ul` or `ol`, give it `li` children: it
39
+ * restates `role="list"`, which Bulma's list reset takes away in Safari.
40
+ * @defaultValue 'div'
41
+ */
42
+ as?: T;
43
+ };
44
+ /**
45
+ * The `Stack` component lays its children out in a column, with Bulma's block spacing between them and the margins Bulma gives them zeroed.
46
+ *
47
+ * A Stack of Boxes, Cards or Notifications looks like Bulma's own stacked
48
+ * blocks, spaced by the gap alone, so there are no margins to undo. A `gap`
49
+ * step replaces the default spacing. It's always a column, top to bottom.
50
+ *
51
+ * @function
52
+ * @param {StackProps} props - Props for the Stack component.
53
+ * @param {React.Ref} ref - Forwarded ref to the element `as` renders.
54
+ * @returns {JSX.Element} The rendered stack.
55
+ *
56
+ * @example
57
+ * <Stack>
58
+ * <Notification color="info">Your changes are saved.</Notification>
59
+ * <Box>…</Box>
60
+ * </Stack>
61
+ */
62
+ export declare const Stack: ConstrainedPolymorphicComponent<StackOwnProps, LayoutElement, "div">;
63
+ export default Stack;
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
3
+ import type { BadgePosition } from './Badge.js';
4
+ /** A corner of the viewport: the same four values as `BadgePosition`. */
5
+ export type AffixPosition = BadgePosition;
6
+ /**
7
+ * Props for the Affix component. The helper props, the other attributes and
8
+ * the `ref` land on its `<div>`.
9
+ *
10
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the `<div>`, wherever it renders.
11
+ */
12
+ export interface AffixProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
13
+ /** Additional CSS classes to apply. */
14
+ className?: string;
15
+ /** What stays in the corner. */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * The corner of the viewport it's fixed to. Physical, as Badge's and
19
+ * Toast's are: `'bottom-right'` stays on the right in right-to-left text.
20
+ * Its distance from the edges is `--bulma-affix-offset-vertical` and
21
+ * `--bulma-affix-offset-horizontal` plus the device's safe-area inset; a
22
+ * margin from the spacing helpers (`mb`, `mr`, …) adds to it. A margin on
23
+ * one side also takes that much of the width its content can have, which
24
+ * the offset variables don't, so move it far with those.
25
+ * @defaultValue 'bottom-right'
26
+ */
27
+ position?: AffixPosition;
28
+ /**
29
+ * Renders it into another container, for a page where an ancestor's
30
+ * `transform`, `filter` or `contain` would capture `position: fixed`.
31
+ * `true` portals to the `portalContainer` a `ConfigProvider` sets,
32
+ * `document.body` by default; a string is used as a
33
+ * `document.querySelector` selector; an element is used directly. Renders
34
+ * in place on the server and while hydrating, moving into the portal once
35
+ * the client takes over, so hydration matches. Portaled, it's appended to
36
+ * that container when it mounts, so it comes after what's already there in
37
+ * the reading and Tab order.
38
+ * @defaultValue false
39
+ */
40
+ portal?: boolean | string | HTMLElement;
41
+ }
42
+ /**
43
+ * The `Affix` component keeps its content fixed to a corner of the viewport while the page scrolls under it.
44
+ *
45
+ * It's a `<div>` with no role, so what's inside keeps its own. It sits
46
+ * `--bulma-affix-offset-vertical` and `--bulma-affix-offset-horizontal`
47
+ * from its corner's edges, plus the device's safe-area inset, and stacks at
48
+ * `--bulma-affix-z-index`, over the page's content and under its navbar,
49
+ * static or fixed, its menus, popovers, the Sidebar, the modals, Tooltip and
50
+ * Toast. It's as wide as its
51
+ * content and never wider than the viewport less its offsets. It doesn't
52
+ * scroll, so nothing inside it is clipped, and content that can be taller
53
+ * than the screen scrolls itself. Its place in the reading and Tab order is
54
+ * its place in the DOM, whatever corner it shows in.
55
+ *
56
+ * @function
57
+ * @param {AffixProps} props - Props for the Affix component.
58
+ * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the `<div>`.
59
+ * @returns The `<div>`, in place or in its portal.
60
+ *
61
+ * @example
62
+ * <Affix position="bottom-left">
63
+ * <Button color="primary">Feedback</Button>
64
+ * </Affix>
65
+ */
66
+ export declare const Affix: React.ForwardRefExoticComponent<AffixProps & React.RefAttributes<HTMLDivElement>>;
67
+ export default Affix;
@@ -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,2 @@
1
+ import type { ContainerBreakpoint } from '../layout/Container.js';
2
+ export declare const CONTAINER_BREAKPOINTS: readonly ContainerBreakpoint[];
@@ -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
+ }
@@ -30,6 +30,48 @@ export declare function resolvePortalContainer(container?: string | HTMLElement)
30
30
  * returns the DOM node to portal into.
31
31
  */
32
32
  export declare function usePortalContainer(): (container?: string | HTMLElement) => HTMLElement;
33
+ /**
34
+ * What a component that takes Modal's `portal` prop does with it now. See
35
+ * `usePortalProp`.
36
+ */
37
+ export interface PortalPropState {
38
+ /**
39
+ * Whether the content renders in its portal: `portal` is set and
40
+ * hydration is over. Before that it renders in place.
41
+ */
42
+ isPortaled: boolean;
43
+ /**
44
+ * The target to pass `Portal` as its `container`: the selector or element
45
+ * `portal` names, or `undefined` for `true`, which leaves the choice to the
46
+ * `portalContainer` a `ConfigProvider` sets and then `document.body`.
47
+ */
48
+ container?: string | HTMLElement;
49
+ /**
50
+ * The `portalContainer` a `ConfigProvider` sets, while it's what places the
51
+ * content (portaled, with `portal` set to `true`), else `undefined`. A
52
+ * change to it moves the content, so effects that hold its nodes depend
53
+ * on it.
54
+ */
55
+ defaultTarget?: string | HTMLElement;
56
+ }
57
+ /**
58
+ * Reads Modal's `portal` prop (`boolean | string | HTMLElement`) for a
59
+ * component that takes it: whether the content is in its portal yet, and
60
+ * where it goes.
61
+ *
62
+ * A portal has no server-rendered counterpart, so such a component renders in
63
+ * place on the server and while hydrating, and moves into its portal once the
64
+ * client takes over. Render the content in `Portal` with
65
+ * `disabled={!isPortaled}` and this `container`. Moving remounts the content,
66
+ * so an effect that holds one of its nodes depends on `isPortaled`, `portal`
67
+ * and `defaultTarget`.
68
+ *
69
+ * @function usePortalProp
70
+ * @param portal - The component's `portal` prop.
71
+ * @returns Whether it's portaled now, its `container`, and the provider's
72
+ * target while that places it.
73
+ */
74
+ export declare function usePortalProp(portal?: boolean | string | HTMLElement): PortalPropState;
33
75
  /**
34
76
  * Props for the Portal component.
35
77
  */
@@ -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;
@@ -33,6 +33,7 @@ export * from './components/TreeView.js';
33
33
  export * from './components/ScrollArea.js';
34
34
  export * from './components/Command.js';
35
35
  export * from './components/DataTable.js';
36
+ export * from './components/Affix.js';
36
37
  export * from './elements/Block.js';
37
38
  export * from './elements/Box.js';
38
39
  export * from './elements/Button.js';
@@ -48,6 +49,7 @@ export * from './elements/Divider.js';
48
49
  export * from './elements/Emphasis.js';
49
50
  export * from './elements/Figure.js';
50
51
  export * from './elements/Icon.js';
52
+ export * from './elements/IconButton.js';
51
53
  export * from './elements/IconText.js';
52
54
  export * from './elements/Image.js';
53
55
  export * from './elements/Kbd.js';
@@ -133,7 +135,7 @@ export type { FormFieldProps } from './form/fieldProps.js';
133
135
  export * from './grid/Cell.js';
134
136
  export * from './grid/Grid.js';
135
137
  export * from './helpers/classNames.js';
136
- export type { ConstrainedPolymorphicComponentWithoutRef, PolymorphicComponent, PolymorphicComponentWithoutRef, PolymorphicProps, PolymorphicRef, } from './helpers/polymorphic.js';
138
+ export type { ConstrainedPolymorphicComponent, ConstrainedPolymorphicComponentWithoutRef, PolymorphicComponent, PolymorphicComponentWithoutRef, PolymorphicProps, PolymorphicRef, } from './helpers/polymorphic.js';
137
139
  export * from './helpers/mergeBulmaStyles.js';
138
140
  export * from './helpers/useBulmaClasses.js';
139
141
  export * from './helpers/Theme.js';
@@ -149,10 +151,15 @@ export { useNumberFormat } from './helpers/localeFormat.js';
149
151
  export type { NumberFormatFunction } from './helpers/localeFormat.js';
150
152
  export { useFocusTrap } from './helpers/useFocusTrap.js';
151
153
  export type { UseFocusTrapOptions } from './helpers/useFocusTrap.js';
154
+ export * from './layout/Center.js';
152
155
  export * from './layout/Container.js';
156
+ export * from './layout/Flex.js';
153
157
  export * from './layout/Footer.js';
158
+ export * from './layout/Group.js';
154
159
  export * from './layout/Hero.js';
155
160
  export * from './layout/Level.js';
156
161
  export * from './layout/Media.js';
157
162
  export * from './layout/Section.js';
158
163
  export * from './layout/Splitter.js';
164
+ export * from './layout/Stack.js';
165
+ export type { LayoutElement } from './helpers/stackLayout.js';
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import type { ConstrainedPolymorphicComponent } from '../helpers/polymorphic.js';
3
+ import { type LayoutElement, type LayoutOwnProps } from '../helpers/stackLayout.js';
4
+ import type { BulmaGapStep, validDisplays } from '../helpers/useBulmaClasses.js';
5
+ /**
6
+ * The Center component's own props, beside the attributes of the element
7
+ * `as` renders.
8
+ */
9
+ export interface CenterOwnProps extends LayoutOwnProps {
10
+ /**
11
+ * Space between children, when there are several. None by default. Needs
12
+ * Bulma's helper classes: under `bestax-no-helpers.css` the default stays.
13
+ */
14
+ gap?: BulmaGapStep;
15
+ /**
16
+ * `'inline-flex'` sizes it to its content, to center something inside a line
17
+ * of text. Needs Bulma's helper classes: under `bestax-no-helpers.css` the
18
+ * default stays.
19
+ */
20
+ display?: (typeof validDisplays)[number] | 'none';
21
+ }
22
+ /**
23
+ * Props for the Center component. The attributes and the `ref` follow `as`.
24
+ *
25
+ * @extraProp {PolymorphicRef<LayoutElement>} [ref] - Ref forwarded to the element `as` renders.
26
+ */
27
+ export type CenterProps<T extends LayoutElement = LayoutElement> = CenterOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof CenterOwnProps | 'as'> & {
28
+ /**
29
+ * The element to render. With `ul` or `ol`, give it `li` children: it
30
+ * restates `role="list"`, which Bulma's list reset takes away in Safari.
31
+ * @defaultValue 'div'
32
+ */
33
+ as?: T;
34
+ };
35
+ /**
36
+ * The `Center` component centers its content on both axes.
37
+ *
38
+ * Use it for a loader, an icon or an empty state in the middle of a box, a
39
+ * card or a section. Give it a height, or put it in something that has one,
40
+ * to center down the middle as well as across. Several children sit side by
41
+ * side in the middle, with no gap unless you set one.
42
+ *
43
+ * @function
44
+ * @param {CenterProps} props - Props for the Center component.
45
+ * @param {React.Ref} ref - Forwarded ref to the element `as` renders.
46
+ * @returns {JSX.Element} The rendered center.
47
+ *
48
+ * @example
49
+ * <Center p="6">
50
+ * <Loader />
51
+ * </Center>
52
+ */
53
+ export declare const Center: ConstrainedPolymorphicComponent<CenterOwnProps, LayoutElement, "div">;
54
+ export default Center;