diff --git a/web/libs/editor/src/common/Button/Button.tsx b/web/libs/editor/src/common/Button/Button.tsx index 9beb8ad4cbf2..07b0ac064a39 100644 --- a/web/libs/editor/src/common/Button/Button.tsx +++ b/web/libs/editor/src/common/Button/Button.tsx @@ -8,10 +8,11 @@ import { forwardRef, type ForwardRefExoticComponent, useMemo, + createElement, } from "react"; import { Hotkey } from "../../core/Hotkey"; import { useHotkey } from "../../hooks/useHotkey"; -import { Block, type CNTagName, Elem } from "../../utils/bem"; +import { cn, type CNTagName } from "../../utils/bem"; import { isDefined } from "../../utils/utilities"; import "./Button.scss"; @@ -107,18 +108,19 @@ export const Button: ButtonType = forwardRef( useHotkey(hotkey, rest.onClick as unknown as Keymaster.KeyHandler, hotkeyScope); - const buttonBody = ( - - <> - {iconElem && ( - - {iconElem} - - )} - {iconElem && children ? {children} : children} - {extra !== undefined ? {extra} : null} - - + const buttonBody = createElement( + finalTag as any, + { + ref, + type, + ...rest, + className: cn("button").mod(mods).mix(className).toClassName(), + }, + <> + {iconElem && {iconElem}} + {iconElem && children ? {children} : children} + {extra !== undefined ?
{extra}
: null} + , ); if ( @@ -147,11 +149,7 @@ export const Button: ButtonType = forwardRef( Button.displayName = "Button"; const Group: FC = ({ className, children, collapsed }) => { - return ( - - {children} - - ); + return
{children}
; }; Button.Group = Group; diff --git a/web/libs/editor/src/common/Dropdown/DropdownComponent.tsx b/web/libs/editor/src/common/Dropdown/DropdownComponent.tsx index 43d1487aedea..2a2c427e9927 100644 --- a/web/libs/editor/src/common/Dropdown/DropdownComponent.tsx +++ b/web/libs/editor/src/common/Dropdown/DropdownComponent.tsx @@ -12,7 +12,7 @@ import { } from "react"; import { createPortal } from "react-dom"; import { useFullscreen } from "../../hooks/useFullscreen"; -import { Block, cn } from "../../utils/bem"; +import { cn } from "../../utils/bem"; import { alignElements, type Align } from "@humansignal/core/lib/utils/dom"; import { aroundTransition } from "@humansignal/core/lib/utils/transition"; import "./Dropdown.scss"; @@ -213,11 +213,10 @@ export const Dropdown = forwardRef( }, [props.style, dropdownIndex, minIndex, offset]); const result = ( - ( onClick={(e: MouseEvent) => e.stopPropagation()} > {content} - + ); return props.inline === true ? result : createPortal(result, document.body); diff --git a/web/libs/editor/src/common/Icon/Icon.jsx b/web/libs/editor/src/common/Icon/Icon.jsx index 0e12b84f62cb..9562ac8c59e5 100644 --- a/web/libs/editor/src/common/Icon/Icon.jsx +++ b/web/libs/editor/src/common/Icon/Icon.jsx @@ -1,11 +1,11 @@ import React from "react"; -import { Block } from "../../utils/bem"; +import { cn } from "../../utils/bem"; import "./Icon.scss"; export const Icon = React.forwardRef(({ icon, ...props }, ref) => { return ( - + {React.createElement(icon, props)} - + ); }); diff --git a/web/libs/editor/src/common/Label/Label.jsx b/web/libs/editor/src/common/Label/Label.jsx index 2f8a9bf06dbd..ff0eca475f5a 100644 --- a/web/libs/editor/src/common/Label/Label.jsx +++ b/web/libs/editor/src/common/Label/Label.jsx @@ -1,5 +1,5 @@ -import { forwardRef } from "react"; -import { Block, Elem } from "../../utils/bem"; +import { createElement, forwardRef } from "react"; +import { cn } from "../../utils/bem"; import "./Label.scss"; export const Label = forwardRef( @@ -14,16 +14,21 @@ export const Label = forwardRef( empty: !children, }; - return ( - - - - {text} - {description && {description}} - - - {children} - + return createElement( + tagName, + { + ref, + style, + "data-required": required, + className: cn("field-label").mod(mods).toClassName(), + }, +
+
+ {text} + {description &&
{description}
} +
+
, +
{children}
, ); }, ); diff --git a/web/libs/editor/src/common/Menu/Menu.jsx b/web/libs/editor/src/common/Menu/Menu.jsx index 1d5921f61b2c..327b2e94248a 100644 --- a/web/libs/editor/src/common/Menu/Menu.jsx +++ b/web/libs/editor/src/common/Menu/Menu.jsx @@ -1,5 +1,5 @@ import { forwardRef, useCallback, useMemo } from "react"; -import { Block, cn } from "../../utils/bem"; +import { cn } from "../../utils/bem"; import { useDropdown } from "../Dropdown/DropdownTrigger"; import "./Menu.scss"; import { MenuContext } from "./MenuContext"; @@ -34,17 +34,14 @@ export const Menu = forwardRef( return ( - {children} - + ); }, diff --git a/web/libs/editor/src/common/Pagination/Pagination.tsx b/web/libs/editor/src/common/Pagination/Pagination.tsx index bc084a3f7e30..c25dbd762607 100644 --- a/web/libs/editor/src/common/Pagination/Pagination.tsx +++ b/web/libs/editor/src/common/Pagination/Pagination.tsx @@ -1,5 +1,5 @@ import { type ChangeEvent, type FC, forwardRef, type KeyboardEvent, useCallback, useMemo, useState } from "react"; -import { Block, Elem } from "../../utils/bem"; +import { cn } from "../../utils/bem"; import { Select } from "@humansignal/ui"; import { WithHotkey } from "../Hotkey/WithHotkey"; import "./Pagination.scss"; @@ -66,15 +66,15 @@ export const Pagination: FC = forwardRef( }, [pageSizeOptions]); return ( - - +
+
<> onChange?.(1)} disabled={currentPage === 1 || disabled} /> - +
= forwardRef( hotkey={hotkey?.prev} disabled={currentPage === 1 || disabled} /> - +
{inputMode ? ( = forwardRef( }} /> ) : ( - { setInputMode(true); }} @@ -128,9 +128,9 @@ export const Pagination: FC = forwardRef( /* */ }} /> - +
)} -
+
onChange?.(currentPage + 1)} @@ -138,20 +138,20 @@ export const Pagination: FC = forwardRef( hotkey={hotkey?.next} /> <> - +
onChange?.(totalPages)} disabled={currentPage === totalPages || disabled} /> - +
{pageSizeSelectable && ( - +