react-smart-copy 1.17.2 → 1.18.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/README.md +9 -3
- package/dist/capture.cjs +30 -153
- package/dist/capture.cjs.map +1 -1
- package/dist/capture.d.cts +2 -25
- package/dist/capture.d.ts +2 -25
- package/dist/capture.js +5 -128
- package/dist/capture.js.map +1 -1
- package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs +102 -0
- package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs.map +1 -0
- package/dist/chunks/clipboard-adapter-CtH4VELE.d.cts +43 -0
- package/dist/chunks/clipboard-adapter-DEXkXxwV.js +97 -0
- package/dist/chunks/clipboard-adapter-DEXkXxwV.js.map +1 -0
- package/dist/chunks/clipboard-adapter-Ds0irroN.d.ts +43 -0
- package/dist/chunks/contrast-C6CVklEI.cjs +842 -0
- package/dist/chunks/contrast-C6CVklEI.cjs.map +1 -0
- package/dist/chunks/contrast-DpK2JIVu.js +789 -0
- package/dist/chunks/contrast-DpK2JIVu.js.map +1 -0
- package/dist/chunks/copy-interceptor-C6NABy1l.d.ts +141 -0
- package/dist/chunks/copy-interceptor-CZWzGOkL.d.cts +141 -0
- package/dist/chunks/core-Cp2HSpaz.js +1035 -0
- package/dist/chunks/core-Cp2HSpaz.js.map +1 -0
- package/dist/chunks/core-DYf_Lhbe.cjs +1142 -0
- package/dist/chunks/core-DYf_Lhbe.cjs.map +1 -0
- package/dist/chunks/deadline-C29AlS_Q.js +46 -0
- package/dist/chunks/deadline-C29AlS_Q.js.map +1 -0
- package/dist/chunks/deadline-DkiB8ZHE.cjs +51 -0
- package/dist/chunks/deadline-DkiB8ZHE.cjs.map +1 -0
- package/dist/chunks/errors-9h8sdFFX.js +120 -0
- package/dist/chunks/errors-9h8sdFFX.js.map +1 -0
- package/dist/chunks/errors-BwOF6T_M.cjs +167 -0
- package/dist/chunks/errors-BwOF6T_M.cjs.map +1 -0
- package/dist/chunks/index-mr7sSAgP.d.ts +426 -0
- package/dist/chunks/index-vz0iW5V2.d.cts +426 -0
- package/dist/chunks/mime--LB7kdqG.cjs +153 -0
- package/dist/chunks/mime--LB7kdqG.cjs.map +1 -0
- package/dist/chunks/mime-aa-HA2dm.js +100 -0
- package/dist/chunks/mime-aa-HA2dm.js.map +1 -0
- package/dist/chunks/paste-adapter--SPL4PRE.d.cts +35 -0
- package/dist/chunks/paste-adapter-uahXnTYk.d.ts +35 -0
- package/dist/chunks/paste-reader-Bo01IMC_.cjs +289 -0
- package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +1 -0
- package/dist/chunks/paste-reader-D9i7yMXF.js +224 -0
- package/dist/chunks/paste-reader-D9i7yMXF.js.map +1 -0
- package/dist/chunks/paste-reader-DcXnRWQr.d.cts +96 -0
- package/dist/chunks/paste-reader-DcXnRWQr.d.ts +96 -0
- package/dist/chunks/payload-CUymxwim.cjs +100 -0
- package/dist/chunks/payload-CUymxwim.cjs.map +1 -0
- package/dist/chunks/payload-CcwKJ_bU.d.cts +162 -0
- package/dist/chunks/payload-Cl_8hCI5.d.ts +162 -0
- package/dist/chunks/payload-DGw-JOo7.js +71 -0
- package/dist/chunks/payload-DGw-JOo7.js.map +1 -0
- package/dist/chunks/payload-DI5AorDz.js +103 -0
- package/dist/chunks/payload-DI5AorDz.js.map +1 -0
- package/dist/chunks/payload-J6GjHuh3.cjs +132 -0
- package/dist/chunks/payload-J6GjHuh3.cjs.map +1 -0
- package/dist/chunks/share-Bop47Znn.js +208 -0
- package/dist/chunks/share-Bop47Znn.js.map +1 -0
- package/dist/chunks/share-C0esXvRK.d.cts +115 -0
- package/dist/chunks/share-ayDz974N.cjs +231 -0
- package/dist/chunks/share-ayDz974N.cjs.map +1 -0
- package/dist/chunks/share-e7FenIr2.d.ts +115 -0
- package/dist/chunks/text-field-Ba8W3v4R.cjs +77 -0
- package/dist/chunks/text-field-Ba8W3v4R.cjs.map +1 -0
- package/dist/chunks/text-field-C0SGmvvR.d.cts +18 -0
- package/dist/chunks/text-field-C0SGmvvR.d.ts +18 -0
- package/dist/chunks/text-field-DUvrMMaK.js +66 -0
- package/dist/chunks/text-field-DUvrMMaK.js.map +1 -0
- package/dist/chunks/url-BcMYVCXQ.js +135 -0
- package/dist/chunks/url-BcMYVCXQ.js.map +1 -0
- package/dist/chunks/url-D4PGsRm8.cjs +164 -0
- package/dist/chunks/url-D4PGsRm8.cjs.map +1 -0
- package/dist/chunks/url-DWdElCT3.d.cts +43 -0
- package/dist/chunks/url-DWdElCT3.d.ts +43 -0
- package/dist/code.cjs +20 -112
- package/dist/code.cjs.map +1 -1
- package/dist/code.d.cts +4 -28
- package/dist/code.d.ts +4 -28
- package/dist/code.js +3 -95
- package/dist/code.js.map +1 -1
- package/dist/color.cjs +21 -893
- package/dist/color.cjs.map +1 -1
- package/dist/color.d.cts +4 -28
- package/dist/color.d.ts +4 -28
- package/dist/color.js +4 -876
- package/dist/color.js.map +1 -1
- package/dist/core.cjs +52 -1659
- package/dist/core.d.cts +8 -878
- package/dist/core.d.ts +8 -878
- package/dist/core.js +7 -1614
- package/dist/image.cjs +23 -94
- package/dist/image.cjs.map +1 -1
- package/dist/image.d.cts +1 -0
- package/dist/image.d.ts +1 -0
- package/dist/image.js +3 -74
- package/dist/image.js.map +1 -1
- package/dist/index.cjs +74 -2072
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -978
- package/dist/index.d.ts +8 -978
- package/dist/index.js +7 -2005
- package/dist/index.js.map +1 -1
- package/dist/link.cjs +24 -338
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +5 -83
- package/dist/link.d.ts +5 -83
- package/dist/link.js +5 -319
- package/dist/link.js.map +1 -1
- package/dist/markdown.cjs +8 -97
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +3 -16
- package/dist/markdown.d.ts +3 -16
- package/dist/markdown.js +3 -92
- package/dist/markdown.js.map +1 -1
- package/dist/rich.cjs +26 -934
- package/dist/rich.cjs.map +1 -1
- package/dist/rich.d.cts +4 -90
- package/dist/rich.d.ts +4 -90
- package/dist/rich.js +4 -912
- package/dist/rich.js.map +1 -1
- package/dist/share.cjs +5 -640
- package/dist/share.d.cts +3 -248
- package/dist/share.d.ts +3 -248
- package/dist/share.js +1 -637
- package/dist/structured.cjs +13 -95
- package/dist/structured.cjs.map +1 -1
- package/dist/structured.d.cts +2 -11
- package/dist/structured.d.ts +2 -11
- package/dist/structured.js +4 -86
- package/dist/structured.js.map +1 -1
- package/dist/table.cjs +11 -39
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +2 -12
- package/dist/table.d.ts +2 -12
- package/dist/table.js +2 -30
- package/dist/table.js.map +1 -1
- package/dist/testing.cjs +10 -43
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +6 -181
- package/dist/testing.d.ts +6 -181
- package/dist/testing.js +3 -36
- package/dist/testing.js.map +1 -1
- package/package.json +20 -2
- package/dist/core.cjs.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/share.cjs.map +0 -1
- package/dist/share.js.map +0 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
|
|
2
|
+
const require_errors = require("./errors-BwOF6T_M.cjs");
|
|
3
|
+
const require_payload = require("./payload-CUymxwim.cjs");
|
|
4
|
+
const require_clipboard_adapter = require("./clipboard-adapter-Cfz-rzw3.cjs");
|
|
5
|
+
const require_url = require("./url-D4PGsRm8.cjs");
|
|
6
|
+
const require_payload$1 = require("./payload-J6GjHuh3.cjs");
|
|
7
|
+
//#region src/share/share.ts
|
|
8
|
+
/** Phones and tablets: a touch screen is the main input and nothing hovers. */
|
|
9
|
+
const TOUCH_FIRST = "(hover: none) and (pointer: coarse)";
|
|
10
|
+
const defaultEnvironment = () => typeof window === "undefined" ? void 0 : window;
|
|
11
|
+
const invalid = (message) => require_errors.createCopyError("invalid-payload", message);
|
|
12
|
+
/** Validates and cleans what to share, or returns the typed error for invalid input. */
|
|
13
|
+
function resolveContent(content, options) {
|
|
14
|
+
const value = content;
|
|
15
|
+
if (typeof value !== "object" || value === null) return invalid("Share content must be an object with a url, text or files.");
|
|
16
|
+
const { url, title, text, files } = value;
|
|
17
|
+
let href = null;
|
|
18
|
+
if (url !== void 0 && url !== null) try {
|
|
19
|
+
href = require_url.linkUrlResolver(options)(url);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return require_errors.toCopyError(error);
|
|
22
|
+
}
|
|
23
|
+
if (title !== void 0 && typeof title !== "string") return invalid("`title` must be a string.");
|
|
24
|
+
if (text !== void 0 && typeof text !== "string") return invalid("`text` must be a string.");
|
|
25
|
+
const list = files ?? [];
|
|
26
|
+
if (!Array.isArray(list) || !list.every((file) => typeof File !== "undefined" && file instanceof File)) return invalid("`files` must be a list of File objects.");
|
|
27
|
+
const cleanName = title === void 0 ? "" : require_payload$1.cleanTitle(title, 300);
|
|
28
|
+
const message = text === void 0 || text.trim() === "" ? null : text;
|
|
29
|
+
if (href === null && message === null && list.length === 0) return invalid("There is nothing to share: give a url, text or files.");
|
|
30
|
+
return {
|
|
31
|
+
url: href,
|
|
32
|
+
title: cleanName === "" ? null : cleanName,
|
|
33
|
+
text: message,
|
|
34
|
+
files: list
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The `ShareData` the browser receives: only the fields that are set. */
|
|
38
|
+
function shareData(content) {
|
|
39
|
+
return {
|
|
40
|
+
...content.url === null ? {} : { url: content.url },
|
|
41
|
+
...content.title === null ? {} : { title: content.title },
|
|
42
|
+
...content.text === null ? {} : { text: content.text },
|
|
43
|
+
...content.files.length === 0 ? {} : { files: [...content.files] }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Whether this browser can open its share sheet for `data`. */
|
|
47
|
+
function canShareNatively(environment, data) {
|
|
48
|
+
const nav = environment?.navigator;
|
|
49
|
+
if (typeof nav?.share !== "function") return false;
|
|
50
|
+
if (data === null) return true;
|
|
51
|
+
return typeof nav.canShare === "function" ? nav.canShare(data) : data.files === void 0;
|
|
52
|
+
}
|
|
53
|
+
function isTouchFirst(environment) {
|
|
54
|
+
return typeof environment?.matchMedia === "function" && environment.matchMedia("(hover: none) and (pointer: coarse)").matches;
|
|
55
|
+
}
|
|
56
|
+
function resolveMode(mode) {
|
|
57
|
+
if (mode === void 0) return "auto";
|
|
58
|
+
return mode === "auto" || mode === "native" || mode === "copy" ? mode : invalid("`mode` must be \"auto\", \"native\" or \"copy\".");
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* How {@link shareOrCopy} would share right now: `"native"` (the share sheet) or
|
|
62
|
+
* `"copy"`. Use it to label the button ("Share…" or "Copy link"). Pass the
|
|
63
|
+
* content when it has files, since not every share sheet takes them.
|
|
64
|
+
*/
|
|
65
|
+
function shareMethod(options = {}, content) {
|
|
66
|
+
const mode = resolveMode(options.mode);
|
|
67
|
+
if (typeof mode !== "string" || mode === "copy") return "copy";
|
|
68
|
+
const environment = options.environment ?? defaultEnvironment();
|
|
69
|
+
if (mode === "auto" && !isTouchFirst(environment)) return "copy";
|
|
70
|
+
const resolved = content === void 0 ? null : resolveContent(content, {});
|
|
71
|
+
const data = resolved === null ? null : "type" in resolved ? void 0 : shareData(resolved);
|
|
72
|
+
return data !== void 0 && canShareNatively(environment, data) ? "native" : "copy";
|
|
73
|
+
}
|
|
74
|
+
/** The default copy: a titled link when there is a URL, otherwise the text (one of them is always set here). */
|
|
75
|
+
function defaultCopy(content) {
|
|
76
|
+
if (content.url !== null) return require_payload$1.linkPayload({
|
|
77
|
+
url: content.url,
|
|
78
|
+
...content.title === null ? {} : { title: content.title }
|
|
79
|
+
});
|
|
80
|
+
return content.text;
|
|
81
|
+
}
|
|
82
|
+
async function copyContent(content, reason, options) {
|
|
83
|
+
if (options.copy === void 0 && content.url === null && content.text === null) return {
|
|
84
|
+
status: "error",
|
|
85
|
+
method: "copy",
|
|
86
|
+
error: require_errors.createCopyError("unsupported-format", "Files can only be shared through a share sheet, and this browser has none for them.")
|
|
87
|
+
};
|
|
88
|
+
let payload;
|
|
89
|
+
try {
|
|
90
|
+
payload = require_payload.normalizePayload((options.copy ?? defaultCopy)(content));
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
status: "error",
|
|
94
|
+
method: "copy",
|
|
95
|
+
error: require_errors.toCopyError(error)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const problem = require_payload.validatePayload(payload);
|
|
99
|
+
if (problem !== null) return {
|
|
100
|
+
status: "error",
|
|
101
|
+
method: "copy",
|
|
102
|
+
error: problem
|
|
103
|
+
};
|
|
104
|
+
if (options.signal?.aborted === true) return {
|
|
105
|
+
status: "error",
|
|
106
|
+
method: "copy",
|
|
107
|
+
error: require_errors.createCopyError("aborted", "The share was aborted.")
|
|
108
|
+
};
|
|
109
|
+
try {
|
|
110
|
+
await (options.adapter ?? require_clipboard_adapter.createBrowserClipboardAdapter()).write(payload, options.signal === void 0 ? void 0 : { signal: options.signal });
|
|
111
|
+
} catch (error) {
|
|
112
|
+
return {
|
|
113
|
+
status: "error",
|
|
114
|
+
method: "copy",
|
|
115
|
+
error: require_errors.toCopyError(error)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
status: "copied",
|
|
120
|
+
method: "copy",
|
|
121
|
+
reason,
|
|
122
|
+
payload,
|
|
123
|
+
content
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Shares through the device's share sheet where people expect one, and copies a
|
|
128
|
+
* titled link everywhere else. Call it directly in a click handler: the share
|
|
129
|
+
* sheet needs the user's gesture.
|
|
130
|
+
*
|
|
131
|
+
* It never rejects. It resolves to `shared`, `copied` (with why), `cancelled`
|
|
132
|
+
* (the user closed the share sheet: nothing to report) or `error` with a typed
|
|
133
|
+
* {@link CopyError}.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* button.addEventListener('click', async () => {
|
|
137
|
+
* const outcome = await shareOrCopy({ url: location.href, title: document.title });
|
|
138
|
+
* if (outcome.status === 'copied') toast('Link copied');
|
|
139
|
+
* });
|
|
140
|
+
*/
|
|
141
|
+
async function shareOrCopy(content, options = {}) {
|
|
142
|
+
const mode = resolveMode(options.mode);
|
|
143
|
+
if (typeof mode !== "string") return {
|
|
144
|
+
status: "error",
|
|
145
|
+
method: "copy",
|
|
146
|
+
error: mode
|
|
147
|
+
};
|
|
148
|
+
const resolved = resolveContent(content, options);
|
|
149
|
+
if ("type" in resolved) return {
|
|
150
|
+
status: "error",
|
|
151
|
+
method: "copy",
|
|
152
|
+
error: resolved
|
|
153
|
+
};
|
|
154
|
+
const environment = options.environment ?? defaultEnvironment();
|
|
155
|
+
if (mode === "copy" || mode === "auto" && !isTouchFirst(environment)) return copyContent(resolved, "preferred", options);
|
|
156
|
+
const data = shareData(resolved);
|
|
157
|
+
if (!canShareNatively(environment, data)) return copyContent(resolved, "unsupported", options);
|
|
158
|
+
try {
|
|
159
|
+
await (environment?.navigator?.share)(data);
|
|
160
|
+
return {
|
|
161
|
+
status: "shared",
|
|
162
|
+
method: "native",
|
|
163
|
+
content: resolved
|
|
164
|
+
};
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (readName(error) === "AbortError") return {
|
|
167
|
+
status: "cancelled",
|
|
168
|
+
method: "native"
|
|
169
|
+
};
|
|
170
|
+
if (options.fallback === false) return {
|
|
171
|
+
status: "error",
|
|
172
|
+
method: "native",
|
|
173
|
+
error: shareError(error)
|
|
174
|
+
};
|
|
175
|
+
return copyContent(resolved, "fallback", options);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function readName(error) {
|
|
179
|
+
const name = typeof error === "object" && error !== null ? error.name : void 0;
|
|
180
|
+
return typeof name === "string" ? name : void 0;
|
|
181
|
+
}
|
|
182
|
+
/** Classifies a share sheet failure. */
|
|
183
|
+
function shareError(cause) {
|
|
184
|
+
switch (readName(cause)) {
|
|
185
|
+
case "NotAllowedError": return require_errors.createCopyError("permission-denied", "The share sheet was blocked: it needs a click, and an iframe needs the web-share permission.", cause);
|
|
186
|
+
case "InvalidStateError": return require_errors.createCopyError("unknown", "Another share sheet is already open.", cause);
|
|
187
|
+
case "DataError":
|
|
188
|
+
case "TypeError": return require_errors.createCopyError("unsupported-format", "The share sheet rejected this content.", cause);
|
|
189
|
+
default: return require_errors.toCopyError(cause);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const SHARE_DESCRIPTIONS = {
|
|
193
|
+
"permission-denied": "Sharing isn't allowed here.",
|
|
194
|
+
"unsupported-format": "This can't be shared from this browser.",
|
|
195
|
+
timeout: "Sharing took too long. Try again."
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Default English, user-facing sentence for a failed share: a share sheet
|
|
199
|
+
* failure is described as sharing, a failed copy as copying. Replace for i18n.
|
|
200
|
+
*/
|
|
201
|
+
function describeShareError(error, method) {
|
|
202
|
+
if (method === "copy") return require_errors.describeCopyError(error);
|
|
203
|
+
return SHARE_DESCRIPTIONS[error.type] ?? "Couldn't share. Try again.";
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
Object.defineProperty(exports, "TOUCH_FIRST", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function() {
|
|
209
|
+
return TOUCH_FIRST;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, "describeShareError", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function() {
|
|
215
|
+
return describeShareError;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, "shareMethod", {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function() {
|
|
221
|
+
return shareMethod;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(exports, "shareOrCopy", {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function() {
|
|
227
|
+
return shareOrCopy;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
//# sourceMappingURL=share-ayDz974N.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-ayDz974N.cjs","names":["createCopyError","linkUrlResolver","toCopyError","cleanTitle","linkPayload","normalizePayload","validatePayload","createBrowserClipboardAdapter","describeCopyError"],"sources":["../../src/share/share.ts"],"sourcesContent":["import { createBrowserClipboardAdapter, type ClipboardAdapter } from '../core/clipboard-adapter';\nimport { createCopyError, describeCopyError, toCopyError, type CopyError, type CopyErrorType } from '../core/errors';\nimport { normalizePayload, validatePayload, type CopyInput, type CopyPayload } from '../core/payload';\nimport { cleanTitle, DEFAULT_LINK_TITLE_LENGTH, linkPayload } from '../link/payload';\nimport { linkUrlResolver, type LinkUrlOptions } from '../link/url';\n\n/** What to share: a link, a message, files, or any mix of them. */\nexport interface ShareContent {\n /** Validated like every link in this package: allowed schemes only, credentials removed. */\n readonly url?: string | URL;\n readonly title?: string;\n /** A message to share alongside (or instead of) the link. */\n readonly text?: string;\n /** Files for the share sheet, where the browser can share them (`navigator.canShare({ files })`). Never copied. */\n readonly files?: readonly File[];\n}\n\n/** The content after validation: what the share sheet or the clipboard receives. */\nexport interface ResolvedShare {\n readonly url: string | null;\n /** Cleaned of hidden characters; `null` when there is none. */\n readonly title: string | null;\n readonly text: string | null;\n readonly files: readonly File[];\n}\n\n/**\n * How to share:\n * - `auto` (default): the share sheet on phones and tablets, where people expect it; copy elsewhere.\n * - `native`: the share sheet wherever the browser has one (also desktop Safari, Edge and Chrome on Windows and macOS).\n * - `copy`: always copy.\n */\nexport type ShareMode = 'auto' | 'native' | 'copy';\n\nexport type ShareMethod = 'native' | 'copy';\n\n/** Structural view of what sharing needs from the browser; `window` by default. */\nexport interface ShareEnvironment {\n readonly navigator?: {\n readonly share?: (data: ShareData) => Promise<void>;\n readonly canShare?: (data: ShareData) => boolean;\n };\n readonly matchMedia?: (query: string) => { readonly matches: boolean };\n}\n\nexport interface ShareOptions extends LinkUrlOptions {\n /** Default `\"auto\"`. */\n readonly mode?: ShareMode;\n /** When the share sheet fails for a reason other than the user closing it, copy instead. Default `true`. */\n readonly fallback?: boolean;\n /**\n * What to copy. Default: a titled link (`linkPayload`) when there is a URL,\n * otherwise the text. Return a string or any copy payload.\n */\n readonly copy?: (content: ResolvedShare) => CopyInput;\n /** Default: the browser Clipboard API, as `useCopy` uses. */\n readonly adapter?: ClipboardAdapter;\n /** Default: `window`. For tests, webviews and other hosts. */\n readonly environment?: ShareEnvironment;\n /** Aborting it stops a copy in progress; the share sheet itself can only be closed by the user. */\n readonly signal?: AbortSignal;\n}\n\n/**\n * Why the content was copied rather than shared: `preferred` (the mode chose\n * copy, as on desktop in `auto`), `unsupported` (no share sheet, or it can't\n * take this content) or `fallback` (the share sheet failed).\n */\nexport type CopyReason = 'preferred' | 'unsupported' | 'fallback';\n\n/** What `shareOrCopy` resolves to. It never rejects. */\nexport type ShareOutcome =\n | { readonly status: 'shared'; readonly method: 'native'; readonly content: ResolvedShare }\n | { readonly status: 'copied'; readonly method: 'copy'; readonly reason: CopyReason; readonly payload: CopyPayload; readonly content: ResolvedShare }\n /** The user closed the share sheet. Nothing to report. */\n | { readonly status: 'cancelled'; readonly method: 'native' }\n | { readonly status: 'error'; readonly method: ShareMethod; readonly error: CopyError };\n\n/** Phones and tablets: a touch screen is the main input and nothing hovers. */\nexport const TOUCH_FIRST = '(hover: none) and (pointer: coarse)';\n\nconst defaultEnvironment = (): ShareEnvironment | undefined => (typeof window === 'undefined' ? undefined : window);\n\nconst invalid = (message: string): CopyError => createCopyError('invalid-payload', message);\n\n/** Validates and cleans what to share, or returns the typed error for invalid input. */\nfunction resolveContent(content: ShareContent, options: LinkUrlOptions): ResolvedShare | CopyError {\n const value: unknown = content;\n if (typeof value !== 'object' || value === null) return invalid('Share content must be an object with a url, text or files.');\n const { url, title, text, files } = value as Record<string, unknown>;\n let href: string | null = null;\n if (url !== undefined && url !== null) {\n try {\n href = linkUrlResolver(options)(url as string | URL);\n } catch (error) {\n return toCopyError(error);\n }\n }\n if (title !== undefined && typeof title !== 'string') return invalid('`title` must be a string.');\n if (text !== undefined && typeof text !== 'string') return invalid('`text` must be a string.');\n const list: unknown = files ?? [];\n if (!Array.isArray(list) || !list.every((file: unknown) => typeof File !== 'undefined' && file instanceof File)) {\n return invalid('`files` must be a list of File objects.');\n }\n const cleanName = title === undefined ? '' : cleanTitle(title, DEFAULT_LINK_TITLE_LENGTH);\n const message = text === undefined || text.trim() === '' ? null : text;\n if (href === null && message === null && list.length === 0) return invalid('There is nothing to share: give a url, text or files.');\n return { url: href, title: cleanName === '' ? null : cleanName, text: message, files: list as File[] };\n}\n\n/** The `ShareData` the browser receives: only the fields that are set. */\nfunction shareData(content: ResolvedShare): ShareData {\n return {\n ...(content.url === null ? {} : { url: content.url }),\n ...(content.title === null ? {} : { title: content.title }),\n ...(content.text === null ? {} : { text: content.text }),\n ...(content.files.length === 0 ? {} : { files: [...content.files] }),\n };\n}\n\n/** Whether this browser can open its share sheet for `data`. */\nfunction canShareNatively(environment: ShareEnvironment | undefined, data: ShareData | null): boolean {\n const nav = environment?.navigator;\n if (typeof nav?.share !== 'function') return false;\n if (data === null) return true;\n // Without canShare (older Safari), only links and text can be shared.\n return typeof nav.canShare === 'function' ? nav.canShare(data) : data.files === undefined;\n}\n\nfunction isTouchFirst(environment: ShareEnvironment | undefined): boolean {\n return typeof environment?.matchMedia === 'function' && environment.matchMedia(TOUCH_FIRST).matches;\n}\n\nfunction resolveMode(mode: unknown): ShareMode | CopyError {\n if (mode === undefined) return 'auto';\n return mode === 'auto' || mode === 'native' || mode === 'copy' ? mode : invalid('`mode` must be \"auto\", \"native\" or \"copy\".');\n}\n\n/**\n * How {@link shareOrCopy} would share right now: `\"native\"` (the share sheet) or\n * `\"copy\"`. Use it to label the button (\"Share…\" or \"Copy link\"). Pass the\n * content when it has files, since not every share sheet takes them.\n */\nexport function shareMethod(options: Pick<ShareOptions, 'mode' | 'environment'> = {}, content?: ShareContent): ShareMethod {\n const mode = resolveMode(options.mode);\n if (typeof mode !== 'string' || mode === 'copy') return 'copy';\n const environment = options.environment ?? defaultEnvironment();\n if (mode === 'auto' && !isTouchFirst(environment)) return 'copy';\n const resolved = content === undefined ? null : resolveContent(content, {});\n const data = resolved === null ? null : 'type' in resolved ? undefined : shareData(resolved);\n return data !== undefined && canShareNatively(environment, data) ? 'native' : 'copy';\n}\n\n/** The default copy: a titled link when there is a URL, otherwise the text (one of them is always set here). */\nfunction defaultCopy(content: ResolvedShare): CopyInput {\n if (content.url !== null) return linkPayload({ url: content.url, ...(content.title === null ? {} : { title: content.title }) });\n return content.text as string;\n}\n\nasync function copyContent(content: ResolvedShare, reason: CopyReason, options: ShareOptions): Promise<ShareOutcome> {\n if (options.copy === undefined && content.url === null && content.text === null) {\n return { status: 'error', method: 'copy', error: createCopyError('unsupported-format', 'Files can only be shared through a share sheet, and this browser has none for them.') };\n }\n let payload: CopyPayload;\n try {\n payload = normalizePayload((options.copy ?? defaultCopy)(content));\n } catch (error) {\n return { status: 'error', method: 'copy', error: toCopyError(error) };\n }\n const problem = validatePayload(payload);\n if (problem !== null) return { status: 'error', method: 'copy', error: problem };\n if (options.signal?.aborted === true) return { status: 'error', method: 'copy', error: createCopyError('aborted', 'The share was aborted.') };\n try {\n await (options.adapter ?? createBrowserClipboardAdapter()).write(payload, options.signal === undefined ? undefined : { signal: options.signal });\n } catch (error) {\n return { status: 'error', method: 'copy', error: toCopyError(error) };\n }\n return { status: 'copied', method: 'copy', reason, payload, content };\n}\n\n/**\n * Shares through the device's share sheet where people expect one, and copies a\n * titled link everywhere else. Call it directly in a click handler: the share\n * sheet needs the user's gesture.\n *\n * It never rejects. It resolves to `shared`, `copied` (with why), `cancelled`\n * (the user closed the share sheet: nothing to report) or `error` with a typed\n * {@link CopyError}.\n *\n * @example\n * button.addEventListener('click', async () => {\n * const outcome = await shareOrCopy({ url: location.href, title: document.title });\n * if (outcome.status === 'copied') toast('Link copied');\n * });\n */\nexport async function shareOrCopy(content: ShareContent, options: ShareOptions = {}): Promise<ShareOutcome> {\n const mode = resolveMode(options.mode);\n if (typeof mode !== 'string') return { status: 'error', method: 'copy', error: mode };\n const resolved = resolveContent(content, options);\n if ('type' in resolved) return { status: 'error', method: 'copy', error: resolved };\n const environment = options.environment ?? defaultEnvironment();\n if (mode === 'copy' || (mode === 'auto' && !isTouchFirst(environment))) return copyContent(resolved, 'preferred', options);\n const data = shareData(resolved);\n if (!canShareNatively(environment, data)) return copyContent(resolved, 'unsupported', options);\n try {\n // Called before any await: the share sheet needs the click's user activation.\n await (environment?.navigator?.share as (data: ShareData) => Promise<void>)(data);\n return { status: 'shared', method: 'native', content: resolved };\n } catch (error) {\n if (readName(error) === 'AbortError') return { status: 'cancelled', method: 'native' };\n if (options.fallback === false) return { status: 'error', method: 'native', error: shareError(error) };\n return copyContent(resolved, 'fallback', options);\n }\n}\n\nfunction readName(error: unknown): string | undefined {\n const name: unknown = typeof error === 'object' && error !== null ? (error as { name?: unknown }).name : undefined;\n return typeof name === 'string' ? name : undefined;\n}\n\n/** Classifies a share sheet failure. */\nfunction shareError(cause: unknown): CopyError {\n switch (readName(cause)) {\n case 'NotAllowedError':\n return createCopyError('permission-denied', 'The share sheet was blocked: it needs a click, and an iframe needs the web-share permission.', cause);\n case 'InvalidStateError':\n return createCopyError('unknown', 'Another share sheet is already open.', cause);\n case 'DataError':\n case 'TypeError':\n return createCopyError('unsupported-format', 'The share sheet rejected this content.', cause);\n default:\n return toCopyError(cause);\n }\n}\n\nconst SHARE_DESCRIPTIONS: Partial<Readonly<Record<CopyErrorType, string>>> = {\n 'permission-denied': \"Sharing isn't allowed here.\",\n 'unsupported-format': \"This can't be shared from this browser.\",\n timeout: 'Sharing took too long. Try again.',\n};\n\n/**\n * Default English, user-facing sentence for a failed share: a share sheet\n * failure is described as sharing, a failed copy as copying. Replace for i18n.\n */\nexport function describeShareError(error: CopyError, method: ShareMethod): string {\n if (method === 'copy') return describeCopyError(error);\n return SHARE_DESCRIPTIONS[error.type] ?? \"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tB,SAAS;AACX;;;;;AAMA,SAAgB,mBAAmB,OAAkB,QAA6B;CAChF,IAAI,WAAW,QAAQ,OAAOM,eAAAA,kBAAkB,KAAK;CACrD,OAAO,mBAAmB,MAAM,SAAS;AAC3C"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
|
|
2
|
+
import { n as CopyInput, r as CopyPayload, v as CopyError } from "./payload-Cl_8hCI5.js";
|
|
3
|
+
import { n as ClipboardAdapter } from "./clipboard-adapter-Ds0irroN.js";
|
|
4
|
+
import { r as LinkUrlOptions } from "./url-DWdElCT3.js";
|
|
5
|
+
//#region src/share/share.d.ts
|
|
6
|
+
/** What to share: a link, a message, files, or any mix of them. */
|
|
7
|
+
interface ShareContent {
|
|
8
|
+
/** Validated like every link in this package: allowed schemes only, credentials removed. */
|
|
9
|
+
readonly url?: string | URL;
|
|
10
|
+
readonly title?: string;
|
|
11
|
+
/** A message to share alongside (or instead of) the link. */
|
|
12
|
+
readonly text?: string;
|
|
13
|
+
/** Files for the share sheet, where the browser can share them (`navigator.canShare({ files })`). Never copied. */
|
|
14
|
+
readonly files?: readonly File[];
|
|
15
|
+
}
|
|
16
|
+
/** The content after validation: what the share sheet or the clipboard receives. */
|
|
17
|
+
interface ResolvedShare {
|
|
18
|
+
readonly url: string | null;
|
|
19
|
+
/** Cleaned of hidden characters; `null` when there is none. */
|
|
20
|
+
readonly title: string | null;
|
|
21
|
+
readonly text: string | null;
|
|
22
|
+
readonly files: readonly File[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* How to share:
|
|
26
|
+
* - `auto` (default): the share sheet on phones and tablets, where people expect it; copy elsewhere.
|
|
27
|
+
* - `native`: the share sheet wherever the browser has one (also desktop Safari, Edge and Chrome on Windows and macOS).
|
|
28
|
+
* - `copy`: always copy.
|
|
29
|
+
*/
|
|
30
|
+
type ShareMode = 'auto' | 'native' | 'copy';
|
|
31
|
+
type ShareMethod = 'native' | 'copy';
|
|
32
|
+
/** Structural view of what sharing needs from the browser; `window` by default. */
|
|
33
|
+
interface ShareEnvironment {
|
|
34
|
+
readonly navigator?: {
|
|
35
|
+
readonly share?: (data: ShareData) => Promise<void>;
|
|
36
|
+
readonly canShare?: (data: ShareData) => boolean;
|
|
37
|
+
};
|
|
38
|
+
readonly matchMedia?: (query: string) => {
|
|
39
|
+
readonly matches: boolean;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
interface ShareOptions extends LinkUrlOptions {
|
|
43
|
+
/** Default `"auto"`. */
|
|
44
|
+
readonly mode?: ShareMode;
|
|
45
|
+
/** When the share sheet fails for a reason other than the user closing it, copy instead. Default `true`. */
|
|
46
|
+
readonly fallback?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* What to copy. Default: a titled link (`linkPayload`) when there is a URL,
|
|
49
|
+
* otherwise the text. Return a string or any copy payload.
|
|
50
|
+
*/
|
|
51
|
+
readonly copy?: (content: ResolvedShare) => CopyInput;
|
|
52
|
+
/** Default: the browser Clipboard API, as `useCopy` uses. */
|
|
53
|
+
readonly adapter?: ClipboardAdapter;
|
|
54
|
+
/** Default: `window`. For tests, webviews and other hosts. */
|
|
55
|
+
readonly environment?: ShareEnvironment;
|
|
56
|
+
/** Aborting it stops a copy in progress; the share sheet itself can only be closed by the user. */
|
|
57
|
+
readonly signal?: AbortSignal;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Why the content was copied rather than shared: `preferred` (the mode chose
|
|
61
|
+
* copy, as on desktop in `auto`), `unsupported` (no share sheet, or it can't
|
|
62
|
+
* take this content) or `fallback` (the share sheet failed).
|
|
63
|
+
*/
|
|
64
|
+
type CopyReason = 'preferred' | 'unsupported' | 'fallback';
|
|
65
|
+
/** What `shareOrCopy` resolves to. It never rejects. */
|
|
66
|
+
type ShareOutcome = {
|
|
67
|
+
readonly status: 'shared';
|
|
68
|
+
readonly method: 'native';
|
|
69
|
+
readonly content: ResolvedShare;
|
|
70
|
+
} | {
|
|
71
|
+
readonly status: 'copied';
|
|
72
|
+
readonly method: 'copy';
|
|
73
|
+
readonly reason: CopyReason;
|
|
74
|
+
readonly payload: CopyPayload;
|
|
75
|
+
readonly content: ResolvedShare;
|
|
76
|
+
} |
|
|
77
|
+
/** The user closed the share sheet. Nothing to report. */
|
|
78
|
+
{
|
|
79
|
+
readonly status: 'cancelled';
|
|
80
|
+
readonly method: 'native';
|
|
81
|
+
} | {
|
|
82
|
+
readonly status: 'error';
|
|
83
|
+
readonly method: ShareMethod;
|
|
84
|
+
readonly error: CopyError;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* How {@link shareOrCopy} would share right now: `"native"` (the share sheet) or
|
|
88
|
+
* `"copy"`. Use it to label the button ("Share…" or "Copy link"). Pass the
|
|
89
|
+
* content when it has files, since not every share sheet takes them.
|
|
90
|
+
*/
|
|
91
|
+
declare function shareMethod(options?: Pick<ShareOptions, 'mode' | 'environment'>, content?: ShareContent): ShareMethod;
|
|
92
|
+
/**
|
|
93
|
+
* Shares through the device's share sheet where people expect one, and copies a
|
|
94
|
+
* titled link everywhere else. Call it directly in a click handler: the share
|
|
95
|
+
* sheet needs the user's gesture.
|
|
96
|
+
*
|
|
97
|
+
* It never rejects. It resolves to `shared`, `copied` (with why), `cancelled`
|
|
98
|
+
* (the user closed the share sheet: nothing to report) or `error` with a typed
|
|
99
|
+
* {@link CopyError}.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* button.addEventListener('click', async () => {
|
|
103
|
+
* const outcome = await shareOrCopy({ url: location.href, title: document.title });
|
|
104
|
+
* if (outcome.status === 'copied') toast('Link copied');
|
|
105
|
+
* });
|
|
106
|
+
*/
|
|
107
|
+
declare function shareOrCopy(content: ShareContent, options?: ShareOptions): Promise<ShareOutcome>;
|
|
108
|
+
/**
|
|
109
|
+
* Default English, user-facing sentence for a failed share: a share sheet
|
|
110
|
+
* failure is described as sharing, a failed copy as copying. Replace for i18n.
|
|
111
|
+
*/
|
|
112
|
+
declare function describeShareError(error: CopyError, method: ShareMethod): string;
|
|
113
|
+
//#endregion
|
|
114
|
+
export { ShareMethod as a, ShareOutcome as c, shareOrCopy as d, ShareEnvironment as i, describeShareError as l, ResolvedShare as n, ShareMode as o, ShareContent as r, ShareOptions as s, CopyReason as t, shareMethod as u };
|
|
115
|
+
//# sourceMappingURL=share-e7FenIr2.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/text-field.ts
|
|
3
|
+
const TEXT_INPUTS = /* @__PURE__ */ new Set([
|
|
4
|
+
"text",
|
|
5
|
+
"search",
|
|
6
|
+
"url",
|
|
7
|
+
"tel",
|
|
8
|
+
"password"
|
|
9
|
+
]);
|
|
10
|
+
function asTextField(target) {
|
|
11
|
+
if (typeof target !== "object" || target === null) return null;
|
|
12
|
+
const element = target;
|
|
13
|
+
if (element.nodeName === "TEXTAREA") return target;
|
|
14
|
+
if (element.nodeName === "INPUT" && typeof element.type === "string" && TEXT_INPUTS.has(element.type)) return target;
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the
|
|
19
|
+
* selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still
|
|
20
|
+
* works, `input` events fire (so React and other frameworks see the change),
|
|
21
|
+
* and `maxlength` is respected. Returns `false` for disabled or read-only fields.
|
|
22
|
+
*/
|
|
23
|
+
function insertText(field, text) {
|
|
24
|
+
if (field.disabled || field.readOnly) return false;
|
|
25
|
+
const value = field.nodeName === "INPUT" ? text.replace(/[ \t]*(?:\r\n|\r|\n)+[ \t]*/g, " ") : text;
|
|
26
|
+
const doc = field.ownerDocument;
|
|
27
|
+
field.focus();
|
|
28
|
+
const start = field.selectionStart;
|
|
29
|
+
const end = field.selectionEnd;
|
|
30
|
+
try {
|
|
31
|
+
if (start !== null && end !== null) field.setSelectionRange(start, end);
|
|
32
|
+
if (doc.activeElement === field && doc.execCommand("insertText", false, value)) return true;
|
|
33
|
+
} catch {}
|
|
34
|
+
const from = start ?? field.value.length;
|
|
35
|
+
const to = end ?? from;
|
|
36
|
+
let insert = value;
|
|
37
|
+
if (field.maxLength >= 0) {
|
|
38
|
+
const room = Math.max(0, field.maxLength - (field.value.length - (to - from)));
|
|
39
|
+
insert = insert.slice(0, room);
|
|
40
|
+
if (/[\ud800-\udbff]$/.test(insert)) insert = insert.slice(0, -1);
|
|
41
|
+
}
|
|
42
|
+
if (start === null) setNativeValue(field, field.value + insert);
|
|
43
|
+
else field.setRangeText(insert, from, to, "end");
|
|
44
|
+
const view = doc.defaultView;
|
|
45
|
+
const event = view !== null && typeof view.InputEvent === "function" ? new view.InputEvent("input", {
|
|
46
|
+
bubbles: true,
|
|
47
|
+
inputType: "insertFromPaste",
|
|
48
|
+
data: insert
|
|
49
|
+
}) : new Event("input", { bubbles: true });
|
|
50
|
+
field.dispatchEvent(event);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets a field's value through the prototype's setter. React tracks the value
|
|
55
|
+
* set on the element itself; going around it lets React see the change and
|
|
56
|
+
* call `onChange` for the `input` event that follows.
|
|
57
|
+
*/
|
|
58
|
+
function setNativeValue(field, next) {
|
|
59
|
+
const setter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), "value")?.set;
|
|
60
|
+
if (setter) setter.call(field, next);
|
|
61
|
+
else field.value = next;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
Object.defineProperty(exports, "asTextField", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function() {
|
|
67
|
+
return asTextField;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "insertText", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function() {
|
|
73
|
+
return insertText;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=text-field-Ba8W3v4R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-field-Ba8W3v4R.cjs","names":[],"sources":["../../src/core/text-field.ts"],"sourcesContent":["/**\n * Text-field helpers shared by the paste handlers of the opt-in entry points.\n * Internal: not part of `react-smart-copy/core`'s public API.\n */\n\n/** Text fields `setRangeText` and `execCommand('insertText')` both support. */\nexport type TextField = HTMLTextAreaElement | HTMLInputElement;\n\nconst TEXT_INPUTS = new Set(['text', 'search', 'url', 'tel', 'password']);\n\nexport function asTextField(target: EventTarget | null): TextField | null {\n if (typeof target !== 'object' || target === null) return null;\n const element = target as Partial<Element> & { type?: unknown };\n if (element.nodeName === 'TEXTAREA') return target as HTMLTextAreaElement;\n if (element.nodeName === 'INPUT' && typeof element.type === 'string' && TEXT_INPUTS.has(element.type)) return target as HTMLInputElement;\n return null;\n}\n\n/**\n * Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the\n * selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still\n * works, `input` events fire (so React and other frameworks see the change),\n * and `maxlength` is respected. Returns `false` for disabled or read-only fields.\n */\nexport function insertText(field: TextField, text: string): boolean {\n if (field.disabled || field.readOnly) return false;\n // An <input> holds one line: each run of line breaks (a paragraph break too) becomes one space.\n const value = field.nodeName === 'INPUT' ? text.replace(/[ \\t]*(?:\\r\\n|\\r|\\n)+[ \\t]*/g, ' ') : text;\n const doc = field.ownerDocument;\n field.focus();\n // `null` for inputs without a selection API (email, number): the text is appended.\n const start = field.selectionStart;\n const end = field.selectionEnd;\n try {\n // Re-applying the selection ends the current typing run, so the paste gets its own undo step\n // (as a native paste does) instead of merging with what was typed just before.\n if (start !== null && end !== null) field.setSelectionRange(start, end);\n // The only way to keep the native undo stack; supported for text fields in every current browser.\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- no replacement keeps undo history\n if (doc.activeElement === field && doc.execCommand('insertText', false, value)) return true;\n } catch {\n // Fall through to the manual insertion.\n }\n const from = start ?? field.value.length;\n const to = end ?? from;\n let insert = value;\n if (field.maxLength >= 0) {\n const room = Math.max(0, field.maxLength - (field.value.length - (to - from)));\n insert = insert.slice(0, room);\n // Never leave half of a surrogate pair (an emoji) behind.\n if (/[\\ud800-\\udbff]$/.test(insert)) insert = insert.slice(0, -1);\n }\n if (start === null) setNativeValue(field, field.value + insert);\n else field.setRangeText(insert, from, to, 'end');\n const view = doc.defaultView;\n const event =\n view !== null && typeof view.InputEvent === 'function'\n ? new view.InputEvent('input', { bubbles: true, inputType: 'insertFromPaste', data: insert })\n : new Event('input', { bubbles: true });\n field.dispatchEvent(event);\n return true;\n}\n\n/**\n * Sets a field's value through the prototype's setter. React tracks the value\n * set on the element itself; going around it lets React see the change and\n * call `onChange` for the `input` event that follows.\n */\nfunction setNativeValue(field: TextField, next: string): void {\n const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field) as object, 'value');\n // eslint-disable-next-line @typescript-eslint/unbound-method -- it is called right below with the field as `this`\n const setter = descriptor?.set;\n if (setter) setter.call(field, next);\n else field.value = next;\n}\n"],"mappings":";;AAQA,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAO;CAAO;AAAU,CAAC;AAExE,SAAgB,YAAY,QAA8C;CACxE,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM,OAAO;CAC1D,MAAM,UAAU;CAChB,IAAI,QAAQ,aAAa,YAAY,OAAO;CAC5C,IAAI,QAAQ,aAAa,WAAW,OAAO,QAAQ,SAAS,YAAY,YAAY,IAAI,QAAQ,IAAI,GAAG,OAAO;CAC9G,OAAO;AACT;;;;;;;AAQA,SAAgB,WAAW,OAAkB,MAAuB;CAClE,IAAI,MAAM,YAAY,MAAM,UAAU,OAAO;CAE7C,MAAM,QAAQ,MAAM,aAAa,UAAU,KAAK,QAAQ,gCAAgC,GAAG,IAAI;CAC/F,MAAM,MAAM,MAAM;CAClB,MAAM,MAAM;CAEZ,MAAM,QAAQ,MAAM;CACpB,MAAM,MAAM,MAAM;CAClB,IAAI;EAGF,IAAI,UAAU,QAAQ,QAAQ,MAAM,MAAM,kBAAkB,OAAO,GAAG;EAGtE,IAAI,IAAI,kBAAkB,SAAS,IAAI,YAAY,cAAc,OAAO,KAAK,GAAG,OAAO;CACzF,QAAQ,CAER;CACA,MAAM,OAAO,SAAS,MAAM,MAAM;CAClC,MAAM,KAAK,OAAO;CAClB,IAAI,SAAS;CACb,IAAI,MAAM,aAAa,GAAG;EACxB,MAAM,OAAO,KAAK,IAAI,GAAG,MAAM,aAAa,MAAM,MAAM,UAAU,KAAK,MAAM;EAC7E,SAAS,OAAO,MAAM,GAAG,IAAI;EAE7B,IAAI,mBAAmB,KAAK,MAAM,GAAG,SAAS,OAAO,MAAM,GAAG,EAAE;CAClE;CACA,IAAI,UAAU,MAAM,eAAe,OAAO,MAAM,QAAQ,MAAM;MACzD,MAAM,aAAa,QAAQ,MAAM,IAAI,KAAK;CAC/C,MAAM,OAAO,IAAI;CACjB,MAAM,QACJ,SAAS,QAAQ,OAAO,KAAK,eAAe,aACxC,IAAI,KAAK,WAAW,SAAS;EAAE,SAAS;EAAM,WAAW;EAAmB,MAAM;CAAO,CAAC,IAC1F,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC;CAC1C,MAAM,cAAc,KAAK;CACzB,OAAO;AACT;;;;;;AAOA,SAAS,eAAe,OAAkB,MAAoB;CAG5D,MAAM,SAFa,OAAO,yBAAyB,OAAO,eAAe,KAAK,GAAa,OAEnE,CAAC,EAAE;CAC3B,IAAI,QAAQ,OAAO,KAAK,OAAO,IAAI;MAC9B,MAAM,QAAQ;AACrB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/text-field.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Text-field helpers shared by the paste handlers of the opt-in entry points.
|
|
5
|
+
* Internal: not part of `react-smart-copy/core`'s public API.
|
|
6
|
+
*/
|
|
7
|
+
/** Text fields `setRangeText` and `execCommand('insertText')` both support. */
|
|
8
|
+
type TextField = HTMLTextAreaElement | HTMLInputElement;
|
|
9
|
+
/**
|
|
10
|
+
* Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the
|
|
11
|
+
* selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still
|
|
12
|
+
* works, `input` events fire (so React and other frameworks see the change),
|
|
13
|
+
* and `maxlength` is respected. Returns `false` for disabled or read-only fields.
|
|
14
|
+
*/
|
|
15
|
+
declare function insertText(field: TextField, text: string): boolean;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { insertText as t };
|
|
18
|
+
//# sourceMappingURL=text-field-C0SGmvvR.d.cts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/text-field.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Text-field helpers shared by the paste handlers of the opt-in entry points.
|
|
5
|
+
* Internal: not part of `react-smart-copy/core`'s public API.
|
|
6
|
+
*/
|
|
7
|
+
/** Text fields `setRangeText` and `execCommand('insertText')` both support. */
|
|
8
|
+
type TextField = HTMLTextAreaElement | HTMLInputElement;
|
|
9
|
+
/**
|
|
10
|
+
* Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the
|
|
11
|
+
* selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still
|
|
12
|
+
* works, `input` events fire (so React and other frameworks see the change),
|
|
13
|
+
* and `maxlength` is respected. Returns `false` for disabled or read-only fields.
|
|
14
|
+
*/
|
|
15
|
+
declare function insertText(field: TextField, text: string): boolean;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { insertText as t };
|
|
18
|
+
//# sourceMappingURL=text-field-C0SGmvvR.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/text-field.ts
|
|
3
|
+
const TEXT_INPUTS = /* @__PURE__ */ new Set([
|
|
4
|
+
"text",
|
|
5
|
+
"search",
|
|
6
|
+
"url",
|
|
7
|
+
"tel",
|
|
8
|
+
"password"
|
|
9
|
+
]);
|
|
10
|
+
function asTextField(target) {
|
|
11
|
+
if (typeof target !== "object" || target === null) return null;
|
|
12
|
+
const element = target;
|
|
13
|
+
if (element.nodeName === "TEXTAREA") return target;
|
|
14
|
+
if (element.nodeName === "INPUT" && typeof element.type === "string" && TEXT_INPUTS.has(element.type)) return target;
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the
|
|
19
|
+
* selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still
|
|
20
|
+
* works, `input` events fire (so React and other frameworks see the change),
|
|
21
|
+
* and `maxlength` is respected. Returns `false` for disabled or read-only fields.
|
|
22
|
+
*/
|
|
23
|
+
function insertText(field, text) {
|
|
24
|
+
if (field.disabled || field.readOnly) return false;
|
|
25
|
+
const value = field.nodeName === "INPUT" ? text.replace(/[ \t]*(?:\r\n|\r|\n)+[ \t]*/g, " ") : text;
|
|
26
|
+
const doc = field.ownerDocument;
|
|
27
|
+
field.focus();
|
|
28
|
+
const start = field.selectionStart;
|
|
29
|
+
const end = field.selectionEnd;
|
|
30
|
+
try {
|
|
31
|
+
if (start !== null && end !== null) field.setSelectionRange(start, end);
|
|
32
|
+
if (doc.activeElement === field && doc.execCommand("insertText", false, value)) return true;
|
|
33
|
+
} catch {}
|
|
34
|
+
const from = start ?? field.value.length;
|
|
35
|
+
const to = end ?? from;
|
|
36
|
+
let insert = value;
|
|
37
|
+
if (field.maxLength >= 0) {
|
|
38
|
+
const room = Math.max(0, field.maxLength - (field.value.length - (to - from)));
|
|
39
|
+
insert = insert.slice(0, room);
|
|
40
|
+
if (/[\ud800-\udbff]$/.test(insert)) insert = insert.slice(0, -1);
|
|
41
|
+
}
|
|
42
|
+
if (start === null) setNativeValue(field, field.value + insert);
|
|
43
|
+
else field.setRangeText(insert, from, to, "end");
|
|
44
|
+
const view = doc.defaultView;
|
|
45
|
+
const event = view !== null && typeof view.InputEvent === "function" ? new view.InputEvent("input", {
|
|
46
|
+
bubbles: true,
|
|
47
|
+
inputType: "insertFromPaste",
|
|
48
|
+
data: insert
|
|
49
|
+
}) : new Event("input", { bubbles: true });
|
|
50
|
+
field.dispatchEvent(event);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets a field's value through the prototype's setter. React tracks the value
|
|
55
|
+
* set on the element itself; going around it lets React see the change and
|
|
56
|
+
* call `onChange` for the `input` event that follows.
|
|
57
|
+
*/
|
|
58
|
+
function setNativeValue(field, next) {
|
|
59
|
+
const setter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), "value")?.set;
|
|
60
|
+
if (setter) setter.call(field, next);
|
|
61
|
+
else field.value = next;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { insertText as n, asTextField as t };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=text-field-DUvrMMaK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-field-DUvrMMaK.js","names":[],"sources":["../../src/core/text-field.ts"],"sourcesContent":["/**\n * Text-field helpers shared by the paste handlers of the opt-in entry points.\n * Internal: not part of `react-smart-copy/core`'s public API.\n */\n\n/** Text fields `setRangeText` and `execCommand('insertText')` both support. */\nexport type TextField = HTMLTextAreaElement | HTMLInputElement;\n\nconst TEXT_INPUTS = new Set(['text', 'search', 'url', 'tel', 'password']);\n\nexport function asTextField(target: EventTarget | null): TextField | null {\n if (typeof target !== 'object' || target === null) return null;\n const element = target as Partial<Element> & { type?: unknown };\n if (element.nodeName === 'TEXTAREA') return target as HTMLTextAreaElement;\n if (element.nodeName === 'INPUT' && typeof element.type === 'string' && TEXT_INPUTS.has(element.type)) return target as HTMLInputElement;\n return null;\n}\n\n/**\n * Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the\n * selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still\n * works, `input` events fire (so React and other frameworks see the change),\n * and `maxlength` is respected. Returns `false` for disabled or read-only fields.\n */\nexport function insertText(field: TextField, text: string): boolean {\n if (field.disabled || field.readOnly) return false;\n // An <input> holds one line: each run of line breaks (a paragraph break too) becomes one space.\n const value = field.nodeName === 'INPUT' ? text.replace(/[ \\t]*(?:\\r\\n|\\r|\\n)+[ \\t]*/g, ' ') : text;\n const doc = field.ownerDocument;\n field.focus();\n // `null` for inputs without a selection API (email, number): the text is appended.\n const start = field.selectionStart;\n const end = field.selectionEnd;\n try {\n // Re-applying the selection ends the current typing run, so the paste gets its own undo step\n // (as a native paste does) instead of merging with what was typed just before.\n if (start !== null && end !== null) field.setSelectionRange(start, end);\n // The only way to keep the native undo stack; supported for text fields in every current browser.\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- no replacement keeps undo history\n if (doc.activeElement === field && doc.execCommand('insertText', false, value)) return true;\n } catch {\n // Fall through to the manual insertion.\n }\n const from = start ?? field.value.length;\n const to = end ?? from;\n let insert = value;\n if (field.maxLength >= 0) {\n const room = Math.max(0, field.maxLength - (field.value.length - (to - from)));\n insert = insert.slice(0, room);\n // Never leave half of a surrogate pair (an emoji) behind.\n if (/[\\ud800-\\udbff]$/.test(insert)) insert = insert.slice(0, -1);\n }\n if (start === null) setNativeValue(field, field.value + insert);\n else field.setRangeText(insert, from, to, 'end');\n const view = doc.defaultView;\n const event =\n view !== null && typeof view.InputEvent === 'function'\n ? new view.InputEvent('input', { bubbles: true, inputType: 'insertFromPaste', data: insert })\n : new Event('input', { bubbles: true });\n field.dispatchEvent(event);\n return true;\n}\n\n/**\n * Sets a field's value through the prototype's setter. React tracks the value\n * set on the element itself; going around it lets React see the change and\n * call `onChange` for the `input` event that follows.\n */\nfunction setNativeValue(field: TextField, next: string): void {\n const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field) as object, 'value');\n // eslint-disable-next-line @typescript-eslint/unbound-method -- it is called right below with the field as `this`\n const setter = descriptor?.set;\n if (setter) setter.call(field, next);\n else field.value = next;\n}\n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