@vizejs/composable 0.457.0 → 0.463.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.
@@ -44,9 +44,9 @@ interface TextareaAutosizeControls {
44
44
  * Grow a textarea to fit its content.
45
45
  *
46
46
  * On each input change (and when the element width changes), the style
47
- * property is reset to `auto`, `scrollHeight` is read, and the height is
48
- * written back in pixels. Nothing is measured during server rendering, so the
49
- * markup keeps its declared `rows`.
47
+ * property is reset to `auto`, and `scrollHeight` is adjusted for the element's
48
+ * padding, borders and box sizing before writing the CSS height in pixels.
49
+ * Nothing is measured during server rendering; markup keeps its declared `rows`.
50
50
  *
51
51
  * @param target Reactive textarea target.
52
52
  * @param options Bound input, style property, callback, and observer capability.
@@ -7,9 +7,9 @@ import { ref, watch } from "vue";
7
7
  * Grow a textarea to fit its content.
8
8
  *
9
9
  * On each input change (and when the element width changes), the style
10
- * property is reset to `auto`, `scrollHeight` is read, and the height is
11
- * written back in pixels. Nothing is measured during server rendering, so the
12
- * markup keeps its declared `rows`.
10
+ * property is reset to `auto`, and `scrollHeight` is adjusted for the element's
11
+ * padding, borders and box sizing before writing the CSS height in pixels.
12
+ * Nothing is measured during server rendering; markup keeps its declared `rows`.
13
13
  *
14
14
  * @param target Reactive textarea target.
15
15
  * @param options Bound input, style property, callback, and observer capability.
@@ -24,7 +24,9 @@ function useTextareaAutosize(target, options = {}) {
24
24
  const element = resolveElement(target);
25
25
  if (!element || !isAutosizeElement(element)) return;
26
26
  element.style.setProperty(styleProp, "auto");
27
- const height = element.scrollHeight;
27
+ const style = element.ownerDocument?.defaultView?.getComputedStyle(element);
28
+ const offset = style?.boxSizing === "border-box" ? cssPixels(style.borderTopWidth) + cssPixels(style.borderBottomWidth) : -cssPixels(style?.paddingTop) - cssPixels(style?.paddingBottom);
29
+ const height = Math.max(0, element.scrollHeight + offset);
28
30
  element.style.setProperty(styleProp, `${height}px`);
29
31
  options.onResize?.(height);
30
32
  };
@@ -50,5 +52,8 @@ function useTextareaAutosize(target, options = {}) {
50
52
  function isAutosizeElement(element) {
51
53
  return "style" in element && typeof element.scrollHeight === "number";
52
54
  }
55
+ function cssPixels(value) {
56
+ return Number.parseFloat(value ?? "0") || 0;
57
+ }
53
58
  //#endregion
54
59
  export { useTextareaAutosize };
@@ -1,6 +1,6 @@
1
1
  import { ResizeObserverHost } from "./resize-observer.mjs";
2
2
  import { ElementRefSetter } from "./element-ref.mjs";
3
- import { ComputedRef, MaybeRefOrGetter } from "vue";
3
+ import { CSSProperties, ComputedRef, MaybeRefOrGetter } from "vue";
4
4
 
5
5
  //#region src/virtual-list.d.ts
6
6
  /** Item size: a fixed size in CSS pixels or a per-item function. */
@@ -49,14 +49,14 @@ interface VirtualListItem<Item> {
49
49
  readonly size: number;
50
50
  }
51
51
  /** Inline style for the scroll container. */
52
- interface VirtualContainerStyle {
52
+ interface VirtualContainerStyle extends CSSProperties {
53
53
  /** Vertical overflow. */
54
54
  readonly overflowY: "auto" | "hidden";
55
55
  /** Horizontal overflow. */
56
56
  readonly overflowX: "auto" | "hidden";
57
57
  }
58
58
  /** Inline style for the inner wrapper that holds the rendered items. */
59
- interface VirtualWrapperStyle {
59
+ interface VirtualWrapperStyle extends CSSProperties {
60
60
  /** Wrapper width. */
61
61
  readonly width: string;
62
62
  /** Wrapper height. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/composable",
3
- "version": "0.457.0",
3
+ "version": "0.463.0",
4
4
  "description": "Lifecycle-safe composable foundations for Vize applications",
5
5
  "keywords": [
6
6
  "composables",
@@ -977,7 +977,7 @@
977
977
  },
978
978
  "devDependencies": {
979
979
  "@types/node": "25.9.2",
980
- "@vizejs/native": "0.457.0",
980
+ "@vizejs/native": "0.463.0",
981
981
  "happy-dom": "20.11.2",
982
982
  "typescript": "6.0.3",
983
983
  "vite-plus": "0.1.24",
@@ -61,9 +61,9 @@ export interface TextareaAutosizeControls {
61
61
  * Grow a textarea to fit its content.
62
62
  *
63
63
  * On each input change (and when the element width changes), the style
64
- * property is reset to `auto`, `scrollHeight` is read, and the height is
65
- * written back in pixels. Nothing is measured during server rendering, so the
66
- * markup keeps its declared `rows`.
64
+ * property is reset to `auto`, and `scrollHeight` is adjusted for the element's
65
+ * padding, borders and box sizing before writing the CSS height in pixels.
66
+ * Nothing is measured during server rendering; markup keeps its declared `rows`.
67
67
  *
68
68
  * @param target Reactive textarea target.
69
69
  * @param options Bound input, style property, callback, and observer capability.
@@ -82,7 +82,12 @@ export function useTextareaAutosize(
82
82
  const element = resolveElement(target);
83
83
  if (!element || !isAutosizeElement(element)) return;
84
84
  element.style.setProperty(styleProp, "auto");
85
- const height = element.scrollHeight;
85
+ const style = element.ownerDocument?.defaultView?.getComputedStyle(element);
86
+ const offset =
87
+ style?.boxSizing === "border-box"
88
+ ? cssPixels(style.borderTopWidth) + cssPixels(style.borderBottomWidth)
89
+ : -cssPixels(style?.paddingTop) - cssPixels(style?.paddingBottom);
90
+ const height = Math.max(0, element.scrollHeight + offset);
86
91
  element.style.setProperty(styleProp, `${height}px`);
87
92
  options.onResize?.(height);
88
93
  };
@@ -112,3 +117,7 @@ export function useTextareaAutosize(
112
117
  function isAutosizeElement(element: Element): element is AutosizeElement {
113
118
  return "style" in element && typeof element.scrollHeight === "number";
114
119
  }
120
+
121
+ function cssPixels(value: string | undefined): number {
122
+ return Number.parseFloat(value ?? "0") || 0;
123
+ }
@@ -1,5 +1,5 @@
1
1
  import { computed, shallowRef, toValue } from "vue";
2
- import type { ComputedRef, MaybeRefOrGetter } from "vue";
2
+ import type { ComputedRef, CSSProperties, MaybeRefOrGetter } from "vue";
3
3
 
4
4
  import { useElementRef } from "./element-ref.ts";
5
5
  import type { ElementRefSetter } from "./element-ref.ts";
@@ -60,7 +60,7 @@ export interface VirtualListItem<Item> {
60
60
  }
61
61
 
62
62
  /** Inline style for the scroll container. */
63
- export interface VirtualContainerStyle {
63
+ export interface VirtualContainerStyle extends CSSProperties {
64
64
  /** Vertical overflow. */
65
65
  readonly overflowY: "auto" | "hidden";
66
66
  /** Horizontal overflow. */
@@ -68,7 +68,7 @@ export interface VirtualContainerStyle {
68
68
  }
69
69
 
70
70
  /** Inline style for the inner wrapper that holds the rendered items. */
71
- export interface VirtualWrapperStyle {
71
+ export interface VirtualWrapperStyle extends CSSProperties {
72
72
  /** Wrapper width. */
73
73
  readonly width: string;
74
74
  /** Wrapper height. */
@@ -3,7 +3,7 @@
3
3
  "registryKind": "vize-lib",
4
4
  "package": {
5
5
  "name": "@vizejs/composable",
6
- "version": "0.457.0"
6
+ "version": "0.463.0"
7
7
  },
8
8
  "kind": "composable",
9
9
  "filesDirectory": "files",
@@ -2179,8 +2179,8 @@
2179
2179
  {
2180
2180
  "path": "textarea-autosize.ts",
2181
2181
  "role": "entry",
2182
- "sha256": "4f7c142eacab4a82e492bba55652a8d6e02132245c6fa4410fb3c180bda52776",
2183
- "size": 3576
2182
+ "sha256": "83c46e693c6ffb6ba0ff427f9bed73842289886f105cad037da5a00684be1e8b",
2183
+ "size": 4047
2184
2184
  }
2185
2185
  ],
2186
2186
  "registryDependencies": [
@@ -2195,7 +2195,7 @@
2195
2195
  "kind": "peer"
2196
2196
  }
2197
2197
  ],
2198
- "contentHash": "3916d3669ccd4feaa5839a237d194eb4f9ddb128527137f92bf596302f00b7f7",
2198
+ "contentHash": "b98040d2d64f4c695225dc282b4203c6fc1853e4e428f6688d61e6a0a79b19d1",
2199
2199
  "examples": []
2200
2200
  },
2201
2201
  {
@@ -5521,8 +5521,8 @@
5521
5521
  {
5522
5522
  "path": "virtual-list.ts",
5523
5523
  "role": "entry",
5524
- "sha256": "e3ba302ebd836881b81aeb0cc12df31812b97c855ca064ee6e7882ae77810232",
5525
- "size": 8025
5524
+ "sha256": "e7b9f8c0059b85ecb71ac909bce323876ed625df42bc2836e16ccd766c7be07f",
5525
+ "size": 8084
5526
5526
  }
5527
5527
  ],
5528
5528
  "registryDependencies": [
@@ -5538,7 +5538,7 @@
5538
5538
  "kind": "peer"
5539
5539
  }
5540
5540
  ],
5541
- "contentHash": "9faf1b67039f540505ca459988a60d902bf09845eb837dc0698b5dc05ee80f55",
5541
+ "contentHash": "44506accc8b59b4778c28d23f7aa12cb655b0c033f5d165ee2580ae44a4f1368",
5542
5542
  "examples": []
5543
5543
  },
5544
5544
  {