Skip to content

Commit 6112070

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) TextAreaRegionView fix
1 parent 54415aa commit 6112070

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

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

Lines changed: 33 additions & 23 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

@@ -52,7 +52,7 @@ const HtxTextAreaResultLine = forwardRef(
5252
);
5353

5454
const inputProps = {
55-
className: `ant-input ${styles.input}`,
55+
className: `ant-input ${styles.input} ${cn("textarea-tag").elem("input").toClassName()}`,
5656
value: displayValue,
5757
autoSize: isTextarea ? { minRows: 1 } : null,
5858
onChange: changeHandler,
@@ -70,23 +70,27 @@ const HtxTextAreaResultLine = forwardRef(
7070
}
7171
};
7272

73+
7374
return (
74-
<Elem name="item">
75-
<Elem name="input" tag={isTextarea ? TextArea : Input} {...inputProps} ref={ref} />
75+
<div className={cn("textarea-tag").elem("item").toClassName()}>
76+
{isTextarea ? (
77+
<TextArea {...inputProps} ref={ref} />
78+
) : (
79+
<Input {...inputProps} ref={ref} />
80+
)}
7681
{canDelete && !collapsed && !readOnly && (
77-
<Elem
78-
name="action"
82+
<Button
83+
className={cn("textarea-tag").elem("action").toClassName()}
7984
size="small"
8085
look="string"
8186
aria-label="Delete Region"
82-
tag={Button}
8387
leading={<IconTrash />}
8488
onClick={() => {
8589
onDelete(idx);
8690
}}
8791
/>
8892
)}
89-
</Elem>
93+
</div>
9094
);
9195
},
9296
);
@@ -193,7 +197,7 @@ const HtxTextAreaRegionView = observer(({ item, area, collapsed, setCollapsed, o
193197
ref: mainInputRef,
194198
value,
195199
rows: item.rows,
196-
className: "is-search",
200+
className: `is-search ${cn("textarea-tag").elem("input").toClassName()}` ,
197201
label: item.label,
198202
placeholder: item.placeholder,
199203
autoSize: isTextArea ? { minRows: 1 } : null,
@@ -245,7 +249,7 @@ const HtxTextAreaRegionView = observer(({ item, area, collapsed, setCollapsed, o
245249

246250
return (
247251
(result || showSubmit) && (
248-
<Block name="textarea-tag" mod={{ mode: item.mode, outliner }} style={styles}>
252+
<div className={cn("textarea-tag").mod({ mode: item.mode, outliner }).toClassName()} style={styles}>
249253
{result ? (
250254
<HtxTextAreaResult
251255
control={item}
@@ -258,9 +262,8 @@ const HtxTextAreaRegionView = observer(({ item, area, collapsed, setCollapsed, o
258262
) : null}
259263

260264
{showSubmit && (
261-
<Elem
262-
name="form"
263-
tag={Form}
265+
<Form
266+
className={cn("textarea-tag").elem("form").toClassName()}
264267
onFinish={() => {
265268
if (item.allowsubmit && item._value && !item.annotation.isReadOnly()) {
266269
submitValue();
@@ -271,17 +274,24 @@ const HtxTextAreaRegionView = observer(({ item, area, collapsed, setCollapsed, o
271274
e.stopPropagation();
272275
}}
273276
>
274-
<Elem
275-
name="input"
276-
tag={isTextArea ? TextArea : Input}
277-
{...props}
278-
onClick={(e) => {
279-
e.stopPropagation();
280-
}}
281-
/>
282-
</Elem>
277+
{isTextArea ? (
278+
<TextArea
279+
{...props}
280+
onClick={(e) => {
281+
e.stopPropagation();
282+
}}
283+
/>
284+
) : (
285+
<Input
286+
{...props}
287+
onClick={(e) => {
288+
e.stopPropagation();
289+
}}
290+
/>
291+
)}
292+
</Form>
283293
)}
284-
</Block>
294+
</div>
285295
)
286296
);
287297
});

0 commit comments

Comments
 (0)