@peculiar/react-components 0.5.2 → 0.6.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/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/use_clipboard.js +64 -41
- package/dist/cjs/hooks/use_clipboard.js.map +1 -1
- package/dist/cjs/utils/copy_to_clipboard.js +44 -0
- package/dist/cjs/utils/copy_to_clipboard.js.map +1 -0
- package/dist/cjs/utils/index.js +5 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/use_clipboard.js +64 -41
- package/dist/esm/hooks/use_clipboard.js.map +1 -1
- package/dist/esm/utils/copy_to_clipboard.js +40 -0
- package/dist/esm/utils/copy_to_clipboard.js.map +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esnext/hooks/index.js.map +1 -1
- package/dist/esnext/hooks/use_clipboard.js +25 -30
- package/dist/esnext/hooks/use_clipboard.js.map +1 -1
- package/dist/esnext/utils/copy_to_clipboard.js +40 -0
- package/dist/esnext/utils/copy_to_clipboard.js.map +1 -0
- package/dist/esnext/utils/index.js +1 -0
- package/dist/esnext/utils/index.js.map +1 -1
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/hooks/use_clipboard.d.ts +4 -23
- package/dist/types/utils/copy_to_clipboard.d.ts +3 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,uDAA0D;AAAjD,wHAAA,oBAAoB,OAAA;AAE7B,mCAAiC;AAAxB,+FAAA,KAAK,OAAA;AACd,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AACjB,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAChC,uDAE4B;AAD1B,mHAAA,eAAe,OAAA;AAUjB,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA"}
|
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
12
37
|
};
|
|
13
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -16,42 +41,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
42
|
exports.useClipboard = void 0;
|
|
18
43
|
var react_1 = __importDefault(require("react"));
|
|
19
|
-
var
|
|
44
|
+
var utils_1 = require("../utils");
|
|
20
45
|
/**
|
|
21
|
-
* React hook to copy content to clipboard
|
|
22
|
-
*
|
|
23
|
-
* @param text the text or value to copy
|
|
24
|
-
* @param {Number} [optionsOrTimeout=1500] optionsOrTimeout -
|
|
25
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
26
|
-
* @param {Object} optionsOrTimeout
|
|
27
|
-
* @param {string} optionsOrTimeout.format - set the desired MIME type
|
|
28
|
-
* @param {number} optionsOrTimeout.timeout -
|
|
29
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
46
|
+
* React hook to copy content to clipboard.
|
|
30
47
|
*/
|
|
31
|
-
function useClipboard(
|
|
32
|
-
|
|
33
|
-
var _a = react_1.default.useState(false),
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
: optionsOrTimeout, _c = _b.timeout, timeout = _c === void 0 ? 1500 : _c, copyOptions = __rest(_b, ["timeout"]);
|
|
37
|
-
var onCopy = react_1.default.useCallback(function () {
|
|
38
|
-
var didCopy = (0, copy_to_clipboard_1.default)(text, copyOptions);
|
|
39
|
-
setHasCopied(didCopy);
|
|
40
|
-
}, [text, copyOptions]);
|
|
48
|
+
function useClipboard() {
|
|
49
|
+
var _this = this;
|
|
50
|
+
var _a = react_1.default.useState(false), isCopied = _a[0], setIsCopied = _a[1];
|
|
51
|
+
var timeout = react_1.default.useRef();
|
|
52
|
+
var mounted = react_1.default.useRef(false);
|
|
41
53
|
react_1.default.useEffect(function () {
|
|
42
|
-
|
|
43
|
-
if (hasCopied) {
|
|
44
|
-
timeoutId = window.setTimeout(function () {
|
|
45
|
-
setHasCopied(false);
|
|
46
|
-
}, timeout);
|
|
47
|
-
}
|
|
54
|
+
mounted.current = true;
|
|
48
55
|
return function () {
|
|
49
|
-
|
|
50
|
-
window.clearTimeout(timeoutId);
|
|
51
|
-
}
|
|
56
|
+
mounted.current = false;
|
|
52
57
|
};
|
|
53
|
-
}, [
|
|
54
|
-
|
|
58
|
+
}, []);
|
|
59
|
+
var copy = function (text) { return __awaiter(_this, void 0, void 0, function () {
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
try {
|
|
62
|
+
setIsCopied(true);
|
|
63
|
+
clearTimeout(timeout.current);
|
|
64
|
+
timeout.current = setTimeout(function () {
|
|
65
|
+
if (mounted) {
|
|
66
|
+
setIsCopied(false);
|
|
67
|
+
}
|
|
68
|
+
}, 1500);
|
|
69
|
+
(0, utils_1.copyToClipboard)(text);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// ignore error
|
|
73
|
+
}
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
});
|
|
76
|
+
}); };
|
|
77
|
+
return { copy: copy, isCopied: isCopied };
|
|
55
78
|
}
|
|
56
79
|
exports.useClipboard = useClipboard;
|
|
57
80
|
//# sourceMappingURL=use_clipboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_clipboard.js","sourceRoot":"","sources":["../../../src/hooks/use_clipboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use_clipboard.js","sourceRoot":"","sources":["../../../src/hooks/use_clipboard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,kCAA2C;AAE3C;;GAEG;AACH,SAAgB,YAAY;IAA5B,iBA+BC;IA9BO,IAAA,KAA0B,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAA9C,QAAQ,QAAA,EAAE,WAAW,QAAyB,CAAC;IACtD,IAAM,OAAO,GAAG,eAAK,CAAC,MAAM,EAAiC,CAAC;IAC9D,IAAM,OAAO,GAAG,eAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpC,eAAK,CAAC,SAAS,CAAC;QACd,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QAEvB,OAAO;YACL,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAM,IAAI,GAAG,UAAO,IAAY;;YAC9B,IAAI;gBACF,WAAW,CAAC,IAAI,CAAC,CAAC;gBAClB,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAE9B,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC;oBAC3B,IAAI,OAAO,EAAE;wBACX,WAAW,CAAC,KAAK,CAAC,CAAC;qBACpB;gBACH,CAAC,EAAE,IAAI,CAAC,CAAC;gBAET,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAC;aACvB;YAAC,OAAO,KAAK,EAAE;gBACd,eAAe;aAChB;;;SACF,CAAC;IAEF,OAAO,EAAE,IAAI,MAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAC5B,CAAC;AA/BD,oCA+BC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyToClipboard = void 0;
|
|
4
|
+
var fallbackCopyToClipboard = function (text, onSuccess) {
|
|
5
|
+
var textareaElement = document.createElement('textarea');
|
|
6
|
+
textareaElement.value = text;
|
|
7
|
+
document.body.appendChild(textareaElement);
|
|
8
|
+
if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
|
|
9
|
+
var range = document.createRange();
|
|
10
|
+
textareaElement.setAttribute('contentEditable', 'true');
|
|
11
|
+
textareaElement.setAttribute('readOnly', 'true');
|
|
12
|
+
range.selectNodeContents(textareaElement);
|
|
13
|
+
var selection = window.getSelection();
|
|
14
|
+
if (selection) {
|
|
15
|
+
selection.removeAllRanges();
|
|
16
|
+
selection.addRange(range);
|
|
17
|
+
}
|
|
18
|
+
textareaElement.setSelectionRange(0, text.length);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
textareaElement.select();
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
document.execCommand('copy');
|
|
25
|
+
if (onSuccess) {
|
|
26
|
+
onSuccess();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error('Fallback copy error:', error);
|
|
31
|
+
}
|
|
32
|
+
document.body.removeChild(textareaElement);
|
|
33
|
+
};
|
|
34
|
+
var copyToClipboard = function (text, onSuccess) {
|
|
35
|
+
if (!navigator.clipboard) {
|
|
36
|
+
fallbackCopyToClipboard(text, onSuccess);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
navigator.clipboard.writeText(text)
|
|
40
|
+
.then(onSuccess)
|
|
41
|
+
.catch(function () { return fallbackCopyToClipboard(text, onSuccess); });
|
|
42
|
+
};
|
|
43
|
+
exports.copyToClipboard = copyToClipboard;
|
|
44
|
+
//# sourceMappingURL=copy_to_clipboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy_to_clipboard.js","sourceRoot":"","sources":["../../../src/utils/copy_to_clipboard.ts"],"names":[],"mappings":";;;AAEA,IAAM,uBAAuB,GAAG,UAAC,IAAY,EAAE,SAA2B;IACxE,IAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAE3D,eAAe,CAAC,KAAK,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAE3C,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE;QAClD,IAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAErC,eAAe,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACxD,eAAe,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEjD,KAAK,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAE1C,IAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QAExC,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,eAAe,EAAE,CAAC;YAC5B,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,eAAe,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;KACnD;SAAM;QACL,eAAe,CAAC,MAAM,EAAE,CAAC;KAC1B;IAED,IAAI;QACF,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE7B,IAAI,SAAS,EAAE;YACb,SAAS,EAAE,CAAC;SACb;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;KAC9C;IAED,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEK,IAAM,eAAe,GAAG,UAAC,IAAY,EAAE,SAA2B;IACvE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;QACxB,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAEzC,OAAO;KACR;IAED,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;SAChC,IAAI,CAAC,SAAS,CAAC;SACf,KAAK,CAAC,cAAM,OAAA,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,EAAxC,CAAwC,CAAC,CAAC;AAC3D,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B"}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyToClipboard = void 0;
|
|
4
|
+
var copy_to_clipboard_1 = require("./copy_to_clipboard");
|
|
5
|
+
Object.defineProperty(exports, "copyToClipboard", { enumerable: true, get: function () { return copy_to_clipboard_1.copyToClipboard; } });
|
|
1
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAA7C,oHAAA,eAAe,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACL,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1,50 +1,73 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
11
36
|
};
|
|
12
37
|
import React from 'react';
|
|
13
|
-
import
|
|
38
|
+
import { copyToClipboard } from '../utils';
|
|
14
39
|
/**
|
|
15
|
-
* React hook to copy content to clipboard
|
|
16
|
-
*
|
|
17
|
-
* @param text the text or value to copy
|
|
18
|
-
* @param {Number} [optionsOrTimeout=1500] optionsOrTimeout -
|
|
19
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
20
|
-
* @param {Object} optionsOrTimeout
|
|
21
|
-
* @param {string} optionsOrTimeout.format - set the desired MIME type
|
|
22
|
-
* @param {number} optionsOrTimeout.timeout -
|
|
23
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
40
|
+
* React hook to copy content to clipboard.
|
|
24
41
|
*/
|
|
25
|
-
export function useClipboard(
|
|
26
|
-
|
|
27
|
-
var _a = React.useState(false),
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
: optionsOrTimeout, _c = _b.timeout, timeout = _c === void 0 ? 1500 : _c, copyOptions = __rest(_b, ["timeout"]);
|
|
31
|
-
var onCopy = React.useCallback(function () {
|
|
32
|
-
var didCopy = copy(text, copyOptions);
|
|
33
|
-
setHasCopied(didCopy);
|
|
34
|
-
}, [text, copyOptions]);
|
|
42
|
+
export function useClipboard() {
|
|
43
|
+
var _this = this;
|
|
44
|
+
var _a = React.useState(false), isCopied = _a[0], setIsCopied = _a[1];
|
|
45
|
+
var timeout = React.useRef();
|
|
46
|
+
var mounted = React.useRef(false);
|
|
35
47
|
React.useEffect(function () {
|
|
36
|
-
|
|
37
|
-
if (hasCopied) {
|
|
38
|
-
timeoutId = window.setTimeout(function () {
|
|
39
|
-
setHasCopied(false);
|
|
40
|
-
}, timeout);
|
|
41
|
-
}
|
|
48
|
+
mounted.current = true;
|
|
42
49
|
return function () {
|
|
43
|
-
|
|
44
|
-
window.clearTimeout(timeoutId);
|
|
45
|
-
}
|
|
50
|
+
mounted.current = false;
|
|
46
51
|
};
|
|
47
|
-
}, [
|
|
48
|
-
|
|
52
|
+
}, []);
|
|
53
|
+
var copy = function (text) { return __awaiter(_this, void 0, void 0, function () {
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
try {
|
|
56
|
+
setIsCopied(true);
|
|
57
|
+
clearTimeout(timeout.current);
|
|
58
|
+
timeout.current = setTimeout(function () {
|
|
59
|
+
if (mounted) {
|
|
60
|
+
setIsCopied(false);
|
|
61
|
+
}
|
|
62
|
+
}, 1500);
|
|
63
|
+
copyToClipboard(text);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// ignore error
|
|
67
|
+
}
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
});
|
|
70
|
+
}); };
|
|
71
|
+
return { copy: copy, isCopied: isCopied };
|
|
49
72
|
}
|
|
50
73
|
//# sourceMappingURL=use_clipboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_clipboard.js","sourceRoot":"","sources":["../../../src/hooks/use_clipboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use_clipboard.js","sourceRoot":"","sources":["../../../src/hooks/use_clipboard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,MAAM,UAAU,YAAY;IAA5B,iBA+BC;IA9BO,IAAA,KAA0B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAA9C,QAAQ,QAAA,EAAE,WAAW,QAAyB,CAAC;IACtD,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAiC,CAAC;IAC9D,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpC,KAAK,CAAC,SAAS,CAAC;QACd,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QAEvB,OAAO;YACL,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAM,IAAI,GAAG,UAAO,IAAY;;YAC9B,IAAI;gBACF,WAAW,CAAC,IAAI,CAAC,CAAC;gBAClB,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAE9B,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC;oBAC3B,IAAI,OAAO,EAAE;wBACX,WAAW,CAAC,KAAK,CAAC,CAAC;qBACpB;gBACH,CAAC,EAAE,IAAI,CAAC,CAAC;gBAET,eAAe,CAAC,IAAI,CAAC,CAAC;aACvB;YAAC,OAAO,KAAK,EAAE;gBACd,eAAe;aAChB;;;SACF,CAAC;IAEF,OAAO,EAAE,IAAI,MAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var fallbackCopyToClipboard = function (text, onSuccess) {
|
|
2
|
+
var textareaElement = document.createElement('textarea');
|
|
3
|
+
textareaElement.value = text;
|
|
4
|
+
document.body.appendChild(textareaElement);
|
|
5
|
+
if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
|
|
6
|
+
var range = document.createRange();
|
|
7
|
+
textareaElement.setAttribute('contentEditable', 'true');
|
|
8
|
+
textareaElement.setAttribute('readOnly', 'true');
|
|
9
|
+
range.selectNodeContents(textareaElement);
|
|
10
|
+
var selection = window.getSelection();
|
|
11
|
+
if (selection) {
|
|
12
|
+
selection.removeAllRanges();
|
|
13
|
+
selection.addRange(range);
|
|
14
|
+
}
|
|
15
|
+
textareaElement.setSelectionRange(0, text.length);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
textareaElement.select();
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
document.execCommand('copy');
|
|
22
|
+
if (onSuccess) {
|
|
23
|
+
onSuccess();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('Fallback copy error:', error);
|
|
28
|
+
}
|
|
29
|
+
document.body.removeChild(textareaElement);
|
|
30
|
+
};
|
|
31
|
+
export var copyToClipboard = function (text, onSuccess) {
|
|
32
|
+
if (!navigator.clipboard) {
|
|
33
|
+
fallbackCopyToClipboard(text, onSuccess);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
navigator.clipboard.writeText(text)
|
|
37
|
+
.then(onSuccess)
|
|
38
|
+
.catch(function () { return fallbackCopyToClipboard(text, onSuccess); });
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=copy_to_clipboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy_to_clipboard.js","sourceRoot":"","sources":["../../../src/utils/copy_to_clipboard.ts"],"names":[],"mappings":"AAEA,IAAM,uBAAuB,GAAG,UAAC,IAAY,EAAE,SAA2B;IACxE,IAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAE3D,eAAe,CAAC,KAAK,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAE3C,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE;QAClD,IAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAErC,eAAe,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACxD,eAAe,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEjD,KAAK,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAE1C,IAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QAExC,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,eAAe,EAAE,CAAC;YAC5B,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,eAAe,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;KACnD;SAAM;QACL,eAAe,CAAC,MAAM,EAAE,CAAC;KAC1B;IAED,IAAI;QACF,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE7B,IAAI,SAAS,EAAE;YACb,SAAS,EAAE,CAAC;SACb;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;KAC9C;IAED,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,eAAe,GAAG,UAAC,IAAY,EAAE,SAA2B;IACvE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;QACxB,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAEzC,OAAO;KACR;IAED,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;SAChC,IAAI,CAAC,SAAS,CAAC;SACf,KAAK,CAAC,cAAM,OAAA,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,EAAxC,CAAwC,CAAC,CAAC;AAC3D,CAAC,CAAC"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACL,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1,38 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { copyToClipboard } from '../utils';
|
|
3
3
|
/**
|
|
4
|
-
* React hook to copy content to clipboard
|
|
5
|
-
*
|
|
6
|
-
* @param text the text or value to copy
|
|
7
|
-
* @param {Number} [optionsOrTimeout=1500] optionsOrTimeout -
|
|
8
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
9
|
-
* @param {Object} optionsOrTimeout
|
|
10
|
-
* @param {string} optionsOrTimeout.format - set the desired MIME type
|
|
11
|
-
* @param {number} optionsOrTimeout.timeout -
|
|
12
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
4
|
+
* React hook to copy content to clipboard.
|
|
13
5
|
*/
|
|
14
|
-
export function useClipboard(
|
|
15
|
-
const [
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
: optionsOrTimeout;
|
|
19
|
-
const onCopy = React.useCallback(() => {
|
|
20
|
-
const didCopy = copy(text, copyOptions);
|
|
21
|
-
setHasCopied(didCopy);
|
|
22
|
-
}, [text, copyOptions]);
|
|
6
|
+
export function useClipboard() {
|
|
7
|
+
const [isCopied, setIsCopied] = React.useState(false);
|
|
8
|
+
const timeout = React.useRef();
|
|
9
|
+
const mounted = React.useRef(false);
|
|
23
10
|
React.useEffect(() => {
|
|
24
|
-
|
|
25
|
-
if (hasCopied) {
|
|
26
|
-
timeoutId = window.setTimeout(() => {
|
|
27
|
-
setHasCopied(false);
|
|
28
|
-
}, timeout);
|
|
29
|
-
}
|
|
11
|
+
mounted.current = true;
|
|
30
12
|
return () => {
|
|
31
|
-
|
|
32
|
-
window.clearTimeout(timeoutId);
|
|
33
|
-
}
|
|
13
|
+
mounted.current = false;
|
|
34
14
|
};
|
|
35
|
-
}, [
|
|
36
|
-
|
|
15
|
+
}, []);
|
|
16
|
+
const copy = async (text) => {
|
|
17
|
+
try {
|
|
18
|
+
setIsCopied(true);
|
|
19
|
+
clearTimeout(timeout.current);
|
|
20
|
+
timeout.current = setTimeout(() => {
|
|
21
|
+
if (mounted) {
|
|
22
|
+
setIsCopied(false);
|
|
23
|
+
}
|
|
24
|
+
}, 1500);
|
|
25
|
+
copyToClipboard(text);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// ignore error
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return { copy, isCopied };
|
|
37
32
|
}
|
|
38
33
|
//# sourceMappingURL=use_clipboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_clipboard.js","sourceRoot":"","sources":["../../../src/hooks/use_clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"use_clipboard.js","sourceRoot":"","sources":["../../../src/hooks/use_clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAiC,CAAC;IAC9D,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QAEvB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,IAAI,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;QAClC,IAAI;YACF,WAAW,CAAC,IAAI,CAAC,CAAC;YAClB,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAE9B,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAChC,IAAI,OAAO,EAAE;oBACX,WAAW,CAAC,KAAK,CAAC,CAAC;iBACpB;YACH,CAAC,EAAE,IAAI,CAAC,CAAC;YAET,eAAe,CAAC,IAAI,CAAC,CAAC;SACvB;QAAC,OAAO,KAAK,EAAE;YACd,eAAe;SAChB;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const fallbackCopyToClipboard = (text, onSuccess) => {
|
|
2
|
+
const textareaElement = document.createElement('textarea');
|
|
3
|
+
textareaElement.value = text;
|
|
4
|
+
document.body.appendChild(textareaElement);
|
|
5
|
+
if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
|
|
6
|
+
const range = document.createRange();
|
|
7
|
+
textareaElement.setAttribute('contentEditable', 'true');
|
|
8
|
+
textareaElement.setAttribute('readOnly', 'true');
|
|
9
|
+
range.selectNodeContents(textareaElement);
|
|
10
|
+
const selection = window.getSelection();
|
|
11
|
+
if (selection) {
|
|
12
|
+
selection.removeAllRanges();
|
|
13
|
+
selection.addRange(range);
|
|
14
|
+
}
|
|
15
|
+
textareaElement.setSelectionRange(0, text.length);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
textareaElement.select();
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
document.execCommand('copy');
|
|
22
|
+
if (onSuccess) {
|
|
23
|
+
onSuccess();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('Fallback copy error:', error);
|
|
28
|
+
}
|
|
29
|
+
document.body.removeChild(textareaElement);
|
|
30
|
+
};
|
|
31
|
+
export const copyToClipboard = (text, onSuccess) => {
|
|
32
|
+
if (!navigator.clipboard) {
|
|
33
|
+
fallbackCopyToClipboard(text, onSuccess);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
navigator.clipboard.writeText(text)
|
|
37
|
+
.then(onSuccess)
|
|
38
|
+
.catch(() => fallbackCopyToClipboard(text, onSuccess));
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=copy_to_clipboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy_to_clipboard.js","sourceRoot":"","sources":["../../../src/utils/copy_to_clipboard.ts"],"names":[],"mappings":"AAEA,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAE,SAA2B,EAAE,EAAE;IAC5E,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAE3D,eAAe,CAAC,KAAK,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAE3C,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE;QAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAErC,eAAe,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACxD,eAAe,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEjD,KAAK,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAE1C,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QAExC,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,eAAe,EAAE,CAAC;YAC5B,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,eAAe,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;KACnD;SAAM;QACL,eAAe,CAAC,MAAM,EAAE,CAAC;KAC1B;IAED,IAAI;QACF,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE7B,IAAI,SAAS,EAAE;YACb,SAAS,EAAE,CAAC;SACb;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;KAC9C;IAED,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,SAA2B,EAAE,EAAE;IAC3E,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;QACxB,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAEzC,OAAO;KACR;IAED,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;SAChC,IAAI,CAAC,SAAS,CAAC;SACf,KAAK,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { useMediaQuery } from './use_media_query';
|
|
2
2
|
export { useMergedRef } from './use_merged_ref';
|
|
3
3
|
export { useClipboard } from './use_clipboard';
|
|
4
|
-
export type { UseClipboardOptions } from './use_clipboard';
|
|
5
4
|
export { useControllableState } from './use_controllable';
|
|
6
5
|
export type { UseControllableStateProps } from './use_controllable';
|
|
7
6
|
export { useId } from './use_id';
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
export declare type UseClipboardOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* timeout delay (in ms) to switch back to initial state once copied.
|
|
4
|
-
*/
|
|
5
|
-
timeout?: number;
|
|
6
|
-
/**
|
|
7
|
-
* Set the desired MIME type
|
|
8
|
-
*/
|
|
9
|
-
format?: string;
|
|
10
|
-
};
|
|
11
1
|
/**
|
|
12
|
-
* React hook to copy content to clipboard
|
|
13
|
-
*
|
|
14
|
-
* @param text the text or value to copy
|
|
15
|
-
* @param {Number} [optionsOrTimeout=1500] optionsOrTimeout -
|
|
16
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
17
|
-
* @param {Object} optionsOrTimeout
|
|
18
|
-
* @param {string} optionsOrTimeout.format - set the desired MIME type
|
|
19
|
-
* @param {number} optionsOrTimeout.timeout -
|
|
20
|
-
* delay (in ms) to switch back to initial state once copied.
|
|
2
|
+
* React hook to copy content to clipboard.
|
|
21
3
|
*/
|
|
22
|
-
export declare function useClipboard(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
hasCopied: boolean;
|
|
4
|
+
export declare function useClipboard(): {
|
|
5
|
+
copy: (text: string) => Promise<void>;
|
|
6
|
+
isCopied: boolean;
|
|
26
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { copyToClipboard } from './copy_to_clipboard';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peculiar/react-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"author": "PeculiarVentures Team",
|
|
6
6
|
"description": "A simple and customizable component library to build faster, beautiful, and more accessible React applications.",
|
|
7
7
|
"keywords": [
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"@popperjs/core": "^2.11.7",
|
|
53
53
|
"@types/flat": "^5.0.2",
|
|
54
54
|
"@types/react-transition-group": "^4.4.5",
|
|
55
|
-
"copy-to-clipboard": "^3.3.1",
|
|
56
55
|
"deepmerge": "^4.3.1",
|
|
57
56
|
"flat": "^5.0.2",
|
|
58
57
|
"focus-trap": "^7.5.4",
|
|
@@ -82,5 +81,5 @@
|
|
|
82
81
|
"node": ">=12.x"
|
|
83
82
|
},
|
|
84
83
|
"license": "MIT",
|
|
85
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f7f1364df8aa2eb7bbb18798c10781a1fcaededb"
|
|
86
85
|
}
|