@ucalgary-design-system/dropdown 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/index.js +139 -754
  3. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @ucalgary-design-system/dropdown
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - fe87dab: Updated externalized dependencies
8
+ - Updated dependencies [fe87dab]
9
+ - @ucalgary-design-system/icon@1.0.4
10
+ - @ucalgary-design-system/core@1.0.4
11
+ - @ucalgary-design-system/tokens@1.0.4
12
+
13
+ ## 1.0.3
14
+
15
+ ### Patch Changes
16
+
17
+ - c3fdd31: Updated dependencies and modified build
18
+ - Updated dependencies [386b04a]
19
+ - Updated dependencies [c3fdd31]
20
+ - @ucalgary-design-system/icon@1.0.3
21
+ - @ucalgary-design-system/core@1.0.3
22
+
3
23
  ## 1.0.2
4
24
 
5
25
  ### Patch Changes
package/index.js CHANGED
@@ -1,631 +1,16 @@
1
- import { unsafeCSS as oe, nothing as L, html as H } from "lit";
2
- import { BaseElement as N } from "@ucalgary-design-system/core";
1
+ import { unsafeCSS as v, nothing as u, html as p } from "lit";
2
+ import { property as a, state as b, queryAssignedElements as x, customElement as w } from "lit/decorators.js";
3
+ import { classMap as y } from "lit/directives/class-map.js";
4
+ import { BaseElement as m } from "@ucalgary-design-system/core";
3
5
  import "@ucalgary-design-system/helper-components";
4
6
  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);
7
+ const _ = ':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-family-sans-serif);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)}';
8
+ var k = Object.defineProperty, I = Object.getOwnPropertyDescriptor, d = (e, t, i, o) => {
9
+ for (var s = o > 1 ? void 0 : o ? I(t, i) : t, r = e.length - 1, n; r >= 0; r--)
10
+ (n = e[r]) && (s = (o ? n(t, i, s) : n(s)) || s);
11
+ return o && s && k(t, i, s), s;
14
12
  };
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-family-sans-serif);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 {
13
+ let l = class extends m {
629
14
  // == Constructor ==
630
15
  constructor() {
631
16
  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();
@@ -636,9 +21,9 @@ let p = class extends N {
636
21
  return this._value;
637
22
  }
638
23
  /** 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);
24
+ set value(e) {
25
+ const t = this._value;
26
+ this._value = e, this.internals.setFormValue(this._value), this.requestUpdate("value", t);
642
27
  }
643
28
  // == Lifecycle methods ==
644
29
  connectedCallback() {
@@ -648,27 +33,27 @@ let p = class extends N {
648
33
  super.disconnectedCallback && super.disconnectedCallback(), this.removeEventListener("keydown", this._handleKeydown), this._removeOutsideClickListener();
649
34
  }
650
35
  firstUpdated() {
651
- const r = this.items.find((e) => e.hasAttribute("selected"));
36
+ const e = this.items.find((t) => t.hasAttribute("selected"));
652
37
  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();
38
+ var t;
39
+ !this.value && e ? (this.initialValue = e.value, this.initialLabel = (t = e.textContent) == null ? void 0 : t.trim(), this.value = this.initialValue, this.selectedLabel = this.initialLabel, this.activeIndex = this.items.indexOf(e)) : (this.initialValue = "", this.initialLabel = this.selectedLabel), this._syncSelectedItem();
655
40
  });
656
41
  }
657
42
  // == Event handlers ==
658
43
  /** Handles keyboard navigation and interaction. */
659
- _handleKeydown(r) {
660
- var t, s;
661
- const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector(".toggle");
44
+ _handleKeydown(e) {
45
+ var i, o;
46
+ const t = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".toggle");
662
47
  if (!this.open) {
663
- if (["ArrowDown", "ArrowUp", " "].includes(r.key)) {
48
+ if (["ArrowDown", "ArrowUp", " "].includes(e.key)) {
664
49
  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", {
50
+ const s = this.items.findIndex((r) => r.hasAttribute("selected"));
51
+ this.activeIndex = s >= 0 ? s : 0, this.updateComplete.then(() => this._focusActiveItem()), e.preventDefault(), e.stopImmediatePropagation();
52
+ } else if (["ArrowLeft", "ArrowRight"].includes(e.key)) {
53
+ e.preventDefault(), e.stopImmediatePropagation();
54
+ const s = this.items.find((h) => h.hasAttribute("selected")), r = s ? this.items.indexOf(s) : -1;
55
+ let n = r;
56
+ e.key === "ArrowLeft" ? n = Math.max(r - 1, 0) : e.key === "ArrowRight" && (n = Math.min(r + 1, this.items.length - 1)), n !== this.activeIndex && (this.activeIndex = n, this.value = this.items[this.activeIndex].value, this.selectedLabel = (o = this.items[this.activeIndex].textContent) == null ? void 0 : o.trim(), this._syncSelectedItem(), this.dispatchEvent(new CustomEvent("change", {
672
57
  detail: { value: this.value, selectedLabel: this.selectedLabel },
673
58
  bubbles: !0,
674
59
  composed: !0
@@ -676,49 +61,49 @@ let p = class extends N {
676
61
  }
677
62
  return;
678
63
  }
679
- switch (r.key) {
64
+ switch (e.key) {
680
65
  case "ArrowDown":
681
- r.preventDefault(), this.activeIndex = Math.min(this.activeIndex + 1, this.items.length - 1), this._focusActiveItem();
66
+ e.preventDefault(), this.activeIndex = Math.min(this.activeIndex + 1, this.items.length - 1), this._focusActiveItem();
682
67
  break;
683
68
  case "ArrowUp":
684
- r.preventDefault(), this.activeIndex = Math.max(this.activeIndex - 1, 0), this._focusActiveItem();
69
+ e.preventDefault(), this.activeIndex = Math.max(this.activeIndex - 1, 0), this._focusActiveItem();
685
70
  break;
686
71
  case "Escape":
687
- this._toggleMenu(), e == null || e.focus();
72
+ this._toggleMenu(), t == null || t.focus();
688
73
  break;
689
74
  }
690
75
  }
691
76
  /** 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();
77
+ _handleSelection(e) {
78
+ this.value = e.detail.value, this.selectedLabel = e.detail.selectedLabel, this._syncSelectedItem(), queueMicrotask(() => {
79
+ var o;
80
+ const t = this.items.find((s) => s.hasAttribute("selected"));
81
+ this.activeIndex = this.items.indexOf(t), this._toggleMenu();
82
+ const i = (o = this.shadowRoot) == null ? void 0 : o.querySelector(".toggle");
83
+ i == null || i.focus();
699
84
  });
700
85
  }
701
86
  /** Closes the dropdown when clicking outside. */
702
- _handleOutsideClick(r) {
703
- var e;
87
+ _handleOutsideClick(e) {
88
+ var t;
704
89
  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());
90
+ const i = e.composedPath(), o = (t = this.shadowRoot) == null ? void 0 : t.querySelector(".menu");
91
+ (!o || !i.includes(o)) && (this.open = !1, this._removeOutsideClickListener());
707
92
  }
708
93
  }
709
94
  // == Form-associated methods ==
710
95
  /** Called when parent form is reset. */
711
96
  formResetCallback() {
712
- var e;
97
+ var t;
713
98
  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();
99
+ const e = this.items.find((i) => i.value === this.initialValue);
100
+ e ? (this.selectedLabel = (t = e.textContent) == null ? void 0 : t.trim(), this.activeIndex = this.items.indexOf(e)) : (this.selectedLabel = this.initialLabel, this.activeIndex = -1), this._syncSelectedItem();
716
101
  }
717
102
  /** 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");
103
+ formStateRestoreCallback(e) {
104
+ var i;
105
+ const t = this.items.find((o) => o.value === e);
106
+ t ? (this.selectedLabel = (i = t.textContent) == null ? void 0 : i.trim(), this.activeIndex = this.items.indexOf(t), this._syncSelectedItem(), this.value = e) : console.warn("No matching item found during restore");
722
107
  }
723
108
  // == Private methods ==
724
109
  /** Opens or closes the dropdown. */
@@ -729,28 +114,28 @@ let p = class extends N {
729
114
  }
730
115
  /** Marks selected item visually based on value. */
731
116
  _syncSelectedItem() {
732
- this.items.forEach((r) => {
733
- const e = r;
734
- e.selected = e.value === this.value;
117
+ this.items.forEach((e) => {
118
+ const t = e;
119
+ t.selected = t.value === this.value;
735
120
  });
736
121
  }
737
122
  /** Determines if dropdown should open upward or downward based on viewport space. */
738
123
  _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`;
124
+ var n, h;
125
+ const t = ((n = this.shadowRoot) == null ? void 0 : n.querySelector(".dropdown")).getBoundingClientRect(), i = t.top, o = window.innerHeight - t.bottom, s = o >= i ? "down" : "up";
126
+ this.setAttribute("data-open-direction", s);
127
+ const r = (h = this.shadowRoot) == null ? void 0 : h.querySelector(".menu");
128
+ if (r) {
129
+ const g = s === "down" ? o - 16 : i - 16;
130
+ r.style.maxHeight = `${g}px`;
746
131
  }
747
132
  }
748
133
  /** Focuses the currently active item (for keyboard nav). */
749
134
  _focusActiveItem() {
750
- var r, e;
135
+ var e, t;
751
136
  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();
137
+ const i = (t = (e = this.items[this.activeIndex]) == null ? void 0 : e.shadowRoot) == null ? void 0 : t.querySelector(".dropdown-item");
138
+ i == null || i.focus();
754
139
  }
755
140
  }
756
141
  /** Helper to remove the outside click handler and update _isOutsideClickListenerAttached at the same time. */
@@ -759,17 +144,17 @@ let p = class extends N {
759
144
  }
760
145
  // == Render ==
761
146
  render() {
762
- const r = {
147
+ const e = {
763
148
  disabled: this.disabled,
764
149
  error: this.error
765
150
  };
766
- return H`
151
+ return p`
767
152
  <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}
153
+ ${this.label ? p`
154
+ <form-label id="${this.inputId}-label" for="${this.inputId}" text="${this.label}" ?required="${this.required}" ?disabled="${this.disabled}"></form-label>` : u}
770
155
  <div class="dropdown">
771
- <div class="toggle ${De(r)}"
772
- aria-disabled="${this.disabled ? !0 : L}"
156
+ <div class="toggle ${y(e)}"
157
+ aria-disabled="${this.disabled ? !0 : u}"
773
158
  role="button"
774
159
  tabindex="${this.disabled ? "-1" : "0"}"
775
160
  @click="${this._toggleMenu}"
@@ -784,85 +169,85 @@ let p = class extends N {
784
169
  <slot></slot>
785
170
  </div>
786
171
  </div>
787
- ${this.error ? H`<form-error-message text="${this.errorText}"></form-error-message>` : L}
172
+ ${this.error ? p`<form-error-message text="${this.errorText}"></form-error-message>` : u}
788
173
  </div>
789
174
  `;
790
175
  }
791
176
  };
792
- p.styles = [
793
- N.styles,
794
- oe(Ne)
177
+ l.styles = [
178
+ m.styles,
179
+ v(_)
795
180
  ];
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;
181
+ l.formAssociated = !0;
182
+ d([
183
+ a({ type: String, attribute: "error-text" })
184
+ ], l.prototype, "errorText", 2);
185
+ d([
186
+ a({ type: String, attribute: "input-id" })
187
+ ], l.prototype, "inputId", 2);
188
+ d([
189
+ a({ type: String })
190
+ ], l.prototype, "label", 2);
191
+ d([
192
+ a({ type: String, reflect: !0 })
193
+ ], l.prototype, "name", 2);
194
+ d([
195
+ a({ type: String, attribute: "selected-label" })
196
+ ], l.prototype, "selectedLabel", 2);
197
+ d([
198
+ a({ type: Boolean, reflect: !0 })
199
+ ], l.prototype, "disabled", 2);
200
+ d([
201
+ a({ type: Boolean, reflect: !0 })
202
+ ], l.prototype, "error", 2);
203
+ d([
204
+ a({ type: Boolean, reflect: !0 })
205
+ ], l.prototype, "open", 2);
206
+ d([
207
+ a({ type: Boolean, reflect: !0 })
208
+ ], l.prototype, "required", 2);
209
+ d([
210
+ b()
211
+ ], l.prototype, "activeIndex", 2);
212
+ d([
213
+ b()
214
+ ], l.prototype, "_value", 2);
215
+ d([
216
+ x({ selector: "ucds-dropdown-item" })
217
+ ], l.prototype, "items", 2);
218
+ l = d([
219
+ w("ucds-dropdown")
220
+ ], l);
221
+ const L = ".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}";
222
+ var C = Object.defineProperty, O = Object.getOwnPropertyDescriptor, f = (e, t, i, o) => {
223
+ for (var s = o > 1 ? void 0 : o ? O(t, i) : t, r = e.length - 1, n; r >= 0; r--)
224
+ (n = e[r]) && (s = (o ? n(t, i, s) : n(s)) || s);
225
+ return o && s && C(t, i, s), s;
841
226
  };
842
- let I = class extends N {
227
+ let c = class extends m {
843
228
  constructor() {
844
229
  super(...arguments), this.value = "", this.selected = !1;
845
230
  }
846
231
  // == Private methods ==
847
232
  /** Called when the item is clicked or activated via keyboard. */
848
233
  _select() {
849
- var e;
850
- const r = (e = this.textContent) == null ? void 0 : e.trim();
234
+ var t;
235
+ const e = (t = this.textContent) == null ? void 0 : t.trim();
851
236
  this.selected = !0, this.dispatchEvent(new CustomEvent("dropdown-select", {
852
- detail: { value: this.value, selectedLabel: r },
237
+ detail: { value: this.value, selectedLabel: e },
853
238
  bubbles: !0,
854
239
  composed: !0
855
240
  }));
856
241
  }
857
242
  /** 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());
243
+ _handleKeydown(e) {
244
+ (e.key === "Enter" || e.key === "Tab" || e.key === "Esc") && (e.preventDefault(), this._select());
860
245
  }
861
246
  // == Render ==
862
247
  render() {
863
- return H`
248
+ return p`
864
249
  <div class="dropdown-item ${this.selected ? "selected" : ""}"
865
- aria-selected="${this.selected ? !0 : L}"
250
+ aria-selected="${this.selected ? !0 : u}"
866
251
  role="option"
867
252
  tabindex="-1"
868
253
  @click=${this._select}
@@ -874,20 +259,20 @@ let I = class extends N {
874
259
  `;
875
260
  }
876
261
  };
877
- I.styles = [
878
- N.styles,
879
- oe(Be)
262
+ c.styles = [
263
+ m.styles,
264
+ v(L)
880
265
  ];
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);
266
+ f([
267
+ a({ type: String })
268
+ ], c.prototype, "value", 2);
269
+ f([
270
+ a({ type: Boolean, reflect: !0 })
271
+ ], c.prototype, "selected", 2);
272
+ c = f([
273
+ w("ucds-dropdown-item")
274
+ ], c);
890
275
  export {
891
- p as Dropdown,
892
- I as DropdownItem
276
+ l as Dropdown,
277
+ c as DropdownItem
893
278
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucalgary-design-system/dropdown",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -10,11 +10,11 @@
10
10
  "require": "./index.js"
11
11
  }
12
12
  },
13
- "dependencies": {
14
- "@ucalgary-design-system/core": "^1.0.2",
13
+ "peerDependencies": {
14
+ "@ucalgary-design-system/core": "^1.0.4",
15
15
  "@ucalgary-design-system/helper-components": "^1.0.2",
16
- "@ucalgary-design-system/icon": "^1.0.2",
17
- "@ucalgary-design-system/tokens": "^1.0.3",
16
+ "@ucalgary-design-system/icon": "^1.0.4",
17
+ "@ucalgary-design-system/tokens": "^1.0.4",
18
18
  "lit": "^3.2.1"
19
19
  },
20
20
  "description": "A web component for Dropdown",