@allxsmith/bestax-bulma 5.15.2 → 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.
@@ -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.
@@ -66,8 +67,20 @@ export interface LevelRightProps extends React.HTMLAttributes<HTMLDivElement>, O
66
67
  export declare const LevelRight: React.FC<LevelRightProps>;
67
68
  /**
68
69
  * Props for the LevelItem component.
70
+ *
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
73
+ * renders a `<p>` without it. That asymmetry is deliberate for now: deriving
74
+ * them from `as` instead is what makes the dead pair a type error, and it also
75
+ * stops `const p: LevelItemProps = { href }` compiling for consumers who write
76
+ * it today. #672 carries that half, labelled `next-major`.
77
+ *
78
+ * What that set must NOT become is a hand-written list. Enumerating only `href`,
79
+ * `target` and `rel` made every other anchor attribute a type error even at
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.
69
82
  */
70
- export interface LevelItemProps extends React.HTMLAttributes<HTMLDivElement | HTMLParagraphElement | HTMLAnchorElement>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
83
+ export interface LevelItemProps extends AnchorOnlyAttributes, React.HTMLAttributes<HTMLDivElement | HTMLParagraphElement | HTMLAnchorElement>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
71
84
  /** Element type to render. */
72
85
  as?: 'div' | 'p' | 'a';
73
86
  /** Center the text in the item. */
@@ -82,12 +95,6 @@ export interface LevelItemProps extends React.HTMLAttributes<HTMLDivElement | HT
82
95
  className?: string;
83
96
  /** Content. */
84
97
  children?: React.ReactNode;
85
- /** Href for "a" tag. */
86
- href?: string;
87
- /** Target for "a" tag */
88
- target?: string;
89
- /** Rel for "a" tag */
90
- rel?: string;
91
98
  }
92
99
  /**
93
100
  * Individual item, can be rendered as `div`, `p`, or `a`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allxsmith/bestax-bulma",
3
- "version": "5.15.2",
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",