@gridui/clipboard 1.0.6 → 1.0.8
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/README.md +8 -0
- package/dist/index.js +163 -122
- package/dist/index.js.map +4 -4
- package/dist/shared/copy-status.d.ts +14 -0
- package/dist/shared/use-copy.d.ts +14 -0
- package/dist/styles.css +23 -7
- package/docs/catalog.json +8 -3
- package/docs/reference/README.md +5 -0
- package/docs/reference/copy-button.md +105 -0
- package/docs/reference/copy-path.md +49 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,8 +13,16 @@ See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/
|
|
|
13
13
|
its accessible `label`, `copyLabel`, `copiedLabel`, and `failedLabel`. Clipboard
|
|
14
14
|
success is announced only after the write resolves; unavailable or denied
|
|
15
15
|
clipboard access selects the visible path for manual copying and reports failure.
|
|
16
|
+
Both copy controls retain focus while pending and block repeated activation with
|
|
17
|
+
an immediate in-flight lock. Result feedback reserves space for both supplied
|
|
18
|
+
messages, including wrapping, and remains visible during a retry. Failed manual
|
|
19
|
+
copy content remains mounted while retrying. Stale completions cannot report a
|
|
20
|
+
result for a newer value. Clipboard writes start directly from the action.
|
|
21
|
+
|
|
16
22
|
`frame="integrated"` omits outer borders so a parent grid owns its seams and
|
|
17
23
|
uses the grid border color for the copy button's separator;
|
|
18
24
|
standalone mode supplies a straight control border. Neither mode adds external
|
|
19
25
|
padding or expands environment variables, usernames, or path placeholders.
|
|
20
26
|
|
|
27
|
+
|
|
28
|
+
[Component reference](docs/reference/README.md) contains focused API pages for each public component.
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
// src/shared/copy-status.tsx
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var copyStatusStyles = cva("gridui-copy-status");
|
|
5
|
+
var CopyStatus = (props) => {
|
|
6
|
+
const { copiedLabel, failedLabel, message, className } = props;
|
|
7
|
+
return /* @__PURE__ */ jsxs(
|
|
8
|
+
"span",
|
|
9
|
+
{
|
|
10
|
+
className: copyStatusStyles({ className }),
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ jsx(
|
|
13
|
+
"span",
|
|
14
|
+
{
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
children: copiedLabel
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
"span",
|
|
21
|
+
{
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
children: failedLabel
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
"span",
|
|
28
|
+
{
|
|
29
|
+
role: "status",
|
|
30
|
+
children: message
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
1
38
|
// src/shared/clipboard.ts
|
|
2
39
|
var copyPath = async (value) => {
|
|
3
40
|
try {
|
|
@@ -8,102 +45,124 @@ var copyPath = async (value) => {
|
|
|
8
45
|
}
|
|
9
46
|
};
|
|
10
47
|
|
|
11
|
-
// src/
|
|
12
|
-
import { Button } from "@gridui/button";
|
|
13
|
-
import { Textarea } from "@gridui/input";
|
|
48
|
+
// src/shared/use-copy.ts
|
|
14
49
|
import { useEffect, useRef, useState } from "react";
|
|
15
|
-
|
|
16
|
-
var CopyButton = (props) => {
|
|
17
|
-
const { value, label, copiedLabel, failedLabel, disabled, ...restProps } = props;
|
|
50
|
+
var useCopy = (value) => {
|
|
18
51
|
const [
|
|
19
52
|
result,
|
|
20
53
|
setResult
|
|
21
54
|
] = useState(null);
|
|
22
55
|
const [
|
|
23
|
-
|
|
24
|
-
|
|
56
|
+
pending,
|
|
57
|
+
setPending
|
|
25
58
|
] = useState(false);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
59
|
+
const active = useRef(false);
|
|
60
|
+
const mounted = useRef(true);
|
|
28
61
|
const currentValue = useRef(value);
|
|
29
62
|
currentValue.current = value;
|
|
30
|
-
const copyInFlight = useRef(false);
|
|
31
63
|
useEffect(() => {
|
|
32
|
-
|
|
64
|
+
mounted.current = true;
|
|
33
65
|
return () => {
|
|
34
|
-
|
|
66
|
+
mounted.current = false;
|
|
35
67
|
};
|
|
36
68
|
}, []);
|
|
37
|
-
const
|
|
38
|
-
|
|
69
|
+
const copy = async () => {
|
|
70
|
+
if (active.current) {
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
active.current = true;
|
|
74
|
+
setPending(true);
|
|
75
|
+
const success = await copyPath(value);
|
|
76
|
+
active.current = false;
|
|
77
|
+
setPending(false);
|
|
78
|
+
if (!mounted.current) {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
if (value !== currentValue.current) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
setResult({
|
|
85
|
+
value,
|
|
86
|
+
success
|
|
87
|
+
});
|
|
88
|
+
return success;
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
pending,
|
|
92
|
+
copy,
|
|
93
|
+
result: result?.value === value ? result : null
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/copy-button/copy-button.tsx
|
|
98
|
+
import { Button } from "@gridui/button";
|
|
99
|
+
import { Textarea } from "@gridui/input";
|
|
100
|
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
101
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
102
|
+
var CopyButton = (props) => {
|
|
103
|
+
const { value, label, copiedLabel, failedLabel, disabled, loading, ...restProps } = props;
|
|
104
|
+
const { result: visibleResult, pending, copy } = useCopy(value);
|
|
105
|
+
const manualCopyInput = useRef2(null);
|
|
106
|
+
useEffect2(() => {
|
|
39
107
|
if (visibleResult && !visibleResult.success) {
|
|
40
108
|
manualCopyInput.current?.focus();
|
|
41
109
|
manualCopyInput.current?.select();
|
|
42
110
|
}
|
|
43
111
|
}, [visibleResult]);
|
|
44
|
-
const copyValue = async () => {
|
|
45
|
-
if (disabled || copyInFlight.current) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
copyInFlight.current = true;
|
|
49
|
-
setBusy(true);
|
|
50
|
-
setResult(null);
|
|
51
|
-
const success = await copyPath(value);
|
|
52
|
-
copyInFlight.current = false;
|
|
53
|
-
if (isMounted.current) {
|
|
54
|
-
setBusy(false);
|
|
55
|
-
if (value === currentValue.current) {
|
|
56
|
-
setResult({
|
|
57
|
-
value,
|
|
58
|
-
success
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
112
|
const message = visibleResult?.success ? copiedLabel : failedLabel;
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
return /* @__PURE__ */ jsxs2(
|
|
114
|
+
"span",
|
|
115
|
+
{
|
|
116
|
+
className: "gridui-copy-button",
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ jsx2(
|
|
119
|
+
Button,
|
|
120
|
+
{
|
|
121
|
+
...restProps,
|
|
122
|
+
disabled,
|
|
123
|
+
loading: loading || pending,
|
|
124
|
+
onClick: () => {
|
|
125
|
+
void copy();
|
|
126
|
+
},
|
|
127
|
+
children: label
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ jsx2(
|
|
131
|
+
CopyStatus,
|
|
132
|
+
{
|
|
133
|
+
copiedLabel,
|
|
134
|
+
failedLabel,
|
|
135
|
+
message: visibleResult ? message : ""
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
visibleResult && !visibleResult.success && /* @__PURE__ */ jsx2(
|
|
139
|
+
Textarea,
|
|
140
|
+
{
|
|
141
|
+
ref: manualCopyInput,
|
|
142
|
+
"aria-label": failedLabel,
|
|
143
|
+
className: "gridui-u-clipboard--col-span-full",
|
|
144
|
+
value,
|
|
145
|
+
readOnly: true
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
);
|
|
93
151
|
};
|
|
94
152
|
|
|
95
153
|
// src/copy-path/style.ts
|
|
96
|
-
import { cva } from "class-variance-authority";
|
|
97
|
-
var copyPathStyles =
|
|
98
|
-
var copyPathRowStyles =
|
|
99
|
-
var copyPathValueStyles =
|
|
100
|
-
var copyPathActionStyles =
|
|
101
|
-
var copyPathStatusStyles =
|
|
154
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
155
|
+
var copyPathStyles = cva2("gridui-copy-path gridui-u-clipboard--min-w-0 gridui-u-clipboard--rounded-none");
|
|
156
|
+
var copyPathRowStyles = cva2("gridui-u-clipboard--grid gridui-u-clipboard--min-w-0 gridui-u-clipboard--grid-cols-[minmax(0,1fr)_auto] gridui-u-clipboard--bg-surface");
|
|
157
|
+
var copyPathValueStyles = cva2("gridui-u-clipboard--min-w-0 gridui-u-clipboard--self-center gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-16 gridui-u-clipboard--type-code gridui-u-clipboard--text-foreground gridui-u-clipboard--wrap-anywhere gridui-u-clipboard--select-text");
|
|
158
|
+
var copyPathActionStyles = cva2("gridui-copy-path-action gridui-u-clipboard--flex gridui-u-clipboard--min-h-11 gridui-u-clipboard--items-center gridui-u-clipboard--justify-center gridui-u-clipboard--gap-gridui-8 gridui-u-clipboard--rounded-none gridui-u-clipboard--bg-background gridui-u-clipboard--px-gridui-16 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--text-foreground gridui-u-clipboard--type-ui gridui-u-clipboard--cursor-pointer gridui-u-clipboard--[&_svg]:h-gridui-16 gridui-u-clipboard--[&_svg]:w-gridui-16 gridui-u-clipboard--[&_svg]:shrink-0");
|
|
159
|
+
var copyPathStatusStyles = cva2("gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--type-supporting gridui-u-clipboard--text-muted");
|
|
102
160
|
|
|
103
161
|
// src/copy-path/copy-path.tsx
|
|
162
|
+
import { Button as Button2 } from "@gridui/button";
|
|
104
163
|
import { Check, Copy } from "lucide-react";
|
|
105
|
-
import { useRef as
|
|
106
|
-
import { jsx as
|
|
164
|
+
import { useRef as useRef3 } from "react";
|
|
165
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
107
166
|
var CopyPath = (props) => {
|
|
108
167
|
const {
|
|
109
168
|
value,
|
|
@@ -113,40 +172,23 @@ var CopyPath = (props) => {
|
|
|
113
172
|
failedLabel,
|
|
114
173
|
frame = "standalone"
|
|
115
174
|
} = props;
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
setResult
|
|
119
|
-
] = useState2(null);
|
|
120
|
-
const [
|
|
121
|
-
pending,
|
|
122
|
-
setPending
|
|
123
|
-
] = useState2(false);
|
|
124
|
-
const code = useRef2(null);
|
|
125
|
-
const current = result?.value === value ? result : null;
|
|
175
|
+
const { pending, result, copy } = useCopy(value);
|
|
176
|
+
const code = useRef3(null);
|
|
126
177
|
let statusLabel = "";
|
|
127
|
-
if (
|
|
128
|
-
statusLabel =
|
|
178
|
+
if (result) {
|
|
179
|
+
statusLabel = result.success ? copiedLabel : failedLabel;
|
|
129
180
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
setPending(true);
|
|
135
|
-
const copied = await copyPath(value);
|
|
136
|
-
if (!copied && code.current?.textContent === value) {
|
|
181
|
+
const copyValue = async () => {
|
|
182
|
+
const success = await copy();
|
|
183
|
+
if (success === false && code.current?.textContent === value) {
|
|
137
184
|
const range = document.createRange();
|
|
138
185
|
range.selectNodeContents(code.current);
|
|
139
186
|
const selection = window.getSelection();
|
|
140
187
|
selection?.removeAllRanges();
|
|
141
188
|
selection?.addRange(range);
|
|
142
189
|
}
|
|
143
|
-
setResult({
|
|
144
|
-
value,
|
|
145
|
-
copied
|
|
146
|
-
});
|
|
147
|
-
setPending(false);
|
|
148
190
|
};
|
|
149
|
-
return /* @__PURE__ */
|
|
191
|
+
return /* @__PURE__ */ jsxs3(
|
|
150
192
|
"div",
|
|
151
193
|
{
|
|
152
194
|
className: copyPathStyles(),
|
|
@@ -154,12 +196,12 @@ var CopyPath = (props) => {
|
|
|
154
196
|
role: "group",
|
|
155
197
|
"aria-label": label,
|
|
156
198
|
children: [
|
|
157
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ jsxs3(
|
|
158
200
|
"div",
|
|
159
201
|
{
|
|
160
202
|
className: copyPathRowStyles(),
|
|
161
203
|
children: [
|
|
162
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ jsx3(
|
|
163
205
|
"code",
|
|
164
206
|
{
|
|
165
207
|
ref: code,
|
|
@@ -167,41 +209,40 @@ var CopyPath = (props) => {
|
|
|
167
209
|
children: value
|
|
168
210
|
}
|
|
169
211
|
),
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
|
|
212
|
+
/* @__PURE__ */ jsx3(
|
|
213
|
+
Button2,
|
|
172
214
|
{
|
|
173
215
|
type: "button",
|
|
174
216
|
className: copyPathActionStyles(),
|
|
175
|
-
|
|
217
|
+
variant: "quiet",
|
|
218
|
+
loading: pending,
|
|
219
|
+
startIcon: result?.success ? /* @__PURE__ */ jsx3(
|
|
220
|
+
Check,
|
|
221
|
+
{
|
|
222
|
+
"aria-hidden": "true"
|
|
223
|
+
}
|
|
224
|
+
) : /* @__PURE__ */ jsx3(
|
|
225
|
+
Copy,
|
|
226
|
+
{
|
|
227
|
+
"aria-hidden": "true"
|
|
228
|
+
}
|
|
229
|
+
),
|
|
176
230
|
onClick: () => {
|
|
177
|
-
void
|
|
231
|
+
void copyValue();
|
|
178
232
|
},
|
|
179
|
-
children:
|
|
180
|
-
current?.copied ? /* @__PURE__ */ jsx2(
|
|
181
|
-
Check,
|
|
182
|
-
{
|
|
183
|
-
"aria-hidden": "true"
|
|
184
|
-
}
|
|
185
|
-
) : /* @__PURE__ */ jsx2(
|
|
186
|
-
Copy,
|
|
187
|
-
{
|
|
188
|
-
"aria-hidden": "true"
|
|
189
|
-
}
|
|
190
|
-
),
|
|
191
|
-
copyLabel
|
|
192
|
-
]
|
|
233
|
+
children: copyLabel
|
|
193
234
|
}
|
|
194
235
|
)
|
|
195
236
|
]
|
|
196
237
|
}
|
|
197
238
|
),
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
|
|
239
|
+
/* @__PURE__ */ jsx3(
|
|
240
|
+
CopyStatus,
|
|
200
241
|
{
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
242
|
+
copiedLabel,
|
|
243
|
+
failedLabel,
|
|
244
|
+
message: statusLabel,
|
|
245
|
+
className: copyPathStatusStyles()
|
|
205
246
|
}
|
|
206
247
|
)
|
|
207
248
|
]
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/shared/clipboard.ts", "../src/copy-button/copy-button.tsx", "../src/copy-path/style.ts", "../src/copy-path/copy-path.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Clipboard\n */\n\nexport const copyPath = async (value: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(value);\n return true;\n } catch {\n return false;\n }\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": ["useRef", "
|
|
3
|
+
"sources": ["../src/shared/copy-status.tsx", "../src/shared/clipboard.ts", "../src/shared/use-copy.ts", "../src/copy-button/copy-button.tsx", "../src/copy-path/style.ts", "../src/copy-path/copy-path.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Copy Status\n */\n\nimport { cva } from \"class-variance-authority\";\nimport type { FC } from \"react\";\n\nconst copyStatusStyles = cva(\"gridui-copy-status\");\n\nexport type CopyStatusProps = {\n readonly copiedLabel: string;\n readonly failedLabel: string;\n readonly message: string;\n readonly className?: string;\n};\n\nexport const CopyStatus: FC<CopyStatusProps> = (props: CopyStatusProps) => {\n const { copiedLabel, failedLabel, message, className } = props;\n return (<span\n className={copyStatusStyles({ className })}\n >\n <span\n aria-hidden=\"true\"\n >\n {copiedLabel}\n </span>\n <span\n aria-hidden=\"true\"\n >\n {failedLabel}\n </span>\n <span\n role=\"status\"\n >\n {message}\n </span>\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Clipboard\n */\n\nexport const copyPath = async (value: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(value);\n return true;\n } catch {\n return false;\n }\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Use Copy\n */\n\nimport { copyPath } from \"./clipboard\";\nimport { useEffect, useRef, useState } from \"react\";\n\nexport const useCopy = (value: string) => {\n const [\n result,\n setResult,\n ] = useState<{\n value: string;\n success: boolean;\n } | null>(null);\n const [\n pending,\n setPending,\n ] = useState(false);\n const active = useRef(false);\n const mounted = useRef(true);\n const currentValue = useRef(value);\n currentValue.current = value;\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const copy = async (): Promise<boolean | undefined> => {\n if (active.current) {\n return undefined;\n }\n active.current = true;\n setPending(true);\n const success = await copyPath(value);\n active.current = false;\n // Activity can disconnect effects while preserving pending state.\n setPending(false);\n if (!mounted.current) {\n return undefined;\n }\n if (value !== currentValue.current) {\n return undefined;\n }\n setResult({\n value,\n success,\n });\n return success;\n };\n return {\n pending,\n copy,\n result: result?.value === value ? result : null,\n };\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyButton\n * @description Copy Button\n */\n\nimport type { CopyOptions } from \"../shared/copy-options\";\nimport { CopyStatus } from \"../shared/copy-status\";\nimport { useCopy } from \"../shared/use-copy\";\nimport { Button, type ButtonProps, type ButtonVariants } from \"@gridui/button\";\nimport { Textarea } from \"@gridui/input\";\nimport { type FC, useEffect, useRef } from \"react\";\n\nexport type CopyButtonProps = Omit<ButtonProps, \"children\" | \"onClick\" | \"value\"> & ButtonVariants & CopyOptions & {\n readonly label: string;\n};\n\nexport const CopyButton: FC<CopyButtonProps> = (props: CopyButtonProps) => {\n const { value, label, copiedLabel, failedLabel, disabled, loading, ...restProps } = props;\n const { result: visibleResult, pending, copy } = useCopy(value);\n const manualCopyInput = useRef<HTMLTextAreaElement>(null);\n useEffect(() => {\n if (visibleResult && !visibleResult.success) {\n manualCopyInput.current?.focus();\n manualCopyInput.current?.select();\n }\n }, [visibleResult]);\n const message = visibleResult?.success ? copiedLabel : failedLabel;\n return (<span\n className=\"gridui-copy-button\"\n >\n <Button\n {...restProps}\n disabled={disabled}\n loading={loading || pending}\n onClick={() => {\n void copy();\n }}\n >\n {label}\n </Button>\n <CopyStatus\n copiedLabel={copiedLabel}\n failedLabel={failedLabel}\n message={visibleResult ? message : \"\"}\n />\n {visibleResult && !visibleResult.success && (<Textarea\n ref={manualCopyInput}\n aria-label={failedLabel}\n className=\"gridui-u-clipboard--col-span-full\"\n value={value}\n readOnly\n />)}\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyPath\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const copyPathStyles = cva(\"gridui-copy-path gridui-u-clipboard--min-w-0 gridui-u-clipboard--rounded-none\");\n\nexport const copyPathRowStyles = cva(\"gridui-u-clipboard--grid gridui-u-clipboard--min-w-0 gridui-u-clipboard--grid-cols-[minmax(0,1fr)_auto] gridui-u-clipboard--bg-surface\");\n\nexport const copyPathValueStyles = cva(\"gridui-u-clipboard--min-w-0 gridui-u-clipboard--self-center gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-16 gridui-u-clipboard--type-code gridui-u-clipboard--text-foreground gridui-u-clipboard--wrap-anywhere gridui-u-clipboard--select-text\");\n\nexport const copyPathActionStyles = cva(\"gridui-copy-path-action gridui-u-clipboard--flex gridui-u-clipboard--min-h-11 gridui-u-clipboard--items-center gridui-u-clipboard--justify-center gridui-u-clipboard--gap-gridui-8 gridui-u-clipboard--rounded-none gridui-u-clipboard--bg-background gridui-u-clipboard--px-gridui-16 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--text-foreground gridui-u-clipboard--type-ui gridui-u-clipboard--cursor-pointer gridui-u-clipboard--[&_svg]:h-gridui-16 gridui-u-clipboard--[&_svg]:w-gridui-16 gridui-u-clipboard--[&_svg]:shrink-0\");\n\nexport const copyPathStatusStyles = cva(\"gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--type-supporting gridui-u-clipboard--text-muted\");\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyPath\n * @description Copy Path\n */\n\nimport type { CopyOptions } from \"../shared/copy-options\";\nimport { CopyStatus } from \"../shared/copy-status\";\nimport { useCopy } from \"../shared/use-copy\";\nimport { copyPathActionStyles, copyPathRowStyles, copyPathStatusStyles, copyPathStyles, copyPathValueStyles } from \"./style\";\nimport { Button } from \"@gridui/button\";\nimport { Check, Copy } from \"lucide-react\";\nimport { type FC, useRef } from \"react\";\n\nexport type CopyPathProps = CopyOptions & {\n readonly label: string;\n readonly copyLabel: string;\n readonly frame?: \"standalone\" | \"integrated\";\n};\n\nexport const CopyPath: FC<CopyPathProps> = (props: CopyPathProps) => {\n const {\n value,\n label,\n copyLabel,\n copiedLabel,\n failedLabel,\n frame = \"standalone\",\n } = props;\n const { pending, result, copy } = useCopy(value);\n const code = useRef<HTMLElement>(null);\n let statusLabel = \"\";\n if (result) {\n statusLabel = result.success ? copiedLabel : failedLabel;\n }\n const copyValue = async (): Promise<void> => {\n const success = await copy();\n if (success === false && code.current?.textContent === value) {\n const range = document.createRange();\n range.selectNodeContents(code.current);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n }\n };\n return (<div\n className={copyPathStyles()}\n data-frame={frame}\n role=\"group\"\n aria-label={label}\n >\n <div\n className={copyPathRowStyles()}\n >\n <code\n ref={code}\n className={copyPathValueStyles()}\n >\n {value}\n </code>\n <Button\n type=\"button\"\n className={copyPathActionStyles()}\n variant=\"quiet\"\n loading={pending}\n startIcon={result?.success ? (<Check\n aria-hidden=\"true\"\n />) : (<Copy\n aria-hidden=\"true\"\n />)}\n onClick={() => {\n void copyValue();\n }}\n >\n {copyLabel}\n </Button>\n </div>\n <CopyStatus\n copiedLabel={copiedLabel}\n failedLabel={failedLabel}\n message={statusLabel}\n className={copyPathStatusStyles()}\n />\n </div>);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,WAAW;AAcR,SAGJ,KAHI;AAXZ,IAAM,mBAAmB,IAAI,oBAAoB;AAS1C,IAAM,aAAkC,CAAC,UAA2B;AACvE,QAAM,EAAE,aAAa,aAAa,SAAS,UAAU,IAAI;AACzD,SAAQ;AAAA,IAAC;AAAA;AAAA,MACL,WAAW,iBAAiB,EAAE,UAAU,CAAC;AAAA,MAEzC;AAAA;AAAA,UAAC;AAAA;AAAA,YACG,eAAY;AAAA,YAEX;AAAA;AAAA,QACL;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACG,eAAY;AAAA,YAEX;AAAA;AAAA,QACL;AAAA,QACA;AAAA,UAA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;AAAA,kBACA,SAAS,MAAM;AACX,yBAAK,UAAU;AAAA,kBACnB;AAAA,kBAEC;AAAA;AAAA,cACL;AAAA;AAAA;AAAA,QACJ;AAAA,QACA,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACG;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT,WAAW,qBAAqB;AAAA;AAAA,QACpC;AAAA;AAAA;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": ["useEffect", "useRef", "jsx", "jsxs", "cva", "Button", "useRef", "jsx", "jsxs"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Clipboard
|
|
4
|
+
* @namespace Shared
|
|
5
|
+
* @description Copy Status
|
|
6
|
+
*/
|
|
7
|
+
import type { FC } from "react";
|
|
8
|
+
export type CopyStatusProps = {
|
|
9
|
+
readonly copiedLabel: string;
|
|
10
|
+
readonly failedLabel: string;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
readonly className?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const CopyStatus: FC<CopyStatusProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Clipboard
|
|
4
|
+
* @namespace Shared
|
|
5
|
+
* @description Use Copy
|
|
6
|
+
*/
|
|
7
|
+
export declare const useCopy: (value: string) => {
|
|
8
|
+
pending: boolean;
|
|
9
|
+
copy: () => Promise<boolean | undefined>;
|
|
10
|
+
result: {
|
|
11
|
+
value: string;
|
|
12
|
+
success: boolean;
|
|
13
|
+
} | null;
|
|
14
|
+
};
|
package/dist/styles.css
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
@layer utilities {
|
|
9
|
+
.gridui-u-clipboard--col-span-full {
|
|
10
|
+
grid-column: 1 / -1;
|
|
11
|
+
}
|
|
9
12
|
.gridui-u-clipboard--flex {
|
|
10
13
|
display: flex;
|
|
11
14
|
}
|
|
@@ -82,12 +85,6 @@
|
|
|
82
85
|
-webkit-user-select: text;
|
|
83
86
|
user-select: text;
|
|
84
87
|
}
|
|
85
|
-
.gridui-u-clipboard--empty\:hidden:empty {
|
|
86
|
-
display: none;
|
|
87
|
-
}
|
|
88
|
-
.gridui-u-clipboard--disabled\:cursor-wait:disabled {
|
|
89
|
-
cursor: wait;
|
|
90
|
-
}
|
|
91
88
|
.gridui-u-clipboard--\[\&_svg\]\:h-gridui-16 svg {
|
|
92
89
|
height: var(--gridui-space-16);
|
|
93
90
|
}
|
|
@@ -108,8 +105,27 @@
|
|
|
108
105
|
.gridui-copy-path[data-frame="integrated"] {
|
|
109
106
|
--_gridui-copy-path-border: var(--gridui-border);
|
|
110
107
|
}
|
|
111
|
-
.gridui-copy-path-action {
|
|
108
|
+
.gridui-copy-path .gridui-copy-path-action {
|
|
112
109
|
border: 0;
|
|
113
110
|
border-inline-start: 1px solid var(--_gridui-copy-path-border);
|
|
114
111
|
}
|
|
112
|
+
.gridui-copy-status {
|
|
113
|
+
display: inline-grid;
|
|
114
|
+
min-width: 0;
|
|
115
|
+
vertical-align: middle;
|
|
116
|
+
}
|
|
117
|
+
.gridui-copy-status > span {
|
|
118
|
+
grid-area: 1 / 1;
|
|
119
|
+
overflow-wrap: anywhere;
|
|
120
|
+
}
|
|
121
|
+
.gridui-copy-status > [aria-hidden="true"] {
|
|
122
|
+
visibility: hidden;
|
|
123
|
+
}
|
|
124
|
+
.gridui-copy-button {
|
|
125
|
+
display: inline-grid;
|
|
126
|
+
grid-template-columns: minmax(0, auto) minmax(0, 1fr);
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: var(--gridui-space-8);
|
|
129
|
+
max-width: 100%;
|
|
130
|
+
}
|
|
115
131
|
}
|
package/docs/catalog.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/clipboard",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"category": "core",
|
|
6
6
|
"description": "GridUI React clipboard",
|
|
7
|
-
"usage": "`CopyPath` displays an exact `value` and an explicit copy button. Callers supply its accessible `label`, `copyLabel`, `copiedLabel`, and `failedLabel`. Clipboard success is announced only after the write resolves; unavailable or denied clipboard access selects the visible path for manual copying and reports failure.
|
|
7
|
+
"usage": "`CopyPath` displays an exact `value` and an explicit copy button. Callers supply its accessible `label`, `copyLabel`, `copiedLabel`, and `failedLabel`. Clipboard success is announced only after the write resolves; unavailable or denied clipboard access selects the visible path for manual copying and reports failure. Both copy controls retain focus while pending and block repeated activation with an immediate in-flight lock. Result feedback reserves space for both supplied messages, including wrapping, and remains visible during a retry. Failed manual copy content remains mounted while retrying. Stale completions cannot report a result for a newer value. Clipboard writes start directly from the action.",
|
|
8
8
|
"documentation": [
|
|
9
|
-
"README.md"
|
|
9
|
+
"README.md",
|
|
10
|
+
"docs/reference/README.md",
|
|
11
|
+
"docs/reference/copy-button.md",
|
|
12
|
+
"docs/reference/copy-path.md"
|
|
10
13
|
],
|
|
11
14
|
"exports": [
|
|
12
15
|
{
|
|
@@ -38,6 +41,8 @@
|
|
|
38
41
|
"@gridui/clipboard/styles.css"
|
|
39
42
|
],
|
|
40
43
|
"examples": [
|
|
44
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/stories/copying.mdx",
|
|
45
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/stories/getting-started.mdx",
|
|
41
46
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/stories/copy-button.stories.tsx",
|
|
42
47
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/stories/copy-path.stories.tsx"
|
|
43
48
|
]
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# CopyButton
|
|
3
|
+
|
|
4
|
+
Copies supplied text to the clipboard and reports the result. Use it beside content that users need to paste elsewhere.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/clipboard`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { CopyButton } from "@gridui/clipboard";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/clipboard/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/stories/copy-button.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### variant
|
|
23
|
+
|
|
24
|
+
``"text" | "primary" | "secondary" | "quiet" | "highlight" | "underlined" | null | undefined`` · Optional
|
|
25
|
+
|
|
26
|
+
Visual variant.
|
|
27
|
+
|
|
28
|
+
### size
|
|
29
|
+
|
|
30
|
+
``"small" | "standard" | "large" | "extra-large" | null | undefined`` · Optional
|
|
31
|
+
|
|
32
|
+
Component size preset.
|
|
33
|
+
|
|
34
|
+
### layout
|
|
35
|
+
|
|
36
|
+
``"cell" | "standard" | "icon" | "entry" | "rail" | "divided" | null | undefined`` · Optional
|
|
37
|
+
|
|
38
|
+
Layout within the containing region.
|
|
39
|
+
|
|
40
|
+
### iconMotion
|
|
41
|
+
|
|
42
|
+
``"none" | "outward" | null | undefined`` · Optional
|
|
43
|
+
|
|
44
|
+
### onFocus
|
|
45
|
+
|
|
46
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
47
|
+
|
|
48
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
49
|
+
|
|
50
|
+
### onBlur
|
|
51
|
+
|
|
52
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
53
|
+
|
|
54
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
55
|
+
|
|
56
|
+
### onChange
|
|
57
|
+
|
|
58
|
+
``(event: ChangeEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
59
|
+
|
|
60
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
61
|
+
|
|
62
|
+
### onSubmit
|
|
63
|
+
|
|
64
|
+
``(event: SubmitEvent<HTMLButtonElement>): void`` · Optional
|
|
65
|
+
|
|
66
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
67
|
+
|
|
68
|
+
### loading
|
|
69
|
+
|
|
70
|
+
``boolean | undefined`` · Optional
|
|
71
|
+
|
|
72
|
+
### startIcon
|
|
73
|
+
|
|
74
|
+
``ReactNode`` · Optional
|
|
75
|
+
|
|
76
|
+
### startIconLayout
|
|
77
|
+
|
|
78
|
+
``"divided" | "inline" | undefined`` · Optional
|
|
79
|
+
|
|
80
|
+
### startIconSize
|
|
81
|
+
|
|
82
|
+
``"standard" | "large" | "extra-large" | undefined`` · Optional
|
|
83
|
+
|
|
84
|
+
### endIcon
|
|
85
|
+
|
|
86
|
+
``ReactNode`` · Optional
|
|
87
|
+
|
|
88
|
+
### value
|
|
89
|
+
|
|
90
|
+
``string`` · Required
|
|
91
|
+
|
|
92
|
+
Controlled value. Pair with the corresponding change callback.
|
|
93
|
+
|
|
94
|
+
### copiedLabel
|
|
95
|
+
|
|
96
|
+
``string`` · Required
|
|
97
|
+
|
|
98
|
+
### failedLabel
|
|
99
|
+
|
|
100
|
+
``string`` · Required
|
|
101
|
+
|
|
102
|
+
### label
|
|
103
|
+
|
|
104
|
+
``string`` · Required
|
|
105
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# CopyPath
|
|
3
|
+
|
|
4
|
+
Displays a path with a copy action. Use it for file locations or other path-like values that users need to reuse.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/clipboard`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { CopyPath } from "@gridui/clipboard";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/clipboard/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/clipboard/stories/copy-path.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### value
|
|
23
|
+
|
|
24
|
+
``string`` · Required
|
|
25
|
+
|
|
26
|
+
Controlled value. Pair with the corresponding change callback.
|
|
27
|
+
|
|
28
|
+
### copiedLabel
|
|
29
|
+
|
|
30
|
+
``string`` · Required
|
|
31
|
+
|
|
32
|
+
### failedLabel
|
|
33
|
+
|
|
34
|
+
``string`` · Required
|
|
35
|
+
|
|
36
|
+
### label
|
|
37
|
+
|
|
38
|
+
``string`` · Required
|
|
39
|
+
|
|
40
|
+
### copyLabel
|
|
41
|
+
|
|
42
|
+
``string`` · Required
|
|
43
|
+
|
|
44
|
+
### frame
|
|
45
|
+
|
|
46
|
+
``"standalone" | "integrated" | undefined`` · Optional
|
|
47
|
+
|
|
48
|
+
Default: ``"standalone"``
|
|
49
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/clipboard",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "GridUI React clipboard",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"react-dom": "^19.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gridui/button": "^
|
|
31
|
-
"@gridui/input": "^
|
|
32
|
-
"@gridui/theme": "^2.5.
|
|
30
|
+
"@gridui/button": "^5.0.0",
|
|
31
|
+
"@gridui/input": "^4.0.0",
|
|
32
|
+
"@gridui/theme": "^2.5.4",
|
|
33
33
|
"class-variance-authority": "0.7.1",
|
|
34
34
|
"lucide-react": "1.70.0"
|
|
35
35
|
},
|