@simplysm/core-browser 13.0.41 → 13.0.43

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.
Files changed (2) hide show
  1. package/README.md +26 -26
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -20,14 +20,14 @@ Instance methods automatically added to `Element.prototype` when importing `"@si
20
20
 
21
21
  | Method | Return Type | Description |
22
22
  |--------|-----------|------|
23
- | `findAll<T>(selector)` | `T[]` | Search all descendant elements by selector |
24
- | `findFirst<T>(selector)` | `T \| undefined` | Search first matching element by selector |
25
- | `prependChild<T>(child)` | `T` | Insert element as first child |
23
+ | `findAll<T>(selector: string)` | `T[]` | Search all descendant elements by selector. Returns empty array for empty selector. |
24
+ | `findFirst<T>(selector: string)` | `T \| undefined` | Search first matching element by selector. Returns `undefined` for empty selector. |
25
+ | `prependChild<T>(child: T)` | `T` | Insert element as first child |
26
26
  | `getParents()` | `Element[]` | Return list of all parent elements (closest first) |
27
- | `findFocusableParent()` | `HTMLElement \| undefined` | Search for first focusable element among parents |
28
- | `findFirstFocusableChild()` | `HTMLElement \| undefined` | Search for first focusable element among children |
29
- | `isOffsetElement()` | `boolean` | Check if element is an offset reference element |
30
- | `isVisible()` | `boolean` | Check element visibility |
27
+ | `findFocusableParent()` | `HTMLElement \| undefined` | Search for first focusable element among parents (uses tabbable) |
28
+ | `findFirstFocusableChild()` | `HTMLElement \| undefined` | Search for first focusable element among children (uses tabbable) |
29
+ | `isOffsetElement()` | `boolean` | Check if element has `position: relative`, `absolute`, `fixed`, or `sticky` |
30
+ | `isVisible()` | `boolean` | Check element visibility (clientRects exist, not `visibility: hidden`, not `opacity: 0`) |
31
31
 
32
32
  ### HTMLElement Extension Methods
33
33
 
@@ -35,37 +35,37 @@ Instance methods automatically added to `HTMLElement.prototype`.
35
35
 
36
36
  | Method | Return Type | Description |
37
37
  |--------|-----------|------|
38
- | `repaint()` | `void` | Trigger forced repaint (triggers forced synchronous layout) |
39
- | `getRelativeOffset(parent: HTMLElement \| string)` | `{ top: number; left: number }` | Calculate relative position based on parent element or CSS selector |
40
- | `scrollIntoViewIfNeeded(target, offset?)` | `void` | Adjust scroll if target is obscured by fixed regions (top/left only) |
38
+ | `repaint()` | `void` | Trigger forced repaint by causing forced synchronous layout |
39
+ | `getRelativeOffset(parent: HTMLElement \| string)` | `{ top: number; left: number }` | Calculate document-based position relative to a parent element or CSS selector, suitable for CSS `top`/`left` (includes `window.scrollX/Y`, parent scroll, border widths, and CSS transforms) |
40
+ | `scrollIntoViewIfNeeded(target: { top: number; left: number }, offset?: { top: number; left: number })` | `void` | Adjust scroll so that target position is visible past any fixed offset regions (top/left only) |
41
41
 
42
42
  ### Static Functions
43
43
 
44
44
  | Function | Return Type | Description |
45
45
  |------|-----------|------|
46
- | `copyElement(event)` | `void` | Copy element content to clipboard |
47
- | `pasteToElement(event)` | `void` | Paste clipboard content into element |
48
- | `getBounds(els, timeout?)` | `Promise<ElementBounds[]>` | Query element bounds using IntersectionObserver |
46
+ | `copyElement(event: ClipboardEvent)` | `void` | Copy value of first `input`/`textarea` within the event target element to clipboard |
47
+ | `pasteToElement(event: ClipboardEvent)` | `void` | Paste clipboard text into the first `input`/`textarea` within the event target element |
48
+ | `getBounds(els: Element[], timeout?: number)` | `Promise<ElementBounds[]>` | Query element bounds using `IntersectionObserver`. Results are returned in input order. Default timeout: 5000ms. |
49
49
 
50
50
  ### Download Utilities
51
51
 
52
52
  | Function | Return Type | Description |
53
53
  |------|-----------|------|
54
- | `downloadBlob(blob, fileName)` | `void` | Download Blob as file |
55
- | `fetchUrlBytes(url, options?)` | `Promise<Uint8Array>` | Download binary data from URL (with progress callback support) |
54
+ | `downloadBlob(blob: Blob, fileName: string)` | `void` | Download a Blob as a file |
55
+ | `fetchUrlBytes(url: string, options?: { onProgress?: (progress: DownloadProgress) => void })` | `Promise<Uint8Array>` | Download binary data from a URL with optional progress callback |
56
56
 
57
57
  ### File Dialog
58
58
 
59
59
  | Function | Return Type | Description |
60
60
  |------|-----------|------|
61
- | `openFileDialog(options?)` | `Promise<File[] \| undefined>` | Open file selection dialog (supports single/multiple file selection) |
61
+ | `openFileDialog(options?: { accept?: string; multiple?: boolean })` | `Promise<File[] \| undefined>` | Open a file selection dialog. Returns `undefined` if the user cancels without selecting. |
62
62
 
63
63
  ### Types
64
64
 
65
65
  | Type | Description |
66
66
  |------|------|
67
- | `ElementBounds` | Element bounds information (`target`, `top`, `left`, `width`, `height`) |
68
- | `DownloadProgress` | Download progress information (`receivedLength`, `contentLength`) |
67
+ | `ElementBounds` | Element bounds information: `target: Element`, `top: number`, `left: number`, `width: number`, `height: number` |
68
+ | `DownloadProgress` | Download progress: `receivedLength: number`, `contentLength: number` |
69
69
 
70
70
  ## Usage Examples
71
71
 
@@ -107,12 +107,12 @@ import "@simplysm/core-browser";
107
107
  // Forced repaint (useful for restarting CSS animations)
108
108
  element.repaint();
109
109
 
110
- // Calculate relative position based on parent element (can be used directly for CSS top/left)
110
+ // Calculate document-based position relative to a parent element (can be used directly for CSS top/left)
111
111
  const offset = element.getRelativeOffset(document.body);
112
112
  popup.style.top = `${offset.top}px`;
113
113
  popup.style.left = `${offset.left}px`;
114
114
 
115
- // Parent can also be specified by selector
115
+ // Parent can also be specified by CSS selector (uses closest())
116
116
  const offset2 = element.getRelativeOffset(".scroll-container");
117
117
 
118
118
  // Adjust scroll position in table with fixed header/columns
@@ -131,11 +131,11 @@ scrollContainer.scrollIntoViewIfNeeded(
131
131
  import { copyElement, pasteToElement } from "@simplysm/core-browser";
132
132
 
133
133
  // Use in copy event handler
134
- // Copy value of first input/textarea within target element to clipboard
134
+ // Copies value of the first input/textarea within the target element to clipboard
135
135
  element.addEventListener("copy", (e) => copyElement(e));
136
136
 
137
137
  // Use in paste event handler
138
- // Paste clipboard content into first input/textarea within target element
138
+ // Pastes clipboard content into the first input/textarea within the target element
139
139
  element.addEventListener("paste", (e) => pasteToElement(e));
140
140
  ```
141
141
 
@@ -229,11 +229,11 @@ if (selectedFiles) {
229
229
 
230
230
  - This package is **browser-only**. It cannot be used in Node.js environments.
231
231
  - `Element` and `HTMLElement` prototype extensions work as **side-effect imports**. Extensions are automatically applied when importing `"@simplysm/core-browser"` or any item from the package.
232
- - The `getBounds()` function uses `IntersectionObserver` and works asynchronously. If all elements are not observed within the specified timeout (default 5000ms), a `TimeoutError` is thrown.
233
- - The `getRelativeOffset()` method accepts either an `HTMLElement` or a CSS selector string as the `parent` parameter. It throws `ArgumentError` if the parent element cannot be found. Border thickness and scroll position of intermediate elements are included in the calculation, and CSS `transform` is correctly handled.
232
+ - The `getBounds()` function uses `IntersectionObserver` and works asynchronously. If all elements are not observed within the specified timeout (default 5000ms), a `TimeoutError` is thrown. Duplicate elements in the input array are deduplicated; results are returned in input order.
233
+ - The `getRelativeOffset()` method accepts either an `HTMLElement` or a CSS selector string as the `parent` parameter. When a string is given, it uses `closest()` to find the nearest matching ancestor. It throws `ArgumentError` if the parent element cannot be found. The returned coordinates are document-based (include `window.scrollX/Y`) and are suitable for use as CSS `top`/`left` values. Intermediate element border widths, parent scroll position, and CSS `transform` are all included in the calculation.
234
234
  - The `scrollIntoViewIfNeeded()` method only handles cases where the target is beyond the top/left boundaries. The bottom/right directions rely on the browser's default focus scrolling.
235
- - The `fetchUrlBytes()` function improves memory efficiency by pre-allocating when the `Content-Length` header is available, and collects and merges chunks for chunked encoding.
236
- - The `pasteToElement()` function replaces the entire value of the target input/textarea. It does not consider cursor position or selection range.
235
+ - The `fetchUrlBytes()` function improves memory efficiency by pre-allocating a buffer when the `Content-Length` header is available, and collects and merges chunks for chunked encoding. Throws an `Error` if the response status is not ok or if the response body is not readable.
236
+ - The `pasteToElement()` function replaces the entire value of the target input/textarea. It does not consider cursor position or selection range. It dispatches an `input` event after the value is set.
237
237
 
238
238
  ## License
239
239
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/core-browser",
3
- "version": "13.0.41",
3
+ "version": "13.0.43",
4
4
  "description": "심플리즘 패키지 - 코어 모듈 (browser)",
5
5
  "author": "김석래",
6
6
  "license": "Apache-2.0",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "tabbable": "^6.4.0",
25
- "@simplysm/core-common": "13.0.41"
25
+ "@simplysm/core-common": "13.0.43"
26
26
  },
27
27
  "devDependencies": {
28
28
  "happy-dom": "^20.6.3"