@allxsmith/bestax-bulma 5.16.7 → 5.16.8

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.
@@ -32,11 +32,11 @@ export interface AvatarOwnProps extends Omit<BulmaClassesProps, 'color'> {
32
32
  shape?: AvatarShape;
33
33
  /** Background color for initials/icon avatars (else auto-derived from `name`). */
34
34
  color?: AvatarColor;
35
- /** When set, renders the avatar as a link. */
35
+ /** When set, renders the avatar as a link: an `<a>` unless `as` names the element itself. An `as` target declaring its own `href` supersedes this one, and its type and its requiredness are what apply. */
36
36
  href?: string;
37
- /** Anchor target — forwarded only when rendering a link (an `a` or a custom `as` component). */
37
+ /** Anchor target — forwarded only when rendering a link (an `a` or a custom `as` component), and superseded by the target's own declaration the way `href` is. */
38
38
  target?: string;
39
- /** Anchor rel — forwarded only when rendering a link (an `a` or a custom `as` component). */
39
+ /** Anchor rel — forwarded only when rendering a link (an `a` or a custom `as` component), and superseded by the target's own declaration the way `href` is. */
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>;
@@ -51,14 +51,23 @@ export interface AvatarOwnProps extends Omit<BulmaClassesProps, 'color'> {
51
51
  */
52
52
  children?: never;
53
53
  }
54
+ /**
55
+ * The own props Avatar hands to the element `as` names rather than consuming.
56
+ *
57
+ * They are what *chooses* the element when `as` is absent — an `<a>` with an
58
+ * `href`, a `<figure>` without one — so Avatar has to accept them before `as` is
59
+ * known. Declaring them is only half of it. `PolymorphicProps` explains what
60
+ * naming them here buys, and what leaving them unnamed cost (#665).
61
+ */
62
+ type AvatarForwardedProp = 'href' | 'target' | 'rel';
54
63
  /**
55
64
  * Props for the Avatar component. The DOM attributes and the `ref` both follow
56
65
  * `as`.
57
66
  *
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.
67
+ * `href`, `target` and `rel` are Avatar's own props only for a target that has
68
+ * none of its own: `<Avatar href="/x" />` needs no `as`, while
69
+ * `<Avatar as={NextLink} />` takes `next/link`'s `href` — required, and a URL
70
+ * object as readily as a string.
62
71
  *
63
72
  * The type parameter defaults to `'figure'`, not to `React.ElementType`.
64
73
  * Defaulting to the constraint sounds truer to a runtime default that is
@@ -70,7 +79,7 @@ export interface AvatarOwnProps extends Omit<BulmaClassesProps, 'color'> {
70
79
  *
71
80
  * @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
81
  */
73
- export type AvatarProps<T extends React.ElementType = 'figure'> = AvatarOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof AvatarOwnProps | 'as'> & {
82
+ export type AvatarProps<T extends React.ElementType = 'figure'> = Omit<AvatarOwnProps, Extract<AvatarForwardedProp, keyof React.ComponentPropsWithoutRef<T>>> & Omit<React.ComponentPropsWithoutRef<T>, Exclude<keyof AvatarOwnProps, AvatarForwardedProp> | 'as'> & {
74
83
  /** Element/component to render as. Defaults to `'a'` when `href` is set, else `'figure'`. */
75
84
  as?: T;
76
85
  };
@@ -87,5 +96,5 @@ export type AvatarProps<T extends React.ElementType = 'figure'> = AvatarOwnProps
87
96
  * @example
88
97
  * <Avatar name="Grace Hopper" />
89
98
  */
90
- export declare const Avatar: PolymorphicComponent<AvatarOwnProps, "figure">;
99
+ export declare const Avatar: PolymorphicComponent<AvatarOwnProps, "figure", AvatarForwardedProp>;
91
100
  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: import("../index.js").PolymorphicComponent<import("./Avatar.js").AvatarOwnProps, "figure">;
28
+ Avatar: import("../index.js").PolymorphicComponent<import("./Avatar.js").AvatarOwnProps, "figure", "rel" | "href" | "target">;
29
29
  };
30
30
  export default Avatars;
@@ -98,7 +98,7 @@ export declare const DropdownItem: ConstrainedPolymorphicComponentWithoutRef<Dro
98
98
  export declare const DropdownDivider: React.FC;
99
99
  /** Bulma Dropdown component with Item and Divider sub-components. */
100
100
  export declare const Dropdown: React.ForwardRefExoticComponent<DropdownProps & React.RefAttributes<HTMLDivElement>> & {
101
- Item: ConstrainedPolymorphicComponentWithoutRef<DropdownItemOwnProps, DropdownItemElement, "a">;
101
+ Item: ConstrainedPolymorphicComponentWithoutRef<DropdownItemOwnProps, DropdownItemElement, "a", never>;
102
102
  Divider: React.FC<{}>;
103
103
  };
104
104
  export default Dropdown;
@@ -95,6 +95,6 @@ export declare const MenuItem: PolymorphicComponent<MenuItemOwnProps, "a">;
95
95
  export declare const Menu: React.FC<MenuProps> & {
96
96
  Label: React.FC<MenuLabelProps>;
97
97
  List: React.FC<MenuListProps>;
98
- Item: PolymorphicComponent<MenuItemOwnProps, "a">;
98
+ Item: PolymorphicComponent<MenuItemOwnProps, "a", never>;
99
99
  };
100
100
  export default Menu;
@@ -289,8 +289,8 @@ export declare const NavbarDropdownMenu: React.FC<NavbarDropdownMenuProps>;
289
289
  export declare const NavbarDivider: React.FC<React.HTMLAttributes<HTMLHRElement>>;
290
290
  export declare const Navbar: React.ForwardRefExoticComponent<NavbarProps & React.RefAttributes<HTMLElement>> & {
291
291
  Brand: React.FC<NavbarBrandProps>;
292
- Item: PolymorphicComponent<NavbarItemOwnProps, "a">;
293
- Link: PolymorphicComponent<NavbarLinkOwnProps, "a">;
292
+ Item: PolymorphicComponent<NavbarItemOwnProps, "a", never>;
293
+ Link: PolymorphicComponent<NavbarLinkOwnProps, "a", never>;
294
294
  Burger: React.ForwardRefExoticComponent<NavbarBurgerProps & React.RefAttributes<HTMLButtonElement>>;
295
295
  Menu: React.FC<NavbarMenuProps>;
296
296
  Start: React.FC<NavbarStartEndProps>;
@@ -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: import("../index.js").PolymorphicComponent<import("./Button.js").ButtonOwnProps, "button">;
38
- LinkButton: import("../index.js").PolymorphicComponent<import("./LinkButton.js").LinkButtonOwnProps, "button">;
37
+ Button: import("../index.js").PolymorphicComponent<import("./Button.js").ButtonOwnProps, "button", never>;
38
+ LinkButton: import("../index.js").PolymorphicComponent<import("./LinkButton.js").LinkButtonOwnProps, "button", never>;
39
39
  };
40
40
  export {};
@@ -29,14 +29,44 @@ export type PolymorphicRef<T extends React.ElementType> = 'ref' extends keyof Re
29
29
  /**
30
30
  * A component's own props, plus the attributes of the element `as` names.
31
31
  *
32
- * `Own` wins every collision — a component that declares `color` as a Bulma
33
- * variant keeps it, rather than inheriting the DOM attribute of the same name.
34
- * That subtraction is the ONLY one. `color` used to be dropped here as well, to
35
- * stop the deprecated presentational HTML attribute reaching the three
36
- * components whose own props do not declare one — but doing it in the shared
37
- * type also stripped `color` from a CUSTOM target that legitimately has one.
38
- * Those three declare `color?: never` themselves instead, which lands in
39
- * `keyof Own` and reaches the same result without a special case here.
32
+ * `Own` wins a collision by default — a component that declares
33
+ * `color` as a Bulma variant keeps it, rather than inheriting the DOM attribute
34
+ * of the same name. `color` used to be dropped here as well, to stop the
35
+ * deprecated presentational HTML attribute reaching the components whose own
36
+ * props do not declare one — but doing it in the shared type also stripped
37
+ * `color` from a CUSTOM target that legitimately has one. Those components
38
+ * declare `color?: never` themselves instead, which lands in `keyof Own` and
39
+ * reaches the same result without a special case here.
40
+ *
41
+ * `Forwarded` names the own props the component hands STRAIGHT to the target
42
+ * instead of consuming, and the subtraction runs the other way for them: the
43
+ * TARGET's declaration wins, and the own one is what covers a target that has
44
+ * no such prop. Subtracting them threw the target's declaration away, so an
45
+ * OPTIONAL own prop hid a REQUIRED one — `<Avatar as={NextLink} name="Ada" />`
46
+ * compiled because Avatar's `href?: string` survived while `next/link`'s
47
+ * required `href` was omitted, and the target threw on what it never received
48
+ * (#665). The target wins rather than both declarations applying at once,
49
+ * because for a prop the component only passes along its own type has no
50
+ * standing: `next/link` accepts a URL object as well as a string, and
51
+ * intersecting Avatar's `string` with that would refuse the object.
52
+ *
53
+ * `Forwarded` defaults to `never`, so a prop the component CONSUMES stays
54
+ * subtracted — the common case, and the one `color` needs. What that costs is
55
+ * that a target REQUIRING a consumed prop is still satisfiable with the prop
56
+ * omitted, and the value goes wherever the component sends it: `Menu.Item`
57
+ * spends several of its own props on its wrapping `<li>`, `title` and `style`
58
+ * among them, so a target requiring one of those never sees it. Erroring on
59
+ * that needs a category this pair cannot express, since `className` is consumed
60
+ * too and yet every component composes one and passes it on. It is pinned as a
61
+ * limitation in `__typetests__/polymorphic.tsx` rather than guessed at here.
62
+ *
63
+ * `Own` is returned untouched when nothing is forwarded, rather than run through
64
+ * an `Omit` that names no keys. `Omit` is not the identity it looks like: it
65
+ * keys off `keyof Own`, which for a UNION `Own` is only what the members share,
66
+ * so `PolymorphicProps<'div', A | B>` lost every prop of both. It is public API
67
+ * and a consumer's wrapper can pass a union; the untouched branch also keeps
68
+ * each own prop's TSDoc reaching an IDE, which a mapped type drops. The
69
+ * forwarded branch distributes over `Own` for the same reason.
40
70
  *
41
71
  * Distributive over `T` on purpose. `Omit<A | B, K>` keys off `keyof (A | B)`,
42
72
  * which is only what A and B share — so a union-typed `as` (a ternary, or a
@@ -51,7 +81,7 @@ export type PolymorphicRef<T extends React.ElementType> = 'ref' extends keyof Re
51
81
  * This type is here for the component's cast target and for consumers writing
52
82
  * wrappers.
53
83
  */
54
- export type PolymorphicProps<T extends React.ElementType, Own> = T extends unknown ? Own & Omit<React.ComponentPropsWithoutRef<T>, keyof Own | 'as'> & {
84
+ export type PolymorphicProps<T extends React.ElementType, Own, Forwarded extends keyof Own = never> = T extends unknown ? ([Forwarded] extends [never] ? Own : Own extends unknown ? Omit<Own, Extract<Forwarded, keyof React.ComponentPropsWithoutRef<T>>> : never) & Omit<React.ComponentPropsWithoutRef<T>, Exclude<keyof Own, Forwarded> | 'as'> & {
55
85
  /** The element or component to render. */
56
86
  as?: T;
57
87
  } : never;
@@ -86,11 +116,11 @@ export type PolymorphicProps<T extends React.ElementType, Own> = T extends unkno
86
116
  * const MemoButton = React.memo(Button) as typeof Button;
87
117
  * ```
88
118
  */
89
- export interface PolymorphicComponent<Own, Default extends React.ElementType> {
90
- <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own> & {
119
+ export interface PolymorphicComponent<Own, Default extends React.ElementType, Forwarded extends keyof Own = never> {
120
+ <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own, Forwarded> & {
91
121
  ref?: PolymorphicRef<T>;
92
122
  }): React.ReactElement | null;
93
- (props: PolymorphicProps<Default, Own> & {
123
+ (props: PolymorphicProps<Default, Own, Forwarded> & {
94
124
  ref?: PolymorphicRef<Default>;
95
125
  }): React.ReactElement | null;
96
126
  displayName?: string;
@@ -101,10 +131,14 @@ export interface PolymorphicComponent<Own, Default extends React.ElementType> {
101
131
  * For components that own the node they observe — `Reveal` keeps its own ref on
102
132
  * the element it watches for scroll intersection, which is not always the
103
133
  * element `as` names.
134
+ *
135
+ * It carries `Forwarded` even with no component passing one today: the default
136
+ * is the behaviour without it, and a component that grows a forwarded own prop
137
+ * would otherwise reintroduce #665 here with nothing to say so.
104
138
  */
105
- export interface PolymorphicComponentWithoutRef<Own, Default extends React.ElementType> {
106
- <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own>): React.ReactElement | null;
107
- (props: PolymorphicProps<Default, Own>): React.ReactElement | null;
139
+ export interface PolymorphicComponentWithoutRef<Own, Default extends React.ElementType, Forwarded extends keyof Own = never> {
140
+ <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own, Forwarded>): React.ReactElement | null;
141
+ (props: PolymorphicProps<Default, Own, Forwarded>): React.ReactElement | null;
108
142
  displayName?: string;
109
143
  }
110
144
  /**
@@ -131,8 +165,8 @@ export interface PolymorphicComponentWithoutRef<Own, Default extends React.Eleme
131
165
  * than losing every prop the members do not share. Narrowing it is not a
132
166
  * constrained-component question; it would have to change for `Button` first.
133
167
  */
134
- export interface ConstrainedPolymorphicComponentWithoutRef<Own, Allowed extends React.ElementType, Default extends Allowed> {
135
- <T extends Allowed = Default>(props: PolymorphicProps<T, Own>): React.ReactElement | null;
136
- (props: PolymorphicProps<Default, Own>): React.ReactElement | null;
168
+ export interface ConstrainedPolymorphicComponentWithoutRef<Own, Allowed extends React.ElementType, Default extends Allowed, Forwarded extends keyof Own = never> {
169
+ <T extends Allowed = Default>(props: PolymorphicProps<T, Own, Forwarded>): React.ReactElement | null;
170
+ (props: PolymorphicProps<Default, Own, Forwarded>): React.ReactElement | null;
137
171
  displayName?: string;
138
172
  }
@@ -32,11 +32,11 @@ export interface AvatarOwnProps extends Omit<BulmaClassesProps, 'color'> {
32
32
  shape?: AvatarShape;
33
33
  /** Background color for initials/icon avatars (else auto-derived from `name`). */
34
34
  color?: AvatarColor;
35
- /** When set, renders the avatar as a link. */
35
+ /** When set, renders the avatar as a link: an `<a>` unless `as` names the element itself. An `as` target declaring its own `href` supersedes this one, and its type and its requiredness are what apply. */
36
36
  href?: string;
37
- /** Anchor target — forwarded only when rendering a link (an `a` or a custom `as` component). */
37
+ /** Anchor target — forwarded only when rendering a link (an `a` or a custom `as` component), and superseded by the target's own declaration the way `href` is. */
38
38
  target?: string;
39
- /** Anchor rel — forwarded only when rendering a link (an `a` or a custom `as` component). */
39
+ /** Anchor rel — forwarded only when rendering a link (an `a` or a custom `as` component), and superseded by the target's own declaration the way `href` is. */
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>;
@@ -51,14 +51,23 @@ export interface AvatarOwnProps extends Omit<BulmaClassesProps, 'color'> {
51
51
  */
52
52
  children?: never;
53
53
  }
54
+ /**
55
+ * The own props Avatar hands to the element `as` names rather than consuming.
56
+ *
57
+ * They are what *chooses* the element when `as` is absent — an `<a>` with an
58
+ * `href`, a `<figure>` without one — so Avatar has to accept them before `as` is
59
+ * known. Declaring them is only half of it. `PolymorphicProps` explains what
60
+ * naming them here buys, and what leaving them unnamed cost (#665).
61
+ */
62
+ type AvatarForwardedProp = 'href' | 'target' | 'rel';
54
63
  /**
55
64
  * Props for the Avatar component. The DOM attributes and the `ref` both follow
56
65
  * `as`.
57
66
  *
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.
67
+ * `href`, `target` and `rel` are Avatar's own props only for a target that has
68
+ * none of its own: `<Avatar href="/x" />` needs no `as`, while
69
+ * `<Avatar as={NextLink} />` takes `next/link`'s `href` — required, and a URL
70
+ * object as readily as a string.
62
71
  *
63
72
  * The type parameter defaults to `'figure'`, not to `React.ElementType`.
64
73
  * Defaulting to the constraint sounds truer to a runtime default that is
@@ -70,7 +79,7 @@ export interface AvatarOwnProps extends Omit<BulmaClassesProps, 'color'> {
70
79
  *
71
80
  * @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
81
  */
73
- export type AvatarProps<T extends React.ElementType = 'figure'> = AvatarOwnProps & Omit<React.ComponentPropsWithoutRef<T>, keyof AvatarOwnProps | 'as'> & {
82
+ export type AvatarProps<T extends React.ElementType = 'figure'> = Omit<AvatarOwnProps, Extract<AvatarForwardedProp, keyof React.ComponentPropsWithoutRef<T>>> & Omit<React.ComponentPropsWithoutRef<T>, Exclude<keyof AvatarOwnProps, AvatarForwardedProp> | 'as'> & {
74
83
  /** Element/component to render as. Defaults to `'a'` when `href` is set, else `'figure'`. */
75
84
  as?: T;
76
85
  };
@@ -87,5 +96,5 @@ export type AvatarProps<T extends React.ElementType = 'figure'> = AvatarOwnProps
87
96
  * @example
88
97
  * <Avatar name="Grace Hopper" />
89
98
  */
90
- export declare const Avatar: PolymorphicComponent<AvatarOwnProps, "figure">;
99
+ export declare const Avatar: PolymorphicComponent<AvatarOwnProps, "figure", AvatarForwardedProp>;
91
100
  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: import("../index.js").PolymorphicComponent<import("./Avatar.js").AvatarOwnProps, "figure">;
28
+ Avatar: import("../index.js").PolymorphicComponent<import("./Avatar.js").AvatarOwnProps, "figure", "rel" | "href" | "target">;
29
29
  };
30
30
  export default Avatars;
@@ -98,7 +98,7 @@ export declare const DropdownItem: ConstrainedPolymorphicComponentWithoutRef<Dro
98
98
  export declare const DropdownDivider: React.FC;
99
99
  /** Bulma Dropdown component with Item and Divider sub-components. */
100
100
  export declare const Dropdown: React.ForwardRefExoticComponent<DropdownProps & React.RefAttributes<HTMLDivElement>> & {
101
- Item: ConstrainedPolymorphicComponentWithoutRef<DropdownItemOwnProps, DropdownItemElement, "a">;
101
+ Item: ConstrainedPolymorphicComponentWithoutRef<DropdownItemOwnProps, DropdownItemElement, "a", never>;
102
102
  Divider: React.FC<{}>;
103
103
  };
104
104
  export default Dropdown;
@@ -95,6 +95,6 @@ export declare const MenuItem: PolymorphicComponent<MenuItemOwnProps, "a">;
95
95
  export declare const Menu: React.FC<MenuProps> & {
96
96
  Label: React.FC<MenuLabelProps>;
97
97
  List: React.FC<MenuListProps>;
98
- Item: PolymorphicComponent<MenuItemOwnProps, "a">;
98
+ Item: PolymorphicComponent<MenuItemOwnProps, "a", never>;
99
99
  };
100
100
  export default Menu;
@@ -289,8 +289,8 @@ export declare const NavbarDropdownMenu: React.FC<NavbarDropdownMenuProps>;
289
289
  export declare const NavbarDivider: React.FC<React.HTMLAttributes<HTMLHRElement>>;
290
290
  export declare const Navbar: React.ForwardRefExoticComponent<NavbarProps & React.RefAttributes<HTMLElement>> & {
291
291
  Brand: React.FC<NavbarBrandProps>;
292
- Item: PolymorphicComponent<NavbarItemOwnProps, "a">;
293
- Link: PolymorphicComponent<NavbarLinkOwnProps, "a">;
292
+ Item: PolymorphicComponent<NavbarItemOwnProps, "a", never>;
293
+ Link: PolymorphicComponent<NavbarLinkOwnProps, "a", never>;
294
294
  Burger: React.ForwardRefExoticComponent<NavbarBurgerProps & React.RefAttributes<HTMLButtonElement>>;
295
295
  Menu: React.FC<NavbarMenuProps>;
296
296
  Start: React.FC<NavbarStartEndProps>;
@@ -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: import("../index.js").PolymorphicComponent<import("./Button.js").ButtonOwnProps, "button">;
38
- LinkButton: import("../index.js").PolymorphicComponent<import("./LinkButton.js").LinkButtonOwnProps, "button">;
37
+ Button: import("../index.js").PolymorphicComponent<import("./Button.js").ButtonOwnProps, "button", never>;
38
+ LinkButton: import("../index.js").PolymorphicComponent<import("./LinkButton.js").LinkButtonOwnProps, "button", never>;
39
39
  };
40
40
  export {};
@@ -29,14 +29,44 @@ export type PolymorphicRef<T extends React.ElementType> = 'ref' extends keyof Re
29
29
  /**
30
30
  * A component's own props, plus the attributes of the element `as` names.
31
31
  *
32
- * `Own` wins every collision — a component that declares `color` as a Bulma
33
- * variant keeps it, rather than inheriting the DOM attribute of the same name.
34
- * That subtraction is the ONLY one. `color` used to be dropped here as well, to
35
- * stop the deprecated presentational HTML attribute reaching the three
36
- * components whose own props do not declare one — but doing it in the shared
37
- * type also stripped `color` from a CUSTOM target that legitimately has one.
38
- * Those three declare `color?: never` themselves instead, which lands in
39
- * `keyof Own` and reaches the same result without a special case here.
32
+ * `Own` wins a collision by default — a component that declares
33
+ * `color` as a Bulma variant keeps it, rather than inheriting the DOM attribute
34
+ * of the same name. `color` used to be dropped here as well, to stop the
35
+ * deprecated presentational HTML attribute reaching the components whose own
36
+ * props do not declare one — but doing it in the shared type also stripped
37
+ * `color` from a CUSTOM target that legitimately has one. Those components
38
+ * declare `color?: never` themselves instead, which lands in `keyof Own` and
39
+ * reaches the same result without a special case here.
40
+ *
41
+ * `Forwarded` names the own props the component hands STRAIGHT to the target
42
+ * instead of consuming, and the subtraction runs the other way for them: the
43
+ * TARGET's declaration wins, and the own one is what covers a target that has
44
+ * no such prop. Subtracting them threw the target's declaration away, so an
45
+ * OPTIONAL own prop hid a REQUIRED one — `<Avatar as={NextLink} name="Ada" />`
46
+ * compiled because Avatar's `href?: string` survived while `next/link`'s
47
+ * required `href` was omitted, and the target threw on what it never received
48
+ * (#665). The target wins rather than both declarations applying at once,
49
+ * because for a prop the component only passes along its own type has no
50
+ * standing: `next/link` accepts a URL object as well as a string, and
51
+ * intersecting Avatar's `string` with that would refuse the object.
52
+ *
53
+ * `Forwarded` defaults to `never`, so a prop the component CONSUMES stays
54
+ * subtracted — the common case, and the one `color` needs. What that costs is
55
+ * that a target REQUIRING a consumed prop is still satisfiable with the prop
56
+ * omitted, and the value goes wherever the component sends it: `Menu.Item`
57
+ * spends several of its own props on its wrapping `<li>`, `title` and `style`
58
+ * among them, so a target requiring one of those never sees it. Erroring on
59
+ * that needs a category this pair cannot express, since `className` is consumed
60
+ * too and yet every component composes one and passes it on. It is pinned as a
61
+ * limitation in `__typetests__/polymorphic.tsx` rather than guessed at here.
62
+ *
63
+ * `Own` is returned untouched when nothing is forwarded, rather than run through
64
+ * an `Omit` that names no keys. `Omit` is not the identity it looks like: it
65
+ * keys off `keyof Own`, which for a UNION `Own` is only what the members share,
66
+ * so `PolymorphicProps<'div', A | B>` lost every prop of both. It is public API
67
+ * and a consumer's wrapper can pass a union; the untouched branch also keeps
68
+ * each own prop's TSDoc reaching an IDE, which a mapped type drops. The
69
+ * forwarded branch distributes over `Own` for the same reason.
40
70
  *
41
71
  * Distributive over `T` on purpose. `Omit<A | B, K>` keys off `keyof (A | B)`,
42
72
  * which is only what A and B share — so a union-typed `as` (a ternary, or a
@@ -51,7 +81,7 @@ export type PolymorphicRef<T extends React.ElementType> = 'ref' extends keyof Re
51
81
  * This type is here for the component's cast target and for consumers writing
52
82
  * wrappers.
53
83
  */
54
- export type PolymorphicProps<T extends React.ElementType, Own> = T extends unknown ? Own & Omit<React.ComponentPropsWithoutRef<T>, keyof Own | 'as'> & {
84
+ export type PolymorphicProps<T extends React.ElementType, Own, Forwarded extends keyof Own = never> = T extends unknown ? ([Forwarded] extends [never] ? Own : Own extends unknown ? Omit<Own, Extract<Forwarded, keyof React.ComponentPropsWithoutRef<T>>> : never) & Omit<React.ComponentPropsWithoutRef<T>, Exclude<keyof Own, Forwarded> | 'as'> & {
55
85
  /** The element or component to render. */
56
86
  as?: T;
57
87
  } : never;
@@ -86,11 +116,11 @@ export type PolymorphicProps<T extends React.ElementType, Own> = T extends unkno
86
116
  * const MemoButton = React.memo(Button) as typeof Button;
87
117
  * ```
88
118
  */
89
- export interface PolymorphicComponent<Own, Default extends React.ElementType> {
90
- <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own> & {
119
+ export interface PolymorphicComponent<Own, Default extends React.ElementType, Forwarded extends keyof Own = never> {
120
+ <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own, Forwarded> & {
91
121
  ref?: PolymorphicRef<T>;
92
122
  }): React.ReactElement | null;
93
- (props: PolymorphicProps<Default, Own> & {
123
+ (props: PolymorphicProps<Default, Own, Forwarded> & {
94
124
  ref?: PolymorphicRef<Default>;
95
125
  }): React.ReactElement | null;
96
126
  displayName?: string;
@@ -101,10 +131,14 @@ export interface PolymorphicComponent<Own, Default extends React.ElementType> {
101
131
  * For components that own the node they observe — `Reveal` keeps its own ref on
102
132
  * the element it watches for scroll intersection, which is not always the
103
133
  * element `as` names.
134
+ *
135
+ * It carries `Forwarded` even with no component passing one today: the default
136
+ * is the behaviour without it, and a component that grows a forwarded own prop
137
+ * would otherwise reintroduce #665 here with nothing to say so.
104
138
  */
105
- export interface PolymorphicComponentWithoutRef<Own, Default extends React.ElementType> {
106
- <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own>): React.ReactElement | null;
107
- (props: PolymorphicProps<Default, Own>): React.ReactElement | null;
139
+ export interface PolymorphicComponentWithoutRef<Own, Default extends React.ElementType, Forwarded extends keyof Own = never> {
140
+ <T extends React.ElementType = Default>(props: PolymorphicProps<T, Own, Forwarded>): React.ReactElement | null;
141
+ (props: PolymorphicProps<Default, Own, Forwarded>): React.ReactElement | null;
108
142
  displayName?: string;
109
143
  }
110
144
  /**
@@ -131,8 +165,8 @@ export interface PolymorphicComponentWithoutRef<Own, Default extends React.Eleme
131
165
  * than losing every prop the members do not share. Narrowing it is not a
132
166
  * constrained-component question; it would have to change for `Button` first.
133
167
  */
134
- export interface ConstrainedPolymorphicComponentWithoutRef<Own, Allowed extends React.ElementType, Default extends Allowed> {
135
- <T extends Allowed = Default>(props: PolymorphicProps<T, Own>): React.ReactElement | null;
136
- (props: PolymorphicProps<Default, Own>): React.ReactElement | null;
168
+ export interface ConstrainedPolymorphicComponentWithoutRef<Own, Allowed extends React.ElementType, Default extends Allowed, Forwarded extends keyof Own = never> {
169
+ <T extends Allowed = Default>(props: PolymorphicProps<T, Own, Forwarded>): React.ReactElement | null;
170
+ (props: PolymorphicProps<Default, Own, Forwarded>): React.ReactElement | null;
137
171
  displayName?: string;
138
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allxsmith/bestax-bulma",
3
- "version": "5.16.7",
3
+ "version": "5.16.8",
4
4
  "description": "A fully-typed React component library for the Bulma CSS framework. Build modern UIs quickly with reusable, accessible, and customizable Bulma-based React components.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.esm.js",