@phcdevworks/spectre-components 0.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +113 -40
  2. package/dist/base-2rD8EmdC.d.cts +32 -0
  3. package/dist/base-2rD8EmdC.d.ts +32 -0
  4. package/dist/button.cjs +295 -170
  5. package/dist/button.cjs.map +1 -1
  6. package/dist/button.d.cts +30 -61
  7. package/dist/button.d.ts +30 -61
  8. package/dist/button.js +296 -171
  9. package/dist/button.js.map +1 -1
  10. package/dist/checkbox.cjs +286 -71
  11. package/dist/checkbox.cjs.map +1 -1
  12. package/dist/checkbox.d.cts +38 -43
  13. package/dist/checkbox.d.ts +38 -43
  14. package/dist/checkbox.js +287 -72
  15. package/dist/checkbox.js.map +1 -1
  16. package/dist/fieldset.cjs +233 -88
  17. package/dist/fieldset.cjs.map +1 -1
  18. package/dist/fieldset.d.cts +23 -40
  19. package/dist/fieldset.d.ts +23 -40
  20. package/dist/fieldset.js +233 -88
  21. package/dist/fieldset.js.map +1 -1
  22. package/dist/form-iI7vV-3W.d.cts +6 -0
  23. package/dist/form-iI7vV-3W.d.ts +6 -0
  24. package/dist/index.cjs +564 -1029
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +5 -2
  27. package/dist/index.d.ts +5 -2
  28. package/dist/index.js +566 -1030
  29. package/dist/index.js.map +1 -1
  30. package/dist/input.cjs +232 -119
  31. package/dist/input.cjs.map +1 -1
  32. package/dist/input.d.cts +52 -68
  33. package/dist/input.d.ts +52 -68
  34. package/dist/input.js +232 -119
  35. package/dist/input.js.map +1 -1
  36. package/dist/label.cjs +232 -73
  37. package/dist/label.cjs.map +1 -1
  38. package/dist/label.d.cts +13 -22
  39. package/dist/label.d.ts +13 -22
  40. package/dist/label.js +232 -73
  41. package/dist/label.js.map +1 -1
  42. package/dist/projectable-BzDQ4xp_.d.cts +17 -0
  43. package/dist/projectable-s3SgvjGX.d.ts +17 -0
  44. package/dist/radio.cjs +286 -71
  45. package/dist/radio.cjs.map +1 -1
  46. package/dist/radio.d.cts +38 -43
  47. package/dist/radio.d.ts +38 -43
  48. package/dist/radio.js +287 -72
  49. package/dist/radio.js.map +1 -1
  50. package/dist/select.cjs +292 -163
  51. package/dist/select.cjs.map +1 -1
  52. package/dist/select.d.cts +35 -58
  53. package/dist/select.d.ts +35 -58
  54. package/dist/select.js +293 -163
  55. package/dist/select.js.map +1 -1
  56. package/dist/textarea.cjs +191 -290
  57. package/dist/textarea.cjs.map +1 -1
  58. package/dist/textarea.d.cts +41 -58
  59. package/dist/textarea.d.ts +41 -58
  60. package/dist/textarea.js +191 -290
  61. package/dist/textarea.js.map +1 -1
  62. package/package.json +13 -12
package/dist/select.js CHANGED
@@ -4,199 +4,331 @@ import { ifDefined } from 'lit/directives/if-defined.js';
4
4
  import { getInputClasses } from '@phcdevworks/spectre-ui';
5
5
 
6
6
  // src/components/select/sp-select.ts
7
- var spectreSelectSizes = ["sm", "md", "lg"];
8
- function isSelectSize(value) {
9
- return spectreSelectSizes.includes(value);
10
- }
11
- function isSelectableContent(node) {
12
- if (node.nodeType === Node.ELEMENT_NODE) {
13
- const tagName = node.tagName;
14
- return tagName === "OPTION" || tagName === "OPTGROUP";
15
- }
16
- if (node.nodeType === Node.TEXT_NODE) {
17
- return (node.textContent?.trim().length ?? 0) > 0;
18
- }
19
- return false;
20
- }
21
- var SpectreSelectElement = class extends LitElement {
7
+ var SpectreBaseElement = class extends LitElement {
22
8
  constructor() {
23
9
  super(...arguments);
24
- this.ariaLabel = null;
25
- this.ariaLabelledBy = null;
26
- this.ariaDescribedBy = null;
27
- this.autofocus = false;
28
- this.disabled = false;
29
- this.fullWidth = false;
30
- this.invalid = false;
31
- this.loading = false;
32
- this.pill = false;
33
- this.required = false;
34
- this.size = "md";
35
- this.success = false;
36
- this.title = "";
37
- this.value = "";
38
- this.projectedOptions = [];
10
+ this._ariaLabel = null;
11
+ this._ariaLabelledBy = null;
12
+ this._ariaDescribedBy = null;
13
+ this._title = "";
14
+ this._id = "";
15
+ }
16
+ get ariaLabel() {
17
+ return this._ariaLabel;
18
+ }
19
+ set ariaLabel(value) {
20
+ if (this._ariaLabel === value) {
21
+ return;
22
+ }
23
+ this._ariaLabel = value;
24
+ this._removeHostAttribute("aria-label");
25
+ this.requestUpdate();
26
+ }
27
+ get ariaLabelledBy() {
28
+ return this._ariaLabelledBy;
29
+ }
30
+ set ariaLabelledBy(value) {
31
+ if (this._ariaLabelledBy === value) {
32
+ return;
33
+ }
34
+ this._ariaLabelledBy = value;
35
+ this._removeHostAttribute("aria-labelledby");
36
+ this.requestUpdate();
37
+ }
38
+ get ariaDescribedBy() {
39
+ return this._ariaDescribedBy;
40
+ }
41
+ set ariaDescribedBy(value) {
42
+ if (this._ariaDescribedBy === value) {
43
+ return;
44
+ }
45
+ this._ariaDescribedBy = value;
46
+ this._removeHostAttribute("aria-describedby");
47
+ this.requestUpdate();
48
+ }
49
+ get title() {
50
+ return this._title;
51
+ }
52
+ set title(value) {
53
+ const normalizedValue = value ?? "";
54
+ if (this._title === normalizedValue) {
55
+ return;
56
+ }
57
+ this._title = normalizedValue;
58
+ this._removeHostAttribute("title");
59
+ this.requestUpdate();
39
60
  }
40
61
  get id() {
41
- return this._id ?? "";
62
+ return this._id;
42
63
  }
43
64
  set id(value) {
44
- if ((this._id ?? "") === value) {
65
+ const normalizedValue = value ?? "";
66
+ if (this._id === normalizedValue) {
45
67
  return;
46
68
  }
47
- this._id = value;
48
- const host = this;
49
- if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
50
- HTMLElement.prototype.removeAttribute.call(host, "id");
51
- }
69
+ this._id = normalizedValue;
70
+ this._removeHostAttribute("id");
52
71
  this.requestUpdate();
53
72
  }
73
+ // Spectre components intentionally render in light DOM so the global
74
+ // `@phcdevworks/spectre-ui` styling contract can apply directly.
54
75
  createRenderRoot() {
55
76
  return this;
56
77
  }
57
78
  connectedCallback() {
58
79
  super.connectedCallback();
59
- const hostId = super.getAttribute("id");
60
- if (hostId !== null) {
61
- this.id = hostId;
62
- }
63
- this.syncProjectedOptions();
64
- this.startContentObserver();
65
- }
66
- disconnectedCallback() {
67
- this.stopContentObserver();
68
- super.disconnectedCallback();
80
+ const proxiedAttributes = [
81
+ "id",
82
+ "title",
83
+ "aria-label",
84
+ "aria-labelledby",
85
+ "aria-describedby"
86
+ ];
87
+ proxiedAttributes.forEach((attr) => {
88
+ const value = super.getAttribute(attr);
89
+ if (value !== null) {
90
+ this.setAttribute(attr, value);
91
+ }
92
+ });
69
93
  }
70
94
  getAttribute(qualifiedName) {
71
- if (qualifiedName === "id") {
72
- return this.id || null;
95
+ switch (qualifiedName) {
96
+ case "id":
97
+ return this.id || null;
98
+ case "title":
99
+ return this.title || null;
100
+ case "aria-label":
101
+ return this.ariaLabel;
102
+ case "aria-labelledby":
103
+ return this.ariaLabelledBy;
104
+ case "aria-describedby":
105
+ return this.ariaDescribedBy;
106
+ default:
107
+ return super.getAttribute(qualifiedName);
73
108
  }
74
- return super.getAttribute(qualifiedName);
75
109
  }
76
110
  hasAttribute(qualifiedName) {
77
- if (qualifiedName === "id") {
78
- return this.id !== "";
111
+ switch (qualifiedName) {
112
+ case "id":
113
+ return this.id !== "";
114
+ case "title":
115
+ return this.title !== "";
116
+ case "aria-label":
117
+ return this.ariaLabel !== null;
118
+ case "aria-labelledby":
119
+ return this.ariaLabelledBy !== null;
120
+ case "aria-describedby":
121
+ return this.ariaDescribedBy !== null;
122
+ default:
123
+ return super.hasAttribute(qualifiedName);
79
124
  }
80
- return super.hasAttribute(qualifiedName);
81
125
  }
82
126
  setAttribute(qualifiedName, value) {
83
- if (qualifiedName === "id") {
84
- this.id = value;
85
- return;
127
+ switch (qualifiedName) {
128
+ case "id":
129
+ this.id = value;
130
+ break;
131
+ case "title":
132
+ this.title = value;
133
+ break;
134
+ case "aria-label":
135
+ this.ariaLabel = value;
136
+ break;
137
+ case "aria-labelledby":
138
+ this.ariaLabelledBy = value;
139
+ break;
140
+ case "aria-describedby":
141
+ this.ariaDescribedBy = value;
142
+ break;
143
+ default:
144
+ super.setAttribute(qualifiedName, value);
86
145
  }
87
- super.setAttribute(qualifiedName, value);
88
146
  }
89
147
  removeAttribute(qualifiedName) {
90
- if (qualifiedName === "id") {
91
- this.id = "";
92
- return;
148
+ switch (qualifiedName) {
149
+ case "id":
150
+ this.id = "";
151
+ break;
152
+ case "title":
153
+ this.title = "";
154
+ break;
155
+ case "aria-label":
156
+ this.ariaLabel = null;
157
+ break;
158
+ case "aria-labelledby":
159
+ this.ariaLabelledBy = null;
160
+ break;
161
+ case "aria-describedby":
162
+ this.ariaDescribedBy = null;
163
+ break;
164
+ default:
165
+ super.removeAttribute(qualifiedName);
93
166
  }
94
- super.removeAttribute(qualifiedName);
95
167
  }
96
- willUpdate(changedProperties) {
97
- if (changedProperties.has("size") && !isSelectSize(this.size)) {
98
- this.size = "md";
99
- }
100
- if (changedProperties.has("value") && this.value == null) {
101
- this.value = "";
168
+ _removeHostAttribute(name) {
169
+ const host = this;
170
+ if (HTMLElement.prototype.hasAttribute.call(host, name)) {
171
+ HTMLElement.prototype.removeAttribute.call(host, name);
102
172
  }
103
173
  }
104
- update(changedProperties) {
105
- this.stopContentObserver();
106
- super.update(changedProperties);
107
- this.startContentObserver();
174
+ get forwardedAriaLabel() {
175
+ const value = this.ariaLabel?.trim();
176
+ return value ? value : void 0;
108
177
  }
109
- updated(changedProperties) {
110
- super.updated(changedProperties);
111
- const nativeSelect = this.nativeSelect;
112
- if (!nativeSelect) {
113
- return;
114
- }
115
- if (this.value !== "" && nativeSelect.value !== this.value) {
116
- nativeSelect.value = this.value;
117
- return;
178
+ get forwardedAriaLabelledBy() {
179
+ const value = this.ariaLabelledBy?.trim();
180
+ return value ? value : void 0;
181
+ }
182
+ get forwardedAriaDescribedBy() {
183
+ const value = this.ariaDescribedBy?.trim();
184
+ return value ? value : void 0;
185
+ }
186
+ };
187
+ SpectreBaseElement.properties = {};
188
+
189
+ // src/utils/dom.ts
190
+ function hasMeaningfulContent(nodes) {
191
+ return nodes.some((node) => {
192
+ if (node.nodeType === Node.ELEMENT_NODE) {
193
+ return true;
118
194
  }
119
- if (this.value === "" && !this.hasAttribute("value")) {
120
- const nativeValue = nativeSelect.value ?? "";
121
- if (nativeValue !== "") {
122
- this.value = nativeValue;
123
- }
195
+ if (node.nodeType === Node.TEXT_NODE) {
196
+ return (node.textContent?.trim().length ?? 0) > 0;
124
197
  }
198
+ return false;
199
+ });
200
+ }
201
+
202
+ // src/utils/projectable.ts
203
+ var SpectreProjectableElement = class extends SpectreBaseElement {
204
+ constructor() {
205
+ super(...arguments);
206
+ this.projectedContent = [];
125
207
  }
126
- get selectClasses() {
127
- return getInputClasses({
128
- fullWidth: this.fullWidth,
129
- pill: this.pill,
130
- size: this.size,
131
- state: this.isDisabled ? this.disabled ? "disabled" : "loading" : this.invalid ? "error" : this.success ? "success" : "default"
132
- });
133
- }
134
- get isDisabled() {
135
- return this.disabled || this.loading;
208
+ get hasProjectedContent() {
209
+ return hasMeaningfulContent(this.projectedContent);
136
210
  }
137
- get nativeSelect() {
138
- return this.querySelector("[data-sp-select-native]");
211
+ connectedCallback() {
212
+ super.connectedCallback();
213
+ this.syncProjectedContent();
214
+ this.startContentObserver();
139
215
  }
140
- get forwardedAriaLabel() {
141
- const ariaLabel = this.ariaLabel?.trim();
142
- return ariaLabel ? ariaLabel : void 0;
216
+ disconnectedCallback() {
217
+ this.stopContentObserver();
218
+ super.disconnectedCallback();
143
219
  }
144
- get forwardedAriaLabelledBy() {
145
- const ariaLabelledBy = this.ariaLabelledBy?.trim();
146
- return ariaLabelledBy ? ariaLabelledBy : void 0;
220
+ update(changedProperties) {
221
+ this.stopContentObserver();
222
+ super.update(changedProperties);
223
+ this.startContentObserver();
147
224
  }
148
- get forwardedAriaDescribedBy() {
149
- const ariaDescribedBy = this.ariaDescribedBy?.trim();
150
- return ariaDescribedBy ? ariaDescribedBy : void 0;
225
+ syncProjectedContent() {
226
+ const nextProjectedContent = [];
227
+ const sourceNodes = [
228
+ ...this.childNodes,
229
+ ...this.getContentContainer()?.childNodes ?? []
230
+ ];
231
+ sourceNodes.forEach((node) => {
232
+ if (!this.isInternalNode(node) && !nextProjectedContent.includes(node)) {
233
+ nextProjectedContent.push(node);
234
+ }
235
+ });
236
+ const hasChanged = nextProjectedContent.length !== this.projectedContent.length || nextProjectedContent.some((node, index) => node !== this.projectedContent[index]);
237
+ if (hasChanged) {
238
+ this.projectedContent = nextProjectedContent;
239
+ }
240
+ return hasChanged;
151
241
  }
152
242
  startContentObserver() {
153
243
  if (this.contentObserver) {
154
244
  return;
155
245
  }
156
246
  this.contentObserver = new MutationObserver((mutations) => {
157
- const isInternalMovement = mutations.every((mutation) => {
158
- return Array.from(mutation.removedNodes).every(
159
- (node) => this.isInternalSelectNode(node) || this.contains(node)
160
- ) && Array.from(mutation.addedNodes).every((node) => this.isInternalSelectNode(node));
161
- });
247
+ const isInternalMovement = mutations.every(
248
+ (mutation) => [...mutation.removedNodes].every(
249
+ (node) => this.isInternalNode(node) || this.contains(node)
250
+ ) && [...mutation.addedNodes].every((node) => this.isInternalNode(node))
251
+ );
162
252
  if (isInternalMovement) {
163
253
  return;
164
254
  }
165
- if (this.syncProjectedOptions()) {
255
+ if (this.syncProjectedContent()) {
166
256
  this.requestUpdate();
167
257
  }
168
258
  });
169
- this.contentObserver.observe(this, {
170
- childList: true
171
- });
259
+ this.contentObserver.observe(this, { childList: true });
172
260
  }
173
261
  stopContentObserver() {
174
262
  this.contentObserver?.disconnect();
175
263
  this.contentObserver = void 0;
176
264
  }
177
- syncProjectedOptions() {
178
- const nextProjectedOptions = [];
179
- Array.from(this.childNodes).forEach((node) => {
180
- if (this.isInternalSelectNode(node)) {
181
- this.projectedOptions.forEach((projectedNode) => {
182
- if (projectedNode.parentNode !== this && this.contains(projectedNode)) {
183
- nextProjectedOptions.push(projectedNode);
265
+ };
266
+ var spectreInputSizes = ["sm", "md", "lg"];
267
+ function isInputSize(value) {
268
+ return spectreInputSizes.includes(value);
269
+ }
270
+ var SpectreSelectElement = class extends SpectreProjectableElement {
271
+ constructor() {
272
+ super(...arguments);
273
+ this.autofocus = false;
274
+ this.disabled = false;
275
+ this.fullWidth = false;
276
+ this.invalid = false;
277
+ this.loading = false;
278
+ this.pill = false;
279
+ this.required = false;
280
+ this.size = "md";
281
+ this.success = false;
282
+ this.value = "";
283
+ }
284
+ getContentContainer() {
285
+ return this.querySelector("[data-sp-select-native]");
286
+ }
287
+ isInternalNode(node) {
288
+ if (node.nodeType !== Node.ELEMENT_NODE) {
289
+ return false;
290
+ }
291
+ const el = node;
292
+ return el.hasAttribute("data-sp-select-native");
293
+ }
294
+ willUpdate(changedProperties) {
295
+ if (changedProperties.has("size") && !isInputSize(this.size)) {
296
+ this.size = "md";
297
+ }
298
+ if (changedProperties.has("value") && this.value == null) {
299
+ this.value = "";
300
+ }
301
+ }
302
+ updated(changedProperties) {
303
+ super.updated(changedProperties);
304
+ const nativeSelect = this.getContentContainer();
305
+ if (!nativeSelect) {
306
+ return;
307
+ }
308
+ if (this.value !== "" && nativeSelect.value !== this.value) {
309
+ nativeSelect.value = this.value;
310
+ }
311
+ if (this.value === "" && !this.hasAttribute("value")) {
312
+ const nativeValue = nativeSelect.value ?? "";
313
+ if (nativeValue !== "" && nativeValue !== this.value) {
314
+ this.updateComplete.then(() => {
315
+ if (this.value === "" && !this.hasAttribute("value")) {
316
+ this.value = nativeValue;
184
317
  }
185
318
  });
186
- return;
187
319
  }
188
- if (isSelectableContent(node)) {
189
- nextProjectedOptions.push(node);
190
- }
191
- });
192
- const hasChanged = nextProjectedOptions.length !== this.projectedOptions.length || nextProjectedOptions.some((node, index) => node !== this.projectedOptions[index]);
193
- if (hasChanged) {
194
- this.projectedOptions = nextProjectedOptions;
195
320
  }
196
- return hasChanged;
197
321
  }
198
- isInternalSelectNode(node) {
199
- return node.nodeType === Node.ELEMENT_NODE && node.hasAttribute("data-sp-select-native");
322
+ get selectClasses() {
323
+ return getInputClasses({
324
+ fullWidth: this.fullWidth,
325
+ pill: this.pill,
326
+ size: this.size,
327
+ state: this.isDisabled ? this.disabled ? "disabled" : "loading" : this.invalid ? "error" : this.success ? "success" : "default"
328
+ });
329
+ }
330
+ get isDisabled() {
331
+ return this.disabled || this.loading;
200
332
  }
201
333
  handleInput(event) {
202
334
  const select = event.currentTarget;
@@ -207,51 +339,49 @@ var SpectreSelectElement = class extends LitElement {
207
339
  this.value = select.value;
208
340
  }
209
341
  focus(options) {
210
- this.nativeSelect?.focus(options);
342
+ this.getContentContainer()?.focus(options);
211
343
  }
212
344
  blur() {
213
- this.nativeSelect?.blur();
345
+ this.getContentContainer()?.blur();
214
346
  }
215
347
  render() {
216
- return html`
217
- <select
218
- aria-busy=${this.loading ? "true" : "false"}
219
- aria-describedby=${ifDefined(this.forwardedAriaDescribedBy)}
220
- aria-invalid=${ifDefined(this.invalid ? "true" : void 0)}
221
- aria-label=${ifDefined(this.forwardedAriaLabel)}
222
- aria-labelledby=${ifDefined(this.forwardedAriaLabelledBy)}
223
- ?autofocus=${this.autofocus}
224
- class=${this.selectClasses}
225
- data-sp-select-native
226
- ?disabled=${this.isDisabled}
227
- id=${ifDefined(this.id || void 0)}
228
- name=${ifDefined(this.name)}
229
- ?required=${this.required}
230
- title=${ifDefined(this.title || void 0)}
231
- .value=${live(this.value)}
232
- @change=${this.handleChange}
233
- @input=${this.handleInput}
234
- >
235
- ${this.projectedOptions.length > 0 ? this.projectedOptions : nothing}
236
- </select>
237
- `;
348
+ return html`<select
349
+ aria-busy="${this.loading ? "true" : "false"}"
350
+ aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
351
+ aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
352
+ aria-label="${ifDefined(this.forwardedAriaLabel)}"
353
+ aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
354
+ autocomplete="${ifDefined(this.autocomplete || void 0)}"
355
+ ?autofocus="${this.autofocus}"
356
+ class="${this.selectClasses}"
357
+ data-sp-select-native
358
+ ?disabled="${this.isDisabled}"
359
+ form="${ifDefined(this.form || void 0)}"
360
+ id="${ifDefined(this.id || void 0)}"
361
+ name="${ifDefined(this.name || void 0)}"
362
+ ?required="${this.required}"
363
+ title="${ifDefined(this.title || void 0)}"
364
+ .value="${live(this.value)}"
365
+ @change="${this.handleChange}"
366
+ @input="${this.handleInput}"
367
+ >
368
+ ${this.hasProjectedContent ? this.projectedContent : nothing}
369
+ </select>`;
238
370
  }
239
371
  };
240
372
  SpectreSelectElement.properties = {
241
- ariaLabel: { attribute: "aria-label", type: String },
242
- ariaLabelledBy: { attribute: "aria-labelledby", type: String },
243
- ariaDescribedBy: { attribute: "aria-describedby", type: String },
373
+ autocomplete: { type: String, reflect: true },
244
374
  autofocus: { type: Boolean, reflect: true },
245
375
  disabled: { type: Boolean, reflect: true },
376
+ form: { type: String },
246
377
  fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
247
378
  invalid: { type: Boolean, reflect: true },
248
379
  loading: { type: Boolean, reflect: true },
249
- name: { type: String },
380
+ name: { type: String, reflect: true },
250
381
  pill: { type: Boolean, reflect: true },
251
382
  required: { type: Boolean, reflect: true },
252
383
  size: { type: String, reflect: true },
253
384
  success: { type: Boolean, reflect: true },
254
- title: { type: String, reflect: true },
255
385
  value: { type: String }
256
386
  };
257
387
  function defineSpectreSelect(tagName = "sp-select") {
@@ -263,6 +393,6 @@ function defineSpectreSelect(tagName = "sp-select") {
263
393
  return SpectreSelectElement;
264
394
  }
265
395
 
266
- export { SpectreSelectElement, defineSpectreSelect, spectreSelectSizes };
396
+ export { SpectreSelectElement, defineSpectreSelect };
267
397
  //# sourceMappingURL=select.js.map
268
398
  //# sourceMappingURL=select.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/select/sp-select.ts"],"names":[],"mappings":";;;;;;AASO,IAAM,kBAAA,GAAqB,CAAC,IAAA,EAAM,IAAA,EAAM,IAAI;AAmBnD,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AAI,OAAO,CAAA;AAElD,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,cAAA,CAAe,MAAA,CAAO,SAAS,oBAAoB,CAAA;AACnD,EAAA,OAAO,oBAAA;AACT","file":"select.js","sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { live } from 'lit/directives/live.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport {\n getInputClasses,\n type InputSize,\n} from '@phcdevworks/spectre-ui';\n\nexport const spectreSelectSizes = ['sm', 'md', 'lg'] as const;\n\nexport type SpectreSelectSize = (typeof spectreSelectSizes)[number];\n\nexport interface SpectreSelectProps {\n autofocus?: boolean;\n disabled?: boolean;\n fullWidth?: boolean;\n invalid?: boolean;\n loading?: boolean;\n name?: string;\n pill?: boolean;\n required?: boolean;\n size?: SpectreSelectSize;\n success?: boolean;\n title?: string;\n value?: string;\n}\n\nfunction isSelectSize(value: string): value is InputSize {\n return (spectreSelectSizes as readonly string[]).includes(value);\n}\n\nfunction isSelectableContent(node: Node): boolean {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const tagName = (node as Element).tagName;\n return tagName === 'OPTION' || tagName === 'OPTGROUP';\n }\n\n if (node.nodeType === Node.TEXT_NODE) {\n return (node.textContent?.trim().length ?? 0) > 0;\n }\n\n return false;\n}\n\nexport class SpectreSelectElement extends LitElement implements SpectreSelectProps {\n static properties = {\n ariaLabel: { attribute: 'aria-label', type: String },\n ariaLabelledBy: { attribute: 'aria-labelledby', type: String },\n ariaDescribedBy: { attribute: 'aria-describedby', type: String },\n autofocus: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n fullWidth: { attribute: 'full-width', type: Boolean, reflect: true },\n invalid: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n name: { type: String },\n pill: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n success: { type: Boolean, reflect: true },\n title: { type: String, reflect: true },\n value: { type: String },\n };\n\n ariaLabel: string | null = null;\n ariaLabelledBy: string | null = null;\n ariaDescribedBy: string | null = null;\n autofocus = false;\n disabled = false;\n fullWidth = false;\n invalid = false;\n loading = false;\n name?: string;\n pill = false;\n required = false;\n size: SpectreSelectSize = 'md';\n success = false;\n override title = '';\n value = '';\n private _id?: string;\n private projectedOptions: Node[] = [];\n private contentObserver?: MutationObserver | undefined;\n\n override get id(): string {\n return this._id ?? '';\n }\n\n override set id(value: string) {\n if ((this._id ?? '') === value) {\n return;\n }\n\n this._id = value;\n\n const host = this as unknown as HTMLElement;\n if (HTMLElement.prototype.hasAttribute.call(host, 'id')) {\n HTMLElement.prototype.removeAttribute.call(host, 'id');\n }\n\n this.requestUpdate();\n }\n\n createRenderRoot(): this {\n // Spectre components intentionally render in light DOM so the global\n // Spectre UI styling contract can apply directly.\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n\n const hostId = super.getAttribute('id');\n\n if (hostId !== null) {\n this.id = hostId;\n }\n\n this.syncProjectedOptions();\n this.startContentObserver();\n }\n\n override disconnectedCallback(): void {\n this.stopContentObserver();\n super.disconnectedCallback();\n }\n\n override getAttribute(qualifiedName: string): string | null {\n if (qualifiedName === 'id') {\n return this.id || null;\n }\n\n return super.getAttribute(qualifiedName);\n }\n\n override hasAttribute(qualifiedName: string): boolean {\n if (qualifiedName === 'id') {\n return this.id !== '';\n }\n\n return super.hasAttribute(qualifiedName);\n }\n\n override setAttribute(qualifiedName: string, value: string): void {\n if (qualifiedName === 'id') {\n this.id = value;\n return;\n }\n\n super.setAttribute(qualifiedName, value);\n }\n\n override removeAttribute(qualifiedName: string): void {\n if (qualifiedName === 'id') {\n this.id = '';\n return;\n }\n\n super.removeAttribute(qualifiedName);\n }\n\n protected override willUpdate(changedProperties: Map<PropertyKey, unknown>): void {\n if (changedProperties.has('size') && !isSelectSize(this.size)) {\n this.size = 'md';\n }\n\n if (changedProperties.has('value') && this.value == null) {\n this.value = '';\n }\n\n }\n\n protected override update(changedProperties: Map<PropertyKey, unknown>): void {\n this.stopContentObserver();\n super.update(changedProperties);\n this.startContentObserver();\n }\n\n protected override updated(changedProperties: Map<PropertyKey, unknown>): void {\n super.updated(changedProperties);\n\n const nativeSelect = this.nativeSelect;\n if (!nativeSelect) {\n return;\n }\n\n if (this.value !== '' && nativeSelect.value !== this.value) {\n nativeSelect.value = this.value;\n return;\n }\n\n if (this.value === '' && !this.hasAttribute('value')) {\n const nativeValue = nativeSelect.value ?? '';\n if (nativeValue !== '') {\n this.value = nativeValue;\n }\n }\n }\n\n private get selectClasses(): string {\n return getInputClasses({\n fullWidth: this.fullWidth,\n pill: this.pill,\n size: this.size,\n state: this.isDisabled\n ? this.disabled\n ? 'disabled'\n : 'loading'\n : this.invalid\n ? 'error'\n : this.success\n ? 'success'\n : 'default',\n });\n }\n\n private get isDisabled(): boolean {\n return this.disabled || this.loading;\n }\n\n private get nativeSelect(): HTMLSelectElement | null {\n return this.querySelector('[data-sp-select-native]');\n }\n\n private get forwardedAriaLabel(): string | undefined {\n const ariaLabel = this.ariaLabel?.trim();\n return ariaLabel ? ariaLabel : undefined;\n }\n\n private get forwardedAriaLabelledBy(): string | undefined {\n const ariaLabelledBy = this.ariaLabelledBy?.trim();\n return ariaLabelledBy ? ariaLabelledBy : undefined;\n }\n\n private get forwardedAriaDescribedBy(): string | undefined {\n const ariaDescribedBy = this.ariaDescribedBy?.trim();\n return ariaDescribedBy ? ariaDescribedBy : undefined;\n }\n\n private startContentObserver(): void {\n if (this.contentObserver) {\n return;\n }\n\n this.contentObserver = new MutationObserver((mutations) => {\n const isInternalMovement = mutations.every((mutation) => {\n return (\n Array.from(mutation.removedNodes).every(\n (node) => this.isInternalSelectNode(node) || this.contains(node),\n ) &&\n Array.from(mutation.addedNodes).every((node) => this.isInternalSelectNode(node))\n );\n });\n\n if (isInternalMovement) {\n return;\n }\n\n if (this.syncProjectedOptions()) {\n this.requestUpdate();\n }\n });\n\n this.contentObserver.observe(this, {\n childList: true,\n });\n }\n\n private stopContentObserver(): void {\n this.contentObserver?.disconnect();\n this.contentObserver = undefined;\n }\n\n private syncProjectedOptions(): boolean {\n const nextProjectedOptions: Node[] = [];\n\n Array.from(this.childNodes).forEach((node) => {\n if (this.isInternalSelectNode(node)) {\n this.projectedOptions.forEach((projectedNode) => {\n if (projectedNode.parentNode !== this && this.contains(projectedNode)) {\n nextProjectedOptions.push(projectedNode);\n }\n });\n return;\n }\n\n if (isSelectableContent(node)) {\n nextProjectedOptions.push(node);\n }\n });\n\n const hasChanged =\n nextProjectedOptions.length !== this.projectedOptions.length ||\n nextProjectedOptions.some((node, index) => node !== this.projectedOptions[index]);\n\n if (hasChanged) {\n this.projectedOptions = nextProjectedOptions;\n }\n\n return hasChanged;\n }\n\n private isInternalSelectNode(node: Node): boolean {\n return (\n node.nodeType === Node.ELEMENT_NODE && (node as Element).hasAttribute('data-sp-select-native')\n );\n }\n\n private handleInput(event: Event): void {\n const select = event.currentTarget as HTMLSelectElement;\n this.value = select.value;\n }\n\n private handleChange(event: Event): void {\n const select = event.currentTarget as HTMLSelectElement;\n this.value = select.value;\n }\n\n override focus(options?: FocusOptions): void {\n this.nativeSelect?.focus(options);\n }\n\n override blur(): void {\n this.nativeSelect?.blur();\n }\n\n\n override render() {\n return html`\n <select\n aria-busy=${this.loading ? 'true' : 'false'}\n aria-describedby=${ifDefined(this.forwardedAriaDescribedBy)}\n aria-invalid=${ifDefined(this.invalid ? 'true' : undefined)}\n aria-label=${ifDefined(this.forwardedAriaLabel)}\n aria-labelledby=${ifDefined(this.forwardedAriaLabelledBy)}\n ?autofocus=${this.autofocus}\n class=${this.selectClasses}\n data-sp-select-native\n ?disabled=${this.isDisabled}\n id=${ifDefined(this.id || undefined)}\n name=${ifDefined(this.name)}\n ?required=${this.required}\n title=${ifDefined(this.title || undefined)}\n .value=${live(this.value)}\n @change=${this.handleChange}\n @input=${this.handleInput}\n >\n ${this.projectedOptions.length > 0 ? this.projectedOptions : nothing}\n </select>\n `;\n }\n}\n\nexport function defineSpectreSelect(tagName = 'sp-select'): typeof SpectreSelectElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreSelectElement;\n }\n\n customElements.define(tagName, SpectreSelectElement);\n return SpectreSelectElement;\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/base.ts","../src/utils/dom.ts","../src/utils/projectable.ts","../src/utils/form.ts","../src/components/select/sp-select.ts"],"names":[],"mappings":";;;;;;AAEO,IAAM,kBAAA,GAAN,cAAiC,UAAA,CAAW;AAAA,EAA5C,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAGL,IAAA,IAAA,CAAQ,UAAA,GAA4B,IAAA;AACpC,IAAA,IAAA,CAAQ,eAAA,GAAiC,IAAA;AACzC,IAAA,IAAA,CAAQ,gBAAA,GAAkC,IAAA;AAC1C,IAAA,IAAA,CAAQ,MAAA,GAAS,EAAA;AACjB,IAAA,IAAA,CAAQ,GAAA,GAAM,EAAA;AAAA,EAAA;AAAA,EAEd,IAAI,SAAA,GAA2B;AAC7B,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EACd;AAAA,EAEA,IAAI,UAAU,KAAA,EAAsB;AAClC,IAAA,IAAI,IAAA,CAAK,eAAe,KAAA,EAAO;AAC7B,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,UAAA,GAAa,KAAA;AAClB,IAAA,IAAA,CAAK,qBAAqB,YAAY,CAAA;AACtC,IAAA,IAAA,CAAK,aAAA,EAAc;AAAA,EACrB;AAAA,EAEA,IAAI,cAAA,GAAgC;AAClC,IAAA,OAAO,IAAA,CAAK,eAAA;AAAA,EACd;AAAA,EAEA,IAAI,eAAe,KAAA,EAAsB;AACvC,IAAA,IAAI,IAAA,CAAK,oBAAoB,KAAA,EAAO;AAClC,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,eAAA,GAAkB,KAAA;AACvB,IAAA,IAAA,CAAK,qBAAqB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AAS,IAAA,EAAK;AAAA,EACpC,OAAA,EAAS,EAAE,IAAA,EAAM,OAAA,EAAS,SAAS,IAAA,EAAK;AAAA,EACxC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA;AACjB,CAAA;AAgIK,SAAS,mBAAA,CAAoB,UAAU,WAAA,EAA0C;AACtF,EAAA,MAAM,eAAA,GAAkB,cAAA,CAAe,GAAA,CAAI,OAAO,CAAA;AAElD,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,cAAA,CAAe,MAAA,CAAO,SAAS,oBAAoB,CAAA;AACnD,EAAA,OAAO,oBAAA;AACT","file":"select.js","sourcesContent":["import { LitElement, type PropertyDeclarations } from 'lit';\n\nexport class SpectreBaseElement extends LitElement {\n static properties: PropertyDeclarations = {};\n\n private _ariaLabel: string | null = null;\n private _ariaLabelledBy: string | null = null;\n private _ariaDescribedBy: string | null = null;\n private _title = '';\n private _id = '';\n\n get ariaLabel(): string | null {\n return this._ariaLabel;\n }\n\n set ariaLabel(value: string | null) {\n if (this._ariaLabel === value) {\n return;\n }\n this._ariaLabel = value;\n this._removeHostAttribute('aria-label');\n this.requestUpdate();\n }\n\n get ariaLabelledBy(): string | null {\n return this._ariaLabelledBy;\n }\n\n set ariaLabelledBy(value: string | null) {\n if (this._ariaLabelledBy === value) {\n return;\n }\n this._ariaLabelledBy = value;\n this._removeHostAttribute('aria-labelledby');\n this.requestUpdate();\n }\n\n get ariaDescribedBy(): string | null {\n return this._ariaDescribedBy;\n }\n\n set ariaDescribedBy(value: string | null) {\n if (this._ariaDescribedBy === value) {\n return;\n }\n this._ariaDescribedBy = value;\n this._removeHostAttribute('aria-describedby');\n this.requestUpdate();\n }\n\n override get title(): string {\n return this._title;\n }\n\n override set title(value: string | undefined | null) {\n const normalizedValue = value ?? '';\n if (this._title === normalizedValue) {\n return;\n }\n this._title = normalizedValue;\n this._removeHostAttribute('title');\n this.requestUpdate();\n }\n\n override get id(): string {\n return this._id;\n }\n\n override set id(value: string | undefined | null) {\n const normalizedValue = value ?? '';\n if (this._id === normalizedValue) {\n return;\n }\n this._id = normalizedValue;\n this._removeHostAttribute('id');\n this.requestUpdate();\n }\n\n // Spectre components intentionally render in light DOM so the global\n // `@phcdevworks/spectre-ui` styling contract can apply directly.\n createRenderRoot(): this {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n\n const proxiedAttributes = [\n 'id',\n 'title',\n 'aria-label',\n 'aria-labelledby',\n 'aria-describedby',\n ];\n\n proxiedAttributes.forEach((attr) => {\n const value = super.getAttribute(attr);\n if (value !== null) {\n this.setAttribute(attr, value);\n }\n });\n }\n\n override getAttribute(qualifiedName: string): string | null {\n switch (qualifiedName) {\n case 'id':\n return this.id || null;\n case 'title':\n return this.title || null;\n case 'aria-label':\n return this.ariaLabel;\n case 'aria-labelledby':\n return this.ariaLabelledBy;\n case 'aria-describedby':\n return this.ariaDescribedBy;\n default:\n return super.getAttribute(qualifiedName);\n }\n }\n\n override hasAttribute(qualifiedName: string): boolean {\n switch (qualifiedName) {\n case 'id':\n return this.id !== '';\n case 'title':\n return this.title !== '';\n case 'aria-label':\n return this.ariaLabel !== null;\n case 'aria-labelledby':\n return this.ariaLabelledBy !== null;\n case 'aria-describedby':\n return this.ariaDescribedBy !== null;\n default:\n return super.hasAttribute(qualifiedName);\n }\n }\n\n override setAttribute(qualifiedName: string, value: string): void {\n switch (qualifiedName) {\n case 'id':\n this.id = value;\n break;\n case 'title':\n this.title = value;\n break;\n case 'aria-label':\n this.ariaLabel = value;\n break;\n case 'aria-labelledby':\n this.ariaLabelledBy = value;\n break;\n case 'aria-describedby':\n this.ariaDescribedBy = value;\n break;\n default:\n super.setAttribute(qualifiedName, value);\n }\n }\n\n override removeAttribute(qualifiedName: string): void {\n switch (qualifiedName) {\n case 'id':\n this.id = '';\n break;\n case 'title':\n this.title = '';\n break;\n case 'aria-label':\n this.ariaLabel = null;\n break;\n case 'aria-labelledby':\n this.ariaLabelledBy = null;\n break;\n case 'aria-describedby':\n this.ariaDescribedBy = null;\n break;\n default:\n super.removeAttribute(qualifiedName);\n }\n }\n\n private _removeHostAttribute(name: string): void {\n const host = this as unknown as HTMLElement;\n if (HTMLElement.prototype.hasAttribute.call(host, name)) {\n HTMLElement.prototype.removeAttribute.call(host, name);\n }\n }\n\n protected get forwardedAriaLabel(): string | undefined {\n const value = this.ariaLabel?.trim();\n return value ? value : undefined;\n }\n\n protected get forwardedAriaLabelledBy(): string | undefined {\n const value = this.ariaLabelledBy?.trim();\n return value ? value : undefined;\n }\n\n protected get forwardedAriaDescribedBy(): string | undefined {\n const value = this.ariaDescribedBy?.trim();\n return value ? value : undefined;\n }\n}\n","export function hasMeaningfulContent(nodes: readonly Node[]): boolean {\n return nodes.some((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n return true;\n }\n\n if (node.nodeType === Node.TEXT_NODE) {\n return (node.textContent?.trim().length ?? 0) > 0;\n }\n\n return false;\n });\n}\n","import { SpectreBaseElement } from './base';\nimport { hasMeaningfulContent } from './dom';\n\nexport abstract class SpectreProjectableElement extends SpectreBaseElement {\n protected projectedContent: Node[] = [];\n private contentObserver?: MutationObserver | undefined;\n\n // Return the native container whose existing children are also treated as\n // projected content sources (e.g. the rendered <button>, <select>, <label>).\n protected abstract getContentContainer(): Element | null;\n\n // Return true if the node was rendered by this component and should not be\n // treated as external projected content.\n protected abstract isInternalNode(node: Node): boolean;\n\n protected get hasProjectedContent(): boolean {\n return hasMeaningfulContent(this.projectedContent);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.syncProjectedContent();\n this.startContentObserver();\n }\n\n override disconnectedCallback(): void {\n this.stopContentObserver();\n super.disconnectedCallback();\n }\n\n protected override update(changedProperties: Map<PropertyKey, unknown>): void {\n this.stopContentObserver();\n super.update(changedProperties);\n this.startContentObserver();\n }\n\n protected syncProjectedContent(): boolean {\n const nextProjectedContent: Node[] = [];\n const sourceNodes = [\n ...this.childNodes,\n ...(this.getContentContainer()?.childNodes ?? []),\n ];\n\n sourceNodes.forEach((node) => {\n if (!this.isInternalNode(node) && !nextProjectedContent.includes(node)) {\n nextProjectedContent.push(node);\n }\n });\n\n const hasChanged =\n nextProjectedContent.length !== this.projectedContent.length ||\n nextProjectedContent.some((node, index) => node !== this.projectedContent[index]);\n\n if (hasChanged) {\n this.projectedContent = nextProjectedContent;\n }\n\n return hasChanged;\n }\n\n private startContentObserver(): void {\n if (this.contentObserver) {\n return;\n }\n\n this.contentObserver = new MutationObserver((mutations) => {\n const isInternalMovement = mutations.every((mutation) =>\n [...mutation.removedNodes].every(\n (node) => this.isInternalNode(node) || this.contains(node),\n ) &&\n [...mutation.addedNodes].every((node) => this.isInternalNode(node)),\n );\n\n if (isInternalMovement) {\n return;\n }\n\n if (this.syncProjectedContent()) {\n this.requestUpdate();\n }\n });\n\n this.contentObserver.observe(this, { childList: true });\n }\n\n private stopContentObserver(): void {\n this.contentObserver?.disconnect();\n this.contentObserver = undefined;\n }\n}\n","import { type InputSize } from '@phcdevworks/spectre-ui';\n\nexport const spectreInputSizes = ['sm', 'md', 'lg'] as const;\nexport type SpectreInputSize = (typeof spectreInputSizes)[number];\n\nexport function isInputSize(value: unknown): value is InputSize {\n return (spectreInputSizes as readonly string[]).includes(value as string);\n}\n\nexport const spectreInputTypes = [\n 'text',\n 'email',\n 'password',\n 'search',\n 'tel',\n 'url',\n 'number',\n 'date',\n 'datetime-local',\n 'month',\n 'time',\n 'week',\n] as const;\n\nexport type SpectreInputType = (typeof spectreInputTypes)[number];\n\nexport function isInputType(value: unknown): value is SpectreInputType {\n return (spectreInputTypes as readonly string[]).includes(value as string);\n}\n\nexport function normalizeInt(\n value: unknown,\n fallback: number | undefined,\n min = 0,\n): number | undefined {\n if (\n value == null ||\n typeof value !== 'number' ||\n !Number.isInteger(value) ||\n value < min\n ) {\n return fallback;\n }\n return value;\n}\n","import { html, nothing } from 'lit';\nimport { live } from 'lit/directives/live.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { SpectreProjectableElement } from '../../utils/projectable';\nimport { isInputSize, type SpectreInputSize } from '../../utils/form';\n\nimport { getInputClasses } from '@phcdevworks/spectre-ui';\n\nexport interface SpectreSelectProps {\n ariaLabel: string | null;\n ariaLabelledBy: string | null;\n ariaDescribedBy: string | null;\n autocomplete?: string | undefined;\n autofocus?: boolean | undefined;\n disabled?: boolean | undefined;\n form?: string | undefined;\n fullWidth?: boolean | undefined;\n invalid?: boolean | undefined;\n loading?: boolean | undefined;\n name?: string | undefined;\n pill?: boolean | undefined;\n required?: boolean | undefined;\n size?: SpectreInputSize | undefined;\n success?: boolean | undefined;\n title?: string | undefined;\n value?: string | undefined;\n}\n\nexport class SpectreSelectElement extends SpectreProjectableElement implements SpectreSelectProps {\n static properties = {\n autocomplete: { type: String, reflect: true },\n autofocus: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n form: { type: String },\n fullWidth: { attribute: 'full-width', type: Boolean, reflect: true },\n invalid: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n name: { type: String, reflect: true },\n pill: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n success: { type: Boolean, reflect: true },\n value: { type: String },\n };\n\n autocomplete: string | undefined;\n autofocus = false;\n disabled = false;\n form: string | undefined;\n fullWidth = false;\n invalid = false;\n loading = false;\n name: string | undefined;\n pill = false;\n required = false;\n size: SpectreInputSize = 'md';\n success = false;\n value = '';\n\n protected override getContentContainer(): Element | null {\n return this.querySelector('[data-sp-select-native]');\n }\n\n protected override isInternalNode(node: Node): boolean {\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return false;\n }\n\n const el = node as Element;\n return el.hasAttribute('data-sp-select-native');\n }\n\n protected override willUpdate(changedProperties: Map<PropertyKey, unknown>): void {\n if (changedProperties.has('size') && !isInputSize(this.size)) {\n this.size = 'md';\n }\n\n if (changedProperties.has('value') && this.value == null) {\n this.value = '';\n }\n }\n\n protected override updated(changedProperties: Map<PropertyKey, unknown>): void {\n super.updated(changedProperties);\n\n const nativeSelect = this.getContentContainer() as HTMLSelectElement | null;\n if (!nativeSelect) {\n return;\n }\n\n if (this.value !== '' && nativeSelect.value !== this.value) {\n nativeSelect.value = this.value;\n }\n\n if (this.value === '' && !this.hasAttribute('value')) {\n const nativeValue = nativeSelect.value ?? '';\n if (nativeValue !== '' && nativeValue !== this.value) {\n this.updateComplete.then(() => {\n if (this.value === '' && !this.hasAttribute('value')) {\n this.value = nativeValue;\n }\n });\n }\n }\n }\n\n private get selectClasses(): string {\n return getInputClasses({\n fullWidth: this.fullWidth,\n pill: this.pill,\n size: this.size,\n state: this.isDisabled\n ? this.disabled\n ? 'disabled'\n : 'loading'\n : this.invalid\n ? 'error'\n : this.success\n ? 'success'\n : 'default',\n });\n }\n\n private get isDisabled(): boolean {\n return this.disabled || this.loading;\n }\n\n private handleInput(event: Event): void {\n const select = event.currentTarget as HTMLSelectElement;\n this.value = select.value;\n }\n\n private handleChange(event: Event): void {\n const select = event.currentTarget as HTMLSelectElement;\n this.value = select.value;\n }\n\n override focus(options?: FocusOptions): void {\n (this.getContentContainer() as HTMLSelectElement | null)?.focus(options);\n }\n\n override blur(): void {\n (this.getContentContainer() as HTMLSelectElement | null)?.blur();\n }\n\n override render() {\n return html`<select\n aria-busy=\"${this.loading ? 'true' : 'false'}\"\n aria-describedby=\"${ifDefined(this.forwardedAriaDescribedBy)}\"\n aria-invalid=\"${ifDefined(this.invalid ? 'true' : undefined)}\"\n aria-label=\"${ifDefined(this.forwardedAriaLabel)}\"\n aria-labelledby=\"${ifDefined(this.forwardedAriaLabelledBy)}\"\n autocomplete=\"${ifDefined(this.autocomplete || undefined)}\"\n ?autofocus=\"${this.autofocus}\"\n class=\"${this.selectClasses}\"\n data-sp-select-native\n ?disabled=\"${this.isDisabled}\"\n form=\"${ifDefined(this.form || undefined)}\"\n id=\"${ifDefined(this.id || undefined)}\"\n name=\"${ifDefined(this.name || undefined)}\"\n ?required=\"${this.required}\"\n title=\"${ifDefined(this.title || undefined)}\"\n .value=\"${live(this.value)}\"\n @change=\"${this.handleChange}\"\n @input=\"${this.handleInput}\"\n >\n ${this.hasProjectedContent ? this.projectedContent : nothing}\n </select>`;\n }\n}\n\nexport function defineSpectreSelect(tagName = 'sp-select'): typeof SpectreSelectElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreSelectElement;\n }\n\n customElements.define(tagName, SpectreSelectElement);\n return SpectreSelectElement;\n}\n"]}