Skip to content

Commit 6b294b2

Browse files
committed
refactor: trim verbose JSDoc comments and use CodebuffTransaction type
1 parent d56740c commit 6b294b2

File tree

4 files changed

+22
-293
lines changed

4 files changed

+22
-293
lines changed

cli/src/components/clickable.tsx

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@ import React, { cloneElement, isValidElement, memo } from 'react'
22
import type { ReactElement, ReactNode } from 'react'
33

44
/**
5-
* Makes all text content within a React node tree non-selectable.
6-
*
7-
* This is important for interactive elements (buttons, clickable boxes) because
8-
* text inside them should not be selectable when the user clicks - it creates
9-
* a poor UX where text gets highlighted during interactions.
10-
*
11-
* Handles both `<text>` and `<span>` OpenTUI elements by adding `selectable={false}`.
12-
*
13-
* @example
14-
* ```tsx
15-
* // Use this when building custom interactive components
16-
* const processedChildren = makeTextUnselectable(children)
17-
* return <box onMouseDown={handleClick}>{processedChildren}</box>
18-
* ```
5+
* Makes all `<text>` and `<span>` children non-selectable.
6+
* Use for interactive elements where text selection during clicks is undesirable.
197
*/
208
export function makeTextUnselectable(node: ReactNode): ReactNode {
219
if (node === null || node === undefined || typeof node === 'boolean') return node
@@ -56,34 +44,8 @@ interface ClickableProps {
5644
}
5745

5846
/**
59-
* A wrapper component for any interactive/clickable area in the CLI.
60-
*
61-
* **Why use this instead of raw `<box>` or `<text>` with mouse handlers?**
62-
*
63-
* This component automatically makes all text content non-selectable, which is
64-
* essential for good UX - users shouldn't accidentally select text when clicking
65-
* interactive elements.
66-
*
67-
* **The `as` prop:**
68-
* - `as="box"` (default) - Renders a `<box>` element for layout containers
69-
* - `as="text"` - Renders a `<text>` element for inline clickable text
70-
*
71-
* **When to use `Clickable` vs `Button`:**
72-
* - Use `Button` for actual button-like interactions (has click-on-mouseup logic)
73-
* - Use `Clickable` for simpler interactive areas where you need direct mouse event control
74-
*
75-
* @example
76-
* ```tsx
77-
* // Default: renders <box>
78-
* <Clickable onMouseDown={handleClick}>
79-
* <text>Click me</text>
80-
* </Clickable>
81-
*
82-
* // For inline text: renders <text>
83-
* <Clickable as="text" onMouseDown={handleCopy}>
84-
* <span>⎘ copy</span>
85-
* </Clickable>
86-
* ```
47+
* Wrapper for interactive areas. Makes text non-selectable automatically.
48+
* Use `as="text"` for inline clickable text, default is `as="box"`.
8749
*/
8850
export const Clickable = memo(function Clickable({
8951
as = 'box',

0 commit comments

Comments
 (0)