@streamscloud/kit 0.93.2 → 0.93.3
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.
|
@@ -13,8 +13,15 @@ const trimOnCommit = $derived(trim && !disabled && !readonly && !inert);
|
|
|
13
13
|
/** Imperative API exposed via `bind:this` on `<Textarea>`. */
|
|
14
14
|
export const focus = () => textareaEl?.focus();
|
|
15
15
|
export const select = () => textareaEl?.select();
|
|
16
|
+
let measuredValue = null;
|
|
17
|
+
let heightCapped = false;
|
|
16
18
|
const resize = () => {
|
|
17
|
-
if (!textareaEl || !autoresize) {
|
|
19
|
+
if (!textareaEl || !autoresize || textareaEl.value === measuredValue) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
measuredValue = textareaEl.value;
|
|
23
|
+
// Without this skip, every keystroke in a 100k-character note re-lays out the whole text through `height: auto` (~20 ms).
|
|
24
|
+
if (heightCapped && textareaEl.scrollHeight > textareaEl.clientHeight) {
|
|
18
25
|
return;
|
|
19
26
|
}
|
|
20
27
|
textareaEl.style.overflowY = 'hidden';
|
|
@@ -23,6 +30,7 @@ const resize = () => {
|
|
|
23
30
|
const lineHeight = parseFloat(styles.lineHeight) || parseFloat(styles.fontSize) * 1.4;
|
|
24
31
|
const paddingY = parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom);
|
|
25
32
|
const max = lineHeight * maxRows + paddingY;
|
|
33
|
+
heightCapped = textareaEl.scrollHeight > max;
|
|
26
34
|
textareaEl.style.height = Math.min(textareaEl.scrollHeight, max) + 'px';
|
|
27
35
|
textareaEl.style.overflowY = '';
|
|
28
36
|
};
|
|
@@ -34,6 +42,12 @@ const initTextarea = (node) => {
|
|
|
34
42
|
on?.mounted?.({ textarea: node });
|
|
35
43
|
resize();
|
|
36
44
|
};
|
|
45
|
+
$effect(() => {
|
|
46
|
+
void [size, effectiveRows, maxRows, autoresize];
|
|
47
|
+
measuredValue = null;
|
|
48
|
+
heightCapped = false;
|
|
49
|
+
resize();
|
|
50
|
+
});
|
|
37
51
|
$effect(() => {
|
|
38
52
|
void valueParsed;
|
|
39
53
|
resize();
|
|
@@ -83,8 +97,9 @@ const handleKeydown = (e) => {
|
|
|
83
97
|
const handleBlur = () => {
|
|
84
98
|
// Before the re-sync: trimming after it re-emits a lagging prop as fresh input, losing the last edit.
|
|
85
99
|
commitTrim();
|
|
86
|
-
if (textareaEl) {
|
|
100
|
+
if (textareaEl && textareaEl.value !== valueParsed) {
|
|
87
101
|
textareaEl.value = valueParsed;
|
|
102
|
+
resize();
|
|
88
103
|
}
|
|
89
104
|
on?.blur?.();
|
|
90
105
|
};
|