@lumx/react 4.22.0 → 4.22.1-alpha.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/index.d.ts CHANGED
@@ -802,7 +802,7 @@ interface ButtonProps extends GenericProps$1, ReactToJSX<ButtonProps$1> {
802
802
  * @param ref Component ref.
803
803
  * @return React element.
804
804
  */
805
- declare const Button: Comp<ButtonProps, HTMLAnchorElement | HTMLButtonElement>;
805
+ declare const Button: Comp<ButtonProps, HTMLButtonElement | HTMLAnchorElement>;
806
806
 
807
807
  interface IconButtonProps$1 extends BaseButtonProps {
808
808
  /**
@@ -2262,7 +2262,7 @@ declare const Combobox: {
2262
2262
  /** Provides shared combobox context (handle, listbox ID, anchor ref) to all sub-components. */
2263
2263
  Provider: typeof ComboboxProvider;
2264
2264
  /** Button trigger for select-only combobox mode with keyboard navigation and typeahead. */
2265
- Button: (<E extends React$1.ElementType = Comp<ButtonProps, HTMLAnchorElement | HTMLButtonElement>>(props: Omit<HasPolymorphicAs$1<E>, "children" | "role" | "aria-activedescendant" | "aria-controls" | "aria-expanded" | "aria-haspopup"> & _lumx_core_js_types.HasRequiredLinkHref<E> & ReactToJSX<ComboboxButtonProps$1> & React$1.ComponentProps<E> & {
2265
+ Button: (<E extends React$1.ElementType = Comp<ButtonProps, HTMLButtonElement | HTMLAnchorElement>>(props: Omit<HasPolymorphicAs$1<E>, "children" | "aria-expanded" | "aria-haspopup" | "role" | "aria-controls" | "aria-activedescendant"> & _lumx_core_js_types.HasRequiredLinkHref<E> & ReactToJSX<ComboboxButtonProps$1> & React$1.ComponentProps<E> & {
2266
2266
  ref?: ComponentRef<E> | undefined;
2267
2267
  }) => React.JSX.Element) & {
2268
2268
  displayName: string;
@@ -2838,7 +2838,7 @@ declare const GenericBlockGapSize: Pick<{
2838
2838
  readonly medium: "medium";
2839
2839
  readonly big: "big";
2840
2840
  readonly huge: "huge";
2841
- }, "big" | "tiny" | "medium" | "regular" | "huge">;
2841
+ }, "big" | "medium" | "tiny" | "regular" | "huge">;
2842
2842
  type GenericBlockGapSize = ValueOf<typeof GenericBlockGapSize>;
2843
2843
 
2844
2844
  interface GenericBlockProps$1 extends FlexBoxProps$1 {
@@ -3033,7 +3033,7 @@ interface GridColumnProps extends GenericProps$1, ReactToJSX<GridColumnProps$1>
3033
3033
  */
3034
3034
  declare const GridColumn: Comp<GridColumnProps, HTMLElement>;
3035
3035
 
3036
- declare const ICON_SIZES: ("s" | "m" | "xxs" | "xs" | "l" | "xl" | "xxl")[];
3036
+ declare const ICON_SIZES: ("m" | "s" | "xxs" | "xs" | "l" | "xl" | "xxl")[];
3037
3037
 
3038
3038
  type IconSizes = (typeof ICON_SIZES)[number];
3039
3039
  /**
@@ -3537,7 +3537,7 @@ interface LinkProps extends GenericProps$1, ReactToJSX<LinkProps$1> {
3537
3537
  * @param ref Component ref.
3538
3538
  * @return React element.
3539
3539
  */
3540
- declare const Link: Comp<LinkProps, HTMLAnchorElement | HTMLButtonElement>;
3540
+ declare const Link: Comp<LinkProps, HTMLButtonElement | HTMLAnchorElement>;
3541
3541
 
3542
3542
  /**
3543
3543
  * Defines the props of the component.
package/index.js CHANGED
@@ -2760,20 +2760,37 @@ const useOverflowTooltipLabel = content => {
2760
2760
  */
2761
2761
  const isComponentType = type => node => /*#__PURE__*/React__default.isValidElement(node) && node.type === type;
2762
2762
 
2763
- /** Force wrap spaces around icons to make sure they are never stuck against text. */
2764
- function wrapChildrenIconWithSpaces(children) {
2763
+ /**
2764
+ * Recursively wrap icons with spaces.
2765
+ *
2766
+ * `isFirst`/`isLast` tell whether the given children are at the very start/end of the whole
2767
+ * children tree, so that an icon on an edge is detected even when nested in a fragment or element.
2768
+ */
2769
+ function wrap(children, isFirst, isLast) {
2765
2770
  if (children === null || children === undefined) return undefined;
2766
- return Children.toArray(children).flatMap(child => {
2771
+ const childArray = Children.toArray(children);
2772
+ return childArray.flatMap((child, index) => {
2773
+ const childIsFirst = isFirst && index === 0;
2774
+ const childIsLast = isLast && index === childArray.length - 1;
2767
2775
  if (isComponentType(Icon)(child)) {
2768
- return [' ', child, ' '];
2776
+ // No space on the edges of the text: the icon is not stuck against anything there.
2777
+ return [...(childIsFirst ? [] : [' ']), child, ...(childIsLast ? [] : [' '])];
2769
2778
  }
2770
2779
  if (/*#__PURE__*/React__default.isValidElement(child) && child.props && typeof child.props === 'object' && 'children' in child.props) {
2771
- return /*#__PURE__*/React__default.cloneElement(child, undefined, wrapChildrenIconWithSpaces(child.props.children));
2780
+ return /*#__PURE__*/React__default.cloneElement(child, undefined, wrap(child.props.children, childIsFirst, childIsLast));
2772
2781
  }
2773
2782
  return child;
2774
2783
  });
2775
2784
  }
2776
2785
 
2786
+ /**
2787
+ * Force wrap spaces around icons to make sure they are never stuck against text.
2788
+ * Icons at the very start or end of the text are not padded on that side.
2789
+ */
2790
+ function wrapChildrenIconWithSpaces(children) {
2791
+ return wrap(children, true, true);
2792
+ }
2793
+
2777
2794
  /**
2778
2795
  * Defines the props of the component.
2779
2796
  */