@zag-js/auto-resize 1.2.1 → 1.3.1
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/index.js +17 -3
- package/dist/index.mjs +17 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -48,12 +48,25 @@ var autoresizeTextarea = (el) => {
|
|
|
48
48
|
const resize = () => {
|
|
49
49
|
requestAnimationFrame(() => {
|
|
50
50
|
el.style.height = "auto";
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
let newHeight;
|
|
52
|
+
if (style.boxSizing === "content-box") {
|
|
53
|
+
newHeight = el.scrollHeight - (parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
|
|
54
|
+
} else {
|
|
55
|
+
newHeight = el.scrollHeight + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
56
|
+
}
|
|
57
|
+
if (style.maxHeight !== "none" && newHeight > parseFloat(style.maxHeight)) {
|
|
58
|
+
if (style.overflowY === "hidden") {
|
|
59
|
+
el.style.overflowY = "scroll";
|
|
60
|
+
}
|
|
61
|
+
newHeight = parseFloat(style.maxHeight);
|
|
62
|
+
} else if (style.overflowY !== "hidden") {
|
|
63
|
+
el.style.overflowY = "hidden";
|
|
64
|
+
}
|
|
65
|
+
el.style.height = `${newHeight}px`;
|
|
54
66
|
});
|
|
55
67
|
};
|
|
56
68
|
el.addEventListener("input", resize);
|
|
69
|
+
el.form?.addEventListener("reset", resize);
|
|
57
70
|
const elementPrototype = Object.getPrototypeOf(el);
|
|
58
71
|
const descriptor = Object.getOwnPropertyDescriptor(elementPrototype, "value");
|
|
59
72
|
Object.defineProperty(el, "value", {
|
|
@@ -72,6 +85,7 @@ var autoresizeTextarea = (el) => {
|
|
|
72
85
|
doc.fonts?.addEventListener("loadingdone", resize);
|
|
73
86
|
return () => {
|
|
74
87
|
el.removeEventListener("input", resize);
|
|
88
|
+
el.form?.removeEventListener("reset", resize);
|
|
75
89
|
doc.fonts?.removeEventListener("loadingdone", resize);
|
|
76
90
|
resizeObserver.disconnect();
|
|
77
91
|
attrObserver.disconnect();
|
package/dist/index.mjs
CHANGED
|
@@ -46,12 +46,25 @@ var autoresizeTextarea = (el) => {
|
|
|
46
46
|
const resize = () => {
|
|
47
47
|
requestAnimationFrame(() => {
|
|
48
48
|
el.style.height = "auto";
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
let newHeight;
|
|
50
|
+
if (style.boxSizing === "content-box") {
|
|
51
|
+
newHeight = el.scrollHeight - (parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
|
|
52
|
+
} else {
|
|
53
|
+
newHeight = el.scrollHeight + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
54
|
+
}
|
|
55
|
+
if (style.maxHeight !== "none" && newHeight > parseFloat(style.maxHeight)) {
|
|
56
|
+
if (style.overflowY === "hidden") {
|
|
57
|
+
el.style.overflowY = "scroll";
|
|
58
|
+
}
|
|
59
|
+
newHeight = parseFloat(style.maxHeight);
|
|
60
|
+
} else if (style.overflowY !== "hidden") {
|
|
61
|
+
el.style.overflowY = "hidden";
|
|
62
|
+
}
|
|
63
|
+
el.style.height = `${newHeight}px`;
|
|
52
64
|
});
|
|
53
65
|
};
|
|
54
66
|
el.addEventListener("input", resize);
|
|
67
|
+
el.form?.addEventListener("reset", resize);
|
|
55
68
|
const elementPrototype = Object.getPrototypeOf(el);
|
|
56
69
|
const descriptor = Object.getOwnPropertyDescriptor(elementPrototype, "value");
|
|
57
70
|
Object.defineProperty(el, "value", {
|
|
@@ -70,6 +83,7 @@ var autoresizeTextarea = (el) => {
|
|
|
70
83
|
doc.fonts?.addEventListener("loadingdone", resize);
|
|
71
84
|
return () => {
|
|
72
85
|
el.removeEventListener("input", resize);
|
|
86
|
+
el.form?.removeEventListener("reset", resize);
|
|
73
87
|
doc.fonts?.removeEventListener("loadingdone", resize);
|
|
74
88
|
resizeObserver.disconnect();
|
|
75
89
|
attrObserver.disconnect();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/auto-resize",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Autoresize utilities for the web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@zag-js/dom-query": "1.
|
|
25
|
+
"@zag-js/dom-query": "1.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"clean-package": "2.2.0"
|