@zag-js/auto-resize 0.10.5 → 0.11.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.
@@ -0,0 +1,3 @@
1
+ declare function autoResizeInput(input: HTMLInputElement | null): (() => void) | undefined;
2
+
3
+ export { autoResizeInput };
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export declare function autoResizeInput(input: HTMLInputElement | null): (() => void) | undefined;
1
+ declare function autoResizeInput(input: HTMLInputElement | null): (() => void) | undefined;
2
+
3
+ export { autoResizeInput };
package/dist/index.js CHANGED
@@ -1,13 +1,33 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const domQuery = require('@zag-js/dom-query');
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
6
19
 
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ autoResizeInput: () => autoResizeInput
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+ var import_dom_query = require("@zag-js/dom-query");
7
27
  function copyVisualStyles(fromEl, toEl) {
8
28
  if (!fromEl)
9
29
  return;
10
- const win = domQuery.getWindow(fromEl);
30
+ const win = (0, import_dom_query.getWindow)(fromEl);
11
31
  const el = win.getComputedStyle(fromEl);
12
32
  const cssText = "box-sizing:" + el.boxSizing + ";border-left:" + el.borderLeftWidth + " solid red;border-right:" + el.borderRightWidth + " solid red;font-family:" + el.fontFamily + ";font-feature-settings:" + el.fontFeatureSettings + ";font-kerning:" + el.fontKerning + ";font-size:" + el.fontSize + ";font-stretch:" + el.fontStretch + ";font-style:" + el.fontStyle + ";font-variant:" + el.fontVariant + ";font-variant-caps:" + el.fontVariantCaps + ";font-variant-ligatures:" + el.fontVariantLigatures + ";font-variant-numeric:" + el.fontVariantNumeric + ";font-weight:" + el.fontWeight + ";letter-spacing:" + el.letterSpacing + ";margin-left:" + el.marginLeft + ";margin-right:" + el.marginRight + ";padding-left:" + el.paddingLeft + ";padding-right:" + el.paddingRight + ";text-indent:" + el.textIndent + ";text-transform:" + el.textTransform;
13
33
  toEl.style.cssText += cssText;
@@ -22,8 +42,8 @@ function createGhostElement(doc) {
22
42
  function autoResizeInput(input) {
23
43
  if (!input)
24
44
  return;
25
- const doc = domQuery.getDocument(input);
26
- const win = domQuery.getWindow(input);
45
+ const doc = (0, import_dom_query.getDocument)(input);
46
+ const win = (0, import_dom_query.getWindow)(input);
27
47
  const ghost = createGhostElement(doc);
28
48
  copyVisualStyles(input, ghost);
29
49
  function resize() {
@@ -42,5 +62,8 @@ function autoResizeInput(input) {
42
62
  input?.removeEventListener("change", resize);
43
63
  };
44
64
  }
45
-
46
- exports.autoResizeInput = autoResizeInput;
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ autoResizeInput
68
+ });
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { getDocument, getWindow } from \"@zag-js/dom-query\"\n\nfunction copyVisualStyles(fromEl: HTMLElement | null, toEl: HTMLElement) {\n if (!fromEl) return\n\n const win = getWindow(fromEl)\n const el = win.getComputedStyle(fromEl)\n\n // prettier-ignore\n const cssText = 'box-sizing:' + el.boxSizing +\n ';border-left:' + el.borderLeftWidth + ' solid red' +\n ';border-right:' + el.borderRightWidth + ' solid red' +\n ';font-family:' + el.fontFamily +\n ';font-feature-settings:' + el.fontFeatureSettings +\n ';font-kerning:' + el.fontKerning +\n ';font-size:' + el.fontSize +\n ';font-stretch:' + el.fontStretch +\n ';font-style:' + el.fontStyle +\n ';font-variant:' + el.fontVariant +\n ';font-variant-caps:' + el.fontVariantCaps +\n ';font-variant-ligatures:' + el.fontVariantLigatures +\n ';font-variant-numeric:' + el.fontVariantNumeric +\n ';font-weight:' + el.fontWeight +\n ';letter-spacing:' + el.letterSpacing +\n ';margin-left:' + el.marginLeft +\n ';margin-right:' + el.marginRight +\n ';padding-left:' + el.paddingLeft +\n ';padding-right:' + el.paddingRight +\n ';text-indent:' + el.textIndent +\n ';text-transform:' + el.textTransform\n\n toEl.style.cssText += cssText\n}\n\nfunction createGhostElement(doc: Document) {\n var el = doc.createElement(\"div\")\n el.id = \"ghost\"\n el.style.cssText =\n \"display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;\"\n doc.body.appendChild(el)\n return el\n}\n\nexport function autoResizeInput(input: HTMLInputElement | null) {\n if (!input) return\n const doc = getDocument(input)\n const win = getWindow(input)\n\n const ghost = createGhostElement(doc)\n\n copyVisualStyles(input, ghost)\n\n function resize() {\n win.requestAnimationFrame(() => {\n ghost.innerHTML = input!.value\n const rect = win.getComputedStyle(ghost)\n input?.style.setProperty(\"width\", rect.width)\n })\n }\n\n resize()\n\n input?.addEventListener(\"input\", resize)\n input?.addEventListener(\"change\", resize)\n\n return () => {\n doc.body.removeChild(ghost)\n input?.removeEventListener(\"input\", resize)\n input?.removeEventListener(\"change\", resize)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAuC;AAEvC,SAAS,iBAAiB,QAA4B,MAAmB;AACvE,MAAI,CAAC;AA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C,WAAO,oBAAoB,UAAU,MAAM;AAAA,EAC7C;AACF;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { getDocument, getWindow } from '@zag-js/dom-query';
2
-
1
+ // src/index.ts
2
+ import { getDocument, getWindow } from "@zag-js/dom-query";
3
3
  function copyVisualStyles(fromEl, toEl) {
4
4
  if (!fromEl)
5
5
  return;
@@ -38,5 +38,7 @@ function autoResizeInput(input) {
38
38
  input?.removeEventListener("change", resize);
39
39
  };
40
40
  }
41
-
42
- export { autoResizeInput };
41
+ export {
42
+ autoResizeInput
43
+ };
44
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { getDocument, getWindow } from \"@zag-js/dom-query\"\n\nfunction copyVisualStyles(fromEl: HTMLElement | null, toEl: HTMLElement) {\n if (!fromEl) return\n\n const win = getWindow(fromEl)\n const el = win.getComputedStyle(fromEl)\n\n // prettier-ignore\n const cssText = 'box-sizing:' + el.boxSizing +\n ';border-left:' + el.borderLeftWidth + ' solid red' +\n ';border-right:' + el.borderRightWidth + ' solid red' +\n ';font-family:' + el.fontFamily +\n ';font-feature-settings:' + el.fontFeatureSettings +\n ';font-kerning:' + el.fontKerning +\n ';font-size:' + el.fontSize +\n ';font-stretch:' + el.fontStretch +\n ';font-style:' + el.fontStyle +\n ';font-variant:' + el.fontVariant +\n ';font-variant-caps:' + el.fontVariantCaps +\n ';font-variant-ligatures:' + el.fontVariantLigatures +\n ';font-variant-numeric:' + el.fontVariantNumeric +\n ';font-weight:' + el.fontWeight +\n ';letter-spacing:' + el.letterSpacing +\n ';margin-left:' + el.marginLeft +\n ';margin-right:' + el.marginRight +\n ';padding-left:' + el.paddingLeft +\n ';padding-right:' + el.paddingRight +\n ';text-indent:' + el.textIndent +\n ';text-transform:' + el.textTransform\n\n toEl.style.cssText += cssText\n}\n\nfunction createGhostElement(doc: Document) {\n var el = doc.createElement(\"div\")\n el.id = \"ghost\"\n el.style.cssText =\n \"display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;\"\n doc.body.appendChild(el)\n return el\n}\n\nexport function autoResizeInput(input: HTMLInputElement | null) {\n if (!input) return\n const doc = getDocument(input)\n const win = getWindow(input)\n\n const ghost = createGhostElement(doc)\n\n copyVisualStyles(input, ghost)\n\n function resize() {\n win.requestAnimationFrame(() => {\n ghost.innerHTML = input!.value\n const rect = win.getComputedStyle(ghost)\n input?.style.setProperty(\"width\", rect.width)\n })\n }\n\n resize()\n\n input?.addEventListener(\"input\", resize)\n input?.addEventListener(\"change\", resize)\n\n return () => {\n doc.body.removeChild(ghost)\n input?.removeEventListener(\"input\", resize)\n input?.removeEventListener(\"change\", resize)\n }\n}\n"],"mappings":";AAAA,SAAS,aAAa,iBAAiB;AAEvC,SAAS,iBAAiB,QAA4B,MAAmB;AACvE,MAAI,CAAC;AAAQ;AAEb,QAAM,MAAM,UAAU,MAAM;AAC5B,QAAM,KAAK,IAAI,iBAAiB,MAAM;AAGtC,QAAM,UAAU,gBAAgB,GAAG,YACf,kBAAkB,GAAG,kBAAkB,6BACpB,GAAG,mBAAmB,4BACvB,GAAG,aACrB,4BAA4B,GAAG,sBAC/B,mBAAmB,GAAG,cACtB,gBAAgB,GAAG,WACnB,mBAAmB,GAAG,cACtB,iBAAiB,GAAG,YACpB,mBAAmB,GAAG,cACtB,wBAAwB,GAAG,kBAC3B,6BAA6B,GAAG,uBAChC,2BAA2B,GAAG,qBAC9B,kBAAkB,GAAG,aACrB,qBAAqB,GAAG,gBACxB,kBAAkB,GAAG,aACrB,mBAAmB,GAAG,cACtB,mBAAmB,GAAG,cACtB,oBAAoB,GAAG,eACvB,kBAAkB,GAAG,aACrB,qBAAqB,GAAG;AAE5C,OAAK,MAAM,WAAW;AACxB;AAEA,SAAS,mBAAmB,KAAe;AACzC,MAAI,KAAK,IAAI,cAAc,KAAK;AAChC,KAAG,KAAK;AACR,KAAG,MAAM,UACP;AACF,MAAI,KAAK,YAAY,EAAE;AACvB,SAAO;AACT;AAEO,SAAS,gBAAgB,OAAgC;AAC9D,MAAI,CAAC;AAAO;AACZ,QAAM,MAAM,YAAY,KAAK;AAC7B,QAAM,MAAM,UAAU,KAAK;AAE3B,QAAM,QAAQ,mBAAmB,GAAG;AAEpC,mBAAiB,OAAO,KAAK;AAE7B,WAAS,SAAS;AAChB,QAAI,sBAAsB,MAAM;AAC9B,YAAM,YAAY,MAAO;AACzB,YAAM,OAAO,IAAI,iBAAiB,KAAK;AACvC,aAAO,MAAM,YAAY,SAAS,KAAK,KAAK;AAAA,IAC9C,CAAC;AAAA,EACH;AAEA,SAAO;AAEP,SAAO,iBAAiB,SAAS,MAAM;AACvC,SAAO,iBAAiB,UAAU,MAAM;AAExC,SAAO,MAAM;AACX,QAAI,KAAK,YAAY,KAAK;AAC1B,WAAO,oBAAoB,SAAS,MAAM;AAC1C,WAAO,oBAAoB,UAAU,MAAM;AAAA,EAC7C;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/auto-resize",
3
- "version": "0.10.5",
3
+ "version": "0.11.1",
4
4
  "description": "Autoresize utilities for the web",
5
5
  "keywords": [
6
6
  "js",
@@ -23,7 +23,7 @@
23
23
  "url": "https://github.com/chakra-ui/zag/issues"
24
24
  },
25
25
  "dependencies": {
26
- "@zag-js/dom-query": "0.10.5"
26
+ "@zag-js/dom-query": "0.11.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "clean-package": "2.2.0"
@@ -41,7 +41,7 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "scripts": {
44
- "build": "vite build -c ../../../vite.config.ts",
44
+ "build": "tsup",
45
45
  "test": "jest --config ../../../jest.config.js --rootDir tests",
46
46
  "lint": "eslint src --ext .ts,.tsx",
47
47
  "test-ci": "pnpm test --ci --runInBand -u",