@allxsmith/bestax-bulma 5.58.0 → 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 (68) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/elements/Buttons.js +2 -0
  4. package/dist/esm/elements/Buttons.js.map +1 -1
  5. package/dist/esm/elements/IconButton.js +114 -0
  6. package/dist/esm/elements/IconButton.js.map +1 -0
  7. package/dist/esm/helpers/containerBreakpoints.js +14 -0
  8. package/dist/esm/helpers/containerBreakpoints.js.map +1 -0
  9. package/dist/esm/helpers/polymorphic.js.map +1 -1
  10. package/dist/esm/helpers/stackLayout.js +30 -0
  11. package/dist/esm/helpers/stackLayout.js.map +1 -0
  12. package/dist/esm/helpers/useBulmaClasses.js +8 -2
  13. package/dist/esm/helpers/useBulmaClasses.js.map +1 -1
  14. package/dist/esm/helpers/useFlexboxClasses.js +17 -4
  15. package/dist/esm/helpers/useFlexboxClasses.js.map +1 -1
  16. package/dist/esm/layout/Center.js +33 -0
  17. package/dist/esm/layout/Center.js.map +1 -0
  18. package/dist/esm/layout/Container.js +2 -6
  19. package/dist/esm/layout/Container.js.map +1 -1
  20. package/dist/esm/layout/Flex.js +34 -0
  21. package/dist/esm/layout/Flex.js.map +1 -0
  22. package/dist/esm/layout/Group.js +43 -0
  23. package/dist/esm/layout/Group.js.map +1 -0
  24. package/dist/esm/layout/Stack.js +34 -0
  25. package/dist/esm/layout/Stack.js.map +1 -0
  26. package/dist/extras.css +1 -1
  27. package/dist/extras.css.map +1 -1
  28. package/dist/index.cjs +400 -136
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.esm.js +5 -0
  31. package/dist/index.esm.js.map +1 -1
  32. package/dist/types/elements/Buttons.d.ts +1 -0
  33. package/dist/types/elements/IconButton.d.ts +110 -0
  34. package/dist/types/helpers/containerBreakpoints.d.ts +2 -0
  35. package/dist/types/helpers/polymorphic.d.ts +19 -0
  36. package/dist/types/helpers/stackLayout.d.ts +62 -0
  37. package/dist/types/helpers/useBulmaClasses.d.ts +8 -2
  38. package/dist/types/helpers/useFlexboxClasses.d.ts +26 -3
  39. package/dist/types/index.d.ts +7 -1
  40. package/dist/types/layout/Center.d.ts +54 -0
  41. package/dist/types/layout/Flex.d.ts +92 -0
  42. package/dist/types/layout/Group.d.ts +86 -0
  43. package/dist/types/layout/Stack.d.ts +63 -0
  44. package/dist/types-cjs/elements/Buttons.d.ts +1 -0
  45. package/dist/types-cjs/elements/IconButton.d.ts +110 -0
  46. package/dist/types-cjs/helpers/containerBreakpoints.d.ts +2 -0
  47. package/dist/types-cjs/helpers/polymorphic.d.ts +19 -0
  48. package/dist/types-cjs/helpers/stackLayout.d.ts +62 -0
  49. package/dist/types-cjs/helpers/useBulmaClasses.d.ts +8 -2
  50. package/dist/types-cjs/helpers/useFlexboxClasses.d.ts +26 -3
  51. package/dist/types-cjs/index.d.ts +7 -1
  52. package/dist/types-cjs/layout/Center.d.ts +54 -0
  53. package/dist/types-cjs/layout/Flex.d.ts +92 -0
  54. package/dist/types-cjs/layout/Group.d.ts +86 -0
  55. package/dist/types-cjs/layout/Stack.d.ts +63 -0
  56. package/dist/versions/bestax-no-dark-mode.css +1 -1
  57. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  58. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  59. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  60. package/dist/versions/bestax-no-helpers.css +1 -1
  61. package/dist/versions/bestax-no-helpers.css.map +1 -1
  62. package/dist/versions/bestax-prefixed.css +1 -1
  63. package/dist/versions/bestax-prefixed.css.map +1 -1
  64. package/package.json +1 -1
  65. package/src/scss/elements/_iconbutton.scss +36 -0
  66. package/src/scss/elements/_index.scss +1 -0
  67. package/src/scss/layout/_index.scss +1 -0
  68. package/src/scss/layout/_stack.scss +145 -0
@@ -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
+ }
@@ -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;
@@ -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';
@@ -133,7 +134,7 @@ export type { FormFieldProps } from './form/fieldProps.js';
133
134
  export * from './grid/Cell.js';
134
135
  export * from './grid/Grid.js';
135
136
  export * from './helpers/classNames.js';
136
- export type { ConstrainedPolymorphicComponentWithoutRef, PolymorphicComponent, PolymorphicComponentWithoutRef, PolymorphicProps, PolymorphicRef, } from './helpers/polymorphic.js';
137
+ export type { ConstrainedPolymorphicComponent, ConstrainedPolymorphicComponentWithoutRef, PolymorphicComponent, PolymorphicComponentWithoutRef, PolymorphicProps, PolymorphicRef, } from './helpers/polymorphic.js';
137
138
  export * from './helpers/mergeBulmaStyles.js';
138
139
  export * from './helpers/useBulmaClasses.js';
139
140
  export * from './helpers/Theme.js';
@@ -149,10 +150,15 @@ export { useNumberFormat } from './helpers/localeFormat.js';
149
150
  export type { NumberFormatFunction } from './helpers/localeFormat.js';
150
151
  export { useFocusTrap } from './helpers/useFocusTrap.js';
151
152
  export type { UseFocusTrapOptions } from './helpers/useFocusTrap.js';
153
+ export * from './layout/Center.js';
152
154
  export * from './layout/Container.js';
155
+ export * from './layout/Flex.js';
153
156
  export * from './layout/Footer.js';
157
+ export * from './layout/Group.js';
154
158
  export * from './layout/Hero.js';
155
159
  export * from './layout/Level.js';
156
160
  export * from './layout/Media.js';
157
161
  export * from './layout/Section.js';
158
162
  export * from './layout/Splitter.js';
163
+ export * from './layout/Stack.js';
164
+ 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;
@@ -0,0 +1,92 @@
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, validAlignContents, validAlignItems, validFlexDirections, validFlexWraps, validJustifyContents } from '../helpers/useBulmaClasses.js';
5
+ /**
6
+ * The Flex component's own props, beside the attributes of the element `as`
7
+ * renders.
8
+ */
9
+ export interface FlexOwnProps extends LayoutOwnProps {
10
+ /**
11
+ * The main axis. `row-reverse` and `column-reverse` change only what's seen:
12
+ * reading and Tab order still follow the children's order (WCAG 1.3.2 and
13
+ * 2.4.3). Needs Bulma's helper classes: under `bestax-no-helpers.css` the
14
+ * default stays.
15
+ * @defaultValue 'row'
16
+ */
17
+ flexDirection?: (typeof validFlexDirections)[number];
18
+ /**
19
+ * Whether children move to a new line when they don't fit. Needs Bulma's
20
+ * helper classes: under `bestax-no-helpers.css` the default stays.
21
+ * @defaultValue 'nowrap'
22
+ */
23
+ flexWrap?: (typeof validFlexWraps)[number];
24
+ /**
25
+ * How each child sits across the main axis. Needs Bulma's helper classes:
26
+ * under `bestax-no-helpers.css` the default stays.
27
+ * @defaultValue 'stretch'
28
+ */
29
+ alignItems?: (typeof validAlignItems)[number];
30
+ /**
31
+ * Where the children sit along the main axis. Needs Bulma's helper classes:
32
+ * under `bestax-no-helpers.css` the default stays.
33
+ */
34
+ justifyContent?: (typeof validJustifyContents)[number];
35
+ /**
36
+ * How wrapped lines share the space across the main axis. Needs Bulma's
37
+ * helper classes: under `bestax-no-helpers.css` the default stays.
38
+ */
39
+ alignContent?: (typeof validAlignContents)[number];
40
+ /**
41
+ * Space between children, a step of Bulma's gap scale. None by default. Needs
42
+ * Bulma's helper classes: under `bestax-no-helpers.css` the default stays.
43
+ */
44
+ gap?: BulmaGapStep;
45
+ /**
46
+ * Space between wrapped lines, when it differs from `gap`. Needs Bulma's
47
+ * helper classes: under `bestax-no-helpers.css` the default stays.
48
+ */
49
+ rowGap?: BulmaGapStep;
50
+ /**
51
+ * Space between children along a row, when it differs from `gap`. Needs
52
+ * Bulma's helper classes: under `bestax-no-helpers.css` the default stays.
53
+ */
54
+ columnGap?: BulmaGapStep;
55
+ }
56
+ /**
57
+ * Props for the Flex component. The attributes and the `ref` follow `as`, so
58
+ * `as="form"` takes `action` and `as="fieldset"` takes `disabled`.
59
+ *
60
+ * @extraProp {PolymorphicRef<LayoutElement>} [ref] - Ref forwarded to the element `as` renders.
61
+ */
62
+ export type FlexProps<T extends LayoutElement = LayoutElement> = FlexOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof FlexOwnProps | 'as'> & {
63
+ /**
64
+ * The element to render. With `ul` or `ol`, give it `li` children: it
65
+ * restates `role="list"`, which Bulma's list reset takes away in Safari.
66
+ * @defaultValue 'div'
67
+ */
68
+ as?: T;
69
+ };
70
+ /**
71
+ * The `Flex` component is a flex container with CSS's own defaults, taking the flex container's properties as props.
72
+ *
73
+ * It's a row that doesn't wrap, with its children stretched across it and no
74
+ * gap, until you set otherwise. Use it for a layout of your own, such as a
75
+ * fixed side beside a growing one, with `flexGrow` and `flexShrink` on the
76
+ * children. Its children's own block margins are zeroed, so the gap is the
77
+ * only space. For a column of blocks or a row of controls with Bulma's
78
+ * spacing already in place, `Stack` and `Group` start closer.
79
+ *
80
+ * @function
81
+ * @param {FlexProps} props - Props for the Flex component.
82
+ * @param {React.Ref} ref - Forwarded ref to the element `as` renders.
83
+ * @returns {JSX.Element} The rendered flex container.
84
+ *
85
+ * @example
86
+ * <Flex gap="4" alignItems="flex-start">
87
+ * <Box flexShrink="0">…</Box>
88
+ * <Box flexGrow="1">…</Box>
89
+ * </Flex>
90
+ */
91
+ export declare const Flex: ConstrainedPolymorphicComponent<FlexOwnProps, LayoutElement, "div">;
92
+ export default Flex;
@@ -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;