@frsource/autoresize-textarea 1.0.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/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +2 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +2 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 FRSOURCE - Let's shape your web
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://www.npmjs.com/package/@frsource/autoresize-textarea">
|
|
3
|
+
<img src="https://img.shields.io/npm/v/@frsource/autoresize-textarea" alt="NPM version badge">
|
|
4
|
+
</a>
|
|
5
|
+
<a href="https://bundlephobia.com/result?p=@frsource/autoresize-textarea" title="Visit bundlephobia for more details!">
|
|
6
|
+
<img src="https://img.shields.io/bundlephobia/minzip/@frsource/autoresize-textarea" alt="Core bundle size badge. Data from bundlephobia.com">
|
|
7
|
+
</a>
|
|
8
|
+
<a href="https://github.com/semantic-release/semantic-release">
|
|
9
|
+
<img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-relase badge">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://bundlephobia.com/result?p=@frsource/autoresize-textarea">
|
|
12
|
+
<img src="https://badgen.net/bundlephobia/tree-shaking/@frsource/autoresize-textarea" alt="Tree shaking supported">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://github.com/FRSOURCE/autoresize-textarea/blob/master/LICENSE">
|
|
15
|
+
<img src="https://img.shields.io/github/license/FRSOURCE/autoresize-textarea" alt="license MIT badge">
|
|
16
|
+
</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<h1 align="center">Autoresize Textarea - minimalistic plugin to autosize your textareas! 💪</h1>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="#quick-start">Getting Started</a>
|
|
23
|
+
·
|
|
24
|
+
<a href="https://www.frsource.org/autoresize-textarea" target="_blank">Demo</a>
|
|
25
|
+
.
|
|
26
|
+
<a href="#contribution">Contribution</a>
|
|
27
|
+
·
|
|
28
|
+
<a href="https://github.com/FRSOURCE/autoresize-textarea/issues">File an Issue</a>
|
|
29
|
+
·
|
|
30
|
+
<a href="#questions">Have a question or an idea?</a>
|
|
31
|
+
<br>
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<br>
|
|
36
|
+
<i>Tiny library which make your textareas fluid.
|
|
37
|
+
<br>Mobile & desktop-friendly
|
|
38
|
+
<br>Performant & small bundle size.
|
|
39
|
+
<br>Published as separate bundles for JS ES5 or modern browsers thanks to <a href="https://www.npmjs.com/package/microbundle">microbundle</a>.
|
|
40
|
+
<br>Written completely in <a href="https://www.typescriptlang.org">typescript</a>.</i>
|
|
41
|
+
<br>Published under [MIT](https://opensource.org/licenses/MIT) license.</i>
|
|
42
|
+
<br>
|
|
43
|
+
<br>
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
### ES/Typescript
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { attach } from "@frsource/autoresize-textarea";
|
|
52
|
+
const textarea = document.querySelector("textarea");
|
|
53
|
+
attach(textarea);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### UMD
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
const textarea = document.querySelector("textarea");
|
|
60
|
+
window.autoresizeTextarea.attach(textarea);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
For working example, check out [our demo](https://www.frsource.org/autoresize-textarea).
|
|
64
|
+
|
|
65
|
+
## Questions
|
|
66
|
+
|
|
67
|
+
Don’t hesitate to ask a question directly on the [discussions board](https://github.com/FRSOURCE/autoresize-textarea/discussions)!
|
|
68
|
+
|
|
69
|
+
## Changelog
|
|
70
|
+
|
|
71
|
+
Changes for every release are documented in the [release notes](https://github.com/FRSOURCE/autoresize-textarea/releases) and [CHANGELOG file](https://github.com/FRSOURCE/autoresize-textarea/tree/master/CHANGELOG.md).
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
[MIT](https://opensource.org/licenses/MIT)
|
|
76
|
+
|
|
77
|
+
Copyright (c) 2022-present, Jakub FRS Freisler, FRSOURCE
|
package/dist/index.d.ts
ADDED
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var t=function(t){if(!t.getAttribute("data-frs-autoresize-textarea")){t.setAttribute("data-frs-autoresize-textarea","true");var e="",i=function(){(t.scrollHeight>t.clientHeight||e===t.style.height)&&(t.style.height="auto",t.style.height=e=t.scrollHeight+(t.offsetHeight-t.clientHeight)+"px")};return t.style.overflow="hidden",t.style.boxSizing="border-box",i(),t.addEventListener("input",i),{detach:function(){t.removeEventListener("input",i)}}}};export{t as attach};
|
|
2
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":["const ATTRIBUTE_NAME = \"data-frs-autoresize-textarea\";\n\nexport const attach = (element: HTMLTextAreaElement) => {\n if (element.getAttribute(ATTRIBUTE_NAME)) return;\n element.setAttribute(ATTRIBUTE_NAME, \"true\");\n\n let prevHeight = \"\";\n const inputHandler = () => {\n if (\n element.scrollHeight > element.clientHeight ||\n prevHeight === element.style.height\n ) {\n element.style.height = \"auto\";\n element.style.height = prevHeight =\n element.scrollHeight +\n (element.offsetHeight - element.clientHeight) +\n \"px\";\n }\n };\n\n element.style.overflow = \"hidden\";\n element.style.boxSizing = \"border-box\";\n\n inputHandler();\n\n element.addEventListener(\"input\", inputHandler);\n\n return {\n detach() {\n element.removeEventListener(\"input\", inputHandler);\n },\n };\n};\n"],"names":["attach","element","getAttribute","setAttribute","prevHeight","inputHandler","scrollHeight","clientHeight","style","height","offsetHeight","overflow","boxSizing","addEventListener","detach","removeEventListener"],"mappings":"AAAA,IAEaA,EAAS,SAACC,GACrB,IAAIA,EAAQC,aAHS,gCAGrB,CACAD,EAAQE,aAJa,+BAIgB,QAErC,IAAIC,EAAa,GACXC,EAAe,YAEjBJ,EAAQK,aAAeL,EAAQM,cAC/BH,IAAeH,EAAQO,MAAMC,UAE7BR,EAAQO,MAAMC,OAAS,OACvBR,EAAQO,MAAMC,OAASL,EACrBH,EAAQK,cACPL,EAAQS,aAAeT,EAAQM,cAChC,OAWN,OAPAN,EAAQO,MAAMG,SAAW,SACzBV,EAAQO,MAAMI,UAAY,aAE1BP,IAEAJ,EAAQY,iBAAiB,QAASR,GAE3B,CACLS,kBACEb,EAAQc,oBAAoB,QAASV"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
exports.attach=function(t){if(!t.getAttribute("data-frs-autoresize-textarea")){t.setAttribute("data-frs-autoresize-textarea","true");var e="",i=function(){(t.scrollHeight>t.clientHeight||e===t.style.height)&&(t.style.height="auto",t.style.height=e=t.scrollHeight+(t.offsetHeight-t.clientHeight)+"px")};return t.style.overflow="hidden",t.style.boxSizing="border-box",i(),t.addEventListener("input",i),{detach:function(){t.removeEventListener("input",i)}}}};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["const ATTRIBUTE_NAME = \"data-frs-autoresize-textarea\";\n\nexport const attach = (element: HTMLTextAreaElement) => {\n if (element.getAttribute(ATTRIBUTE_NAME)) return;\n element.setAttribute(ATTRIBUTE_NAME, \"true\");\n\n let prevHeight = \"\";\n const inputHandler = () => {\n if (\n element.scrollHeight > element.clientHeight ||\n prevHeight === element.style.height\n ) {\n element.style.height = \"auto\";\n element.style.height = prevHeight =\n element.scrollHeight +\n (element.offsetHeight - element.clientHeight) +\n \"px\";\n }\n };\n\n element.style.overflow = \"hidden\";\n element.style.boxSizing = \"border-box\";\n\n inputHandler();\n\n element.addEventListener(\"input\", inputHandler);\n\n return {\n detach() {\n element.removeEventListener(\"input\", inputHandler);\n },\n };\n};\n"],"names":["element","getAttribute","setAttribute","prevHeight","inputHandler","scrollHeight","clientHeight","style","height","offsetHeight","overflow","boxSizing","addEventListener","detach","removeEventListener"],"mappings":"eAEsB,SAACA,GACrB,IAAIA,EAAQC,aAHS,gCAGrB,CACAD,EAAQE,aAJa,+BAIgB,QAErC,IAAIC,EAAa,GACXC,EAAe,YAEjBJ,EAAQK,aAAeL,EAAQM,cAC/BH,IAAeH,EAAQO,MAAMC,UAE7BR,EAAQO,MAAMC,OAAS,OACvBR,EAAQO,MAAMC,OAASL,EACrBH,EAAQK,cACPL,EAAQS,aAAeT,EAAQM,cAChC,OAWN,OAPAN,EAAQO,MAAMG,SAAW,SACzBV,EAAQO,MAAMI,UAAY,aAE1BP,IAEAJ,EAAQY,iBAAiB,QAASR,GAE3B,CACLS,kBACEb,EAAQc,oBAAoB,QAASV"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const t=t=>{if(t.getAttribute("data-frs-autoresize-textarea"))return;t.setAttribute("data-frs-autoresize-textarea","true");let e="";const i=()=>{(t.scrollHeight>t.clientHeight||e===t.style.height)&&(t.style.height="auto",t.style.height=e=t.scrollHeight+(t.offsetHeight-t.clientHeight)+"px")};return t.style.overflow="hidden",t.style.boxSizing="border-box",i(),t.addEventListener("input",i),{detach(){t.removeEventListener("input",i)}}};export{t as attach};
|
|
2
|
+
//# sourceMappingURL=index.modern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/index.ts"],"sourcesContent":["const ATTRIBUTE_NAME = \"data-frs-autoresize-textarea\";\n\nexport const attach = (element: HTMLTextAreaElement) => {\n if (element.getAttribute(ATTRIBUTE_NAME)) return;\n element.setAttribute(ATTRIBUTE_NAME, \"true\");\n\n let prevHeight = \"\";\n const inputHandler = () => {\n if (\n element.scrollHeight > element.clientHeight ||\n prevHeight === element.style.height\n ) {\n element.style.height = \"auto\";\n element.style.height = prevHeight =\n element.scrollHeight +\n (element.offsetHeight - element.clientHeight) +\n \"px\";\n }\n };\n\n element.style.overflow = \"hidden\";\n element.style.boxSizing = \"border-box\";\n\n inputHandler();\n\n element.addEventListener(\"input\", inputHandler);\n\n return {\n detach() {\n element.removeEventListener(\"input\", inputHandler);\n },\n };\n};\n"],"names":["attach","element","getAttribute","setAttribute","prevHeight","inputHandler","scrollHeight","clientHeight","style","height","offsetHeight","overflow","boxSizing","addEventListener","detach","removeEventListener"],"mappings":"AAAA,MAEaA,EAAUC,IACrB,GAAIA,EAAQC,aAHS,gCAGqB,OAC1CD,EAAQE,aAJa,+BAIgB,QAErC,IAAIC,EAAa,GACjB,MAAMC,EAAe,MAEjBJ,EAAQK,aAAeL,EAAQM,cAC/BH,IAAeH,EAAQO,MAAMC,UAE7BR,EAAQO,MAAMC,OAAS,OACvBR,EAAQO,MAAMC,OAASL,EACrBH,EAAQK,cACPL,EAAQS,aAAeT,EAAQM,cAChC,OAWN,OAPAN,EAAQO,MAAMG,SAAW,SACzBV,EAAQO,MAAMI,UAAY,aAE1BP,IAEAJ,EAAQY,iBAAiB,QAASR,GAE3B,CACLS,SACEb,EAAQc,oBAAoB,QAASV"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).autoresizeTextarea={})}(this,function(e){var t="data-frs-autoresize-textarea";e.attach=function(e){if(!e.getAttribute(t)){e.setAttribute(t,"true");var i="",n=function(){(e.scrollHeight>e.clientHeight||i===e.style.height)&&(e.style.height="auto",e.style.height=i=e.scrollHeight+(e.offsetHeight-e.clientHeight)+"px")};return e.style.overflow="hidden",e.style.boxSizing="border-box",n(),e.addEventListener("input",n),{detach:function(){e.removeEventListener("input",n)}}}}});
|
|
2
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["const ATTRIBUTE_NAME = \"data-frs-autoresize-textarea\";\n\nexport const attach = (element: HTMLTextAreaElement) => {\n if (element.getAttribute(ATTRIBUTE_NAME)) return;\n element.setAttribute(ATTRIBUTE_NAME, \"true\");\n\n let prevHeight = \"\";\n const inputHandler = () => {\n if (\n element.scrollHeight > element.clientHeight ||\n prevHeight === element.style.height\n ) {\n element.style.height = \"auto\";\n element.style.height = prevHeight =\n element.scrollHeight +\n (element.offsetHeight - element.clientHeight) +\n \"px\";\n }\n };\n\n element.style.overflow = \"hidden\";\n element.style.boxSizing = \"border-box\";\n\n inputHandler();\n\n element.addEventListener(\"input\", inputHandler);\n\n return {\n detach() {\n element.removeEventListener(\"input\", inputHandler);\n },\n };\n};\n"],"names":["ATTRIBUTE_NAME","element","getAttribute","setAttribute","prevHeight","inputHandler","scrollHeight","clientHeight","style","height","offsetHeight","overflow","boxSizing","addEventListener","detach","removeEventListener"],"mappings":"4OAAA,IAAMA,EAAiB,wCAED,SAACC,GACrB,IAAIA,EAAQC,aAAaF,GAAzB,CACAC,EAAQE,aAAaH,EAAgB,QAErC,IAAII,EAAa,GACXC,EAAe,YAEjBJ,EAAQK,aAAeL,EAAQM,cAC/BH,IAAeH,EAAQO,MAAMC,UAE7BR,EAAQO,MAAMC,OAAS,OACvBR,EAAQO,MAAMC,OAASL,EACrBH,EAAQK,cACPL,EAAQS,aAAeT,EAAQM,cAChC,OAWN,OAPAN,EAAQO,MAAMG,SAAW,SACzBV,EAAQO,MAAMI,UAAY,aAE1BP,IAEAJ,EAAQY,iBAAiB,QAASR,GAE3B,CACLS,kBACEb,EAAQc,oBAAoB,QAASV"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@frsource/autoresize-textarea",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Minimalistic plugin to autosize your textareas! 💪",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"source": "src/index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"require": "./dist/index.cjs",
|
|
9
|
+
"default": "./dist/index.modern.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.es.js",
|
|
13
|
+
"unpkg": "./dist/index.umd.js",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "yarn clean && microbundle watch",
|
|
16
|
+
"build": "yarn clean && microbundle --compress",
|
|
17
|
+
"lint": "eslint '**/*.ts' --ignore-pattern '**/*.d.ts'",
|
|
18
|
+
"lint:fix": "yarn lint --fix",
|
|
19
|
+
"lint:ci": "yarn lint --max-warnings 0",
|
|
20
|
+
"prettify": "prettier --write src",
|
|
21
|
+
"prettify:ci": "prettier --check src",
|
|
22
|
+
"release": "semantic-release",
|
|
23
|
+
"release:ci": "yarn release --yes",
|
|
24
|
+
"release:test": "yarn release --no-git-tag-version --no-push --skip-npm",
|
|
25
|
+
"clean": "rimraf dist/**/*"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/FRSOURCE/autoresize-textarea/",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/FRSOURCE/autoresize-textarea.git"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"autosize textarea",
|
|
34
|
+
"resize textarea",
|
|
35
|
+
"lightweight",
|
|
36
|
+
"simple",
|
|
37
|
+
"autosize",
|
|
38
|
+
"fluid textarea"
|
|
39
|
+
],
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/FRSOURCE/autoresize-textarea/issues"
|
|
42
|
+
},
|
|
43
|
+
"author": "Jakub Freisler <jakub@frsource.org>",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
47
|
+
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
48
|
+
"@semantic-release/git": "^10.0.1",
|
|
49
|
+
"@semantic-release/npm": "^9.0.0",
|
|
50
|
+
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
|
52
|
+
"@typescript-eslint/parser": "^5.12.1",
|
|
53
|
+
"eslint": "^8.9.0",
|
|
54
|
+
"eslint-config-prettier": "^8.4.0",
|
|
55
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
56
|
+
"microbundle": "^0.14.2",
|
|
57
|
+
"prettier": "^2.5.1",
|
|
58
|
+
"semantic-release": "^19.0.2",
|
|
59
|
+
"typescript": "^4.5.5"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist",
|
|
66
|
+
"package.json",
|
|
67
|
+
"README.md",
|
|
68
|
+
"LICENSE"
|
|
69
|
+
]
|
|
70
|
+
}
|