@iyulab/components 2.14.0 → 2.16.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.16.0] - 2026-10-07
4
+
5
+ ### Added
6
+
7
+ - **`u-pagination` `label` and `formatRange`.** `label` names the navigation (the locale string when empty) — two
8
+ pagers on one page were two landmarks with the same name. `formatRange(start, end, total)` builds the range text
9
+ when a screen formats counts its own way. Both are what a table needs to use `u-pagination` as its pager.
10
+
11
+ ## [2.15.0] - 2026-10-07
12
+
13
+ ### Added
14
+
15
+ - **`isFromControl(event, boundary)`** — whether an event came from a control inside `boundary`: a link, a button, a
16
+ form field, or an element with a control role (`button`, `link`, `checkbox`, `switch`, `radio`, `menuitem`,
17
+ `option`, `tab`). Open shadow roots are looked into, so a `u-button` counts. For a box that reads «pressed» for
18
+ itself — a row that opens on click — so that pressing a control it renders stays that control's act.
19
+
3
20
  ## [2.14.0] - 2026-10-07
4
21
 
5
22
  ### Added
@@ -39,6 +39,16 @@ export declare class UPagination extends UElement {
39
39
  size: PaginationSize;
40
40
  /** 현재 쪽 양옆에 보일 쪽 번호 수. */
41
41
  siblings: number;
42
+ /**
43
+ * 내비게이션의 접근 가능한 이름. 비우면 로케일 문장(`pagination`). 한 화면에 페이저가 둘 이상이면 각자 이름을 준다
44
+ * (랜드마크는 이름으로 구별된다 — 예: «주문 목록 페이지»).
45
+ */
46
+ label: string;
47
+ /**
48
+ * 범위 글자를 만든다 — `(start, end, total)`, `start` 는 1 기준(행이 없으면 0). 비우면 로케일 문장(`rangeOfTotal` —
49
+ * «1–20 / 345»). 숫자 형식·문구를 화면 규약에 맞출 때.
50
+ */
51
+ formatRange?: (start: number, end: number, total: number) => string;
42
52
  /** 페이지 수 — 행이 없어도 1. */
43
53
  get pageCount(): number;
44
54
  private get current();
@@ -19,6 +19,7 @@ var UPagination = class UPagination extends UElement {
19
19
  this.pageSizes = [];
20
20
  this.size = "md";
21
21
  this.siblings = 1;
22
+ this.label = "";
22
23
  this.onPageSizeChange = (e) => {
23
24
  e.stopPropagation();
24
25
  const size = Number(e.target.value);
@@ -48,8 +49,8 @@ var UPagination = class UPagination extends UElement {
48
49
  const start = this.totalCount === 0 ? 0 : current * this.pageSize + 1;
49
50
  const end = Math.min(this.totalCount, (current + 1) * this.pageSize);
50
51
  return html`
51
- <nav part="nav" aria-label=${Locale.getValue("pagination")}>
52
- <span class="range" part="range">${Locale.getValue("rangeOfTotal", {
52
+ <nav part="nav" aria-label=${this.label || Locale.getValue("pagination")}>
53
+ <span class="range" part="range">${this.formatRange ? this.formatRange(start, end, this.totalCount) : Locale.getValue("rangeOfTotal", {
53
54
  start,
54
55
  end,
55
56
  total: this.totalCount
@@ -130,6 +131,8 @@ __decorate([property({
130
131
  reflect: true
131
132
  }), __decorateMetadata("design:type", Object)], UPagination.prototype, "size", void 0);
132
133
  __decorate([property({ type: Number }), __decorateMetadata("design:type", Object)], UPagination.prototype, "siblings", void 0);
134
+ __decorate([property({ type: String }), __decorateMetadata("design:type", Object)], UPagination.prototype, "label", void 0);
135
+ __decorate([property({ attribute: false }), __decorateMetadata("design:type", Function)], UPagination.prototype, "formatRange", void 0);
133
136
  UPagination = __decorate([customElement("u-pagination")], UPagination);
134
137
  //#endregion
135
138
  export { UPagination };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Locale } from "./utilities/Locale.js";
2
2
  import { UElement } from "./components/UElement.js";
3
- import { getParentElement, isCoarsePointer, isFocusCandidate, querySelectorAllWithin, querySelectorDeep, querySelectorWithin } from "./utilities/elements.js";
3
+ import { getParentElement, isCoarsePointer, isFocusCandidate, isFromControl, querySelectorAllWithin, querySelectorDeep, querySelectorWithin } from "./utilities/elements.js";
4
4
  import { UFloatingElement } from "./components/UFloatingElement.js";
5
5
  import { UFormControlElement } from "./components/UFormControlElement.js";
6
6
  import { isImeComposing } from "./utilities/keyboard.js";
@@ -65,4 +65,4 @@ import { Dialog } from "./utilities/Dialog.js";
65
65
  import { Theme } from "./utilities/Theme.js";
66
66
  import { Toast } from "./utilities/Toast.js";
67
67
  import { decodeTsv, encodeTsv } from "./utilities/tsv.js";
68
- export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPagination, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, isTextEntry, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
68
+ export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPagination, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isFromControl, isImeComposing, isTextEntry, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
@@ -29,6 +29,12 @@ export declare function isCoarsePointer(event: PointerEvent): boolean;
29
29
  * 포커스가 아무 데도 가지 않는다.
30
30
  */
31
31
  export declare function isFocusCandidate(el: Element): el is HTMLElement;
32
+ /**
33
+ * `event` 가 `boundary` 안쪽의 컨트롤(링크 · 버튼 · 입력 칸 · 그 역할을 가진 요소)에서 났는가.
34
+ * 행·셀처럼 «눌렀다» 를 스스로 해석하는 상자가, 그 안에 그려진 컨트롤의 클릭을 제 것으로 읽지 않게 한다
35
+ * — 셀 안 «삭제» 버튼을 누른 것이 «이 행을 연다» 가 되면 안 된다. 열린 섀도 안쪽까지 본다(`composedPath`).
36
+ */
37
+ export declare function isFromControl(event: Event, boundary: EventTarget): boolean;
32
38
  /**
33
39
  * `roots` 와 그 자손에서(열린 섀도 루트 안쪽까지) `selectors` 에 맞는 첫 요소를 문서 순서로 찾는다.
34
40
  * 섀도 루트 안은 호스트 자리에서 이어서 본다 — `querySelector` 는 섀도 경계에서 멈추므로,
@@ -57,6 +57,38 @@ function isFocusCandidate(el) {
57
57
  if (el.matches(":disabled") || el.hasAttribute("disabled") || el.closest("[inert]")) return false;
58
58
  return typeof el.checkVisibility === "function" ? el.checkVisibility() : true;
59
59
  }
60
+ /** 스스로 클릭을 처리하는 컨트롤 — 누르면 그 컨트롤의 동작이다. */
61
+ var OWN_CLICK_SELECTOR = [
62
+ "a[href]",
63
+ "button",
64
+ "input",
65
+ "select",
66
+ "textarea",
67
+ "label",
68
+ "summary",
69
+ "[contenteditable=\"\"]",
70
+ "[contenteditable=\"true\"]",
71
+ "[role=\"button\"]",
72
+ "[role=\"link\"]",
73
+ "[role=\"checkbox\"]",
74
+ "[role=\"switch\"]",
75
+ "[role=\"radio\"]",
76
+ "[role=\"menuitem\"]",
77
+ "[role=\"option\"]",
78
+ "[role=\"tab\"]"
79
+ ].join(", ");
80
+ /**
81
+ * `event` 가 `boundary` 안쪽의 컨트롤(링크 · 버튼 · 입력 칸 · 그 역할을 가진 요소)에서 났는가.
82
+ * 행·셀처럼 «눌렀다» 를 스스로 해석하는 상자가, 그 안에 그려진 컨트롤의 클릭을 제 것으로 읽지 않게 한다
83
+ * — 셀 안 «삭제» 버튼을 누른 것이 «이 행을 연다» 가 되면 안 된다. 열린 섀도 안쪽까지 본다(`composedPath`).
84
+ */
85
+ function isFromControl(event, boundary) {
86
+ for (const node of event.composedPath()) {
87
+ if (node === boundary) return false;
88
+ if (node instanceof Element && node.matches(OWN_CLICK_SELECTOR)) return true;
89
+ }
90
+ return false;
91
+ }
60
92
  /**
61
93
  * `roots` 와 그 자손에서(열린 섀도 루트 안쪽까지) `selectors` 에 맞는 첫 요소를 문서 순서로 찾는다.
62
94
  * 섀도 루트 안은 호스트 자리에서 이어서 본다 — `querySelector` 는 섀도 경계에서 멈추므로,
@@ -81,4 +113,4 @@ function querySelectorDeep(roots, selectors, accept = () => true) {
81
113
  return null;
82
114
  }
83
115
  //#endregion
84
- export { getParentElement, isCoarsePointer, isFocusCandidate, querySelectorAllWithin, querySelectorDeep, querySelectorWithin };
116
+ export { getParentElement, isCoarsePointer, isFocusCandidate, isFromControl, querySelectorAllWithin, querySelectorDeep, querySelectorWithin };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/components",
3
3
  "description": "web-components library based on lit-element made by iyulab",
4
- "version": "2.14.0",
4
+ "version": "2.16.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -37,6 +37,8 @@ pager.addEventListener('page-change', (e) => {
37
37
  | `pageSizes` | `number[]` | `[]` | | Choices for rows per page (attribute `page-sizes`, a comma list). Empty — no select |
38
38
  | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | ✓ | Size step of the buttons and the select, as the other controls |
39
39
  | `siblings` | `number` | `1` | | Page numbers shown on each side of the current one |
40
+ | `label` | `string` | `''` | | The navigation's accessible name; the locale string (`pagination`) when empty. Give each pager on a page its own — landmarks are told apart by name |
41
+ | `formatRange` | `(start, end, total) => string` | — | | Builds the range text (`start` is 1-based, 0 when there are no rows); the locale string (`rangeOfTotal`) when unset |
40
42
 
41
43
  `pageCount` (read-only) is the number of pages — 1 when there are no rows.
42
44
 
@@ -54,3 +54,21 @@ private onPointerEnter(e: PointerEvent) {
54
54
  this.open = true;
55
55
  }
56
56
  ```
57
+
58
+ ---
59
+
60
+ ### `isFromControl(event, boundary)`
61
+
62
+ Returns `true` when `event` came from a control inside `boundary` — a link, a button, a form field, or an
63
+ element with a control role (`button`, `link`, `checkbox`, `switch`, `radio`, `menuitem`, `option`, `tab`).
64
+ Open shadow roots are looked into, so a `u-button` counts. The walk stops at `boundary`.
65
+
66
+ Use it where a box reads "pressed" for itself — a row or a cell that opens on click — so that pressing a
67
+ control the box renders stays that control's act.
68
+
69
+ ```ts
70
+ cell.addEventListener('click', (e) => {
71
+ if (isFromControl(e, cell)) return; // the Delete button in the cell is not "open this row"
72
+ openRow();
73
+ });
74
+ ```