@allxsmith/bestax-bulma 5.15.0 → 5.15.2
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.
- package/dist/index.cjs.js +283 -76
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +284 -77
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Avatar.d.ts +39 -5
- package/dist/types/components/Avatars.d.ts +1 -1
- package/dist/types/components/Dropdown.d.ts +35 -6
- package/dist/types/components/Menu.d.ts +35 -10
- package/dist/types/components/Navbar.d.ts +67 -15
- package/dist/types/components/Panel.d.ts +2 -2
- package/dist/types/components/Reveal.d.ts +18 -24
- package/dist/types/elements/Button.d.ts +25 -16
- package/dist/types/elements/Buttons.d.ts +2 -2
- package/dist/types/elements/Icon.d.ts +44 -5
- package/dist/types/elements/Link.d.ts +33 -9
- package/dist/types/elements/LinkButton.d.ts +34 -5
- package/dist/types/elements/iconProps.d.ts +30 -0
- package/dist/types/helpers/polymorphic.d.ts +138 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -1
- package/src/scss/CLAUDE.md +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BulmaClassesProps } from '../helpers/useBulmaClasses';
|
|
3
|
+
import { type PolymorphicComponent } from '../helpers/polymorphic';
|
|
3
4
|
declare const avatarColors: readonly ["primary", "link", "info", "success", "warning", "danger", "black", "dark", "light", "white"];
|
|
4
5
|
/** Valid color values for the Avatar component. */
|
|
5
6
|
export type AvatarColor = (typeof avatarColors)[number];
|
|
@@ -9,9 +10,10 @@ export type AvatarSize = (typeof avatarSizes)[number];
|
|
|
9
10
|
/** Valid shape values for the Avatar component. */
|
|
10
11
|
export type AvatarShape = 'circle' | 'rounded' | 'square';
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* The Avatar component's own props — everything it adds on top of the
|
|
14
|
+
* attributes of whatever element `as` renders.
|
|
13
15
|
*/
|
|
14
|
-
export interface
|
|
16
|
+
export interface AvatarOwnProps extends Omit<BulmaClassesProps, 'color'> {
|
|
15
17
|
/** Additional CSS classes to apply. */
|
|
16
18
|
className?: string;
|
|
17
19
|
/** Image URL. On load error (or if absent), falls back to initials, then `icon`. */
|
|
@@ -30,8 +32,6 @@ export interface AvatarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'co
|
|
|
30
32
|
shape?: AvatarShape;
|
|
31
33
|
/** Background color for initials/icon avatars (else auto-derived from `name`). */
|
|
32
34
|
color?: AvatarColor;
|
|
33
|
-
/** Element/component to render as. Defaults to `'a'` when `href` is set, else `'figure'`. */
|
|
34
|
-
as?: React.ElementType;
|
|
35
35
|
/** When set, renders the avatar as a link. */
|
|
36
36
|
href?: string;
|
|
37
37
|
/** Anchor target — forwarded only when rendering a link (an `a` or a custom `as` component). */
|
|
@@ -40,12 +40,46 @@ export interface AvatarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'co
|
|
|
40
40
|
rel?: string;
|
|
41
41
|
/** Extra props forwarded to the underlying `<img>` (e.g. `loading`, `crossOrigin`); its `onError` is chained before the fallback fires. */
|
|
42
42
|
imageProps?: React.ImgHTMLAttributes<HTMLImageElement>;
|
|
43
|
+
/** Inline styles, merged after the size style. */
|
|
44
|
+
style?: React.CSSProperties;
|
|
45
|
+
/**
|
|
46
|
+
* Not accepted. Avatar always renders its own content — the image, the
|
|
47
|
+
* initials, or the icon — so anything a caller passed would be replaced. It
|
|
48
|
+
* is declared unavailable rather than derived from `as`, which would let a
|
|
49
|
+
* target requiring `children` compel a value it then never receives.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
children?: never;
|
|
43
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Props for the Avatar component. The DOM attributes and the `ref` both follow
|
|
56
|
+
* `as`.
|
|
57
|
+
*
|
|
58
|
+
* `href`, `target` and `rel` stay Avatar's own props rather than being derived:
|
|
59
|
+
* they are what *chooses* the element when `as` is absent (an `<a>` with an
|
|
60
|
+
* `href`, a `<figure>` without one), so they have to be accepted before `as` is
|
|
61
|
+
* known.
|
|
62
|
+
*
|
|
63
|
+
* The type parameter defaults to `'figure'`, not to `React.ElementType`.
|
|
64
|
+
* Defaulting to the constraint sounds truer to a runtime default that is
|
|
65
|
+
* conditional, but `ComponentPropsWithoutRef<React.ElementType>` spreads across
|
|
66
|
+
* every element at once and accepts anything — which is the false-positive this
|
|
67
|
+
* whole change exists to remove. `'figure'` is the element a no-`href` avatar
|
|
68
|
+
* actually renders, and the anchor props it can additionally take are declared
|
|
69
|
+
* above.
|
|
70
|
+
*
|
|
71
|
+
* @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the element `as` renders, typed from `as`: the DOM node for an intrinsic tag, or whatever handle a custom component exposes.
|
|
72
|
+
*/
|
|
73
|
+
export type AvatarProps<T extends React.ElementType = 'figure'> = AvatarOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof AvatarOwnProps | 'as'> & {
|
|
74
|
+
/** Element/component to render as. Defaults to `'a'` when `href` is set, else `'figure'`. */
|
|
75
|
+
as?: T;
|
|
76
|
+
};
|
|
44
77
|
/**
|
|
45
78
|
* The `Avatar` component represents a person or entity as a compact image.
|
|
46
79
|
*
|
|
47
80
|
* @function
|
|
48
81
|
* @param {AvatarProps} props - Props for the Avatar component.
|
|
82
|
+
* @param {React.Ref} ref - Forwarded ref to the element `as` renders.
|
|
49
83
|
* @returns {JSX.Element} The rendered avatar element.
|
|
50
84
|
*
|
|
51
85
|
* @example
|
|
@@ -53,5 +87,5 @@ export interface AvatarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'co
|
|
|
53
87
|
* @example
|
|
54
88
|
* <Avatar name="Grace Hopper" />
|
|
55
89
|
*/
|
|
56
|
-
export declare const Avatar:
|
|
90
|
+
export declare const Avatar: PolymorphicComponent<AvatarOwnProps, "figure">;
|
|
57
91
|
export default Avatar;
|
|
@@ -25,6 +25,6 @@ export interface AvatarsProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
25
25
|
children?: React.ReactNode;
|
|
26
26
|
}
|
|
27
27
|
export declare const Avatars: React.FC<AvatarsProps> & {
|
|
28
|
-
Avatar:
|
|
28
|
+
Avatar: import("..").PolymorphicComponent<import("./Avatar").AvatarOwnProps, "figure">;
|
|
29
29
|
};
|
|
30
30
|
export default Avatars;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BulmaClassesProps } from '../helpers/useBulmaClasses';
|
|
3
|
+
import type { ConstrainedPolymorphicComponentWithoutRef } from '../helpers/polymorphic';
|
|
3
4
|
/**
|
|
4
5
|
* Checks if code is running in a browser environment.
|
|
5
6
|
* @param win - Window object.
|
|
@@ -38,20 +39,48 @@ export interface DropdownProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
38
39
|
id?: string;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* The elements a dropdown item may render as. Bulma's dropdown markup names
|
|
43
|
+
* these three and no others, so `as` is a closed set rather than an open
|
|
44
|
+
* `React.ElementType`.
|
|
42
45
|
*/
|
|
43
|
-
export
|
|
46
|
+
export type DropdownItemElement = 'a' | 'div' | 'button';
|
|
47
|
+
/**
|
|
48
|
+
* The DropdownItem component's own props.
|
|
49
|
+
*/
|
|
50
|
+
export interface DropdownItemOwnProps extends BulmaClassesProps {
|
|
44
51
|
/** Whether the item is active. */
|
|
45
52
|
active?: boolean;
|
|
46
53
|
/** Additional CSS classes. */
|
|
47
54
|
className?: string;
|
|
48
|
-
/** The element type to render. */
|
|
49
|
-
as?: 'a' | 'div' | 'button';
|
|
50
55
|
/** Marks the item as disabled; disabled items are skipped during keyboard navigation. Use with `as="button"` for a native disabled control, or pair with `aria-disabled` on a link. */
|
|
51
56
|
disabled?: boolean;
|
|
52
57
|
/** Item content. */
|
|
53
58
|
children?: React.ReactNode;
|
|
54
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Props for the DropdownItem component. Everything the item does not own
|
|
62
|
+
* follows `as`: `href`, `target` and `rel` under the default `'a'`, `type` and
|
|
63
|
+
* `form` under `'button'`, and the shared HTML attributes under any of them.
|
|
64
|
+
*
|
|
65
|
+
* Pinning these to `React.HTMLAttributes<HTMLElement>` instead — which is what
|
|
66
|
+
* this type did before — rejected `href` on an anchor and `type` on a button,
|
|
67
|
+
* both of which have always worked at runtime. Same defect as #641, in the
|
|
68
|
+
* narrower shape a constrained `as` takes.
|
|
69
|
+
*
|
|
70
|
+
* **Name the tag you mean.** The type parameter defaults to the whole union, not
|
|
71
|
+
* to the rendered element, so bare `DropdownItemProps` keeps accepting
|
|
72
|
+
* `{ as: 'div' }` the way it always has. The cost is that it is not
|
|
73
|
+
* distributive: `Omit` over a union keeps only the shared keys, so the bare
|
|
74
|
+
* alias carries no `href` even though the component takes one under `as="a"`.
|
|
75
|
+
* Write `DropdownItemProps<'a'>` for the anchor's props. That is the #667 alias
|
|
76
|
+
* limitation Button carries, labelled next-major because closing it is
|
|
77
|
+
* source-breaking, and pinned for this component in
|
|
78
|
+
* `__typetests__/polymorphic.tsx`; the component itself is unaffected.
|
|
79
|
+
*/
|
|
80
|
+
export type DropdownItemProps<T extends DropdownItemElement = DropdownItemElement> = DropdownItemOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof DropdownItemOwnProps | 'as'> & {
|
|
81
|
+
/** The element type to render. */
|
|
82
|
+
as?: T;
|
|
83
|
+
};
|
|
55
84
|
/**
|
|
56
85
|
* Bulma Dropdown item.
|
|
57
86
|
*
|
|
@@ -59,7 +88,7 @@ export interface DropdownItemProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
59
88
|
* @param {DropdownItemProps} props - Props for the DropdownItem component.
|
|
60
89
|
* @returns {JSX.Element} The rendered dropdown item.
|
|
61
90
|
*/
|
|
62
|
-
export declare const DropdownItem:
|
|
91
|
+
export declare const DropdownItem: ConstrainedPolymorphicComponentWithoutRef<DropdownItemOwnProps, DropdownItemElement, "a">;
|
|
63
92
|
/**
|
|
64
93
|
* Bulma Dropdown divider.
|
|
65
94
|
*
|
|
@@ -69,7 +98,7 @@ export declare const DropdownItem: React.FC<DropdownItemProps>;
|
|
|
69
98
|
export declare const DropdownDivider: React.FC;
|
|
70
99
|
/** Bulma Dropdown component with Item and Divider sub-components. */
|
|
71
100
|
export declare const Dropdown: React.ForwardRefExoticComponent<DropdownProps & React.RefAttributes<HTMLDivElement>> & {
|
|
72
|
-
Item:
|
|
101
|
+
Item: ConstrainedPolymorphicComponentWithoutRef<DropdownItemOwnProps, DropdownItemElement, "a">;
|
|
73
102
|
Divider: React.FC<{}>;
|
|
74
103
|
};
|
|
75
104
|
export default Dropdown;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BulmaClassesProps } from '../helpers/useBulmaClasses';
|
|
3
|
+
import { type PolymorphicComponent } from '../helpers/polymorphic';
|
|
3
4
|
/**
|
|
4
5
|
* Props for the Menu component.
|
|
5
6
|
*/
|
|
@@ -44,32 +45,56 @@ export interface MenuListProps extends Omit<React.HTMLAttributes<HTMLUListElemen
|
|
|
44
45
|
*/
|
|
45
46
|
export declare const MenuList: React.FC<MenuListProps>;
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
+
* The MenuItem component's own props.
|
|
49
|
+
*
|
|
50
|
+
* A menu item is two elements: a wrapping `<li>` and, inside it, the element
|
|
51
|
+
* `as` names. The props here are the ones the `<li>` consumes; everything else
|
|
52
|
+
* follows `as` onto the inner element.
|
|
48
53
|
*/
|
|
49
|
-
export interface
|
|
50
|
-
/** Additional CSS classes
|
|
54
|
+
export interface MenuItemOwnProps extends BulmaClassesProps {
|
|
55
|
+
/** Additional CSS classes for the wrapping `<li>`. */
|
|
51
56
|
className?: string;
|
|
52
57
|
/** Item content and optional nested MenuList. */
|
|
53
58
|
children: React.ReactNode;
|
|
54
59
|
/** Highlight item as active. */
|
|
55
60
|
active?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
/** Inline styles for the wrapping `<li>`. */
|
|
62
|
+
style?: React.CSSProperties;
|
|
63
|
+
/** `id` for the wrapping `<li>`. */
|
|
64
|
+
id?: string;
|
|
65
|
+
/** `title` for the wrapping `<li>`. */
|
|
66
|
+
title?: string;
|
|
67
|
+
/** ARIA role for the wrapping `<li>`. */
|
|
68
|
+
role?: React.AriaRole;
|
|
69
|
+
/** Tab index for the wrapping `<li>`. */
|
|
70
|
+
tabIndex?: number;
|
|
71
|
+
/** Test id for the wrapping `<li>`. */
|
|
72
|
+
'data-testid'?: string;
|
|
61
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Props for the MenuItem component. Everything the `<li>` does not consume
|
|
76
|
+
* follows `as` onto the inner element: with the default `'a'` that means `href`
|
|
77
|
+
* and the other anchor attributes, and with `as={Link}` it means that
|
|
78
|
+
* component's own props.
|
|
79
|
+
*
|
|
80
|
+
* @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the inner element `as` renders, not the wrapping `<li>`, typed from `as`: the DOM node for an intrinsic tag, or whatever handle a custom component exposes.
|
|
81
|
+
*/
|
|
82
|
+
export type MenuItemProps<T extends React.ElementType = 'a'> = MenuItemOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof MenuItemOwnProps | 'as'> & {
|
|
83
|
+
/** Custom link component (e.g. `Link` from router). */
|
|
84
|
+
as?: T;
|
|
85
|
+
};
|
|
62
86
|
/**
|
|
63
87
|
* MenuItem supports `as` prop for custom link components, e.g., react-router-dom Link.
|
|
64
88
|
*
|
|
65
89
|
* @function
|
|
66
90
|
* @param {MenuItemProps} props - Props for the MenuItem component.
|
|
91
|
+
* @param {React.Ref} ref - Forwarded ref to the inner element `as` renders.
|
|
67
92
|
* @returns {JSX.Element} The rendered menu item.
|
|
68
93
|
*/
|
|
69
|
-
export declare const MenuItem:
|
|
94
|
+
export declare const MenuItem: PolymorphicComponent<MenuItemOwnProps, "a">;
|
|
70
95
|
export declare const Menu: React.FC<MenuProps> & {
|
|
71
96
|
Label: React.FC<MenuLabelProps>;
|
|
72
97
|
List: React.FC<MenuListProps>;
|
|
73
|
-
Item:
|
|
98
|
+
Item: PolymorphicComponent<MenuItemOwnProps, "a">;
|
|
74
99
|
};
|
|
75
100
|
export default Menu;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { PolymorphicComponent } from '../helpers/polymorphic';
|
|
2
3
|
import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses';
|
|
3
4
|
/**
|
|
4
5
|
* Props for the Navbar component.
|
|
@@ -42,13 +43,27 @@ export interface NavbarBrandProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
|
42
43
|
*/
|
|
43
44
|
export declare const NavbarBrand: React.FC<NavbarBrandProps>;
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
+
* The NavbarItem component's own props — everything it adds on top of the
|
|
47
|
+
* attributes of whatever element `as` renders.
|
|
46
48
|
*/
|
|
47
|
-
export interface
|
|
49
|
+
export interface NavbarItemOwnProps extends Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
50
|
+
/**
|
|
51
|
+
* Not accepted. `color` here would be the deprecated presentational HTML
|
|
52
|
+
* attribute, and `useBulmaClasses` consumes any `color` key as a Bulma helper
|
|
53
|
+
* before the target could see it — so it is declared unavailable rather than
|
|
54
|
+
* silently eaten. Use `textColor` / `bgColor`.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
color?: never;
|
|
58
|
+
/**
|
|
59
|
+
* Not accepted under this name. `useBulmaClasses` consumes any
|
|
60
|
+
* `backgroundColor` key before `rest` is spread, so a custom `as` target
|
|
61
|
+
* declaring one would never receive it. Use `bgColor`.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
backgroundColor?: never;
|
|
48
65
|
/** Additional CSS classes. */
|
|
49
66
|
className?: string;
|
|
50
|
-
/** Render as a custom component (e.g., a router link). */
|
|
51
|
-
as?: React.ElementType;
|
|
52
67
|
/** Whether the item is active. */
|
|
53
68
|
active?: boolean;
|
|
54
69
|
/** Text color for the item. */
|
|
@@ -57,16 +72,27 @@ export interface NavbarItemProps extends Omit<React.AnchorHTMLAttributes<HTMLAnc
|
|
|
57
72
|
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
58
73
|
/** Navbar item content. */
|
|
59
74
|
children?: React.ReactNode;
|
|
60
|
-
[key: string]: unknown;
|
|
61
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Props for the NavbarItem component. The DOM attributes and the `ref` both
|
|
78
|
+
* follow `as`: rendering as a router link accepts that component's props (`to`
|
|
79
|
+
* and friends) by inference, and `as="span"` rejects `href`.
|
|
80
|
+
*
|
|
81
|
+
* @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the element `as` renders, typed from `as`: the DOM node for an intrinsic tag, or whatever handle a custom component exposes.
|
|
82
|
+
*/
|
|
83
|
+
export type NavbarItemProps<T extends React.ElementType = 'a'> = NavbarItemOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof NavbarItemOwnProps | 'as'> & {
|
|
84
|
+
/** Render as another intrinsic element (`'span'`, `'div'`) or a custom component (e.g. a router link). Defaults to `'a'`. */
|
|
85
|
+
as?: T;
|
|
86
|
+
};
|
|
62
87
|
/**
|
|
63
88
|
* Navigation links, buttons, or custom content
|
|
64
89
|
*
|
|
65
90
|
* @function
|
|
66
91
|
* @param {NavbarItemProps} props - Props for the NavbarItem component.
|
|
92
|
+
* @param {React.Ref} ref - Forwarded ref to the element `as` renders.
|
|
67
93
|
* @returns {JSX.Element} The rendered item.
|
|
68
94
|
*/
|
|
69
|
-
export declare const NavbarItem:
|
|
95
|
+
export declare const NavbarItem: PolymorphicComponent<NavbarItemOwnProps, "a">;
|
|
70
96
|
/**
|
|
71
97
|
* Props for the NavbarBurger component.
|
|
72
98
|
* @extraProp {React.Ref<HTMLButtonElement>} [ref] - Ref forwarded to the burger button element.
|
|
@@ -151,14 +177,27 @@ export declare const NavbarStart: React.FC<NavbarStartEndProps>;
|
|
|
151
177
|
*/
|
|
152
178
|
export declare const NavbarEnd: React.FC<NavbarStartEndProps>;
|
|
153
179
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
180
|
+
* The NavbarLink component's own props — everything it adds on top of the
|
|
181
|
+
* attributes of whatever element `as` renders.
|
|
156
182
|
*/
|
|
157
|
-
export interface
|
|
183
|
+
export interface NavbarLinkOwnProps extends Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
184
|
+
/**
|
|
185
|
+
* Not accepted. `color` here would be the deprecated presentational HTML
|
|
186
|
+
* attribute, and `useBulmaClasses` consumes any `color` key as a Bulma helper
|
|
187
|
+
* before the target could see it — so it is declared unavailable rather than
|
|
188
|
+
* silently eaten. Use `textColor` / `bgColor`.
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
color?: never;
|
|
192
|
+
/**
|
|
193
|
+
* Not accepted under this name. `useBulmaClasses` consumes any
|
|
194
|
+
* `backgroundColor` key before `rest` is spread, so a custom `as` target
|
|
195
|
+
* declaring one would never receive it. Use `bgColor`.
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
backgroundColor?: never;
|
|
158
199
|
/** Additional CSS classes. */
|
|
159
200
|
className?: string;
|
|
160
|
-
/** Render as a custom component (default: 'a'). */
|
|
161
|
-
as?: React.ElementType;
|
|
162
201
|
/** Remove the dropdown arrow indicator. */
|
|
163
202
|
arrowless?: boolean;
|
|
164
203
|
/** Text color. */
|
|
@@ -168,15 +207,28 @@ export interface NavbarLinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnc
|
|
|
168
207
|
/** Link content. */
|
|
169
208
|
children?: React.ReactNode;
|
|
170
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Props for the NavbarLink component. The DOM attributes and the `ref` both
|
|
212
|
+
* follow `as`: `as="button"` accepts the button attributes and a button ref,
|
|
213
|
+
* and `as="span"` rejects `href` and `target`. Not `rel` — React declares it on
|
|
214
|
+
* `HTMLAttributes<T>`, so it is valid on every element, and rejecting it would
|
|
215
|
+
* mean diverging from React's own typing.
|
|
216
|
+
*
|
|
217
|
+
* @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the element `as` renders, typed from `as`: the DOM node for an intrinsic tag, or whatever handle a custom component exposes.
|
|
218
|
+
*/
|
|
219
|
+
export type NavbarLinkProps<T extends React.ElementType = 'a'> = NavbarLinkOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof NavbarLinkOwnProps | 'as'> & {
|
|
220
|
+
/** Render as another intrinsic element (`'button'`, `'span'`) or a custom component. Defaults to `'a'`. */
|
|
221
|
+
as?: T;
|
|
222
|
+
};
|
|
171
223
|
/**
|
|
172
224
|
* Dropdown trigger with arrow indicator (use as first child of `Navbar.Dropdown`)
|
|
173
225
|
*
|
|
174
226
|
* @function
|
|
175
227
|
* @param {NavbarLinkProps} props - Props for the NavbarLink component.
|
|
176
|
-
* @param {React.Ref
|
|
228
|
+
* @param {React.Ref} ref - Forwarded ref to the element `as` renders.
|
|
177
229
|
* @returns {JSX.Element} The rendered navbar link.
|
|
178
230
|
*/
|
|
179
|
-
export declare const NavbarLink:
|
|
231
|
+
export declare const NavbarLink: PolymorphicComponent<NavbarLinkOwnProps, "a">;
|
|
180
232
|
/**
|
|
181
233
|
* Props for the NavbarDropdown component.
|
|
182
234
|
* @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the dropdown container element.
|
|
@@ -237,8 +289,8 @@ export declare const NavbarDropdownMenu: React.FC<NavbarDropdownMenuProps>;
|
|
|
237
289
|
export declare const NavbarDivider: React.FC<React.HTMLAttributes<HTMLHRElement>>;
|
|
238
290
|
export declare const Navbar: React.ForwardRefExoticComponent<NavbarProps & React.RefAttributes<HTMLElement>> & {
|
|
239
291
|
Brand: React.FC<NavbarBrandProps>;
|
|
240
|
-
Item:
|
|
241
|
-
Link:
|
|
292
|
+
Item: PolymorphicComponent<NavbarItemOwnProps, "a">;
|
|
293
|
+
Link: PolymorphicComponent<NavbarLinkOwnProps, "a">;
|
|
242
294
|
Burger: React.ForwardRefExoticComponent<NavbarBurgerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
243
295
|
Menu: React.FC<NavbarMenuProps>;
|
|
244
296
|
Start: React.FC<NavbarStartEndProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BulmaClassesProps } from '../helpers/useBulmaClasses';
|
|
3
|
-
import { IconChildrenProps, IconNameProps } from '../elements/Icon';
|
|
3
|
+
import { IconChildrenProps, IconDeprecatedProps, IconNameProps } from '../elements/Icon';
|
|
4
4
|
/**
|
|
5
5
|
* Props for the Panel component.
|
|
6
6
|
*/
|
|
@@ -45,7 +45,7 @@ export interface PanelBlockProps extends React.AnchorHTMLAttributes<HTMLAnchorEl
|
|
|
45
45
|
* Props for the PanelIcon component.
|
|
46
46
|
* Extends IconProps but uses 'panel-icon' as the container class.
|
|
47
47
|
*/
|
|
48
|
-
export type PanelIconProps = Omit<IconNameProps, 'containerClassName'> | Omit<IconChildrenProps, 'containerClassName'>;
|
|
48
|
+
export type PanelIconProps = Omit<IconNameProps, 'containerClassName'> | Omit<IconChildrenProps, 'containerClassName'> | Omit<IconDeprecatedProps, 'containerClassName'>;
|
|
49
49
|
/**
|
|
50
50
|
* Props for the PanelInputBlock component.
|
|
51
51
|
*/
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { PolymorphicComponentWithoutRef } from '../helpers/polymorphic';
|
|
2
3
|
import { BulmaClassesProps } from '../helpers/useBulmaClasses';
|
|
3
4
|
/**
|
|
4
5
|
* Animation styles available for the Reveal component.
|
|
5
6
|
*/
|
|
6
7
|
export type RevealAnimation = 'fade' | 'fade-up' | 'fade-down' | 'slide-left' | 'slide-right' | 'zoom' | 'flip';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* The Reveal component's own props — everything it adds on top of the
|
|
10
|
+
* attributes of whatever element `as` renders.
|
|
10
11
|
*/
|
|
11
|
-
export interface
|
|
12
|
+
export interface RevealOwnProps extends BulmaClassesProps {
|
|
12
13
|
/** Animation style applied when the element enters the viewport. */
|
|
13
14
|
animation?: RevealAnimation;
|
|
14
15
|
/** Delay in milliseconds before the animation starts. Default: 0. */
|
|
@@ -19,35 +20,28 @@ export interface RevealProps extends Omit<React.HTMLAttributes<HTMLElement>, 'co
|
|
|
19
20
|
threshold?: number;
|
|
20
21
|
/** Animate only the first time the element enters the viewport. If `false`, it re-animates on every entry/exit. */
|
|
21
22
|
once?: boolean;
|
|
22
|
-
/** Element or component to render as. Default: 'div'. When `as` is a plain intrinsic tag (e.g. `'section'`), your `className`, `style`, and Bulma helper classes plus everything in `...rest` all land on that single element. When `as` is a component (e.g. `Section`, `Card`), scroll detection needs a real DOM node with a ref, so `Reveal` wraps it in an observed `div`: `className`/`style`/helper classes go on that wrapper `div`, while `...rest` (`id`, `aria-*`, `data-*`, event handlers) is forwarded to the inner component. */
|
|
23
|
-
as?: React.ElementType;
|
|
24
23
|
/** Stagger direct children with an incrementing delay instead of animating this element as a single block. */
|
|
25
24
|
cascade?: boolean;
|
|
26
25
|
/** Milliseconds added to each successive child's delay when `cascade` is set. Default: 80. */
|
|
27
26
|
cascadeInterval?: number;
|
|
28
27
|
/** Content to reveal. */
|
|
29
28
|
children?: React.ReactNode;
|
|
29
|
+
/** Additional CSS classes. Applied to the observed element (the wrapper `div` when `as` is a component). */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Inline styles, merged after the animation's own. Applied to the observed element. */
|
|
32
|
+
style?: React.CSSProperties;
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @function
|
|
35
|
-
* @param {RevealProps} props - Props for the Reveal component.
|
|
36
|
-
* @returns {JSX.Element} The rendered reveal wrapper.
|
|
35
|
+
* Props for the Reveal component. The DOM attributes follow `as`.
|
|
37
36
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* </Reveal>
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* // Stagger a set of cards as they enter the viewport
|
|
46
|
-
* <Reveal animation="fade-up" cascade cascadeInterval={80}>
|
|
47
|
-
* {services.map(service => (
|
|
48
|
-
* <Card key={service.name}>{service.name}</Card>
|
|
49
|
-
* ))}
|
|
50
|
-
* </Reveal>
|
|
37
|
+
* Reveal forwards no `ref`: it owns the node it observes for scroll
|
|
38
|
+
* intersection, and when `as` is a component that node is a wrapper `div`
|
|
39
|
+
* rather than the element `as` names — so a ref derived from `as` would point
|
|
40
|
+
* at the wrong thing.
|
|
51
41
|
*/
|
|
52
|
-
export
|
|
42
|
+
export type RevealProps<T extends React.ElementType = 'div'> = RevealOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof RevealOwnProps | 'as'> & {
|
|
43
|
+
/** Element or component to render as. Default: 'div'. When `as` is a plain intrinsic tag (e.g. `'section'`), your `className`, `style`, and Bulma helper classes plus everything in `...rest` all land on that single element. When `as` is a component (e.g. `Section`, `Card`), scroll detection needs a real DOM node with a ref, so `Reveal` wraps it in an observed `div`: `className`/`style`/helper classes go on that wrapper `div`, while `...rest` (`id`, `aria-*`, `data-*`, event handlers) is forwarded to the inner component. */
|
|
44
|
+
as?: T;
|
|
45
|
+
};
|
|
46
|
+
export declare const Reveal: PolymorphicComponentWithoutRef<RevealOwnProps, "div">;
|
|
53
47
|
export default Reveal;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type PolymorphicComponent } from '../helpers/polymorphic';
|
|
2
3
|
import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* The Button component's own props — everything it adds on top of the
|
|
6
|
+
* attributes of whatever element `as` renders.
|
|
6
7
|
*/
|
|
7
|
-
export interface
|
|
8
|
+
export interface ButtonOwnProps extends Omit<BulmaClassesProps, 'color' | 'backgroundColor' | 'size'> {
|
|
9
|
+
/**
|
|
10
|
+
* Not accepted under this name. `useBulmaClasses` consumes any
|
|
11
|
+
* `backgroundColor` key before `rest` is spread, so a custom `as` target
|
|
12
|
+
* declaring one would never receive it. Use `bgColor`.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
backgroundColor?: never;
|
|
8
16
|
/** Bulma color variant for the button. `ghost` renders a link-like button; `text` renders a minimal text-only button. */
|
|
9
17
|
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger' | 'white' | 'light' | 'dark' | 'black' | 'text' | 'ghost';
|
|
10
18
|
/** Size of the button. */
|
|
@@ -39,27 +47,28 @@ export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonE
|
|
|
39
47
|
textColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
40
48
|
/** Background color helper. */
|
|
41
49
|
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
42
|
-
/** Render as a `<button>`, `<a>`, or a custom component (e.g. a router `Link`). Defaults to `'button'`; anything else (including `'a'`) uses anchor-style prop handling. */
|
|
43
|
-
as?: React.ElementType;
|
|
44
|
-
/** Href value (if rendering as `<a>`). */
|
|
45
|
-
href?: string;
|
|
46
|
-
/** Click event handler. */
|
|
47
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | React.MouseEventHandler<HTMLAnchorElement>;
|
|
48
|
-
/** Anchor tag target. */
|
|
49
|
-
target?: string;
|
|
50
|
-
/** Anchor tag rel. */
|
|
51
|
-
rel?: string;
|
|
52
50
|
/** Button content. */
|
|
53
51
|
children?: React.ReactNode;
|
|
54
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Props for the Button component. The DOM attributes and the `ref` both follow
|
|
55
|
+
* `as`: with `as="a"` the anchor attributes are accepted, with `as="div"` they
|
|
56
|
+
* are not.
|
|
57
|
+
*
|
|
58
|
+
* @extraProp {PolymorphicRef<React.ElementType>} [ref] - Ref forwarded to the element `as` renders, typed from `as`: the DOM node for an intrinsic tag, or whatever handle a custom component exposes.
|
|
59
|
+
*/
|
|
60
|
+
export type ButtonProps<T extends React.ElementType = 'button'> = ButtonOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof ButtonOwnProps | 'as'> & {
|
|
61
|
+
/** Render as a `<button>`, `<a>`, or a custom component (e.g. a router `Link`). Defaults to `'button'`; anything else renders through the anchor path, which adds `href`/`target`/`rel` and withholds the submit-override attributes (`formAction` and friends) from an `<a>`. */
|
|
62
|
+
as?: T;
|
|
63
|
+
};
|
|
55
64
|
/**
|
|
56
65
|
* The `Button` component provides a flexible and highly customizable button for your Bulma React UI.
|
|
57
66
|
*
|
|
58
67
|
* @function
|
|
59
68
|
* @param {ButtonProps} props - Props for the Button component.
|
|
60
|
-
* @param {React.Ref
|
|
61
|
-
* @returns {JSX.Element} The rendered button or
|
|
69
|
+
* @param {React.Ref} ref - Forwarded ref to the element `as` renders.
|
|
70
|
+
* @returns {JSX.Element} The rendered button, anchor, or custom element.
|
|
62
71
|
* @see {@link https://bulma.io/documentation/elements/button/ | Bulma Button documentation}
|
|
63
72
|
*/
|
|
64
|
-
export declare const Button:
|
|
73
|
+
export declare const Button: PolymorphicComponent<ButtonOwnProps, "button">;
|
|
65
74
|
export default Button;
|
|
@@ -34,7 +34,7 @@ interface ButtonsProps extends React.HTMLAttributes<HTMLDivElement>, Omit<BulmaC
|
|
|
34
34
|
children: React.ReactNode;
|
|
35
35
|
}
|
|
36
36
|
export declare const Buttons: React.FC<ButtonsProps> & {
|
|
37
|
-
Button:
|
|
38
|
-
LinkButton:
|
|
37
|
+
Button: import("..").PolymorphicComponent<import("./Button").ButtonOwnProps, "button">;
|
|
38
|
+
LinkButton: import("..").PolymorphicComponent<import("./LinkButton").LinkButtonOwnProps, "button">;
|
|
39
39
|
};
|
|
40
40
|
export {};
|
|
@@ -33,7 +33,14 @@ interface IconBaseProps extends React.HTMLAttributes<HTMLSpanElement>, BulmaClas
|
|
|
33
33
|
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
|
|
34
34
|
/** Background color helper. */
|
|
35
35
|
bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Legacy icon class string (e.g. `'fas fa-star'`). Only its last segment is read, as the
|
|
38
|
+
* glyph name; the library still comes from `library` or `ConfigProvider`, so
|
|
39
|
+
* `'mdi mdi-rocket'` renders an `fa` class unless the effective library is already `mdi` —
|
|
40
|
+
* set it here or on the provider.
|
|
41
|
+
*
|
|
42
|
+
* @deprecated Use `name` instead.
|
|
43
|
+
*/
|
|
37
44
|
icon?: string;
|
|
38
45
|
/**
|
|
39
46
|
* The icon library to use ('fa' = Font Awesome, 'mdi' = Material Design Icons, 'ion' = Ionicons Web Components, 'material-icons' = Google Material Icons, 'material-symbols' = Google Material Symbols). Defaults to the value set in ConfigProvider or 'fa' if not configured. Ignored when `children` supplies the glyph instead of `name`.
|
|
@@ -44,7 +51,11 @@ interface IconBaseProps extends React.HTMLAttributes<HTMLSpanElement>, BulmaClas
|
|
|
44
51
|
variant?: string;
|
|
45
52
|
/** Additional modifiers (e.g. `'fa-lg'`, `'fa-spin'`, `'is-size-1'`). Ignored when `children` supplies the glyph instead of `name`. */
|
|
46
53
|
features?: string | string[];
|
|
47
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Additional modifiers in the older combined form, parsed into `variant` and `features`.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated Use `variant` and `features` instead.
|
|
58
|
+
*/
|
|
48
59
|
libraryFeatures?: string | string[];
|
|
49
60
|
/** Size modifier for the icon container. */
|
|
50
61
|
size?: 'small' | 'medium' | 'large';
|
|
@@ -83,10 +94,38 @@ export interface IconChildrenProps extends IconBaseProps {
|
|
|
83
94
|
children: Exclude<React.ReactNode, undefined>;
|
|
84
95
|
}
|
|
85
96
|
/**
|
|
86
|
-
* Props for
|
|
87
|
-
*
|
|
97
|
+
* Props for `Icon` naming its glyph through the deprecated `icon` prop instead of `name`.
|
|
98
|
+
*
|
|
99
|
+
* The runtime has always accepted `icon` on its own — it strips a leading library prefix off
|
|
100
|
+
* the class string and falls through to the `name` path — but the type offered no member without
|
|
101
|
+
* a `name` or `children`, so every caller still on the deprecated prop got an error the
|
|
102
|
+
* package could not see — until #663 nothing here type-checked a test or a story, so the
|
|
103
|
+
* three `Icon.test.tsx` cases exercising this path proved the runtime and said nothing about
|
|
104
|
+
* the type. Declaring the path is the honest resolution: it is deprecated, not removed, and a
|
|
105
|
+
* deprecation that does not type-check is a removal announced only to whoever tries it.
|
|
106
|
+
*
|
|
107
|
+
* @deprecated Pass `name` instead. This member goes when `icon` does.
|
|
108
|
+
*/
|
|
109
|
+
export interface IconDeprecatedProps extends IconBaseProps {
|
|
110
|
+
/**
|
|
111
|
+
* Legacy icon class string (e.g. `'fas fa-star'`). Only its last segment is read, as the
|
|
112
|
+
* glyph name; the library still comes from `library` or `ConfigProvider`, so
|
|
113
|
+
* `'mdi mdi-rocket'` renders an `fa` class unless the effective library is already `mdi` —
|
|
114
|
+
* set it here or on the provider.
|
|
115
|
+
*
|
|
116
|
+
* @deprecated Use `name` instead.
|
|
117
|
+
*/
|
|
118
|
+
icon: string;
|
|
119
|
+
/** The icon name. Absent on this path — `icon` supplies the glyph. */
|
|
120
|
+
name?: undefined;
|
|
121
|
+
/** A custom node. Mutually exclusive with `icon`. */
|
|
122
|
+
children?: never;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Props for the Icon component — a discriminated union of a class-based `name`, a custom
|
|
126
|
+
* `children` node, and the deprecated `icon` class string.
|
|
88
127
|
*/
|
|
89
|
-
export type IconProps = IconNameProps | IconChildrenProps;
|
|
128
|
+
export type IconProps = IconNameProps | IconChildrenProps | IconDeprecatedProps;
|
|
90
129
|
/**
|
|
91
130
|
* The `Icon` component is a Bulma-styled wrapper for displaying icons from various libraries (Font Awesome, Material Design Icons, Ionicons, Google Material Icons, Material Symbols, etc.).
|
|
92
131
|
*
|