@uxf/core 11.53.2 → 11.58.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.
package/README.md CHANGED
@@ -188,6 +188,17 @@ const submitHandler: FormEventHandler<HTMLFormElement> = () => {
188
188
  };
189
189
  ```
190
190
 
191
+ ### escapeQuotes
192
+
193
+ Escapes all double quotes (`"`) in a string by replacing them with `\"`.
194
+
195
+ ```ts
196
+ import { escapeQuotes } from "@uxf/core/utils/escape-quotes";
197
+
198
+ escapeQuotes('The "quick" fox');
199
+ // Output: The \"quick\" fox
200
+ ```
201
+
191
202
  ### formatBytes
192
203
 
193
204
  Appends suitable unit to the byte value of data size.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/core",
3
- "version": "11.53.2",
3
+ "version": "11.58.0",
4
4
  "description": "UXF Core",
5
5
  "author": "Petr Vejvoda <vejvoda@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/core#readme",
@@ -4,17 +4,16 @@ exports.adjustTextareaHeight = adjustTextareaHeight;
4
4
  function setHeightByContent(element, shouldShrink, rows = 4) {
5
5
  if (rows >= 1) {
6
6
  const lineHeight = parseFloat(window.getComputedStyle(element).getPropertyValue("line-height"));
7
- const fontSize = parseFloat(window.getComputedStyle(element).getPropertyValue("font-size"));
8
- const targetHeight = parseInt((rows * fontSize * (lineHeight / fontSize)).toFixed(3), 10);
7
+ const minRowsHeight = parseInt((rows * lineHeight).toFixed(3), 10);
9
8
  if (shouldShrink) {
10
9
  while (element.scrollHeight <= element.clientHeight) {
11
- element.style.height = Math.max(targetHeight, element.scrollHeight - lineHeight) + "px";
12
- if (element.clientHeight - lineHeight <= targetHeight) {
10
+ element.style.height = Math.max(minRowsHeight, element.scrollHeight - lineHeight) + "px";
11
+ if (element.clientHeight - lineHeight <= minRowsHeight) {
13
12
  break;
14
13
  }
15
14
  }
16
15
  }
17
- element.style.height = Math.max(targetHeight, element.scrollHeight) + "px";
16
+ element.style.height = Math.max(minRowsHeight, element.scrollHeight) + "px";
18
17
  }
19
18
  else {
20
19
  element.style.height = "auto";
@@ -0,0 +1 @@
1
+ export declare function escapeQuotes(value: string): string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.escapeQuotes = escapeQuotes;
4
+ function escapeQuotes(value) {
5
+ return value.replace(/\x22/g, "\\\x22");
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const escape_quotes_1 = require("./escape-quotes");
4
+ test("escapeQuotes", () => {
5
+ expect((0, escape_quotes_1.escapeQuotes)('"Název něčeho"')).toBe('\\"Název něčeho\\"');
6
+ });
@@ -0,0 +1 @@
1
+ export declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
package/utils/omit.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omit = omit;
4
+ function omit(obj, keys) {
5
+ const result = { ...obj };
6
+ for (const key of keys) {
7
+ delete result[key];
8
+ }
9
+ return result;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const omit_1 = require("./omit");
4
+ describe("omit function", () => {
5
+ it("basic usage", () => {
6
+ const result = (0, omit_1.omit)({ a: "1", b: "2" }, ["a"]);
7
+ expect(result).toEqual({ b: "2" });
8
+ });
9
+ });