@allxsmith/bestax-bulma 5.15.1 → 5.15.2

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 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 = ({ children, active, className, as: Component = 'a', ...props }) => {
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", ...rest, children: children }));
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 (`IconProps` is a discriminated union of
3134
- // the two, and `IconChildrenProps['children']` excludes `undefined` so `children={undefined}`
3135
- // can't slip past into this branch) — the cast only matters for legacy callers that bypass
3136
- // the type and rely solely on the deprecated `icon` prop below.
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. Unreachable through the public type, but a plain-JS caller (or one
3161
- // that casts) can land here, and building a class off an absent name produced a bogus
3162
- // `fa-undefined` glyph. Render the bare container instead, matching the `children` branch.
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 `react-icons`
5606
- * component, …) passed to a slot that accepts either.
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$1(value) {
5609
- return (typeof value === 'object' &&
5610
- value !== null &&
5611
- !React.isValidElement(value) &&
5612
- ('name' in value || 'children' in value));
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$1(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 &&
5635
- (isIconProps$1(iconProps) ? (jsxRuntime.jsx(Icon, { ...iconProps })) : (jsxRuntime.jsx(Icon, { children: iconProps }))), children && jsxRuntime.jsx("span", { children: children })] })) }));
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.