@allxsmith/bestax-bulma 5.15.3 → 5.15.4
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 +129 -57
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +129 -57
- package/dist/index.esm.js.map +1 -1
- package/dist/types/helpers/anchorAttrs.d.ts +37 -0
- package/dist/types/layout/Level.d.ts +6 -23
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Exactly what `<a>` adds over the attributes every element has: `href`,
|
|
4
|
+
* `target`, `download`, `hrefLang`, `ping`, `referrerPolicy`, `media`, `type`.
|
|
5
|
+
*
|
|
6
|
+
* Subtracted from React's own types rather than listed. Listing them is how
|
|
7
|
+
* `Level.Item` came to reject `download` at `as="a"` — its list said `href`,
|
|
8
|
+
* `target`, `rel` and stopped (#641). A list gains an entry when someone
|
|
9
|
+
* notices; a subtraction gains it when React does.
|
|
10
|
+
*
|
|
11
|
+
* NOT `rel`: React declares it on `HTMLAttributes`, for every element, so the
|
|
12
|
+
* subtraction removes it. A component that withholds `rel` from a non-anchor is
|
|
13
|
+
* making a compatibility choice rather than stating a fact about anchors, and
|
|
14
|
+
* says so where it makes it.
|
|
15
|
+
*/
|
|
16
|
+
export type AnchorOnlyAttributes = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof React.HTMLAttributes<HTMLAnchorElement>>;
|
|
17
|
+
/**
|
|
18
|
+
* The runtime mirror of `AnchorOnlyAttributes`, keyed so the two cannot drift.
|
|
19
|
+
*
|
|
20
|
+
* `Record<keyof …, true>` is what links them: the day React adds an anchor
|
|
21
|
+
* attribute, every component deriving its props from `as` accepts it and this
|
|
22
|
+
* object stops compiling until it is named here. A plain array beside a derived
|
|
23
|
+
* type drifts in the one direction that matters — the type accepts the new
|
|
24
|
+
* attribute and the filter lets it leak onto a `<div>`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ANCHOR_ONLY_ATTRS: Readonly<Record<keyof AnchorOnlyAttributes, true>>;
|
|
27
|
+
/**
|
|
28
|
+
* `props` without the keys named in `strip`.
|
|
29
|
+
*
|
|
30
|
+
* The SET is per component and deliberately not shared, because the right
|
|
31
|
+
* answer differs and the differences are principled: how open the component's
|
|
32
|
+
* `as` is, and which of these attributes its own tags legitimately take. What
|
|
33
|
+
* IS shared is the derived source of truth above and this function. Each caller
|
|
34
|
+
* declares its delta next to the set it passes, which is the only place that
|
|
35
|
+
* stays true when a component's `as` changes.
|
|
36
|
+
*/
|
|
37
|
+
export declare function omitAttrs<T extends object, K extends string>(props: T, strip: Readonly<Record<K, true>>): Omit<T, K>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type AnchorOnlyAttributes } from '../helpers/anchorAttrs';
|
|
2
3
|
import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses';
|
|
3
4
|
/**
|
|
4
5
|
* Props for the Level component.
|
|
@@ -64,38 +65,20 @@ export interface LevelRightProps extends React.HTMLAttributes<HTMLDivElement>, O
|
|
|
64
65
|
* @returns {JSX.Element} The rendered level right section.
|
|
65
66
|
*/
|
|
66
67
|
export declare const LevelRight: React.FC<LevelRightProps>;
|
|
67
|
-
/**
|
|
68
|
-
* Exactly what `<a>` adds over the attributes every element has: `href`,
|
|
69
|
-
* `target`, `download`, `hrefLang`, `ping`, `referrerPolicy`, `media`, `type`.
|
|
70
|
-
*
|
|
71
|
-
* NOT `rel`, which React declares on `HTMLAttributes` for every element and the
|
|
72
|
-
* subtraction therefore removes. This component withholds it from a non-anchor
|
|
73
|
-
* anyway, because it always has — see `ANCHOR_ONLY` in the implementation,
|
|
74
|
-
* where it is named separately for that reason.
|
|
75
|
-
*
|
|
76
|
-
* Subtracted from React's own types rather than listed. Listing them is how this
|
|
77
|
-
* component came to reject `download` at `as="a"` — the list said `href`,
|
|
78
|
-
* `target`, `rel` and stopped, and #641 is the report. A list gains an entry only
|
|
79
|
-
* when someone notices; a subtraction gains it when React does.
|
|
80
|
-
*
|
|
81
|
-
* They reach the `<a>` branch and no other: declared at every `as` because
|
|
82
|
-
* narrowing them to the anchor is source-breaking (#672, `next-major`), and
|
|
83
|
-
* withheld at runtime so the type's permissiveness costs no dead markup.
|
|
84
|
-
*/
|
|
85
|
-
type AnchorOnlyAttributes = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof React.HTMLAttributes<HTMLAnchorElement>>;
|
|
86
68
|
/**
|
|
87
69
|
* Props for the LevelItem component.
|
|
88
70
|
*
|
|
89
|
-
* The anchor attributes
|
|
90
|
-
* when the tag is an `<a>` — so `<Level.Item as="p" download>` compiles and
|
|
71
|
+
* The anchor attributes arrive through `AnchorOnlyAttributes`, at every `as`, and
|
|
72
|
+
* are forwarded only when the tag is an `<a>` — so `<Level.Item as="p" download>` compiles and
|
|
91
73
|
* renders a `<p>` without it. That asymmetry is deliberate for now: deriving
|
|
92
74
|
* them from `as` instead is what makes the dead pair a type error, and it also
|
|
93
75
|
* stops `const p: LevelItemProps = { href }` compiling for consumers who write
|
|
94
76
|
* it today. #672 carries that half, labelled `next-major`.
|
|
95
77
|
*
|
|
96
|
-
* What
|
|
78
|
+
* What that set must NOT become is a hand-written list. Enumerating only `href`,
|
|
97
79
|
* `target` and `rel` made every other anchor attribute a type error even at
|
|
98
|
-
* `as="a"`, which is what #641 reported.
|
|
80
|
+
* `as="a"`, which is what #641 reported; `helpers/anchorAttrs.ts` derives it from
|
|
81
|
+
* React instead, and `ANCHOR_ONLY_ATTRS` there is the guard to protect.
|
|
99
82
|
*/
|
|
100
83
|
export interface LevelItemProps extends AnchorOnlyAttributes, React.HTMLAttributes<HTMLDivElement | HTMLParagraphElement | HTMLAnchorElement>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
|
|
101
84
|
/** Element type to render. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allxsmith/bestax-bulma",
|
|
3
|
-
"version": "5.15.
|
|
3
|
+
"version": "5.15.4",
|
|
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.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|