Skip to content

Commit d900b9c

Browse files
committed
refactor(bem): replace Block/Elem with cn() in TextAreaRegionView.jsx
Migrated TextAreaRegionView component from Block/Elem to cn() helper. - Replaced Block/Elem imports with cn import - Replaced <Block name="textarea-tag"> with <div className={cn("textarea-tag")...}> - Replaced <Elem name="item"> with <div className={cn("textarea-tag").elem("item")...}> - Replaced <Elem name="form" tag={Form}> with <Form className={cn("textarea-tag").elem("form")...}> - Replaced <Elem name="input" tag={...}> with dynamic Input/TextArea components - Replaced <Elem name="action" tag={Button}> with <Button className={cn("textarea-tag").elem("action")...}> - HtxTextAreaResultLine component uses parent Block "textarea-tag" for all Elems - Dynamic tag (Input vs TextArea) handled with conditional rendering - Preserved refs, mods, styles, and all props - Added type assertion for styles with CSS custom properties - No behavior change, equivalent class strings Note: Elem "item" under Block "textarea-tag" generates dm-textarea-tag__item (different from dm-choice__item in Choice.jsx - no CSS conflict)
1 parent 3822b8f commit d900b9c

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

web/libs/editor/src/tags/control/TextArea/TextAreaRegionView.jsx

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IconTrash } from "@humansignal/icons";
88
import styles from "../../../components/HtxTextBox/HtxTextBox.module.scss";
99
import Registry from "../../../core/Registry";
1010
import { PER_REGION_MODES } from "../../../mixins/PerRegion";
11-
import { Block, Elem } from "../../../utils/bem";
11+
import { cn } from "../../../utils/bem";
1212

1313
import "./TextArea.scss";
1414

@@ -71,22 +71,25 @@ const HtxTextAreaResultLine = forwardRef(
7171
};
7272

7373
return (
74-
<Elem name="item">
75-
<Elem name="input" tag={isTextarea ? TextArea : Input} {...inputProps} ref={ref} />
74+
<div className={cn("textarea-tag").elem("item").toClassName()}>
75+
{isTextarea ? (
76+
<TextArea className={cn("textarea-tag").elem("input").toClassName()} {...inputProps} ref={ref} />
77+
) : (
78+
<Input className={cn("textarea-tag").elem("input").toClassName()} {...inputProps} ref={ref} />
79+
)}
7680
{canDelete && !collapsed && !readOnly && (
77-
<Elem
78-
name="action"
81+
<Button
82+
className={cn("textarea-tag").elem("action").toClassName()}
7983
size="small"
8084
look="string"
8185
aria-label="Delete Region"
82-
tag={Button}
8386
leading={<IconTrash />}
8487
onClick={() => {
8588
onDelete(idx);
8689
}}
8790
/>
8891
)}
89-
</Elem>
92+
</div>
9093
);
9194
},
9295
);
@@ -245,7 +248,7 @@ const HtxTextAreaRegionView = observer(({ item, area, collapsed, setCollapsed, o
245248

246249
return (
247250
(result || showSubmit) && (
248-
<Block name="textarea-tag" mod={{ mode: item.mode, outliner }} style={styles}>
251+
<div className={cn("textarea-tag").mod({ mode: item.mode, outliner }).toClassName()} style={styles as any}>
249252
{result ? (
250253
<HtxTextAreaResult
251254
control={item}
@@ -258,9 +261,8 @@ const HtxTextAreaRegionView = observer(({ item, area, collapsed, setCollapsed, o
258261
) : null}
259262

260263
{showSubmit && (
261-
<Elem
262-
name="form"
263-
tag={Form}
264+
<Form
265+
className={cn("textarea-tag").elem("form").toClassName()}
264266
onFinish={() => {
265267
if (item.allowsubmit && item._value && !item.annotation.isReadOnly()) {
266268
submitValue();
@@ -271,17 +273,26 @@ const HtxTextAreaRegionView = observer(({ item, area, collapsed, setCollapsed, o
271273
e.stopPropagation();
272274
}}
273275
>
274-
<Elem
275-
name="input"
276-
tag={isTextArea ? TextArea : Input}
277-
{...props}
278-
onClick={(e) => {
279-
e.stopPropagation();
280-
}}
281-
/>
282-
</Elem>
276+
{isTextArea ? (
277+
<TextArea
278+
className={cn("textarea-tag").elem("input").toClassName()}
279+
{...props}
280+
onClick={(e) => {
281+
e.stopPropagation();
282+
}}
283+
/>
284+
) : (
285+
<Input
286+
className={cn("textarea-tag").elem("input").toClassName()}
287+
{...props}
288+
onClick={(e) => {
289+
e.stopPropagation();
290+
}}
291+
/>
292+
)}
293+
</Form>
283294
)}
284-
</Block>
295+
</div>
285296
)
286297
);
287298
});

0 commit comments

Comments
 (0)