tiny-essentials 1.20.1 โ 1.20.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/README.md +5 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTextarea.min.js +1 -0
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/basics/html.cjs +33 -2
- package/dist/v1/basics/html.d.mts +14 -4
- package/dist/v1/basics/html.mjs +27 -2
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +3 -1
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/simpleMath.cjs +23 -4
- package/dist/v1/basics/simpleMath.d.mts +18 -4
- package/dist/v1/basics/simpleMath.mjs +22 -4
- package/dist/v1/build/TinyTextarea.cjs +7 -0
- package/dist/v1/build/TinyTextarea.d.mts +3 -0
- package/dist/v1/build/TinyTextarea.mjs +2 -0
- package/dist/v1/index.cjs +4 -0
- package/dist/v1/index.d.mts +4 -1
- package/dist/v1/index.mjs +4 -3
- package/dist/v1/libs/TinyHtml.cjs +210 -4
- package/dist/v1/libs/TinyHtml.d.mts +109 -3
- package/dist/v1/libs/TinyHtml.mjs +184 -4
- package/dist/v1/libs/TinySmartScroller.cjs +87 -0
- package/dist/v1/libs/TinySmartScroller.d.mts +52 -0
- package/dist/v1/libs/TinySmartScroller.mjs +76 -0
- package/dist/v1/libs/TinyTextarea.cjs +230 -0
- package/dist/v1/libs/TinyTextarea.d.mts +128 -0
- package/dist/v1/libs/TinyTextarea.mjs +198 -0
- package/docs/v1/README.md +1 -0
- package/docs/v1/basics/html.md +78 -22
- package/docs/v1/basics/simpleMath.md +22 -4
- package/docs/v1/libs/TinyHtml.md +140 -0
- package/docs/v1/libs/TinySmartScroller.md +4 -4
- package/docs/v1/libs/TinyTextarea.md +156 -0
- package/package.json +1 -1
package/docs/v1/basics/html.md
CHANGED
|
@@ -142,11 +142,11 @@ saveJsonFile('yasmin.json', data);
|
|
|
142
142
|
|
|
143
143
|
### ๐ `fetchTemplate(...)`
|
|
144
144
|
|
|
145
|
-
Loads data from a remote URL using Fetch API, with support for custom HTTP methods, retries, timeouts, headers, and even external abort controllers.
|
|
145
|
+
Loads data from a remote URL using the Fetch API, with support for custom HTTP methods, retries, timeouts, headers, and even external abort controllers.
|
|
146
146
|
|
|
147
147
|
#### ๐ฅ Parameters
|
|
148
148
|
|
|
149
|
-
* `url` *(string)*: The full URL to fetch
|
|
149
|
+
* `url` *(string)*: The full URL to fetch from (must start with `http://`, `https://`, `/`, `./`, or `../`).
|
|
150
150
|
* `options` *(object)* *(optional)*:
|
|
151
151
|
|
|
152
152
|
* `signal` *(`AbortSignal` | `null`)*: Custom abort signal.
|
|
@@ -156,42 +156,88 @@ Loads data from a remote URL using Fetch API, with support for custom HTTP metho
|
|
|
156
156
|
* `headers` *(object)*: Additional headers to include in the request.
|
|
157
157
|
* `body` *(object)*: Request body. If the value is a plain object, it will be automatically stringified as JSON.
|
|
158
158
|
|
|
159
|
-
#### `fetchJson(url, options?)
|
|
159
|
+
#### `fetchJson(url, options?)`
|
|
160
160
|
|
|
161
|
-
Loads and parses a JSON.
|
|
161
|
+
Loads and parses a remote JSON file.
|
|
162
162
|
|
|
163
|
-
*
|
|
164
|
-
* `options` *(object)* *(optional)*:
|
|
163
|
+
* **Parameters**:
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
* `url` *(string)*: URL to fetch the JSON from.
|
|
166
|
+
* `options` *(object)* *(optional)*: Same structure as `fetchTemplate`.
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
* **Returns**:
|
|
169
|
+
`Promise<any[] | Record<string | number | symbol, unknown>>` โ The parsed JSON data.
|
|
169
170
|
|
|
170
|
-
*
|
|
171
|
-
* `allowedMimeTypes` Optional list of accepted MIME types (e.g., ['image/jpeg']).
|
|
172
|
-
* `options` *(object)* *(optional)*:
|
|
171
|
+
* **Throws**:
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
* `Error` if the fetch fails, times out, or returns invalid JSON.
|
|
174
|
+
* `Error` if the `Content-Type` is not `application/json`.
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
---
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
* Retry logic is **disabled**
|
|
180
|
-
* Abortion is handled externally
|
|
178
|
+
#### `fetchBlob(url, allowedMimeTypes?, options?)`
|
|
181
179
|
|
|
182
|
-
|
|
180
|
+
Loads a remote file as a Blob object.
|
|
181
|
+
|
|
182
|
+
* **Parameters**:
|
|
183
|
+
|
|
184
|
+
* `url` *(string)*: URL of the remote file.
|
|
185
|
+
* `allowedMimeTypes` *(string\[])* *(optional)*: List of accepted MIME types.
|
|
186
|
+
* `options` *(object)* *(optional)*: Same structure as `fetchTemplate`.
|
|
187
|
+
|
|
188
|
+
* **Returns**:
|
|
189
|
+
`Promise<Blob>`
|
|
190
|
+
|
|
191
|
+
* **Throws**:
|
|
192
|
+
|
|
193
|
+
* `Error` if fetch fails or the MIME type is not allowed.
|
|
194
|
+
* `Error` if the response is not OK.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
#### `fetchText(url, allowedMimeTypes?, options?)`
|
|
199
|
+
|
|
200
|
+
Loads a remote file as **plain text** using the Fetch API.
|
|
201
|
+
|
|
202
|
+
* **Parameters**:
|
|
203
|
+
|
|
204
|
+
* `url` *(string)*: Full URL of the file to fetch.
|
|
205
|
+
* `allowedMimeTypes` *(string\[])* *(optional)*: List of accepted MIME types (e.g., `['text/plain']`).
|
|
206
|
+
* `options` *(object)* *(optional)*: Same structure as `fetchTemplate`.
|
|
207
|
+
|
|
208
|
+
* **Returns**:
|
|
209
|
+
`Promise<string>` โ The content of the file as a text string.
|
|
210
|
+
|
|
211
|
+
* **Throws**:
|
|
183
212
|
|
|
184
|
-
* `
|
|
213
|
+
* `Error` if the fetch fails or the response is not OK.
|
|
214
|
+
* `Error` if the MIME type is not in the allowed list (when provided).
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
#### ๐ค Returns (for all helpers)
|
|
219
|
+
|
|
220
|
+
* `Promise<any>` โ Depends on the function:
|
|
221
|
+
|
|
222
|
+
* `fetchJson`: Parsed JSON
|
|
223
|
+
* `fetchBlob`: File as a Blob
|
|
224
|
+
* `fetchText`: File as plain text
|
|
225
|
+
|
|
226
|
+
---
|
|
185
227
|
|
|
186
228
|
#### โ ๏ธ Throws
|
|
187
229
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
* `Error` if the
|
|
230
|
+
All functions may throw the following:
|
|
231
|
+
|
|
232
|
+
* `Error` if the request fails or the response times out.
|
|
233
|
+
* `Error` if `Content-Type` does not match expected type (JSON, Blob, Text, etc).
|
|
234
|
+
* `Error` if response is malformed or rejected by MIME type filter.
|
|
235
|
+
|
|
236
|
+
---
|
|
191
237
|
|
|
192
238
|
#### ๐ง Tip
|
|
193
239
|
|
|
194
|
-
|
|
240
|
+
Using a custom `signal` disables both `timeout` and `retries`. This is useful when you want to handle cancellation yourself, like in user interfaces or abortable workflows.
|
|
195
241
|
|
|
196
242
|
#### ๐งช Example
|
|
197
243
|
|
|
@@ -210,6 +256,16 @@ const data = await fetchJson('https://api.example.com/data', {
|
|
|
210
256
|
});
|
|
211
257
|
```
|
|
212
258
|
|
|
259
|
+
```js
|
|
260
|
+
const text = await fetchText('/example.txt', ['text/plain'], {
|
|
261
|
+
timeout: 3000,
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
```js
|
|
266
|
+
const blob = await fetchBlob('/image.jpg', ['image/jpeg']);
|
|
267
|
+
```
|
|
268
|
+
|
|
213
269
|
---
|
|
214
270
|
|
|
215
271
|
### ๐ฆ `HtmlElBoxSides` Type
|
|
@@ -36,19 +36,37 @@ ruleOfThree(2, 6, 3, true); // โ 4
|
|
|
36
36
|
|
|
37
37
|
### ๐ฏ `getSimplePerc(price, percentage)`
|
|
38
38
|
|
|
39
|
-
**Calculates the percentage of a
|
|
39
|
+
**Calculates the actual value that corresponds to a percentage of a base number.**
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
Unlike `getPercentage`, which tells how much something represents in percent,
|
|
42
|
+
this function tells how much a given percentage *is worth* in actual value.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
- **`price`**: The base number to apply the percentage to.
|
|
45
|
+
- **`percentage`**: The percentage to calculate from the base.
|
|
45
46
|
|
|
47
|
+
#### Example:
|
|
46
48
|
```js
|
|
47
49
|
getSimplePerc(200, 15); // โ 30
|
|
48
50
|
```
|
|
49
51
|
|
|
50
52
|
---
|
|
51
53
|
|
|
54
|
+
### ๐ `getPercentage(part, total)`
|
|
55
|
+
|
|
56
|
+
**Calculates how much percent a partial value represents of the total value.**
|
|
57
|
+
|
|
58
|
+
This function is useful when you want to know what fraction of the total a value is, in percentage form.
|
|
59
|
+
|
|
60
|
+
- **`part`**: The partial value to compare.
|
|
61
|
+
- **`total`**: The total or maximum value.
|
|
62
|
+
|
|
63
|
+
#### Example:
|
|
64
|
+
```js
|
|
65
|
+
getPercentage(5, 100); // โ 5
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
52
70
|
### ๐ `getAge(timeData, now)`
|
|
53
71
|
|
|
54
72
|
**Calculates the age based on a birthdate.**
|
package/docs/v1/libs/TinyHtml.md
CHANGED
|
@@ -445,6 +445,139 @@ Finds elements by tag name in a namespace (defaults to XHTML).
|
|
|
445
445
|
|
|
446
446
|
---
|
|
447
447
|
|
|
448
|
+
## ๐ HTML Parser
|
|
449
|
+
|
|
450
|
+
### Type Definition
|
|
451
|
+
|
|
452
|
+
A parsed HTML element represented as an array:
|
|
453
|
+
|
|
454
|
+
```ts
|
|
455
|
+
type HtmlParsed = [
|
|
456
|
+
tagName: string, // e.g., 'div', 'span', 'img'
|
|
457
|
+
attributes: Record<string, string>, // Key-value map of all element attributes
|
|
458
|
+
...children: (string | HtmlParsed)[] // Nested elements or text content
|
|
459
|
+
];
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
### `fetchHtmlFile(url, ops?)`
|
|
465
|
+
|
|
466
|
+
Fetches an HTML file from a URL and parses it into a JSON-like structure.
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
static async fetchHtmlFile(url: string | URL | Request, ops?: RequestInit): Promise<HtmlParsed[]>
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
* **url**: The URL of the HTML file.
|
|
473
|
+
* **ops**: (Optional) `fetch()` options (method, headers, etc).
|
|
474
|
+
* **Returns**: Promise of parsed JSON structure (`HtmlParsed[]`).
|
|
475
|
+
* Throws if content-type is not `text/html`.
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
### `fetchHtmlNodes(url, ops?)`
|
|
480
|
+
|
|
481
|
+
Fetches an HTML file and returns it as DOM nodes.
|
|
482
|
+
|
|
483
|
+
```ts
|
|
484
|
+
static async fetchHtmlNodes(url: string, ops?: RequestInit): Promise<(HTMLElement | Text)[]>
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
* **Returns**: Array of real DOM nodes (`HTMLElement | Text`).
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
### `fetchHtmlTinyElems(url, ops?)`
|
|
492
|
+
|
|
493
|
+
Fetches HTML and converts it into an array of `TinyHtml` instances.
|
|
494
|
+
|
|
495
|
+
```ts
|
|
496
|
+
static async fetchHtmlTinyElems(url: string, ops?: RequestInit): Promise<TinyHtml[]>
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
* **Returns**: `TinyHtml[]` (custom wrapper elements).
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
### `templateToJson(template)`
|
|
504
|
+
|
|
505
|
+
Converts the contents of a `<template>` to JSON format.
|
|
506
|
+
|
|
507
|
+
```ts
|
|
508
|
+
static templateToJson(template: HTMLTemplateElement): HtmlParsed[]
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
* **Returns**: Structured JSON representation (`HtmlParsed[]`).
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
### `templateToNodes(template)`
|
|
516
|
+
|
|
517
|
+
Converts `<template>` content into real DOM nodes.
|
|
518
|
+
|
|
519
|
+
```ts
|
|
520
|
+
static templateToNodes(template: HTMLTemplateElement): (Element | Text)[]
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
* **Returns**: Cloned nodes excluding comments.
|
|
524
|
+
* Throws error if unexpected node types are encountered.
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
### `templateToTinyElems(template)`
|
|
529
|
+
|
|
530
|
+
Converts a `<template>` into `TinyHtml` instances.
|
|
531
|
+
|
|
532
|
+
```ts
|
|
533
|
+
static templateToTinyElems(template: HTMLTemplateElement): TinyHtml[]
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
* **Returns**: Array of `TinyHtml` objects.
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
### `htmlToJson(htmlString)`
|
|
541
|
+
|
|
542
|
+
Parses an HTML string into structured JSON (`HtmlParsed[]`).
|
|
543
|
+
|
|
544
|
+
```ts
|
|
545
|
+
static htmlToJson(htmlString: string): HtmlParsed[]
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
* **Returns**: Parsed representation as an array of `[tag, attributes, ...children]`.
|
|
549
|
+
|
|
550
|
+
---
|
|
551
|
+
|
|
552
|
+
### `jsonToNodes(jsonArray)`
|
|
553
|
+
|
|
554
|
+
Converts parsed JSON back into actual DOM nodes.
|
|
555
|
+
|
|
556
|
+
```ts
|
|
557
|
+
static jsonToNodes(jsonArray: HtmlParsed[]): (HTMLElement | Text)[]
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
* **Returns**: Array of DOM elements/text nodes.
|
|
561
|
+
* Skips comments.
|
|
562
|
+
|
|
563
|
+
---
|
|
564
|
+
|
|
565
|
+
### `jsonToTinyElems(jsonArray)`
|
|
566
|
+
|
|
567
|
+
Converts parsed JSON back into `TinyHtml` instances.
|
|
568
|
+
|
|
569
|
+
```ts
|
|
570
|
+
static jsonToTinyElems(jsonArray: HtmlParsed[]): TinyHtml[]
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
* **Returns**: TinyHtml-wrapped elements.
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
๐ก **Tip**: All conversion methods rely on a consistent internal format (`HtmlParsed[]`). That means you can seamlessly switch between representations (JSON โ DOM โ TinyHtml)!
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
448
581
|
## ๐งฉ Internal Element Access
|
|
449
582
|
|
|
450
583
|
### `exists(index)`
|
|
@@ -461,6 +594,13 @@ Returns the raw DOM element associated with this instance.
|
|
|
461
594
|
|
|
462
595
|
---
|
|
463
596
|
|
|
597
|
+
### `size`
|
|
598
|
+
Returns the number of elements currently stored in the internal element list.
|
|
599
|
+
|
|
600
|
+
- **Returns**: `number`
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
464
604
|
### `extract(index)`
|
|
465
605
|
Extracts a single DOM element from the internal list at the specified index.
|
|
466
606
|
|
|
@@ -442,19 +442,19 @@ Scrolls the target all the way to the top immediately.
|
|
|
442
442
|
|
|
443
443
|
## ๐งญ Scroll Position Status
|
|
444
444
|
|
|
445
|
-
### ๐ `
|
|
445
|
+
### ๐ `isAtCustomBottom()`
|
|
446
446
|
|
|
447
447
|
Returns `true` if the user is within the custom boundary of the bottom.
|
|
448
448
|
|
|
449
|
-
### ๐ `
|
|
449
|
+
### ๐ `isAtCustomTop()`
|
|
450
450
|
|
|
451
451
|
Returns `true` if the user is within the custom boundary of the top.
|
|
452
452
|
|
|
453
|
-
### ๐งจ `
|
|
453
|
+
### ๐งจ `isAtBottom()`
|
|
454
454
|
|
|
455
455
|
Returns `true` if user is currently scrolled to the actual bottom.
|
|
456
456
|
|
|
457
|
-
### ๐งท `
|
|
457
|
+
### ๐งท `isAtTop()`
|
|
458
458
|
|
|
459
459
|
Returns `true` if user is currently scrolled to the actual top.
|
|
460
460
|
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# โจ `TinyTextarea`
|
|
2
|
+
|
|
3
|
+
A lightweight JavaScript utility for automatically resizing `<textarea>` elements as users type โ without ugly scrollbars!
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ฆ Features
|
|
8
|
+
|
|
9
|
+
* ๐ **Auto-resizing**: Grows or shrinks with the content
|
|
10
|
+
* ๐ซ **No scrollbars** (until limit): Prevents `overflow-y` unless needed
|
|
11
|
+
* ๐ง **Configurable**: Set `maxRows`, `extraHeight`, and hooks
|
|
12
|
+
* ๐ก **Live events**: Hooks for `onInput` and `onResize`
|
|
13
|
+
* ๐งผ **Clean lifecycle**: Includes `.refresh()` and `.destroy()`
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ๐ Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import TinyTextarea from './TinyTextarea.js';
|
|
21
|
+
|
|
22
|
+
const textarea = document.querySelector('textarea');
|
|
23
|
+
|
|
24
|
+
const autoResize = new TinyTextarea(textarea, {
|
|
25
|
+
maxRows: 8,
|
|
26
|
+
extraHeight: 0,
|
|
27
|
+
onResize: (info) => console.log('Resized:', info),
|
|
28
|
+
onInput: (info) => console.log('Input event:', info),
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To stop behavior and clean up:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
autoResize.destroy();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## ๐ง Constructor
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
new TinyTextarea(textarea, options?);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Parameters
|
|
47
|
+
|
|
48
|
+
| Name | Type | Description |
|
|
49
|
+
| --------------------- | ----------------------------- | ----------------------------------------------------- |
|
|
50
|
+
| `textarea` | `HTMLTextAreaElement` | The `<textarea>` element to be managed. |
|
|
51
|
+
| `options` | `Object` *(optional)* | Configuration options. |
|
|
52
|
+
| `options.maxRows` | `number` | Max number of visible rows before scrollbars appear. |
|
|
53
|
+
| `options.extraHeight` | `number` | Extra height (in px) to add on top of computed value. |
|
|
54
|
+
| `options.onResize` | `(info: OnInputInfo) => void` | Called when number of visible rows changes. |
|
|
55
|
+
| `options.onInput` | `(info: OnInputInfo) => void` | Called on every `input` event. |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## ๐ API
|
|
60
|
+
|
|
61
|
+
### `.getData() โ { height, rows }`
|
|
62
|
+
|
|
63
|
+
Returns the last known height and number of visible rows.
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const { height, rows } = autoResize.getData();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### `.refresh()`
|
|
72
|
+
|
|
73
|
+
Forces a manual recalculation and resize of the `<textarea>`.
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
autoResize.refresh();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### `.destroy()`
|
|
82
|
+
|
|
83
|
+
Cleans up listeners and disables resizing behavior. Use this if you remove the element or want to stop automatic behavior.
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
autoResize.destroy();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### ๐ Getters
|
|
92
|
+
|
|
93
|
+
TinyTextarea exposes several readonly properties to let you inspect the current configuration and state of the managed `<textarea>`.
|
|
94
|
+
|
|
95
|
+
#### ๐ `lineHeight: number`
|
|
96
|
+
|
|
97
|
+
Returns the height in pixels of a single line of text in the textarea, computed from its current CSS styles.
|
|
98
|
+
Useful for calculating exact space usage or aligning UI elements.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
#### ๐ `maxRows: number`
|
|
103
|
+
|
|
104
|
+
Returns the maximum number of visible text rows allowed before the textarea begins to scroll.
|
|
105
|
+
This value reflects the limit set via `options.maxRows`.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
#### โ `extraHeight: number`
|
|
110
|
+
|
|
111
|
+
Returns the number of extra pixels added to the calculated height of the textarea.
|
|
112
|
+
This is useful for custom padding or visual adjustments.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
#### ๐ `currentHeight: number`
|
|
117
|
+
|
|
118
|
+
Returns the most recently applied height (in pixels) that was set on the `<textarea>` after resizing.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
#### ๐ `currentRows: number`
|
|
123
|
+
|
|
124
|
+
Returns the most recent number of visible text rows that the textarea is currently using.
|
|
125
|
+
This value is calculated dynamically and may change as the user types.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
#### ๐งฉ `textarea: HTMLTextAreaElement`
|
|
130
|
+
|
|
131
|
+
Returns the original `<textarea>` DOM element that was enhanced by this instance.
|
|
132
|
+
You can use this for direct styling, value changes, or other DOM-level operations.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## ๐ค Event Payload: `OnInputInfo`
|
|
137
|
+
|
|
138
|
+
Whenever `onResize` or `onInput` is triggered, the following object is passed:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
{
|
|
142
|
+
breakLines: number; // Total number of '\n' in the textarea
|
|
143
|
+
height: number; // Final computed height (px)
|
|
144
|
+
scrollHeight: number; // Natural scrollHeight of textarea
|
|
145
|
+
maxHeight: number; // Max height before scrollbars show
|
|
146
|
+
lineHeight: number; // Height of one line of text
|
|
147
|
+
maxRows: number; // Maximum number of visible rows allowed
|
|
148
|
+
rows: number; // Final calculated number of rows used
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## ๐งช Beta Notice
|
|
155
|
+
|
|
156
|
+
> ๐งช This library is currently marked as `@beta`. The API is stable but may be adjusted slightly during updates.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.3",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|