@iyulab/components 2.3.1 → 2.5.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/assets/locales/ar.json.js +3 -1
  3. package/dist/assets/locales/de.json.js +3 -1
  4. package/dist/assets/locales/en.json.js +3 -1
  5. package/dist/assets/locales/es.json.js +3 -1
  6. package/dist/assets/locales/fr.json.js +3 -1
  7. package/dist/assets/locales/id.json.js +3 -1
  8. package/dist/assets/locales/ja.json.js +3 -1
  9. package/dist/assets/locales/ko.json.js +3 -1
  10. package/dist/assets/locales/pt-BR.json.js +3 -1
  11. package/dist/assets/locales/ru.json.js +3 -1
  12. package/dist/assets/locales/th.json.js +3 -1
  13. package/dist/assets/locales/vi.json.js +3 -1
  14. package/dist/assets/locales/zh-CN.json.js +3 -1
  15. package/dist/assets/locales/zh-TW.json.js +3 -1
  16. package/dist/components/UOverlayElement.d.ts +11 -0
  17. package/dist/components/UOverlayElement.js +30 -9
  18. package/dist/components/alert/UAlert.js +1 -1
  19. package/dist/components/breadcrumb/UBreadcrumb.js +1 -1
  20. package/dist/components/carousel/UCarousel.js +1 -1
  21. package/dist/components/checkbox/UCheckbox.js +1 -1
  22. package/dist/components/chip/UChip.js +1 -1
  23. package/dist/components/copy-button/UCopyButton.js +1 -1
  24. package/dist/components/date-picker/UDatePicker.js +1 -1
  25. package/dist/components/date-range-picker/UDateRangePicker.js +1 -1
  26. package/dist/components/dialog/UDialog.js +2 -1
  27. package/dist/components/drawer/UDrawer.js +2 -1
  28. package/dist/components/file-input/UFileInput.js +5 -2
  29. package/dist/components/icon-button/UIconButton.d.ts +3 -0
  30. package/dist/components/icon-button/UIconButton.js +9 -3
  31. package/dist/components/input/UInput.d.ts +2 -0
  32. package/dist/components/input/UInput.js +3 -2
  33. package/dist/components/input/UInput.styles.js +11 -0
  34. package/dist/components/progress-bar/UProgressBar.d.ts +3 -0
  35. package/dist/components/progress-bar/UProgressBar.js +11 -0
  36. package/dist/components/progress-ring/UProgressRing.d.ts +3 -0
  37. package/dist/components/progress-ring/UProgressRing.js +11 -0
  38. package/dist/components/rating/URating.js +2 -1
  39. package/dist/components/select/USelect.js +1 -1
  40. package/dist/components/spinner/USpinner.d.ts +7 -0
  41. package/dist/components/spinner/USpinner.js +12 -1
  42. package/dist/components/split-panel/USplitPanel.js +1 -1
  43. package/dist/components/switch/USwitch.js +1 -0
  44. package/dist/components/tab/UTab.js +1 -1
  45. package/dist/components/tree-item/UTreeItem.d.ts +5 -0
  46. package/dist/components/tree-item/UTreeItem.js +27 -2
  47. package/dist/index.js +1 -1
  48. package/dist/utilities/Dialog.d.ts +2 -0
  49. package/dist/utilities/Dialog.js +36 -13
  50. package/dist/utilities/Locale.d.ts +1 -1
  51. package/dist/utilities/progressAria.d.ts +14 -0
  52. package/dist/utilities/progressAria.js +22 -0
  53. package/package.json +1 -1
  54. package/skills/iyulab-components/references/components/dialog.md +7 -0
  55. package/skills/iyulab-components/references/components/drawer.md +5 -0
  56. package/skills/iyulab-components/references/components/file-input.md +1 -1
  57. package/skills/iyulab-components/references/components/icon-button.md +2 -1
  58. package/skills/iyulab-components/references/components/input.md +1 -0
  59. package/skills/iyulab-components/references/components/progress-bar.md +4 -0
  60. package/skills/iyulab-components/references/components/progress-ring.md +4 -0
  61. package/skills/iyulab-components/references/components/rating.md +4 -0
  62. package/skills/iyulab-components/references/components/spinner.md +4 -0
  63. package/skills/iyulab-components/references/components/switch.md +5 -0
  64. package/skills/iyulab-components/references/components/tree.md +6 -0
  65. package/skills/iyulab-components/references/utilities/dialog.md +6 -0
@@ -49,6 +49,9 @@ export declare class UIconButton extends UElement {
49
49
  */
50
50
  static get observedAttributes(): string[];
51
51
  attributeChangedCallback(name: string, old: string | null, value: string | null): void;
52
+ /** 기본 슬롯(툴팁)의 글자 — `aria-label` 이 없을 때 버튼의 이름. */
53
+ private slotText;
54
+ private handleSlotChange;
52
55
  render(): import('lit-html').TemplateResult<1>;
53
56
  }
54
57
  declare global {
@@ -7,7 +7,7 @@ import "../icon/UIcon.js";
7
7
  import "../tooltip/UTooltip.js";
8
8
  import { styles } from "./UIconButton.styles.js";
9
9
  import { html } from "lit";
10
- import { customElement, property } from "lit/decorators.js";
10
+ import { customElement, property, state } from "lit/decorators.js";
11
11
  import { ifDefined } from "lit/directives/if-defined.js";
12
12
  //#region src/components/icon-button/UIconButton.ts
13
13
  var UIconButton = class UIconButton extends UElement {
@@ -19,6 +19,11 @@ var UIconButton = class UIconButton extends UElement {
19
19
  this.loading = false;
20
20
  this.tooltipPlacement = "top";
21
21
  this.tooltipOffset = 4;
22
+ this.slotText = "";
23
+ this.handleSlotChange = (e) => {
24
+ const nodes = e.target.assignedNodes({ flatten: true });
25
+ this.slotText = nodes.map((n) => n.textContent ?? "").join(" ").replace(/\s+/g, " ").trim();
26
+ };
22
27
  }
23
28
  static {
24
29
  this.styles = [super.styles, styles];
@@ -44,7 +49,7 @@ var UIconButton = class UIconButton extends UElement {
44
49
  if (FORWARDED_ARIA.includes(name)) this.requestUpdate();
45
50
  }
46
51
  render() {
47
- const ariaLabel = this.getAttribute("aria-label") ?? void 0;
52
+ const ariaLabel = this.getAttribute("aria-label") ?? (this.slotText || void 0);
48
53
  const pressed = this.getAttribute("aria-pressed") ?? void 0;
49
54
  const expanded = this.getAttribute("aria-expanded") ?? void 0;
50
55
  const haspopup = this.getAttribute("aria-haspopup") ?? void 0;
@@ -75,7 +80,7 @@ var UIconButton = class UIconButton extends UElement {
75
80
  .placement=${this.tooltipPlacement}
76
81
  .offset=${this.tooltipOffset}
77
82
  >
78
- <slot></slot>
83
+ <slot @slotchange=${this.handleSlotChange}></slot>
79
84
  </u-tooltip>
80
85
  `;
81
86
  }
@@ -110,6 +115,7 @@ __decorate([property({
110
115
  type: Number,
111
116
  attribute: "tooltip-offset"
112
117
  }), __decorateMetadata("design:type", Object)], UIconButton.prototype, "tooltipOffset", void 0);
118
+ __decorate([state(), __decorateMetadata("design:type", Object)], UIconButton.prototype, "slotText", void 0);
113
119
  UIconButton = __decorate([customElement("u-icon-button")], UIconButton);
114
120
  //#endregion
115
121
  export { UIconButton };
@@ -40,6 +40,8 @@ export type FieldSize = 'sm' | 'md' | 'lg';
40
40
  * 컨테이너 폭을 채우려면 `block`으로 지정한다.
41
41
  * @cssprop --u-input-width - 호스트의 width (기본값: auto). flex 컨테이너처럼 block만으로는
42
42
  * 늘어나지 않는 맥락에서 `100%`로 지정한다.
43
+ * @cssprop --input-min-text - 글자 영역의 최소 폭 (기본값: 4ch). 접미 아이콘(스테퍼·지우기·비밀번호 토글)이 폭을 나눠도 글자
44
+ * 영역은 이 아래로 접히지 않는다 — 주어진 폭이 그보다 좁으면 칸이 호스트 밖으로 넘친다.
43
45
  * @cssprop --input-popover-width - 드롭다운 팝오버의 너비 (기본값: 앵커(트리거) 너비)
44
46
  * @cssprop --input-popover-min-height - 드롭다운 팝오버의 최소 높이 (기본값: 0px)
45
47
  * @cssprop --input-popover-max-height - 드롭다운 팝오버의 최대 높이 (기본값: 50vh)
@@ -2,9 +2,9 @@ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/hel
2
2
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
3
3
  import { UFormControlElement } from "../UFormControlElement.js";
4
4
  import { isImeComposing } from "../../utilities/keyboard.js";
5
+ import { Locale } from "../../utilities/Locale.js";
5
6
  import "../spinner/USpinner.js";
6
7
  import "../icon/UIcon.js";
7
- import { Locale } from "../../utilities/Locale.js";
8
8
  import { parseNumber } from "../../utilities/format.js";
9
9
  import "../field/UField.js";
10
10
  import { UPopover } from "../popover/UPopover.js";
@@ -193,7 +193,8 @@ var UInput = class UInput extends UFormControlElement {
193
193
  .description=${this.description}
194
194
  .validationMessage=${this.validationMessage}
195
195
  >
196
- <div class="container" part="container">
196
+ <div class="container" part="container"
197
+ style=${`--_icons: ${(showStepper ? 2 : 0) + (showClear ? 1 : 0) + (showToggle ? 1 : 0)}`}>
197
198
 
198
199
  <slot name="prefix"></slot>
199
200
 
@@ -35,6 +35,17 @@ var styles = css`
35
35
  테두리 1px 위까지 닿는다. 패딩 상자에서 자르면 그 1px 이 눌리지 않는다(hidden 은 여백을 받지 않는다). */
36
36
  overflow: clip;
37
37
  overflow-clip-margin: 1px;
38
+ /* 글자 영역의 하한 — 고정 크기 접미 아이콘(스테퍼 둘 · 지우기 · 비밀번호 토글, 각 상자 = max(1.5em, 24px, 호스트 하한))이
39
+ 한 줄을 나눌 때, 주어진 폭이 좁으면 입력이 0 까지 접혀 값도 커서도 «보이지 않는» 채 정상처럼 그려졌다.
40
+ 하한 아래로는 칸이 호스트 밖으로 넘친다 — 보이는 실패다. 아이콘 수(--_icons)는 렌더가 정한다.
41
+ 입력의 고유 폭(size 기본 20자)이 intrinsic 계산을 지배하므로 min-content 로는 낼 수 없어 기하를 직접 더한다.
42
+ 접두·접미 슬롯 내용은 세지 않는다(폭을 모른다). 글자 하한은 --input-min-text 로 바꾼다. */
43
+ --_icon-box: max(1.5em, 24px, var(--u-target-size, 0px));
44
+ min-inline-size: calc(
45
+ 2px + var(--u-field-padding-inline, 0.6em) + var(--input-min-text, 4ch)
46
+ + var(--_icons, 0) * var(--_icon-box)
47
+ + max(var(--u-field-padding-inline, 0.6em), calc(var(--u-target-size, 0px) / 2 - 0.5em))
48
+ );
38
49
  }
39
50
  :host([readonly]) .container,
40
51
  :host(:disabled) .container {
@@ -38,9 +38,12 @@ export declare class UProgressBar extends UElement {
38
38
  buffer?: number;
39
39
  /** 현재값 */
40
40
  value: number;
41
+ /** 보조기기에 내놓는 역할·값(`progressbar`) — 호스트 속성이 이긴다. */
42
+ private readonly internals;
41
43
  private progress;
42
44
  private bufferProgress;
43
45
  protected willUpdate(changedProperties: PropertyValues): void;
46
+ protected updated(changedProperties: PropertyValues): void;
44
47
  render(): import('lit-html').TemplateResult<1>;
45
48
  private calcProgress;
46
49
  }
@@ -1,6 +1,7 @@
1
1
  import { UElement } from "../UElement.js";
2
2
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
+ import { attachProgressbar, syncProgressValue } from "../../utilities/progressAria.js";
4
5
  import { styles } from "./UProgressBar.styles.js";
5
6
  import { html } from "lit";
6
7
  import { customElement, property, state } from "lit/decorators.js";
@@ -17,6 +18,7 @@ var UProgressBar = class UProgressBar extends UElement {
17
18
  this.min = 0;
18
19
  this.max = 100;
19
20
  this.value = 0;
21
+ this.internals = attachProgressbar(this);
20
22
  this.progress = 0;
21
23
  this.bufferProgress = 0;
22
24
  }
@@ -35,6 +37,15 @@ var UProgressBar = class UProgressBar extends UElement {
35
37
  this.bufferProgress = this.buffer !== void 0 ? this.calcProgress(this.buffer) : 0;
36
38
  }
37
39
  }
40
+ updated(changedProperties) {
41
+ super.updated(changedProperties);
42
+ if ([
43
+ "min",
44
+ "max",
45
+ "value",
46
+ "indeterminate"
47
+ ].some((k) => changedProperties.has(k))) syncProgressValue(this.internals, this);
48
+ }
38
49
  render() {
39
50
  const hasBuffer = this.buffer !== void 0 && !this.indeterminate;
40
51
  const hasSegments = this.segments > 1;
@@ -35,11 +35,14 @@ export declare class UProgressRing extends UElement {
35
35
  buffer?: number;
36
36
  /** 현재값 */
37
37
  value: number;
38
+ /** 보조기기에 내놓는 역할·값(`progressbar`) — 호스트 속성이 이긴다. */
39
+ private readonly internals;
38
40
  private progress;
39
41
  private bufferProgress;
40
42
  private dasharray;
41
43
  private uuid;
42
44
  protected willUpdate(changedProperties: PropertyValues): void;
45
+ protected updated(changedProperties: PropertyValues): void;
43
46
  render(): import('lit-html').TemplateResult<1>;
44
47
  private calcProgress;
45
48
  private calcDasharray;
@@ -1,6 +1,7 @@
1
1
  import { UElement } from "../UElement.js";
2
2
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
+ import { attachProgressbar, syncProgressValue } from "../../utilities/progressAria.js";
4
5
  import { styles } from "./UProgressRing.styles.js";
5
6
  import { html } from "lit";
6
7
  import { customElement, property, state } from "lit/decorators.js";
@@ -18,6 +19,7 @@ var UProgressRing = class UProgressRing extends UElement {
18
19
  this.min = 0;
19
20
  this.max = 100;
20
21
  this.value = 0;
22
+ this.internals = attachProgressbar(this);
21
23
  this.progress = 0;
22
24
  this.bufferProgress = 0;
23
25
  this.dasharray = PATH_LENGTH.toString();
@@ -39,6 +41,15 @@ var UProgressRing = class UProgressRing extends UElement {
39
41
  }
40
42
  if (["segments", "segmentGap"].some((k) => changedProperties.has(k))) this.dasharray = this.calcDasharray(this.segments, this.segmentGap);
41
43
  }
44
+ updated(changedProperties) {
45
+ super.updated(changedProperties);
46
+ if ([
47
+ "min",
48
+ "max",
49
+ "value",
50
+ "indeterminate"
51
+ ].some((k) => changedProperties.has(k))) syncProgressValue(this.internals, this);
52
+ }
42
53
  render() {
43
54
  const hasBuffer = this.buffer !== void 0 && !this.indeterminate;
44
55
  const linecap = this.rounded ? "round" : "butt";
@@ -1,8 +1,8 @@
1
1
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
2
2
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
3
3
  import { UFormControlElement } from "../UFormControlElement.js";
4
- import "../icon/UIcon.js";
5
4
  import { Locale } from "../../utilities/Locale.js";
5
+ import "../icon/UIcon.js";
6
6
  import "../field/UField.js";
7
7
  import { styles } from "./URating.styles.js";
8
8
  import { html } from "lit";
@@ -121,6 +121,7 @@ var URating = class URating extends UFormControlElement {
121
121
  return html`
122
122
  <span class="symbol" part="symbol"
123
123
  role="radio"
124
+ aria-label=${String(score)}
124
125
  aria-checked=${score === Math.round(this.value || 0) ? "true" : "false"}
125
126
  aria-disabled=${this.interactive ? "false" : "true"}
126
127
  tabindex=${this.interactive ? "0" : "-1"}
@@ -1,9 +1,9 @@
1
1
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
2
2
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
3
3
  import { UFormControlElement } from "../UFormControlElement.js";
4
+ import { Locale } from "../../utilities/Locale.js";
4
5
  import "../spinner/USpinner.js";
5
6
  import "../icon/UIcon.js";
6
- import { Locale } from "../../utilities/Locale.js";
7
7
  import "../field/UField.js";
8
8
  import { UPopover } from "../popover/UPopover.js";
9
9
  import { UOption } from "../option/UOption.js";
@@ -19,6 +19,13 @@ export declare class USpinner extends UElement {
19
19
  /** 인디케이터 색상 */
20
20
  color?: SpinnerColor;
21
21
  private hasLabel;
22
+ /**
23
+ * 보조기기에는 «양을 모르는 진행»(`progressbar`, 값 없음). 이름은 슬롯 글자, 없으면 로케일의 `loading` — 회전하는
24
+ * 그림만으로는 무엇이 진행 중인지 들리지 않는다. 호스트의 `aria-label` 이 이긴다.
25
+ */
26
+ private readonly internals;
27
+ connectedCallback(): void;
28
+ private nameFrom;
22
29
  render(): import('lit-html').TemplateResult<1>;
23
30
  private handleSlotChange;
24
31
  }
@@ -2,6 +2,8 @@ import { UElement } from "../UElement.js";
2
2
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import { styles } from "./USpinner.styles.js";
5
+ import { attachProgressbar } from "../../utilities/progressAria.js";
6
+ import { Locale } from "../../utilities/Locale.js";
5
7
  import { html } from "lit";
6
8
  import { customElement, property, state } from "lit/decorators.js";
7
9
  //#region src/components/spinner/USpinner.ts
@@ -9,10 +11,18 @@ var USpinner = class USpinner extends UElement {
9
11
  constructor(..._args) {
10
12
  super(..._args);
11
13
  this.hasLabel = false;
14
+ this.internals = attachProgressbar(this);
12
15
  }
13
16
  static {
14
17
  this.styles = [super.styles, styles];
15
18
  }
19
+ connectedCallback() {
20
+ super.connectedCallback();
21
+ this.nameFrom("");
22
+ }
23
+ nameFrom(text) {
24
+ if (this.internals) this.internals.ariaLabel = text || Locale.getValue("loading");
25
+ }
16
26
  render() {
17
27
  return html`
18
28
  <svg class="spinner" part="svg">
@@ -20,7 +30,7 @@ var USpinner = class USpinner extends UElement {
20
30
  <circle class="indicator"></circle>
21
31
  </svg>
22
32
 
23
- <span class="label" part="label" ?hidden=${!this.hasLabel}>
33
+ <span class="label" part="label" ?hidden=${!this.hasLabel} aria-hidden="true">
24
34
  <slot @slotchange=${this.handleSlotChange}></slot>
25
35
  </span>
26
36
  `;
@@ -28,6 +38,7 @@ var USpinner = class USpinner extends UElement {
28
38
  handleSlotChange(e) {
29
39
  const nodes = e.target.assignedNodes({ flatten: true });
30
40
  this.hasLabel = nodes.some((node) => node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.TEXT_NODE && node.textContent?.trim() !== "");
41
+ this.nameFrom(nodes.map((n) => n.textContent ?? "").join(" ").replace(/\s+/g, " ").trim());
31
42
  }
32
43
  };
33
44
  __decorate([property({
@@ -2,8 +2,8 @@ import { UElement } from "../UElement.js";
2
2
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import { arrayAttrConverter } from "../../utilities/converters.js";
5
- import { devWarnOnce } from "../../utilities/devWarning.js";
6
5
  import { Locale } from "../../utilities/Locale.js";
6
+ import { devWarnOnce } from "../../utilities/devWarning.js";
7
7
  import { styles } from "./USplitPanel.styles.js";
8
8
  import { html } from "lit";
9
9
  import { customElement, property, query } from "lit/decorators.js";
@@ -47,6 +47,7 @@ var USwitch = class USwitch extends UFormControlElement {
47
47
  <label class="wrapper" part="wrapper">
48
48
  <input
49
49
  type="checkbox"
50
+ role="switch"
50
51
  aria-label=${ifDefined(this.contentAriaLabel)}
51
52
  ?disabled=${this.effectivelyDisabled || this.readonly}
52
53
  ?required=${this.required}
@@ -1,9 +1,9 @@
1
1
  import { UElement } from "../UElement.js";
2
2
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
+ import { Locale } from "../../utilities/Locale.js";
4
5
  import "../button/UButton.js";
5
6
  import "../icon/UIcon.js";
6
- import { Locale } from "../../utilities/Locale.js";
7
7
  import { styles } from "./UTab.styles.js";
8
8
  import { html } from "lit";
9
9
  import { customElement, property } from "lit/decorators.js";
@@ -51,6 +51,11 @@ export declare class UTreeItem extends UElement {
51
51
  get parentItem(): UTreeItem | null;
52
52
  private _childItems;
53
53
  get childItems(): readonly UTreeItem[];
54
+ /**
55
+ * 이름 = 자기 라벨(기본 슬롯)의 글자. 역할이 호스트에 있으므로 내용에서 이름을 계산하면 **자식 항목의 글자까지**
56
+ * 들어갔다(실측: 부모 이름 «Root Child»). 호스트의 `aria-label` 이 이긴다.
57
+ */
58
+ private readonly internals;
54
59
  connectedCallback(): void;
55
60
  protected updated(changedProperties: PropertyValues): void;
56
61
  render(): import('lit-html').TemplateResult<1>;
@@ -30,9 +30,15 @@ var UTreeItem = class UTreeItem extends UElement {
30
30
  this.indeterminate = false;
31
31
  this._parentItem = null;
32
32
  this._childItems = [];
33
+ this.internals = "attachInternals" in this ? this.attachInternals() : void 0;
33
34
  this.handleSlotChange = (e) => {
34
- const elements = e.target.assignedElements({ flatten: true });
35
+ const slot = e.target;
36
+ const elements = slot.assignedElements({ flatten: true });
35
37
  for (const el of elements) if (el instanceof _UTreeItem && !el.hasAttribute("slot")) el.setAttribute("slot", "children");
38
+ if (this.internals) {
39
+ const text = slot.assignedNodes({ flatten: true }).filter((n) => !(n instanceof _UTreeItem)).map((n) => n.textContent ?? "").join(" ").replace(/\s+/g, " ").trim();
40
+ this.internals.ariaLabel = text || null;
41
+ }
36
42
  };
37
43
  this.handleChildrenSlotChange = (e) => {
38
44
  const slot = e.target;
@@ -90,7 +96,26 @@ var UTreeItem = class UTreeItem extends UElement {
90
96
  if (this.disabled) this.setAttribute("aria-disabled", "true");
91
97
  else this.removeAttribute("aria-disabled");
92
98
  }
93
- if (changedProperties.has("depth")) this.style.setProperty("--tree-item-depth", String(this.depth));
99
+ if (changedProperties.has("depth")) {
100
+ this.style.setProperty("--tree-item-depth", String(this.depth));
101
+ this.setAttribute("aria-level", String(this.depth + 1));
102
+ }
103
+ if (changedProperties.has("expanded") || changedProperties.has("leaf")) {
104
+ if (this.leaf) this.removeAttribute("aria-expanded");
105
+ else this.setAttribute("aria-expanded", this.expanded ? "true" : "false");
106
+ }
107
+ if (changedProperties.has("selected") || changedProperties.has("selectable")) {
108
+ if (this.selectable) this.setAttribute("aria-selected", this.selected ? "true" : "false");
109
+ else this.removeAttribute("aria-selected");
110
+ }
111
+ if ([
112
+ "checked",
113
+ "indeterminate",
114
+ "checkable"
115
+ ].some((k) => changedProperties.has(k))) {
116
+ if (this.checkable) this.setAttribute("aria-checked", this.indeterminate ? "mixed" : this.checked ? "true" : "false");
117
+ else this.removeAttribute("aria-checked");
118
+ }
94
119
  }
95
120
  render() {
96
121
  return html`
package/dist/index.js CHANGED
@@ -6,12 +6,12 @@ import { isImeComposing } from "./utilities/keyboard.js";
6
6
  import { OverlayManager } from "./utilities/OverlayManager.js";
7
7
  import { arrayAttrConverter, booleanAttrConverter, dateAttrConverter, jsonAttrConverter, urlAttrConverter } from "./utilities/converters.js";
8
8
  import { UOverlayElement } from "./components/UOverlayElement.js";
9
+ import { Locale } from "./utilities/Locale.js";
9
10
  import { USpinner } from "./components/spinner/USpinner.js";
10
11
  import { UButton } from "./components/button/UButton.js";
11
12
  import { IconCache, IconRegistry, getDefaultBaseUrl, setDefaultBaseUrl } from "./utilities/icons.js";
12
13
  import { createDevWarner, devWarnOnce, resetDevWarnings } from "./utilities/devWarning.js";
13
14
  import { UIcon } from "./components/icon/UIcon.js";
14
- import { Locale } from "./utilities/Locale.js";
15
15
  import { ALERT_STATUSES, UAlert } from "./components/alert/UAlert.js";
16
16
  import { UAvatar } from "./components/avatar/UAvatar.js";
17
17
  import { UBadge } from "./components/badge/UBadge.js";
@@ -88,6 +88,8 @@ export declare class Dialog {
88
88
  * @returns 클릭된 액션의 value 또는 닫힌 경우 null
89
89
  */
90
90
  static show(options: CustomDialogOptions): Promise<string | null>;
91
+ /** `show` 의 본체 — `decorate` 는 `alert`·`confirm`·`prompt` 가 렌더 뒤 접근성 이름·설명을 잇는 자리다. */
92
+ private static present;
91
93
  /** 다이얼로그 엘리먼트를 생성하고 옵션을 적용합니다. */
92
94
  private static createDialog;
93
95
  }
@@ -1,6 +1,6 @@
1
1
  import { isImeComposing } from "./keyboard.js";
2
- import "../components/button/UButton.js";
3
2
  import { Locale } from "./Locale.js";
3
+ import "../components/button/UButton.js";
4
4
  import { UDialog } from "../components/dialog/UDialog.js";
5
5
  import "../components/input/UInput.js";
6
6
  import { html, nothing, render } from "lit";
@@ -10,9 +10,23 @@ import { unsafeHTML } from "lit/directives/unsafe-html.js";
10
10
  /**
11
11
  * 메시지를 본문 템플릿으로 — 문자열은 lit 이 글자로 이스케이프한다. `show` 는 문자열 `content` 를 HTML 로 해석하므로
12
12
  * (그것이 `show` 의 계약이다) `alert`·`confirm` 이 문자열을 그대로 넘기면 그 계약을 조용히 물려받아 마크업 주입 싱크가 된다.
13
+ *
14
+ * 메시지 상자에는 id 를 준다 — 대화상자의 이름(제목이 없을 때)이나 설명(제목이 있을 때)으로 잇는다.
13
15
  */
14
- function asText(message) {
15
- return html`${message}`;
16
+ function asText(message, id) {
17
+ return html`<div id=${id}>${message}</div>`;
18
+ }
19
+ var messageSeq = 0;
20
+ var nextMessageId = () => `u-dialog-message-${++messageSeq}`;
21
+ /**
22
+ * 보조기기가 듣는 대화상자의 이름과 설명 — 제목이 있으면 제목이 이름이고 메시지가 설명이다(APG Alert Dialog).
23
+ * 제목이 없으면 메시지가 이름이다 — 이름 없는 대화상자는 «대화상자» 라는 말만 남긴다.
24
+ */
25
+ function describe(dialog, messageId, role) {
26
+ if (role === "alertdialog") dialog.setAttribute("role", "alertdialog");
27
+ const titleId = dialog.querySelector(":scope > [slot=\"header\"]")?.id;
28
+ dialog.setAttribute("aria-labelledby", titleId || messageId);
29
+ if (titleId) dialog.setAttribute("aria-describedby", messageId);
16
30
  }
17
31
  /**
18
32
  * Dialog 유틸리티 클래스입니다.
@@ -27,10 +41,11 @@ var Dialog = class {
27
41
  * `TemplateResult`(`html\`…\``)를 넘긴다. HTML 문자열은 그것을 명시한 `show({ content })` 로만.
28
42
  */
29
43
  static async alert(message, options) {
30
- await this.show({
44
+ const messageId = nextMessageId();
45
+ await this.present({
31
46
  ...options,
32
- content: asText(message)
33
- });
47
+ content: asText(message, messageId)
48
+ }, (dialog) => describe(dialog, messageId, "alertdialog"));
34
49
  }
35
50
  /**
36
51
  * 확인 다이얼로그를 표시합니다. (확인/취소 버튼)
@@ -38,9 +53,10 @@ var Dialog = class {
38
53
  * @returns 확인이면 true, 취소이면 false
39
54
  */
40
55
  static async confirm(message, options) {
41
- return await this.show({
56
+ const messageId = nextMessageId();
57
+ return await this.present({
42
58
  ...options,
43
- content: asText(message),
59
+ content: asText(message, messageId),
44
60
  actions: [{
45
61
  label: options?.cancelLabel || Locale.getValue("cancel"),
46
62
  value: "cancel",
@@ -50,7 +66,7 @@ var Dialog = class {
50
66
  value: "confirm",
51
67
  color: options?.confirmColor
52
68
  }]
53
- }) === "confirm";
69
+ }, (dialog) => describe(dialog, messageId, "alertdialog")) === "confirm";
54
70
  }
55
71
  /**
56
72
  * 입력 다이얼로그를 표시합니다. (텍스트 입력 + 확인/취소)
@@ -58,11 +74,12 @@ var Dialog = class {
58
74
  */
59
75
  static async prompt(message, options) {
60
76
  let inputValue = options?.defaultValue || "";
61
- return await this.show({
77
+ const messageId = nextMessageId();
78
+ return await this.present({
62
79
  ...options,
63
80
  content: html`
64
81
  <div style="display: flex; flex-direction: column; gap: 12px;">
65
- <div>${message}</div>
82
+ <div id=${messageId}>${message}</div>
66
83
  <u-input
67
84
  type=${options?.type || "text"}
68
85
  placeholder=${options?.placeholder || ""}
@@ -89,13 +106,17 @@ var Dialog = class {
89
106
  label: options?.confirmLabel || Locale.getValue("confirm"),
90
107
  value: "confirm"
91
108
  }]
92
- }) === "confirm" ? inputValue : null;
109
+ }, (dialog) => describe(dialog, messageId, "dialog")) === "confirm" ? inputValue : null;
93
110
  }
94
111
  /**
95
112
  * 커스텀 다이얼로그를 표시합니다.
96
113
  * @returns 클릭된 액션의 value 또는 닫힌 경우 null
97
114
  */
98
- static async show(options) {
115
+ static show(options) {
116
+ return this.present(options);
117
+ }
118
+ /** `show` 의 본체 — `decorate` 는 `alert`·`confirm`·`prompt` 가 렌더 뒤 접근성 이름·설명을 잇는 자리다. */
119
+ static async present(options, decorate) {
99
120
  let closeValue = null;
100
121
  const dialog = this.createDialog(options);
101
122
  const content = typeof options.content === "string" ? unsafeHTML(options.content) : options.content;
@@ -119,6 +140,7 @@ var Dialog = class {
119
140
  ` : nothing}
120
141
  </div>
121
142
  `, dialog);
143
+ decorate?.(dialog);
122
144
  (options.target || document.body).appendChild(dialog);
123
145
  const closed = new Promise((resolve) => {
124
146
  dialog.addEventListener("hide", (e) => {
@@ -152,6 +174,7 @@ var Dialog = class {
152
174
  dialog.closeOn = closeOn;
153
175
  if (options?.title) {
154
176
  const header = document.createElement("span");
177
+ header.id = `u-dialog-title-${++messageSeq}`;
155
178
  header.slot = "header";
156
179
  header.textContent = options.title;
157
180
  dialog.prepend(header);
@@ -12,7 +12,7 @@ export type SupportedLocale = 'en' | 'ko' | 'ja' | 'zh-CN' | 'zh-TW' | 'es' | 'f
12
12
  /** 내장 로케일은 자동완성되지만, 임의의 BCP47 태그도 그대로 받는다. */
13
13
  export type LocaleTag = SupportedLocale | (string & {});
14
14
  /** 라이브러리가 제공하는 chrome 문자열 키. 지금은 검증 메시지뿐이지만 이후 다른 UI 문구도 추가될 수 있다. */
15
- export type LocaleMessageKey = 'valueMissing' | 'badInput' | 'typeMismatch' | 'patternMismatch' | 'rangeUnderflow' | 'rangeOverflow' | 'stepMismatch' | 'tooShort' | 'tooLong' | 'increment' | 'decrement' | 'clear' | 'today' | 'time' | 'showPassword' | 'hidePassword' | 'previousSlide' | 'nextSlide' | 'goToSlide' | 'stopSlideRotation' | 'startSlideRotation' | 'chooseDate' | 'chooseDateRange' | 'yesterday' | 'last7Days' | 'last30Days' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'quickRanges' | 'rangeStartChosen' | 'previousMonth' | 'nextMonth' | 'close' | 'copy' | 'copied' | 'chooseFile' | 'noFileChosen' | 'filesSelected' | 'resizePanels' | 'breadcrumb' | 'search' | 'alertError' | 'alertWarning' | 'alertSuccess' | 'alertInfo' | 'alertNotice' | 'alertMessage' | 'remove' | 'closeTab' | 'confirm' | 'cancel' | 'stepComplete' | 'stepOnHold' | 'apply' | 'dateUnavailable' | 'startTime' | 'endTime' | 'timeAm' | 'timePm';
15
+ export type LocaleMessageKey = 'valueMissing' | 'badInput' | 'typeMismatch' | 'patternMismatch' | 'rangeUnderflow' | 'rangeOverflow' | 'stepMismatch' | 'tooShort' | 'tooLong' | 'increment' | 'decrement' | 'clear' | 'today' | 'time' | 'showPassword' | 'hidePassword' | 'previousSlide' | 'nextSlide' | 'goToSlide' | 'stopSlideRotation' | 'startSlideRotation' | 'chooseDate' | 'chooseDateRange' | 'yesterday' | 'last7Days' | 'last30Days' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'quickRanges' | 'rangeStartChosen' | 'previousMonth' | 'nextMonth' | 'close' | 'copy' | 'copied' | 'chooseFile' | 'noFileChosen' | 'filesSelected' | 'resizePanels' | 'loading' | 'breadcrumb' | 'search' | 'alertError' | 'alertWarning' | 'alertSuccess' | 'alertInfo' | 'alertNotice' | 'alertMessage' | 'remove' | 'closeTab' | 'confirm' | 'cancel' | 'stepComplete' | 'stepOnHold' | 'apply' | 'dateUnavailable' | 'startTime' | 'endTime' | 'timeAm' | 'timePm';
16
16
  type LocaleTable = Record<LocaleMessageKey, string>;
17
17
  /**
18
18
  * 한 패키지(또는 앱 영역)의 문자열 묶음.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 진행 표시(`u-progress-bar`·`u-progress-ring`·`u-spinner`)를 보조기기에 `progressbar` 로 내놓는다.
3
+ *
4
+ * 그리는 막대·고리만 있고 역할이 없으면 보조기기에는 아무것도 없다 — 진행 중이라는 사실도, 몇 % 인지도.
5
+ * 역할과 값은 `ElementInternals` 기본값이라 호스트에 단 `role`·`aria-*` 속성이 이긴다. 값이 정해지지 않은
6
+ * 진행(`indeterminate`·스피너)은 `aria-valuenow` 를 두지 않는다 — WAI-ARIA 의 «진행 중, 양은 모름» 표기.
7
+ */
8
+ export declare function attachProgressbar(host: HTMLElement): ElementInternals | undefined;
9
+ export declare function syncProgressValue(internals: ElementInternals | undefined, state: {
10
+ indeterminate: boolean;
11
+ value: number;
12
+ min: number;
13
+ max: number;
14
+ }): void;
@@ -0,0 +1,22 @@
1
+ //#region src/utilities/progressAria.ts
2
+ /**
3
+ * 진행 표시(`u-progress-bar`·`u-progress-ring`·`u-spinner`)를 보조기기에 `progressbar` 로 내놓는다.
4
+ *
5
+ * 그리는 막대·고리만 있고 역할이 없으면 보조기기에는 아무것도 없다 — 진행 중이라는 사실도, 몇 % 인지도.
6
+ * 역할과 값은 `ElementInternals` 기본값이라 호스트에 단 `role`·`aria-*` 속성이 이긴다. 값이 정해지지 않은
7
+ * 진행(`indeterminate`·스피너)은 `aria-valuenow` 를 두지 않는다 — WAI-ARIA 의 «진행 중, 양은 모름» 표기.
8
+ */
9
+ function attachProgressbar(host) {
10
+ if (!("attachInternals" in host)) return void 0;
11
+ const internals = host.attachInternals();
12
+ internals.role = "progressbar";
13
+ return internals;
14
+ }
15
+ function syncProgressValue(internals, state) {
16
+ if (!internals) return;
17
+ internals.ariaValueMin = String(state.min);
18
+ internals.ariaValueMax = String(state.max);
19
+ internals.ariaValueNow = state.indeterminate ? null : String(Math.max(state.min, Math.min(state.max, state.value)));
20
+ }
21
+ //#endregion
22
+ export { attachProgressbar, syncProgressValue };
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.3.1",
4
+ "version": "2.5.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -44,6 +44,13 @@ u-dialog { height: 400px; } /* the panel then caps at 360px */
44
44
  ⚠ That lever only shrinks: a height on the host lowers the panel's maximum, it does not reserve a
45
45
  panel of that size. A short dialog stays short.
46
46
 
47
+ ## Accessibility
48
+
49
+ The host is exposed as a **`dialog`**, with `aria-modal` when `mode="modal"`. Its name is whatever sits in the
50
+ `header` slot, and follows that content as it changes. Without a header, name it with `aria-label` (or
51
+ `aria-labelledby`) on the host — attributes on the host override the defaults, including `role="alertdialog"` for a
52
+ message that needs a response.
53
+
47
54
  ## Slots
48
55
 
49
56
  | Name | Description |
@@ -20,6 +20,11 @@ Side panel that slides in from any screen edge. Extends `UOverlayElement` (focus
20
20
 
21
21
  ---
22
22
 
23
+ ## Accessibility
24
+
25
+ Same as `u-dialog`: exposed as a **`dialog`** (`aria-modal` when modal), named by the `header` slot, or by
26
+ `aria-label`/`aria-labelledby` on the host.
27
+
23
28
  ## Slots
24
29
 
25
30
  | Name | Description |
@@ -35,7 +35,7 @@ No drag-and-drop in this version — it is a minimal wrapper (trigger + status +
35
35
 
36
36
  | Property | Type | Default | Reflect | Description |
37
37
  |----------|------|---------|---------|-------------|
38
- | `value` | `File[] \| null` | `null` | — | Selected files (always an array, even for single-file selection) |
38
+ | `value` | `File[] \| null` | `null` | — | Selected files (always an array, even for single-file selection). Setting it to `null` (or `[]`) clears the native input as `reset()` does, so the same file can be picked again |
39
39
  | `accept` | `string` | — | — | Passed through to the native `accept` attribute |
40
40
  | `multiple` | `boolean` | `false` | ✓ | Allow selecting more than one file |
41
41
  | `disabled` | `boolean` | `false` | ✓ | Disable the control |