@allxsmith/bestax-bulma 5.13.0 → 5.14.0

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
@@ -2788,8 +2788,37 @@ function getIconClasses(library, name, variant, features) {
2788
2788
  const Icon = ({ className, textColor, bgColor, name, library, variant, features, libraryFeatures, // Deprecated but maintained for backward compatibility
2789
2789
  size, ariaLabel = 'icon', style, icon, // Capture and exclude the deprecated 'icon' prop from DOM
2790
2790
  color: _color, // Exclude 'color' prop if passed directly
2791
- containerClassName, ...restProps }) => {
2792
- // Handle deprecated 'icon' prop - parse it to extract the actual name
2791
+ containerClassName, children, ...restProps }) => {
2792
+ // Get the default icon library from context, fallback to 'fa' if not set
2793
+ const defaultLibrary = useIconLibrary();
2794
+ /**
2795
+ * Generates Bulma helper classes and separates out remaining props.
2796
+ * Note: variant, features, and libraryFeatures are excluded from props spread
2797
+ */
2798
+ const { bulmaHelperClasses, rest } = useBulmaClasses({
2799
+ color: textColor,
2800
+ backgroundColor: bgColor,
2801
+ ...restProps,
2802
+ });
2803
+ // Hoisted unconditionally to respect rules-of-hooks; the branches below
2804
+ // pick which result to consume.
2805
+ const defaultIconClasses = usePrefixedClassNames('icon', {
2806
+ [`is-${size}`]: size,
2807
+ });
2808
+ const sizeModifierClass = usePrefixedClassNames(size ? `is-${size}` : undefined);
2809
+ const bulmaClasses = containerClassName
2810
+ ? containerClassName
2811
+ : defaultIconClasses;
2812
+ const iconContainerClasses = classNames(bulmaClasses, containerClassName && size ? sizeModifierClass : undefined, bulmaHelperClasses, className);
2813
+ if (children !== undefined) {
2814
+ // `IconChildrenProps`: render the caller's node (an inline SVG, a `react-icons`
2815
+ // component, …) in place of a class-based glyph. Library/variant/features don't apply.
2816
+ return (jsxRuntime.jsx("span", { className: iconContainerClasses, "aria-label": ariaLabel, style: style, ...rest, children: children }));
2817
+ }
2818
+ // `name` is guaranteed once `children` is absent (`IconProps` is a discriminated union of
2819
+ // the two, and `IconChildrenProps['children']` excludes `undefined` so `children={undefined}`
2820
+ // can't slip past into this branch) — the cast only matters for legacy callers that bypass
2821
+ // the type and rely solely on the deprecated `icon` prop below.
2793
2822
  let finalName = name;
2794
2823
  if (!name && icon) {
2795
2824
  // If icon prop is provided instead of name, try to parse it
@@ -2808,31 +2837,16 @@ containerClassName, ...restProps }) => {
2808
2837
  }
2809
2838
  }
2810
2839
  }
2811
- // Get the default icon library from context, fallback to 'fa' if not set
2812
- const defaultLibrary = useIconLibrary();
2813
2840
  const finalLibrary = library || defaultLibrary || 'fa';
2814
2841
  // Normalize a redundant leading library prefix (e.g. "fa-check" -> "check" when the
2815
2842
  // library is 'fa'), so `name` behaves identically with or without the prefix.
2816
2843
  finalName = stripRedundantLibraryPrefix(finalName, finalLibrary);
2817
- /**
2818
- * Generates Bulma helper classes and separates out remaining props.
2819
- * Note: variant, features, and libraryFeatures are excluded from props spread
2820
- */
2821
- const { bulmaHelperClasses, rest } = useBulmaClasses({
2822
- color: textColor,
2823
- backgroundColor: bgColor,
2824
- ...restProps,
2825
- });
2826
- // Hoisted unconditionally to respect rules-of-hooks; the ternaries below
2827
- // pick which result to consume.
2828
- const defaultIconClasses = usePrefixedClassNames('icon', {
2829
- [`is-${size}`]: size,
2830
- });
2831
- const sizeModifierClass = usePrefixedClassNames(size ? `is-${size}` : undefined);
2832
- const bulmaClasses = containerClassName
2833
- ? containerClassName
2834
- : defaultIconClasses;
2835
- const iconContainerClasses = classNames(bulmaClasses, containerClassName && size ? sizeModifierClass : undefined, bulmaHelperClasses, className);
2844
+ if (!finalName) {
2845
+ // No glyph to name. Unreachable through the public type, but a plain-JS caller (or one
2846
+ // that casts) can land here, and building a class off an absent name produced a bogus
2847
+ // `fa-undefined` glyph. Render the bare container instead, matching the `children` branch.
2848
+ return (jsxRuntime.jsx("span", { className: iconContainerClasses, "aria-label": ariaLabel, style: style, ...rest }));
2849
+ }
2836
2850
  // Backward compatibility: if libraryFeatures is provided, parse it for variant and features
2837
2851
  let finalVariant = variant;
2838
2852
  let finalFeatures = features;
@@ -2951,8 +2965,9 @@ const PanelTabs = ({ className, children, ...props }) => (jsxRuntime.jsx("p", {
2951
2965
  */
2952
2966
  const PanelBlock = ({ className, active, children, ...props }) => (jsxRuntime.jsx("a", { className: classNames(usePrefixedClassNames('panel-block', { 'is-active': active }), className), ...props, children: children }));
2953
2967
  /**
2954
- * Icon wrapper with panel styling (renders as `<span class="panel-icon"><i/></span>`).
2955
- * Accepts all Icon props (`name`, `variant`, `features`, etc.)
2968
+ * Icon wrapper with panel styling (renders as `<span class="panel-icon">`, containing an
2969
+ * `<i/>` when a `name` is given, or the custom node passed as `children`).
2970
+ * Accepts all Icon props (`name`, `variant`, `features`, etc.), or `children` for a custom node.
2956
2971
  *
2957
2972
  * @function
2958
2973
  * @param {PanelIconProps} props - Props for the PanelIcon component.
@@ -5127,6 +5142,16 @@ const Figure = withSubComponents(FigureComponent, {
5127
5142
  Caption: FigureCaption,
5128
5143
  }, 'Figure');
5129
5144
 
5145
+ /**
5146
+ * Distinguishes an `IconProps` object from a plain custom node (an inline SVG, a `react-icons`
5147
+ * component, …) passed to a slot that accepts either.
5148
+ */
5149
+ function isIconProps$1(value) {
5150
+ return (typeof value === 'object' &&
5151
+ value !== null &&
5152
+ !React.isValidElement(value) &&
5153
+ ('name' in value || 'children' in value));
5154
+ }
5130
5155
  /**
5131
5156
  * The `IconText` component provides a Bulma-styled horizontal arrangement of one or more `Icon` components and optional text.
5132
5157
  *
@@ -5146,7 +5171,9 @@ const IconTextComponent = ({ className, textColor, color, bgColor, iconProps, ch
5146
5171
  });
5147
5172
  const bulmaClasses = usePrefixedClassNames('icon-text');
5148
5173
  const iconTextClasses = classNames(bulmaClasses, bulmaHelperClasses, className);
5149
- return (jsxRuntime.jsx("span", { className: iconTextClasses, ...rest, children: items ? (items.map((item, index) => (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(Icon, { ...item.iconProps }), item.text && jsxRuntime.jsx("span", { children: item.text })] }, index)))) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconProps && jsxRuntime.jsx(Icon, { ...iconProps }), children && jsxRuntime.jsx("span", { children: children })] })) }));
5174
+ return (jsxRuntime.jsx("span", { className: iconTextClasses, ...rest, children: items ? (items.map((item, index) => (jsxRuntime.jsxs(React.Fragment, { children: [item.iconProps &&
5175
+ (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 &&
5176
+ (isIconProps$1(iconProps) ? (jsxRuntime.jsx(Icon, { ...iconProps })) : (jsxRuntime.jsx(Icon, { children: iconProps }))), children && jsxRuntime.jsx("span", { children: children })] })) }));
5150
5177
  };
5151
5178
  const IconText = withSubComponents(IconTextComponent, { Icon }, 'IconText');
5152
5179
 
@@ -6057,6 +6084,16 @@ const Checkbox = React.forwardRef(({ color, size, className, children, textColor
6057
6084
  });
6058
6085
  Checkbox.displayName = 'Checkbox';
6059
6086
 
6087
+ /**
6088
+ * Distinguishes an `IconProps` object from a plain custom node (an inline SVG, a `react-icons`
6089
+ * component, …) passed to a slot that accepts either.
6090
+ */
6091
+ function isIconProps(value) {
6092
+ return (typeof value === 'object' &&
6093
+ value !== null &&
6094
+ !React.isValidElement(value) &&
6095
+ ('name' in value || 'children' in value));
6096
+ }
6060
6097
  const allowedColors = [...validColors, 'inherit', 'current'];
6061
6098
  /**
6062
6099
  * 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.
@@ -6088,15 +6125,19 @@ const Control = React.forwardRef(({ as = 'div', hasIconsLeft, hasIconsRight, isL
6088
6125
  backgroundColor: safeBgColor,
6089
6126
  ...restProps,
6090
6127
  });
6091
- // Prepare icon props for the shortcut
6092
- const leftIconProps = iconLeft ||
6128
+ // Prepare icon props for the shortcut. A truthiness test (not `!== undefined`)
6129
+ // so a falsy node from the idiomatic `iconLeft={cond && <Node/>}` / `iconLeft={maybe ?? null}`
6130
+ // pattern counts as "no icon" — otherwise `false`/`null` would reserve the icon column and
6131
+ // mount an empty `.icon` span. A falsy `iconLeft` also correctly falls through to the
6132
+ // `iconLeftName` shortcut, matching the pre-node behavior.
6133
+ const leftIconValue = iconLeft ||
6093
6134
  (iconLeftName
6094
6135
  ? {
6095
6136
  name: iconLeftName,
6096
6137
  size: iconLeftSize,
6097
6138
  }
6098
6139
  : undefined);
6099
- const rightIconProps = iconRight ||
6140
+ const rightIconValue = iconRight ||
6100
6141
  (iconRightName
6101
6142
  ? {
6102
6143
  name: iconRightName,
@@ -6104,15 +6145,17 @@ const Control = React.forwardRef(({ as = 'div', hasIconsLeft, hasIconsRight, isL
6104
6145
  }
6105
6146
  : undefined);
6106
6147
  const mainClass = usePrefixedClassNames('control', {
6107
- 'has-icons-left': hasIconsLeft || !!leftIconProps,
6108
- 'has-icons-right': hasIconsRight || !!rightIconProps,
6148
+ 'has-icons-left': hasIconsLeft || !!leftIconValue,
6149
+ 'has-icons-right': hasIconsRight || !!rightIconValue,
6109
6150
  'is-loading': isLoading,
6110
6151
  'is-expanded': isExpanded,
6111
6152
  [`is-${size}`]: !!size,
6112
6153
  });
6113
6154
  const controlClass = classNames(mainClass, bulmaHelperClasses, className);
6114
6155
  // --- FIX: Spread both restProps (for data-testid, etc) AND rest (from useBulmaClasses) ---
6115
- return (jsxRuntime.jsx(ControlProvider, { value: true, children: jsxRuntime.jsxs(Component, { className: controlClass, ref: ref, ...restProps, ...rest, children: [children, leftIconProps && leftIconProps.name && (jsxRuntime.jsx(Icon, { ...leftIconProps, className: prefixedClassNames(classPrefix, 'is-left') })), rightIconProps && rightIconProps.name && (jsxRuntime.jsx(Icon, { ...rightIconProps, className: prefixedClassNames(classPrefix, 'is-right') }))] }) }));
6156
+ return (jsxRuntime.jsx(ControlProvider, { value: true, children: jsxRuntime.jsxs(Component, { className: controlClass, ref: ref, ...restProps, ...rest, children: [children, leftIconValue &&
6157
+ (isIconProps(leftIconValue) ? (jsxRuntime.jsx(Icon, { ...leftIconValue, className: prefixedClassNames(classPrefix, 'is-left') })) : (jsxRuntime.jsx(Icon, { className: prefixedClassNames(classPrefix, 'is-left'), children: leftIconValue }))), rightIconValue &&
6158
+ (isIconProps(rightIconValue) ? (jsxRuntime.jsx(Icon, { ...rightIconValue, className: prefixedClassNames(classPrefix, 'is-right') })) : (jsxRuntime.jsx(Icon, { className: prefixedClassNames(classPrefix, 'is-right'), children: rightIconValue })))] }) }));
6116
6159
  });
6117
6160
  Control.displayName = 'Control';
6118
6161