@simplysm/core-browser 13.0.68 → 13.0.70

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.
@@ -2,82 +2,82 @@ import { isFocusable } from "tabbable";
2
2
  import { TimeoutError } from "@simplysm/core-common";
3
3
 
4
4
  /**
5
- * 요소 bounds 정보 타입
5
+ * Element bounds information type
6
6
  */
7
7
  export interface ElementBounds {
8
- /** 측정 대상 요소 */
8
+ /** Element to be measured */
9
9
  target: Element;
10
- /** 뷰포트 기준 상단 위치 */
10
+ /** Top position relative to viewport */
11
11
  top: number;
12
- /** 뷰포트 기준 왼쪽 위치 */
12
+ /** Left position relative to viewport */
13
13
  left: number;
14
- /** 요소 너비 */
14
+ /** Element width */
15
15
  width: number;
16
- /** 요소 높이 */
16
+ /** Element height */
17
17
  height: number;
18
18
  }
19
19
 
20
20
  declare global {
21
21
  interface Element {
22
22
  /**
23
- * 셀렉터로 하위 요소 전체 검색
23
+ * Find all child elements matching selector
24
24
  *
25
- * @param selector - CSS 셀렉터
26
- * @returns 매칭된 요소 배열 ( 셀렉터는 배열 반환)
25
+ * @param selector - CSS selector
26
+ * @returns Array of matching elements (empty selector returns empty array)
27
27
  */
28
28
  findAll<T extends Element = Element>(selector: string): T[];
29
29
 
30
30
  /**
31
- * 셀렉터로 번째 매칭 요소 검색
31
+ * Find first element matching selector
32
32
  *
33
- * @param selector - CSS 셀렉터
34
- * @returns 번째 매칭 요소 또는 undefined ( 셀렉터는 undefined 반환)
33
+ * @param selector - CSS selector
34
+ * @returns First matching element or undefined (empty selector returns undefined)
35
35
  */
36
36
  findFirst<T extends Element = Element>(selector: string): T | undefined;
37
37
 
38
38
  /**
39
- * 요소를 번째 자식으로 삽입
39
+ * Insert element as first child
40
40
  *
41
- * @param child - 삽입할 자식 요소
42
- * @returns 삽입된 자식 요소
41
+ * @param child - Child element to insert
42
+ * @returns Inserted child element
43
43
  */
44
44
  prependChild<T extends Element>(child: T): T;
45
45
 
46
46
  /**
47
- * 모든 부모 요소 목록 반환 (가까운 순서)
47
+ * Get all parent elements (in order of proximity)
48
48
  *
49
- * @returns 부모 요소 배열 (가까운 부모부터 순서대로)
49
+ * @returns Array of parent elements (from closest to farthest)
50
50
  */
51
51
  getParents(): Element[];
52
52
 
53
53
  /**
54
- * 부모 번째 포커스 가능 요소 검색 (tabbable 사용)
54
+ * Find first focusable parent element (using tabbable)
55
55
  *
56
- * @returns 포커스 가능한 번째 부모 요소 또는 undefined
56
+ * @returns First focusable parent element or undefined
57
57
  */
58
58
  findFocusableParent(): HTMLElement | undefined;
59
59
 
60
60
  /**
61
- * 자식 번째 포커스 가능 요소 검색 (tabbable 사용)
61
+ * Find first focusable child element (using tabbable)
62
62
  *
63
- * @returns 포커스 가능한 번째 자식 요소 또는 undefined
63
+ * @returns First focusable child element or undefined
64
64
  */
65
65
  findFirstFocusableChild(): HTMLElement | undefined;
66
66
 
67
67
  /**
68
- * 요소가 offset 기준 요소인지 확인 (position: relative/absolute/fixed/sticky)
68
+ * Check if element is an offset parent (position: relative/absolute/fixed/sticky)
69
69
  *
70
- * @returns position 속성이 relative, absolute, fixed, sticky 중 하나면 true
70
+ * @returns true if position property is one of relative, absolute, fixed, or sticky
71
71
  */
72
72
  isOffsetElement(): boolean;
73
73
 
74
74
  /**
75
- * 요소가 화면에 보이는지 확인
75
+ * Check if element is visible on screen
76
76
  *
77
77
  * @remarks
78
- * clientRects 존재 여부, visibility: hidden, opacity: 0 여부를 확인한다.
78
+ * Checks existence of clientRects, visibility: hidden, and opacity: 0.
79
79
  *
80
- * @returns 요소가 화면에 보이면 true
80
+ * @returns true if element is visible on screen
81
81
  */
82
82
  isVisible(): boolean;
83
83
  }
@@ -144,13 +144,13 @@ Element.prototype.isVisible = function (): boolean {
144
144
  };
145
145
 
146
146
  // ============================================================================
147
- // 정적 함수 (이벤트 핸들러용 또는 여러 요소 대상)
147
+ // Static functions (for event handlers or multiple elements)
148
148
  // ============================================================================
149
149
 
150
150
  /**
151
- * 요소 내용을 클립보드에 복사 (copy 이벤트 핸들러에서 사용)
151
+ * Copy element content to clipboard (use with copy event handler)
152
152
  *
153
- * @param event - copy 이벤트 객체
153
+ * @param event - copy event object
154
154
  */
155
155
  export function copyElement(event: ClipboardEvent): void {
156
156
  const clipboardData = event.clipboardData;
@@ -167,13 +167,13 @@ export function copyElement(event: ClipboardEvent): void {
167
167
  }
168
168
 
169
169
  /**
170
- * 클립보드 내용을 요소에 붙여넣기 (paste 이벤트 핸들러에서 사용)
170
+ * Paste clipboard content to element (use with paste event handler)
171
171
  *
172
172
  * @remarks
173
- * 대상 요소 내의 첫 번째 input/textarea 찾아 전체 값을 클립보드 내용으로 교체한다.
174
- * 커서 위치나 선택 영역을 고려하지 않는다.
173
+ * Finds the first input/textarea within the target element and replaces its entire value with clipboard content.
174
+ * Does not consider cursor position or selection.
175
175
  *
176
- * @param event - paste 이벤트 객체
176
+ * @param event - paste event object
177
177
  */
178
178
  export function pasteToElement(event: ClipboardEvent): void {
179
179
  const clipboardData = event.clipboardData;
@@ -191,20 +191,20 @@ export function pasteToElement(event: ClipboardEvent): void {
191
191
  }
192
192
 
193
193
  /**
194
- * IntersectionObserver를 사용하여 요소들의 bounds 정보 조회
194
+ * Get bounds information for elements using IntersectionObserver
195
195
  *
196
- * @param els - 대상 요소 배열
197
- * @param timeout - 타임아웃 (밀리초, 기본: 5000)
198
- * @throws {TimeoutError} 타임아웃 시간 내에 응답이 없을 경우
196
+ * @param els - Array of target elements
197
+ * @param timeout - Timeout in milliseconds (default: 5000)
198
+ * @throws {TimeoutError} If no response within timeout duration
199
199
  */
200
200
  export async function getBounds(els: Element[], timeout: number = 5000): Promise<ElementBounds[]> {
201
- // 중복 제거 입력 순서대로 결과를 정렬하기 위한 인덱스
201
+ // Index map to remove duplicates and sort results in input order
202
202
  const indexMap = new Map(els.map((el, i) => [el, i] as const));
203
203
  if (indexMap.size === 0) {
204
204
  return [];
205
205
  }
206
206
 
207
- // 정렬 성능 최적화를 위한 인덱스
207
+ // Index map for sorting performance optimization
208
208
  const sortIndexMap = new Map(els.map((el, i) => [el, i] as const));
209
209
 
210
210
  let observer: IntersectionObserver | undefined;
@@ -231,7 +231,7 @@ export async function getBounds(els: Element[], timeout: number = 5000): Promise
231
231
 
232
232
  if (indexMap.size === 0) {
233
233
  observer?.disconnect();
234
- // 입력 순서대로 정렬
234
+ // Sort in input order
235
235
  resolve(
236
236
  results.sort((a, b) => sortIndexMap.get(a.target)! - sortIndexMap.get(b.target)!),
237
237
  );
@@ -243,7 +243,7 @@ export async function getBounds(els: Element[], timeout: number = 5000): Promise
243
243
  }
244
244
  }),
245
245
  new Promise<ElementBounds[]>((_, reject) =>
246
- setTimeout(() => reject(new TimeoutError(undefined, `${timeout}ms 초과`)), timeout),
246
+ setTimeout(() => reject(new TimeoutError(undefined, `${timeout}ms timeout`)), timeout),
247
247
  ),
248
248
  ]);
249
249
  } finally {
@@ -3,44 +3,44 @@ import { ArgumentError } from "@simplysm/core-common";
3
3
  declare global {
4
4
  interface HTMLElement {
5
5
  /**
6
- * 강제 리페인트 (reflow 트리거)
6
+ * Force repaint (triggers reflow)
7
7
  */
8
8
  repaint(): void;
9
9
 
10
10
  /**
11
- * 부모 요소 기준 상대 위치 계산 (CSS 포지셔닝용)
11
+ * Calculate relative position based on parent element (for CSS positioning)
12
12
  *
13
13
  * @remarks
14
- * 함수는 요소의 위치를 부모 요소 기준으로 계산하되, `window.scrollX/Y`를 포함하여
15
- * CSS `top`/`left` 속성에 직접 사용할 있는 문서 기준 좌표를 반환한다.
14
+ * Calculates element position relative to parent element, returning document-based coordinates
15
+ * including `window.scrollX/Y` that can be directly used in CSS `top`/`left` properties.
16
16
  *
17
- * 주요 사용 사례:
18
- * - 드롭다운, 팝업 등을 `document.body`에 append 후 위치 지정
19
- * - 스크롤된 페이지에서도 올바르게 동작
17
+ * Common use cases:
18
+ * - Position dropdowns, popups after appending to `document.body`
19
+ * - Works correctly on scrolled pages
20
20
  *
21
- * 계산에 포함되는 요소:
22
- * - 뷰포트 기준 위치 (getBoundingClientRect)
23
- * - 문서 스크롤 위치 (window.scrollX/Y)
24
- * - 부모 요소 내부 스크롤 (parentEl.scrollTop/Left)
25
- * - 중간 요소들의 border 두께
26
- * - CSS transform 변환
21
+ * Factors included in calculation:
22
+ * - Viewport-relative position (getBoundingClientRect)
23
+ * - Document scroll position (window.scrollX/Y)
24
+ * - Parent element internal scroll (parentEl.scrollTop/Left)
25
+ * - Border thickness of intermediate elements
26
+ * - CSS transform transformations
27
27
  *
28
- * @param parent - 기준이 부모 요소 또는 셀렉터 (예: document.body, ".container")
29
- * @returns CSS top/left 속성에 사용할 수 있는 좌표
30
- * @throws {ArgumentError} 부모 요소를 찾을 없는 경우
28
+ * @param parent - Parent element or selector to use as reference (e.g., document.body, ".container")
29
+ * @returns Coordinates usable in CSS top/left properties
30
+ * @throws {ArgumentError} If parent element cannot be found
31
31
  */
32
32
  getRelativeOffset(parent: HTMLElement | string): { top: number; left: number };
33
33
 
34
34
  /**
35
- * 대상이 offset 영역(고정 헤더/고정 등)에 가려진 경우, 보이도록 스크롤
35
+ * Scroll to make target visible if hidden by offset area (e.g., fixed header/column)
36
36
  *
37
37
  * @remarks
38
- * 함수는 대상이 스크롤 영역의 위쪽/왼쪽 경계를 벗어난 경우만 처리한다.
39
- * 아래쪽/오른쪽으로 스크롤이 필요한 경우는 브라우저의 기본 포커스 스크롤 동작에 의존한다.
40
- * 주로 고정 헤더나 고정 열이 있는 테이블에서 포커스 이벤트와 함께 사용된다.
38
+ * Only handles cases where target extends beyond top/left boundaries of scroll area.
39
+ * For scrolling needed downward/rightward, relies on browser's default focus scroll behavior.
40
+ * Typically used with focus events on tables with fixed headers or columns.
41
41
  *
42
- * @param target - 대상의 컨테이너 위치 (offsetTop, offsetLeft)
43
- * @param offset - 가려지면 되는 영역 크기 (예: 고정 헤더 높이, 고정 너비)
42
+ * @param target - Target position within container (offsetTop, offsetLeft)
43
+ * @param offset - Size of area that must not be obscured (e.g., fixed header height, fixed column width)
44
44
  */
45
45
  scrollIntoViewIfNeeded(
46
46
  target: { top: number; left: number },
@@ -50,8 +50,8 @@ declare global {
50
50
  }
51
51
 
52
52
  HTMLElement.prototype.repaint = function (): void {
53
- // offsetHeight 접근 시 브라우저는 동기적 레이아웃 계산(forced synchronous layout)을 수행하며,
54
- // 이로 인해 현재 배치된 스타일 변경사항이 즉시 적용되어 리페인트가 트리거된다.
53
+ // Accessing offsetHeight triggers forced synchronous layout in browser,
54
+ // causing style changes in current layout to be applied immediately and triggering repaint.
55
55
  void this.offsetHeight;
56
56
  };
57
57
 
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- // core-browser: 브라우저 전용 유틸리티
1
+ // core-browser: Browser-only utilities
2
2
 
3
3
  // extensions (side-effect)
4
4
  import "./extensions/element-ext";
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Blob 파일로 다운로드
2
+ * Download Blob as file
3
3
  *
4
- * @param blob - 다운로드할 Blob 객체
5
- * @param fileName - 저장될 파일 이름
4
+ * @param blob - Blob object to download
5
+ * @param fileName - File name to save as
6
6
  */
7
7
  export function downloadBlob(blob: Blob, fileName: string): void {
8
8
  const url = URL.createObjectURL(blob);
@@ -4,7 +4,7 @@ export interface DownloadProgress {
4
4
  }
5
5
 
6
6
  /**
7
- * URL에서 바이너리 데이터 다운로드 (진행률 콜백 지원)
7
+ * Download binary data from URL (with progress callback support)
8
8
  */
9
9
  export async function fetchUrlBytes(
10
10
  url: string,
@@ -22,7 +22,7 @@ export async function fetchUrlBytes(
22
22
  }
23
23
 
24
24
  try {
25
- // Content-Length 있으면 미리 할당하여 메모리 효율성 향상
25
+ // If Content-Length is known, pre-allocate for memory efficiency
26
26
  if (contentLength > 0) {
27
27
  const result = new Uint8Array(contentLength);
28
28
  let receivedLength = 0;
@@ -39,7 +39,7 @@ export async function fetchUrlBytes(
39
39
  return result;
40
40
  }
41
41
 
42
- // Content-Length 모르면 청크 수집 병합 (chunked encoding)
42
+ // If Content-Length is unknown, collect chunks then merge (chunked encoding)
43
43
  const chunks: Uint8Array[] = [];
44
44
  let receivedLength = 0;
45
45
 
@@ -51,7 +51,7 @@ export async function fetchUrlBytes(
51
51
  receivedLength += value.length;
52
52
  }
53
53
 
54
- // 청크 병합
54
+ // Merge chunks
55
55
  const result = new Uint8Array(receivedLength);
56
56
  let position = 0;
57
57
  for (const chunk of chunks) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 파일 선택 다이얼로그를 프로그래밍 방식으로 열기
2
+ * Programmatically open file selection dialog
3
3
  */
4
4
  export function openFileDialog(options?: {
5
5
  accept?: string;