@hypoth-ui/wc 0.1.1
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/LICENSE +21 -0
- package/README.md +60 -0
- package/dist/button-MKQKTC5Q.js +10 -0
- package/dist/button-MKQKTC5Q.js.map +1 -0
- package/dist/chunk-4HLM6DBG.js +910 -0
- package/dist/chunk-4HLM6DBG.js.map +1 -0
- package/dist/chunk-55ID7LJL.js +3602 -0
- package/dist/chunk-55ID7LJL.js.map +1 -0
- package/dist/chunk-66HFYJD7.js +86 -0
- package/dist/chunk-66HFYJD7.js.map +1 -0
- package/dist/chunk-CZOXIJVS.js +70 -0
- package/dist/chunk-CZOXIJVS.js.map +1 -0
- package/dist/chunk-DHUM4Q5Y.js +495 -0
- package/dist/chunk-DHUM4Q5Y.js.map +1 -0
- package/dist/chunk-DNNI5BDE.js +1842 -0
- package/dist/chunk-DNNI5BDE.js.map +1 -0
- package/dist/chunk-GXKZ6E6K.js +99 -0
- package/dist/chunk-GXKZ6E6K.js.map +1 -0
- package/dist/chunk-H4GJJZ3N.js +51 -0
- package/dist/chunk-H4GJJZ3N.js.map +1 -0
- package/dist/chunk-JMPTFALJ.js +175 -0
- package/dist/chunk-JMPTFALJ.js.map +1 -0
- package/dist/chunk-MYQWCLUJ.js +45 -0
- package/dist/chunk-MYQWCLUJ.js.map +1 -0
- package/dist/chunk-QZSPWT7L.js +183 -0
- package/dist/chunk-QZSPWT7L.js.map +1 -0
- package/dist/chunk-TSKBQCTR.js +5137 -0
- package/dist/chunk-TSKBQCTR.js.map +1 -0
- package/dist/chunk-TXIIUVL3.js +130 -0
- package/dist/chunk-TXIIUVL3.js.map +1 -0
- package/dist/chunk-UM7WRO7W.js +237 -0
- package/dist/chunk-UM7WRO7W.js.map +1 -0
- package/dist/chunk-VPXL4RB3.js +202 -0
- package/dist/chunk-VPXL4RB3.js.map +1 -0
- package/dist/chunk-VX5CKSMN.js +39 -0
- package/dist/chunk-VX5CKSMN.js.map +1 -0
- package/dist/chunk-WQ5BEP3E.js +2845 -0
- package/dist/chunk-WQ5BEP3E.js.map +1 -0
- package/dist/chunk-YDQ434UH.js +60 -0
- package/dist/chunk-YDQ434UH.js.map +1 -0
- package/dist/chunk-ZWV4VI6D.js +153 -0
- package/dist/chunk-ZWV4VI6D.js.map +1 -0
- package/dist/core.d.ts +127 -0
- package/dist/core.js +38 -0
- package/dist/core.js.map +1 -0
- package/dist/data-display.d.ts +872 -0
- package/dist/data-display.js +57 -0
- package/dist/data-display.js.map +1 -0
- package/dist/ds-element-Db0LMfxI.d.ts +43 -0
- package/dist/feedback.d.ts +292 -0
- package/dist/feedback.js +31 -0
- package/dist/feedback.js.map +1 -0
- package/dist/form-controls.d.ts +1713 -0
- package/dist/form-controls.js +63 -0
- package/dist/form-controls.js.map +1 -0
- package/dist/icon-7IZTJ5WT.js +8 -0
- package/dist/icon-7IZTJ5WT.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +423 -0
- package/dist/index.js.map +1 -0
- package/dist/input-LB6UR37A.js +10 -0
- package/dist/input-LB6UR37A.js.map +1 -0
- package/dist/layout.d.ts +504 -0
- package/dist/layout.js +34 -0
- package/dist/layout.js.map +1 -0
- package/dist/link-NHDJ6SFY.js +9 -0
- package/dist/link-NHDJ6SFY.js.map +1 -0
- package/dist/navigation.d.ts +255 -0
- package/dist/navigation.js +111 -0
- package/dist/navigation.js.map +1 -0
- package/dist/overlays.d.ts +1291 -0
- package/dist/overlays.js +106 -0
- package/dist/overlays.js.map +1 -0
- package/dist/primitives.d.ts +230 -0
- package/dist/primitives.js +26 -0
- package/dist/primitives.js.map +1 -0
- package/dist/registry-Bns0t11H.d.ts +233 -0
- package/dist/skeleton-MUdd2029.d.ts +109 -0
- package/dist/spinner-BWaNlc-Y.d.ts +45 -0
- package/dist/spinner-UIYDUVBZ.js +8 -0
- package/dist/spinner-UIYDUVBZ.js.map +1 -0
- package/dist/stepper-CCRwcQOe.d.ts +851 -0
- package/dist/text-MT3S3EMU.js +8 -0
- package/dist/text-MT3S3EMU.js.map +1 -0
- package/dist/visually-hidden-MW2XY4CS.js +8 -0
- package/dist/visually-hidden-MW2XY4CS.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,2845 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StandardEvents,
|
|
3
|
+
emitEvent
|
|
4
|
+
} from "./chunk-YDQ434UH.js";
|
|
5
|
+
import {
|
|
6
|
+
DSElement,
|
|
7
|
+
__decorateClass,
|
|
8
|
+
define
|
|
9
|
+
} from "./chunk-H4GJJZ3N.js";
|
|
10
|
+
|
|
11
|
+
// src/components/collapsible/collapsible-content.ts
|
|
12
|
+
import { createPresence, prefersReducedMotion } from "@hypoth-ui/primitives-dom";
|
|
13
|
+
import { html } from "lit";
|
|
14
|
+
import { property, state } from "lit/decorators.js";
|
|
15
|
+
var DsCollapsibleContent = class extends DSElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.forceMount = false;
|
|
19
|
+
this.dataState = "closed";
|
|
20
|
+
this.isAnimatingOut = false;
|
|
21
|
+
this.presence = null;
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.setAttribute("role", "region");
|
|
26
|
+
this.updateVisibility();
|
|
27
|
+
}
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
super.disconnectedCallback();
|
|
30
|
+
this.presence?.destroy();
|
|
31
|
+
this.presence = null;
|
|
32
|
+
}
|
|
33
|
+
updated(changedProperties) {
|
|
34
|
+
if (changedProperties.has("dataState")) {
|
|
35
|
+
this.handleStateChange();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
handleStateChange() {
|
|
39
|
+
this.setAttribute("data-state", this.dataState);
|
|
40
|
+
if (this.dataState === "open") {
|
|
41
|
+
this.isAnimatingOut = false;
|
|
42
|
+
this.updateVisibility();
|
|
43
|
+
} else if (!this.forceMount && !prefersReducedMotion()) {
|
|
44
|
+
this.isAnimatingOut = true;
|
|
45
|
+
this.presence?.destroy();
|
|
46
|
+
this.presence = createPresence({
|
|
47
|
+
onExitComplete: () => {
|
|
48
|
+
this.isAnimatingOut = false;
|
|
49
|
+
this.updateVisibility();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.presence.hide(this);
|
|
53
|
+
} else {
|
|
54
|
+
this.updateVisibility();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
updateVisibility() {
|
|
58
|
+
if (this.forceMount) {
|
|
59
|
+
this.hidden = false;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (this.isAnimatingOut) {
|
|
63
|
+
this.hidden = false;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.hidden = this.dataState === "closed";
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
return html`<slot></slot>`;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
__decorateClass([
|
|
73
|
+
property({ type: Boolean, attribute: "force-mount" })
|
|
74
|
+
], DsCollapsibleContent.prototype, "forceMount", 2);
|
|
75
|
+
__decorateClass([
|
|
76
|
+
state()
|
|
77
|
+
], DsCollapsibleContent.prototype, "dataState", 2);
|
|
78
|
+
__decorateClass([
|
|
79
|
+
state()
|
|
80
|
+
], DsCollapsibleContent.prototype, "isAnimatingOut", 2);
|
|
81
|
+
define("ds-collapsible-content", DsCollapsibleContent);
|
|
82
|
+
|
|
83
|
+
// src/components/collapsible/collapsible-trigger.ts
|
|
84
|
+
import { html as html2 } from "lit";
|
|
85
|
+
var DsCollapsibleTrigger = class extends DSElement {
|
|
86
|
+
connectedCallback() {
|
|
87
|
+
super.connectedCallback();
|
|
88
|
+
if (!this.hasAttribute("tabindex")) {
|
|
89
|
+
this.setAttribute("tabindex", "0");
|
|
90
|
+
}
|
|
91
|
+
if (!this.hasAttribute("role")) {
|
|
92
|
+
this.setAttribute("role", "button");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
return html2`<slot></slot>`;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
define("ds-collapsible-trigger", DsCollapsibleTrigger);
|
|
100
|
+
|
|
101
|
+
// src/components/collapsible/collapsible.ts
|
|
102
|
+
import { html as html3 } from "lit";
|
|
103
|
+
import { property as property2, state as state2 } from "lit/decorators.js";
|
|
104
|
+
var DsCollapsible = class extends DSElement {
|
|
105
|
+
constructor() {
|
|
106
|
+
super(...arguments);
|
|
107
|
+
this.open = false;
|
|
108
|
+
this.disabled = false;
|
|
109
|
+
this.contentId = `collapsible-${crypto.randomUUID().slice(0, 8)}`;
|
|
110
|
+
this.handleTriggerClick = (event) => {
|
|
111
|
+
const target = event.target;
|
|
112
|
+
const trigger = target.closest('[slot="trigger"], ds-collapsible-trigger');
|
|
113
|
+
if (trigger && this.contains(trigger)) {
|
|
114
|
+
this.toggle();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
this.handleKeyDown = (event) => {
|
|
118
|
+
const target = event.target;
|
|
119
|
+
const trigger = target.closest('[slot="trigger"], ds-collapsible-trigger');
|
|
120
|
+
if (trigger && this.contains(trigger)) {
|
|
121
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
this.toggle();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
connectedCallback() {
|
|
129
|
+
super.connectedCallback();
|
|
130
|
+
this.addEventListener("click", this.handleTriggerClick);
|
|
131
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
132
|
+
}
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
super.disconnectedCallback();
|
|
135
|
+
this.removeEventListener("click", this.handleTriggerClick);
|
|
136
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Toggle the open state.
|
|
140
|
+
*/
|
|
141
|
+
toggle() {
|
|
142
|
+
if (this.disabled) return;
|
|
143
|
+
this.setOpen(!this.open);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Set the open state.
|
|
147
|
+
*/
|
|
148
|
+
setOpen(open) {
|
|
149
|
+
if (this.disabled || this.open === open) return;
|
|
150
|
+
this.open = open;
|
|
151
|
+
emitEvent(this, open ? StandardEvents.OPEN : StandardEvents.CLOSE);
|
|
152
|
+
this.updateContent();
|
|
153
|
+
}
|
|
154
|
+
updated() {
|
|
155
|
+
this.updateContent();
|
|
156
|
+
this.updateTrigger();
|
|
157
|
+
}
|
|
158
|
+
updateContent() {
|
|
159
|
+
const content = this.querySelector("ds-collapsible-content");
|
|
160
|
+
if (content) {
|
|
161
|
+
content.id = this.contentId;
|
|
162
|
+
content.dataState = this.open ? "open" : "closed";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
updateTrigger() {
|
|
166
|
+
const trigger = this.querySelector('[slot="trigger"]') || this.querySelector("ds-collapsible-trigger");
|
|
167
|
+
if (trigger) {
|
|
168
|
+
trigger.setAttribute("aria-expanded", String(this.open));
|
|
169
|
+
trigger.setAttribute("aria-controls", this.contentId);
|
|
170
|
+
if (this.disabled) {
|
|
171
|
+
trigger.setAttribute("aria-disabled", "true");
|
|
172
|
+
} else {
|
|
173
|
+
trigger.removeAttribute("aria-disabled");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
render() {
|
|
178
|
+
return html3`
|
|
179
|
+
<slot name="trigger"></slot>
|
|
180
|
+
<slot></slot>
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
__decorateClass([
|
|
185
|
+
property2({ type: Boolean, reflect: true })
|
|
186
|
+
], DsCollapsible.prototype, "open", 2);
|
|
187
|
+
__decorateClass([
|
|
188
|
+
property2({ type: Boolean, reflect: true })
|
|
189
|
+
], DsCollapsible.prototype, "disabled", 2);
|
|
190
|
+
__decorateClass([
|
|
191
|
+
state2()
|
|
192
|
+
], DsCollapsible.prototype, "contentId", 2);
|
|
193
|
+
define("ds-collapsible", DsCollapsible);
|
|
194
|
+
|
|
195
|
+
// src/components/tabs/tabs-list.ts
|
|
196
|
+
import { html as html4 } from "lit";
|
|
197
|
+
var DsTabsList = class extends DSElement {
|
|
198
|
+
connectedCallback() {
|
|
199
|
+
super.connectedCallback();
|
|
200
|
+
requestAnimationFrame(() => {
|
|
201
|
+
this.setupBehavior();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Setup behavior connection (called by parent when options change).
|
|
206
|
+
*/
|
|
207
|
+
setupBehavior() {
|
|
208
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
209
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
210
|
+
if (!tabsBehavior) return;
|
|
211
|
+
const tablistProps = tabsBehavior.getTabListProps();
|
|
212
|
+
this.setAttribute("id", tablistProps.id);
|
|
213
|
+
this.setAttribute("role", tablistProps.role);
|
|
214
|
+
this.setAttribute("aria-orientation", tablistProps["aria-orientation"]);
|
|
215
|
+
tabsBehavior.setTablistElement(this);
|
|
216
|
+
}
|
|
217
|
+
render() {
|
|
218
|
+
return html4`<slot></slot>`;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
define("ds-tabs-list", DsTabsList);
|
|
222
|
+
|
|
223
|
+
// src/components/tabs/tabs-trigger.ts
|
|
224
|
+
import { html as html5 } from "lit";
|
|
225
|
+
import { property as property3, state as state3 } from "lit/decorators.js";
|
|
226
|
+
var DsTabsTrigger = class extends DSElement {
|
|
227
|
+
constructor() {
|
|
228
|
+
super(...arguments);
|
|
229
|
+
this.value = "";
|
|
230
|
+
this.disabled = false;
|
|
231
|
+
this.selected = false;
|
|
232
|
+
this.handleClick = () => {
|
|
233
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
234
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
235
|
+
tabsBehavior?.handleTriggerClick(this.value);
|
|
236
|
+
};
|
|
237
|
+
this.handleKeyDown = (event) => {
|
|
238
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
239
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
240
|
+
tabsBehavior?.handleTriggerKeyDown(event, this.value);
|
|
241
|
+
};
|
|
242
|
+
this.handleFocus = () => {
|
|
243
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
244
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
245
|
+
tabsBehavior?.handleTriggerFocus(this.value);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
connectedCallback() {
|
|
249
|
+
super.connectedCallback();
|
|
250
|
+
this.addEventListener("click", this.handleClick);
|
|
251
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
252
|
+
this.addEventListener("focus", this.handleFocus);
|
|
253
|
+
requestAnimationFrame(() => {
|
|
254
|
+
this.registerWithBehavior();
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
disconnectedCallback() {
|
|
258
|
+
super.disconnectedCallback();
|
|
259
|
+
this.removeEventListener("click", this.handleClick);
|
|
260
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
261
|
+
this.removeEventListener("focus", this.handleFocus);
|
|
262
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
263
|
+
tabsRoot?.getTabsBehavior()?.unregisterTab(this.value);
|
|
264
|
+
}
|
|
265
|
+
registerWithBehavior() {
|
|
266
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
267
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
268
|
+
if (!tabsBehavior) return;
|
|
269
|
+
tabsBehavior.registerTab(this.value, { disabled: this.disabled });
|
|
270
|
+
this.applyBehaviorProps();
|
|
271
|
+
}
|
|
272
|
+
applyBehaviorProps() {
|
|
273
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
274
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
275
|
+
if (!tabsBehavior) return;
|
|
276
|
+
const triggerProps = tabsBehavior.getTriggerProps(this.value, { disabled: this.disabled });
|
|
277
|
+
this.id = triggerProps.id;
|
|
278
|
+
this.setAttribute("role", triggerProps.role);
|
|
279
|
+
this.setAttribute("tabindex", String(triggerProps.tabIndex));
|
|
280
|
+
this.setAttribute("aria-selected", triggerProps["aria-selected"]);
|
|
281
|
+
this.setAttribute("aria-controls", triggerProps["aria-controls"]);
|
|
282
|
+
if (triggerProps["aria-disabled"]) {
|
|
283
|
+
this.setAttribute("aria-disabled", triggerProps["aria-disabled"]);
|
|
284
|
+
} else {
|
|
285
|
+
this.removeAttribute("aria-disabled");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Update from behavior (called by parent).
|
|
290
|
+
*/
|
|
291
|
+
updateFromBehavior(selected) {
|
|
292
|
+
this.selected = selected;
|
|
293
|
+
this.applyBehaviorProps();
|
|
294
|
+
}
|
|
295
|
+
updated(changedProperties) {
|
|
296
|
+
if (changedProperties.has("disabled")) {
|
|
297
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
298
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
299
|
+
if (tabsBehavior) {
|
|
300
|
+
tabsBehavior.unregisterTab(this.value);
|
|
301
|
+
tabsBehavior.registerTab(this.value, { disabled: this.disabled });
|
|
302
|
+
this.applyBehaviorProps();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
render() {
|
|
307
|
+
return html5`<slot></slot>`;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
__decorateClass([
|
|
311
|
+
property3({ reflect: true })
|
|
312
|
+
], DsTabsTrigger.prototype, "value", 2);
|
|
313
|
+
__decorateClass([
|
|
314
|
+
property3({ type: Boolean, reflect: true })
|
|
315
|
+
], DsTabsTrigger.prototype, "disabled", 2);
|
|
316
|
+
__decorateClass([
|
|
317
|
+
state3()
|
|
318
|
+
], DsTabsTrigger.prototype, "selected", 2);
|
|
319
|
+
define("ds-tabs-trigger", DsTabsTrigger);
|
|
320
|
+
|
|
321
|
+
// src/components/tabs/tabs-content.ts
|
|
322
|
+
import { html as html6 } from "lit";
|
|
323
|
+
import { property as property4, state as state4 } from "lit/decorators.js";
|
|
324
|
+
var DsTabsContent = class extends DSElement {
|
|
325
|
+
constructor() {
|
|
326
|
+
super(...arguments);
|
|
327
|
+
this.value = "";
|
|
328
|
+
this.forceMount = false;
|
|
329
|
+
this.active = false;
|
|
330
|
+
}
|
|
331
|
+
connectedCallback() {
|
|
332
|
+
super.connectedCallback();
|
|
333
|
+
requestAnimationFrame(() => {
|
|
334
|
+
this.applyBehaviorProps();
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
applyBehaviorProps() {
|
|
338
|
+
const tabsRoot = this.closest("ds-tabs");
|
|
339
|
+
const tabsBehavior = tabsRoot?.getTabsBehavior();
|
|
340
|
+
if (!tabsBehavior) {
|
|
341
|
+
this.setAttribute("role", "tabpanel");
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const panelProps = tabsBehavior.getPanelProps(this.value);
|
|
345
|
+
this.id = panelProps.id;
|
|
346
|
+
this.setAttribute("role", panelProps.role);
|
|
347
|
+
this.setAttribute("aria-labelledby", panelProps["aria-labelledby"]);
|
|
348
|
+
this.setAttribute("tabindex", String(panelProps.tabIndex));
|
|
349
|
+
if (this.forceMount) {
|
|
350
|
+
this.hidden = false;
|
|
351
|
+
} else {
|
|
352
|
+
this.hidden = panelProps.hidden;
|
|
353
|
+
}
|
|
354
|
+
this.setAttribute("data-state", panelProps.hidden ? "inactive" : "active");
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Update from behavior (called by parent).
|
|
358
|
+
*/
|
|
359
|
+
updateFromBehavior(active) {
|
|
360
|
+
this.active = active;
|
|
361
|
+
this.applyBehaviorProps();
|
|
362
|
+
}
|
|
363
|
+
render() {
|
|
364
|
+
return html6`<slot></slot>`;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
__decorateClass([
|
|
368
|
+
property4({ reflect: true })
|
|
369
|
+
], DsTabsContent.prototype, "value", 2);
|
|
370
|
+
__decorateClass([
|
|
371
|
+
property4({ type: Boolean, attribute: "force-mount" })
|
|
372
|
+
], DsTabsContent.prototype, "forceMount", 2);
|
|
373
|
+
__decorateClass([
|
|
374
|
+
state4()
|
|
375
|
+
], DsTabsContent.prototype, "active", 2);
|
|
376
|
+
define("ds-tabs-content", DsTabsContent);
|
|
377
|
+
|
|
378
|
+
// src/components/tabs/tabs.ts
|
|
379
|
+
import {
|
|
380
|
+
createTabsBehavior
|
|
381
|
+
} from "@hypoth-ui/primitives-dom";
|
|
382
|
+
import { html as html7 } from "lit";
|
|
383
|
+
import { property as property5, state as state5 } from "lit/decorators.js";
|
|
384
|
+
var DsTabs = class extends DSElement {
|
|
385
|
+
constructor() {
|
|
386
|
+
super(...arguments);
|
|
387
|
+
this.orientation = "horizontal";
|
|
388
|
+
this.activationMode = "automatic";
|
|
389
|
+
this.loop = true;
|
|
390
|
+
/** Behavior primitive instance */
|
|
391
|
+
this.tabsBehavior = null;
|
|
392
|
+
}
|
|
393
|
+
/** Whether we're in controlled mode */
|
|
394
|
+
get isControlled() {
|
|
395
|
+
return this.value !== void 0;
|
|
396
|
+
}
|
|
397
|
+
/** Current active value */
|
|
398
|
+
get activeValue() {
|
|
399
|
+
return this.isControlled ? this.value : this.internalValue;
|
|
400
|
+
}
|
|
401
|
+
/** Get the tabs behavior (for child components) */
|
|
402
|
+
getTabsBehavior() {
|
|
403
|
+
return this.tabsBehavior;
|
|
404
|
+
}
|
|
405
|
+
connectedCallback() {
|
|
406
|
+
super.connectedCallback();
|
|
407
|
+
if (!this.isControlled && this.defaultValue) {
|
|
408
|
+
this.internalValue = this.defaultValue;
|
|
409
|
+
}
|
|
410
|
+
this.initTabsBehavior();
|
|
411
|
+
}
|
|
412
|
+
disconnectedCallback() {
|
|
413
|
+
super.disconnectedCallback();
|
|
414
|
+
this.tabsBehavior?.destroy();
|
|
415
|
+
this.tabsBehavior = null;
|
|
416
|
+
}
|
|
417
|
+
initTabsBehavior() {
|
|
418
|
+
this.tabsBehavior = createTabsBehavior({
|
|
419
|
+
defaultValue: this.activeValue ?? this.defaultValue ?? "",
|
|
420
|
+
orientation: this.orientation,
|
|
421
|
+
activationMode: this.activationMode,
|
|
422
|
+
loop: this.loop,
|
|
423
|
+
onValueChange: (newValue) => {
|
|
424
|
+
if (!this.isControlled) {
|
|
425
|
+
this.internalValue = newValue;
|
|
426
|
+
}
|
|
427
|
+
emitEvent(this, "ds:change", { detail: { value: newValue } });
|
|
428
|
+
this.updateTabsState();
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Select a tab by value.
|
|
434
|
+
*/
|
|
435
|
+
selectTab(value) {
|
|
436
|
+
if (this.activeValue === value) return;
|
|
437
|
+
this.tabsBehavior?.select(value);
|
|
438
|
+
}
|
|
439
|
+
updated(changedProperties) {
|
|
440
|
+
if (changedProperties.has("value") && this.isControlled && this.value) {
|
|
441
|
+
this.tabsBehavior?.select(this.value);
|
|
442
|
+
this.updateTabsState();
|
|
443
|
+
}
|
|
444
|
+
if (changedProperties.has("internalValue")) {
|
|
445
|
+
this.updateTabsState();
|
|
446
|
+
}
|
|
447
|
+
if (changedProperties.has("defaultValue") && !this.isControlled && !this.internalValue) {
|
|
448
|
+
this.internalValue = this.defaultValue;
|
|
449
|
+
this.tabsBehavior?.select(this.defaultValue ?? "");
|
|
450
|
+
this.updateTabsState();
|
|
451
|
+
}
|
|
452
|
+
if (changedProperties.has("orientation") || changedProperties.has("activationMode") || changedProperties.has("loop")) {
|
|
453
|
+
const currentValue = this.activeValue;
|
|
454
|
+
this.tabsBehavior?.destroy();
|
|
455
|
+
this.initTabsBehavior();
|
|
456
|
+
if (currentValue) {
|
|
457
|
+
this.tabsBehavior?.select(currentValue);
|
|
458
|
+
}
|
|
459
|
+
const tabsList = this.querySelector("ds-tabs-list");
|
|
460
|
+
tabsList?.setupBehavior();
|
|
461
|
+
this.updateTabsState();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
updateTabsState() {
|
|
465
|
+
const activeValue = this.activeValue;
|
|
466
|
+
const triggers = this.querySelectorAll("ds-tabs-trigger");
|
|
467
|
+
for (const trigger of triggers) {
|
|
468
|
+
trigger.updateFromBehavior(trigger.value === activeValue);
|
|
469
|
+
}
|
|
470
|
+
const contents = this.querySelectorAll("ds-tabs-content");
|
|
471
|
+
for (const content of contents) {
|
|
472
|
+
content.updateFromBehavior(content.value === activeValue);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
render() {
|
|
476
|
+
return html7`<slot></slot>`;
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
__decorateClass([
|
|
480
|
+
property5()
|
|
481
|
+
], DsTabs.prototype, "value", 2);
|
|
482
|
+
__decorateClass([
|
|
483
|
+
property5({ attribute: "default-value" })
|
|
484
|
+
], DsTabs.prototype, "defaultValue", 2);
|
|
485
|
+
__decorateClass([
|
|
486
|
+
property5({ reflect: true })
|
|
487
|
+
], DsTabs.prototype, "orientation", 2);
|
|
488
|
+
__decorateClass([
|
|
489
|
+
property5({ attribute: "activation-mode" })
|
|
490
|
+
], DsTabs.prototype, "activationMode", 2);
|
|
491
|
+
__decorateClass([
|
|
492
|
+
property5({ type: Boolean })
|
|
493
|
+
], DsTabs.prototype, "loop", 2);
|
|
494
|
+
__decorateClass([
|
|
495
|
+
state5()
|
|
496
|
+
], DsTabs.prototype, "internalValue", 2);
|
|
497
|
+
define("ds-tabs", DsTabs);
|
|
498
|
+
|
|
499
|
+
// src/components/accordion/accordion-item.ts
|
|
500
|
+
import { html as html8 } from "lit";
|
|
501
|
+
import { property as property6, state as state6 } from "lit/decorators.js";
|
|
502
|
+
var DsAccordionItem = class extends DSElement {
|
|
503
|
+
constructor() {
|
|
504
|
+
super(...arguments);
|
|
505
|
+
this.value = "";
|
|
506
|
+
this.disabled = false;
|
|
507
|
+
this.expanded = false;
|
|
508
|
+
/** ID for ARIA relationships */
|
|
509
|
+
this.contentId = "";
|
|
510
|
+
this.triggerId = "";
|
|
511
|
+
}
|
|
512
|
+
connectedCallback() {
|
|
513
|
+
super.connectedCallback();
|
|
514
|
+
const id = crypto.randomUUID().slice(0, 8);
|
|
515
|
+
this.contentId = `accordion-content-${this.value}-${id}`;
|
|
516
|
+
this.triggerId = `accordion-trigger-${this.value}-${id}`;
|
|
517
|
+
this.setAttribute("data-state", "closed");
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Set the expanded state (called by parent).
|
|
521
|
+
*/
|
|
522
|
+
setExpanded(expanded) {
|
|
523
|
+
this.expanded = expanded;
|
|
524
|
+
this.setAttribute("data-state", expanded ? "open" : "closed");
|
|
525
|
+
this.updateChildren();
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Get whether the item is expanded.
|
|
529
|
+
*/
|
|
530
|
+
isExpanded() {
|
|
531
|
+
return this.expanded;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Get the content ID.
|
|
535
|
+
*/
|
|
536
|
+
getContentId() {
|
|
537
|
+
return this.contentId;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Get the trigger ID.
|
|
541
|
+
*/
|
|
542
|
+
getTriggerId() {
|
|
543
|
+
return this.triggerId;
|
|
544
|
+
}
|
|
545
|
+
updateChildren() {
|
|
546
|
+
const trigger = this.querySelector("ds-accordion-trigger");
|
|
547
|
+
const content = this.querySelector("ds-accordion-content");
|
|
548
|
+
if (trigger) {
|
|
549
|
+
trigger.id = this.triggerId;
|
|
550
|
+
trigger.setExpanded(this.expanded);
|
|
551
|
+
trigger.setContentId(this.contentId);
|
|
552
|
+
if (this.disabled) {
|
|
553
|
+
trigger.setAttribute("aria-disabled", "true");
|
|
554
|
+
} else {
|
|
555
|
+
trigger.removeAttribute("aria-disabled");
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (content) {
|
|
559
|
+
content.id = this.contentId;
|
|
560
|
+
content.setExpanded(this.expanded);
|
|
561
|
+
content.setTriggerId(this.triggerId);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
updated() {
|
|
565
|
+
this.updateChildren();
|
|
566
|
+
}
|
|
567
|
+
render() {
|
|
568
|
+
return html8`<slot></slot>`;
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
__decorateClass([
|
|
572
|
+
property6({ reflect: true })
|
|
573
|
+
], DsAccordionItem.prototype, "value", 2);
|
|
574
|
+
__decorateClass([
|
|
575
|
+
property6({ type: Boolean, reflect: true })
|
|
576
|
+
], DsAccordionItem.prototype, "disabled", 2);
|
|
577
|
+
__decorateClass([
|
|
578
|
+
state6()
|
|
579
|
+
], DsAccordionItem.prototype, "expanded", 2);
|
|
580
|
+
define("ds-accordion-item", DsAccordionItem);
|
|
581
|
+
|
|
582
|
+
// src/components/accordion/accordion-trigger.ts
|
|
583
|
+
import { html as html9 } from "lit";
|
|
584
|
+
import { state as state7 } from "lit/decorators.js";
|
|
585
|
+
var DsAccordionTrigger = class extends DSElement {
|
|
586
|
+
constructor() {
|
|
587
|
+
super(...arguments);
|
|
588
|
+
this.expanded = false;
|
|
589
|
+
this.contentId = "";
|
|
590
|
+
this.handleClick = () => {
|
|
591
|
+
if (this.hasAttribute("aria-disabled")) return;
|
|
592
|
+
this.toggle();
|
|
593
|
+
};
|
|
594
|
+
this.handleKeyDown = (event) => {
|
|
595
|
+
if (this.hasAttribute("aria-disabled")) return;
|
|
596
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
597
|
+
event.preventDefault();
|
|
598
|
+
this.toggle();
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
connectedCallback() {
|
|
603
|
+
super.connectedCallback();
|
|
604
|
+
this.setAttribute("role", "button");
|
|
605
|
+
this.setAttribute("tabindex", "0");
|
|
606
|
+
this.addEventListener("click", this.handleClick);
|
|
607
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
608
|
+
}
|
|
609
|
+
disconnectedCallback() {
|
|
610
|
+
super.disconnectedCallback();
|
|
611
|
+
this.removeEventListener("click", this.handleClick);
|
|
612
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Set the expanded state (called by parent).
|
|
616
|
+
*/
|
|
617
|
+
setExpanded(expanded) {
|
|
618
|
+
this.expanded = expanded;
|
|
619
|
+
this.updateAccessibility();
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Set the content ID for aria-controls.
|
|
623
|
+
*/
|
|
624
|
+
setContentId(id) {
|
|
625
|
+
this.contentId = id;
|
|
626
|
+
this.updateAccessibility();
|
|
627
|
+
}
|
|
628
|
+
toggle() {
|
|
629
|
+
const item = this.closest("ds-accordion-item");
|
|
630
|
+
if (!item) return;
|
|
631
|
+
emitEvent(this, "ds:accordion-toggle", {
|
|
632
|
+
detail: { value: item.value },
|
|
633
|
+
bubbles: true
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
updateAccessibility() {
|
|
637
|
+
this.setAttribute("aria-expanded", String(this.expanded));
|
|
638
|
+
if (this.contentId) {
|
|
639
|
+
this.setAttribute("aria-controls", this.contentId);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
updated() {
|
|
643
|
+
this.updateAccessibility();
|
|
644
|
+
}
|
|
645
|
+
render() {
|
|
646
|
+
return html9`<slot></slot>`;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
__decorateClass([
|
|
650
|
+
state7()
|
|
651
|
+
], DsAccordionTrigger.prototype, "expanded", 2);
|
|
652
|
+
__decorateClass([
|
|
653
|
+
state7()
|
|
654
|
+
], DsAccordionTrigger.prototype, "contentId", 2);
|
|
655
|
+
define("ds-accordion-trigger", DsAccordionTrigger);
|
|
656
|
+
|
|
657
|
+
// src/components/accordion/accordion-content.ts
|
|
658
|
+
import { createPresence as createPresence2, prefersReducedMotion as prefersReducedMotion2 } from "@hypoth-ui/primitives-dom";
|
|
659
|
+
import { html as html10 } from "lit";
|
|
660
|
+
import { property as property7, state as state8 } from "lit/decorators.js";
|
|
661
|
+
var DsAccordionContent = class extends DSElement {
|
|
662
|
+
constructor() {
|
|
663
|
+
super(...arguments);
|
|
664
|
+
this.forceMount = false;
|
|
665
|
+
this.expanded = false;
|
|
666
|
+
this.triggerId = "";
|
|
667
|
+
this.isAnimatingOut = false;
|
|
668
|
+
this.presence = null;
|
|
669
|
+
}
|
|
670
|
+
connectedCallback() {
|
|
671
|
+
super.connectedCallback();
|
|
672
|
+
this.setAttribute("role", "region");
|
|
673
|
+
this.updateVisibility();
|
|
674
|
+
}
|
|
675
|
+
disconnectedCallback() {
|
|
676
|
+
super.disconnectedCallback();
|
|
677
|
+
this.presence?.destroy();
|
|
678
|
+
this.presence = null;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Set the expanded state (called by parent).
|
|
682
|
+
*/
|
|
683
|
+
setExpanded(expanded) {
|
|
684
|
+
const wasExpanded = this.expanded;
|
|
685
|
+
this.expanded = expanded;
|
|
686
|
+
this.setAttribute("data-state", expanded ? "open" : "closed");
|
|
687
|
+
if (wasExpanded && !expanded) {
|
|
688
|
+
this.handleCollapse();
|
|
689
|
+
} else {
|
|
690
|
+
this.isAnimatingOut = false;
|
|
691
|
+
this.updateVisibility();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Set the trigger ID for aria-labelledby.
|
|
696
|
+
*/
|
|
697
|
+
setTriggerId(id) {
|
|
698
|
+
this.triggerId = id;
|
|
699
|
+
this.setAttribute("aria-labelledby", id);
|
|
700
|
+
}
|
|
701
|
+
handleCollapse() {
|
|
702
|
+
if (!this.forceMount && !prefersReducedMotion2()) {
|
|
703
|
+
this.isAnimatingOut = true;
|
|
704
|
+
this.presence?.destroy();
|
|
705
|
+
this.presence = createPresence2({
|
|
706
|
+
onExitComplete: () => {
|
|
707
|
+
this.isAnimatingOut = false;
|
|
708
|
+
this.updateVisibility();
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
this.presence.hide(this);
|
|
712
|
+
} else {
|
|
713
|
+
this.updateVisibility();
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
updateVisibility() {
|
|
717
|
+
if (this.forceMount) {
|
|
718
|
+
this.hidden = false;
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
if (this.isAnimatingOut) {
|
|
722
|
+
this.hidden = false;
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
this.hidden = !this.expanded;
|
|
726
|
+
}
|
|
727
|
+
render() {
|
|
728
|
+
return html10`<slot></slot>`;
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
__decorateClass([
|
|
732
|
+
property7({ type: Boolean, attribute: "force-mount" })
|
|
733
|
+
], DsAccordionContent.prototype, "forceMount", 2);
|
|
734
|
+
__decorateClass([
|
|
735
|
+
state8()
|
|
736
|
+
], DsAccordionContent.prototype, "expanded", 2);
|
|
737
|
+
__decorateClass([
|
|
738
|
+
state8()
|
|
739
|
+
], DsAccordionContent.prototype, "triggerId", 2);
|
|
740
|
+
__decorateClass([
|
|
741
|
+
state8()
|
|
742
|
+
], DsAccordionContent.prototype, "isAnimatingOut", 2);
|
|
743
|
+
define("ds-accordion-content", DsAccordionContent);
|
|
744
|
+
|
|
745
|
+
// src/components/accordion/accordion.ts
|
|
746
|
+
import { createRovingFocus } from "@hypoth-ui/primitives-dom";
|
|
747
|
+
import { html as html11 } from "lit";
|
|
748
|
+
import { property as property8, state as state9 } from "lit/decorators.js";
|
|
749
|
+
var DsAccordion = class extends DSElement {
|
|
750
|
+
constructor() {
|
|
751
|
+
super(...arguments);
|
|
752
|
+
this.type = "single";
|
|
753
|
+
this.collapsible = false;
|
|
754
|
+
this.orientation = "vertical";
|
|
755
|
+
this.internalValue = /* @__PURE__ */ new Set();
|
|
756
|
+
this.rovingFocus = null;
|
|
757
|
+
this.handleItemToggle = (event) => {
|
|
758
|
+
this.toggleItem(event.detail.value);
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
/** Whether we're in controlled mode */
|
|
762
|
+
get isControlled() {
|
|
763
|
+
return this.value !== void 0;
|
|
764
|
+
}
|
|
765
|
+
/** Current expanded values */
|
|
766
|
+
get expandedValues() {
|
|
767
|
+
if (this.isControlled) {
|
|
768
|
+
return this.parseValue(this.value);
|
|
769
|
+
}
|
|
770
|
+
return this.internalValue;
|
|
771
|
+
}
|
|
772
|
+
parseValue(value) {
|
|
773
|
+
if (!value) return /* @__PURE__ */ new Set();
|
|
774
|
+
if (value.startsWith("[")) {
|
|
775
|
+
try {
|
|
776
|
+
const arr = JSON.parse(value);
|
|
777
|
+
return new Set(Array.isArray(arr) ? arr : []);
|
|
778
|
+
} catch {
|
|
779
|
+
return /* @__PURE__ */ new Set();
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return /* @__PURE__ */ new Set([value]);
|
|
783
|
+
}
|
|
784
|
+
connectedCallback() {
|
|
785
|
+
super.connectedCallback();
|
|
786
|
+
if (!this.isControlled && this.defaultValue) {
|
|
787
|
+
this.internalValue = this.parseValue(this.defaultValue);
|
|
788
|
+
}
|
|
789
|
+
this.addEventListener("ds:accordion-toggle", this.handleItemToggle);
|
|
790
|
+
requestAnimationFrame(() => {
|
|
791
|
+
this.setupRovingFocus();
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
disconnectedCallback() {
|
|
795
|
+
super.disconnectedCallback();
|
|
796
|
+
this.removeEventListener("ds:accordion-toggle", this.handleItemToggle);
|
|
797
|
+
this.rovingFocus?.destroy();
|
|
798
|
+
this.rovingFocus = null;
|
|
799
|
+
}
|
|
800
|
+
setupRovingFocus() {
|
|
801
|
+
this.rovingFocus = createRovingFocus({
|
|
802
|
+
container: this,
|
|
803
|
+
selector: "ds-accordion-trigger:not([aria-disabled='true'])",
|
|
804
|
+
direction: this.orientation,
|
|
805
|
+
loop: true
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Toggle an item's expanded state.
|
|
810
|
+
*/
|
|
811
|
+
toggleItem(value) {
|
|
812
|
+
const items = this.querySelectorAll("ds-accordion-item");
|
|
813
|
+
const item = Array.from(items).find((i) => i.value === value);
|
|
814
|
+
if (!item || item.disabled) return;
|
|
815
|
+
const currentExpanded = this.expandedValues;
|
|
816
|
+
const isExpanded = currentExpanded.has(value);
|
|
817
|
+
let newValue;
|
|
818
|
+
if (this.type === "single") {
|
|
819
|
+
if (isExpanded) {
|
|
820
|
+
newValue = this.collapsible ? /* @__PURE__ */ new Set() : currentExpanded;
|
|
821
|
+
} else {
|
|
822
|
+
newValue = /* @__PURE__ */ new Set([value]);
|
|
823
|
+
}
|
|
824
|
+
} else {
|
|
825
|
+
newValue = new Set(currentExpanded);
|
|
826
|
+
if (isExpanded) {
|
|
827
|
+
newValue.delete(value);
|
|
828
|
+
} else {
|
|
829
|
+
newValue.add(value);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (!this.isControlled) {
|
|
833
|
+
this.internalValue = newValue;
|
|
834
|
+
}
|
|
835
|
+
const eventValue = this.type === "single" ? Array.from(newValue)[0] ?? "" : JSON.stringify(Array.from(newValue));
|
|
836
|
+
emitEvent(this, "ds:change", { detail: { value: eventValue } });
|
|
837
|
+
this.updateItems();
|
|
838
|
+
}
|
|
839
|
+
updated(changedProperties) {
|
|
840
|
+
if (changedProperties.has("value") || changedProperties.has("internalValue") || changedProperties.has("defaultValue")) {
|
|
841
|
+
this.updateItems();
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
updateItems() {
|
|
845
|
+
const expanded = this.expandedValues;
|
|
846
|
+
const items = this.querySelectorAll("ds-accordion-item");
|
|
847
|
+
for (const item of items) {
|
|
848
|
+
item.setExpanded(expanded.has(item.value));
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
render() {
|
|
852
|
+
return html11`<slot></slot>`;
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
__decorateClass([
|
|
856
|
+
property8({ reflect: true })
|
|
857
|
+
], DsAccordion.prototype, "type", 2);
|
|
858
|
+
__decorateClass([
|
|
859
|
+
property8()
|
|
860
|
+
], DsAccordion.prototype, "value", 2);
|
|
861
|
+
__decorateClass([
|
|
862
|
+
property8({ attribute: "default-value" })
|
|
863
|
+
], DsAccordion.prototype, "defaultValue", 2);
|
|
864
|
+
__decorateClass([
|
|
865
|
+
property8({ type: Boolean, reflect: true })
|
|
866
|
+
], DsAccordion.prototype, "collapsible", 2);
|
|
867
|
+
__decorateClass([
|
|
868
|
+
property8({ reflect: true })
|
|
869
|
+
], DsAccordion.prototype, "orientation", 2);
|
|
870
|
+
__decorateClass([
|
|
871
|
+
state9()
|
|
872
|
+
], DsAccordion.prototype, "internalValue", 2);
|
|
873
|
+
define("ds-accordion", DsAccordion);
|
|
874
|
+
|
|
875
|
+
// src/components/navigation-menu/navigation-menu-list.ts
|
|
876
|
+
import { html as html12 } from "lit";
|
|
877
|
+
var DsNavigationMenuList = class extends DSElement {
|
|
878
|
+
connectedCallback() {
|
|
879
|
+
super.connectedCallback();
|
|
880
|
+
this.setAttribute("role", "menubar");
|
|
881
|
+
}
|
|
882
|
+
render() {
|
|
883
|
+
return html12`<slot></slot>`;
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
define("ds-navigation-menu-list", DsNavigationMenuList);
|
|
887
|
+
|
|
888
|
+
// src/components/navigation-menu/navigation-menu-item.ts
|
|
889
|
+
import { html as html13 } from "lit";
|
|
890
|
+
import { property as property9 } from "lit/decorators.js";
|
|
891
|
+
var DsNavigationMenuItem = class extends DSElement {
|
|
892
|
+
constructor() {
|
|
893
|
+
super(...arguments);
|
|
894
|
+
this.value = "";
|
|
895
|
+
this.handleMouseEnter = () => {
|
|
896
|
+
emitEvent(this, "ds:navigation-item-enter", {
|
|
897
|
+
detail: { value: this.value },
|
|
898
|
+
bubbles: true
|
|
899
|
+
});
|
|
900
|
+
};
|
|
901
|
+
this.handleMouseLeave = () => {
|
|
902
|
+
emitEvent(this, "ds:navigation-item-leave", {
|
|
903
|
+
detail: { value: this.value },
|
|
904
|
+
bubbles: true
|
|
905
|
+
});
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
connectedCallback() {
|
|
909
|
+
super.connectedCallback();
|
|
910
|
+
this.setAttribute("role", "none");
|
|
911
|
+
this.setAttribute("data-state", "closed");
|
|
912
|
+
this.addEventListener("mouseenter", this.handleMouseEnter);
|
|
913
|
+
this.addEventListener("mouseleave", this.handleMouseLeave);
|
|
914
|
+
}
|
|
915
|
+
disconnectedCallback() {
|
|
916
|
+
super.disconnectedCallback();
|
|
917
|
+
this.removeEventListener("mouseenter", this.handleMouseEnter);
|
|
918
|
+
this.removeEventListener("mouseleave", this.handleMouseLeave);
|
|
919
|
+
}
|
|
920
|
+
render() {
|
|
921
|
+
return html13`<slot></slot>`;
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
__decorateClass([
|
|
925
|
+
property9({ type: String, reflect: true })
|
|
926
|
+
], DsNavigationMenuItem.prototype, "value", 2);
|
|
927
|
+
define("ds-navigation-menu-item", DsNavigationMenuItem);
|
|
928
|
+
|
|
929
|
+
// src/components/navigation-menu/navigation-menu-trigger.ts
|
|
930
|
+
import { html as html14 } from "lit";
|
|
931
|
+
import { property as property10 } from "lit/decorators.js";
|
|
932
|
+
var DsNavigationMenuTrigger = class extends DSElement {
|
|
933
|
+
constructor() {
|
|
934
|
+
super(...arguments);
|
|
935
|
+
this.disabled = false;
|
|
936
|
+
this.observer = null;
|
|
937
|
+
this.handleClick = () => {
|
|
938
|
+
if (this.disabled) return;
|
|
939
|
+
const value = this.getItemValue();
|
|
940
|
+
emitEvent(this, "ds:navigation-trigger", {
|
|
941
|
+
detail: { value, type: "click" },
|
|
942
|
+
bubbles: true
|
|
943
|
+
});
|
|
944
|
+
};
|
|
945
|
+
this.handleKeyDown = (event) => {
|
|
946
|
+
if (this.disabled) return;
|
|
947
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
948
|
+
event.preventDefault();
|
|
949
|
+
this.handleClick();
|
|
950
|
+
} else if (event.key === "ArrowDown") {
|
|
951
|
+
event.preventDefault();
|
|
952
|
+
const value = this.getItemValue();
|
|
953
|
+
emitEvent(this, "ds:navigation-trigger", {
|
|
954
|
+
detail: { value, type: "focus" },
|
|
955
|
+
bubbles: true
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
connectedCallback() {
|
|
961
|
+
super.connectedCallback();
|
|
962
|
+
this.setAttribute("role", "menuitem");
|
|
963
|
+
this.setAttribute("tabindex", "0");
|
|
964
|
+
this.setAttribute("aria-haspopup", "menu");
|
|
965
|
+
this.updateAriaExpanded();
|
|
966
|
+
const item = this.closest("ds-navigation-menu-item");
|
|
967
|
+
if (item) {
|
|
968
|
+
this.observer = new MutationObserver(() => {
|
|
969
|
+
this.updateAriaExpanded();
|
|
970
|
+
});
|
|
971
|
+
this.observer.observe(item, { attributes: true, attributeFilter: ["data-state"] });
|
|
972
|
+
}
|
|
973
|
+
this.addEventListener("click", this.handleClick);
|
|
974
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
975
|
+
}
|
|
976
|
+
disconnectedCallback() {
|
|
977
|
+
super.disconnectedCallback();
|
|
978
|
+
this.removeEventListener("click", this.handleClick);
|
|
979
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
980
|
+
this.observer?.disconnect();
|
|
981
|
+
this.observer = null;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Update aria-expanded based on parent item's state.
|
|
985
|
+
* Per APG, menuitem with submenu should have aria-expanded.
|
|
986
|
+
*/
|
|
987
|
+
updateAriaExpanded() {
|
|
988
|
+
const item = this.closest("ds-navigation-menu-item");
|
|
989
|
+
const isOpen = item?.getAttribute("data-state") === "open";
|
|
990
|
+
this.setAttribute("aria-expanded", String(isOpen));
|
|
991
|
+
}
|
|
992
|
+
getItemValue() {
|
|
993
|
+
const item = this.closest("ds-navigation-menu-item");
|
|
994
|
+
return item?.getAttribute("value") || "";
|
|
995
|
+
}
|
|
996
|
+
updated(changedProperties) {
|
|
997
|
+
if (changedProperties.has("disabled")) {
|
|
998
|
+
this.setAttribute("aria-disabled", String(this.disabled));
|
|
999
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0");
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
render() {
|
|
1003
|
+
return html14`<slot></slot>`;
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
__decorateClass([
|
|
1007
|
+
property10({ type: Boolean, reflect: true })
|
|
1008
|
+
], DsNavigationMenuTrigger.prototype, "disabled", 2);
|
|
1009
|
+
define("ds-navigation-menu-trigger", DsNavigationMenuTrigger);
|
|
1010
|
+
|
|
1011
|
+
// src/components/navigation-menu/navigation-menu-content.ts
|
|
1012
|
+
import { html as html15 } from "lit";
|
|
1013
|
+
var DsNavigationMenuContent = class extends DSElement {
|
|
1014
|
+
connectedCallback() {
|
|
1015
|
+
super.connectedCallback();
|
|
1016
|
+
this.setAttribute("role", "menu");
|
|
1017
|
+
}
|
|
1018
|
+
render() {
|
|
1019
|
+
return html15`<slot></slot>`;
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
define("ds-navigation-menu-content", DsNavigationMenuContent);
|
|
1023
|
+
|
|
1024
|
+
// src/components/navigation-menu/navigation-menu-link.ts
|
|
1025
|
+
import { html as html16 } from "lit";
|
|
1026
|
+
import { property as property11 } from "lit/decorators.js";
|
|
1027
|
+
var DsNavigationMenuLink = class extends DSElement {
|
|
1028
|
+
constructor() {
|
|
1029
|
+
super(...arguments);
|
|
1030
|
+
this.href = "";
|
|
1031
|
+
this.active = false;
|
|
1032
|
+
this.disabled = false;
|
|
1033
|
+
this.handleClick = (event) => {
|
|
1034
|
+
if (this.disabled) return;
|
|
1035
|
+
const navigateEvent = emitEvent(this, "ds:navigate", {
|
|
1036
|
+
detail: { href: this.href },
|
|
1037
|
+
bubbles: true,
|
|
1038
|
+
cancelable: true
|
|
1039
|
+
});
|
|
1040
|
+
if (!navigateEvent.defaultPrevented && this.href) {
|
|
1041
|
+
if (event.ctrlKey || event.metaKey) {
|
|
1042
|
+
window.open(this.href, "_blank");
|
|
1043
|
+
} else {
|
|
1044
|
+
window.location.href = this.href;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
this.handleKeyDown = (event) => {
|
|
1049
|
+
if (this.disabled) return;
|
|
1050
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1051
|
+
event.preventDefault();
|
|
1052
|
+
this.handleClick(new MouseEvent("click"));
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
connectedCallback() {
|
|
1057
|
+
super.connectedCallback();
|
|
1058
|
+
this.setAttribute("role", "menuitem");
|
|
1059
|
+
this.setAttribute("tabindex", "0");
|
|
1060
|
+
this.addEventListener("click", this.handleClick);
|
|
1061
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
1062
|
+
}
|
|
1063
|
+
disconnectedCallback() {
|
|
1064
|
+
super.disconnectedCallback();
|
|
1065
|
+
this.removeEventListener("click", this.handleClick);
|
|
1066
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
1067
|
+
}
|
|
1068
|
+
updated(changedProperties) {
|
|
1069
|
+
if (changedProperties.has("active")) {
|
|
1070
|
+
this.setAttribute("aria-current", this.active ? "page" : "false");
|
|
1071
|
+
}
|
|
1072
|
+
if (changedProperties.has("disabled")) {
|
|
1073
|
+
this.setAttribute("aria-disabled", String(this.disabled));
|
|
1074
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0");
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
render() {
|
|
1078
|
+
return html16`<slot></slot>`;
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
__decorateClass([
|
|
1082
|
+
property11({ type: String, reflect: true })
|
|
1083
|
+
], DsNavigationMenuLink.prototype, "href", 2);
|
|
1084
|
+
__decorateClass([
|
|
1085
|
+
property11({ type: Boolean, reflect: true })
|
|
1086
|
+
], DsNavigationMenuLink.prototype, "active", 2);
|
|
1087
|
+
__decorateClass([
|
|
1088
|
+
property11({ type: Boolean, reflect: true })
|
|
1089
|
+
], DsNavigationMenuLink.prototype, "disabled", 2);
|
|
1090
|
+
define("ds-navigation-menu-link", DsNavigationMenuLink);
|
|
1091
|
+
|
|
1092
|
+
// src/components/navigation-menu/navigation-menu-indicator.ts
|
|
1093
|
+
import { html as html17 } from "lit";
|
|
1094
|
+
var DsNavigationMenuIndicator = class extends DSElement {
|
|
1095
|
+
connectedCallback() {
|
|
1096
|
+
super.connectedCallback();
|
|
1097
|
+
this.setAttribute("aria-hidden", "true");
|
|
1098
|
+
}
|
|
1099
|
+
render() {
|
|
1100
|
+
return html17`<div class="ds-navigation-menu-indicator__arrow"></div>`;
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
define("ds-navigation-menu-indicator", DsNavigationMenuIndicator);
|
|
1104
|
+
|
|
1105
|
+
// src/components/navigation-menu/navigation-menu-viewport.ts
|
|
1106
|
+
import { html as html18 } from "lit";
|
|
1107
|
+
var DsNavigationMenuViewport = class extends DSElement {
|
|
1108
|
+
constructor() {
|
|
1109
|
+
super(...arguments);
|
|
1110
|
+
this.contentObserver = null;
|
|
1111
|
+
}
|
|
1112
|
+
connectedCallback() {
|
|
1113
|
+
super.connectedCallback();
|
|
1114
|
+
this.setAttribute("hidden", "");
|
|
1115
|
+
this.setAttribute("data-state", "closed");
|
|
1116
|
+
this.setupContentObserver();
|
|
1117
|
+
}
|
|
1118
|
+
disconnectedCallback() {
|
|
1119
|
+
super.disconnectedCallback();
|
|
1120
|
+
this.contentObserver?.disconnect();
|
|
1121
|
+
this.contentObserver = null;
|
|
1122
|
+
}
|
|
1123
|
+
setupContentObserver() {
|
|
1124
|
+
const menu = this.closest("ds-navigation-menu");
|
|
1125
|
+
if (!menu) return;
|
|
1126
|
+
this.contentObserver = new MutationObserver(() => {
|
|
1127
|
+
this.updateContent();
|
|
1128
|
+
});
|
|
1129
|
+
this.contentObserver.observe(menu, {
|
|
1130
|
+
attributes: true,
|
|
1131
|
+
attributeFilter: ["value"]
|
|
1132
|
+
});
|
|
1133
|
+
this.updateContent();
|
|
1134
|
+
}
|
|
1135
|
+
updateContent() {
|
|
1136
|
+
const menu = this.closest("ds-navigation-menu");
|
|
1137
|
+
if (!menu) return;
|
|
1138
|
+
const value = menu.getAttribute("value");
|
|
1139
|
+
const items = menu.querySelectorAll("ds-navigation-menu-item");
|
|
1140
|
+
this.innerHTML = "";
|
|
1141
|
+
for (const item of items) {
|
|
1142
|
+
const itemValue = item.getAttribute("value");
|
|
1143
|
+
const content = item.querySelector("ds-navigation-menu-content");
|
|
1144
|
+
if (itemValue === value && content) {
|
|
1145
|
+
const clone = content.cloneNode(true);
|
|
1146
|
+
clone.setAttribute("data-value", itemValue || "");
|
|
1147
|
+
this.appendChild(clone);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
render() {
|
|
1152
|
+
return html18`<slot></slot>`;
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
define("ds-navigation-menu-viewport", DsNavigationMenuViewport);
|
|
1156
|
+
|
|
1157
|
+
// src/components/navigation-menu/navigation-menu.ts
|
|
1158
|
+
import {
|
|
1159
|
+
createDismissableLayer,
|
|
1160
|
+
createRovingFocus as createRovingFocus2
|
|
1161
|
+
} from "@hypoth-ui/primitives-dom";
|
|
1162
|
+
import { html as html19 } from "lit";
|
|
1163
|
+
import { property as property12 } from "lit/decorators.js";
|
|
1164
|
+
var DsNavigationMenu = class extends DSElement {
|
|
1165
|
+
constructor() {
|
|
1166
|
+
super(...arguments);
|
|
1167
|
+
this.value = "";
|
|
1168
|
+
this.delayDuration = 200;
|
|
1169
|
+
this.skipDelayDuration = 300;
|
|
1170
|
+
this.orientation = "horizontal";
|
|
1171
|
+
this.rovingFocus = null;
|
|
1172
|
+
this.dismissLayer = null;
|
|
1173
|
+
this.openTimer = null;
|
|
1174
|
+
this.closeTimer = null;
|
|
1175
|
+
this.previousValue = "";
|
|
1176
|
+
this.handleTriggerInteraction = (event) => {
|
|
1177
|
+
const { value } = event.detail;
|
|
1178
|
+
if (this.value === value) {
|
|
1179
|
+
this.close();
|
|
1180
|
+
} else {
|
|
1181
|
+
this.open(value);
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
this.handleItemEnter = (event) => {
|
|
1185
|
+
const { value } = event.detail;
|
|
1186
|
+
this.clearTimers();
|
|
1187
|
+
const delay = this.value ? 0 : this.delayDuration;
|
|
1188
|
+
this.openTimer = setTimeout(() => {
|
|
1189
|
+
this.open(value);
|
|
1190
|
+
}, delay);
|
|
1191
|
+
};
|
|
1192
|
+
this.handleItemLeave = () => {
|
|
1193
|
+
this.clearTimers();
|
|
1194
|
+
this.closeTimer = setTimeout(() => {
|
|
1195
|
+
this.close();
|
|
1196
|
+
}, this.skipDelayDuration);
|
|
1197
|
+
};
|
|
1198
|
+
this.handleDismiss = () => {
|
|
1199
|
+
this.close();
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
connectedCallback() {
|
|
1203
|
+
super.connectedCallback();
|
|
1204
|
+
this.setAttribute("role", "navigation");
|
|
1205
|
+
this.setAttribute("aria-label", "Main");
|
|
1206
|
+
this.addEventListener("ds:navigation-trigger", this.handleTriggerInteraction);
|
|
1207
|
+
this.addEventListener("ds:navigation-item-enter", this.handleItemEnter);
|
|
1208
|
+
this.addEventListener("ds:navigation-item-leave", this.handleItemLeave);
|
|
1209
|
+
this.updateComplete.then(() => {
|
|
1210
|
+
this.setupRovingFocus();
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
disconnectedCallback() {
|
|
1214
|
+
super.disconnectedCallback();
|
|
1215
|
+
this.removeEventListener(
|
|
1216
|
+
"ds:navigation-trigger",
|
|
1217
|
+
this.handleTriggerInteraction
|
|
1218
|
+
);
|
|
1219
|
+
this.removeEventListener("ds:navigation-item-enter", this.handleItemEnter);
|
|
1220
|
+
this.removeEventListener("ds:navigation-item-leave", this.handleItemLeave);
|
|
1221
|
+
this.cleanup();
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Opens a navigation item by value.
|
|
1225
|
+
*/
|
|
1226
|
+
open(itemValue) {
|
|
1227
|
+
if (this.value === itemValue) return;
|
|
1228
|
+
this.clearTimers();
|
|
1229
|
+
this.previousValue = this.value;
|
|
1230
|
+
this.value = itemValue;
|
|
1231
|
+
this.updateActiveItem();
|
|
1232
|
+
this.setupDismissLayer();
|
|
1233
|
+
emitEvent(this, "ds:value-change", {
|
|
1234
|
+
detail: { value: this.value },
|
|
1235
|
+
bubbles: true
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Closes the navigation menu.
|
|
1240
|
+
*/
|
|
1241
|
+
close() {
|
|
1242
|
+
if (!this.value) return;
|
|
1243
|
+
this.clearTimers();
|
|
1244
|
+
this.previousValue = this.value;
|
|
1245
|
+
this.value = "";
|
|
1246
|
+
this.updateActiveItem();
|
|
1247
|
+
this.dismissLayer?.deactivate();
|
|
1248
|
+
this.dismissLayer = null;
|
|
1249
|
+
emitEvent(this, "ds:value-change", {
|
|
1250
|
+
detail: { value: "" },
|
|
1251
|
+
bubbles: true
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
clearTimers() {
|
|
1255
|
+
if (this.openTimer) {
|
|
1256
|
+
clearTimeout(this.openTimer);
|
|
1257
|
+
this.openTimer = null;
|
|
1258
|
+
}
|
|
1259
|
+
if (this.closeTimer) {
|
|
1260
|
+
clearTimeout(this.closeTimer);
|
|
1261
|
+
this.closeTimer = null;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
setupRovingFocus() {
|
|
1265
|
+
const list = this.querySelector("ds-navigation-menu-list");
|
|
1266
|
+
if (!list) return;
|
|
1267
|
+
this.rovingFocus = createRovingFocus2({
|
|
1268
|
+
container: list,
|
|
1269
|
+
selector: "ds-navigation-menu-trigger, ds-navigation-menu-link:not([disabled])",
|
|
1270
|
+
direction: this.orientation === "horizontal" ? "horizontal" : "vertical",
|
|
1271
|
+
loop: true,
|
|
1272
|
+
skipDisabled: true
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
setupDismissLayer() {
|
|
1276
|
+
if (this.dismissLayer) {
|
|
1277
|
+
this.dismissLayer.deactivate();
|
|
1278
|
+
}
|
|
1279
|
+
const viewport = this.querySelector("ds-navigation-menu-viewport");
|
|
1280
|
+
if (!viewport) return;
|
|
1281
|
+
this.dismissLayer = createDismissableLayer({
|
|
1282
|
+
container: viewport,
|
|
1283
|
+
excludeElements: [this],
|
|
1284
|
+
onDismiss: this.handleDismiss,
|
|
1285
|
+
closeOnEscape: true,
|
|
1286
|
+
closeOnOutsideClick: true
|
|
1287
|
+
});
|
|
1288
|
+
this.dismissLayer.activate();
|
|
1289
|
+
}
|
|
1290
|
+
updateActiveItem() {
|
|
1291
|
+
const items = this.querySelectorAll("ds-navigation-menu-item");
|
|
1292
|
+
for (const item of items) {
|
|
1293
|
+
const itemValue = item.getAttribute("value") || "";
|
|
1294
|
+
const isActive = itemValue === this.value;
|
|
1295
|
+
if (isActive) {
|
|
1296
|
+
item.setAttribute("data-state", "open");
|
|
1297
|
+
} else {
|
|
1298
|
+
item.setAttribute("data-state", "closed");
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
const viewport = this.querySelector("ds-navigation-menu-viewport");
|
|
1302
|
+
if (viewport) {
|
|
1303
|
+
if (this.value) {
|
|
1304
|
+
viewport.removeAttribute("hidden");
|
|
1305
|
+
viewport.setAttribute("data-state", "open");
|
|
1306
|
+
} else {
|
|
1307
|
+
viewport.setAttribute("data-state", "closed");
|
|
1308
|
+
setTimeout(() => {
|
|
1309
|
+
if (!this.value) {
|
|
1310
|
+
viewport.setAttribute("hidden", "");
|
|
1311
|
+
}
|
|
1312
|
+
}, 200);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
cleanup() {
|
|
1317
|
+
this.clearTimers();
|
|
1318
|
+
this.rovingFocus?.destroy();
|
|
1319
|
+
this.rovingFocus = null;
|
|
1320
|
+
this.dismissLayer?.deactivate();
|
|
1321
|
+
this.dismissLayer = null;
|
|
1322
|
+
}
|
|
1323
|
+
updated(changedProperties) {
|
|
1324
|
+
if (changedProperties.has("value")) {
|
|
1325
|
+
this.updateActiveItem();
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
render() {
|
|
1329
|
+
return html19`<slot></slot>`;
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
__decorateClass([
|
|
1333
|
+
property12({ type: String, reflect: true })
|
|
1334
|
+
], DsNavigationMenu.prototype, "value", 2);
|
|
1335
|
+
__decorateClass([
|
|
1336
|
+
property12({ type: Number, attribute: "delay-duration" })
|
|
1337
|
+
], DsNavigationMenu.prototype, "delayDuration", 2);
|
|
1338
|
+
__decorateClass([
|
|
1339
|
+
property12({ type: Number, attribute: "skip-delay-duration" })
|
|
1340
|
+
], DsNavigationMenu.prototype, "skipDelayDuration", 2);
|
|
1341
|
+
__decorateClass([
|
|
1342
|
+
property12({ type: String, reflect: true })
|
|
1343
|
+
], DsNavigationMenu.prototype, "orientation", 2);
|
|
1344
|
+
define("ds-navigation-menu", DsNavigationMenu);
|
|
1345
|
+
|
|
1346
|
+
// src/components/scroll-area/scroll-area-viewport.ts
|
|
1347
|
+
import { html as html20 } from "lit";
|
|
1348
|
+
var DsScrollAreaViewport = class extends DSElement {
|
|
1349
|
+
constructor() {
|
|
1350
|
+
super(...arguments);
|
|
1351
|
+
this.resizeObserver = null;
|
|
1352
|
+
this.handleScroll = () => {
|
|
1353
|
+
this.updateScrollbarPositions();
|
|
1354
|
+
emitEvent(this, "ds:scroll", {
|
|
1355
|
+
detail: {
|
|
1356
|
+
scrollTop: this.scrollTop,
|
|
1357
|
+
scrollLeft: this.scrollLeft,
|
|
1358
|
+
scrollHeight: this.scrollHeight,
|
|
1359
|
+
scrollWidth: this.scrollWidth
|
|
1360
|
+
},
|
|
1361
|
+
bubbles: true
|
|
1362
|
+
});
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
connectedCallback() {
|
|
1366
|
+
super.connectedCallback();
|
|
1367
|
+
this.setAttribute("tabindex", "0");
|
|
1368
|
+
this.addEventListener("scroll", this.handleScroll);
|
|
1369
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
1370
|
+
this.updateOverflowState();
|
|
1371
|
+
});
|
|
1372
|
+
this.resizeObserver.observe(this);
|
|
1373
|
+
this.updateComplete.then(() => {
|
|
1374
|
+
this.updateOverflowState();
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
disconnectedCallback() {
|
|
1378
|
+
super.disconnectedCallback();
|
|
1379
|
+
this.removeEventListener("scroll", this.handleScroll);
|
|
1380
|
+
this.resizeObserver?.disconnect();
|
|
1381
|
+
this.resizeObserver = null;
|
|
1382
|
+
}
|
|
1383
|
+
updateOverflowState() {
|
|
1384
|
+
const hasVerticalOverflow = this.scrollHeight > this.clientHeight;
|
|
1385
|
+
const hasHorizontalOverflow = this.scrollWidth > this.clientWidth;
|
|
1386
|
+
this.toggleAttribute("data-overflow-y", hasVerticalOverflow);
|
|
1387
|
+
this.toggleAttribute("data-overflow-x", hasHorizontalOverflow);
|
|
1388
|
+
const scrollArea = this.closest("ds-scroll-area");
|
|
1389
|
+
if (scrollArea) {
|
|
1390
|
+
scrollArea.toggleAttribute("data-overflow-y", hasVerticalOverflow);
|
|
1391
|
+
scrollArea.toggleAttribute("data-overflow-x", hasHorizontalOverflow);
|
|
1392
|
+
}
|
|
1393
|
+
this.updateScrollbarPositions();
|
|
1394
|
+
}
|
|
1395
|
+
updateScrollbarPositions() {
|
|
1396
|
+
const scrollArea = this.closest("ds-scroll-area");
|
|
1397
|
+
if (!scrollArea) return;
|
|
1398
|
+
const scrollbars = scrollArea.querySelectorAll("ds-scroll-area-scrollbar");
|
|
1399
|
+
for (const scrollbar of scrollbars) {
|
|
1400
|
+
const orientation = scrollbar.getAttribute("orientation") || "vertical";
|
|
1401
|
+
const thumb = scrollbar.querySelector("ds-scroll-area-thumb");
|
|
1402
|
+
if (!thumb) continue;
|
|
1403
|
+
if (orientation === "vertical") {
|
|
1404
|
+
const scrollRatio = this.scrollTop / (this.scrollHeight - this.clientHeight);
|
|
1405
|
+
const thumbHeight = this.clientHeight / this.scrollHeight * 100;
|
|
1406
|
+
const thumbTop = scrollRatio * (100 - thumbHeight);
|
|
1407
|
+
thumb.style.height = `${Math.max(10, thumbHeight)}%`;
|
|
1408
|
+
thumb.style.top = `${thumbTop}%`;
|
|
1409
|
+
} else {
|
|
1410
|
+
const scrollRatio = this.scrollLeft / (this.scrollWidth - this.clientWidth);
|
|
1411
|
+
const thumbWidth = this.clientWidth / this.scrollWidth * 100;
|
|
1412
|
+
const thumbLeft = scrollRatio * (100 - thumbWidth);
|
|
1413
|
+
thumb.style.width = `${Math.max(10, thumbWidth)}%`;
|
|
1414
|
+
thumb.style.left = `${thumbLeft}%`;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Scrolls to a specific position.
|
|
1420
|
+
*/
|
|
1421
|
+
scrollToPosition(options) {
|
|
1422
|
+
this.scrollTo(options);
|
|
1423
|
+
}
|
|
1424
|
+
render() {
|
|
1425
|
+
return html20`<slot></slot>`;
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
define("ds-scroll-area-viewport", DsScrollAreaViewport);
|
|
1429
|
+
|
|
1430
|
+
// src/components/scroll-area/scroll-area-scrollbar.ts
|
|
1431
|
+
import { html as html21 } from "lit";
|
|
1432
|
+
import { property as property13 } from "lit/decorators.js";
|
|
1433
|
+
var DsScrollAreaScrollbar = class extends DSElement {
|
|
1434
|
+
constructor() {
|
|
1435
|
+
super(...arguments);
|
|
1436
|
+
this.orientation = "vertical";
|
|
1437
|
+
this.hideTimer = null;
|
|
1438
|
+
this.isHovered = false;
|
|
1439
|
+
this.handleTrackClick = (event) => {
|
|
1440
|
+
const thumb = event.target;
|
|
1441
|
+
if (thumb.tagName === "DS-SCROLL-AREA-THUMB") return;
|
|
1442
|
+
const scrollArea = this.closest("ds-scroll-area");
|
|
1443
|
+
const viewport = scrollArea?.querySelector("ds-scroll-area-viewport");
|
|
1444
|
+
if (!viewport) return;
|
|
1445
|
+
const rect = this.getBoundingClientRect();
|
|
1446
|
+
if (this.orientation === "vertical") {
|
|
1447
|
+
const clickRatio = (event.clientY - rect.top) / rect.height;
|
|
1448
|
+
const scrollHeight = viewport.scrollHeight - viewport.clientHeight;
|
|
1449
|
+
viewport.scrollTo({
|
|
1450
|
+
top: clickRatio * scrollHeight,
|
|
1451
|
+
behavior: "smooth"
|
|
1452
|
+
});
|
|
1453
|
+
} else {
|
|
1454
|
+
const clickRatio = (event.clientX - rect.left) / rect.width;
|
|
1455
|
+
const scrollWidth = viewport.scrollWidth - viewport.clientWidth;
|
|
1456
|
+
viewport.scrollTo({
|
|
1457
|
+
left: clickRatio * scrollWidth,
|
|
1458
|
+
behavior: "smooth"
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
this.handleViewportScroll = () => {
|
|
1463
|
+
this.setAttribute("data-state", "visible");
|
|
1464
|
+
this.scheduleHide();
|
|
1465
|
+
};
|
|
1466
|
+
this.handleMouseEnter = () => {
|
|
1467
|
+
this.isHovered = true;
|
|
1468
|
+
if (this.hideTimer) {
|
|
1469
|
+
clearTimeout(this.hideTimer);
|
|
1470
|
+
this.hideTimer = null;
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
this.handleMouseLeave = () => {
|
|
1474
|
+
this.isHovered = false;
|
|
1475
|
+
this.scheduleHide();
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
connectedCallback() {
|
|
1479
|
+
super.connectedCallback();
|
|
1480
|
+
this.setAttribute("role", "scrollbar");
|
|
1481
|
+
this.setAttribute("aria-orientation", this.orientation);
|
|
1482
|
+
this.addEventListener("mousedown", this.handleTrackClick);
|
|
1483
|
+
this.addEventListener("mouseenter", this.handleMouseEnter);
|
|
1484
|
+
this.addEventListener("mouseleave", this.handleMouseLeave);
|
|
1485
|
+
const scrollArea = this.closest("ds-scroll-area");
|
|
1486
|
+
const viewport = scrollArea?.querySelector("ds-scroll-area-viewport");
|
|
1487
|
+
if (viewport) {
|
|
1488
|
+
viewport.addEventListener("scroll", this.handleViewportScroll);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
disconnectedCallback() {
|
|
1492
|
+
super.disconnectedCallback();
|
|
1493
|
+
this.removeEventListener("mousedown", this.handleTrackClick);
|
|
1494
|
+
this.removeEventListener("mouseenter", this.handleMouseEnter);
|
|
1495
|
+
this.removeEventListener("mouseleave", this.handleMouseLeave);
|
|
1496
|
+
if (this.hideTimer) {
|
|
1497
|
+
clearTimeout(this.hideTimer);
|
|
1498
|
+
}
|
|
1499
|
+
const scrollArea = this.closest("ds-scroll-area");
|
|
1500
|
+
const viewport = scrollArea?.querySelector("ds-scroll-area-viewport");
|
|
1501
|
+
if (viewport) {
|
|
1502
|
+
viewport.removeEventListener("scroll", this.handleViewportScroll);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
scheduleHide() {
|
|
1506
|
+
const scrollArea = this.closest("ds-scroll-area");
|
|
1507
|
+
const type = scrollArea?.getAttribute("type") || "hover";
|
|
1508
|
+
if (type !== "hover") return;
|
|
1509
|
+
if (this.hideTimer) {
|
|
1510
|
+
clearTimeout(this.hideTimer);
|
|
1511
|
+
}
|
|
1512
|
+
const delay = Number(scrollArea?.getAttribute("scroll-hide-delay")) || 600;
|
|
1513
|
+
this.hideTimer = setTimeout(() => {
|
|
1514
|
+
if (!this.isHovered) {
|
|
1515
|
+
this.setAttribute("data-state", "hidden");
|
|
1516
|
+
}
|
|
1517
|
+
}, delay);
|
|
1518
|
+
}
|
|
1519
|
+
updated(changedProperties) {
|
|
1520
|
+
if (changedProperties.has("orientation")) {
|
|
1521
|
+
this.setAttribute("aria-orientation", this.orientation);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
render() {
|
|
1525
|
+
return html21`<slot></slot>`;
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
__decorateClass([
|
|
1529
|
+
property13({ type: String, reflect: true })
|
|
1530
|
+
], DsScrollAreaScrollbar.prototype, "orientation", 2);
|
|
1531
|
+
define("ds-scroll-area-scrollbar", DsScrollAreaScrollbar);
|
|
1532
|
+
|
|
1533
|
+
// src/components/scroll-area/scroll-area-thumb.ts
|
|
1534
|
+
import { html as html22 } from "lit";
|
|
1535
|
+
var DsScrollAreaThumb = class extends DSElement {
|
|
1536
|
+
constructor() {
|
|
1537
|
+
super(...arguments);
|
|
1538
|
+
this.isDragging = false;
|
|
1539
|
+
this.startY = 0;
|
|
1540
|
+
this.startX = 0;
|
|
1541
|
+
this.startScrollTop = 0;
|
|
1542
|
+
this.startScrollLeft = 0;
|
|
1543
|
+
/** Cached scrollbar dimensions to avoid layout thrashing during drag */
|
|
1544
|
+
this.cachedDimensions = { width: 0, height: 0 };
|
|
1545
|
+
/** ResizeObserver for tracking scrollbar size changes */
|
|
1546
|
+
this.resizeObserver = null;
|
|
1547
|
+
/** Scrollbar element reference for ResizeObserver */
|
|
1548
|
+
this.scrollbarElement = null;
|
|
1549
|
+
this.handleMouseDown = (event) => {
|
|
1550
|
+
event.preventDefault();
|
|
1551
|
+
this.startDrag(event.clientX, event.clientY);
|
|
1552
|
+
document.addEventListener("mousemove", this.handleMouseMove);
|
|
1553
|
+
document.addEventListener("mouseup", this.handleMouseUp);
|
|
1554
|
+
};
|
|
1555
|
+
this.handleMouseMove = (event) => {
|
|
1556
|
+
if (!this.isDragging) return;
|
|
1557
|
+
this.drag(event.clientX, event.clientY);
|
|
1558
|
+
};
|
|
1559
|
+
this.handleMouseUp = () => {
|
|
1560
|
+
this.cleanupDrag();
|
|
1561
|
+
};
|
|
1562
|
+
this.handleTouchStart = (event) => {
|
|
1563
|
+
const touch = event.touches[0];
|
|
1564
|
+
if (!touch) return;
|
|
1565
|
+
event.preventDefault();
|
|
1566
|
+
this.startDrag(touch.clientX, touch.clientY);
|
|
1567
|
+
document.addEventListener("touchmove", this.handleTouchMove, { passive: false });
|
|
1568
|
+
document.addEventListener("touchend", this.handleTouchEnd);
|
|
1569
|
+
};
|
|
1570
|
+
this.handleTouchMove = (event) => {
|
|
1571
|
+
if (!this.isDragging) return;
|
|
1572
|
+
const touch = event.touches[0];
|
|
1573
|
+
if (!touch) return;
|
|
1574
|
+
event.preventDefault();
|
|
1575
|
+
this.drag(touch.clientX, touch.clientY);
|
|
1576
|
+
};
|
|
1577
|
+
this.handleTouchEnd = () => {
|
|
1578
|
+
this.cleanupDrag();
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
connectedCallback() {
|
|
1582
|
+
super.connectedCallback();
|
|
1583
|
+
this.addEventListener("mousedown", this.handleMouseDown);
|
|
1584
|
+
this.addEventListener("touchstart", this.handleTouchStart, { passive: false });
|
|
1585
|
+
this.setupResizeObserver();
|
|
1586
|
+
}
|
|
1587
|
+
disconnectedCallback() {
|
|
1588
|
+
super.disconnectedCallback();
|
|
1589
|
+
this.removeEventListener("mousedown", this.handleMouseDown);
|
|
1590
|
+
this.removeEventListener("touchstart", this.handleTouchStart);
|
|
1591
|
+
this.cleanupDrag();
|
|
1592
|
+
this.cleanupResizeObserver();
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Set up ResizeObserver to cache scrollbar dimensions.
|
|
1596
|
+
* This avoids calling getBoundingClientRect on every drag event.
|
|
1597
|
+
*/
|
|
1598
|
+
setupResizeObserver() {
|
|
1599
|
+
this.cleanupResizeObserver();
|
|
1600
|
+
const scrollbar = this.closest("ds-scroll-area-scrollbar");
|
|
1601
|
+
if (!scrollbar) return;
|
|
1602
|
+
this.scrollbarElement = scrollbar;
|
|
1603
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
1604
|
+
for (const entry of entries) {
|
|
1605
|
+
if (entry.target === this.scrollbarElement) {
|
|
1606
|
+
this.cachedDimensions = {
|
|
1607
|
+
width: entry.contentRect.width,
|
|
1608
|
+
height: entry.contentRect.height
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
this.resizeObserver.observe(scrollbar);
|
|
1614
|
+
const rect = scrollbar.getBoundingClientRect();
|
|
1615
|
+
this.cachedDimensions = {
|
|
1616
|
+
width: rect.width,
|
|
1617
|
+
height: rect.height
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Clean up ResizeObserver on disconnect.
|
|
1622
|
+
*/
|
|
1623
|
+
cleanupResizeObserver() {
|
|
1624
|
+
if (this.resizeObserver) {
|
|
1625
|
+
this.resizeObserver.disconnect();
|
|
1626
|
+
this.resizeObserver = null;
|
|
1627
|
+
}
|
|
1628
|
+
this.scrollbarElement = null;
|
|
1629
|
+
}
|
|
1630
|
+
getViewport() {
|
|
1631
|
+
const scrollArea = this.closest("ds-scroll-area");
|
|
1632
|
+
return scrollArea?.querySelector("ds-scroll-area-viewport") || null;
|
|
1633
|
+
}
|
|
1634
|
+
getOrientation() {
|
|
1635
|
+
const scrollbar = this.closest("ds-scroll-area-scrollbar");
|
|
1636
|
+
return scrollbar?.getAttribute("orientation") || "vertical";
|
|
1637
|
+
}
|
|
1638
|
+
startDrag(clientX, clientY) {
|
|
1639
|
+
const viewport = this.getViewport();
|
|
1640
|
+
if (!viewport) return;
|
|
1641
|
+
this.isDragging = true;
|
|
1642
|
+
this.startX = clientX;
|
|
1643
|
+
this.startY = clientY;
|
|
1644
|
+
this.startScrollTop = viewport.scrollTop;
|
|
1645
|
+
this.startScrollLeft = viewport.scrollLeft;
|
|
1646
|
+
this.setAttribute("data-dragging", "");
|
|
1647
|
+
document.body.style.userSelect = "none";
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Handle drag movement using cached dimensions.
|
|
1651
|
+
* Uses ResizeObserver-cached values instead of getBoundingClientRect
|
|
1652
|
+
* to avoid layout thrashing during drag operations.
|
|
1653
|
+
*/
|
|
1654
|
+
drag(clientX, clientY) {
|
|
1655
|
+
const viewport = this.getViewport();
|
|
1656
|
+
if (!viewport) return;
|
|
1657
|
+
const orientation = this.getOrientation();
|
|
1658
|
+
const { width: trackWidth, height: trackHeight } = this.cachedDimensions;
|
|
1659
|
+
if (orientation === "vertical") {
|
|
1660
|
+
const deltaY = clientY - this.startY;
|
|
1661
|
+
const scrollableHeight = viewport.scrollHeight - viewport.clientHeight;
|
|
1662
|
+
if (trackHeight > 0 && scrollableHeight > 0) {
|
|
1663
|
+
const scrollDelta = deltaY / trackHeight * scrollableHeight;
|
|
1664
|
+
viewport.scrollTop = this.startScrollTop + scrollDelta;
|
|
1665
|
+
}
|
|
1666
|
+
} else {
|
|
1667
|
+
const deltaX = clientX - this.startX;
|
|
1668
|
+
const scrollableWidth = viewport.scrollWidth - viewport.clientWidth;
|
|
1669
|
+
if (trackWidth > 0 && scrollableWidth > 0) {
|
|
1670
|
+
const scrollDelta = deltaX / trackWidth * scrollableWidth;
|
|
1671
|
+
viewport.scrollLeft = this.startScrollLeft + scrollDelta;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
cleanupDrag() {
|
|
1676
|
+
this.isDragging = false;
|
|
1677
|
+
this.removeAttribute("data-dragging");
|
|
1678
|
+
document.body.style.userSelect = "";
|
|
1679
|
+
document.removeEventListener("mousemove", this.handleMouseMove);
|
|
1680
|
+
document.removeEventListener("mouseup", this.handleMouseUp);
|
|
1681
|
+
document.removeEventListener("touchmove", this.handleTouchMove);
|
|
1682
|
+
document.removeEventListener("touchend", this.handleTouchEnd);
|
|
1683
|
+
}
|
|
1684
|
+
render() {
|
|
1685
|
+
return html22``;
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
define("ds-scroll-area-thumb", DsScrollAreaThumb);
|
|
1689
|
+
|
|
1690
|
+
// src/components/scroll-area/scroll-area.ts
|
|
1691
|
+
import { html as html23 } from "lit";
|
|
1692
|
+
import { property as property14 } from "lit/decorators.js";
|
|
1693
|
+
var DsScrollArea = class extends DSElement {
|
|
1694
|
+
constructor() {
|
|
1695
|
+
super(...arguments);
|
|
1696
|
+
this.type = "hover";
|
|
1697
|
+
this.scrollHideDelay = 600;
|
|
1698
|
+
this.orientation = "vertical";
|
|
1699
|
+
}
|
|
1700
|
+
connectedCallback() {
|
|
1701
|
+
super.connectedCallback();
|
|
1702
|
+
}
|
|
1703
|
+
render() {
|
|
1704
|
+
return html23`<slot></slot>`;
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
__decorateClass([
|
|
1708
|
+
property14({ type: String, reflect: true })
|
|
1709
|
+
], DsScrollArea.prototype, "type", 2);
|
|
1710
|
+
__decorateClass([
|
|
1711
|
+
property14({ type: Number, attribute: "scroll-hide-delay" })
|
|
1712
|
+
], DsScrollArea.prototype, "scrollHideDelay", 2);
|
|
1713
|
+
__decorateClass([
|
|
1714
|
+
property14({ type: String, reflect: true })
|
|
1715
|
+
], DsScrollArea.prototype, "orientation", 2);
|
|
1716
|
+
define("ds-scroll-area", DsScrollArea);
|
|
1717
|
+
|
|
1718
|
+
// src/components/breadcrumb/breadcrumb-list.ts
|
|
1719
|
+
import { html as html24 } from "lit";
|
|
1720
|
+
var DsBreadcrumbList = class extends DSElement {
|
|
1721
|
+
connectedCallback() {
|
|
1722
|
+
super.connectedCallback();
|
|
1723
|
+
this.setAttribute("role", "list");
|
|
1724
|
+
}
|
|
1725
|
+
render() {
|
|
1726
|
+
return html24`<slot></slot>`;
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
define("ds-breadcrumb-list", DsBreadcrumbList);
|
|
1730
|
+
|
|
1731
|
+
// src/components/breadcrumb/breadcrumb-item.ts
|
|
1732
|
+
import { html as html25 } from "lit";
|
|
1733
|
+
var DsBreadcrumbItem = class extends DSElement {
|
|
1734
|
+
connectedCallback() {
|
|
1735
|
+
super.connectedCallback();
|
|
1736
|
+
this.setAttribute("role", "listitem");
|
|
1737
|
+
}
|
|
1738
|
+
render() {
|
|
1739
|
+
return html25`<slot></slot>`;
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
define("ds-breadcrumb-item", DsBreadcrumbItem);
|
|
1743
|
+
|
|
1744
|
+
// src/components/breadcrumb/breadcrumb-link.ts
|
|
1745
|
+
import { html as html26 } from "lit";
|
|
1746
|
+
import { property as property15 } from "lit/decorators.js";
|
|
1747
|
+
var DsBreadcrumbLink = class extends DSElement {
|
|
1748
|
+
constructor() {
|
|
1749
|
+
super(...arguments);
|
|
1750
|
+
this.href = "";
|
|
1751
|
+
this.handleClick = (event) => {
|
|
1752
|
+
const navigateEvent = emitEvent(this, "ds:navigate", {
|
|
1753
|
+
detail: { href: this.href },
|
|
1754
|
+
bubbles: true,
|
|
1755
|
+
cancelable: true
|
|
1756
|
+
});
|
|
1757
|
+
if (!navigateEvent.defaultPrevented && this.href) {
|
|
1758
|
+
if (event.ctrlKey || event.metaKey) {
|
|
1759
|
+
window.open(this.href, "_blank");
|
|
1760
|
+
} else {
|
|
1761
|
+
window.location.href = this.href;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
this.handleKeyDown = (event) => {
|
|
1766
|
+
if (event.key === "Enter") {
|
|
1767
|
+
event.preventDefault();
|
|
1768
|
+
this.handleClick(new MouseEvent("click"));
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
connectedCallback() {
|
|
1773
|
+
super.connectedCallback();
|
|
1774
|
+
this.setAttribute("tabindex", "0");
|
|
1775
|
+
this.addEventListener("click", this.handleClick);
|
|
1776
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
1777
|
+
}
|
|
1778
|
+
disconnectedCallback() {
|
|
1779
|
+
super.disconnectedCallback();
|
|
1780
|
+
this.removeEventListener("click", this.handleClick);
|
|
1781
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
1782
|
+
}
|
|
1783
|
+
render() {
|
|
1784
|
+
return html26`<slot></slot>`;
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
__decorateClass([
|
|
1788
|
+
property15({ type: String, reflect: true })
|
|
1789
|
+
], DsBreadcrumbLink.prototype, "href", 2);
|
|
1790
|
+
define("ds-breadcrumb-link", DsBreadcrumbLink);
|
|
1791
|
+
|
|
1792
|
+
// src/components/breadcrumb/breadcrumb-page.ts
|
|
1793
|
+
import { html as html27 } from "lit";
|
|
1794
|
+
var DsBreadcrumbPage = class extends DSElement {
|
|
1795
|
+
connectedCallback() {
|
|
1796
|
+
super.connectedCallback();
|
|
1797
|
+
this.setAttribute("role", "link");
|
|
1798
|
+
this.setAttribute("aria-current", "page");
|
|
1799
|
+
this.setAttribute("aria-disabled", "true");
|
|
1800
|
+
}
|
|
1801
|
+
render() {
|
|
1802
|
+
return html27`<slot></slot>`;
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
define("ds-breadcrumb-page", DsBreadcrumbPage);
|
|
1806
|
+
|
|
1807
|
+
// src/components/breadcrumb/breadcrumb-separator.ts
|
|
1808
|
+
import { html as html28 } from "lit";
|
|
1809
|
+
var DsBreadcrumbSeparator = class extends DSElement {
|
|
1810
|
+
connectedCallback() {
|
|
1811
|
+
super.connectedCallback();
|
|
1812
|
+
this.setAttribute("role", "presentation");
|
|
1813
|
+
this.setAttribute("aria-hidden", "true");
|
|
1814
|
+
}
|
|
1815
|
+
render() {
|
|
1816
|
+
return html28`<slot>/</slot>`;
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
define("ds-breadcrumb-separator", DsBreadcrumbSeparator);
|
|
1820
|
+
|
|
1821
|
+
// src/components/breadcrumb/breadcrumb.ts
|
|
1822
|
+
import { html as html29 } from "lit";
|
|
1823
|
+
var DsBreadcrumb = class extends DSElement {
|
|
1824
|
+
connectedCallback() {
|
|
1825
|
+
super.connectedCallback();
|
|
1826
|
+
this.setAttribute("role", "navigation");
|
|
1827
|
+
this.setAttribute("aria-label", "Breadcrumb");
|
|
1828
|
+
}
|
|
1829
|
+
render() {
|
|
1830
|
+
return html29`<slot></slot>`;
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
define("ds-breadcrumb", DsBreadcrumb);
|
|
1834
|
+
|
|
1835
|
+
// src/components/pagination/pagination-content.ts
|
|
1836
|
+
import { html as html30 } from "lit";
|
|
1837
|
+
var DsPaginationContent = class extends DSElement {
|
|
1838
|
+
connectedCallback() {
|
|
1839
|
+
super.connectedCallback();
|
|
1840
|
+
this.setAttribute("role", "list");
|
|
1841
|
+
}
|
|
1842
|
+
render() {
|
|
1843
|
+
return html30`<slot></slot>`;
|
|
1844
|
+
}
|
|
1845
|
+
};
|
|
1846
|
+
define("ds-pagination-content", DsPaginationContent);
|
|
1847
|
+
|
|
1848
|
+
// src/components/pagination/pagination-item.ts
|
|
1849
|
+
import { html as html31 } from "lit";
|
|
1850
|
+
var DsPaginationItem = class extends DSElement {
|
|
1851
|
+
connectedCallback() {
|
|
1852
|
+
super.connectedCallback();
|
|
1853
|
+
this.setAttribute("role", "listitem");
|
|
1854
|
+
}
|
|
1855
|
+
render() {
|
|
1856
|
+
return html31`<slot></slot>`;
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
define("ds-pagination-item", DsPaginationItem);
|
|
1860
|
+
|
|
1861
|
+
// src/components/pagination/pagination-link.ts
|
|
1862
|
+
import { html as html32 } from "lit";
|
|
1863
|
+
import { property as property16 } from "lit/decorators.js";
|
|
1864
|
+
var DsPaginationLink = class extends DSElement {
|
|
1865
|
+
constructor() {
|
|
1866
|
+
super(...arguments);
|
|
1867
|
+
this.page = 1;
|
|
1868
|
+
this.active = false;
|
|
1869
|
+
this.handleClick = () => {
|
|
1870
|
+
if (this.active) return;
|
|
1871
|
+
emitEvent(this, "ds:page-select", {
|
|
1872
|
+
detail: { page: this.page },
|
|
1873
|
+
bubbles: true
|
|
1874
|
+
});
|
|
1875
|
+
};
|
|
1876
|
+
this.handleKeyDown = (event) => {
|
|
1877
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1878
|
+
event.preventDefault();
|
|
1879
|
+
this.handleClick();
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
connectedCallback() {
|
|
1884
|
+
super.connectedCallback();
|
|
1885
|
+
this.setAttribute("role", "button");
|
|
1886
|
+
this.setAttribute("tabindex", "0");
|
|
1887
|
+
this.addEventListener("click", this.handleClick);
|
|
1888
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
1889
|
+
}
|
|
1890
|
+
disconnectedCallback() {
|
|
1891
|
+
super.disconnectedCallback();
|
|
1892
|
+
this.removeEventListener("click", this.handleClick);
|
|
1893
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
1894
|
+
}
|
|
1895
|
+
updated(changedProperties) {
|
|
1896
|
+
if (changedProperties.has("active")) {
|
|
1897
|
+
if (this.active) {
|
|
1898
|
+
this.setAttribute("aria-current", "page");
|
|
1899
|
+
} else {
|
|
1900
|
+
this.removeAttribute("aria-current");
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
render() {
|
|
1905
|
+
return html32`<slot></slot>`;
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1908
|
+
__decorateClass([
|
|
1909
|
+
property16({ type: Number, reflect: true })
|
|
1910
|
+
], DsPaginationLink.prototype, "page", 2);
|
|
1911
|
+
__decorateClass([
|
|
1912
|
+
property16({ type: Boolean, reflect: true })
|
|
1913
|
+
], DsPaginationLink.prototype, "active", 2);
|
|
1914
|
+
define("ds-pagination-link", DsPaginationLink);
|
|
1915
|
+
|
|
1916
|
+
// src/components/pagination/pagination-previous.ts
|
|
1917
|
+
import { html as html33 } from "lit";
|
|
1918
|
+
import { property as property17 } from "lit/decorators.js";
|
|
1919
|
+
var DsPaginationPrevious = class extends DSElement {
|
|
1920
|
+
constructor() {
|
|
1921
|
+
super(...arguments);
|
|
1922
|
+
this.disabled = false;
|
|
1923
|
+
this.handleClick = () => {
|
|
1924
|
+
if (this.disabled) return;
|
|
1925
|
+
const pagination = this.closest("ds-pagination");
|
|
1926
|
+
pagination?.previousPage();
|
|
1927
|
+
};
|
|
1928
|
+
this.handleKeyDown = (event) => {
|
|
1929
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1930
|
+
event.preventDefault();
|
|
1931
|
+
this.handleClick();
|
|
1932
|
+
}
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
connectedCallback() {
|
|
1936
|
+
super.connectedCallback();
|
|
1937
|
+
this.setAttribute("role", "button");
|
|
1938
|
+
this.setAttribute("tabindex", "0");
|
|
1939
|
+
this.setAttribute("aria-label", "Go to previous page");
|
|
1940
|
+
this.addEventListener("click", this.handleClick);
|
|
1941
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
1942
|
+
}
|
|
1943
|
+
disconnectedCallback() {
|
|
1944
|
+
super.disconnectedCallback();
|
|
1945
|
+
this.removeEventListener("click", this.handleClick);
|
|
1946
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
1947
|
+
}
|
|
1948
|
+
updated(changedProperties) {
|
|
1949
|
+
if (changedProperties.has("disabled")) {
|
|
1950
|
+
this.setAttribute("aria-disabled", String(this.disabled));
|
|
1951
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0");
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
render() {
|
|
1955
|
+
return html33`<slot>Previous</slot>`;
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
__decorateClass([
|
|
1959
|
+
property17({ type: Boolean, reflect: true })
|
|
1960
|
+
], DsPaginationPrevious.prototype, "disabled", 2);
|
|
1961
|
+
define("ds-pagination-previous", DsPaginationPrevious);
|
|
1962
|
+
|
|
1963
|
+
// src/components/pagination/pagination-next.ts
|
|
1964
|
+
import { html as html34 } from "lit";
|
|
1965
|
+
import { property as property18 } from "lit/decorators.js";
|
|
1966
|
+
var DsPaginationNext = class extends DSElement {
|
|
1967
|
+
constructor() {
|
|
1968
|
+
super(...arguments);
|
|
1969
|
+
this.disabled = false;
|
|
1970
|
+
this.handleClick = () => {
|
|
1971
|
+
if (this.disabled) return;
|
|
1972
|
+
const pagination = this.closest("ds-pagination");
|
|
1973
|
+
pagination?.nextPage();
|
|
1974
|
+
};
|
|
1975
|
+
this.handleKeyDown = (event) => {
|
|
1976
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1977
|
+
event.preventDefault();
|
|
1978
|
+
this.handleClick();
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
connectedCallback() {
|
|
1983
|
+
super.connectedCallback();
|
|
1984
|
+
this.setAttribute("role", "button");
|
|
1985
|
+
this.setAttribute("tabindex", "0");
|
|
1986
|
+
this.setAttribute("aria-label", "Go to next page");
|
|
1987
|
+
this.addEventListener("click", this.handleClick);
|
|
1988
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
1989
|
+
}
|
|
1990
|
+
disconnectedCallback() {
|
|
1991
|
+
super.disconnectedCallback();
|
|
1992
|
+
this.removeEventListener("click", this.handleClick);
|
|
1993
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
1994
|
+
}
|
|
1995
|
+
updated(changedProperties) {
|
|
1996
|
+
if (changedProperties.has("disabled")) {
|
|
1997
|
+
this.setAttribute("aria-disabled", String(this.disabled));
|
|
1998
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0");
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
render() {
|
|
2002
|
+
return html34`<slot>Next</slot>`;
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
__decorateClass([
|
|
2006
|
+
property18({ type: Boolean, reflect: true })
|
|
2007
|
+
], DsPaginationNext.prototype, "disabled", 2);
|
|
2008
|
+
define("ds-pagination-next", DsPaginationNext);
|
|
2009
|
+
|
|
2010
|
+
// src/components/pagination/pagination-ellipsis.ts
|
|
2011
|
+
import { html as html35 } from "lit";
|
|
2012
|
+
var DsPaginationEllipsis = class extends DSElement {
|
|
2013
|
+
connectedCallback() {
|
|
2014
|
+
super.connectedCallback();
|
|
2015
|
+
this.setAttribute("aria-hidden", "true");
|
|
2016
|
+
}
|
|
2017
|
+
render() {
|
|
2018
|
+
return html35`<span>...</span>`;
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
define("ds-pagination-ellipsis", DsPaginationEllipsis);
|
|
2022
|
+
|
|
2023
|
+
// src/components/pagination/pagination.ts
|
|
2024
|
+
import { html as html36 } from "lit";
|
|
2025
|
+
import { property as property19 } from "lit/decorators.js";
|
|
2026
|
+
var DsPagination = class extends DSElement {
|
|
2027
|
+
constructor() {
|
|
2028
|
+
super(...arguments);
|
|
2029
|
+
this.page = 1;
|
|
2030
|
+
this.totalPages = 1;
|
|
2031
|
+
this.siblingCount = 1;
|
|
2032
|
+
this.boundaryCount = 1;
|
|
2033
|
+
this.handlePageSelect = (event) => {
|
|
2034
|
+
event.stopPropagation();
|
|
2035
|
+
this.goToPage(event.detail.page);
|
|
2036
|
+
};
|
|
2037
|
+
}
|
|
2038
|
+
connectedCallback() {
|
|
2039
|
+
super.connectedCallback();
|
|
2040
|
+
this.setAttribute("role", "navigation");
|
|
2041
|
+
this.setAttribute("aria-label", "Pagination");
|
|
2042
|
+
this.addEventListener("ds:page-select", this.handlePageSelect);
|
|
2043
|
+
}
|
|
2044
|
+
disconnectedCallback() {
|
|
2045
|
+
super.disconnectedCallback();
|
|
2046
|
+
this.removeEventListener("ds:page-select", this.handlePageSelect);
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Navigate to a specific page.
|
|
2050
|
+
*/
|
|
2051
|
+
goToPage(newPage) {
|
|
2052
|
+
const clampedPage = Math.max(1, Math.min(newPage, this.totalPages));
|
|
2053
|
+
if (clampedPage !== this.page) {
|
|
2054
|
+
this.page = clampedPage;
|
|
2055
|
+
this.updateActiveState();
|
|
2056
|
+
emitEvent(this, "ds:page-change", {
|
|
2057
|
+
detail: { page: this.page },
|
|
2058
|
+
bubbles: true
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Go to previous page.
|
|
2064
|
+
*/
|
|
2065
|
+
previousPage() {
|
|
2066
|
+
this.goToPage(this.page - 1);
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Go to next page.
|
|
2070
|
+
*/
|
|
2071
|
+
nextPage() {
|
|
2072
|
+
this.goToPage(this.page + 1);
|
|
2073
|
+
}
|
|
2074
|
+
updateActiveState() {
|
|
2075
|
+
const links = this.querySelectorAll("ds-pagination-link");
|
|
2076
|
+
for (const link of links) {
|
|
2077
|
+
const linkPage = Number(link.getAttribute("page"));
|
|
2078
|
+
if (linkPage === this.page) {
|
|
2079
|
+
link.setAttribute("aria-current", "page");
|
|
2080
|
+
link.setAttribute("active", "");
|
|
2081
|
+
} else {
|
|
2082
|
+
link.removeAttribute("aria-current");
|
|
2083
|
+
link.removeAttribute("active");
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
const prevButton = this.querySelector("ds-pagination-previous");
|
|
2087
|
+
const nextButton = this.querySelector("ds-pagination-next");
|
|
2088
|
+
if (prevButton) {
|
|
2089
|
+
if (this.page <= 1) {
|
|
2090
|
+
prevButton.setAttribute("disabled", "");
|
|
2091
|
+
} else {
|
|
2092
|
+
prevButton.removeAttribute("disabled");
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
if (nextButton) {
|
|
2096
|
+
if (this.page >= this.totalPages) {
|
|
2097
|
+
nextButton.setAttribute("disabled", "");
|
|
2098
|
+
} else {
|
|
2099
|
+
nextButton.removeAttribute("disabled");
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
updated(changedProperties) {
|
|
2104
|
+
if (changedProperties.has("page") || changedProperties.has("totalPages")) {
|
|
2105
|
+
this.updateActiveState();
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
render() {
|
|
2109
|
+
return html36`<slot></slot>`;
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
__decorateClass([
|
|
2113
|
+
property19({ type: Number, reflect: true })
|
|
2114
|
+
], DsPagination.prototype, "page", 2);
|
|
2115
|
+
__decorateClass([
|
|
2116
|
+
property19({ type: Number, attribute: "total-pages" })
|
|
2117
|
+
], DsPagination.prototype, "totalPages", 2);
|
|
2118
|
+
__decorateClass([
|
|
2119
|
+
property19({ type: Number, attribute: "sibling-count" })
|
|
2120
|
+
], DsPagination.prototype, "siblingCount", 2);
|
|
2121
|
+
__decorateClass([
|
|
2122
|
+
property19({ type: Number, attribute: "boundary-count" })
|
|
2123
|
+
], DsPagination.prototype, "boundaryCount", 2);
|
|
2124
|
+
define("ds-pagination", DsPagination);
|
|
2125
|
+
|
|
2126
|
+
// src/components/stepper/stepper-item.ts
|
|
2127
|
+
import { html as html37 } from "lit";
|
|
2128
|
+
import { property as property20 } from "lit/decorators.js";
|
|
2129
|
+
var DsStepperItem = class extends DSElement {
|
|
2130
|
+
constructor() {
|
|
2131
|
+
super(...arguments);
|
|
2132
|
+
this.step = 1;
|
|
2133
|
+
this.completed = false;
|
|
2134
|
+
this.disabled = false;
|
|
2135
|
+
}
|
|
2136
|
+
connectedCallback() {
|
|
2137
|
+
super.connectedCallback();
|
|
2138
|
+
this.setAttribute("role", "listitem");
|
|
2139
|
+
this.setAttribute("data-state", "pending");
|
|
2140
|
+
}
|
|
2141
|
+
updated(_changedProperties) {
|
|
2142
|
+
const state11 = this.getAttribute("data-state");
|
|
2143
|
+
if (state11 === "active") {
|
|
2144
|
+
this.setAttribute("aria-current", "step");
|
|
2145
|
+
} else {
|
|
2146
|
+
this.removeAttribute("aria-current");
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
render() {
|
|
2150
|
+
return html37`<slot></slot>`;
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
__decorateClass([
|
|
2154
|
+
property20({ type: Number, reflect: true })
|
|
2155
|
+
], DsStepperItem.prototype, "step", 2);
|
|
2156
|
+
__decorateClass([
|
|
2157
|
+
property20({ type: Boolean, reflect: true })
|
|
2158
|
+
], DsStepperItem.prototype, "completed", 2);
|
|
2159
|
+
__decorateClass([
|
|
2160
|
+
property20({ type: Boolean, reflect: true })
|
|
2161
|
+
], DsStepperItem.prototype, "disabled", 2);
|
|
2162
|
+
define("ds-stepper-item", DsStepperItem);
|
|
2163
|
+
|
|
2164
|
+
// src/components/stepper/stepper-trigger.ts
|
|
2165
|
+
import { html as html38 } from "lit";
|
|
2166
|
+
var DsStepperTrigger = class extends DSElement {
|
|
2167
|
+
constructor() {
|
|
2168
|
+
super(...arguments);
|
|
2169
|
+
this.handleClick = () => {
|
|
2170
|
+
if (this.isDisabled()) return;
|
|
2171
|
+
emitEvent(this, "ds:step-select", {
|
|
2172
|
+
detail: { step: this.getStep() },
|
|
2173
|
+
bubbles: true
|
|
2174
|
+
});
|
|
2175
|
+
};
|
|
2176
|
+
this.handleKeyDown = (event) => {
|
|
2177
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
2178
|
+
event.preventDefault();
|
|
2179
|
+
this.handleClick();
|
|
2180
|
+
}
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
connectedCallback() {
|
|
2184
|
+
super.connectedCallback();
|
|
2185
|
+
this.setAttribute("role", "button");
|
|
2186
|
+
this.setAttribute("tabindex", "0");
|
|
2187
|
+
this.addEventListener("click", this.handleClick);
|
|
2188
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
2189
|
+
}
|
|
2190
|
+
disconnectedCallback() {
|
|
2191
|
+
super.disconnectedCallback();
|
|
2192
|
+
this.removeEventListener("click", this.handleClick);
|
|
2193
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
2194
|
+
}
|
|
2195
|
+
getStep() {
|
|
2196
|
+
const item = this.closest("ds-stepper-item");
|
|
2197
|
+
return Number(item?.getAttribute("step")) || 1;
|
|
2198
|
+
}
|
|
2199
|
+
isDisabled() {
|
|
2200
|
+
const item = this.closest("ds-stepper-item");
|
|
2201
|
+
return item?.hasAttribute("disabled") || false;
|
|
2202
|
+
}
|
|
2203
|
+
render() {
|
|
2204
|
+
return html38`<slot></slot>`;
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
define("ds-stepper-trigger", DsStepperTrigger);
|
|
2208
|
+
|
|
2209
|
+
// src/components/stepper/stepper-indicator.ts
|
|
2210
|
+
import { html as html39 } from "lit";
|
|
2211
|
+
var DsStepperIndicator = class extends DSElement {
|
|
2212
|
+
connectedCallback() {
|
|
2213
|
+
super.connectedCallback();
|
|
2214
|
+
this.setAttribute("aria-hidden", "true");
|
|
2215
|
+
}
|
|
2216
|
+
render() {
|
|
2217
|
+
return html39`<slot></slot>`;
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
define("ds-stepper-indicator", DsStepperIndicator);
|
|
2221
|
+
|
|
2222
|
+
// src/components/stepper/stepper-title.ts
|
|
2223
|
+
import { html as html40 } from "lit";
|
|
2224
|
+
var DsStepperTitle = class extends DSElement {
|
|
2225
|
+
render() {
|
|
2226
|
+
return html40`<slot></slot>`;
|
|
2227
|
+
}
|
|
2228
|
+
};
|
|
2229
|
+
define("ds-stepper-title", DsStepperTitle);
|
|
2230
|
+
|
|
2231
|
+
// src/components/stepper/stepper-description.ts
|
|
2232
|
+
import { html as html41 } from "lit";
|
|
2233
|
+
var DsStepperDescription = class extends DSElement {
|
|
2234
|
+
render() {
|
|
2235
|
+
return html41`<slot></slot>`;
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
define("ds-stepper-description", DsStepperDescription);
|
|
2239
|
+
|
|
2240
|
+
// src/components/stepper/stepper-separator.ts
|
|
2241
|
+
import { html as html42 } from "lit";
|
|
2242
|
+
var DsStepperSeparator = class extends DSElement {
|
|
2243
|
+
connectedCallback() {
|
|
2244
|
+
super.connectedCallback();
|
|
2245
|
+
this.setAttribute("role", "separator");
|
|
2246
|
+
this.setAttribute("aria-hidden", "true");
|
|
2247
|
+
}
|
|
2248
|
+
render() {
|
|
2249
|
+
return html42``;
|
|
2250
|
+
}
|
|
2251
|
+
};
|
|
2252
|
+
define("ds-stepper-separator", DsStepperSeparator);
|
|
2253
|
+
|
|
2254
|
+
// src/components/stepper/stepper-content.ts
|
|
2255
|
+
import { html as html43 } from "lit";
|
|
2256
|
+
var DsStepperContent = class extends DSElement {
|
|
2257
|
+
connectedCallback() {
|
|
2258
|
+
super.connectedCallback();
|
|
2259
|
+
this.setAttribute("role", "tabpanel");
|
|
2260
|
+
}
|
|
2261
|
+
render() {
|
|
2262
|
+
return html43`<slot></slot>`;
|
|
2263
|
+
}
|
|
2264
|
+
};
|
|
2265
|
+
define("ds-stepper-content", DsStepperContent);
|
|
2266
|
+
|
|
2267
|
+
// src/components/stepper/stepper.ts
|
|
2268
|
+
import { html as html44 } from "lit";
|
|
2269
|
+
import { property as property21 } from "lit/decorators.js";
|
|
2270
|
+
var DsStepper = class extends DSElement {
|
|
2271
|
+
constructor() {
|
|
2272
|
+
super(...arguments);
|
|
2273
|
+
this.value = 1;
|
|
2274
|
+
this.orientation = "horizontal";
|
|
2275
|
+
this.linear = false;
|
|
2276
|
+
this.ariaLabel = "Progress steps";
|
|
2277
|
+
this.handleStepSelect = (event) => {
|
|
2278
|
+
event.stopPropagation();
|
|
2279
|
+
this.goToStep(event.detail.step);
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
connectedCallback() {
|
|
2283
|
+
super.connectedCallback();
|
|
2284
|
+
this.setAttribute("role", "list");
|
|
2285
|
+
this.setAttribute("aria-label", this.ariaLabel);
|
|
2286
|
+
this.addEventListener("ds:step-select", this.handleStepSelect);
|
|
2287
|
+
}
|
|
2288
|
+
disconnectedCallback() {
|
|
2289
|
+
super.disconnectedCallback();
|
|
2290
|
+
this.removeEventListener("ds:step-select", this.handleStepSelect);
|
|
2291
|
+
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Go to a specific step.
|
|
2294
|
+
*/
|
|
2295
|
+
goToStep(step) {
|
|
2296
|
+
if (this.linear) {
|
|
2297
|
+
const items = this.querySelectorAll("ds-stepper-item");
|
|
2298
|
+
let maxAllowed = 1;
|
|
2299
|
+
for (const item of items) {
|
|
2300
|
+
const itemStep = Number(item.getAttribute("step"));
|
|
2301
|
+
if (item.hasAttribute("completed") || itemStep === this.value) {
|
|
2302
|
+
maxAllowed = Math.max(maxAllowed, itemStep + 1);
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
if (step > maxAllowed) return;
|
|
2306
|
+
}
|
|
2307
|
+
if (step !== this.value) {
|
|
2308
|
+
this.value = step;
|
|
2309
|
+
this.updateActiveState();
|
|
2310
|
+
emitEvent(this, "ds:step-change", {
|
|
2311
|
+
detail: { step: this.value },
|
|
2312
|
+
bubbles: true
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
/**
|
|
2317
|
+
* Go to next step.
|
|
2318
|
+
*/
|
|
2319
|
+
nextStep() {
|
|
2320
|
+
this.goToStep(this.value + 1);
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Go to previous step.
|
|
2324
|
+
*/
|
|
2325
|
+
previousStep() {
|
|
2326
|
+
this.goToStep(this.value - 1);
|
|
2327
|
+
}
|
|
2328
|
+
updateActiveState() {
|
|
2329
|
+
const items = this.querySelectorAll("ds-stepper-item");
|
|
2330
|
+
for (const item of items) {
|
|
2331
|
+
const step = Number(item.getAttribute("step"));
|
|
2332
|
+
if (step === this.value) {
|
|
2333
|
+
item.setAttribute("data-state", "active");
|
|
2334
|
+
} else if (step < this.value || item.hasAttribute("completed")) {
|
|
2335
|
+
item.setAttribute("data-state", "completed");
|
|
2336
|
+
} else {
|
|
2337
|
+
item.setAttribute("data-state", "pending");
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
updated(changedProperties) {
|
|
2342
|
+
if (changedProperties.has("value")) {
|
|
2343
|
+
this.updateActiveState();
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
render() {
|
|
2347
|
+
return html44`<slot></slot>`;
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
__decorateClass([
|
|
2351
|
+
property21({ type: Number, reflect: true })
|
|
2352
|
+
], DsStepper.prototype, "value", 2);
|
|
2353
|
+
__decorateClass([
|
|
2354
|
+
property21({ type: String, reflect: true })
|
|
2355
|
+
], DsStepper.prototype, "orientation", 2);
|
|
2356
|
+
__decorateClass([
|
|
2357
|
+
property21({ type: Boolean })
|
|
2358
|
+
], DsStepper.prototype, "linear", 2);
|
|
2359
|
+
__decorateClass([
|
|
2360
|
+
property21({ type: String, attribute: "aria-label" })
|
|
2361
|
+
], DsStepper.prototype, "ariaLabel", 2);
|
|
2362
|
+
define("ds-stepper", DsStepper);
|
|
2363
|
+
|
|
2364
|
+
// src/components/command/command.ts
|
|
2365
|
+
import { property as property22, state as state10 } from "lit/decorators.js";
|
|
2366
|
+
var DsCommand = class extends DSElement {
|
|
2367
|
+
constructor() {
|
|
2368
|
+
super(...arguments);
|
|
2369
|
+
this.value = "";
|
|
2370
|
+
this.loading = false;
|
|
2371
|
+
this.filter = true;
|
|
2372
|
+
this.label = "Command palette";
|
|
2373
|
+
this._visibleCount = 0;
|
|
2374
|
+
this._handleInputChange = (event) => {
|
|
2375
|
+
const e = event;
|
|
2376
|
+
this.value = e.detail.value;
|
|
2377
|
+
if (this.filter) {
|
|
2378
|
+
this._filterItems(this.value);
|
|
2379
|
+
}
|
|
2380
|
+
emitEvent(this, "value-change", { detail: { value: this.value } });
|
|
2381
|
+
};
|
|
2382
|
+
this._handleSelect = (event) => {
|
|
2383
|
+
const e = event;
|
|
2384
|
+
emitEvent(this, "select", { detail: { value: e.detail.value } });
|
|
2385
|
+
};
|
|
2386
|
+
}
|
|
2387
|
+
connectedCallback() {
|
|
2388
|
+
super.connectedCallback();
|
|
2389
|
+
this.setAttribute("role", "search");
|
|
2390
|
+
this.setAttribute("aria-label", this.label);
|
|
2391
|
+
this.addEventListener("ds:command-input", this._handleInputChange);
|
|
2392
|
+
this.addEventListener("ds:command-select", this._handleSelect);
|
|
2393
|
+
}
|
|
2394
|
+
disconnectedCallback() {
|
|
2395
|
+
super.disconnectedCallback();
|
|
2396
|
+
this.removeEventListener("ds:command-input", this._handleInputChange);
|
|
2397
|
+
this.removeEventListener("ds:command-select", this._handleSelect);
|
|
2398
|
+
}
|
|
2399
|
+
_filterItems(query) {
|
|
2400
|
+
const normalizedQuery = query.toLowerCase().trim();
|
|
2401
|
+
const items = this.querySelectorAll("ds-command-item");
|
|
2402
|
+
let visibleCount = 0;
|
|
2403
|
+
items.forEach((item) => {
|
|
2404
|
+
const text = item.textContent?.toLowerCase() || "";
|
|
2405
|
+
const value = item.getAttribute("value")?.toLowerCase() || "";
|
|
2406
|
+
const keywords = item.getAttribute("keywords")?.toLowerCase() || "";
|
|
2407
|
+
const matches = normalizedQuery === "" || this._fuzzyMatch(normalizedQuery, text) || this._fuzzyMatch(normalizedQuery, value) || this._fuzzyMatch(normalizedQuery, keywords);
|
|
2408
|
+
if (matches) {
|
|
2409
|
+
item.removeAttribute("data-filtered");
|
|
2410
|
+
visibleCount++;
|
|
2411
|
+
} else {
|
|
2412
|
+
item.setAttribute("data-filtered", "true");
|
|
2413
|
+
}
|
|
2414
|
+
});
|
|
2415
|
+
this._visibleCount = visibleCount;
|
|
2416
|
+
this._updateGroupVisibility();
|
|
2417
|
+
this._updateEmptyState();
|
|
2418
|
+
}
|
|
2419
|
+
_fuzzyMatch(query, text) {
|
|
2420
|
+
if (!query) return true;
|
|
2421
|
+
if (!text) return false;
|
|
2422
|
+
let queryIndex = 0;
|
|
2423
|
+
for (let i = 0; i < text.length && queryIndex < query.length; i++) {
|
|
2424
|
+
if (text[i] === query[queryIndex]) {
|
|
2425
|
+
queryIndex++;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
return queryIndex === query.length;
|
|
2429
|
+
}
|
|
2430
|
+
_updateGroupVisibility() {
|
|
2431
|
+
const groups = this.querySelectorAll("ds-command-group");
|
|
2432
|
+
groups.forEach((group) => {
|
|
2433
|
+
const visibleItems = group.querySelectorAll("ds-command-item:not([data-filtered])");
|
|
2434
|
+
if (visibleItems.length === 0) {
|
|
2435
|
+
group.setAttribute("data-empty", "true");
|
|
2436
|
+
} else {
|
|
2437
|
+
group.removeAttribute("data-empty");
|
|
2438
|
+
}
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
_updateEmptyState() {
|
|
2442
|
+
const emptyEl = this.querySelector("ds-command-empty");
|
|
2443
|
+
if (emptyEl) {
|
|
2444
|
+
if (this._visibleCount === 0 && this.value) {
|
|
2445
|
+
emptyEl.removeAttribute("hidden");
|
|
2446
|
+
} else {
|
|
2447
|
+
emptyEl.setAttribute("hidden", "");
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* Programmatically set the search value.
|
|
2453
|
+
*/
|
|
2454
|
+
setValue(value) {
|
|
2455
|
+
this.value = value;
|
|
2456
|
+
const input = this.querySelector("ds-command-input");
|
|
2457
|
+
if (input) {
|
|
2458
|
+
input.value = value;
|
|
2459
|
+
}
|
|
2460
|
+
if (this.filter) {
|
|
2461
|
+
this._filterItems(value);
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* Clear the search value.
|
|
2466
|
+
*/
|
|
2467
|
+
clear() {
|
|
2468
|
+
this.setValue("");
|
|
2469
|
+
}
|
|
2470
|
+
};
|
|
2471
|
+
__decorateClass([
|
|
2472
|
+
property22({ type: String })
|
|
2473
|
+
], DsCommand.prototype, "value", 2);
|
|
2474
|
+
__decorateClass([
|
|
2475
|
+
property22({ type: Boolean, reflect: true })
|
|
2476
|
+
], DsCommand.prototype, "loading", 2);
|
|
2477
|
+
__decorateClass([
|
|
2478
|
+
property22({ type: Boolean, attribute: "filter" })
|
|
2479
|
+
], DsCommand.prototype, "filter", 2);
|
|
2480
|
+
__decorateClass([
|
|
2481
|
+
property22({ type: String })
|
|
2482
|
+
], DsCommand.prototype, "label", 2);
|
|
2483
|
+
__decorateClass([
|
|
2484
|
+
state10()
|
|
2485
|
+
], DsCommand.prototype, "_visibleCount", 2);
|
|
2486
|
+
|
|
2487
|
+
// src/components/command/command-input.ts
|
|
2488
|
+
import { property as property23 } from "lit/decorators.js";
|
|
2489
|
+
var DsCommandInput = class extends DSElement {
|
|
2490
|
+
constructor() {
|
|
2491
|
+
super(...arguments);
|
|
2492
|
+
this.value = "";
|
|
2493
|
+
this.placeholder = "Type a command or search...";
|
|
2494
|
+
this.disabled = false;
|
|
2495
|
+
this._input = null;
|
|
2496
|
+
this._handleInput = (event) => {
|
|
2497
|
+
const target = event.target;
|
|
2498
|
+
this.value = target.value;
|
|
2499
|
+
emitEvent(this, "command-input", {
|
|
2500
|
+
detail: { value: this.value }
|
|
2501
|
+
});
|
|
2502
|
+
};
|
|
2503
|
+
this._handleKeyDown = (event) => {
|
|
2504
|
+
const command = this.closest("ds-command");
|
|
2505
|
+
const list = command?.querySelector("ds-command-list");
|
|
2506
|
+
switch (event.key) {
|
|
2507
|
+
case "ArrowDown":
|
|
2508
|
+
event.preventDefault();
|
|
2509
|
+
list?.focus();
|
|
2510
|
+
break;
|
|
2511
|
+
case "ArrowUp":
|
|
2512
|
+
event.preventDefault();
|
|
2513
|
+
if (list && "focusLast" in list && typeof list.focusLast === "function") {
|
|
2514
|
+
list.focusLast();
|
|
2515
|
+
}
|
|
2516
|
+
break;
|
|
2517
|
+
case "Enter": {
|
|
2518
|
+
event.preventDefault();
|
|
2519
|
+
const activeItem = command?.querySelector(
|
|
2520
|
+
"ds-command-item[data-active]"
|
|
2521
|
+
);
|
|
2522
|
+
if (activeItem) {
|
|
2523
|
+
activeItem.click();
|
|
2524
|
+
}
|
|
2525
|
+
break;
|
|
2526
|
+
}
|
|
2527
|
+
case "Escape":
|
|
2528
|
+
event.preventDefault();
|
|
2529
|
+
emitEvent(this, "command-escape", { detail: {} });
|
|
2530
|
+
break;
|
|
2531
|
+
}
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
connectedCallback() {
|
|
2535
|
+
super.connectedCallback();
|
|
2536
|
+
this._createInput();
|
|
2537
|
+
}
|
|
2538
|
+
disconnectedCallback() {
|
|
2539
|
+
super.disconnectedCallback();
|
|
2540
|
+
if (this._input) {
|
|
2541
|
+
this._input.removeEventListener("input", this._handleInput);
|
|
2542
|
+
this._input.removeEventListener("keydown", this._handleKeyDown);
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
_createInput() {
|
|
2546
|
+
let input = this.querySelector("input");
|
|
2547
|
+
if (!input) {
|
|
2548
|
+
input = document.createElement("input");
|
|
2549
|
+
input.type = "text";
|
|
2550
|
+
input.className = "ds-command-input__field";
|
|
2551
|
+
this.appendChild(input);
|
|
2552
|
+
}
|
|
2553
|
+
this._input = input;
|
|
2554
|
+
this._input.placeholder = this.placeholder;
|
|
2555
|
+
this._input.disabled = this.disabled;
|
|
2556
|
+
this._input.value = this.value;
|
|
2557
|
+
this._input.setAttribute("role", "combobox");
|
|
2558
|
+
this._input.setAttribute("aria-expanded", "true");
|
|
2559
|
+
this._input.setAttribute("aria-controls", "");
|
|
2560
|
+
this._input.setAttribute("aria-autocomplete", "list");
|
|
2561
|
+
this._input.setAttribute("autocomplete", "off");
|
|
2562
|
+
this._input.setAttribute("autocorrect", "off");
|
|
2563
|
+
this._input.setAttribute("spellcheck", "false");
|
|
2564
|
+
this._input.addEventListener("input", this._handleInput);
|
|
2565
|
+
this._input.addEventListener("keydown", this._handleKeyDown);
|
|
2566
|
+
}
|
|
2567
|
+
/**
|
|
2568
|
+
* Focus the input.
|
|
2569
|
+
*/
|
|
2570
|
+
focus() {
|
|
2571
|
+
this._input?.focus();
|
|
2572
|
+
}
|
|
2573
|
+
/**
|
|
2574
|
+
* Blur the input.
|
|
2575
|
+
*/
|
|
2576
|
+
blur() {
|
|
2577
|
+
this._input?.blur();
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
__decorateClass([
|
|
2581
|
+
property23({ type: String })
|
|
2582
|
+
], DsCommandInput.prototype, "value", 2);
|
|
2583
|
+
__decorateClass([
|
|
2584
|
+
property23({ type: String })
|
|
2585
|
+
], DsCommandInput.prototype, "placeholder", 2);
|
|
2586
|
+
__decorateClass([
|
|
2587
|
+
property23({ type: Boolean, reflect: true })
|
|
2588
|
+
], DsCommandInput.prototype, "disabled", 2);
|
|
2589
|
+
|
|
2590
|
+
// src/components/command/command-list.ts
|
|
2591
|
+
import { createRovingFocus as createRovingFocus3 } from "@hypoth-ui/primitives-dom";
|
|
2592
|
+
var DsCommandList = class extends DSElement {
|
|
2593
|
+
constructor() {
|
|
2594
|
+
super(...arguments);
|
|
2595
|
+
this._rovingFocus = null;
|
|
2596
|
+
this._observer = null;
|
|
2597
|
+
}
|
|
2598
|
+
connectedCallback() {
|
|
2599
|
+
super.connectedCallback();
|
|
2600
|
+
this.setAttribute("role", "listbox");
|
|
2601
|
+
this.tabIndex = -1;
|
|
2602
|
+
this._setupRovingFocus();
|
|
2603
|
+
this._setupMutationObserver();
|
|
2604
|
+
}
|
|
2605
|
+
disconnectedCallback() {
|
|
2606
|
+
super.disconnectedCallback();
|
|
2607
|
+
this._rovingFocus?.destroy();
|
|
2608
|
+
this._observer?.disconnect();
|
|
2609
|
+
}
|
|
2610
|
+
_setupMutationObserver() {
|
|
2611
|
+
this._observer = new MutationObserver(() => {
|
|
2612
|
+
this._rovingFocus?.destroy();
|
|
2613
|
+
this._setupRovingFocus();
|
|
2614
|
+
});
|
|
2615
|
+
this._observer.observe(this, {
|
|
2616
|
+
childList: true,
|
|
2617
|
+
subtree: true,
|
|
2618
|
+
attributes: true,
|
|
2619
|
+
attributeFilter: ["data-filtered", "disabled"]
|
|
2620
|
+
});
|
|
2621
|
+
}
|
|
2622
|
+
_setupRovingFocus() {
|
|
2623
|
+
const items = this._getVisibleItems();
|
|
2624
|
+
if (items.length === 0) return;
|
|
2625
|
+
this._rovingFocus = createRovingFocus3({
|
|
2626
|
+
container: this,
|
|
2627
|
+
selector: "ds-command-item:not([data-filtered]):not([disabled])",
|
|
2628
|
+
direction: "vertical",
|
|
2629
|
+
loop: true,
|
|
2630
|
+
onFocus: (item) => {
|
|
2631
|
+
this._getVisibleItems().forEach((i) => i.removeAttribute("data-active"));
|
|
2632
|
+
item.setAttribute("data-active", "true");
|
|
2633
|
+
}
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
_getVisibleItems() {
|
|
2637
|
+
return Array.from(
|
|
2638
|
+
this.querySelectorAll("ds-command-item:not([data-filtered]):not([disabled])")
|
|
2639
|
+
);
|
|
2640
|
+
}
|
|
2641
|
+
/**
|
|
2642
|
+
* Focus the first visible item.
|
|
2643
|
+
*/
|
|
2644
|
+
focus() {
|
|
2645
|
+
const items = this._getVisibleItems();
|
|
2646
|
+
if (items.length > 0) {
|
|
2647
|
+
const firstItem = items[0];
|
|
2648
|
+
if (firstItem) {
|
|
2649
|
+
firstItem.focus();
|
|
2650
|
+
firstItem.setAttribute("data-active", "true");
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
/**
|
|
2655
|
+
* Focus the last visible item.
|
|
2656
|
+
*/
|
|
2657
|
+
focusLast() {
|
|
2658
|
+
const items = this._getVisibleItems();
|
|
2659
|
+
if (items.length > 0) {
|
|
2660
|
+
const lastItem = items[items.length - 1];
|
|
2661
|
+
if (lastItem) {
|
|
2662
|
+
lastItem.focus();
|
|
2663
|
+
lastItem.setAttribute("data-active", "true");
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
};
|
|
2668
|
+
|
|
2669
|
+
// src/components/command/command-item.ts
|
|
2670
|
+
import { property as property24 } from "lit/decorators.js";
|
|
2671
|
+
var DsCommandItem = class extends DSElement {
|
|
2672
|
+
constructor() {
|
|
2673
|
+
super(...arguments);
|
|
2674
|
+
this.value = "";
|
|
2675
|
+
this.keywords = "";
|
|
2676
|
+
this.disabled = false;
|
|
2677
|
+
this._handleClick = () => {
|
|
2678
|
+
if (this.disabled) return;
|
|
2679
|
+
this._select();
|
|
2680
|
+
};
|
|
2681
|
+
this._handleKeyDown = (event) => {
|
|
2682
|
+
if (this.disabled) return;
|
|
2683
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
2684
|
+
event.preventDefault();
|
|
2685
|
+
this._select();
|
|
2686
|
+
}
|
|
2687
|
+
};
|
|
2688
|
+
}
|
|
2689
|
+
connectedCallback() {
|
|
2690
|
+
super.connectedCallback();
|
|
2691
|
+
this.setAttribute("role", "option");
|
|
2692
|
+
this.tabIndex = -1;
|
|
2693
|
+
if (this.disabled) {
|
|
2694
|
+
this.setAttribute("aria-disabled", "true");
|
|
2695
|
+
}
|
|
2696
|
+
this.addEventListener("click", this._handleClick);
|
|
2697
|
+
this.addEventListener("keydown", this._handleKeyDown);
|
|
2698
|
+
}
|
|
2699
|
+
disconnectedCallback() {
|
|
2700
|
+
super.disconnectedCallback();
|
|
2701
|
+
this.removeEventListener("click", this._handleClick);
|
|
2702
|
+
this.removeEventListener("keydown", this._handleKeyDown);
|
|
2703
|
+
}
|
|
2704
|
+
_select() {
|
|
2705
|
+
emitEvent(this, "command-select", {
|
|
2706
|
+
detail: { value: this.value || this.textContent?.trim() || "" }
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
};
|
|
2710
|
+
__decorateClass([
|
|
2711
|
+
property24({ type: String })
|
|
2712
|
+
], DsCommandItem.prototype, "value", 2);
|
|
2713
|
+
__decorateClass([
|
|
2714
|
+
property24({ type: String })
|
|
2715
|
+
], DsCommandItem.prototype, "keywords", 2);
|
|
2716
|
+
__decorateClass([
|
|
2717
|
+
property24({ type: Boolean, reflect: true })
|
|
2718
|
+
], DsCommandItem.prototype, "disabled", 2);
|
|
2719
|
+
|
|
2720
|
+
// src/components/command/command-group.ts
|
|
2721
|
+
import { property as property25 } from "lit/decorators.js";
|
|
2722
|
+
var DsCommandGroup = class extends DSElement {
|
|
2723
|
+
constructor() {
|
|
2724
|
+
super(...arguments);
|
|
2725
|
+
this.heading = "";
|
|
2726
|
+
this._headingEl = null;
|
|
2727
|
+
}
|
|
2728
|
+
connectedCallback() {
|
|
2729
|
+
super.connectedCallback();
|
|
2730
|
+
this.setAttribute("role", "group");
|
|
2731
|
+
if (this.heading) {
|
|
2732
|
+
this._createHeading();
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
updated(changedProperties) {
|
|
2736
|
+
if (changedProperties.has("heading")) {
|
|
2737
|
+
if (this.heading) {
|
|
2738
|
+
this._createHeading();
|
|
2739
|
+
} else if (this._headingEl) {
|
|
2740
|
+
this._headingEl.remove();
|
|
2741
|
+
this._headingEl = null;
|
|
2742
|
+
this.removeAttribute("aria-labelledby");
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
_createHeading() {
|
|
2747
|
+
if (!this._headingEl) {
|
|
2748
|
+
this._headingEl = document.createElement("div");
|
|
2749
|
+
this._headingEl.className = "ds-command-group__heading";
|
|
2750
|
+
this._headingEl.id = `ds-command-group-${Math.random().toString(36).slice(2, 9)}`;
|
|
2751
|
+
this._headingEl.setAttribute("aria-hidden", "true");
|
|
2752
|
+
this.prepend(this._headingEl);
|
|
2753
|
+
this.setAttribute("aria-labelledby", this._headingEl.id);
|
|
2754
|
+
}
|
|
2755
|
+
this._headingEl.textContent = this.heading;
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
__decorateClass([
|
|
2759
|
+
property25({ type: String })
|
|
2760
|
+
], DsCommandGroup.prototype, "heading", 2);
|
|
2761
|
+
|
|
2762
|
+
// src/components/command/command-separator.ts
|
|
2763
|
+
var DsCommandSeparator = class extends DSElement {
|
|
2764
|
+
connectedCallback() {
|
|
2765
|
+
super.connectedCallback();
|
|
2766
|
+
this.setAttribute("role", "separator");
|
|
2767
|
+
this.setAttribute("aria-orientation", "horizontal");
|
|
2768
|
+
}
|
|
2769
|
+
};
|
|
2770
|
+
|
|
2771
|
+
// src/components/command/command-empty.ts
|
|
2772
|
+
var DsCommandEmpty = class extends DSElement {
|
|
2773
|
+
connectedCallback() {
|
|
2774
|
+
super.connectedCallback();
|
|
2775
|
+
this.setAttribute("role", "status");
|
|
2776
|
+
this.setAttribute("aria-live", "polite");
|
|
2777
|
+
this.setAttribute("hidden", "");
|
|
2778
|
+
}
|
|
2779
|
+
};
|
|
2780
|
+
|
|
2781
|
+
// src/components/command/command-loading.ts
|
|
2782
|
+
var DsCommandLoading = class extends DSElement {
|
|
2783
|
+
connectedCallback() {
|
|
2784
|
+
super.connectedCallback();
|
|
2785
|
+
this.setAttribute("role", "status");
|
|
2786
|
+
this.setAttribute("aria-live", "polite");
|
|
2787
|
+
this.setAttribute("aria-label", "Loading");
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
|
|
2791
|
+
export {
|
|
2792
|
+
DsCollapsibleContent,
|
|
2793
|
+
DsCollapsibleTrigger,
|
|
2794
|
+
DsCollapsible,
|
|
2795
|
+
DsTabsList,
|
|
2796
|
+
DsTabsTrigger,
|
|
2797
|
+
DsTabsContent,
|
|
2798
|
+
DsTabs,
|
|
2799
|
+
DsAccordionItem,
|
|
2800
|
+
DsAccordionTrigger,
|
|
2801
|
+
DsAccordionContent,
|
|
2802
|
+
DsAccordion,
|
|
2803
|
+
DsNavigationMenuList,
|
|
2804
|
+
DsNavigationMenuItem,
|
|
2805
|
+
DsNavigationMenuTrigger,
|
|
2806
|
+
DsNavigationMenuContent,
|
|
2807
|
+
DsNavigationMenuLink,
|
|
2808
|
+
DsNavigationMenuIndicator,
|
|
2809
|
+
DsNavigationMenuViewport,
|
|
2810
|
+
DsNavigationMenu,
|
|
2811
|
+
DsScrollAreaViewport,
|
|
2812
|
+
DsScrollAreaScrollbar,
|
|
2813
|
+
DsScrollAreaThumb,
|
|
2814
|
+
DsScrollArea,
|
|
2815
|
+
DsBreadcrumbList,
|
|
2816
|
+
DsBreadcrumbItem,
|
|
2817
|
+
DsBreadcrumbLink,
|
|
2818
|
+
DsBreadcrumbPage,
|
|
2819
|
+
DsBreadcrumbSeparator,
|
|
2820
|
+
DsBreadcrumb,
|
|
2821
|
+
DsPaginationContent,
|
|
2822
|
+
DsPaginationItem,
|
|
2823
|
+
DsPaginationLink,
|
|
2824
|
+
DsPaginationPrevious,
|
|
2825
|
+
DsPaginationNext,
|
|
2826
|
+
DsPaginationEllipsis,
|
|
2827
|
+
DsPagination,
|
|
2828
|
+
DsStepperItem,
|
|
2829
|
+
DsStepperTrigger,
|
|
2830
|
+
DsStepperIndicator,
|
|
2831
|
+
DsStepperTitle,
|
|
2832
|
+
DsStepperDescription,
|
|
2833
|
+
DsStepperSeparator,
|
|
2834
|
+
DsStepperContent,
|
|
2835
|
+
DsStepper,
|
|
2836
|
+
DsCommand,
|
|
2837
|
+
DsCommandInput,
|
|
2838
|
+
DsCommandList,
|
|
2839
|
+
DsCommandItem,
|
|
2840
|
+
DsCommandGroup,
|
|
2841
|
+
DsCommandSeparator,
|
|
2842
|
+
DsCommandEmpty,
|
|
2843
|
+
DsCommandLoading
|
|
2844
|
+
};
|
|
2845
|
+
//# sourceMappingURL=chunk-WQ5BEP3E.js.map
|