@ucalgary-design-system/dropdown 1.0.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/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Dropdown
2
+
3
+ This package provides the **Dropdown** web component.
4
+
5
+ ## Installation
6
+
7
+ Install the component using npm:
8
+
9
+ ```sh
10
+ npm install @ucalgary-design-system/dropdown
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Import the component into your application:
16
+
17
+ ```ts
18
+ import "@ucalgary-design-system/dropdown";
19
+ ```
20
+
21
+ Use the component in your HTML:
22
+
23
+ ```html
24
+ <ucds-dropdown></ucds-dropdown>
25
+ ```
26
+
27
+ ## Development
28
+
29
+ Build the component:
30
+
31
+ ```sh
32
+ npm run build
33
+ ```
34
+
35
+ Alternatively, build from the monorepo root:
36
+
37
+ ```sh
38
+ npm run build -w @ucalgary-design-system/ucds-dropdown
39
+ ```
40
+
41
+ Run storybook from the monorepo root.
42
+
43
+ ## Testing
44
+
45
+ Run the test from this package:
46
+
47
+ ```sh
48
+ npm run test
49
+ ```
50
+
51
+ Alternatively, run the tests from the monorepo root:
52
+
53
+ ```sh
54
+ npm run test -w @ucalgary-design-system/ucds-dropdown
55
+ ```
56
+
57
+
package/dropdown.css ADDED
@@ -0,0 +1 @@
1
+ :root{--ucds-color-palette-brand-red: #d6001c;--ucds-color-palette-brand-gold: #ffcd00;--ucds-color-palette-brand-light-orange: #ffa300;--ucds-color-palette-brand-dark-orange: #ff7b1f;--ucds-color-palette-brand-berry: #9c0534;--ucds-color-palette-brand-rubine: #ce0058;--ucds-color-palette-brand-brown: #6b3529;--ucds-color-palette-brand-teal: #47a67c;--ucds-color-palette-white: #ffffff;--ucds-color-palette-black: #000000;--ucds-color-palette-gray-100: #2d2d2d;--ucds-color-palette-gray-200: #3d3d3d;--ucds-color-palette-gray-250: #4d4d4d;--ucds-color-palette-gray-300: #5d5d5d;--ucds-color-palette-gray-400: #8d8d8d;--ucds-color-palette-gray-500: #adadad;--ucds-color-palette-gray-600: #c0c0c0;--ucds-color-palette-gray-700: #d8d8d8;--ucds-color-palette-gray-800: #e5e5e5;--ucds-color-palette-gray-900: #f4f4f4;--ucds-color-palette-red-100: #3d0910;--ucds-color-palette-red-200: #5c0e18;--ucds-color-palette-red-300: #7a111f;--ucds-color-palette-red-400: #991022;--ucds-color-palette-red-500: #b70b21;--ucds-color-palette-red-600: #d6001c;--ucds-color-palette-red-700: #df3047;--ucds-color-palette-red-800: #ee0e2c;--ucds-color-palette-red-900: #ffadad;--ucds-color-palette-berry-600: #9c0534;--ucds-color-palette-berry-700: #a6192e;--ucds-color-palette-berry-800: #ea7b8a;--ucds-color-palette-berry-900: #f6ebed;--ucds-color-palette-rubine-600: #ce0058;--ucds-color-palette-rubine-800: #ed0a72;--ucds-color-palette-rubine-900: #ffa3c9;--ucds-color-palette-dark-orange-200: #6b3529;--ucds-color-palette-dark-orange-600: #ff671f;--ucds-color-palette-dark-orange-900: #fff2e9;--ucds-color-palette-light-orange-200: #614e00;--ucds-color-palette-light-orange-600: #ffa300;--ucds-color-palette-light-orange-900: #fff6e7;--ucds-color-palette-brown-600: #6c3302;--ucds-color-palette-brown-900: #ca7d68;--ucds-color-surface-page: #ffffff;--ucds-color-surface-primary: #ffffff;--ucds-color-border-neutral: #8d8d8d;--ucds-color-text-primary: #2d2d2d;--ucds-color-text-primary-inverse: #ffffff;--ucds-color-text-secondary: #5d5d5d;--ucds-color-text-error: #df3047;--ucds-color-text-disabled: #e5e5e5;--ucds-color-icon-primary: #2d2d2d;--ucds-color-icon-primary-inverse: #ffffff;--ucds-color-forms-input-background-rest: #ffffff;--ucds-color-forms-input-background-hover: #9c0534;--ucds-color-forms-input-background-active: #9c0534;--ucds-color-forms-input-background-selected: #9c0534;--ucds-color-forms-input-background-disabled: #e5e5e5;--ucds-color-forms-input-background-error: rgb(255 173 173 / 50%);--ucds-color-forms-input-border-rest: #8d8d8d;--ucds-color-forms-input-border-hover: #3d3d3d;--ucds-color-forms-input-border-active: #3d3d3d;--ucds-color-forms-input-border-selected: #9c0534;--ucds-color-forms-input-border-disabled: #e5e5e5;--ucds-color-forms-input-border-error: #df3047;--ucds-color-forms-input-element-disabled: #f4f4f4;--ucds-color-action-rest: #d6001c;--ucds-color-action-hover: #991022;--ucds-color-action-active: #991022;--ucds-color-action-focus: #4d4d4d;--ucds-color-action-visited: #991022;--ucds-color-action-secondary-rest: #2d2d2d;--ucds-color-action-secondary-hover: #4d4d4d;--ucds-color-action-secondary-active: #4d4d4d;--ucds-color-action-secondary-focus: #4d4d4d;--ucds-color-action-inverse-rest: #ffffff;--ucds-color-action-inverse-hover: #e5e5e5;--ucds-color-action-inverse-active: #e5e5e5;--ucds-color-action-inverse-focus: #ffffff;--ucds-color-feedback-error-light: #df3047;--ucds-color-feedback-error-background-light: rgb(255 173 173 / 50%);--ucds-font-base-size: 16px;--ucds-font-base-line-height: 24px;--ucds-font-base-weight-light: 200;--ucds-font-base-weight-normal: 400;--ucds-font-base-weight-medium: 500;--ucds-font-base-weight-semibold: 600;--ucds-font-base-weight-bold: 700;--ucds-font-sans-serif-family: "Proxima Nova", Arial, Helvetica, sans-serif;--ucds-font-serif-family: "Museo Slab", "Proxima Nova", Arial, Helvetica, sans-serif;--ucds-form-element-border-radius: 8px;--ucds-form-element-border-width: 2px;--ucds-form-element-height: 48px;--ucds-form-element-width: 100%;--ucds-form-element-maxwidth: 555px;--ucds-form-element-horizontal-padding: 16px;--ucds-form-component-intra-spacing: 8px;--ucds-form-component-inter-spacing: 16px}
package/index.js ADDED
@@ -0,0 +1,893 @@
1
+ import { unsafeCSS as oe, nothing as L, html as H } from "lit";
2
+ import { BaseElement as N } from "@ucalgary-design-system/core";
3
+ import "@ucalgary-design-system/helper-components";
4
+ import "@ucalgary-design-system/icon";
5
+ /**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */
10
+ const ne = (r) => (e, t) => {
11
+ t !== void 0 ? t.addInitializer(() => {
12
+ customElements.define(r, e);
13
+ }) : customElements.define(r, e);
14
+ };
15
+ /**
16
+ * @license
17
+ * Copyright 2019 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */
20
+ const M = globalThis, K = M.ShadowRoot && (M.ShadyCSS === void 0 || M.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, le = Symbol(), F = /* @__PURE__ */ new WeakMap();
21
+ let pe = class {
22
+ constructor(e, t, s) {
23
+ if (this._$cssResult$ = !0, s !== le) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
24
+ this.cssText = e, this.t = t;
25
+ }
26
+ get styleSheet() {
27
+ let e = this.o;
28
+ const t = this.t;
29
+ if (K && e === void 0) {
30
+ const s = t !== void 0 && t.length === 1;
31
+ s && (e = F.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), s && F.set(t, e));
32
+ }
33
+ return e;
34
+ }
35
+ toString() {
36
+ return this.cssText;
37
+ }
38
+ };
39
+ const fe = (r) => new pe(typeof r == "string" ? r : r + "", void 0, le), me = (r, e) => {
40
+ if (K) r.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet);
41
+ else for (const t of e) {
42
+ const s = document.createElement("style"), i = M.litNonce;
43
+ i !== void 0 && s.setAttribute("nonce", i), s.textContent = t.cssText, r.appendChild(s);
44
+ }
45
+ }, X = K ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((e) => {
46
+ let t = "";
47
+ for (const s of e.cssRules) t += s.cssText;
48
+ return fe(t);
49
+ })(r) : r;
50
+ /**
51
+ * @license
52
+ * Copyright 2017 Google LLC
53
+ * SPDX-License-Identifier: BSD-3-Clause
54
+ */
55
+ const { is: $e, defineProperty: _e, getOwnPropertyDescriptor: ve, getOwnPropertyNames: ge, getOwnPropertySymbols: be, getPrototypeOf: ye } = Object, g = globalThis, G = g.trustedTypes, we = G ? G.emptyScript : "", B = g.reactiveElementPolyfillSupport, C = (r, e) => r, T = { toAttribute(r, e) {
56
+ switch (e) {
57
+ case Boolean:
58
+ r = r ? we : null;
59
+ break;
60
+ case Object:
61
+ case Array:
62
+ r = r == null ? r : JSON.stringify(r);
63
+ }
64
+ return r;
65
+ }, fromAttribute(r, e) {
66
+ let t = r;
67
+ switch (e) {
68
+ case Boolean:
69
+ t = r !== null;
70
+ break;
71
+ case Number:
72
+ t = r === null ? null : Number(r);
73
+ break;
74
+ case Object:
75
+ case Array:
76
+ try {
77
+ t = JSON.parse(r);
78
+ } catch {
79
+ t = null;
80
+ }
81
+ }
82
+ return t;
83
+ } }, W = (r, e) => !$e(r, e), Q = { attribute: !0, type: String, converter: T, reflect: !1, hasChanged: W };
84
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), g.litPropertyMetadata ?? (g.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
85
+ class S extends HTMLElement {
86
+ static addInitializer(e) {
87
+ this._$Ei(), (this.l ?? (this.l = [])).push(e);
88
+ }
89
+ static get observedAttributes() {
90
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
91
+ }
92
+ static createProperty(e, t = Q) {
93
+ if (t.state && (t.attribute = !1), this._$Ei(), this.elementProperties.set(e, t), !t.noAccessor) {
94
+ const s = Symbol(), i = this.getPropertyDescriptor(e, s, t);
95
+ i !== void 0 && _e(this.prototype, e, i);
96
+ }
97
+ }
98
+ static getPropertyDescriptor(e, t, s) {
99
+ const { get: i, set: o } = ve(this.prototype, e) ?? { get() {
100
+ return this[t];
101
+ }, set(n) {
102
+ this[t] = n;
103
+ } };
104
+ return { get() {
105
+ return i == null ? void 0 : i.call(this);
106
+ }, set(n) {
107
+ const a = i == null ? void 0 : i.call(this);
108
+ o.call(this, n), this.requestUpdate(e, a, s);
109
+ }, configurable: !0, enumerable: !0 };
110
+ }
111
+ static getPropertyOptions(e) {
112
+ return this.elementProperties.get(e) ?? Q;
113
+ }
114
+ static _$Ei() {
115
+ if (this.hasOwnProperty(C("elementProperties"))) return;
116
+ const e = ye(this);
117
+ e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
118
+ }
119
+ static finalize() {
120
+ if (this.hasOwnProperty(C("finalized"))) return;
121
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(C("properties"))) {
122
+ const t = this.properties, s = [...ge(t), ...be(t)];
123
+ for (const i of s) this.createProperty(i, t[i]);
124
+ }
125
+ const e = this[Symbol.metadata];
126
+ if (e !== null) {
127
+ const t = litPropertyMetadata.get(e);
128
+ if (t !== void 0) for (const [s, i] of t) this.elementProperties.set(s, i);
129
+ }
130
+ this._$Eh = /* @__PURE__ */ new Map();
131
+ for (const [t, s] of this.elementProperties) {
132
+ const i = this._$Eu(t, s);
133
+ i !== void 0 && this._$Eh.set(i, t);
134
+ }
135
+ this.elementStyles = this.finalizeStyles(this.styles);
136
+ }
137
+ static finalizeStyles(e) {
138
+ const t = [];
139
+ if (Array.isArray(e)) {
140
+ const s = new Set(e.flat(1 / 0).reverse());
141
+ for (const i of s) t.unshift(X(i));
142
+ } else e !== void 0 && t.push(X(e));
143
+ return t;
144
+ }
145
+ static _$Eu(e, t) {
146
+ const s = t.attribute;
147
+ return s === !1 ? void 0 : typeof s == "string" ? s : typeof e == "string" ? e.toLowerCase() : void 0;
148
+ }
149
+ constructor() {
150
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
151
+ }
152
+ _$Ev() {
153
+ var e;
154
+ this._$ES = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (e = this.constructor.l) == null || e.forEach((t) => t(this));
155
+ }
156
+ addController(e) {
157
+ var t;
158
+ (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(e), this.renderRoot !== void 0 && this.isConnected && ((t = e.hostConnected) == null || t.call(e));
159
+ }
160
+ removeController(e) {
161
+ var t;
162
+ (t = this._$EO) == null || t.delete(e);
163
+ }
164
+ _$E_() {
165
+ const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
166
+ for (const s of t.keys()) this.hasOwnProperty(s) && (e.set(s, this[s]), delete this[s]);
167
+ e.size > 0 && (this._$Ep = e);
168
+ }
169
+ createRenderRoot() {
170
+ const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
171
+ return me(e, this.constructor.elementStyles), e;
172
+ }
173
+ connectedCallback() {
174
+ var e;
175
+ this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((t) => {
176
+ var s;
177
+ return (s = t.hostConnected) == null ? void 0 : s.call(t);
178
+ });
179
+ }
180
+ enableUpdating(e) {
181
+ }
182
+ disconnectedCallback() {
183
+ var e;
184
+ (e = this._$EO) == null || e.forEach((t) => {
185
+ var s;
186
+ return (s = t.hostDisconnected) == null ? void 0 : s.call(t);
187
+ });
188
+ }
189
+ attributeChangedCallback(e, t, s) {
190
+ this._$AK(e, s);
191
+ }
192
+ _$EC(e, t) {
193
+ var o;
194
+ const s = this.constructor.elementProperties.get(e), i = this.constructor._$Eu(e, s);
195
+ if (i !== void 0 && s.reflect === !0) {
196
+ const n = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : T).toAttribute(t, s.type);
197
+ this._$Em = e, n == null ? this.removeAttribute(i) : this.setAttribute(i, n), this._$Em = null;
198
+ }
199
+ }
200
+ _$AK(e, t) {
201
+ var o;
202
+ const s = this.constructor, i = s._$Eh.get(e);
203
+ if (i !== void 0 && this._$Em !== i) {
204
+ const n = s.getPropertyOptions(i), a = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((o = n.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? n.converter : T;
205
+ this._$Em = i, this[i] = a.fromAttribute(t, n.type), this._$Em = null;
206
+ }
207
+ }
208
+ requestUpdate(e, t, s) {
209
+ if (e !== void 0) {
210
+ if (s ?? (s = this.constructor.getPropertyOptions(e)), !(s.hasChanged ?? W)(this[e], t)) return;
211
+ this.P(e, t, s);
212
+ }
213
+ this.isUpdatePending === !1 && (this._$ES = this._$ET());
214
+ }
215
+ P(e, t, s) {
216
+ this._$AL.has(e) || this._$AL.set(e, t), s.reflect === !0 && this._$Em !== e && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(e);
217
+ }
218
+ async _$ET() {
219
+ this.isUpdatePending = !0;
220
+ try {
221
+ await this._$ES;
222
+ } catch (t) {
223
+ Promise.reject(t);
224
+ }
225
+ const e = this.scheduleUpdate();
226
+ return e != null && await e, !this.isUpdatePending;
227
+ }
228
+ scheduleUpdate() {
229
+ return this.performUpdate();
230
+ }
231
+ performUpdate() {
232
+ var s;
233
+ if (!this.isUpdatePending) return;
234
+ if (!this.hasUpdated) {
235
+ if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
236
+ for (const [o, n] of this._$Ep) this[o] = n;
237
+ this._$Ep = void 0;
238
+ }
239
+ const i = this.constructor.elementProperties;
240
+ if (i.size > 0) for (const [o, n] of i) n.wrapped !== !0 || this._$AL.has(o) || this[o] === void 0 || this.P(o, this[o], n);
241
+ }
242
+ let e = !1;
243
+ const t = this._$AL;
244
+ try {
245
+ e = this.shouldUpdate(t), e ? (this.willUpdate(t), (s = this._$EO) == null || s.forEach((i) => {
246
+ var o;
247
+ return (o = i.hostUpdate) == null ? void 0 : o.call(i);
248
+ }), this.update(t)) : this._$EU();
249
+ } catch (i) {
250
+ throw e = !1, this._$EU(), i;
251
+ }
252
+ e && this._$AE(t);
253
+ }
254
+ willUpdate(e) {
255
+ }
256
+ _$AE(e) {
257
+ var t;
258
+ (t = this._$EO) == null || t.forEach((s) => {
259
+ var i;
260
+ return (i = s.hostUpdated) == null ? void 0 : i.call(s);
261
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
262
+ }
263
+ _$EU() {
264
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
265
+ }
266
+ get updateComplete() {
267
+ return this.getUpdateComplete();
268
+ }
269
+ getUpdateComplete() {
270
+ return this._$ES;
271
+ }
272
+ shouldUpdate(e) {
273
+ return !0;
274
+ }
275
+ update(e) {
276
+ this._$Ej && (this._$Ej = this._$Ej.forEach((t) => this._$EC(t, this[t]))), this._$EU();
277
+ }
278
+ updated(e) {
279
+ }
280
+ firstUpdated(e) {
281
+ }
282
+ }
283
+ S.elementStyles = [], S.shadowRootOptions = { mode: "open" }, S[C("elementProperties")] = /* @__PURE__ */ new Map(), S[C("finalized")] = /* @__PURE__ */ new Map(), B == null || B({ ReactiveElement: S }), (g.reactiveElementVersions ?? (g.reactiveElementVersions = [])).push("2.0.4");
284
+ /**
285
+ * @license
286
+ * Copyright 2017 Google LLC
287
+ * SPDX-License-Identifier: BSD-3-Clause
288
+ */
289
+ const Ae = { attribute: !0, type: String, converter: T, reflect: !1, hasChanged: W }, xe = (r = Ae, e, t) => {
290
+ const { kind: s, metadata: i } = t;
291
+ let o = globalThis.litPropertyMetadata.get(i);
292
+ if (o === void 0 && globalThis.litPropertyMetadata.set(i, o = /* @__PURE__ */ new Map()), o.set(t.name, r), s === "accessor") {
293
+ const { name: n } = t;
294
+ return { set(a) {
295
+ const l = e.get.call(this);
296
+ e.set.call(this, a), this.requestUpdate(n, l, r);
297
+ }, init(a) {
298
+ return a !== void 0 && this.P(n, void 0, r), a;
299
+ } };
300
+ }
301
+ if (s === "setter") {
302
+ const { name: n } = t;
303
+ return function(a) {
304
+ const l = this[n];
305
+ e.call(this, a), this.requestUpdate(n, l, r);
306
+ };
307
+ }
308
+ throw Error("Unsupported decorator location: " + s);
309
+ };
310
+ function m(r) {
311
+ return (e, t) => typeof t == "object" ? xe(r, e, t) : ((s, i, o) => {
312
+ const n = i.hasOwnProperty(o);
313
+ return i.constructor.createProperty(o, n ? { ...s, wrapped: !0 } : s), n ? Object.getOwnPropertyDescriptor(i, o) : void 0;
314
+ })(r, e, t);
315
+ }
316
+ /**
317
+ * @license
318
+ * Copyright 2017 Google LLC
319
+ * SPDX-License-Identifier: BSD-3-Clause
320
+ */
321
+ function ae(r) {
322
+ return m({ ...r, state: !0, attribute: !1 });
323
+ }
324
+ /**
325
+ * @license
326
+ * Copyright 2017 Google LLC
327
+ * SPDX-License-Identifier: BSD-3-Clause
328
+ */
329
+ const Se = (r, e, t) => (t.configurable = !0, t.enumerable = !0, Reflect.decorate && typeof e != "object" && Object.defineProperty(r, e, t), t);
330
+ /**
331
+ * @license
332
+ * Copyright 2021 Google LLC
333
+ * SPDX-License-Identifier: BSD-3-Clause
334
+ */
335
+ function Ee(r) {
336
+ return (e, t) => {
337
+ const { slot: s, selector: i } = r ?? {}, o = "slot" + (s ? `[name=${s}]` : ":not([name])");
338
+ return Se(e, t, { get() {
339
+ var l;
340
+ const n = (l = this.renderRoot) == null ? void 0 : l.querySelector(o), a = (n == null ? void 0 : n.assignedElements(r)) ?? [];
341
+ return i === void 0 ? a : a.filter((h) => h.matches(i));
342
+ } });
343
+ };
344
+ }
345
+ /**
346
+ * @license
347
+ * Copyright 2017 Google LLC
348
+ * SPDX-License-Identifier: BSD-3-Clause
349
+ */
350
+ const O = globalThis, R = O.trustedTypes, Y = R ? R.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, de = "$lit$", v = `lit$${Math.random().toFixed(9).slice(2)}$`, he = "?" + v, Ce = `<${he}>`, w = document, D = () => w.createComment(""), P = (r) => r === null || typeof r != "object" && typeof r != "function", J = Array.isArray, Oe = (r) => J(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", q = `[
351
+ \f\r]`, E = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ee = /-->/g, te = />/g, b = RegExp(`>|${q}(?:([^\\s"'>=/]+)(${q}*=${q}*(?:[^
352
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), se = /'/g, ie = /"/g, ce = /^(?:script|style|textarea|title)$/i, A = Symbol.for("lit-noChange"), c = Symbol.for("lit-nothing"), re = /* @__PURE__ */ new WeakMap(), y = w.createTreeWalker(w, 129);
353
+ function ue(r, e) {
354
+ if (!J(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
355
+ return Y !== void 0 ? Y.createHTML(e) : e;
356
+ }
357
+ const Pe = (r, e) => {
358
+ const t = r.length - 1, s = [];
359
+ let i, o = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", n = E;
360
+ for (let a = 0; a < t; a++) {
361
+ const l = r[a];
362
+ let h, u, d = -1, $ = 0;
363
+ for (; $ < l.length && (n.lastIndex = $, u = n.exec(l), u !== null); ) $ = n.lastIndex, n === E ? u[1] === "!--" ? n = ee : u[1] !== void 0 ? n = te : u[2] !== void 0 ? (ce.test(u[2]) && (i = RegExp("</" + u[2], "g")), n = b) : u[3] !== void 0 && (n = b) : n === b ? u[0] === ">" ? (n = i ?? E, d = -1) : u[1] === void 0 ? d = -2 : (d = n.lastIndex - u[2].length, h = u[1], n = u[3] === void 0 ? b : u[3] === '"' ? ie : se) : n === ie || n === se ? n = b : n === ee || n === te ? n = E : (n = b, i = void 0);
364
+ const _ = n === b && r[a + 1].startsWith("/>") ? " " : "";
365
+ o += n === E ? l + Ce : d >= 0 ? (s.push(h), l.slice(0, d) + de + l.slice(d) + v + _) : l + v + (d === -2 ? a : _);
366
+ }
367
+ return [ue(r, o + (r[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s];
368
+ };
369
+ class k {
370
+ constructor({ strings: e, _$litType$: t }, s) {
371
+ let i;
372
+ this.parts = [];
373
+ let o = 0, n = 0;
374
+ const a = e.length - 1, l = this.parts, [h, u] = Pe(e, t);
375
+ if (this.el = k.createElement(h, s), y.currentNode = this.el.content, t === 2 || t === 3) {
376
+ const d = this.el.content.firstChild;
377
+ d.replaceWith(...d.childNodes);
378
+ }
379
+ for (; (i = y.nextNode()) !== null && l.length < a; ) {
380
+ if (i.nodeType === 1) {
381
+ if (i.hasAttributes()) for (const d of i.getAttributeNames()) if (d.endsWith(de)) {
382
+ const $ = u[n++], _ = i.getAttribute(d).split(v), U = /([.?@])?(.*)/.exec($);
383
+ l.push({ type: 1, index: o, name: U[2], strings: _, ctor: U[1] === "." ? Ie : U[1] === "?" ? Ue : U[1] === "@" ? Le : z }), i.removeAttribute(d);
384
+ } else d.startsWith(v) && (l.push({ type: 6, index: o }), i.removeAttribute(d));
385
+ if (ce.test(i.tagName)) {
386
+ const d = i.textContent.split(v), $ = d.length - 1;
387
+ if ($ > 0) {
388
+ i.textContent = R ? R.emptyScript : "";
389
+ for (let _ = 0; _ < $; _++) i.append(d[_], D()), y.nextNode(), l.push({ type: 2, index: ++o });
390
+ i.append(d[$], D());
391
+ }
392
+ }
393
+ } else if (i.nodeType === 8) if (i.data === he) l.push({ type: 2, index: o });
394
+ else {
395
+ let d = -1;
396
+ for (; (d = i.data.indexOf(v, d + 1)) !== -1; ) l.push({ type: 7, index: o }), d += v.length - 1;
397
+ }
398
+ o++;
399
+ }
400
+ }
401
+ static createElement(e, t) {
402
+ const s = w.createElement("template");
403
+ return s.innerHTML = e, s;
404
+ }
405
+ }
406
+ function x(r, e, t = r, s) {
407
+ var n, a;
408
+ if (e === A) return e;
409
+ let i = s !== void 0 ? (n = t._$Co) == null ? void 0 : n[s] : t._$Cl;
410
+ const o = P(e) ? void 0 : e._$litDirective$;
411
+ return (i == null ? void 0 : i.constructor) !== o && ((a = i == null ? void 0 : i._$AO) == null || a.call(i, !1), o === void 0 ? i = void 0 : (i = new o(r), i._$AT(r, t, s)), s !== void 0 ? (t._$Co ?? (t._$Co = []))[s] = i : t._$Cl = i), i !== void 0 && (e = x(r, i._$AS(r, e.values), i, s)), e;
412
+ }
413
+ class ke {
414
+ constructor(e, t) {
415
+ this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
416
+ }
417
+ get parentNode() {
418
+ return this._$AM.parentNode;
419
+ }
420
+ get _$AU() {
421
+ return this._$AM._$AU;
422
+ }
423
+ u(e) {
424
+ const { el: { content: t }, parts: s } = this._$AD, i = ((e == null ? void 0 : e.creationScope) ?? w).importNode(t, !0);
425
+ y.currentNode = i;
426
+ let o = y.nextNode(), n = 0, a = 0, l = s[0];
427
+ for (; l !== void 0; ) {
428
+ if (n === l.index) {
429
+ let h;
430
+ l.type === 2 ? h = new j(o, o.nextSibling, this, e) : l.type === 1 ? h = new l.ctor(o, l.name, l.strings, this, e) : l.type === 6 && (h = new He(o, this, e)), this._$AV.push(h), l = s[++a];
431
+ }
432
+ n !== (l == null ? void 0 : l.index) && (o = y.nextNode(), n++);
433
+ }
434
+ return y.currentNode = w, i;
435
+ }
436
+ p(e) {
437
+ let t = 0;
438
+ for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(e, s, t), t += s.strings.length - 2) : s._$AI(e[t])), t++;
439
+ }
440
+ }
441
+ class j {
442
+ get _$AU() {
443
+ var e;
444
+ return ((e = this._$AM) == null ? void 0 : e._$AU) ?? this._$Cv;
445
+ }
446
+ constructor(e, t, s, i) {
447
+ this.type = 2, this._$AH = c, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = s, this.options = i, this._$Cv = (i == null ? void 0 : i.isConnected) ?? !0;
448
+ }
449
+ get parentNode() {
450
+ let e = this._$AA.parentNode;
451
+ const t = this._$AM;
452
+ return t !== void 0 && (e == null ? void 0 : e.nodeType) === 11 && (e = t.parentNode), e;
453
+ }
454
+ get startNode() {
455
+ return this._$AA;
456
+ }
457
+ get endNode() {
458
+ return this._$AB;
459
+ }
460
+ _$AI(e, t = this) {
461
+ e = x(this, e, t), P(e) ? e === c || e == null || e === "" ? (this._$AH !== c && this._$AR(), this._$AH = c) : e !== this._$AH && e !== A && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Oe(e) ? this.k(e) : this._(e);
462
+ }
463
+ O(e) {
464
+ return this._$AA.parentNode.insertBefore(e, this._$AB);
465
+ }
466
+ T(e) {
467
+ this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
468
+ }
469
+ _(e) {
470
+ this._$AH !== c && P(this._$AH) ? this._$AA.nextSibling.data = e : this.T(w.createTextNode(e)), this._$AH = e;
471
+ }
472
+ $(e) {
473
+ var o;
474
+ const { values: t, _$litType$: s } = e, i = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el = k.createElement(ue(s.h, s.h[0]), this.options)), s);
475
+ if (((o = this._$AH) == null ? void 0 : o._$AD) === i) this._$AH.p(t);
476
+ else {
477
+ const n = new ke(i, this), a = n.u(this.options);
478
+ n.p(t), this.T(a), this._$AH = n;
479
+ }
480
+ }
481
+ _$AC(e) {
482
+ let t = re.get(e.strings);
483
+ return t === void 0 && re.set(e.strings, t = new k(e)), t;
484
+ }
485
+ k(e) {
486
+ J(this._$AH) || (this._$AH = [], this._$AR());
487
+ const t = this._$AH;
488
+ let s, i = 0;
489
+ for (const o of e) i === t.length ? t.push(s = new j(this.O(D()), this.O(D()), this, this.options)) : s = t[i], s._$AI(o), i++;
490
+ i < t.length && (this._$AR(s && s._$AB.nextSibling, i), t.length = i);
491
+ }
492
+ _$AR(e = this._$AA.nextSibling, t) {
493
+ var s;
494
+ for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, t); e && e !== this._$AB; ) {
495
+ const i = e.nextSibling;
496
+ e.remove(), e = i;
497
+ }
498
+ }
499
+ setConnected(e) {
500
+ var t;
501
+ this._$AM === void 0 && (this._$Cv = e, (t = this._$AP) == null || t.call(this, e));
502
+ }
503
+ }
504
+ class z {
505
+ get tagName() {
506
+ return this.element.tagName;
507
+ }
508
+ get _$AU() {
509
+ return this._$AM._$AU;
510
+ }
511
+ constructor(e, t, s, i, o) {
512
+ this.type = 1, this._$AH = c, this._$AN = void 0, this.element = e, this.name = t, this._$AM = i, this.options = o, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = c;
513
+ }
514
+ _$AI(e, t = this, s, i) {
515
+ const o = this.strings;
516
+ let n = !1;
517
+ if (o === void 0) e = x(this, e, t, 0), n = !P(e) || e !== this._$AH && e !== A, n && (this._$AH = e);
518
+ else {
519
+ const a = e;
520
+ let l, h;
521
+ for (e = o[0], l = 0; l < o.length - 1; l++) h = x(this, a[s + l], t, l), h === A && (h = this._$AH[l]), n || (n = !P(h) || h !== this._$AH[l]), h === c ? e = c : e !== c && (e += (h ?? "") + o[l + 1]), this._$AH[l] = h;
522
+ }
523
+ n && !i && this.j(e);
524
+ }
525
+ j(e) {
526
+ e === c ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
527
+ }
528
+ }
529
+ class Ie extends z {
530
+ constructor() {
531
+ super(...arguments), this.type = 3;
532
+ }
533
+ j(e) {
534
+ this.element[this.name] = e === c ? void 0 : e;
535
+ }
536
+ }
537
+ class Ue extends z {
538
+ constructor() {
539
+ super(...arguments), this.type = 4;
540
+ }
541
+ j(e) {
542
+ this.element.toggleAttribute(this.name, !!e && e !== c);
543
+ }
544
+ }
545
+ class Le extends z {
546
+ constructor(e, t, s, i, o) {
547
+ super(e, t, s, i, o), this.type = 5;
548
+ }
549
+ _$AI(e, t = this) {
550
+ if ((e = x(this, e, t, 0) ?? c) === A) return;
551
+ const s = this._$AH, i = e === c && s !== c || e.capture !== s.capture || e.once !== s.once || e.passive !== s.passive, o = e !== c && (s === c || i);
552
+ i && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, e), this._$AH = e;
553
+ }
554
+ handleEvent(e) {
555
+ var t;
556
+ typeof this._$AH == "function" ? this._$AH.call(((t = this.options) == null ? void 0 : t.host) ?? this.element, e) : this._$AH.handleEvent(e);
557
+ }
558
+ }
559
+ class He {
560
+ constructor(e, t, s) {
561
+ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s;
562
+ }
563
+ get _$AU() {
564
+ return this._$AM._$AU;
565
+ }
566
+ _$AI(e) {
567
+ x(this, e);
568
+ }
569
+ }
570
+ const V = O.litHtmlPolyfillSupport;
571
+ V == null || V(k, j), (O.litHtmlVersions ?? (O.litHtmlVersions = [])).push("3.2.1");
572
+ /**
573
+ * @license
574
+ * Copyright 2017 Google LLC
575
+ * SPDX-License-Identifier: BSD-3-Clause
576
+ */
577
+ const Me = { ATTRIBUTE: 1 }, Te = (r) => (...e) => ({ _$litDirective$: r, values: e });
578
+ class Re {
579
+ constructor(e) {
580
+ }
581
+ get _$AU() {
582
+ return this._$AM._$AU;
583
+ }
584
+ _$AT(e, t, s) {
585
+ this._$Ct = e, this._$AM = t, this._$Ci = s;
586
+ }
587
+ _$AS(e, t) {
588
+ return this.update(e, t);
589
+ }
590
+ update(e, t) {
591
+ return this.render(...t);
592
+ }
593
+ }
594
+ /**
595
+ * @license
596
+ * Copyright 2018 Google LLC
597
+ * SPDX-License-Identifier: BSD-3-Clause
598
+ */
599
+ const De = Te(class extends Re {
600
+ constructor(r) {
601
+ var e;
602
+ if (super(r), r.type !== Me.ATTRIBUTE || r.name !== "class" || ((e = r.strings) == null ? void 0 : e.length) > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
603
+ }
604
+ render(r) {
605
+ return " " + Object.keys(r).filter((e) => r[e]).join(" ") + " ";
606
+ }
607
+ update(r, [e]) {
608
+ var s, i;
609
+ if (this.st === void 0) {
610
+ this.st = /* @__PURE__ */ new Set(), r.strings !== void 0 && (this.nt = new Set(r.strings.join(" ").split(/\s/).filter((o) => o !== "")));
611
+ for (const o in e) e[o] && !((s = this.nt) != null && s.has(o)) && this.st.add(o);
612
+ return this.render(e);
613
+ }
614
+ const t = r.element.classList;
615
+ for (const o of this.st) o in e || (t.remove(o), this.st.delete(o));
616
+ for (const o in e) {
617
+ const n = !!e[o];
618
+ n === this.st.has(o) || (i = this.nt) != null && i.has(o) || (n ? (t.add(o), this.st.add(o)) : (t.remove(o), this.st.delete(o)));
619
+ }
620
+ return A;
621
+ }
622
+ }), Ne = ':host{position:relative;display:block}.dropdown-wrapper{display:flex;flex-direction:column;gap:8px;align-items:start}.dropdown,.menu,.toggle,.dropdown-wrapper{min-width:115px;max-width:var(--ucds-form-element-maxwidth);width:var(--ucds-form-element-width)}.dropdown{position:relative}.toggle{display:flex;align-items:center;justify-content:space-between;gap:16px;height:48px;padding:0 var(--ucds-form-element-horizontal-padding);font-family:var(--ucds-font-proxima-nova-family);font-size:var(--ucds-font-base-size);border:var(--ucds-color-forms-input-border-rest) solid var(--ucds-form-element-border-width);border-radius:var(--ucds-form-element-border-radius);background-color:var(--ucds-color-forms-input-background-rest)}.toggle:focus{outline:var(--ucds-color-action-focus) 2px solid;outline-offset:2px}.toggle .selected-label-wrapper{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.toggle ucds-icon{color:var(--ucds-color-action-rest);transition:transform .5s ease}.toggle.error{background-color:var(--ucds-color-feedback-error-background-light);border-color:var(--ucds-color-feedback-error-light)}.toggle:hover{border-color:var(--ucds-color-forms-input-border-hover);cursor:pointer}.toggle.disabled{border-color:var(--ucds-color-forms-input-border-disabled);color:var(--ucds-color-text-disabled);cursor:not-allowed;pointer-events:none}.toggle.disabled ucds-icon{color:var(--ucds-color-forms-input-element-disabled)}.menu{position:absolute;background:var(--ucds-color-forms-input-background-rest);border:var(--ucds-color-forms-input-border-rest) solid var(--ucds-form-element-border-width);border-radius:var(--ucds-form-element-border-radius);display:none;cursor:pointer;list-style:none;margin:0;padding:12px;flex-direction:column;gap:8px;overflow-y:auto;z-index:100;-webkit-overflow-scrolling:touch;scroll-behavior:smooth}:host([open]) .menu{display:flex}:host([open]) ucds-icon{transform:rotateX(180deg)}:host([data-open-direction="up"]) .menu{bottom:calc(100% + 8px)}:host([data-open-direction="down"]) .menu{top:calc(100% + 8px)}';
623
+ var je = Object.defineProperty, ze = Object.getOwnPropertyDescriptor, f = (r, e, t, s) => {
624
+ for (var i = s > 1 ? void 0 : s ? ze(e, t) : e, o = r.length - 1, n; o >= 0; o--)
625
+ (n = r[o]) && (i = (s ? n(e, t, i) : n(i)) || i);
626
+ return s && i && je(e, t, i), i;
627
+ };
628
+ let p = class extends N {
629
+ // == Constructor ==
630
+ constructor() {
631
+ super(), this.initialValue = "", this.initialLabel = "", this._isOutsideClickListenerAttached = !1, this.scrollHandler = () => this._adjustDropdownDirection(), this.resizeObserver = new ResizeObserver(() => this._adjustDropdownDirection()), this.errorText = "", this.inputId = "", this.label = "", this.name = "", this.selectedLabel = "- Select -", this.disabled = !1, this.error = !1, this.open = !1, this.required = !1, this.activeIndex = -1, this._value = "", this.internals = this.attachInternals();
632
+ }
633
+ // == Accessors ==
634
+ /** Returns the current value of the dropdown. */
635
+ get value() {
636
+ return this._value;
637
+ }
638
+ /** Updates the value, triggers reactivity and form value update. */
639
+ set value(r) {
640
+ const e = this._value;
641
+ this._value = r, this.internals.setFormValue(this._value), this.requestUpdate("value", e);
642
+ }
643
+ // == Lifecycle methods ==
644
+ connectedCallback() {
645
+ super.connectedCallback && super.connectedCallback(), this.addEventListener("keydown", this._handleKeydown), this._boundOutsideClickHandler = this._handleOutsideClick.bind(this);
646
+ }
647
+ disconnectedCallback() {
648
+ super.disconnectedCallback && super.disconnectedCallback(), this.removeEventListener("keydown", this._handleKeydown), this._removeOutsideClickListener();
649
+ }
650
+ firstUpdated() {
651
+ const r = this.items.find((e) => e.hasAttribute("selected"));
652
+ queueMicrotask(() => {
653
+ var e;
654
+ !this.value && r ? (this.initialValue = r.value, this.initialLabel = (e = r.textContent) == null ? void 0 : e.trim(), this.value = this.initialValue, this.selectedLabel = this.initialLabel, this.activeIndex = this.items.indexOf(r)) : (this.initialValue = "", this.initialLabel = this.selectedLabel), this._syncSelectedItem();
655
+ });
656
+ }
657
+ // == Event handlers ==
658
+ /** Handles keyboard navigation and interaction. */
659
+ _handleKeydown(r) {
660
+ var t, s;
661
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector(".toggle");
662
+ if (!this.open) {
663
+ if (["ArrowDown", "ArrowUp", " "].includes(r.key)) {
664
+ this._toggleMenu();
665
+ const i = this.items.findIndex((o) => o.hasAttribute("selected"));
666
+ this.activeIndex = i >= 0 ? i : 0, this.updateComplete.then(() => this._focusActiveItem()), r.preventDefault(), r.stopImmediatePropagation();
667
+ } else if (["ArrowLeft", "ArrowRight"].includes(r.key)) {
668
+ r.preventDefault(), r.stopImmediatePropagation();
669
+ const i = this.items.find((a) => a.hasAttribute("selected")), o = i ? this.items.indexOf(i) : -1;
670
+ let n = o;
671
+ r.key === "ArrowLeft" ? n = Math.max(o - 1, 0) : r.key === "ArrowRight" && (n = Math.min(o + 1, this.items.length - 1)), n !== this.activeIndex && (this.activeIndex = n, this.value = this.items[this.activeIndex].value, this.selectedLabel = (s = this.items[this.activeIndex].textContent) == null ? void 0 : s.trim(), this._syncSelectedItem(), this.dispatchEvent(new CustomEvent("change", {
672
+ detail: { value: this.value, selectedLabel: this.selectedLabel },
673
+ bubbles: !0,
674
+ composed: !0
675
+ })));
676
+ }
677
+ return;
678
+ }
679
+ switch (r.key) {
680
+ case "ArrowDown":
681
+ r.preventDefault(), this.activeIndex = Math.min(this.activeIndex + 1, this.items.length - 1), this._focusActiveItem();
682
+ break;
683
+ case "ArrowUp":
684
+ r.preventDefault(), this.activeIndex = Math.max(this.activeIndex - 1, 0), this._focusActiveItem();
685
+ break;
686
+ case "Escape":
687
+ this._toggleMenu(), e == null || e.focus();
688
+ break;
689
+ }
690
+ }
691
+ /** Handles selection of an item via custom `dropdown-select` event. */
692
+ _handleSelection(r) {
693
+ this.value = r.detail.value, this.selectedLabel = r.detail.selectedLabel, this._syncSelectedItem(), queueMicrotask(() => {
694
+ var s;
695
+ const e = this.items.find((i) => i.hasAttribute("selected"));
696
+ this.activeIndex = this.items.indexOf(e), this._toggleMenu();
697
+ const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".toggle");
698
+ t == null || t.focus();
699
+ });
700
+ }
701
+ /** Closes the dropdown when clicking outside. */
702
+ _handleOutsideClick(r) {
703
+ var e;
704
+ if (this.open) {
705
+ const t = r.composedPath(), s = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".menu");
706
+ (!s || !t.includes(s)) && (this.open = !1, this._removeOutsideClickListener());
707
+ }
708
+ }
709
+ // == Form-associated methods ==
710
+ /** Called when parent form is reset. */
711
+ formResetCallback() {
712
+ var e;
713
+ this.value = this.initialValue;
714
+ const r = this.items.find((t) => t.value === this.initialValue);
715
+ r ? (this.selectedLabel = (e = r.textContent) == null ? void 0 : e.trim(), this.activeIndex = this.items.indexOf(r)) : (this.selectedLabel = this.initialLabel, this.activeIndex = -1), this._syncSelectedItem();
716
+ }
717
+ /** Called when form state is restored. */
718
+ formStateRestoreCallback(r) {
719
+ var t;
720
+ const e = this.items.find((s) => s.value === r);
721
+ e ? (this.selectedLabel = (t = e.textContent) == null ? void 0 : t.trim(), this.activeIndex = this.items.indexOf(e), this._syncSelectedItem(), this.value = r) : console.warn("No matching item found during restore");
722
+ }
723
+ // == Private methods ==
724
+ /** Opens or closes the dropdown. */
725
+ _toggleMenu() {
726
+ this.disabled || (this.open = !this.open), this.open ? (this._adjustDropdownDirection(), window.addEventListener("scroll", this.scrollHandler, !0), window.addEventListener("resize", this.scrollHandler), this.resizeObserver.observe(this), this._isOutsideClickListenerAttached || setTimeout(() => {
727
+ document.addEventListener("click", this._boundOutsideClickHandler), this._isOutsideClickListenerAttached = !0;
728
+ }, 0)) : (this._removeOutsideClickListener(), window.removeEventListener("scroll", this.scrollHandler, !0), window.removeEventListener("resize", this.scrollHandler), this.resizeObserver.disconnect());
729
+ }
730
+ /** Marks selected item visually based on value. */
731
+ _syncSelectedItem() {
732
+ this.items.forEach((r) => {
733
+ const e = r;
734
+ e.selected = e.value === this.value;
735
+ });
736
+ }
737
+ /** Determines if dropdown should open upward or downward based on viewport space. */
738
+ _adjustDropdownDirection() {
739
+ var n, a;
740
+ const e = ((n = this.shadowRoot) == null ? void 0 : n.querySelector(".dropdown")).getBoundingClientRect(), t = e.top, s = window.innerHeight - e.bottom, i = s >= t ? "down" : "up";
741
+ this.setAttribute("data-open-direction", i);
742
+ const o = (a = this.shadowRoot) == null ? void 0 : a.querySelector(".menu");
743
+ if (o) {
744
+ const l = i === "down" ? s - 16 : t - 16;
745
+ o.style.maxHeight = `${l}px`;
746
+ }
747
+ }
748
+ /** Focuses the currently active item (for keyboard nav). */
749
+ _focusActiveItem() {
750
+ var r, e;
751
+ if (this.items.length > 0 && this.activeIndex > -1) {
752
+ const t = (e = (r = this.items[this.activeIndex]) == null ? void 0 : r.shadowRoot) == null ? void 0 : e.querySelector(".dropdown-item");
753
+ t == null || t.focus();
754
+ }
755
+ }
756
+ /** Helper to remove the outside click handler and update _isOutsideClickListenerAttached at the same time. */
757
+ _removeOutsideClickListener() {
758
+ this._isOutsideClickListenerAttached && (document.removeEventListener("click", this._boundOutsideClickHandler), this._isOutsideClickListenerAttached = !1);
759
+ }
760
+ // == Render ==
761
+ render() {
762
+ const r = {
763
+ disabled: this.disabled,
764
+ error: this.error
765
+ };
766
+ return H`
767
+ <div class="dropdown-wrapper">
768
+ ${this.label ? H`
769
+ <form-label id="${this.inputId}-label" for="${this.inputId}" text="${this.label}" ?required="${this.required}" ?disabled="${this.disabled}"></form-label>` : L}
770
+ <div class="dropdown">
771
+ <div class="toggle ${De(r)}"
772
+ aria-disabled="${this.disabled ? !0 : L}"
773
+ role="button"
774
+ tabindex="${this.disabled ? "-1" : "0"}"
775
+ @click="${this._toggleMenu}"
776
+ @keydown=${this._handleKeydown}
777
+ aria-expanded="${this.open}">
778
+ <div class="selected-label-wrapper">
779
+ ${this.selectedLabel}
780
+ </div>
781
+ <ucds-icon name="chevronDown" size="24"></ucds-icon>
782
+ </div>
783
+ <div class="menu" ?open="${this.open}" role="listbox" aria-labelledby="${this.inputId}-label" @dropdown-select=${this._handleSelection}>
784
+ <slot></slot>
785
+ </div>
786
+ </div>
787
+ ${this.error ? H`<form-error-message text="${this.errorText}"></form-error-message>` : L}
788
+ </div>
789
+ `;
790
+ }
791
+ };
792
+ p.styles = [
793
+ N.styles,
794
+ oe(Ne)
795
+ ];
796
+ p.formAssociated = !0;
797
+ f([
798
+ m({ type: String, attribute: "error-text" })
799
+ ], p.prototype, "errorText", 2);
800
+ f([
801
+ m({ type: String, attribute: "input-id" })
802
+ ], p.prototype, "inputId", 2);
803
+ f([
804
+ m({ type: String })
805
+ ], p.prototype, "label", 2);
806
+ f([
807
+ m({ type: String, reflect: !0 })
808
+ ], p.prototype, "name", 2);
809
+ f([
810
+ m({ type: String, attribute: "selected-label" })
811
+ ], p.prototype, "selectedLabel", 2);
812
+ f([
813
+ m({ type: Boolean, reflect: !0 })
814
+ ], p.prototype, "disabled", 2);
815
+ f([
816
+ m({ type: Boolean, reflect: !0 })
817
+ ], p.prototype, "error", 2);
818
+ f([
819
+ m({ type: Boolean, reflect: !0 })
820
+ ], p.prototype, "open", 2);
821
+ f([
822
+ m({ type: Boolean, reflect: !0 })
823
+ ], p.prototype, "required", 2);
824
+ f([
825
+ ae()
826
+ ], p.prototype, "activeIndex", 2);
827
+ f([
828
+ ae()
829
+ ], p.prototype, "_value", 2);
830
+ f([
831
+ Ee({ selector: "ucds-dropdown-item" })
832
+ ], p.prototype, "items", 2);
833
+ p = f([
834
+ ne("ucds-dropdown")
835
+ ], p);
836
+ const Be = ".dropdown-item{display:flex;gap:4px;align-items:center;padding:10px 6px 10px 26px;border-radius:8px}.dropdown-item ucds-icon{display:none}.dropdown-item .dropdown-item-text{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dropdown-item:hover,.dropdown-item:active,.dropdown-item:focus{background-color:var(--ucds-color-palette-berry-900);outline:none}.dropdown-item.selected{padding-left:6px}.dropdown-item.selected ucds-icon{display:inline-flex}";
837
+ var qe = Object.defineProperty, Ve = Object.getOwnPropertyDescriptor, Z = (r, e, t, s) => {
838
+ for (var i = s > 1 ? void 0 : s ? Ve(e, t) : e, o = r.length - 1, n; o >= 0; o--)
839
+ (n = r[o]) && (i = (s ? n(e, t, i) : n(i)) || i);
840
+ return s && i && qe(e, t, i), i;
841
+ };
842
+ let I = class extends N {
843
+ constructor() {
844
+ super(...arguments), this.value = "", this.selected = !1;
845
+ }
846
+ // == Private methods ==
847
+ /** Called when the item is clicked or activated via keyboard. */
848
+ _select() {
849
+ var e;
850
+ const r = (e = this.textContent) == null ? void 0 : e.trim();
851
+ this.selected = !0, this.dispatchEvent(new CustomEvent("dropdown-select", {
852
+ detail: { value: this.value, selectedLabel: r },
853
+ bubbles: !0,
854
+ composed: !0
855
+ }));
856
+ }
857
+ /** Handle Enter, Tab, or Esc key to activate the item. */
858
+ _handleKeydown(r) {
859
+ (r.key === "Enter" || r.key === "Tab" || r.key === "Esc") && (r.preventDefault(), this._select());
860
+ }
861
+ // == Render ==
862
+ render() {
863
+ return H`
864
+ <div class="dropdown-item ${this.selected ? "selected" : ""}"
865
+ aria-selected="${this.selected ? !0 : L}"
866
+ role="option"
867
+ tabindex="-1"
868
+ @click=${this._select}
869
+ @keydown=${this._handleKeydown}
870
+ >
871
+ <ucds-icon name="checkmark" size="16" color="berry"></ucds-icon>
872
+ <span class="dropdown-item-text"><slot></slot></span>
873
+ </div>
874
+ `;
875
+ }
876
+ };
877
+ I.styles = [
878
+ N.styles,
879
+ oe(Be)
880
+ ];
881
+ Z([
882
+ m({ type: String })
883
+ ], I.prototype, "value", 2);
884
+ Z([
885
+ m({ type: Boolean, reflect: !0 })
886
+ ], I.prototype, "selected", 2);
887
+ I = Z([
888
+ ne("ucds-dropdown-item")
889
+ ], I);
890
+ export {
891
+ p as Dropdown,
892
+ I as DropdownItem
893
+ };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@ucalgary-design-system/dropdown",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "main": "index.js",
6
+ "module": "index.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./index.js",
10
+ "require": "./index.js"
11
+ }
12
+ },
13
+ "dependencies": {
14
+ "@ucalgary-design-system/core": "^1.0.1",
15
+ "@ucalgary-design-system/helper-components": "^1.0.1",
16
+ "@ucalgary-design-system/icon": "^1.0.1",
17
+ "@ucalgary-design-system/tokens": "^1.0.1",
18
+ "lit": "^3.2.1"
19
+ },
20
+ "description": "A web component for Dropdown",
21
+ "publishConfig": {
22
+ "access": "public"
23
+ }
24
+ }