@redis-ui/components 51.26.0 → 51.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.cjs +17 -8
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.js +17 -8
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.d.ts +5 -1
- package/dist/CodeBlock/CodeBlock.cjs +29 -14
- package/dist/CodeBlock/CodeBlock.js +29 -14
- package/dist/CodeBlock/CodeBlock.style.d.ts +4 -3
- package/dist/CodeBlock/CodeBlock.types.cjs +7 -0
- package/dist/CodeBlock/CodeBlock.types.d.ts +4 -0
- package/dist/CodeBlock/CodeBlock.types.js +7 -1
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.cjs +29 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.cjs +34 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.d.ts +25 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.js +32 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.d.ts +6 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.js +29 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.d.ts +10 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.js +1 -0
- package/dist/Inputs/Input/Input.cjs +9 -2
- package/dist/Inputs/Input/Input.d.ts +4 -1
- package/dist/Inputs/Input/Input.js +9 -2
- package/dist/Inputs/Input/Input.types.d.ts +5 -1
- package/dist/Inputs/PasswordInput/components/Compose/Compose.types.d.ts +1 -1
- package/dist/Inputs/TextArea/TextArea.cjs +16 -6
- package/dist/Inputs/TextArea/TextArea.d.ts +3 -1
- package/dist/Inputs/TextArea/TextArea.js +16 -6
- package/dist/Inputs/TextArea/TextArea.types.d.ts +4 -1
- package/dist/Inputs/TextArea/components/CopyButton/CopyButton.cjs +7 -0
- package/dist/Inputs/TextArea/components/CopyButton/CopyButton.d.ts +2 -0
- package/dist/Inputs/TextArea/components/CopyButton/CopyButton.js +7 -0
- package/dist/Inputs/TextArea/components/CopyButton/CopyButton.style.cjs +17 -0
- package/dist/Inputs/TextArea/components/CopyButton/CopyButton.style.d.ts +1 -0
- package/dist/Inputs/TextArea/components/CopyButton/CopyButton.style.js +15 -0
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.cjs +3 -1
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.js +4 -2
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.style.cjs +8 -1
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.style.js +8 -1
- package/dist/Inputs/components/Compose/CommonCompose.cjs +23 -18
- package/dist/Inputs/components/Compose/CommonCompose.d.ts +1 -1
- package/dist/Inputs/components/Compose/CommonCompose.js +24 -19
- package/dist/Inputs/components/Compose/CommonCompose.types.d.ts +2 -0
- package/dist/Inputs/components/Compose/Compose.style.cjs +7 -0
- package/dist/Inputs/components/Compose/Compose.style.js +7 -0
- package/dist/Inputs/components/Compose/NumericCompose.types.d.ts +1 -1
- package/dist/Inputs/components/CopyButton/CopyButton.cjs +15 -0
- package/dist/Inputs/components/CopyButton/CopyButton.d.ts +2 -0
- package/dist/Inputs/components/CopyButton/CopyButton.js +15 -0
- package/dist/Inputs/components/CopyButton/CopyButton.style.cjs +17 -0
- package/dist/Inputs/components/CopyButton/CopyButton.style.d.ts +1 -0
- package/dist/Inputs/components/CopyButton/CopyButton.style.js +15 -0
- package/dist/Inputs/components/CopyButton/CopyButton.types.d.ts +6 -0
- package/dist/Inputs/components/CopyButton/CopyButton.types.js +1 -0
- package/dist/Inputs/components/InputTag/InputTag.cjs +3 -1
- package/dist/Inputs/components/InputTag/InputTag.js +4 -2
- package/dist/Inputs/components/InputTag/InputTag.style.cjs +1 -1
- package/dist/Inputs/components/InputTag/InputTag.style.js +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.js +2 -2
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.cjs +8 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +8 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.cjs +7 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +7 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.cjs +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.js +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/extends.cjs +17 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.cjs +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.cjs +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.cjs +13 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +13 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.cjs +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.cjs +10 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +10 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.cjs +14 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.cjs +9 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/typeof.cjs +16 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.cjs +11 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +11 -0
- package/dist/node_modules/character-entities-legacy/index.cjs +116 -0
- package/dist/node_modules/character-entities-legacy/index.js +116 -0
- package/dist/node_modules/character-reference-invalid/index.cjs +38 -0
- package/dist/node_modules/character-reference-invalid/index.js +38 -0
- package/dist/node_modules/comma-separated-tokens/index.cjs +43 -0
- package/dist/node_modules/comma-separated-tokens/index.js +43 -0
- package/dist/node_modules/decode-named-character-reference/index.dom.cjs +15 -0
- package/dist/node_modules/decode-named-character-reference/index.dom.js +15 -0
- package/dist/node_modules/hast-util-parse-selector/lib/index.cjs +76 -0
- package/dist/node_modules/hast-util-parse-selector/lib/index.js +76 -0
- package/dist/node_modules/hastscript/lib/create-h.cjs +262 -0
- package/dist/node_modules/hastscript/lib/create-h.js +262 -0
- package/dist/node_modules/hastscript/lib/index.cjs +21 -0
- package/dist/node_modules/hastscript/lib/index.js +21 -0
- package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.cjs +49 -0
- package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js +49 -0
- package/dist/node_modules/is-alphabetical/index.cjs +14 -0
- package/dist/node_modules/is-alphabetical/index.js +14 -0
- package/dist/node_modules/is-alphanumerical/index.cjs +15 -0
- package/dist/node_modules/is-alphanumerical/index.js +15 -0
- package/dist/node_modules/is-decimal/index.cjs +14 -0
- package/dist/node_modules/is-decimal/index.js +14 -0
- package/dist/node_modules/is-hexadecimal/index.cjs +14 -0
- package/dist/node_modules/is-hexadecimal/index.js +14 -0
- package/dist/node_modules/parse-entities/lib/index.cjs +232 -0
- package/dist/node_modules/parse-entities/lib/index.js +232 -0
- package/dist/node_modules/property-information/index.cjs +27 -0
- package/dist/node_modules/property-information/index.js +26 -0
- package/dist/node_modules/property-information/lib/aria.cjs +60 -0
- package/dist/node_modules/property-information/lib/aria.js +61 -0
- package/dist/node_modules/property-information/lib/find.cjs +81 -0
- package/dist/node_modules/property-information/lib/find.js +81 -0
- package/dist/node_modules/property-information/lib/html.cjs +326 -0
- package/dist/node_modules/property-information/lib/html.js +326 -0
- package/dist/node_modules/property-information/lib/normalize.cjs +15 -0
- package/dist/node_modules/property-information/lib/normalize.js +15 -0
- package/dist/node_modules/property-information/lib/svg.cjs +564 -0
- package/dist/node_modules/property-information/lib/svg.js +564 -0
- package/dist/node_modules/property-information/lib/util/case-insensitive-transform.cjs +15 -0
- package/dist/node_modules/property-information/lib/util/case-insensitive-transform.js +15 -0
- package/dist/node_modules/property-information/lib/util/case-sensitive-transform.cjs +14 -0
- package/dist/node_modules/property-information/lib/util/case-sensitive-transform.js +14 -0
- package/dist/node_modules/property-information/lib/util/create.cjs +53 -0
- package/dist/node_modules/property-information/lib/util/create.js +53 -0
- package/dist/node_modules/property-information/lib/util/defined-info.cjs +49 -0
- package/dist/node_modules/property-information/lib/util/defined-info.js +49 -0
- package/dist/node_modules/property-information/lib/util/info.cjs +33 -0
- package/dist/node_modules/property-information/lib/util/info.js +33 -0
- package/dist/node_modules/property-information/lib/util/merge.cjs +26 -0
- package/dist/node_modules/property-information/lib/util/merge.js +26 -0
- package/dist/node_modules/property-information/lib/util/schema.cjs +27 -0
- package/dist/node_modules/property-information/lib/util/schema.js +27 -0
- package/dist/node_modules/property-information/lib/util/types.cjs +35 -0
- package/dist/node_modules/property-information/lib/util/types.js +24 -0
- package/dist/node_modules/property-information/lib/xlink.cjs +18 -0
- package/dist/node_modules/property-information/lib/xlink.js +19 -0
- package/dist/node_modules/property-information/lib/xml.cjs +14 -0
- package/dist/node_modules/property-information/lib/xml.js +15 -0
- package/dist/node_modules/property-information/lib/xmlns.cjs +14 -0
- package/dist/node_modules/property-information/lib/xmlns.js +14 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.cjs +6 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.js +6 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.cjs +183 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js +181 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.cjs +308 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js +306 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.cjs +12 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.js +12 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.cjs +121 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.js +121 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.cjs +147 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js +147 -0
- package/dist/node_modules/refractor/lang/bash.cjs +190 -0
- package/dist/node_modules/refractor/lang/bash.js +190 -0
- package/dist/node_modules/refractor/lang/clike.cjs +37 -0
- package/dist/node_modules/refractor/lang/clike.js +37 -0
- package/dist/node_modules/refractor/lang/javascript.cjs +122 -0
- package/dist/node_modules/refractor/lang/javascript.js +122 -0
- package/dist/node_modules/refractor/lang/json.cjs +36 -0
- package/dist/node_modules/refractor/lang/json.js +36 -0
- package/dist/node_modules/refractor/lang/python.cjs +71 -0
- package/dist/node_modules/refractor/lang/python.js +71 -0
- package/dist/node_modules/refractor/lang/typescript.cjs +55 -0
- package/dist/node_modules/refractor/lang/typescript.js +55 -0
- package/dist/node_modules/refractor/lib/core.cjs +214 -0
- package/dist/node_modules/refractor/lib/core.js +214 -0
- package/dist/node_modules/refractor/lib/prism-core.cjs +595 -0
- package/dist/node_modules/refractor/lib/prism-core.js +595 -0
- package/dist/node_modules/space-separated-tokens/index.cjs +15 -0
- package/dist/node_modules/space-separated-tokens/index.js +15 -0
- package/package.json +4 -2
- package/skills/redis-ui-components/references/CodeBlock.md +23 -5
- package/skills/redis-ui-components/references/CopyToClipboardButton.md +23 -1
- package/skills/redis-ui-components/references/Input.md +39 -2
- package/skills/redis-ui-components/references/SearchInput.md +1 -1
- package/skills/redis-ui-components/references/TextArea.md +19 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CodeBlock
|
|
2
2
|
|
|
3
|
-
A multi-line code block for snippets, commands and JSON, with
|
|
3
|
+
A multi-line code block for snippets, commands and JSON, with optional syntax highlighting and a copy button. Use `Typography.Code` for inline code.
|
|
4
4
|
|
|
5
5
|
## Import
|
|
6
6
|
```tsx
|
|
@@ -11,6 +11,7 @@ import { CodeBlock } from '@redis-ui/components';
|
|
|
11
11
|
| Prop | Type | Default | Description |
|
|
12
12
|
|------|------|---------|-------------|
|
|
13
13
|
| code | `string` | *required* | Text rendered in the block and copied by the copy button |
|
|
14
|
+
| language | `'bash' \| 'json' \| 'python' \| 'typescript'` | - | Highlights the code's syntax. Without it, the code is plain text |
|
|
14
15
|
| copyLabel | `string` | - | Shows a copy button and is used as its accessible name |
|
|
15
16
|
| overflow | `'scroll' \| 'wrap' \| 'ellipsis'` | `'scroll'` | How long lines behave: scroll horizontally, wrap (use for commands and prompts), or truncate with an ellipsis |
|
|
16
17
|
| maxHeight | `string` | - | Scrolls vertically past this height (any CSS length, e.g. `'19rem'`) |
|
|
@@ -22,12 +23,12 @@ import { CodeBlock } from '@redis-ui/components';
|
|
|
22
23
|
### Playground
|
|
23
24
|
|
|
24
25
|
```tsx
|
|
25
|
-
import { CodeBlock
|
|
26
|
+
import { CodeBlock } from '@redis-ui/components';
|
|
26
27
|
|
|
27
|
-
<CodeBlock code={lensSnippet} copyLabel="Copy code" overflow="scroll" size="M" />
|
|
28
|
+
<CodeBlock code={lensSnippet} language="typescript" copyLabel="Copy code" overflow="scroll" size="M" />
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
`codeBlockOverflows` and `codeBlockSizes` list the allowed `overflow` and `size` values, e.g. for controls.
|
|
31
|
+
`codeBlockLanguages`, `codeBlockOverflows` and `codeBlockSizes` list the allowed `language`, `overflow` and `size` values, e.g. for controls.
|
|
31
32
|
|
|
32
33
|
### Default
|
|
33
34
|
|
|
@@ -86,8 +87,25 @@ import { CodeBlock, codeBlockSizes } from '@redis-ui/components';
|
|
|
86
87
|
))}
|
|
87
88
|
```
|
|
88
89
|
|
|
90
|
+
### Languages
|
|
91
|
+
|
|
92
|
+
> `language` highlights the syntax of bash, JSON, Python or TypeScript code.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { CodeBlock, codeBlockLanguages } from '@redis-ui/components';
|
|
96
|
+
|
|
97
|
+
{codeBlockLanguages.map((language) => (
|
|
98
|
+
<CodeBlock
|
|
99
|
+
key={language}
|
|
100
|
+
code={languageSnippets[language]}
|
|
101
|
+
language={language}
|
|
102
|
+
copyLabel="Copy code"
|
|
103
|
+
/>
|
|
104
|
+
))}
|
|
105
|
+
```
|
|
106
|
+
|
|
89
107
|
## Notes
|
|
90
108
|
- The component forwards refs to the root element.
|
|
91
109
|
- When the content scrolls, the block becomes keyboard-focusable so it can be scrolled with the keyboard. Truncated lines (`overflow="ellipsis"`) don't count.
|
|
92
110
|
- The copy button is `CopyToClipboardButton`, centered on the first code line in the top-right corner.
|
|
93
|
-
-
|
|
111
|
+
- Without `language`, `code` is rendered as plain text. With it, the syntax is highlighted with the VS palette in light themes and VS Code Dark+ in dark themes, and bash commands, including `npx` and `pip`, are colored as keywords.
|
|
@@ -13,7 +13,9 @@ import { CopyToClipboardButton } from '@redis-ui/components';
|
|
|
13
13
|
| textToCopy | `string` | *required* | Text copied to the clipboard when the button is clicked |
|
|
14
14
|
| copiedLabel | `string` | - | Optional label shown while the copied success state is active |
|
|
15
15
|
| variant | `'default' \| 'outline'` | `'default'` | `outline` renders a bordered square button for copyable values |
|
|
16
|
-
|
|
|
16
|
+
| onCopy | `(text: string) => void` | - | Called with the copied text after it is written to the clipboard |
|
|
17
|
+
| onCopyError | `(error: unknown) => void` | - | Called when writing to the clipboard fails |
|
|
18
|
+
| native button props | `Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' \| 'onCopy'>` | - | Standard button attributes except `onClick`, which is handled internally, and the native `onCopy` event |
|
|
17
19
|
|
|
18
20
|
## Examples
|
|
19
21
|
|
|
@@ -74,6 +76,24 @@ import {
|
|
|
74
76
|
<CopyToClipboardButton textToCopy="Text with custom label" copiedLabel="Successfully copied!" />
|
|
75
77
|
```
|
|
76
78
|
|
|
79
|
+
### OnCopy
|
|
80
|
+
|
|
81
|
+
> `onCopy` is called with the copied text after it is written to the clipboard, for example to show a toast or send analytics. `onCopyError` is called when writing fails.
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
const [message, setMessage] = useState('Click to copy');
|
|
85
|
+
|
|
86
|
+
<>
|
|
87
|
+
<CopyToClipboardButton
|
|
88
|
+
textToCopy="7a1f3c9e-2b4d-4e8f"
|
|
89
|
+
aria-label="Copy project ID"
|
|
90
|
+
onCopy={() => setMessage('Project ID copied')}
|
|
91
|
+
onCopyError={() => setMessage('Could not copy the project ID')}
|
|
92
|
+
/>
|
|
93
|
+
<span>{message}</span>
|
|
94
|
+
</>
|
|
95
|
+
```
|
|
96
|
+
|
|
77
97
|
## Notes
|
|
78
98
|
- The component forwards refs to the underlying `<button>` element.
|
|
79
99
|
- After a successful copy, the icon changes to a check mark for 1.5 seconds before reverting.
|
|
@@ -81,3 +101,5 @@ import {
|
|
|
81
101
|
- If `copiedLabel` is omitted, the accessible label falls back to `Copy`.
|
|
82
102
|
- A successful copy is announced to screen readers (`copiedLabel`, or `Copied`).
|
|
83
103
|
- Use `variant="outline"` for copyable values in Ultra surfaces.
|
|
104
|
+
- Use `onCopy` / `onCopyError` instead of `onClick` to run code after a copy. A failed copy keeps the button in its normal state.
|
|
105
|
+
- To copy the value of a field, use `showCopyButton` on `Input` or `TextArea` instead of placing this button next to the field.
|
|
@@ -38,7 +38,10 @@ import { Input, FormField } from '@redis-ui/components';
|
|
|
38
38
|
| formatter | `(value: string, extra: { event?: ChangeEvent }) => string` | - | Formats the stored value before display. |
|
|
39
39
|
| readonlyRender | `ReadOnlyRenderComponent` | `DefaultReadonlyRender` | Custom renderer used when `readOnly` is enabled. |
|
|
40
40
|
| readonlyProps | `HTMLAttributes<HTMLElement>` | - | Props passed to the read-only wrapper. |
|
|
41
|
+
| boxedReadonly | `boolean` | `false` | `Input.Compose` only. Keeps the field box in read-only mode, with the inner input set to `readonly`, instead of `readonlyRender`. Set by `showCopyButton`. |
|
|
41
42
|
| allowReset | `boolean` | `false` | Shows the reset button when a value is present. |
|
|
43
|
+
| showCopyButton | `boolean` | `false` | Shows a copy button inside the box that copies the current value. With `readOnly`, keeps the box with a selectable, non-editable value. |
|
|
44
|
+
| copyButtonProps | `Partial<CopyToClipboardButtonProps>` (without `variant`) | - | Props for the copy button, such as `aria-label`, `copiedLabel` or `onCopy`. |
|
|
42
45
|
| loading | `boolean` | - | Shows the loading indicator. |
|
|
43
46
|
| autoSize | `boolean` | `false` | Makes the inner input size itself to the current value. |
|
|
44
47
|
|
|
@@ -49,6 +52,7 @@ The component also accepts standard `div` attributes on the compose wrapper and
|
|
|
49
52
|
- `Input.Compose` - Compose wrapper that manages value state, validation state, read-only rendering, and layout.
|
|
50
53
|
- `Input.Tag` - The underlying input element. Supports `autoSize`.
|
|
51
54
|
- `Input.ResetButton` - Clear/reset action button used when there is a value.
|
|
55
|
+
- `Input.CopyButton` - Copies the current value. Accepts `CopyToClipboardButton` props; `textToCopy` defaults to the field value. Stays enabled when the field is disabled.
|
|
52
56
|
- `Input.StatusIndicator` - Error/success status indicator with tooltip support for errors.
|
|
53
57
|
- `Input.LoadingIndicator` - Inline loading spinner shown while `loading` is true.
|
|
54
58
|
- `Input.ReadonlyValue` - Styled read-only text renderer used by the compose wrapper.
|
|
@@ -101,11 +105,42 @@ The component also accepts standard `div` attributes on the compose wrapper and
|
|
|
101
105
|
<Input placeholder="Text Input" defaultValue="orange" allowReset />
|
|
102
106
|
```
|
|
103
107
|
|
|
108
|
+
### CopyButton
|
|
109
|
+
|
|
110
|
+
> Set `showCopyButton` to show a copy button inside the field. With `readOnly`, the input keeps its box: the value can't be edited but can be focused, selected and copied, and a long value ends with an ellipsis. The font is left to the client.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<>
|
|
114
|
+
<Input
|
|
115
|
+
defaultValue="redis-cache-01"
|
|
116
|
+
allowReset
|
|
117
|
+
showCopyButton
|
|
118
|
+
copyButtonProps={{ 'aria-label': 'Copy name' }}
|
|
119
|
+
/>
|
|
120
|
+
<Input
|
|
121
|
+
value={projectId}
|
|
122
|
+
readOnly
|
|
123
|
+
showCopyButton
|
|
124
|
+
copyButtonProps={{ 'aria-label': 'Copy project ID', onCopy: () => showToast('Project ID copied') }}
|
|
125
|
+
style={{ fontFamily: theme.core.font.fontFamily.sourceCodeProRegular }}
|
|
126
|
+
/>
|
|
127
|
+
<Input defaultValue={endpoint} disabled showCopyButton copyButtonProps={{ 'aria-label': 'Copy endpoint' }} />
|
|
128
|
+
</>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
// compose
|
|
133
|
+
<Input.Compose value={projectId} readOnly boxedReadonly>
|
|
134
|
+
<Input.Tag />
|
|
135
|
+
<Input.CopyButton aria-label="Copy project ID" />
|
|
136
|
+
</Input.Compose>
|
|
137
|
+
```
|
|
138
|
+
|
|
104
139
|
### DisabledAndReadonly
|
|
105
140
|
|
|
106
141
|
> Adding `disabled` or `readOnly` switches the component to the corresponding state.
|
|
107
142
|
>
|
|
108
|
-
> In read-only mode only the value is visible. Other indicators are ignored.
|
|
143
|
+
> In read-only mode only the value is visible. Other indicators are ignored, unless `showCopyButton` is set: then the box stays, with the copy button, status and loading indicators.
|
|
109
144
|
>
|
|
110
145
|
> `readOnly` overrides `disabled`.
|
|
111
146
|
|
|
@@ -288,8 +323,10 @@ import { Button, Input } from '@redis-ui/components';
|
|
|
288
323
|
- `error` enables the error state and overrides `valid`.
|
|
289
324
|
- `loading` can be combined with validation and reset states.
|
|
290
325
|
- `allowReset` shows the reset button when the input has a value.
|
|
291
|
-
- `readOnly` overrides `disabled`, and read-only mode hides the indicator affordances.
|
|
326
|
+
- `readOnly` overrides `disabled`, and read-only mode hides the indicator affordances, unless `showCopyButton` keeps the box.
|
|
292
327
|
- Use `FormField` when you need a label or other external decoration around the input.
|
|
293
328
|
- Custom ids passed through `FormField` must start with a letter.
|
|
294
329
|
- `autoSize` is required when you want the text input to grow with its contents.
|
|
295
330
|
- `parser` and `formatter` can be used independently or together for controlled and uncontrolled input flows.
|
|
331
|
+
- `showCopyButton` keeps the box in read-only mode, so the copy button stays available. Use it for read-only values such as IDs and endpoints instead of a disabled input next to a separate copy button.
|
|
332
|
+
- Order inside the box: value, reset button, copy button, status indicator, loading indicator.
|
|
@@ -32,7 +32,7 @@ The component also accepts standard `input` attributes on the inner tag via `Res
|
|
|
32
32
|
|
|
33
33
|
## Sub-components
|
|
34
34
|
|
|
35
|
-
- `SearchInput.Compose` - Compose wrapper used for custom layouts around the search field.
|
|
35
|
+
- `SearchInput.Compose` - Compose wrapper used for custom layouts around the search field. Accepts `boxedReadonly` to keep the field box in read-only mode, with the inner input set to `readonly`, instead of the plain read-only text.
|
|
36
36
|
- `SearchInput.Tag` - The underlying input element. Supports `autoSize`.
|
|
37
37
|
- `SearchInput.ResetButton` - Clear/reset action button shown when a value is present.
|
|
38
38
|
- `SearchInput.StatusIndicator` - Error/success indicator with tooltip support for errors.
|
|
@@ -17,6 +17,8 @@ import { TextArea } from '@redis-ui/components';
|
|
|
17
17
|
| style | `React.CSSProperties` | - | Inline style applied to the composed wrapper |
|
|
18
18
|
| height | `string` | - | Explicit height for the composed textarea; falls back to theme-based sizing when omitted |
|
|
19
19
|
| readOnly | `boolean` | `false` | Switches the field into read-only mode |
|
|
20
|
+
| showCopyButton | `boolean` | `false` | Shows a copy button in the top-right corner of the box that copies the current value. With `readOnly`, keeps the box and scrolling with a selectable, non-editable value |
|
|
21
|
+
| copyButtonProps | `Partial<CopyToClipboardButtonProps>` (without `variant`) | - | Props for the copy button, such as `aria-label`, `copiedLabel` or `onCopy` |
|
|
20
22
|
| variant | `'outline' \| 'underline'` | `'outline'` | Visual variant of the composed field |
|
|
21
23
|
| error | `React.ReactElement \| string` | - | Error content; enables error status and tooltip text |
|
|
22
24
|
| valid | `boolean` | - | Enables valid/success status |
|
|
@@ -31,6 +33,7 @@ The component also accepts native `TextareaHTMLAttributes<HTMLTextAreaElement>`
|
|
|
31
33
|
- `TextArea.Compose` - Composable wrapper that wires value, status, read-only rendering, and layout state.
|
|
32
34
|
- `TextArea.Tag` - The underlying textarea element used by the composed field.
|
|
33
35
|
- `TextArea.StatusIndicator` - Status icon shown for valid and error states.
|
|
36
|
+
- `TextArea.CopyButton` - Copy button pinned to the top-right corner, left of the status indicator. `textToCopy` defaults to the field value. Use with `boxedReadonly` on `TextArea.Compose` to keep it in read-only mode.
|
|
34
37
|
- `TextArea.ReadonlyValue` - Read-only renderer used by the compose API.
|
|
35
38
|
|
|
36
39
|
## Examples
|
|
@@ -66,9 +69,23 @@ import { TextArea } from '@redis-ui/components';
|
|
|
66
69
|
</>
|
|
67
70
|
```
|
|
68
71
|
|
|
72
|
+
### CopyButton
|
|
73
|
+
|
|
74
|
+
> Set `showCopyButton` to show a copy button in the top-right corner. The text area reserves space for it, so it doesn't cover the text. With `readOnly`, the box and scrolling stay.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<TextArea
|
|
78
|
+
value={json}
|
|
79
|
+
readOnly
|
|
80
|
+
showCopyButton
|
|
81
|
+
copyButtonProps={{ 'aria-label': 'Copy JSON' }}
|
|
82
|
+
style={{ fontFamily: theme.core.font.fontFamily.sourceCodeProRegular }}
|
|
83
|
+
/>
|
|
84
|
+
```
|
|
85
|
+
|
|
69
86
|
### DisabledAndReadonly
|
|
70
87
|
|
|
71
|
-
> `disabled` and `readOnly` switch the component into those modes. Read-only mode shows only the value and ignores the other indicators. Read-only takes priority over disabled.
|
|
88
|
+
> `disabled` and `readOnly` switch the component into those modes. Read-only mode shows only the value and ignores the other indicators, unless `showCopyButton` is set, which keeps the box with the copy button and the status indicator. Read-only takes priority over disabled.
|
|
72
89
|
|
|
73
90
|
```tsx
|
|
74
91
|
import { TextArea } from '@redis-ui/components';
|
|
@@ -134,6 +151,7 @@ import { FormField, TextArea } from '@redis-ui/components';
|
|
|
134
151
|
|
|
135
152
|
- `error` overrides `valid` when both are present.
|
|
136
153
|
- `readOnly` overrides `disabled` when both are present.
|
|
154
|
+
- `showCopyButton` keeps the box in read-only mode. The copy button stays enabled when the field is disabled.
|
|
137
155
|
- Use `FormField` when you need a label, helper text, or automatic id wiring.
|
|
138
156
|
- A custom `id` used with `FormField` must start with a letter.
|
|
139
157
|
- The component forwards refs to the underlying `<textarea>` element.
|