@redis-ui/components 51.26.0 → 51.27.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/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/package.json +2 -2
- 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
|
@@ -8,7 +8,7 @@ react = require_runtime.__toESM(react, 1);
|
|
|
8
8
|
let _redislabsdev_redis_ui_icons = require("@redis-ui/icons");
|
|
9
9
|
//#region src/Button/CopyToClipboardButton/CopyToClipboardButton.tsx
|
|
10
10
|
var COPIED_STATE_DURATION = 1500;
|
|
11
|
-
var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel, variant = "default", ...restProps }, ref) => {
|
|
11
|
+
var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel, variant = "default", onCopy, onCopyError, ...restProps }, ref) => {
|
|
12
12
|
const { iconSize } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.copyToClipboardButton.variants.outline;
|
|
13
13
|
const iconProps = variant === "outline" ? { customSize: iconSize } : { size: "L" };
|
|
14
14
|
const [isCopied, setIsCopied] = (0, react.useState)(false);
|
|
@@ -21,13 +21,21 @@ var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel,
|
|
|
21
21
|
const handleClick = (0, react.useCallback)(async () => {
|
|
22
22
|
try {
|
|
23
23
|
await navigator.clipboard.writeText(textToCopy);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
} catch (error) {
|
|
25
|
+
onCopyError?.(error);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setIsCopied(true);
|
|
29
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
30
|
+
timeoutRef.current = setTimeout(() => {
|
|
31
|
+
setIsCopied(false);
|
|
32
|
+
}, COPIED_STATE_DURATION);
|
|
33
|
+
onCopy?.(textToCopy);
|
|
34
|
+
}, [
|
|
35
|
+
textToCopy,
|
|
36
|
+
onCopy,
|
|
37
|
+
onCopyError
|
|
38
|
+
]);
|
|
31
39
|
const ariaLabel = isCopied && copiedLabel ? copiedLabel : restProps["aria-label"] || "Copy";
|
|
32
40
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_CopyToClipboardButton_style.CopyToClipboardWrapper, { children: [
|
|
33
41
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyToClipboardButton_style.CopyToClipboardButton, {
|
|
@@ -35,6 +43,7 @@ var CopyToClipboardButton = react.default.forwardRef(({ textToCopy, copiedLabel,
|
|
|
35
43
|
ref,
|
|
36
44
|
onClick: handleClick,
|
|
37
45
|
$isCopied: isCopied,
|
|
46
|
+
"data-copied": isCopied ? "" : void 0,
|
|
38
47
|
$variant: variant,
|
|
39
48
|
...restProps,
|
|
40
49
|
"aria-label": ariaLabel,
|
|
@@ -6,7 +6,7 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
6
6
|
import { CopyIcon, ToastCheckIcon } from "@redis-ui/icons";
|
|
7
7
|
//#region src/Button/CopyToClipboardButton/CopyToClipboardButton.tsx
|
|
8
8
|
var COPIED_STATE_DURATION = 1500;
|
|
9
|
-
var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant = "default", ...restProps }, ref) => {
|
|
9
|
+
var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant = "default", onCopy, onCopyError, ...restProps }, ref) => {
|
|
10
10
|
const { iconSize } = useTheme().components.copyToClipboardButton.variants.outline;
|
|
11
11
|
const iconProps = variant === "outline" ? { customSize: iconSize } : { size: "L" };
|
|
12
12
|
const [isCopied, setIsCopied] = useState(false);
|
|
@@ -19,13 +19,21 @@ var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant
|
|
|
19
19
|
const handleClick = useCallback(async () => {
|
|
20
20
|
try {
|
|
21
21
|
await navigator.clipboard.writeText(textToCopy);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
} catch (error) {
|
|
23
|
+
onCopyError?.(error);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setIsCopied(true);
|
|
27
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
28
|
+
timeoutRef.current = setTimeout(() => {
|
|
29
|
+
setIsCopied(false);
|
|
30
|
+
}, COPIED_STATE_DURATION);
|
|
31
|
+
onCopy?.(textToCopy);
|
|
32
|
+
}, [
|
|
33
|
+
textToCopy,
|
|
34
|
+
onCopy,
|
|
35
|
+
onCopyError
|
|
36
|
+
]);
|
|
29
37
|
const ariaLabel = isCopied && copiedLabel ? copiedLabel : restProps["aria-label"] || "Copy";
|
|
30
38
|
return /* @__PURE__ */ jsxs(CopyToClipboardWrapper, { children: [
|
|
31
39
|
/* @__PURE__ */ jsx(CopyToClipboardButton$1, {
|
|
@@ -33,6 +41,7 @@ var CopyToClipboardButton = React.forwardRef(({ textToCopy, copiedLabel, variant
|
|
|
33
41
|
ref,
|
|
34
42
|
onClick: handleClick,
|
|
35
43
|
$isCopied: isCopied,
|
|
44
|
+
"data-copied": isCopied ? "" : void 0,
|
|
36
45
|
$variant: variant,
|
|
37
46
|
...restProps,
|
|
38
47
|
"aria-label": ariaLabel,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes } from 'react';
|
|
2
2
|
export declare const copyToClipboardButtonVariants: readonly ["default", "outline"];
|
|
3
3
|
export type CopyToClipboardButtonVariant = (typeof copyToClipboardButtonVariants)[number];
|
|
4
|
-
export interface CopyToClipboardButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {
|
|
4
|
+
export interface CopyToClipboardButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onCopy'> {
|
|
5
5
|
textToCopy: string;
|
|
6
6
|
copiedLabel?: string;
|
|
7
7
|
variant?: CopyToClipboardButtonVariant;
|
|
8
|
+
/** Called with the copied text after it is written to the clipboard. */
|
|
9
|
+
onCopy?: (text: string) => void;
|
|
10
|
+
/** Called when writing to the clipboard fails. */
|
|
11
|
+
onCopyError?: (error: unknown) => void;
|
|
8
12
|
}
|
|
@@ -3,11 +3,12 @@ const require_StatusIndicator = require("../components/StatusIndicator/StatusInd
|
|
|
3
3
|
const require_LoadingIndicator = require("../components/LoadingIndicator/LoadingIndicator.cjs");
|
|
4
4
|
const require_Compose_style = require("../components/Compose/Compose.style.cjs");
|
|
5
5
|
const require_ResetButton = require("../components/ResetButton/ResetButton.cjs");
|
|
6
|
+
const require_CopyButton = require("../components/CopyButton/CopyButton.cjs");
|
|
6
7
|
const require_TextCompose = require("../components/Compose/TextCompose.cjs");
|
|
7
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
9
|
let react = require("react");
|
|
9
10
|
//#region src/Inputs/Input/Input.tsx
|
|
10
|
-
var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, ...restProps }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Input.Compose, {
|
|
11
|
+
var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, showCopyButton = false, copyButtonProps, ...restProps }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Input.Compose, {
|
|
11
12
|
id,
|
|
12
13
|
className,
|
|
13
14
|
style,
|
|
@@ -21,12 +22,17 @@ var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnl
|
|
|
21
22
|
parser,
|
|
22
23
|
formatter,
|
|
23
24
|
readonlyProps: restProps,
|
|
25
|
+
boxedReadonly: showCopyButton,
|
|
24
26
|
children: [
|
|
25
27
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.Tag, {
|
|
26
28
|
ref,
|
|
27
29
|
...restProps
|
|
28
30
|
}),
|
|
29
31
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.ResetButton, { allowReset }),
|
|
32
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.CopyButton, {
|
|
33
|
+
...copyButtonProps,
|
|
34
|
+
showCopyButton
|
|
35
|
+
}),
|
|
30
36
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.StatusIndicator, {}),
|
|
31
37
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input.LoadingIndicator, { loading })
|
|
32
38
|
]
|
|
@@ -36,7 +42,8 @@ var Input = Object.assign((0, react.forwardRef)(({ id, className, style, readOnl
|
|
|
36
42
|
LoadingIndicator: require_LoadingIndicator.default,
|
|
37
43
|
Tag: require_InputTag.default,
|
|
38
44
|
ReadonlyValue: require_Compose_style.ReadonlyValue,
|
|
39
|
-
ResetButton: require_ResetButton.ResetButton
|
|
45
|
+
ResetButton: require_ResetButton.ResetButton,
|
|
46
|
+
CopyButton: require_CopyButton.CopyButton
|
|
40
47
|
});
|
|
41
48
|
//#endregion
|
|
42
49
|
exports.default = Input;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { RestInputProps } from './Input.types';
|
|
2
|
-
declare const Input: import("react").ForwardRefExoticComponent<import("../components/Compose/CommonCompose.types").CommonInputComposeProps & Omit<import("../components/Context/InputValueProvider").InputValueProviderProps, "children"> & import("../components/InputTag/InputTag.types").InputTagProps & import("../components/LoadingIndicator/LoadingIndicator.types").LoadingIndicatorProps & import("../components/ResetButton/ResetButton.types").ResetButtonProps &
|
|
2
|
+
declare const Input: import("react").ForwardRefExoticComponent<import("../components/Compose/CommonCompose.types").CommonInputComposeProps & Omit<import("../components/Context/InputValueProvider").InputValueProviderProps, "children"> & import("../components/InputTag/InputTag.types").InputTagProps & import("../components/LoadingIndicator/LoadingIndicator.types").LoadingIndicatorProps & import("../components/ResetButton/ResetButton.types").ResetButtonProps & import("../components/CopyButton/CopyButton.types").CopyButtonProps & {
|
|
3
|
+
copyButtonProps?: import("../components/CopyButton/CopyButton.types").RestCopyButtonProps;
|
|
4
|
+
} & RestInputProps & import("react").RefAttributes<HTMLInputElement>> & {
|
|
3
5
|
StatusIndicator: ({ className, style, size, ...restProps }: import("@redis-ui/icons").MonochromeIconProps & Pick<import("react").HTMLAttributes<unknown>, "className" | "style">) => import("react/jsx-runtime").JSX.Element | null;
|
|
4
6
|
Compose: ({ value, defaultValue, onChange, parser, formatter, ...restProps }: import("../components/Compose/TextCompose.types").TextInputComposeProps & import("../components/Compose/TextCompose.types").RestTextInputComposeProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
LoadingIndicator: ({ loading, ...restProps }: import("../components/LoadingIndicator/LoadingIndicator.types").LoadingIndicatorProps & import("../components/LoadingIndicator/LoadingIndicator.types").RestLoadingIndicatorProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -8,5 +10,6 @@ declare const Input: import("react").ForwardRefExoticComponent<import("../compon
|
|
|
8
10
|
readOnly: boolean;
|
|
9
11
|
}, "readOnly">;
|
|
10
12
|
ResetButton: ({ size, icon, allowReset, onClick, onMouseDown, ...restProps }: import("../components/ResetButton/ResetButton.types").RestResetButtonProps & import("../components/ResetButton/ResetButton.types").ResetButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
CopyButton: ({ showCopyButton, textToCopy, onMouseDown, ...restProps }: import("../components/CopyButton/CopyButton.types").RestCopyButtonProps & import("../components/CopyButton/CopyButton.types").CopyButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
11
14
|
};
|
|
12
15
|
export default Input;
|
|
@@ -3,11 +3,12 @@ import StatusIndicator from "../components/StatusIndicator/StatusIndicator.js";
|
|
|
3
3
|
import LoadingIndicator from "../components/LoadingIndicator/LoadingIndicator.js";
|
|
4
4
|
import { ReadonlyValue } from "../components/Compose/Compose.style.js";
|
|
5
5
|
import { ResetButton } from "../components/ResetButton/ResetButton.js";
|
|
6
|
+
import { CopyButton } from "../components/CopyButton/CopyButton.js";
|
|
6
7
|
import TextInputCompose from "../components/Compose/TextCompose.js";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { forwardRef } from "react";
|
|
9
10
|
//#region src/Inputs/Input/Input.tsx
|
|
10
|
-
var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, ...restProps }, ref) => /* @__PURE__ */ jsxs(Input.Compose, {
|
|
11
|
+
var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading, variant, error, valid, value, defaultValue, onChange, parser, formatter, allowReset = false, showCopyButton = false, copyButtonProps, ...restProps }, ref) => /* @__PURE__ */ jsxs(Input.Compose, {
|
|
11
12
|
id,
|
|
12
13
|
className,
|
|
13
14
|
style,
|
|
@@ -21,12 +22,17 @@ var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading,
|
|
|
21
22
|
parser,
|
|
22
23
|
formatter,
|
|
23
24
|
readonlyProps: restProps,
|
|
25
|
+
boxedReadonly: showCopyButton,
|
|
24
26
|
children: [
|
|
25
27
|
/* @__PURE__ */ jsx(Input.Tag, {
|
|
26
28
|
ref,
|
|
27
29
|
...restProps
|
|
28
30
|
}),
|
|
29
31
|
/* @__PURE__ */ jsx(Input.ResetButton, { allowReset }),
|
|
32
|
+
/* @__PURE__ */ jsx(Input.CopyButton, {
|
|
33
|
+
...copyButtonProps,
|
|
34
|
+
showCopyButton
|
|
35
|
+
}),
|
|
30
36
|
/* @__PURE__ */ jsx(Input.StatusIndicator, {}),
|
|
31
37
|
/* @__PURE__ */ jsx(Input.LoadingIndicator, { loading })
|
|
32
38
|
]
|
|
@@ -36,7 +42,8 @@ var Input = Object.assign(forwardRef(({ id, className, style, readOnly, loading,
|
|
|
36
42
|
LoadingIndicator,
|
|
37
43
|
Tag: InputTag,
|
|
38
44
|
ReadonlyValue,
|
|
39
|
-
ResetButton
|
|
45
|
+
ResetButton,
|
|
46
|
+
CopyButton
|
|
40
47
|
});
|
|
41
48
|
//#endregion
|
|
42
49
|
export { Input as default };
|
|
@@ -3,5 +3,9 @@ import { TextInputComposeProps } from '../components/Compose/TextCompose.types';
|
|
|
3
3
|
import { InputTagProps } from '../components/InputTag/InputTag.types';
|
|
4
4
|
import { LoadingIndicatorProps } from '../components/LoadingIndicator/LoadingIndicator.types';
|
|
5
5
|
import { ResetButtonProps } from '../components/ResetButton/ResetButton.types';
|
|
6
|
-
|
|
6
|
+
import { CopyButtonProps, RestCopyButtonProps } from '../components/CopyButton/CopyButton.types';
|
|
7
|
+
export type InputProps = TextInputComposeProps & InputTagProps & LoadingIndicatorProps & ResetButtonProps & CopyButtonProps & {
|
|
8
|
+
/** Props of the copy button rendered when `showCopyButton` is set, for example `aria-label` or `onCopy`. */
|
|
9
|
+
copyButtonProps?: RestCopyButtonProps;
|
|
10
|
+
};
|
|
7
11
|
export type RestInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'children' | 'defaultValue' | 'value' | 'onChange' | 'readOnly'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RestTextInputComposeProps, TextInputComposeProps } from '../../../components/Compose/TextCompose.types';
|
|
2
2
|
import { PasswordExposureProps } from '../PasswordInput.context.types';
|
|
3
3
|
export type PasswordInputComposeProps = Omit<TextInputComposeProps, 'parser' | 'formatter'> & PasswordExposureProps;
|
|
4
|
-
export type RestPasswordInputComposeProps = Omit<RestTextInputComposeProps, 'readonlyRender'>;
|
|
4
|
+
export type RestPasswordInputComposeProps = Omit<RestTextInputComposeProps, 'readonlyRender' | 'boxedReadonly'>;
|
|
@@ -2,10 +2,11 @@ const require_Compose_style = require("./components/Compose/Compose.style.cjs");
|
|
|
2
2
|
const require_Compose = require("./components/Compose/Compose.cjs");
|
|
3
3
|
const require_TextAreaTag = require("./components/TextAreaTag/TextAreaTag.cjs");
|
|
4
4
|
const require_StatusIndicator_style = require("./components/StatusIndicator/StatusIndicator.style.cjs");
|
|
5
|
+
const require_CopyButton = require("./components/CopyButton/CopyButton.cjs");
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
7
|
let react = require("react");
|
|
7
8
|
//#region src/Inputs/TextArea/TextArea.tsx
|
|
8
|
-
var TextArea = Object.assign((0, react.forwardRef)(({ id, className, style, readOnly, variant, error, valid, value, defaultValue, onChange, height, ...restProps }, ref) => {
|
|
9
|
+
var TextArea = Object.assign((0, react.forwardRef)(({ id, className, style, readOnly, variant, error, valid, value, defaultValue, onChange, height, showCopyButton = false, copyButtonProps, ...restProps }, ref) => {
|
|
9
10
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TextArea.Compose, {
|
|
10
11
|
id,
|
|
11
12
|
className,
|
|
@@ -19,16 +20,25 @@ var TextArea = Object.assign((0, react.forwardRef)(({ id, className, style, read
|
|
|
19
20
|
defaultValue,
|
|
20
21
|
onChange,
|
|
21
22
|
readonlyProps: restProps,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
boxedReadonly: showCopyButton,
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextArea.Tag, {
|
|
26
|
+
ref,
|
|
27
|
+
...restProps
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextArea.CopyButton, {
|
|
30
|
+
...copyButtonProps,
|
|
31
|
+
showCopyButton
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextArea.StatusIndicator, {})
|
|
34
|
+
]
|
|
26
35
|
});
|
|
27
36
|
}), {
|
|
28
37
|
StatusIndicator: require_StatusIndicator_style.TextAreaStatusIndicator,
|
|
29
38
|
Compose: require_Compose.Compose,
|
|
30
39
|
Tag: require_TextAreaTag.default,
|
|
31
|
-
ReadonlyValue: require_Compose_style.ReadonlyValue
|
|
40
|
+
ReadonlyValue: require_Compose_style.ReadonlyValue,
|
|
41
|
+
CopyButton: require_CopyButton.CopyButton
|
|
32
42
|
});
|
|
33
43
|
//#endregion
|
|
34
44
|
exports.default = TextArea;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RestTextAreaProps } from './TextArea.types';
|
|
2
2
|
declare const TextArea: import("react").ForwardRefExoticComponent<Omit<import("../components/Compose/TextCompose.types").TextInputComposeProps, "parser" | "formatter"> & {
|
|
3
3
|
height?: string;
|
|
4
|
-
} & {
|
|
4
|
+
} & import("../components/CopyButton/CopyButton.types").CopyButtonProps & {
|
|
5
5
|
readOnly?: boolean;
|
|
6
|
+
copyButtonProps?: import("../components/CopyButton/CopyButton.types").RestCopyButtonProps;
|
|
6
7
|
} & RestTextAreaProps & import("react").RefAttributes<HTMLTextAreaElement>> & {
|
|
7
8
|
StatusIndicator: import("styled-components").StyledComponent<({ className, style, size, ...restProps }: import("@redis-ui/icons").MonochromeIconProps & Pick<import("react").HTMLAttributes<unknown>, "className" | "style">) => import("react/jsx-runtime").JSX.Element | null, any, {}, never>;
|
|
8
9
|
Compose: ({ readonlyRender, ...restProps }: import("./components/Compose/Compose.types").TextAreaComposeProps & import("./components/Compose/Compose.types").RestTextAreaComposeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,5 +11,6 @@ declare const TextArea: import("react").ForwardRefExoticComponent<Omit<import(".
|
|
|
10
11
|
ReadonlyValue: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../..").TypographyBodyProps & import("react").RefAttributes<HTMLElement>>, any, {
|
|
11
12
|
readOnly: boolean;
|
|
12
13
|
}, "readOnly">;
|
|
14
|
+
CopyButton: ({ showCopyButton, ...restProps }: import("../components/CopyButton/CopyButton.types").RestCopyButtonProps & import("../components/CopyButton/CopyButton.types").CopyButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
15
|
};
|
|
14
16
|
export default TextArea;
|
|
@@ -2,10 +2,11 @@ import { ReadonlyValue } from "./components/Compose/Compose.style.js";
|
|
|
2
2
|
import { Compose } from "./components/Compose/Compose.js";
|
|
3
3
|
import TextAreaTag from "./components/TextAreaTag/TextAreaTag.js";
|
|
4
4
|
import { TextAreaStatusIndicator } from "./components/StatusIndicator/StatusIndicator.style.js";
|
|
5
|
+
import { CopyButton } from "./components/CopyButton/CopyButton.js";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { forwardRef } from "react";
|
|
7
8
|
//#region src/Inputs/TextArea/TextArea.tsx
|
|
8
|
-
var TextArea = Object.assign(forwardRef(({ id, className, style, readOnly, variant, error, valid, value, defaultValue, onChange, height, ...restProps }, ref) => {
|
|
9
|
+
var TextArea = Object.assign(forwardRef(({ id, className, style, readOnly, variant, error, valid, value, defaultValue, onChange, height, showCopyButton = false, copyButtonProps, ...restProps }, ref) => {
|
|
9
10
|
return /* @__PURE__ */ jsxs(TextArea.Compose, {
|
|
10
11
|
id,
|
|
11
12
|
className,
|
|
@@ -19,16 +20,25 @@ var TextArea = Object.assign(forwardRef(({ id, className, style, readOnly, varia
|
|
|
19
20
|
defaultValue,
|
|
20
21
|
onChange,
|
|
21
22
|
readonlyProps: restProps,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
boxedReadonly: showCopyButton,
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ jsx(TextArea.Tag, {
|
|
26
|
+
ref,
|
|
27
|
+
...restProps
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ jsx(TextArea.CopyButton, {
|
|
30
|
+
...copyButtonProps,
|
|
31
|
+
showCopyButton
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ jsx(TextArea.StatusIndicator, {})
|
|
34
|
+
]
|
|
26
35
|
});
|
|
27
36
|
}), {
|
|
28
37
|
StatusIndicator: TextAreaStatusIndicator,
|
|
29
38
|
Compose,
|
|
30
39
|
Tag: TextAreaTag,
|
|
31
|
-
ReadonlyValue
|
|
40
|
+
ReadonlyValue,
|
|
41
|
+
CopyButton
|
|
32
42
|
});
|
|
33
43
|
//#endregion
|
|
34
44
|
export { TextArea as default };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { TextareaHTMLAttributes } from 'react';
|
|
2
2
|
import { TextAreaComposeProps } from './components/Compose/Compose.types';
|
|
3
|
-
|
|
3
|
+
import { CopyButtonProps, RestCopyButtonProps } from '../components/CopyButton/CopyButton.types';
|
|
4
|
+
export type TextAreaProps = TextAreaComposeProps & CopyButtonProps & {
|
|
4
5
|
readOnly?: boolean;
|
|
6
|
+
/** Props of the copy button rendered when `showCopyButton` is set, for example `aria-label` or `onCopy`. */
|
|
7
|
+
copyButtonProps?: RestCopyButtonProps;
|
|
5
8
|
};
|
|
6
9
|
export type RestTextAreaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'children' | 'defaultValue' | 'value' | 'onChange'>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_CopyButton = require("../../../components/CopyButton/CopyButton.cjs");
|
|
2
|
+
const require_CopyButton_style = require("./CopyButton.style.cjs");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
//#region src/Inputs/TextArea/components/CopyButton/CopyButton.tsx
|
|
5
|
+
var CopyButton = ({ showCopyButton = true, ...restProps }) => showCopyButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyButton_style.CopyButtonContainer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyButton.CopyButton, { ...restProps }) }) : null;
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.CopyButton = CopyButton;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CopyButton as CopyButton$1 } from "../../../components/CopyButton/CopyButton.js";
|
|
2
|
+
import { CopyButtonContainer } from "./CopyButton.style.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Inputs/TextArea/components/CopyButton/CopyButton.tsx
|
|
5
|
+
var CopyButton = ({ showCopyButton = true, ...restProps }) => showCopyButton ? /* @__PURE__ */ jsx(CopyButtonContainer, { children: /* @__PURE__ */ jsx(CopyButton$1, { ...restProps }) }) : null;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { CopyButton };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_runtime = require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_Compose_style = require("../Compose/Compose.style.cjs");
|
|
3
|
+
let styled_components = require("styled-components");
|
|
4
|
+
styled_components = require_runtime.__toESM(styled_components, 1);
|
|
5
|
+
let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
|
|
6
|
+
//#region src/Inputs/TextArea/components/CopyButton/CopyButton.style.ts
|
|
7
|
+
var CopyButtonContainer = styled_components.default.span.withConfig({
|
|
8
|
+
displayName: "CopyButtonstyle__CopyButtonContainer",
|
|
9
|
+
componentId: "RedisUI__sc-uj32r0-0"
|
|
10
|
+
})([
|
|
11
|
+
"position:absolute;display:flex;inset:",
|
|
12
|
+
";",
|
|
13
|
+
":is([data-status='error'],[data-status='success']) &{inset:",
|
|
14
|
+
";}"
|
|
15
|
+
], () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.copyButton.inset, require_Compose_style.TextAreaCompose, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.copyButton.statusInset);
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.CopyButtonContainer = CopyButtonContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CopyButtonContainer: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TextAreaCompose } from "../Compose/Compose.style.js";
|
|
2
|
+
import _styled from "styled-components";
|
|
3
|
+
import { useTheme } from "@redis-ui/styles";
|
|
4
|
+
//#region src/Inputs/TextArea/components/CopyButton/CopyButton.style.ts
|
|
5
|
+
var CopyButtonContainer = _styled.span.withConfig({
|
|
6
|
+
displayName: "CopyButtonstyle__CopyButtonContainer",
|
|
7
|
+
componentId: "RedisUI__sc-uj32r0-0"
|
|
8
|
+
})([
|
|
9
|
+
"position:absolute;display:flex;inset:",
|
|
10
|
+
";",
|
|
11
|
+
":is([data-status='error'],[data-status='success']) &{inset:",
|
|
12
|
+
";}"
|
|
13
|
+
], () => useTheme().components.input.textarea.copyButton.inset, TextAreaCompose, () => useTheme().components.input.textarea.copyButton.statusInset);
|
|
14
|
+
//#endregion
|
|
15
|
+
export { CopyButtonContainer };
|
|
@@ -9,6 +9,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
9
9
|
//#region src/Inputs/TextArea/components/TextAreaTag/TextAreaTag.tsx
|
|
10
10
|
var TextAreaTag = (0, require("react").forwardRef)(({ id, autoComplete = "off", disabled, "aria-describedby": ariaDescribedby, ...restProps }, ref) => {
|
|
11
11
|
const fieldDisabled = require_Field_context.useFieldDisabled(disabled);
|
|
12
|
+
const fieldReadonly = require_FormField_context.useFieldReadonly();
|
|
12
13
|
const sharedId = require_SharedId_context.useSharedId(id);
|
|
13
14
|
const inputValueProps = require_InputValue_context.useInputValueProps(restProps, ref);
|
|
14
15
|
const status = require_FormField_context.useFieldStatus();
|
|
@@ -32,7 +33,8 @@ var TextAreaTag = (0, require("react").forwardRef)(({ id, autoComplete = "off",
|
|
|
32
33
|
}) : null;
|
|
33
34
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TextAreaTag_style.TextAreaTag, {
|
|
34
35
|
id: sharedId,
|
|
35
|
-
disabled: fieldDisabled,
|
|
36
|
+
disabled: !fieldReadonly && fieldDisabled,
|
|
37
|
+
readOnly: fieldReadonly,
|
|
36
38
|
autoComplete,
|
|
37
39
|
...requiredProps,
|
|
38
40
|
...restProps,
|
|
@@ -3,13 +3,14 @@ import { VisuallyHidden } from "../../../../packages/components/node_modules/@ra
|
|
|
3
3
|
import { useSharedId } from "../../../../Helpers/contexts/SharedId.context.js";
|
|
4
4
|
import { useErrorContent, useFieldDisabled } from "../../../components/Context/Field.context.js";
|
|
5
5
|
import { useInputValueProps } from "../../../components/Context/InputValue.context.js";
|
|
6
|
-
import { useFieldAdditionTextId, useFieldRequired, useFieldStatus } from "../../../../FormField/FormField.context.js";
|
|
6
|
+
import { useFieldAdditionTextId, useFieldReadonly, useFieldRequired, useFieldStatus } from "../../../../FormField/FormField.context.js";
|
|
7
7
|
import { TextAreaTag as TextAreaTag$1 } from "./TextAreaTag.style.js";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { forwardRef } from "react";
|
|
10
10
|
//#region src/Inputs/TextArea/components/TextAreaTag/TextAreaTag.tsx
|
|
11
11
|
var TextAreaTag = forwardRef(({ id, autoComplete = "off", disabled, "aria-describedby": ariaDescribedby, ...restProps }, ref) => {
|
|
12
12
|
const fieldDisabled = useFieldDisabled(disabled);
|
|
13
|
+
const fieldReadonly = useFieldReadonly();
|
|
13
14
|
const sharedId = useSharedId(id);
|
|
14
15
|
const inputValueProps = useInputValueProps(restProps, ref);
|
|
15
16
|
const status = useFieldStatus();
|
|
@@ -33,7 +34,8 @@ var TextAreaTag = forwardRef(({ id, autoComplete = "off", disabled, "aria-descri
|
|
|
33
34
|
}) : null;
|
|
34
35
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TextAreaTag$1, {
|
|
35
36
|
id: sharedId,
|
|
36
|
-
disabled: fieldDisabled,
|
|
37
|
+
disabled: !fieldReadonly && fieldDisabled,
|
|
38
|
+
readOnly: fieldReadonly,
|
|
37
39
|
autoComplete,
|
|
38
40
|
...requiredProps,
|
|
39
41
|
...restProps,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_InputTag_style = require("../../../components/InputTag/InputTag.style.cjs");
|
|
3
3
|
const require_Compose_style = require("../Compose/Compose.style.cjs");
|
|
4
|
+
const require_CopyButton_style = require("../CopyButton/CopyButton.style.cjs");
|
|
4
5
|
let styled_components = require("styled-components");
|
|
5
6
|
styled_components = require_runtime.__toESM(styled_components, 1);
|
|
6
7
|
let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
|
|
@@ -13,7 +14,13 @@ var TextAreaTag = styled_components.default.textarea.withConfig({
|
|
|
13
14
|
";height:100%;box-sizing:border-box;background-color:transparent;resize:none;cursor:auto;padding:",
|
|
14
15
|
";",
|
|
15
16
|
":is([data-status='error'],[data-status='success']) &{padding:",
|
|
17
|
+
";}",
|
|
18
|
+
":has(",
|
|
19
|
+
") &{padding:",
|
|
20
|
+
";}",
|
|
21
|
+
":is([data-status='error'],[data-status='success']):has(",
|
|
22
|
+
") &{padding:",
|
|
16
23
|
";}"
|
|
17
|
-
], require_InputTag_style.InputStyle, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.padding, require_Compose_style.TextAreaCompose, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.statusPadding);
|
|
24
|
+
], require_InputTag_style.InputStyle, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.padding, require_Compose_style.TextAreaCompose, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.statusPadding, require_Compose_style.TextAreaCompose, require_CopyButton_style.CopyButtonContainer, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.copyButton.padding, require_Compose_style.TextAreaCompose, require_CopyButton_style.CopyButtonContainer, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.textarea.copyButton.statusPadding);
|
|
18
25
|
//#endregion
|
|
19
26
|
exports.TextAreaTag = TextAreaTag;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputStyle } from "../../../components/InputTag/InputTag.style.js";
|
|
2
2
|
import { TextAreaCompose } from "../Compose/Compose.style.js";
|
|
3
|
+
import { CopyButtonContainer } from "../CopyButton/CopyButton.style.js";
|
|
3
4
|
import _styled from "styled-components";
|
|
4
5
|
import { useTheme } from "@redis-ui/styles";
|
|
5
6
|
//#region src/Inputs/TextArea/components/TextAreaTag/TextAreaTag.style.ts
|
|
@@ -11,7 +12,13 @@ var TextAreaTag = _styled.textarea.withConfig({
|
|
|
11
12
|
";height:100%;box-sizing:border-box;background-color:transparent;resize:none;cursor:auto;padding:",
|
|
12
13
|
";",
|
|
13
14
|
":is([data-status='error'],[data-status='success']) &{padding:",
|
|
15
|
+
";}",
|
|
16
|
+
":has(",
|
|
17
|
+
") &{padding:",
|
|
18
|
+
";}",
|
|
19
|
+
":is([data-status='error'],[data-status='success']):has(",
|
|
20
|
+
") &{padding:",
|
|
14
21
|
";}"
|
|
15
|
-
], InputStyle, () => useTheme().components.input.textarea.padding, TextAreaCompose, () => useTheme().components.input.textarea.statusPadding);
|
|
22
|
+
], InputStyle, () => useTheme().components.input.textarea.padding, TextAreaCompose, () => useTheme().components.input.textarea.statusPadding, TextAreaCompose, CopyButtonContainer, () => useTheme().components.input.textarea.copyButton.padding, TextAreaCompose, CopyButtonContainer, () => useTheme().components.input.textarea.copyButton.statusPadding);
|
|
16
23
|
//#endregion
|
|
17
24
|
export { TextAreaTag };
|
|
@@ -11,30 +11,35 @@ var DefaultReadonlyRender = ({ value, ...restProps }) => /* @__PURE__ */ (0, rea
|
|
|
11
11
|
...restProps,
|
|
12
12
|
children: value
|
|
13
13
|
});
|
|
14
|
-
var CommonInputCompose = ({ id, readOnly, readonlyRender = DefaultReadonlyRender, readonlyProps, variant = "outline", error, valid, children, onPointerUp, ...restProps }) => {
|
|
14
|
+
var CommonInputCompose = ({ id, readOnly, readonlyRender = DefaultReadonlyRender, readonlyProps, boxedReadonly = false, variant = "outline", error, valid, children, onPointerUp, ...restProps }) => {
|
|
15
|
+
const fieldReadonly = require_FormField_context.useFieldReadonly(readOnly);
|
|
15
16
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SharedId_context.SharedIdTransProvider, {
|
|
16
17
|
customId: id,
|
|
17
|
-
children:
|
|
18
|
+
children: fieldReadonly && !boxedReadonly ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ReadonlyRenderWrapper.ReadonlyRenderWrapper, {
|
|
18
19
|
...readonlyProps,
|
|
19
20
|
...restProps,
|
|
20
21
|
render: readonlyRender,
|
|
21
22
|
"$data-children": children
|
|
22
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
23
|
-
value:
|
|
24
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
25
|
-
value: error
|
|
26
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormField_context.FieldReadonlyTransProvider, {
|
|
24
|
+
value: fieldReadonly,
|
|
25
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Field_context.FieldDisabledTransProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormField_context.FieldStatusTransProvider, {
|
|
26
|
+
value: error && "error" || valid && "success" || "none",
|
|
27
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormField_context.FieldRequiredTransProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormField_context.FieldAdditionTextIdTransProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Field_context.ErrorContentProvider, {
|
|
28
|
+
value: error ?? "",
|
|
29
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Compose_style.CommonInputCompose, {
|
|
30
|
+
$variant: variant,
|
|
31
|
+
...restProps,
|
|
32
|
+
"data-editable": "",
|
|
33
|
+
"data-readonly": fieldReadonly ? "" : void 0,
|
|
34
|
+
onPointerUp: require_react_utils.combineHandlers((e) => {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
if (target.tagName !== "INPUT" && target.tagName !== "TEXTAREA") (e.currentTarget.querySelector(`input${require_InputTag_style.InputTag}`) ?? e.currentTarget.querySelector("textarea"))?.focus();
|
|
37
|
+
}, onPointerUp),
|
|
38
|
+
children
|
|
39
|
+
})
|
|
40
|
+
}) }) })
|
|
41
|
+
}) })
|
|
42
|
+
})
|
|
38
43
|
});
|
|
39
44
|
};
|
|
40
45
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReadonlyRenderProps } from '../ReadonlyRender/ReadonlyRender.types';
|
|
2
2
|
import { CommonInputComposeProps, RestCommonInputComposeProps } from './CommonCompose.types';
|
|
3
3
|
export declare const DefaultReadonlyRender: ({ value, ...restProps }: ReadonlyRenderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
declare const CommonInputCompose: ({ id, readOnly, readonlyRender, readonlyProps, variant, error, valid, children, onPointerUp, ...restProps }: CommonInputComposeProps & RestCommonInputComposeProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const CommonInputCompose: ({ id, readOnly, readonlyRender, readonlyProps, boxedReadonly, variant, error, valid, children, onPointerUp, ...restProps }: CommonInputComposeProps & RestCommonInputComposeProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export default CommonInputCompose;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { combineHandlers } from "../../../Helpers/react.utils.js";
|
|
2
2
|
import { SharedIdTransProvider } from "../../../Helpers/contexts/SharedId.context.js";
|
|
3
3
|
import { ErrorContentProvider, FieldDisabledTransProvider } from "../Context/Field.context.js";
|
|
4
|
-
import { FieldAdditionTextIdTransProvider, FieldRequiredTransProvider, FieldStatusTransProvider, useFieldReadonly } from "../../../FormField/FormField.context.js";
|
|
4
|
+
import { FieldAdditionTextIdTransProvider, FieldReadonlyTransProvider, FieldRequiredTransProvider, FieldStatusTransProvider, useFieldReadonly } from "../../../FormField/FormField.context.js";
|
|
5
5
|
import { InputTag } from "../InputTag/InputTag.style.js";
|
|
6
6
|
import { CommonInputCompose as CommonInputCompose$1, ReadonlyValue } from "./Compose.style.js";
|
|
7
7
|
import { ReadonlyRenderWrapper } from "../ReadonlyRender/ReadonlyRenderWrapper.js";
|
|
@@ -11,30 +11,35 @@ var DefaultReadonlyRender = ({ value, ...restProps }) => /* @__PURE__ */ jsx(Rea
|
|
|
11
11
|
...restProps,
|
|
12
12
|
children: value
|
|
13
13
|
});
|
|
14
|
-
var CommonInputCompose = ({ id, readOnly, readonlyRender = DefaultReadonlyRender, readonlyProps, variant = "outline", error, valid, children, onPointerUp, ...restProps }) => {
|
|
14
|
+
var CommonInputCompose = ({ id, readOnly, readonlyRender = DefaultReadonlyRender, readonlyProps, boxedReadonly = false, variant = "outline", error, valid, children, onPointerUp, ...restProps }) => {
|
|
15
|
+
const fieldReadonly = useFieldReadonly(readOnly);
|
|
15
16
|
return /* @__PURE__ */ jsx(SharedIdTransProvider, {
|
|
16
17
|
customId: id,
|
|
17
|
-
children:
|
|
18
|
+
children: fieldReadonly && !boxedReadonly ? /* @__PURE__ */ jsx(ReadonlyRenderWrapper, {
|
|
18
19
|
...readonlyProps,
|
|
19
20
|
...restProps,
|
|
20
21
|
render: readonlyRender,
|
|
21
22
|
"$data-children": children
|
|
22
|
-
}) : /* @__PURE__ */ jsx(
|
|
23
|
-
value:
|
|
24
|
-
children: /* @__PURE__ */ jsx(
|
|
25
|
-
value: error
|
|
26
|
-
children: /* @__PURE__ */ jsx(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
}) : /* @__PURE__ */ jsx(FieldReadonlyTransProvider, {
|
|
24
|
+
value: fieldReadonly,
|
|
25
|
+
children: /* @__PURE__ */ jsx(FieldDisabledTransProvider, { children: /* @__PURE__ */ jsx(FieldStatusTransProvider, {
|
|
26
|
+
value: error && "error" || valid && "success" || "none",
|
|
27
|
+
children: /* @__PURE__ */ jsx(FieldRequiredTransProvider, { children: /* @__PURE__ */ jsx(FieldAdditionTextIdTransProvider, { children: /* @__PURE__ */ jsx(ErrorContentProvider, {
|
|
28
|
+
value: error ?? "",
|
|
29
|
+
children: /* @__PURE__ */ jsx(CommonInputCompose$1, {
|
|
30
|
+
$variant: variant,
|
|
31
|
+
...restProps,
|
|
32
|
+
"data-editable": "",
|
|
33
|
+
"data-readonly": fieldReadonly ? "" : void 0,
|
|
34
|
+
onPointerUp: combineHandlers((e) => {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
if (target.tagName !== "INPUT" && target.tagName !== "TEXTAREA") (e.currentTarget.querySelector(`input${InputTag}`) ?? e.currentTarget.querySelector("textarea"))?.focus();
|
|
37
|
+
}, onPointerUp),
|
|
38
|
+
children
|
|
39
|
+
})
|
|
40
|
+
}) }) })
|
|
41
|
+
}) })
|
|
42
|
+
})
|
|
38
43
|
});
|
|
39
44
|
};
|
|
40
45
|
//#endregion
|
|
@@ -11,5 +11,7 @@ export type CommonInputComposeProps = {
|
|
|
11
11
|
};
|
|
12
12
|
export type RestCommonInputComposeProps = Omit<ComposeElementProps, 'defaultValue' | 'onChange'> & {
|
|
13
13
|
readonlyRender?: ReadOnlyRenderComponent;
|
|
14
|
+
/** Keeps the field box when read-only, with a non-editable but selectable value, instead of `readonlyRender`. */
|
|
15
|
+
boxedReadonly?: boolean;
|
|
14
16
|
readonlyProps?: HTMLAttributes<HTMLElement>;
|
|
15
17
|
};
|
|
@@ -59,6 +59,13 @@ var getStateStyle = (theme) => {
|
|
|
59
59
|
})};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
&[data-readonly] {
|
|
63
|
+
${require_css_utils.styleFromTokens({
|
|
64
|
+
tokenMaps: [bgColor, textColor],
|
|
65
|
+
tokens: statesStyle.boxedReadonly
|
|
66
|
+
})};
|
|
67
|
+
}
|
|
68
|
+
|
|
62
69
|
&:has(:is(input, textarea):disabled) {
|
|
63
70
|
${require_css_utils.styleFromTokens({
|
|
64
71
|
tokenMaps: maps,
|
|
@@ -57,6 +57,13 @@ var getStateStyle = (theme) => {
|
|
|
57
57
|
})};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
&[data-readonly] {
|
|
61
|
+
${styleFromTokens({
|
|
62
|
+
tokenMaps: [bgColor, textColor],
|
|
63
|
+
tokens: statesStyle.boxedReadonly
|
|
64
|
+
})};
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
&:has(:is(input, textarea):disabled) {
|
|
61
68
|
${styleFromTokens({
|
|
62
69
|
tokenMaps: maps,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CommonInputComposeProps, RestCommonInputComposeProps } from './CommonCompose.types';
|
|
2
2
|
import { NumericInputValueProviderProps } from '../Context/NumericInputValueProvider';
|
|
3
3
|
export type NumericInputComposeProps = CommonInputComposeProps & Omit<NumericInputValueProviderProps, 'children'>;
|
|
4
|
-
export type RestNumericInputComposeProps = RestCommonInputComposeProps
|
|
4
|
+
export type RestNumericInputComposeProps = Omit<RestCommonInputComposeProps, 'boxedReadonly'>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const require_react_utils = require("../../../Helpers/react.utils.cjs");
|
|
2
|
+
const require_InputValue_context = require("../Context/InputValue.context.cjs");
|
|
3
|
+
const require_CopyButton_style = require("./CopyButton.style.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/Inputs/components/CopyButton/CopyButton.tsx
|
|
6
|
+
var CopyButton = ({ showCopyButton = true, textToCopy, onMouseDown, ...restProps }) => {
|
|
7
|
+
const { value } = require_InputValue_context.useInputValueApi();
|
|
8
|
+
return showCopyButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CopyButton_style.CopyButton, {
|
|
9
|
+
textToCopy: textToCopy ?? value ?? "",
|
|
10
|
+
...restProps,
|
|
11
|
+
onMouseDown: require_react_utils.combineHandlers((e) => e.preventDefault(), onMouseDown)
|
|
12
|
+
}) : null;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.CopyButton = CopyButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { combineHandlers } from "../../../Helpers/react.utils.js";
|
|
2
|
+
import { useInputValueApi } from "../Context/InputValue.context.js";
|
|
3
|
+
import { CopyButton as CopyButton$1 } from "./CopyButton.style.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/Inputs/components/CopyButton/CopyButton.tsx
|
|
6
|
+
var CopyButton = ({ showCopyButton = true, textToCopy, onMouseDown, ...restProps }) => {
|
|
7
|
+
const { value } = useInputValueApi();
|
|
8
|
+
return showCopyButton ? /* @__PURE__ */ jsx(CopyButton$1, {
|
|
9
|
+
textToCopy: textToCopy ?? value ?? "",
|
|
10
|
+
...restProps,
|
|
11
|
+
onMouseDown: combineHandlers((e) => e.preventDefault(), onMouseDown)
|
|
12
|
+
}) : null;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { CopyButton };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_CopyToClipboardButton = require("../../../Button/CopyToClipboardButton/CopyToClipboardButton.cjs");
|
|
3
|
+
let styled_components = require("styled-components");
|
|
4
|
+
styled_components = require_runtime.__toESM(styled_components, 1);
|
|
5
|
+
let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
|
|
6
|
+
//#region src/Inputs/components/CopyButton/CopyButton.style.ts
|
|
7
|
+
var CopyButton = (0, styled_components.default)(require_CopyToClipboardButton.default).withConfig({
|
|
8
|
+
displayName: "CopyButtonstyle__CopyButton",
|
|
9
|
+
componentId: "RedisUI__sc-eedjzk-0"
|
|
10
|
+
})([
|
|
11
|
+
"flex:none;&&:is(:hover,:active):not(:disabled){background-color:transparent;}&&:is(:hover,:active):not(:disabled,[data-copied]){color:",
|
|
12
|
+
";}& svg{width:",
|
|
13
|
+
";height:",
|
|
14
|
+
";}"
|
|
15
|
+
], () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.copyButton.hoverIconColor, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.copyButton.iconSize, () => (0, _redislabsdev_redis_ui_styles.useTheme)().components.input.copyButton.iconSize);
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.CopyButton = CopyButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CopyButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../..").CopyToClipboardButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, {}, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import CopyToClipboardButton from "../../../Button/CopyToClipboardButton/CopyToClipboardButton.js";
|
|
2
|
+
import _styled from "styled-components";
|
|
3
|
+
import { useTheme } from "@redis-ui/styles";
|
|
4
|
+
//#region src/Inputs/components/CopyButton/CopyButton.style.ts
|
|
5
|
+
var CopyButton = _styled(CopyToClipboardButton).withConfig({
|
|
6
|
+
displayName: "CopyButtonstyle__CopyButton",
|
|
7
|
+
componentId: "RedisUI__sc-eedjzk-0"
|
|
8
|
+
})([
|
|
9
|
+
"flex:none;&&:is(:hover,:active):not(:disabled){background-color:transparent;}&&:is(:hover,:active):not(:disabled,[data-copied]){color:",
|
|
10
|
+
";}& svg{width:",
|
|
11
|
+
";height:",
|
|
12
|
+
";}"
|
|
13
|
+
], () => useTheme().components.input.copyButton.hoverIconColor, () => useTheme().components.input.copyButton.iconSize, () => useTheme().components.input.copyButton.iconSize);
|
|
14
|
+
//#endregion
|
|
15
|
+
export { CopyButton };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CopyToClipboardButtonProps } from '../../../Button/CopyToClipboardButton/CopyToClipboardButton.types';
|
|
2
|
+
export type CopyButtonProps = {
|
|
3
|
+
/** Renders a copy button inside the field that copies the current value. */
|
|
4
|
+
showCopyButton?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type RestCopyButtonProps = Partial<Omit<CopyToClipboardButtonProps, 'variant'>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,6 +9,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
9
9
|
//#region src/Inputs/components/InputTag/InputTag.tsx
|
|
10
10
|
var InputTag = (0, require("react").forwardRef)(({ autoSize, id, type = "text", autoComplete = "off", disabled, "aria-describedby": ariaDescribedby, ...restProps }, ref) => {
|
|
11
11
|
const fieldDisabled = require_Field_context.useFieldDisabled(disabled);
|
|
12
|
+
const fieldReadonly = require_FormField_context.useFieldReadonly();
|
|
12
13
|
const sharedId = require_SharedId_context.useSharedId(id);
|
|
13
14
|
const inputValueProps = require_InputValue_context.useInputValueProps(restProps, ref);
|
|
14
15
|
const status = require_FormField_context.useFieldStatus();
|
|
@@ -27,7 +28,8 @@ var InputTag = (0, require("react").forwardRef)(({ autoSize, id, type = "text",
|
|
|
27
28
|
const inputProps = {
|
|
28
29
|
id: sharedId,
|
|
29
30
|
type,
|
|
30
|
-
disabled: fieldDisabled,
|
|
31
|
+
disabled: !fieldReadonly && fieldDisabled,
|
|
32
|
+
readOnly: fieldReadonly,
|
|
31
33
|
autoComplete,
|
|
32
34
|
...required ? { "aria-required": true } : null,
|
|
33
35
|
...restProps,
|
|
@@ -3,13 +3,14 @@ import { VisuallyHidden } from "../../../packages/components/node_modules/@radix
|
|
|
3
3
|
import { useSharedId } from "../../../Helpers/contexts/SharedId.context.js";
|
|
4
4
|
import { useErrorContent, useFieldDisabled } from "../Context/Field.context.js";
|
|
5
5
|
import { useInputValueProps } from "../Context/InputValue.context.js";
|
|
6
|
-
import { useFieldAdditionTextId, useFieldRequired, useFieldStatus } from "../../../FormField/FormField.context.js";
|
|
6
|
+
import { useFieldAdditionTextId, useFieldReadonly, useFieldRequired, useFieldStatus } from "../../../FormField/FormField.context.js";
|
|
7
7
|
import { AutoSizeInputTag, InputTag as InputTag$1 } from "./InputTag.style.js";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { forwardRef } from "react";
|
|
10
10
|
//#region src/Inputs/components/InputTag/InputTag.tsx
|
|
11
11
|
var InputTag = forwardRef(({ autoSize, id, type = "text", autoComplete = "off", disabled, "aria-describedby": ariaDescribedby, ...restProps }, ref) => {
|
|
12
12
|
const fieldDisabled = useFieldDisabled(disabled);
|
|
13
|
+
const fieldReadonly = useFieldReadonly();
|
|
13
14
|
const sharedId = useSharedId(id);
|
|
14
15
|
const inputValueProps = useInputValueProps(restProps, ref);
|
|
15
16
|
const status = useFieldStatus();
|
|
@@ -28,7 +29,8 @@ var InputTag = forwardRef(({ autoSize, id, type = "text", autoComplete = "off",
|
|
|
28
29
|
const inputProps = {
|
|
29
30
|
id: sharedId,
|
|
30
31
|
type,
|
|
31
|
-
disabled: fieldDisabled,
|
|
32
|
+
disabled: !fieldReadonly && fieldDisabled,
|
|
33
|
+
readOnly: fieldReadonly,
|
|
32
34
|
autoComplete,
|
|
33
35
|
...required ? { "aria-required": true } : null,
|
|
34
36
|
...restProps,
|
|
@@ -55,7 +55,7 @@ var InputTag = styled_components.default.input.withConfig({
|
|
|
55
55
|
componentId: "RedisUI__sc-15tql6o-0"
|
|
56
56
|
})([
|
|
57
57
|
"",
|
|
58
|
-
";align-self:stretch;padding:0
|
|
58
|
+
";align-self:stretch;padding:0;&[readonly]{text-overflow:ellipsis;}&::-webkit-outer-spin-button,&::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}&[type='number']{-moz-appearance:textfield;}&[type='password']:not(:placeholder-shown){font-family:",
|
|
59
59
|
";font-size:",
|
|
60
60
|
";@supports not (-moz-appearance:none){font-size-adjust:",
|
|
61
61
|
";}}"
|
|
@@ -53,7 +53,7 @@ var InputTag = _styled.input.withConfig({
|
|
|
53
53
|
componentId: "RedisUI__sc-15tql6o-0"
|
|
54
54
|
})([
|
|
55
55
|
"",
|
|
56
|
-
";align-self:stretch;padding:0
|
|
56
|
+
";align-self:stretch;padding:0;&[readonly]{text-overflow:ellipsis;}&::-webkit-outer-spin-button,&::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}&[type='number']{-moz-appearance:textfield;}&[type='password']:not(:placeholder-shown){font-family:",
|
|
57
57
|
";font-size:",
|
|
58
58
|
";@supports not (-moz-appearance:none){font-size-adjust:",
|
|
59
59
|
";}}"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redis-ui/components",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "51.
|
|
4
|
+
"version": "51.27.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": "git@github.com:redislabsdev/redis-ui.git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@redis-ui/icons": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
33
|
-
"@redis-ui/styles": "^21.
|
|
33
|
+
"@redis-ui/styles": "^21.29.0",
|
|
34
34
|
"react": "^18.0.0 || ^19.0.0",
|
|
35
35
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
36
36
|
"styled-components": "^5.0.0"
|
|
@@ -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.
|