diff --git a/web/libs/editor/src/common/Button/Button.tsx b/web/libs/editor/src/common/Button/Button.tsx index 07b0ac064a39..9beb8ad4cbf2 100644 --- a/web/libs/editor/src/common/Button/Button.tsx +++ b/web/libs/editor/src/common/Button/Button.tsx @@ -8,11 +8,10 @@ import { forwardRef, type ForwardRefExoticComponent, useMemo, - createElement, } from "react"; import { Hotkey } from "../../core/Hotkey"; import { useHotkey } from "../../hooks/useHotkey"; -import { cn, type CNTagName } from "../../utils/bem"; +import { Block, type CNTagName, Elem } from "../../utils/bem"; import { isDefined } from "../../utils/utilities"; import "./Button.scss"; @@ -108,19 +107,18 @@ export const Button: ButtonType = forwardRef( useHotkey(hotkey, rest.onClick as unknown as Keymaster.KeyHandler, hotkeyScope); - 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} - , + const buttonBody = ( + + <> + {iconElem && ( + + {iconElem} + + )} + {iconElem && children ? {children} : children} + {extra !== undefined ? {extra} : null} + + ); if ( @@ -149,7 +147,11 @@ 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 2a2c427e9927..43d1487aedea 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 { cn } from "../../utils/bem"; +import { Block, 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,10 +213,11 @@ 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 9562ac8c59e5..0e12b84f62cb 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 { cn } from "../../utils/bem"; +import { Block } 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 ff0eca475f5a..2f8a9bf06dbd 100644 --- a/web/libs/editor/src/common/Label/Label.jsx +++ b/web/libs/editor/src/common/Label/Label.jsx @@ -1,5 +1,5 @@ -import { createElement, forwardRef } from "react"; -import { cn } from "../../utils/bem"; +import { forwardRef } from "react"; +import { Block, Elem } from "../../utils/bem"; import "./Label.scss"; export const Label = forwardRef( @@ -14,21 +14,16 @@ export const Label = forwardRef( empty: !children, }; - return createElement( - tagName, - { - ref, - style, - "data-required": required, - className: cn("field-label").mod(mods).toClassName(), - }, -
-
- {text} - {description &&
{description}
} -
-
, -
{children}
, + return ( + + + + {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 327b2e94248a..1d5921f61b2c 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 { cn } from "../../utils/bem"; +import { Block, cn } from "../../utils/bem"; import { useDropdown } from "../Dropdown/DropdownTrigger"; import "./Menu.scss"; import { MenuContext } from "./MenuContext"; @@ -34,14 +34,17 @@ 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 c25dbd762607..bc084a3f7e30 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 { cn } from "../../utils/bem"; +import { Block, Elem } 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 && ( -
+ ) => { setInputValue(e.target.value); handleSearch(e); @@ -130,7 +131,6 @@ const TaxonomySearch = React.forwardRef( placeholder={"Search"} data-testid={"taxonomy-search"} name={"taxonomy-search-input"} - className={cn("taxonomy-search-input").toClassName()} /> ); }); diff --git a/web/libs/editor/src/components/SidePanels/DetailsPanel/DetailsPanel.tsx b/web/libs/editor/src/components/SidePanels/DetailsPanel/DetailsPanel.tsx index 30774d9504ad..dc4a8788f2cc 100644 --- a/web/libs/editor/src/components/SidePanels/DetailsPanel/DetailsPanel.tsx +++ b/web/libs/editor/src/components/SidePanels/DetailsPanel/DetailsPanel.tsx @@ -1,6 +1,6 @@ import { inject, observer } from "mobx-react"; import type { FC } from "react"; -import { cn } from "../../../utils/bem"; +import { Block, Elem } from "../../../utils/bem"; import { Comments as CommentsComponent } from "../../Comments/Comments"; import { AnnotationHistory } from "../../CurrentEntity/AnnotationHistory"; import { PanelBase, type PanelProps } from "../PanelBase"; @@ -34,9 +34,9 @@ const DetailsComponent: FC = ({ currentEntity, regions }) => const selectedRegions = regions.selection; return ( -
+ -
+ ); }; @@ -49,17 +49,17 @@ const CommentsTab: FC = inject("store")( return ( <> {store.hasInterface("annotations:comments") && store.commentStore.isCommentable && ( -
-
-
+ + + -
-
-
+
+ + )} ); @@ -73,19 +73,17 @@ const RelationsTab: FC = inject("store")( return ( <> -
-
+ + {hasRelations ? ( <> -
-
- Relations ({relationStore.size}) -
+ + Relations ({relationStore.size}) -
-
+ + -
+
) : ( = inject("store")( }} /> )} -
-
+ + ); }), @@ -112,8 +110,8 @@ const HistoryTab: FC = inject("store")( return ( <> -
-
+ + = inject("store")( } /> -
-
+ + ); }), @@ -136,8 +134,8 @@ const InfoTab: FC = inject("store")( const nothingSelected = !selection || selection.size === 0; return ( <> -
-
+ + {nothingSelected ? ( } @@ -149,8 +147,8 @@ const InfoTab: FC = inject("store")( )} -
-
+ + ); }), @@ -162,7 +160,7 @@ const GeneralPanel: FC = inject("store")( const showAnnotationHistory = store.hasInterface("annotations:history"); return ( <> -
+ = inject("store")( } /> -
-
-
-
Relations ({relationStore.size})
+ + + + Relations ({relationStore.size}) -
-
+ + -
-
+ + {store.hasInterface("annotations:comments") && store.commentStore.isCommentable && ( -
-
Comments
-
+ + Comments + -
-
+ + )} ); diff --git a/web/libs/editor/src/components/SidePanels/DetailsPanel/RegionDetails.tsx b/web/libs/editor/src/components/SidePanels/DetailsPanel/RegionDetails.tsx index dd3f074884d3..15c20a2b4e5b 100644 --- a/web/libs/editor/src/components/SidePanels/DetailsPanel/RegionDetails.tsx +++ b/web/libs/editor/src/components/SidePanels/DetailsPanel/RegionDetails.tsx @@ -1,6 +1,6 @@ import { observer } from "mobx-react"; import { type FC, useEffect, useMemo, useRef } from "react"; -import { cn } from "../../../utils/bem"; +import { Block, Elem, useBEM } from "../../../utils/bem"; import { RegionEditor } from "./RegionEditor"; import "./RegionDetails.scss"; import { Typography } from "@humansignal/ui"; @@ -48,53 +48,53 @@ export const ResultItem: FC<{ result: any }> = observer(({ result }) => { const content = useMemo(() => { if (type === "rating") { return ( -
+ Rating: -
+ -
-
+ + ); } if (type === "textarea") { return ( -
+ Text: -
+ -
-
+ + ); } if (type === "choices") { return ( -
+ Choices: -
+ -
-
+ + ); } if (type === "taxonomy") { return ( -
+ Taxonomy: -
+ v.join("/"))} /> -
-
+ + ); } }, [type, mainValue]); - return content ?
{content}
: null; + return content ? {content} : null; }); export const RegionDetailsMain: FC<{ region: any }> = observer(({ region }) => { return ( <> -
+ {(region?.results as any[]) // hide per-regions stored only in this session just for a better UX .filter((res) => res.canBeSubmitted) @@ -104,15 +104,15 @@ export const RegionDetailsMain: FC<{ region: any }> = observer(({ region }) => { {/* @todo dirty hack to not duplicate text for OCR regions */} {/* @todo should be converted into universal solution */} {region?.text && !region?.ocrtext ? ( -
-
-
+ + + {region.text.replace(/\\n/g, "\n")} -
-
-
+
+ + ) : null} -
+ ); @@ -127,6 +127,7 @@ type RegionDetailsMetaProps = { export const RegionDetailsMeta: FC = observer( ({ region, editMode, cancelEditMode, enterEditMode }) => { + const bem = useBEM(); const input = useRef(); const saveMeta = (value: string) => { @@ -148,7 +149,7 @@ export const RegionDetailsMeta: FC = observer(