@altano/textfit 1.0.1 → 1.0.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.
package/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
3
  Copyright (c) 2014 Samuel Reed <samuel.trace.reed@gmail.com> (http://strml.net/)
4
- Copyright (c) 2022 Alan Norbauer <altano@gmail.com> (https://alan.norbauer.com/)
4
+ Copyright (c) 2022 Alan Norbauer <alan@norbauer.com> (https://alan.norbauer.com/)
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.d.ts CHANGED
@@ -1,48 +1,45 @@
1
- //#region src/index.d.ts
2
1
  /**
3
- * textFit v2.3.1
4
- * Previously known as jQuery.textFit
5
- * 11/2014 by STRML (strml.github.com)
6
- * MIT License
7
- *
8
- * To use: textFit(document.getElementById('target-div'), options);
9
- *
10
- * Will make the *text* content inside a container scale to fit the container
11
- * The container is required to have a set width and height
12
- * Uses binary search to fit text with minimal layout calls.
13
- * Version 2.0 does not use jQuery.
14
- */
15
- interface Options {
2
+ * textFit v2.3.1
3
+ * Previously known as jQuery.textFit
4
+ * 11/2014 by STRML (strml.github.com)
5
+ * MIT License
6
+ *
7
+ * To use: textFit(document.getElementById('target-div'), options);
8
+ *
9
+ * Will make the *text* content inside a container scale to fit the container
10
+ * The container is required to have a set width and height
11
+ * Uses binary search to fit text with minimal layout calls.
12
+ * Version 2.0 does not use jQuery.
13
+ */
14
+ export interface Options {
16
15
  /**
17
- * if true, textFit will not set white-space: no-wrap
18
- */
16
+ * if true, textFit will not set white-space: no-wrap
17
+ */
19
18
  multiLine?: boolean;
20
19
  /**
21
- * disable to turn off automatic multi-line sensing
22
- */
20
+ * disable to turn off automatic multi-line sensing
21
+ */
23
22
  detectMultiLine?: boolean;
24
23
  minFontSize?: number;
25
24
  maxFontSize?: number;
26
25
  /**
27
- * if true, textFit will re-process already-fit nodes. Set to 'false' for
28
- * better performance
29
- */
26
+ * if true, textFit will re-process already-fit nodes. Set to 'false' for
27
+ * better performance
28
+ */
30
29
  reProcess?: boolean;
31
30
  /**
32
- * if true, textFit will fit text to element width, regardless of text height
33
- */
31
+ * if true, textFit will fit text to element width, regardless of text height
32
+ */
34
33
  widthOnly?: boolean;
35
34
  /**
36
- * if true, textFit will use flexbox for vertical alignment
37
- */
35
+ * if true, textFit will use flexbox for vertical alignment
36
+ */
38
37
  alignVertWithFlexbox?: boolean;
39
38
  /**
40
- * Sets the final size to the max multiple of this. Useful when a font
41
- * requires the font size to be a multiple of a number for optimal rendering.
42
- */
39
+ * Sets the final size to the max multiple of this. Useful when a font
40
+ * requires the font size to be a multiple of a number for optimal rendering.
41
+ */
43
42
  sizeMultipleOf?: number;
44
43
  }
45
- declare function textFit(elements: HTMLElement | HTMLElement[], options?: Options): void;
46
- //#endregion
47
- export { Options, textFit };
44
+ export declare function textFit(elements: HTMLElement | HTMLElement[], options?: Options): void;
48
45
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/index.ts
1
+ // src/index.ts
2
2
  const defaultSettings = {
3
3
  multiLine: false,
4
4
  detectMultiLine: true,
@@ -28,8 +28,10 @@ function processItem(el, settings) {
28
28
  const originalHTML = el.innerHTML;
29
29
  const originalWidth = innerWidth(el);
30
30
  const originalHeight = innerHeight(el);
31
- if (!originalWidth || !settings.widthOnly && !originalHeight) if (!settings.widthOnly) throw new Error("Set a static height and width on the target element " + el.outerHTML + " before using textFit!");
32
- else throw new Error("Set a static width on the target element " + el.outerHTML + " before using textFit!");
31
+ if (!originalWidth || !settings.widthOnly && !originalHeight) {
32
+ if (!settings.widthOnly) throw new Error("Set a static height and width on the target element " + el.outerHTML + " before using textFit!");
33
+ else throw new Error("Set a static width on the target element " + el.outerHTML + " before using textFit!");
34
+ }
33
35
  if (originalHTML.indexOf("textFitted") === -1) {
34
36
  innerSpan = document.createElement("span");
35
37
  innerSpan.className = "textFitted";
@@ -81,6 +83,5 @@ function hasClass(element, cls) {
81
83
  return (" " + element.className + " ").indexOf(" " + cls + " ") > -1;
82
84
  }
83
85
 
84
- //#endregion
85
86
  export { textFit };
86
87
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altano/textfit",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A fast, jQuery-free text sizing component that quickly fits single and multi-line text to the width (and optionally height) of its container.",
5
5
  "keywords": [
6
6
  "fit",
@@ -14,9 +14,13 @@
14
14
  "directory": "packages/textfit"
15
15
  },
16
16
  "license": "MIT",
17
- "author": "Alan Norbauer <altano@gmail.com> (https://alan.norbauer.com/)",
17
+ "author": "Alan Norbauer <alan@norbauer.com> (https://alan.norbauer.com/)",
18
18
  "contributors": [
19
- "Samuel Reed <samuel.trace.reed@gmail.com> (http://strml.net/)"
19
+ {
20
+ "name": "Samuel Reed",
21
+ "email": "samuel.trace.reed@gmail.com",
22
+ "url": "http://strml.net"
23
+ }
20
24
  ],
21
25
  "sideEffects": false,
22
26
  "type": "module",
@@ -27,29 +31,30 @@
27
31
  "dist/**/*.d.ts"
28
32
  ],
29
33
  "devDependencies": {
30
- "@arethetypeswrong/cli": "^0.18.2",
31
- "@playwright/test": "1.58.2",
32
- "@types/node": "^25.5.0",
34
+ "@arethetypeswrong/cli": "^0.18.5",
35
+ "@playwright/test": "1.59.1",
36
+ "@types/node": "^26.6.6",
33
37
  "depcheck": "^1.4.7",
34
- "tsdown": "^0.21.4",
35
- "typescript": "^5.9.3",
36
- "vite": "^7.3.1",
37
- "vitest": "^4.1.0",
38
+ "tsdown": "^0.23.5",
39
+ "typescript": "^6.0.3",
40
+ "vite": "^8.3.5",
41
+ "vitest": "^5.1.0",
38
42
  "@altano/build-config": "0.0.1",
39
- "@altano/tsconfig": "0.0.1"
43
+ "@altano/tsconfig": "0.0.1",
44
+ "@altano/testing": "0.0.1"
40
45
  },
41
46
  "publishConfig": {
42
47
  "access": "public"
43
48
  },
44
49
  "scripts": {
45
- "build": "tsdown --config-loader unrun --config ../build-config/tsdown.config.browser.ts",
50
+ "build": "tsdown",
46
51
  "check:exports": "attw --pack . --profile esm-only --quiet",
47
52
  "check:types:src": "tsc --noEmit",
48
53
  "check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
49
54
  "check:unused-dependencies": "depcheck",
50
55
  "dev": "pnpm run build --watch",
51
- "format": "prettier --check src",
52
- "format:fix": "prettier --write src",
56
+ "format": "prettier --check .",
57
+ "format:fix": "prettier --write .",
53
58
  "lint": "eslint",
54
59
  "lint:fix": "TIMING=1 pnpm lint --fix",
55
60
  "lint:timing": "TIMING=1 pnpm lint",