@xsolla/xui-button 0.191.0 → 0.192.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/web/index.mjs CHANGED
@@ -831,7 +831,7 @@ var IconButton = ({
831
831
  IconButton.displayName = "IconButton";
832
832
 
833
833
  // src/FlexButton.tsx
834
- import {
834
+ import React5, {
835
835
  useRef,
836
836
  useState as useState3
837
837
  } from "react";
@@ -839,10 +839,20 @@ import { useDesignSystem } from "@xsolla/xui-core";
839
839
  import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
840
840
  var FLEX_BUTTON_PADDING = 4;
841
841
  var hasVisibleLabel = (node) => {
842
- if (node == null || node === false) return false;
842
+ if (node == null || node === false || node === true) return false;
843
843
  if (typeof node === "string") return node.trim().length > 0;
844
844
  if (typeof node === "number") return true;
845
845
  if (Array.isArray(node)) return node.some(hasVisibleLabel);
846
+ if (React5.isValidElement(node)) {
847
+ const { children: elementChildren } = node.props ?? {};
848
+ return hasVisibleLabel(elementChildren);
849
+ }
850
+ return true;
851
+ };
852
+ var hasRenderableContent = (node) => {
853
+ if (node == null || node === false || node === true) return false;
854
+ if (typeof node === "string") return node.trim().length > 0;
855
+ if (Array.isArray(node)) return node.some(hasRenderableContent);
846
856
  return true;
847
857
  };
848
858
  var ICON_SIZES = {
@@ -1044,8 +1054,10 @@ var FlexButton = ({
1044
1054
  const fontSize = FONT_SIZES[size];
1045
1055
  const borderRadius = BORDER_RADIUS[size];
1046
1056
  const lineHeight = LINE_HEIGHTS[size];
1047
- const isIconOnly = !loading && !hasVisibleLabel(children) && Boolean(iconLeft || iconRight);
1048
- const iconOnlyHitArea = iconSize + FLEX_BUTTON_PADDING * 2;
1057
+ const showTextLabel = hasVisibleLabel(children);
1058
+ const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1059
+ const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
1060
+ const iconOnlyHitArea = theme.sizing.flexButton(size).height;
1049
1061
  const handleMouseEnter = () => {
1050
1062
  if (!isDisabled) {
1051
1063
  isMouseOverRef.current = true;
@@ -1185,7 +1197,8 @@ var FlexButton = ({
1185
1197
  "data-testid": testID || "flex-button",
1186
1198
  children: /* @__PURE__ */ jsx7("span", { style: contentStyle, children: loading ? /* @__PURE__ */ jsx7("span", { style: spinnerStyle, children: /* @__PURE__ */ jsx7(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
1187
1199
  iconLeft && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1188
- hasVisibleLabel(children) && /* @__PURE__ */ jsx7("span", { children }),
1200
+ showTextLabel && /* @__PURE__ */ jsx7("span", { children }),
1201
+ hasIconChildren && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children }),
1189
1202
  iconRight && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconRight })
1190
1203
  ] }) })
1191
1204
  }