@allxsmith/bestax-bulma 5.15.1 → 5.15.3
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 +134 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +134 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Dropdown.d.ts +35 -6
- package/dist/types/components/Panel.d.ts +2 -2
- package/dist/types/elements/Icon.d.ts +44 -5
- package/dist/types/elements/iconProps.d.ts +30 -0
- package/dist/types/helpers/polymorphic.d.ts +37 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/layout/Level.d.ts +31 -7
- package/package.json +2 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2002,6 +2002,33 @@ const DropdownComponent = React.forwardRef(function DropdownComponent({ label, c
|
|
|
2002
2002
|
const dropdownClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
|
|
2003
2003
|
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
2004
|
});
|
|
2005
|
+
/**
|
|
2006
|
+
* The anchor-only attributes, withheld from a `<div>` or a `<button>`.
|
|
2007
|
+
*
|
|
2008
|
+
* Mirrors `LINK_ATTRS` in `bestax-migrate/src/sources/_shared/polymorphic.ts`,
|
|
2009
|
+
* which drops the same set when a migration lands one on a non-anchor. `rel` is
|
|
2010
|
+
* absent from both on purpose: React declares it on `HTMLAttributes<T>` — every
|
|
2011
|
+
* element — so withholding it would diverge from React's own typing, the same
|
|
2012
|
+
* call #641 recorded for `Navbar.Link`.
|
|
2013
|
+
*/
|
|
2014
|
+
const LINK_ONLY_ATTRS = [
|
|
2015
|
+
'href',
|
|
2016
|
+
'target',
|
|
2017
|
+
'download',
|
|
2018
|
+
'hrefLang',
|
|
2019
|
+
'ping',
|
|
2020
|
+
'referrerPolicy',
|
|
2021
|
+
'media',
|
|
2022
|
+
];
|
|
2023
|
+
/** `props` without any attribute only an anchor can carry. */
|
|
2024
|
+
function omitLinkAttrs(props) {
|
|
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
|
+
}
|
|
2005
2032
|
/**
|
|
2006
2033
|
* Bulma Dropdown item.
|
|
2007
2034
|
*
|
|
@@ -2009,12 +2036,34 @@ const DropdownComponent = React.forwardRef(function DropdownComponent({ label, c
|
|
|
2009
2036
|
* @param {DropdownItemProps} props - Props for the DropdownItem component.
|
|
2010
2037
|
* @returns {JSX.Element} The rendered dropdown item.
|
|
2011
2038
|
*/
|
|
2012
|
-
const DropdownItem = (
|
|
2039
|
+
const DropdownItem = ((itemProps) => {
|
|
2040
|
+
const { children, active, className, as: Component = 'a', ...props } = itemProps;
|
|
2013
2041
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
2042
|
+
// The anchor's attributes reach an anchor and nothing else — `<div href>` and
|
|
2043
|
+
// `<button target>` are invalid HTML. The same rule Menu applies, for the same
|
|
2044
|
+
// reason: the type now derives these from `as`, and deriving them must not
|
|
2045
|
+
// quietly widen where they land. The type stops a direct caller; this stops a
|
|
2046
|
+
// plain-JS one, a loose `{...props}` spread, and the genericity a wrapping HOC
|
|
2047
|
+
// erases.
|
|
2048
|
+
//
|
|
2049
|
+
// The whole link set, not `href` alone. Menu strips only `href` because its
|
|
2050
|
+
// props never gained the rest; here they all arrive together under `as="a"`,
|
|
2051
|
+
// and `bestax-migrate` already removes exactly this set (`LINK_ATTRS`) when it
|
|
2052
|
+
// migrates onto a non-anchor — so stripping less would leave the codemod
|
|
2053
|
+
// stricter than the component it migrates to.
|
|
2054
|
+
//
|
|
2055
|
+
// Menu's condition also admits a custom component and a custom element, which
|
|
2056
|
+
// own their prop contracts. `as` is closed to three intrinsic tags here, so
|
|
2057
|
+
// neither can arrive and the anchor test is the whole rule.
|
|
2058
|
+
const forwarded = Component === 'a' ? rest : omitLinkAttrs(rest);
|
|
2014
2059
|
return (jsxRuntime.jsx(Component, { className: classNames(usePrefixedClassNames('dropdown-item', {
|
|
2015
2060
|
'is-active': active,
|
|
2016
|
-
}), bulmaHelperClasses, className), tabIndex: 0, role: "menuitem", "data-testid": "dropdown-item", ...
|
|
2017
|
-
|
|
2061
|
+
}), bulmaHelperClasses, className), tabIndex: 0, role: "menuitem", "data-testid": "dropdown-item", ...forwarded, ...(Component === 'button'
|
|
2062
|
+
? {
|
|
2063
|
+
type: forwarded.type ?? 'button',
|
|
2064
|
+
}
|
|
2065
|
+
: {}), children: children }));
|
|
2066
|
+
});
|
|
2018
2067
|
/**
|
|
2019
2068
|
* Bulma Dropdown divider.
|
|
2020
2069
|
*
|
|
@@ -3130,10 +3179,11 @@ containerClassName, children, ...restProps }) => {
|
|
|
3130
3179
|
// component, …) in place of a class-based glyph. Library/variant/features don't apply.
|
|
3131
3180
|
return (jsxRuntime.jsx("span", { className: iconContainerClasses, "aria-label": ariaLabel, style: style, ...rest, children: children }));
|
|
3132
3181
|
}
|
|
3133
|
-
// `name` is guaranteed once `children` is absent
|
|
3134
|
-
//
|
|
3135
|
-
//
|
|
3136
|
-
//
|
|
3182
|
+
// `name` is guaranteed once `children` is absent UNLESS the caller is on the deprecated
|
|
3183
|
+
// `icon` path, which `IconDeprecatedProps` declares with `name?: undefined`.
|
|
3184
|
+
// (`IconChildrenProps['children']` excludes `undefined`, so `children={undefined}` can't
|
|
3185
|
+
// slip past into this branch.) The cast covers that third member, and the `!name && icon`
|
|
3186
|
+
// fallback below is what fills it in.
|
|
3137
3187
|
let finalName = name;
|
|
3138
3188
|
if (!name && icon) {
|
|
3139
3189
|
// If icon prop is provided instead of name, try to parse it
|
|
@@ -3157,9 +3207,10 @@ containerClassName, children, ...restProps }) => {
|
|
|
3157
3207
|
// library is 'fa'), so `name` behaves identically with or without the prefix.
|
|
3158
3208
|
finalName = stripRedundantLibraryPrefix(finalName, finalLibrary);
|
|
3159
3209
|
if (!finalName) {
|
|
3160
|
-
// No glyph to name.
|
|
3161
|
-
//
|
|
3162
|
-
// `fa-undefined` glyph
|
|
3210
|
+
// No glyph to name. Reachable through the public type only as `icon=""`, and otherwise
|
|
3211
|
+
// by a plain-JS caller (or one that casts). Building a class off an absent name produced
|
|
3212
|
+
// a bogus `fa-undefined` glyph; render the bare container instead, matching the
|
|
3213
|
+
// `children` branch.
|
|
3163
3214
|
return (jsxRuntime.jsx("span", { className: iconContainerClasses, "aria-label": ariaLabel, style: style, ...rest }));
|
|
3164
3215
|
}
|
|
3165
3216
|
// Backward compatibility: if libraryFeatures is provided, parse it for variant and features
|
|
@@ -5602,15 +5653,49 @@ const Figure = withSubComponents(FigureComponent, {
|
|
|
5602
5653
|
}, 'Figure');
|
|
5603
5654
|
|
|
5604
5655
|
/**
|
|
5605
|
-
* Distinguishes an `IconProps` object from a plain custom node (an inline SVG, a
|
|
5606
|
-
* component, …)
|
|
5656
|
+
* Distinguishes an `IconProps` object from a plain custom node (an inline SVG, a
|
|
5657
|
+
* `react-icons` component, …) in a slot that accepts either — `Control`'s
|
|
5658
|
+
* `iconLeft`/`iconRight`, `IconText`'s `iconProps`.
|
|
5659
|
+
*
|
|
5660
|
+
* One copy, imported by both consumers: two hand-maintained copies, one per
|
|
5661
|
+
* consumer, is how the deprecated `icon` path came to crash both (#663).
|
|
5662
|
+
*
|
|
5663
|
+
* Its own module rather than `Icon.tsx` because `src/index.ts` wildcard-exports
|
|
5664
|
+
* that file, and everything published there is public forever. `polymorphic.ts`
|
|
5665
|
+
* makes the same call for `isCustomElement`: an internal discriminator is not
|
|
5666
|
+
* something to support for the life of the package.
|
|
5667
|
+
*
|
|
5668
|
+
* It tests each member's VALUE, not merely its key, and only after everything
|
|
5669
|
+
* React owns is out of the way. `'icon' in value` was enough
|
|
5670
|
+
* to claim a Font Awesome `IconDefinition` — `{ prefix, iconName, icon: [w, h, …,
|
|
5671
|
+
* path] }` — whose `icon` is a path array rather than a class string. That object
|
|
5672
|
+
* is not a renderable node either, so the honest outcome is the one this slot has
|
|
5673
|
+
* always had for it: the node branch, and React's own "Objects are not valid as a
|
|
5674
|
+
* React child". Claiming it here instead rendered a blank container that still
|
|
5675
|
+
* reserved layout.
|
|
5676
|
+
*
|
|
5677
|
+
* A member added to `IconProps` needs a line here, and a missed one is a crash
|
|
5678
|
+
* rather than a fallthrough. That is the cost of a slot taking either a props
|
|
5679
|
+
* object or a node; keeping the guard in one place is what keeps the cost to a
|
|
5680
|
+
* single line.
|
|
5607
5681
|
*/
|
|
5608
|
-
function isIconProps
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5682
|
+
function isIconProps(value) {
|
|
5683
|
+
if (typeof value !== 'object' || value === null)
|
|
5684
|
+
return false;
|
|
5685
|
+
// Anything React owns. `isValidElement` covers elements only; a PORTAL is a
|
|
5686
|
+
// valid `ReactNode` that fails it and carries a `children` key, so the member
|
|
5687
|
+
// test below claimed it and `Control` spread it into `<Icon>` as props —
|
|
5688
|
+
// rendering the portal's child locally instead of in its container. Every
|
|
5689
|
+
// React internal carries `$$typeof`, so testing for it covers lazy, context
|
|
5690
|
+
// and whatever React adds next, rather than portals alone.
|
|
5691
|
+
if (React.isValidElement(value) || '$$typeof' in value)
|
|
5692
|
+
return false;
|
|
5693
|
+
const candidate = value;
|
|
5694
|
+
return (typeof candidate.name === 'string' ||
|
|
5695
|
+
typeof candidate.icon === 'string' ||
|
|
5696
|
+
'children' in candidate);
|
|
5613
5697
|
}
|
|
5698
|
+
|
|
5614
5699
|
/**
|
|
5615
5700
|
* The `IconText` component provides a Bulma-styled horizontal arrangement of one or more `Icon` components and optional text.
|
|
5616
5701
|
*
|
|
@@ -5631,8 +5716,8 @@ const IconTextComponent = ({ className, textColor, color, bgColor, iconProps, ch
|
|
|
5631
5716
|
const bulmaClasses = usePrefixedClassNames('icon-text');
|
|
5632
5717
|
const iconTextClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
|
|
5633
5718
|
return (jsxRuntime.jsx("span", { className: iconTextClasses, ...rest, children: items ? (items.map((item, index) => (jsxRuntime.jsxs(React.Fragment, { children: [item.iconProps &&
|
|
5634
|
-
(isIconProps
|
|
5635
|
-
(isIconProps
|
|
5719
|
+
(isIconProps(item.iconProps) ? (jsxRuntime.jsx(Icon, { ...item.iconProps })) : (jsxRuntime.jsx(Icon, { children: item.iconProps }))), item.text && jsxRuntime.jsx("span", { children: item.text })] }, index)))) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconProps &&
|
|
5720
|
+
(isIconProps(iconProps) ? (jsxRuntime.jsx(Icon, { ...iconProps })) : (jsxRuntime.jsx(Icon, { children: iconProps }))), children && jsxRuntime.jsx("span", { children: children })] })) }));
|
|
5636
5721
|
};
|
|
5637
5722
|
const IconText = withSubComponents(IconTextComponent, { Icon }, 'IconText');
|
|
5638
5723
|
|
|
@@ -6546,16 +6631,6 @@ const Checkbox = React.forwardRef(({ color, size, className, children, textColor
|
|
|
6546
6631
|
});
|
|
6547
6632
|
Checkbox.displayName = 'Checkbox';
|
|
6548
6633
|
|
|
6549
|
-
/**
|
|
6550
|
-
* Distinguishes an `IconProps` object from a plain custom node (an inline SVG, a `react-icons`
|
|
6551
|
-
* component, …) passed to a slot that accepts either.
|
|
6552
|
-
*/
|
|
6553
|
-
function isIconProps(value) {
|
|
6554
|
-
return (typeof value === 'object' &&
|
|
6555
|
-
value !== null &&
|
|
6556
|
-
!React.isValidElement(value) &&
|
|
6557
|
-
('name' in value || 'children' in value));
|
|
6558
|
-
}
|
|
6559
6634
|
const allowedColors = [...validColors, 'inherit', 'current'];
|
|
6560
6635
|
/**
|
|
6561
6636
|
* The `Control` component is a Bulma-styled wrapper for form controls (`Input`, `Select`, `TextArea`, etc.), supporting icons (left/right), loading state, expansion, size, and Bulma helper props for layout and color.
|
|
@@ -12921,7 +12996,7 @@ const LevelRight = ({ className, children, color, bgColor, textColor, ...props }
|
|
|
12921
12996
|
* @param {LevelItemProps} props - Props for the LevelItem component.
|
|
12922
12997
|
* @returns {JSX.Element} The rendered level item.
|
|
12923
12998
|
*/
|
|
12924
|
-
const LevelItem = ({ as = 'div', hasTextCentered, className, children,
|
|
12999
|
+
const LevelItem = ({ as = 'div', hasTextCentered, className, children, color, bgColor, textColor, ...props }) => {
|
|
12925
13000
|
const { bulmaHelperClasses, rest } = useBulmaClasses({
|
|
12926
13001
|
color: textColor ?? color,
|
|
12927
13002
|
backgroundColor: bgColor,
|
|
@@ -12932,11 +13007,37 @@ const LevelItem = ({ as = 'div', hasTextCentered, className, children, href, tar
|
|
|
12932
13007
|
'has-text-centered': hasTextCentered,
|
|
12933
13008
|
});
|
|
12934
13009
|
const levelItemClasses = classNames(mainClass, bulmaHelperClasses, className);
|
|
12935
|
-
//
|
|
13010
|
+
// The anchor's own attributes reach an `<a>` and nothing else. The type
|
|
13011
|
+
// declares them at every `as` — narrowing that is source-breaking (#672) — so
|
|
13012
|
+
// the runtime is what keeps `<Level.Item as="p" download>` from rendering a
|
|
13013
|
+
// 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
|
+
};
|
|
12936
13036
|
if (Tag === 'a') {
|
|
12937
|
-
return (jsxRuntime.jsx("a", { className: levelItemClasses,
|
|
13037
|
+
return (jsxRuntime.jsx("a", { className: levelItemClasses, ...rest, children: children }));
|
|
12938
13038
|
}
|
|
12939
|
-
|
|
13039
|
+
const withoutAnchorAttrs = Object.fromEntries(Object.entries(rest).filter(([key]) => !(key in ANCHOR_ONLY)));
|
|
13040
|
+
return (jsxRuntime.jsx(Tag, { className: levelItemClasses, ...withoutAnchorAttrs, children: children }));
|
|
12940
13041
|
};
|
|
12941
13042
|
const Level = withSubComponents(LevelComponent, {
|
|
12942
13043
|
Left: LevelLeft,
|