@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
package/dist/index.cjs.js
CHANGED
|
@@ -1781,6 +1781,75 @@ const Card = withSubComponents(CardComponent, {
|
|
|
1781
1781
|
/** Internal test-only exports. Not part of the public API. */
|
|
1782
1782
|
const __test_exports__ = { renderFooter };
|
|
1783
1783
|
|
|
1784
|
+
/**
|
|
1785
|
+
* The runtime mirror of `AnchorOnlyAttributes`, keyed so the two cannot drift.
|
|
1786
|
+
*
|
|
1787
|
+
* `Record<keyof …, true>` is what links them: the day React adds an anchor
|
|
1788
|
+
* attribute, every component deriving its props from `as` accepts it and this
|
|
1789
|
+
* object stops compiling until it is named here. A plain array beside a derived
|
|
1790
|
+
* type drifts in the one direction that matters — the type accepts the new
|
|
1791
|
+
* attribute and the filter lets it leak onto a `<div>`.
|
|
1792
|
+
*/
|
|
1793
|
+
const ANCHOR_ONLY_ATTRS = {
|
|
1794
|
+
href: true,
|
|
1795
|
+
target: true,
|
|
1796
|
+
download: true,
|
|
1797
|
+
hrefLang: true,
|
|
1798
|
+
ping: true,
|
|
1799
|
+
referrerPolicy: true,
|
|
1800
|
+
media: true,
|
|
1801
|
+
type: true,
|
|
1802
|
+
};
|
|
1803
|
+
/**
|
|
1804
|
+
* `props` without the keys named in `strip`.
|
|
1805
|
+
*
|
|
1806
|
+
* The SET is per component and deliberately not shared, because the right
|
|
1807
|
+
* answer differs and the differences are principled: how open the component's
|
|
1808
|
+
* `as` is, and which of these attributes its own tags legitimately take. What
|
|
1809
|
+
* IS shared is the derived source of truth above and this function. Each caller
|
|
1810
|
+
* declares its delta next to the set it passes, which is the only place that
|
|
1811
|
+
* stays true when a component's `as` changes.
|
|
1812
|
+
*/
|
|
1813
|
+
function omitAttrs(props, strip) {
|
|
1814
|
+
const out = {};
|
|
1815
|
+
// `Reflect.ownKeys`, not `Object.entries`: the latter drops symbol-keyed props.
|
|
1816
|
+
// React enumerates props with `for...in`, which never reports a symbol, so
|
|
1817
|
+
// nothing renders differently either way. It is not the same change for all
|
|
1818
|
+
// three callers: Menu filtered by rest-destructure and kept them already,
|
|
1819
|
+
// while Dropdown and Level filtered through `Object.entries` and did not, so
|
|
1820
|
+
// this restores one and widens two. Symbols are the only shape where those
|
|
1821
|
+
// two disagreed, and keeping them is the side a spread is on.
|
|
1822
|
+
for (const key of Reflect.ownKeys(props)) {
|
|
1823
|
+
// Enumerability, for the same reason in the other direction: `Reflect.ownKeys`
|
|
1824
|
+
// also reports NON-enumerable own props, which every filter this replaced left
|
|
1825
|
+
// behind. Copying one out would both add a prop the old code dropped and make
|
|
1826
|
+
// it enumerable on the way, so widening the key source must not widen this.
|
|
1827
|
+
if (!Object.prototype.propertyIsEnumerable.call(props, key))
|
|
1828
|
+
continue;
|
|
1829
|
+
const value = props[key];
|
|
1830
|
+
// `hasOwnProperty`, not `key in strip`: `in` walks the prototype chain, so a
|
|
1831
|
+
// prop named `toString`, `valueOf`, `constructor` or `hasOwnProperty` was
|
|
1832
|
+
// stripped although no caller named it — and anything written to
|
|
1833
|
+
// `Object.prototype` would start deleting props that share its keys.
|
|
1834
|
+
if (typeof key === 'symbol' ||
|
|
1835
|
+
!Object.prototype.hasOwnProperty.call(strip, key)) {
|
|
1836
|
+
// `defineProperty`, not `out[key] = value`: assignment consults the
|
|
1837
|
+
// prototype chain for a setter, and `__proto__` has one. A prop named
|
|
1838
|
+
// `__proto__` would be swallowed by it — dropped from the result AND
|
|
1839
|
+
// replacing the result's prototype with its value. A spread and a rest
|
|
1840
|
+
// destructure both DEFINE, which is what makes them immune, so this has
|
|
1841
|
+
// to define too.
|
|
1842
|
+
Object.defineProperty(out, key, {
|
|
1843
|
+
value,
|
|
1844
|
+
writable: true,
|
|
1845
|
+
enumerable: true,
|
|
1846
|
+
configurable: true,
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
return out;
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1784
1853
|
/**
|
|
1785
1854
|
* Checks if code is running in a browser environment.
|
|
1786
1855
|
* @param win - Window object.
|
|
@@ -2003,32 +2072,25 @@ const DropdownComponent = React.forwardRef(function DropdownComponent({ label, c
|
|
|
2003
2072
|
return (jsxRuntime.jsxs("div", { className: dropdownClasses, ref: setRefs, id: id, "data-testid": "dropdown-root", ...rest, children: [jsxRuntime.jsx("div", { className: usePrefixedClassNames('dropdown-trigger'), children: jsxRuntime.jsxs("button", { ref: triggerRef, className: buttonClass, "aria-haspopup": "true", "aria-controls": id ? `${id}-menu` : undefined, "aria-expanded": active, onClick: handleToggle, onKeyDown: handleTriggerKeyDown, disabled: disabled, type: "button", children: [jsxRuntime.jsx("span", { children: label }), jsxRuntime.jsx("span", { className: usePrefixedClassNames('icon', 'is-small'), "aria-hidden": "true", children: jsxRuntime.jsx("i", { className: "fas fa-angle-down" }) })] }) }), jsxRuntime.jsx("div", { className: classNames(usePrefixedClassNames('dropdown-menu'), menuClassName), id: id ? `${id}-menu` : undefined, role: "menu", "data-testid": "dropdown-menu", onKeyDown: handleMenuKeyDown, children: jsxRuntime.jsx("div", { className: usePrefixedClassNames('dropdown-content'), onClick: handleMenuClick, tabIndex: -1, children: children }) })] }));
|
|
2004
2073
|
});
|
|
2005
2074
|
/**
|
|
2006
|
-
* The anchor
|
|
2007
|
-
*
|
|
2008
|
-
*
|
|
2009
|
-
*
|
|
2010
|
-
*
|
|
2011
|
-
*
|
|
2012
|
-
*
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
const out = {};
|
|
2026
|
-
for (const [key, value] of Object.entries(props)) {
|
|
2027
|
-
if (!LINK_ONLY_ATTRS.includes(key))
|
|
2028
|
-
out[key] = value;
|
|
2029
|
-
}
|
|
2030
|
-
return out;
|
|
2031
|
-
}
|
|
2075
|
+
* The anchor's attributes, minus the one a `<button>` legitimately takes.
|
|
2076
|
+
*
|
|
2077
|
+
* `type` stays: `as="button"` is a supported form and `type="submit"` is valid
|
|
2078
|
+
* there, so stripping it would remove a working attribute. The exclusion is per
|
|
2079
|
+
* COMPONENT where the reason is per TAG, so it also lets a `type` reach a
|
|
2080
|
+
* `<div>`; selecting the set from the rendered element would close that, and
|
|
2081
|
+
* moves output.
|
|
2082
|
+
*
|
|
2083
|
+
* This set differs from `Level.Item`'s in both directions, not just one. The
|
|
2084
|
+
* `type` above, which Level strips and this component keeps, and `rel`, which
|
|
2085
|
+
* Level adds and this component does not: React declares `rel` on
|
|
2086
|
+
* `HTMLAttributes` for every element, so withholding it would diverge from
|
|
2087
|
+
* React's own typing — the call #641 recorded for `Navbar.Link`. Level
|
|
2088
|
+
* withholds it anyway, because it always has.
|
|
2089
|
+
*/
|
|
2090
|
+
const STRIP_FROM_NON_ANCHOR$1 = (() => {
|
|
2091
|
+
const { type: _type, ...rest } = ANCHOR_ONLY_ATTRS;
|
|
2092
|
+
return rest;
|
|
2093
|
+
})();
|
|
2032
2094
|
/**
|
|
2033
2095
|
* Bulma Dropdown item.
|
|
2034
2096
|
*
|
|
@@ -2046,16 +2108,18 @@ const DropdownItem = ((itemProps) => {
|
|
|
2046
2108
|
// plain-JS one, a loose `{...props}` spread, and the genericity a wrapping HOC
|
|
2047
2109
|
// erases.
|
|
2048
2110
|
//
|
|
2049
|
-
// The whole link set, not `href` alone
|
|
2050
|
-
//
|
|
2051
|
-
//
|
|
2052
|
-
//
|
|
2053
|
-
//
|
|
2111
|
+
// The whole link set, not `href` alone: they all arrive together under
|
|
2112
|
+
// `as="a"`. Menu strips `href` only, because its `as` is open and a flat set
|
|
2113
|
+
// would delete attributes legal on the element a caller named.
|
|
2114
|
+
//
|
|
2115
|
+
// `bestax-migrate` tracks the same question from the other side, per attribute
|
|
2116
|
+
// per element (`LINK_ATTR_ELEMENTS`) rather than as one set — so the two lists
|
|
2117
|
+
// are not interchangeable and neither derives from the other.
|
|
2054
2118
|
//
|
|
2055
2119
|
// Menu's condition also admits a custom component and a custom element, which
|
|
2056
2120
|
// own their prop contracts. `as` is closed to three intrinsic tags here, so
|
|
2057
2121
|
// neither can arrive and the anchor test is the whole rule.
|
|
2058
|
-
const forwarded = Component === 'a' ? rest :
|
|
2122
|
+
const forwarded = Component === 'a' ? rest : omitAttrs(rest, STRIP_FROM_NON_ANCHOR$1);
|
|
2059
2123
|
return (jsxRuntime.jsx(Component, { className: classNames(usePrefixedClassNames('dropdown-item', {
|
|
2060
2124
|
'is-active': active,
|
|
2061
2125
|
}), bulmaHelperClasses, className), tabIndex: 0, role: "menuitem", "data-testid": "dropdown-item", ...forwarded, ...(Component === 'button'
|
|
@@ -2120,6 +2184,11 @@ const MenuList = ({ className, children, ...props }) => {
|
|
|
2120
2184
|
// Increment level for nested MenuLists
|
|
2121
2185
|
return (jsxRuntime.jsx(MenuListLevelContext.Provider, { value: level + 1, children: jsxRuntime.jsx("ul", { className: ulClass, ...rest, children: children }) }));
|
|
2122
2186
|
};
|
|
2187
|
+
/**
|
|
2188
|
+
* `href` alone — annotated so a typo is a compile error rather than a silent
|
|
2189
|
+
* no-op, the way both siblings' sets are.
|
|
2190
|
+
*/
|
|
2191
|
+
const STRIP_FROM_NON_LINK = { href: true };
|
|
2123
2192
|
/**
|
|
2124
2193
|
* MenuItem supports `as` prop for custom link components, e.g., react-router-dom Link.
|
|
2125
2194
|
*
|
|
@@ -2139,8 +2208,20 @@ const MenuItem = React.forwardRef(function MenuItem(itemProps, ref) {
|
|
|
2139
2208
|
const isLinkLike = Component === 'a' ||
|
|
2140
2209
|
typeof Component !== 'string' ||
|
|
2141
2210
|
isCustomElement(Component);
|
|
2142
|
-
|
|
2143
|
-
|
|
2211
|
+
// `href` ALONE. `Dropdown.Item` strips every anchor-only attribute except
|
|
2212
|
+
// `type`; `Level.Item` strips all of them, plus `rel`.
|
|
2213
|
+
//
|
|
2214
|
+
// Not because nothing else can arrive: `as` here is an open `React.ElementType`,
|
|
2215
|
+
// and a non-fresh spread skips excess-property checking, so a typed caller
|
|
2216
|
+
// CAN deliver `target` or `download` and they are forwarded. The set stays at
|
|
2217
|
+
// `href` because widening it would be wrong for an open `as` — `referrerPolicy`
|
|
2218
|
+
// on `as="img"`, `target` on `as="form"` and `media` on `as="source"` are all
|
|
2219
|
+
// legal, and a flat strip would delete them. Getting that right needs a
|
|
2220
|
+
// per-attribute-per-element rule, which `bestax-migrate` already models in
|
|
2221
|
+
// `LINK_ATTR_ELEMENTS`.
|
|
2222
|
+
const linkProps = isLinkLike
|
|
2223
|
+
? forwarded
|
|
2224
|
+
: omitAttrs(forwarded, STRIP_FROM_NON_LINK);
|
|
2144
2225
|
const itemClass = classNames({ [usePrefixedClassNames('is-active')]: active }, bulmaHelperClasses);
|
|
2145
2226
|
// Split children into label and nested MenuList(s)
|
|
2146
2227
|
const labelChildren = [];
|
|
@@ -12989,6 +13070,18 @@ const LevelRight = ({ className, children, color, bgColor, textColor, ...props }
|
|
|
12989
13070
|
const levelRightClasses = classNames(mainClass, bulmaHelperClasses, className);
|
|
12990
13071
|
return (jsxRuntime.jsx("div", { className: levelRightClasses, ...rest, children: children }));
|
|
12991
13072
|
};
|
|
13073
|
+
/**
|
|
13074
|
+
* The derived set plus `rel`.
|
|
13075
|
+
*
|
|
13076
|
+
* `rel` is not an anchor-only attribute — React declares it on every element, so
|
|
13077
|
+
* `AnchorOnlyAttributes` excludes it — but this component has always withheld it
|
|
13078
|
+
* from a non-anchor, so it is named separately rather than folded into the shared
|
|
13079
|
+
* set. That separation is what says which names come from where.
|
|
13080
|
+
*
|
|
13081
|
+
* The annotation is load-bearing: without it a typo adds a key nobody strips, and
|
|
13082
|
+
* widening the key type to `string` also erases `omitAttrs`'s return type.
|
|
13083
|
+
*/
|
|
13084
|
+
const STRIP_FROM_NON_ANCHOR = { ...ANCHOR_ONLY_ATTRS, rel: true };
|
|
12992
13085
|
/**
|
|
12993
13086
|
* Individual item, can be rendered as `div`, `p`, or `a`.
|
|
12994
13087
|
*
|
|
@@ -13011,32 +13104,11 @@ const LevelItem = ({ as = 'div', hasTextCentered, className, children, color, bg
|
|
|
13011
13104
|
// declares them at every `as` — narrowing that is source-breaking (#672) — so
|
|
13012
13105
|
// the runtime is what keeps `<Level.Item as="p" download>` from rendering a
|
|
13013
13106
|
// dead attribute.
|
|
13014
|
-
//
|
|
13015
|
-
// Keyed off `AnchorOnlyAttributes` rather than repeated as a list, because a
|
|
13016
|
-
// hand list beside a derived type drifts in the one direction that matters:
|
|
13017
|
-
// the day React adds an anchor attribute, the type would accept it at every
|
|
13018
|
-
// `as` while the list let it leak onto a `<div>`. `Record` makes that a
|
|
13019
|
-
// compile error here until this object catches up. #682 is the issue for
|
|
13020
|
-
// sharing the rule with the two components that keep their own copies.
|
|
13021
|
-
const ANCHOR_ONLY = {
|
|
13022
|
-
href: true,
|
|
13023
|
-
target: true,
|
|
13024
|
-
download: true,
|
|
13025
|
-
hrefLang: true,
|
|
13026
|
-
ping: true,
|
|
13027
|
-
referrerPolicy: true,
|
|
13028
|
-
media: true,
|
|
13029
|
-
type: true,
|
|
13030
|
-
// `rel` is NOT in the subtraction: React declares it on `HTMLAttributes`,
|
|
13031
|
-
// for every element. It is here because this component has always withheld
|
|
13032
|
-
// it from a non-anchor, and it is named separately so the key set above
|
|
13033
|
-
// stays honest about where each name comes from.
|
|
13034
|
-
rel: true,
|
|
13035
|
-
};
|
|
13107
|
+
// `STRIP_FROM_NON_ANCHOR` above names the set and why `rel` is in it.
|
|
13036
13108
|
if (Tag === 'a') {
|
|
13037
13109
|
return (jsxRuntime.jsx("a", { className: levelItemClasses, ...rest, children: children }));
|
|
13038
13110
|
}
|
|
13039
|
-
const withoutAnchorAttrs =
|
|
13111
|
+
const withoutAnchorAttrs = omitAttrs(rest, STRIP_FROM_NON_ANCHOR);
|
|
13040
13112
|
return (jsxRuntime.jsx(Tag, { className: levelItemClasses, ...withoutAnchorAttrs, children: children }));
|
|
13041
13113
|
};
|
|
13042
13114
|
const Level = withSubComponents(LevelComponent, {
|