@iyulab/components 2.33.0 → 2.35.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 (91) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +1 -1
  3. package/dist/assets/locales/ar.json.js +3 -1
  4. package/dist/assets/locales/de.json.js +3 -1
  5. package/dist/assets/locales/en.json.js +3 -1
  6. package/dist/assets/locales/es.json.js +3 -1
  7. package/dist/assets/locales/fr.json.js +3 -1
  8. package/dist/assets/locales/id.json.js +3 -1
  9. package/dist/assets/locales/ja.json.js +3 -1
  10. package/dist/assets/locales/ko.json.js +3 -1
  11. package/dist/assets/locales/pt-BR.json.js +3 -1
  12. package/dist/assets/locales/ru.json.js +3 -1
  13. package/dist/assets/locales/th.json.js +3 -1
  14. package/dist/assets/locales/vi.json.js +3 -1
  15. package/dist/assets/locales/zh-CN.json.js +3 -1
  16. package/dist/assets/locales/zh-TW.json.js +3 -1
  17. package/dist/components/UOverlayElement.d.ts +2 -0
  18. package/dist/components/UOverlayElement.js +6 -0
  19. package/dist/components/auto-scroll/UAutoScroll.d.ts +26 -0
  20. package/dist/components/auto-scroll/UAutoScroll.js +55 -2
  21. package/dist/components/badge/UBadge.d.ts +2 -0
  22. package/dist/components/badge/UBadge.js +4 -2
  23. package/dist/components/badge/UBadge.styles.js +11 -2
  24. package/dist/components/breadcrumb-item/UBreadcrumbItem.d.ts +2 -0
  25. package/dist/components/breadcrumb-item/UBreadcrumbItem.js +6 -4
  26. package/dist/components/breadcrumb-item/UBreadcrumbItem.styles.js +11 -2
  27. package/dist/components/button/UButton.d.ts +2 -0
  28. package/dist/components/button/UButton.js +4 -2
  29. package/dist/components/button/UButton.styles.js +11 -2
  30. package/dist/components/carousel/UCarousel.d.ts +56 -1
  31. package/dist/components/carousel/UCarousel.js +97 -8
  32. package/dist/components/command-palette/UCommandPalette.d.ts +126 -0
  33. package/dist/components/command-palette/UCommandPalette.js +260 -0
  34. package/dist/components/command-palette/UCommandPalette.styles.d.ts +1 -0
  35. package/dist/components/command-palette/UCommandPalette.styles.js +142 -0
  36. package/dist/components/dialog/UDialog.d.ts +3 -0
  37. package/dist/components/dialog/UDialog.js +8 -1
  38. package/dist/components/dialog/UDialog.styles.js +10 -3
  39. package/dist/components/drawer/UDrawer.d.ts +3 -0
  40. package/dist/components/drawer/UDrawer.js +8 -1
  41. package/dist/components/drawer/UDrawer.styles.js +10 -3
  42. package/dist/components/input/UInput.d.ts +2 -0
  43. package/dist/components/input/UInput.js +4 -2
  44. package/dist/components/input/UInput.styles.js +11 -2
  45. package/dist/components/menu-item/UMenuItem.d.ts +2 -0
  46. package/dist/components/menu-item/UMenuItem.js +4 -2
  47. package/dist/components/menu-item/UMenuItem.styles.js +11 -2
  48. package/dist/components/option/UOption.d.ts +2 -0
  49. package/dist/components/option/UOption.js +4 -2
  50. package/dist/components/option/UOption.styles.js +16 -2
  51. package/dist/components/radio/URadio.styles.js +5 -2
  52. package/dist/components/select/USelect.d.ts +36 -2
  53. package/dist/components/select/USelect.js +184 -45
  54. package/dist/components/select/USelect.styles.js +65 -22
  55. package/dist/components/steps/USteps.d.ts +14 -3
  56. package/dist/components/steps/USteps.js +12 -2
  57. package/dist/components/steps/USteps.styles.js +53 -0
  58. package/dist/components/tab/UTab.d.ts +11 -3
  59. package/dist/components/tab/UTab.js +12 -5
  60. package/dist/components/tab/UTab.styles.js +37 -2
  61. package/dist/components/tab-nav/UTabNav.d.ts +10 -1
  62. package/dist/components/tab-nav/UTabNav.js +5 -0
  63. package/dist/components/tab-nav/UTabNav.styles.js +24 -1
  64. package/dist/components/tab-panel/UTabPanel.styles.js +14 -14
  65. package/dist/components/tree-item/UTreeItem.d.ts +2 -0
  66. package/dist/components/tree-item/UTreeItem.js +4 -2
  67. package/dist/components/tree-item/UTreeItem.styles.js +11 -2
  68. package/dist/index.d.ts +1 -0
  69. package/dist/index.js +2 -1
  70. package/dist/react/UCarousel.d.ts +3 -1
  71. package/dist/react/UCarousel.js +3 -1
  72. package/dist/react/UCommandPalette.d.ts +20 -0
  73. package/dist/react/UCommandPalette.js +14 -0
  74. package/dist/react/index.d.ts +1 -0
  75. package/dist/react/index.js +1 -0
  76. package/dist/utilities/Locale.d.ts +1 -1
  77. package/dist/utilities/slotPresence.d.ts +21 -0
  78. package/dist/utilities/slotPresence.js +41 -0
  79. package/dist/utilities/unattended.d.ts +5 -0
  80. package/dist/utilities/unattended.js +7 -0
  81. package/package.json +1 -1
  82. package/skills/iyulab-components/SKILL.md +1 -0
  83. package/skills/iyulab-components/references/components/auto-scroll.md +24 -2
  84. package/skills/iyulab-components/references/components/carousel.md +40 -1
  85. package/skills/iyulab-components/references/components/command-palette.md +96 -0
  86. package/skills/iyulab-components/references/components/dialog.md +1 -0
  87. package/skills/iyulab-components/references/components/drawer.md +1 -0
  88. package/skills/iyulab-components/references/components/select.md +16 -11
  89. package/skills/iyulab-components/references/components/steps.md +16 -1
  90. package/skills/iyulab-components/references/components/tab-nav.md +19 -1
  91. package/skills/iyulab-components/references/components/tab-panel.md +1 -1
@@ -3,22 +3,29 @@ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.155.0/hel
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
4
4
  import { HostAria } from "../../utilities/hostAria.js";
5
5
  import { styles } from "./UAutoScroll.styles.js";
6
+ import { UNATTENDED_IDLE_MS } from "../../utilities/unattended.js";
6
7
  import { html } from "lit";
7
8
  import { customElement, property } from "lit/decorators.js";
8
9
  // src/components/auto-scroll/UAutoScroll.ts
10
+ /** `item` 에서 다음 항목까지 미끄러지는 시간(ms) — 읽히는 것은 멈춘 동안이라 짧고 일정하게 둔다. */
11
+ var ITEM_GLIDE_MS = 600;
9
12
  var UAutoScroll = class UAutoScroll extends UElement {
10
13
  constructor(..._args) {
11
14
  super(..._args);
15
+ this.mode = "continuous";
12
16
  this.speed = 30;
13
17
  this.duration = 0;
14
18
  this.pause = 3e3;
15
19
  this.paused = false;
20
+ this.unattended = false;
21
+ this.resumeDelay = UNATTENDED_IDLE_MS;
16
22
  this.aria = new HostAria(this);
17
23
  this.waitUntil = 0;
18
24
  this.phase = "top";
19
25
  this.legFrom = 0;
20
26
  this.hovered = false;
21
27
  this.focused = false;
28
+ this.lastActivity = 0;
22
29
  this.visible = false;
23
30
  this.tick = (time) => {
24
31
  this.frame = requestAnimationFrame(this.tick);
@@ -35,8 +42,22 @@ var UAutoScroll = class UAutoScroll extends UElement {
35
42
  if (this.legStart === void 0) {
36
43
  this.legStart = time;
37
44
  this.legFrom = this.scrollTop;
45
+ if (this.mode === "item") this.legTo = this.nextItemTop();
38
46
  }
39
47
  const end = this.scrollHeight - this.clientHeight;
48
+ if (this.mode === "item") {
49
+ const to = Math.min(end, this.legTo ?? end);
50
+ const t = Math.min(1, (time - this.legStart) / ITEM_GLIDE_MS);
51
+ const eased = 1 - (1 - t) ** 3;
52
+ this.scrollTop = this.legFrom + (to - this.legFrom) * eased;
53
+ if (t >= 1) {
54
+ this.scrollTop = to;
55
+ this.legStart = void 0;
56
+ this.waitUntil = time + this.pause;
57
+ if (to >= end - 1) this.phase = "end";
58
+ }
59
+ return;
60
+ }
40
61
  const position = Math.min(end, this.legFrom + this.pace(end - this.legFrom) * (time - this.legStart) / 1e3);
41
62
  this.scrollTop = position;
42
63
  if (position >= end) {
@@ -54,8 +75,14 @@ var UAutoScroll = class UAutoScroll extends UElement {
54
75
  this.onPointerLeave = () => {
55
76
  this.hovered = false;
56
77
  };
57
- this.onFocusIn = () => {
78
+ this.onFocusIn = (e) => {
79
+ const origin = e.composedPath()[0];
80
+ if (this.unattended && !(origin instanceof Element && origin.matches(":focus-visible"))) return;
58
81
  this.focused = true;
82
+ this.lastActivity = performance.now();
83
+ };
84
+ this.onActivity = () => {
85
+ this.lastActivity = performance.now();
59
86
  };
60
87
  this.onFocusOut = (e) => {
61
88
  if (!this.contains(e.relatedTarget)) this.focused = false;
@@ -71,6 +98,8 @@ var UAutoScroll = class UAutoScroll extends UElement {
71
98
  this.addEventListener("pointerleave", this.onPointerLeave);
72
99
  this.addEventListener("focusin", this.onFocusIn);
73
100
  this.addEventListener("focusout", this.onFocusOut);
101
+ this.addEventListener("keydown", this.onActivity);
102
+ this.addEventListener("pointerdown", this.onActivity);
74
103
  this.intersection = new IntersectionObserver((entries) => {
75
104
  const now = entries.some((e) => e.isIntersecting);
76
105
  if (now && !this.visible) this.restart();
@@ -90,6 +119,8 @@ var UAutoScroll = class UAutoScroll extends UElement {
90
119
  this.removeEventListener("pointerleave", this.onPointerLeave);
91
120
  this.removeEventListener("focusin", this.onFocusIn);
92
121
  this.removeEventListener("focusout", this.onFocusOut);
122
+ this.removeEventListener("keydown", this.onActivity);
123
+ this.removeEventListener("pointerdown", this.onActivity);
93
124
  super.disconnectedCallback();
94
125
  }
95
126
  /** 맨 위로 돌아가 한 바퀴를 처음부터 시작한다. */
@@ -106,7 +137,17 @@ var UAutoScroll = class UAutoScroll extends UElement {
106
137
  return this.scrollHeight - this.clientHeight > 1;
107
138
  }
108
139
  get moving() {
109
- return !this.paused && !this.hovered && !this.focused && this.visible && !this.reducedMotion?.matches;
140
+ const held = this.unattended ? this.focused && performance.now() - this.lastActivity < this.resumeDelay : this.hovered || this.focused;
141
+ return !this.paused && !held && this.visible && !this.reducedMotion?.matches;
142
+ }
143
+ /** 지금 위치 다음 항목의 윗변(스크롤 좌표). 없으면 끝. */
144
+ nextItemTop() {
145
+ const end = this.scrollHeight - this.clientHeight;
146
+ let items = this.renderRoot.querySelector("slot")?.assignedElements({ flatten: true }) ?? [];
147
+ while (items.length === 1 && items[0].children.length > 0) items = [...items[0].children];
148
+ const origin = this.getBoundingClientRect().top - this.scrollTop + this.clientTop;
149
+ const next = items.map((el) => el.getBoundingClientRect().top - origin).sort((a, b) => a - b).find((top) => top > this.scrollTop + 1);
150
+ return next === void 0 ? end : Math.min(end, next);
110
151
  }
111
152
  /** px/초 — `duration` 이 있으면 남은 거리를 그 시간에서 두 번의 멈춤을 뺀 동안에 간다(최소 1초). */
112
153
  pace(distance) {
@@ -115,6 +156,10 @@ var UAutoScroll = class UAutoScroll extends UElement {
115
156
  return Math.max(1, distance) / (travel / 1e3);
116
157
  }
117
158
  };
159
+ __decorate([property({
160
+ type: String,
161
+ reflect: true
162
+ }), __decorateMetadata("design:type", Object)], UAutoScroll.prototype, "mode", void 0);
118
163
  __decorate([property({ type: Number }), __decorateMetadata("design:type", Object)], UAutoScroll.prototype, "speed", void 0);
119
164
  __decorate([property({ type: Number }), __decorateMetadata("design:type", Object)], UAutoScroll.prototype, "duration", void 0);
120
165
  __decorate([property({ type: Number }), __decorateMetadata("design:type", Object)], UAutoScroll.prototype, "pause", void 0);
@@ -122,5 +167,13 @@ __decorate([property({
122
167
  type: Boolean,
123
168
  reflect: true
124
169
  }), __decorateMetadata("design:type", Object)], UAutoScroll.prototype, "paused", void 0);
170
+ __decorate([property({
171
+ type: Boolean,
172
+ reflect: true
173
+ }), __decorateMetadata("design:type", Object)], UAutoScroll.prototype, "unattended", void 0);
174
+ __decorate([property({
175
+ type: Number,
176
+ attribute: "resume-delay"
177
+ }), __decorateMetadata("design:type", Object)], UAutoScroll.prototype, "resumeDelay", void 0);
125
178
  UAutoScroll = __decorate([customElement("u-auto-scroll")], UAutoScroll);
126
179
  export { UAutoScroll };
@@ -16,6 +16,8 @@ export type BadgeAnchor = "top-right" | "top-left" | "bottom-right" | "bottom-le
16
16
  */
17
17
  export declare class UBadge extends UElement {
18
18
  static styles: import('lit').CSSResultGroup[];
19
+ /** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
20
+ private readonly affixes;
19
21
  /** 배지 유형 */
20
22
  shape: BadgeShape;
21
23
  /** 배지 색상 */
@@ -1,6 +1,7 @@
1
1
  import { UElement } from "../UElement.js";
2
2
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
4
+ import { SlotPresence } from "../../utilities/slotPresence.js";
4
5
  import "../icon/UIcon.js";
5
6
  import { statusIcon } from "../../utilities/statusIcon.js";
6
7
  import { styles } from "./UBadge.styles.js";
@@ -10,6 +11,7 @@ import { customElement, property } from "lit/decorators.js";
10
11
  var UBadge = class UBadge extends UElement {
11
12
  constructor(..._args) {
12
13
  super(..._args);
14
+ this.affixes = new SlotPresence(this, ["prefix", "suffix"]);
13
15
  this.shape = "pill";
14
16
  this.color = "blue";
15
17
  this.icon = false;
@@ -23,9 +25,9 @@ var UBadge = class UBadge extends UElement {
23
25
  return html`
24
26
  <div class="base" part="base">
25
27
  ${iconName ? html`<u-icon class="icon" part="icon" lib="internal" name=${iconName}></u-icon>` : nothing}
26
- <slot name="prefix"></slot>
28
+ <span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
27
29
  <slot></slot>
28
- <slot name="suffix"></slot>
30
+ <span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
29
31
  </div>
30
32
  `;
31
33
  }
@@ -151,10 +151,19 @@ var styles = css`
151
151
  }
152
152
 
153
153
 
154
- ::slotted([slot="prefix"]) {
154
+
155
+ .affix {
156
+ display: inline-flex;
157
+ align-items: center;
158
+ flex: none;
159
+ }
160
+ .affix[hidden] {
161
+ display: none;
162
+ }
163
+ .affix-prefix {
155
164
  margin-right: 0.25em;
156
165
  }
157
- ::slotted([slot="suffix"]) {
166
+ .affix-suffix {
158
167
  margin-left: 0.25em;
159
168
  }
160
169
  `;
@@ -12,6 +12,8 @@ import { UElement } from '../UElement.js';
12
12
  */
13
13
  export declare class UBreadcrumbItem extends UElement {
14
14
  static styles: import('lit').CSSResultGroup[];
15
+ /** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
16
+ private readonly affixes;
15
17
  /** 호스트의 `.focus()` 를 안쪽 컨트롤로 위임한다 — `UButton` 과 같은 계약(호스트는 포커스 가능하지 않다). */
16
18
  static shadowRootOptions: ShadowRootInit;
17
19
  /** 비활성화 상태 */
@@ -1,6 +1,7 @@
1
1
  import { UElement } from "../UElement.js";
2
2
  import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";
3
3
  import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
4
+ import { SlotPresence } from "../../utilities/slotPresence.js";
4
5
  import { styles } from "./UBreadcrumbItem.styles.js";
5
6
  import { html } from "lit";
6
7
  import { customElement, property } from "lit/decorators.js";
@@ -9,6 +10,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
9
10
  var UBreadcrumbItem = class UBreadcrumbItem extends UElement {
10
11
  constructor(..._args) {
11
12
  super(..._args);
13
+ this.affixes = new SlotPresence(this, ["prefix", "suffix"]);
12
14
  this.disabled = false;
13
15
  this.handleAnchorClick = (e) => {
14
16
  if (this.disabled) {
@@ -36,14 +38,14 @@ var UBreadcrumbItem = class UBreadcrumbItem extends UElement {
36
38
  rel=${ifDefined(this.rel)}
37
39
  @click=${this.handleAnchorClick}
38
40
  >
39
- <slot name="prefix"></slot>
41
+ <span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
40
42
  <slot></slot>
41
- <slot name="suffix"></slot>
43
+ <span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
42
44
  </a>`;
43
45
  return html`
44
- <slot name="prefix"></slot>
46
+ <span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
45
47
  <slot></slot>
46
- <slot name="suffix"></slot>
48
+ <span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
47
49
  `;
48
50
  }
49
51
  };
@@ -34,10 +34,19 @@ var styles = css`
34
34
  cursor: inherit;
35
35
  }
36
36
 
37
- ::slotted([slot="prefix"]) {
37
+
38
+ .affix {
39
+ display: inline-flex;
40
+ align-items: center;
41
+ flex: none;
42
+ }
43
+ .affix[hidden] {
44
+ display: none;
45
+ }
46
+ .affix-prefix {
38
47
  margin-right: 0.2em;
39
48
  }
40
- ::slotted([slot="suffix"]) {
49
+ .affix-suffix {
41
50
  margin-left: 0.2em;
42
51
  }
43
52
  `;
@@ -60,6 +60,8 @@ export type ButtonSize = "sm" | "md" | "lg";
60
60
  */
61
61
  export declare class UButton extends UElement {
62
62
  static styles: import('lit').CSSResultGroup[];
63
+ /** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
64
+ private readonly affixes;
63
65
  static formAssociated: boolean;
64
66
  /**
65
67
  * 호스트의 `.focus()` 를 섀도 안의 네이티브 `<button>`/`<a>` 로 위임한다. 호스트는 포커스
@@ -4,6 +4,7 @@ import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm
4
4
  import "../spinner/USpinner.js";
5
5
  import { styles } from "./UButton.styles.js";
6
6
  import { FORWARDED_ARIA, readForwardedAria } from "./forwarded-aria.js";
7
+ import { SlotPresence } from "../../utilities/slotPresence.js";
7
8
  import { html } from "lit";
8
9
  import { customElement, property } from "lit/decorators.js";
9
10
  import { ifDefined } from "lit/directives/if-defined.js";
@@ -11,6 +12,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
11
12
  var UButton = class UButton extends UElement {
12
13
  constructor(..._args) {
13
14
  super(..._args);
15
+ this.affixes = new SlotPresence(this, ["prefix", "suffix"]);
14
16
  this.appearance = "solid";
15
17
  this.size = "md";
16
18
  this.rounded = false;
@@ -153,11 +155,11 @@ var UButton = class UButton extends UElement {
153
155
  }
154
156
  renderContent() {
155
157
  return html`
156
- <slot name="prefix"></slot>
158
+ <span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
157
159
  <div class="content" part="content">
158
160
  <slot></slot>
159
161
  </div>
160
- <slot name="suffix"></slot>
162
+ <span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
161
163
  `;
162
164
  }
163
165
  renderMask() {
@@ -362,10 +362,19 @@ var styles = css`
362
362
  color: inherit;
363
363
  font-size: inherit;
364
364
  }
365
- ::slotted([slot="prefix"]) {
365
+
366
+ .affix {
367
+ display: inline-flex;
368
+ align-items: center;
369
+ flex: none;
370
+ }
371
+ .affix[hidden] {
372
+ display: none;
373
+ }
374
+ .affix-prefix {
366
375
  margin-right: 0.5em;
367
376
  }
368
- ::slotted([slot="suffix"]) {
377
+ .affix-suffix {
369
378
  margin-left: 0.5em;
370
379
  }
371
380
 
@@ -10,10 +10,17 @@ import { UElement } from '../UElement.js';
10
10
  * (WAI-ARIA APG Carousel · WCAG 2.2.2). 사용자가 동작 줄이기(`prefers-reduced-motion: reduce`)를
11
11
  * 켜 두었으면 정지 상태로 시작하고(시작 버튼으로 켤 수 있다), 보는 중에 그 설정이 켜지면 멈춘다.
12
12
  *
13
+ * `unattended` 는 아무도 앞에서 조작하지 않는 화면(벽걸이 보드 · 로비 · 키오스크)이다 — 전체 화면이면 마우스 커서가 늘 그 위에
14
+ * 있으므로 포인터로는 멈추지 않고, 키보드 초점으로 멈춘 회전은 `resume-delay`(기본 30초) 동안 손대지 않으면 다시 돈다. 정지 버튼으로 멈춘 것은
15
+ * 그대로 멈춰 있다(멈출 수단은 남는다 — 2.2.2).
16
+ *
13
17
  * 보조기기에는 WAI-ARIA APG Carousel 구조로 나간다 — 호스트는 «캐러셀» 역할 설명을 단 영역(`region`), 각 슬라이드는
14
18
  * «슬라이드» 역할 설명과 «n / 전체» 이름을 단 그룹이다. 캐러셀의 이름은 호스트의 `aria-label` 로 준다(영역은 이름이
15
19
  * 있어야 랜드마크다). 슬라이드에 소비자가 이미 단 `role`·`aria-roledescription`·`aria-label` 은 덮지 않는다.
16
20
  *
21
+ * 보이지 않는 장은 `inert` 다 — 화면 밖 장의 링크 · 단추가 Tab 순서와 읽기 순서에서 빠진다(소비자가 처음부터 단 `inert` 는 덮지 않는다).
22
+ *
23
+ * @event change - 보이는 장이 바뀌었다 — 사람(단추 · 점 · 끌기 · `next()`/`prev()`/`goTo()`)이든 자동 넘김이든. `detail` 은 새 순번 · 직전 순번 · `cause`(`user` · `autoplay`). `index` 를 대입하면 내지 않고, 거품을 일으키지 않는다(`u-tab-panel` 과 같다).
17
24
  * @csspart slides - 슬라이드 컨테이너
18
25
  * @csspart prev-button - 이전 버튼
19
26
  * @csspart next-button - 다음 버튼
@@ -44,6 +51,13 @@ export declare class UCarousel extends UElement {
44
51
  paginationStyle: 'dots' | 'labels';
45
52
  /** 드래그로 슬라이드 이동 */
46
53
  draggable: boolean;
54
+ /**
55
+ * 아무도 조작하지 않는 화면 — 포인터가 위에 있어도 멈추지 않고, 키보드 초점으로 멈춘 회전은 `resume-delay`(기본 30초) 동안 손대지
56
+ * 않으면 다시 돈다. 정지 버튼으로 멈춘 것은 그대로다. `u-auto-scroll` 의 같은 속성과 짝이다.
57
+ */
58
+ unattended: boolean;
59
+ /** `unattended` 에서 키보드 초점으로 멈춘 회전이 다시 돌기까지 손대지 않은 시간 (ms). */
60
+ resumeDelay: number;
47
61
  /** 한 화면에 표시할 슬라이드 수 */
48
62
  slidesPerView: number;
49
63
  /** 한 번에 이동할 슬라이드 수 */
@@ -57,8 +71,11 @@ export declare class UCarousel extends UElement {
57
71
  private dragOffset;
58
72
  /** 사용자가 회전을 멈췄다(정지 버튼, 또는 키보드 초점 진입). 다시 시작할 때까지 유지된다. */
59
73
  private rotationStopped;
60
- /** 포인터가 캐러셀 위에 있다 — 그동안만 잠시 멈춘다. */
74
+ /** 포인터가 캐러셀 위에 있다 — 그동안만 잠시 멈춘다(`unattended` 가 아닐 때). */
61
75
  private hovered;
76
+ /** 왜 멈췄는가 — `unattended` 에서 초점으로 멈춘 것만 손대지 않으면 다시 돈다. */
77
+ private stopReason?;
78
+ private idleTimer?;
62
79
  private autoplayTimer?;
63
80
  /** 호스트 역할(region · «캐러셀» 역할 설명)을 속성으로 — 소비자의 `role`·`aria-roledescription` 이 있으면 그것이 이긴다. */
64
81
  private readonly aria;
@@ -90,6 +107,8 @@ export declare class UCarousel extends UElement {
90
107
  prev: () => void;
91
108
  next: () => void;
92
109
  goTo: (index: number) => void;
110
+ /** 지금 넘김을 일으킨 것 — 자동 넘김 타이머만 `autoplay` 로 바꾸고 곧바로 되돌린다. */
111
+ private moveCause;
93
112
  private startAutoplay;
94
113
  private stopAutoplay;
95
114
  private handleSlotChange;
@@ -97,6 +116,11 @@ export declare class UCarousel extends UElement {
97
116
  protected localeChanged(): void;
98
117
  /** 슬라이드를 «n / 전체» 이름의 그룹으로 — 처음 볼 때 비어 있던 속성만 우리 것으로 삼고, 그것만 갱신한다. */
99
118
  private labelSlide;
119
+ /**
120
+ * 보이지 않는 장을 `inert` 로 — 화면 밖 장의 링크 · 단추가 Tab 순서에 남고 읽기 순서에서 보이는 장과 섞이지 않게(APG Carousel).
121
+ * 여러 장을 함께 보이면(`slides-per-view`) 그 범위 밖만. 소비자가 처음부터 단 `inert` 는 우리 것이 아니라 건드리지 않는다.
122
+ */
123
+ private syncInertSlides;
100
124
  /** 슬롯을 떠난 슬라이드에서 우리가 단 속성을 걷는다. */
101
125
  private releaseSlide;
102
126
  private handleDragStart;
@@ -104,6 +128,14 @@ export declare class UCarousel extends UElement {
104
128
  private handlePointerMove;
105
129
  private handlePointerUp;
106
130
  private toggleRotation;
131
+ /** 자동 넘김을 다시 시작한다 — 정지 버튼 · 초점 · 동작 줄이기로 멈춘 것 모두(`autoplay` 일 때만 돈다). */
132
+ startRotation(): void;
133
+ /** 자동 넘김을 멈춘다 — 정지 버튼과 같다(`unattended` 에서도 저절로 다시 돌지 않는다). */
134
+ stopRotation(): void;
135
+ /** `unattended` 에서 초점으로 멈췄으면, 손대지 않고 `resumeDelay` 가 지나면 다시 돈다 — 키 · 포인터를 누를 때마다 다시 잰다. */
136
+ private scheduleIdleResume;
137
+ private clearIdle;
138
+ private handleActivity;
107
139
  /** 키보드 초점이 들어오면 멈춘다 — 포인터로 누른 초점은 멈추지 않는다(누른 버튼이 정지 버튼이면 그 클릭이 결정한다). */
108
140
  private handleFocusIn;
109
141
  /** 보는 중에 동작 줄이기가 켜지면 멈춘다. 꺼질 때는 다시 시작하지 않는다 — 멈춘 것을 움직이게
@@ -113,6 +145,29 @@ export declare class UCarousel extends UElement {
113
145
  private handlePointerLeave;
114
146
  private handleClickCancel;
115
147
  }
148
+ /** `<u-carousel>` 의 `change` detail. */
149
+ export interface UCarouselChangeDetail {
150
+ /** 지금 장(첫 보이는 장)의 순번. */
151
+ index: number;
152
+ /** 바뀌기 전 순번. */
153
+ previousIndex: number;
154
+ /** 사람이 넘겼는가(단추 · 점 · 끌기 · 메서드) · 자동 넘김인가. */
155
+ cause: 'user' | 'autoplay';
156
+ }
157
+ /** Events `<u-carousel>` dispatches. */
158
+ export interface UCarouselEventMap {
159
+ /** The shown slide changed — by a person (buttons, dots, drag, `next()`/`prev()`/`goTo()`) or by autoplay. Not when `index` is set. Does not bubble. */
160
+ 'change': CustomEvent<UCarouselChangeDetail>;
161
+ }
162
+ /** Typed listeners for {@link UCarouselEventMap} — element-scoped, the DOM's own pattern (`HTMLMediaElementEventMap`). */
163
+ export interface UCarousel {
164
+ addEventListener<K extends keyof UCarouselEventMap>(type: K, listener: (this: UCarousel, ev: UCarouselEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
165
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: UCarousel, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
166
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
167
+ removeEventListener<K extends keyof UCarouselEventMap>(type: K, listener: (this: UCarousel, ev: UCarouselEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
168
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: UCarousel, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
169
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
170
+ }
116
171
  declare global {
117
172
  interface HTMLElementTagNameMap {
118
173
  'u-carousel': UCarousel;
@@ -5,6 +5,7 @@ import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm
5
5
  import { HostAria } from "../../utilities/hostAria.js";
6
6
  import "../button/UButton.js";
7
7
  import "../icon/UIcon.js";
8
+ import { UNATTENDED_IDLE_MS } from "../../utilities/unattended.js";
8
9
  import { styles } from "./UCarousel.styles.js";
9
10
  import { html, nothing } from "lit";
10
11
  import { customElement, property, state } from "lit/decorators.js";
@@ -21,6 +22,8 @@ var UCarousel = class UCarousel extends UElement {
21
22
  this.pagination = false;
22
23
  this.paginationStyle = "dots";
23
24
  this.draggable = false;
25
+ this.unattended = false;
26
+ this.resumeDelay = UNATTENDED_IDLE_MS;
24
27
  this.slidesPerView = 1;
25
28
  this.slidesPerMove = 1;
26
29
  this.gap = 0;
@@ -48,9 +51,20 @@ var UCarousel = class UCarousel extends UElement {
48
51
  };
49
52
  this.goTo = (index) => {
50
53
  if (index < 0 || index > this.maxIndex || index === this.index) return;
54
+ const previousIndex = this.index;
51
55
  this.index = index;
52
56
  if (this.rotating) this.startAutoplay();
57
+ this.fire("change", {
58
+ detail: {
59
+ index,
60
+ previousIndex,
61
+ cause: this.moveCause
62
+ },
63
+ bubbles: false,
64
+ composed: false
65
+ });
53
66
  };
67
+ this.moveCause = "user";
54
68
  this.handleDragStart = (e) => {
55
69
  e.preventDefault();
56
70
  };
@@ -91,15 +105,27 @@ var UCarousel = class UCarousel extends UElement {
91
105
  if (this.rotating) this.startAutoplay();
92
106
  };
93
107
  this.toggleRotation = () => {
94
- this.rotationStopped = !this.rotationStopped;
108
+ if (this.rotationStopped) this.startRotation();
109
+ else this.stopRotation();
110
+ };
111
+ this.handleActivity = () => {
112
+ if (this.idleTimer !== void 0) this.scheduleIdleResume();
95
113
  };
96
114
  this.handleFocusIn = (e) => {
97
115
  if (!this.autoplay) return;
98
116
  const origin = e.composedPath()[0];
99
- if (origin instanceof Element && origin.matches(":focus-visible")) this.rotationStopped = true;
117
+ if (origin instanceof Element && origin.matches(":focus-visible") && this.stopReason !== "user") {
118
+ this.rotationStopped = true;
119
+ this.stopReason = "focus";
120
+ this.scheduleIdleResume();
121
+ }
100
122
  };
101
123
  this.handleReducedMotionChange = (e) => {
102
- if (e.matches && this.autoplay) this.rotationStopped = true;
124
+ if (e.matches && this.autoplay) {
125
+ this.clearIdle();
126
+ this.rotationStopped = true;
127
+ this.stopReason = "motion";
128
+ }
103
129
  };
104
130
  this.handlePointerEnter = (e) => {
105
131
  if (e.pointerType === "mouse") this.hovered = true;
@@ -117,7 +143,7 @@ var UCarousel = class UCarousel extends UElement {
117
143
  }
118
144
  /** 지금 자동으로 넘기고 있는가. */
119
145
  get rotating() {
120
- return this.autoplay && !this.rotationStopped && !this.hovered;
146
+ return this.autoplay && !this.rotationStopped && (this.unattended || !this.hovered);
121
147
  }
122
148
  get showDots() {
123
149
  return this.pagination && this.pageCount > 1;
@@ -144,6 +170,8 @@ var UCarousel = class UCarousel extends UElement {
144
170
  this.addEventListener("focusin", this.handleFocusIn);
145
171
  this.addEventListener("pointerenter", this.handlePointerEnter);
146
172
  this.addEventListener("pointerleave", this.handlePointerLeave);
173
+ this.addEventListener("keydown", this.handleActivity);
174
+ this.addEventListener("pointerdown", this.handleActivity);
147
175
  this.reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)");
148
176
  this.reducedMotion?.addEventListener("change", this.handleReducedMotionChange);
149
177
  if (this.rotating) this.startAutoplay();
@@ -155,16 +183,23 @@ var UCarousel = class UCarousel extends UElement {
155
183
  this.removeEventListener("focusin", this.handleFocusIn);
156
184
  this.removeEventListener("pointerenter", this.handlePointerEnter);
157
185
  this.removeEventListener("pointerleave", this.handlePointerLeave);
186
+ this.removeEventListener("keydown", this.handleActivity);
187
+ this.removeEventListener("pointerdown", this.handleActivity);
188
+ this.clearIdle();
158
189
  super.disconnectedCallback();
159
190
  }
160
191
  willUpdate(changedProperties) {
161
192
  super.willUpdate(changedProperties);
162
- if (changedProperties.has("autoplay") && this.autoplay) this.rotationStopped = !!this.reducedMotion?.matches;
193
+ if (changedProperties.has("autoplay") && this.autoplay) {
194
+ this.rotationStopped = !!this.reducedMotion?.matches;
195
+ this.stopReason = this.rotationStopped ? "motion" : void 0;
196
+ }
163
197
  if (changedProperties.has("slidesPerView")) this.style.setProperty("--slides-per-view", String(this.perView));
164
198
  if (changedProperties.has("gap")) this.style.setProperty("--slide-gap", `${this.gap}px`);
165
199
  }
166
200
  updated(changedProperties) {
167
201
  super.updated(changedProperties);
202
+ if (changedProperties.has("index") || changedProperties.has("slideCount") || changedProperties.has("slidesPerView")) this.syncInertSlides();
168
203
  if (changedProperties.has("autoplay") || changedProperties.has("autoplayInterval") || changedProperties.has("rotationStopped") || changedProperties.has("hovered")) {
169
204
  if (this.rotating) this.startAutoplay();
170
205
  else this.stopAutoplay();
@@ -249,7 +284,12 @@ var UCarousel = class UCarousel extends UElement {
249
284
  startAutoplay() {
250
285
  this.stopAutoplay();
251
286
  this.autoplayTimer = window.setInterval(() => {
252
- this.next();
287
+ this.moveCause = "autoplay";
288
+ try {
289
+ this.next();
290
+ } finally {
291
+ this.moveCause = "user";
292
+ }
253
293
  }, this.autoplayInterval);
254
294
  }
255
295
  stopAutoplay() {
@@ -279,7 +319,8 @@ var UCarousel = class UCarousel extends UElement {
279
319
  owned = [
280
320
  "role",
281
321
  "aria-roledescription",
282
- "aria-label"
322
+ "aria-label",
323
+ "inert"
283
324
  ].filter((name) => !slide.hasAttribute(name));
284
325
  this.ownedSlideAttrs.set(slide, owned);
285
326
  }
@@ -291,13 +332,53 @@ var UCarousel = class UCarousel extends UElement {
291
332
  total
292
333
  })
293
334
  };
294
- for (const name of owned) slide.setAttribute(name, values[name]);
335
+ for (const name of owned) if (name in values) slide.setAttribute(name, values[name]);
336
+ }
337
+ /**
338
+ * 보이지 않는 장을 `inert` 로 — 화면 밖 장의 링크 · 단추가 Tab 순서에 남고 읽기 순서에서 보이는 장과 섞이지 않게(APG Carousel).
339
+ * 여러 장을 함께 보이면(`slides-per-view`) 그 범위 밖만. 소비자가 처음부터 단 `inert` 는 우리 것이 아니라 건드리지 않는다.
340
+ */
341
+ syncInertSlides() {
342
+ const from = this.index;
343
+ const to = this.index + this.perView;
344
+ this.slides.forEach((slide, i) => {
345
+ if (!this.ownedSlideAttrs.get(slide)?.includes("inert")) return;
346
+ slide.toggleAttribute("inert", i < from || i >= to);
347
+ });
295
348
  }
296
349
  /** 슬롯을 떠난 슬라이드에서 우리가 단 속성을 걷는다. */
297
350
  releaseSlide(slide) {
298
351
  for (const name of this.ownedSlideAttrs.get(slide) ?? []) slide.removeAttribute(name);
299
352
  this.ownedSlideAttrs.delete(slide);
300
353
  }
354
+ /** 자동 넘김을 다시 시작한다 — 정지 버튼 · 초점 · 동작 줄이기로 멈춘 것 모두(`autoplay` 일 때만 돈다). */
355
+ startRotation() {
356
+ this.clearIdle();
357
+ this.stopReason = void 0;
358
+ this.rotationStopped = false;
359
+ }
360
+ /** 자동 넘김을 멈춘다 — 정지 버튼과 같다(`unattended` 에서도 저절로 다시 돌지 않는다). */
361
+ stopRotation() {
362
+ this.clearIdle();
363
+ this.stopReason = "user";
364
+ this.rotationStopped = true;
365
+ }
366
+ /** `unattended` 에서 초점으로 멈췄으면, 손대지 않고 `resumeDelay` 가 지나면 다시 돈다 — 키 · 포인터를 누를 때마다 다시 잰다. */
367
+ scheduleIdleResume() {
368
+ this.clearIdle();
369
+ if (!this.unattended || this.stopReason !== "focus") return;
370
+ this.idleTimer = window.setTimeout(() => {
371
+ this.idleTimer = void 0;
372
+ if (this.unattended && this.stopReason === "focus") {
373
+ this.stopReason = void 0;
374
+ this.rotationStopped = false;
375
+ }
376
+ }, this.resumeDelay);
377
+ }
378
+ clearIdle() {
379
+ if (this.idleTimer !== void 0) window.clearTimeout(this.idleTimer);
380
+ this.idleTimer = void 0;
381
+ }
301
382
  };
302
383
  __decorate([property({
303
384
  type: Boolean,
@@ -328,6 +409,14 @@ __decorate([property({
328
409
  type: Boolean,
329
410
  reflect: true
330
411
  }), __decorateMetadata("design:type", Object)], UCarousel.prototype, "draggable", void 0);
412
+ __decorate([property({
413
+ type: Boolean,
414
+ reflect: true
415
+ }), __decorateMetadata("design:type", Object)], UCarousel.prototype, "unattended", void 0);
416
+ __decorate([property({
417
+ type: Number,
418
+ attribute: "resume-delay"
419
+ }), __decorateMetadata("design:type", Object)], UCarousel.prototype, "resumeDelay", void 0);
331
420
  __decorate([property({
332
421
  type: Number,
333
422
  attribute: "slides-per-view"