This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

42
node_modules/copy-text-to-clipboard/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,42 @@
/// <reference lib="dom"/>
export interface Options {
/**
Specify a DOM element where the temporary, behind-the-scenes `textarea` should be appended, in cases where you need to stay within a focus trap, like in a modal.
@default document.body
@example
```
import copy from 'copy-text-to-clipboard';
const modalWithFocusTrap = document.getElementById('modal');
button.addEventListener('click', () => {
copy('🦄🌈', {
target: modalWithFocusTrap
});
});
```
*/
readonly target?: HTMLElement;
}
/**
Copy text to the clipboard.
Must be called in response to a user gesture event, like `click` or `keyup`.
@param text - The text to copy to clipboard.
@returns Whether it succeeded to copy the text.
@example
```
import copy from 'copy-text-to-clipboard';
button.addEventListener('click', () => {
copy('🦄🌈');
});
```
*/
export default function copyTextToClipboard(text: string, options?: Options): boolean;

47
node_modules/copy-text-to-clipboard/index.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
export default function copyTextToClipboard(text, {target = document.body} = {}) {
if (typeof text !== 'string') {
throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof text}\`.`);
}
const element = document.createElement('textarea');
const previouslyFocusedElement = document.activeElement;
element.value = text;
// Prevent keyboard from showing on mobile
element.setAttribute('readonly', '');
element.style.contain = 'strict';
element.style.position = 'absolute';
element.style.left = '-9999px';
element.style.fontSize = '12pt'; // Prevent zooming on iOS
const selection = document.getSelection();
const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);
target.append(element);
element.select();
// Explicit selection workaround for iOS
element.selectionStart = 0;
element.selectionEnd = text.length;
let isSuccess = false;
try {
isSuccess = document.execCommand('copy');
} catch {}
element.remove();
if (originalRange) {
selection.removeAllRanges();
selection.addRange(originalRange);
}
// Get the focus back on the previously focused element, if any
if (previouslyFocusedElement) {
previouslyFocusedElement.focus();
}
return isSuccess;
}

9
node_modules/copy-text-to-clipboard/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

46
node_modules/copy-text-to-clipboard/package.json generated vendored Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "copy-text-to-clipboard",
"version": "3.2.0",
"description": "Copy text to the clipboard in modern browsers (0.2 kB)",
"license": "MIT",
"repository": "sindresorhus/copy-text-to-clipboard",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": ">=12"
},
"scripts": {
"//test": "xo && tsd",
"test": "xo"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"copy",
"text",
"clipboard",
"browser",
"clipboard.js",
"modern"
],
"devDependencies": {
"tsd": "^0.14.0",
"xo": "^0.37.1"
},
"xo": {
"envs": [
"browser"
]
}
}

51
node_modules/copy-text-to-clipboard/readme.md generated vendored Normal file
View File

@@ -0,0 +1,51 @@
# copy-text-to-clipboard
> Copy text to the clipboard in modern browsers *(0.2 kB)*
[Try it out!](https://jsfiddle.net/sindresorhus/6406v3pf/)
## Comparison
- This module: **0.2 kB**
- [`clipboard.js`](https://github.com/zenorocha/clipboard.js): 3.4 kB
## Install
```sh
npm install copy-text-to-clipboard
```
## Usage
```js
import copy from 'copy-text-to-clipboard';
button.addEventListener('click', () => {
copy('🦄🌈');
});
```
## API
### copy(text, options?)
Copy `text` to the clipboard.
Returns a `boolean` of whether it succeeded to copy the text.
Must be called in response to a user gesture event, like `click` or `keyup`.
#### options
Type: `object`
##### target
Type: `HTMLElement`\
Default: `document.body`
Specify a DOM element where the temporary, behind-the-scenes `textarea` should be appended, in cases where you need to stay within a focus trap, like in a modal.
## Related
- [clipboardy](https://github.com/sindresorhus/clipboardy) - Access the system clipboard (copy/paste) in Node.js