@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/button.js CHANGED
@@ -1,8 +1,267 @@
1
- import { LitElement, nothing, html } from 'lit';
1
+ import { LitElement, html, nothing } from 'lit';
2
2
  import { ifDefined } from 'lit/directives/if-defined.js';
3
3
  import { getButtonClasses } from '@phcdevworks/spectre-ui';
4
4
 
5
5
  // src/components/button/sp-button.ts
6
+ var SpectreBaseElement = class extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this._ariaLabel = null;
10
+ this._ariaLabelledBy = null;
11
+ this._ariaDescribedBy = null;
12
+ this._title = "";
13
+ this._id = "";
14
+ }
15
+ get ariaLabel() {
16
+ return this._ariaLabel;
17
+ }
18
+ set ariaLabel(value) {
19
+ if (this._ariaLabel === value) {
20
+ return;
21
+ }
22
+ this._ariaLabel = value;
23
+ this._removeHostAttribute("aria-label");
24
+ this.requestUpdate();
25
+ }
26
+ get ariaLabelledBy() {
27
+ return this._ariaLabelledBy;
28
+ }
29
+ set ariaLabelledBy(value) {
30
+ if (this._ariaLabelledBy === value) {
31
+ return;
32
+ }
33
+ this._ariaLabelledBy = value;
34
+ this._removeHostAttribute("aria-labelledby");
35
+ this.requestUpdate();
36
+ }
37
+ get ariaDescribedBy() {
38
+ return this._ariaDescribedBy;
39
+ }
40
+ set ariaDescribedBy(value) {
41
+ if (this._ariaDescribedBy === value) {
42
+ return;
43
+ }
44
+ this._ariaDescribedBy = value;
45
+ this._removeHostAttribute("aria-describedby");
46
+ this.requestUpdate();
47
+ }
48
+ get title() {
49
+ return this._title;
50
+ }
51
+ set title(value) {
52
+ const normalizedValue = value ?? "";
53
+ if (this._title === normalizedValue) {
54
+ return;
55
+ }
56
+ this._title = normalizedValue;
57
+ this._removeHostAttribute("title");
58
+ this.requestUpdate();
59
+ }
60
+ get id() {
61
+ return this._id;
62
+ }
63
+ set id(value) {
64
+ const normalizedValue = value ?? "";
65
+ if (this._id === normalizedValue) {
66
+ return;
67
+ }
68
+ this._id = normalizedValue;
69
+ this._removeHostAttribute("id");
70
+ this.requestUpdate();
71
+ }
72
+ // Spectre components intentionally render in light DOM so the global
73
+ // `@phcdevworks/spectre-ui` styling contract can apply directly.
74
+ createRenderRoot() {
75
+ return this;
76
+ }
77
+ connectedCallback() {
78
+ super.connectedCallback();
79
+ const proxiedAttributes = [
80
+ "id",
81
+ "title",
82
+ "aria-label",
83
+ "aria-labelledby",
84
+ "aria-describedby"
85
+ ];
86
+ proxiedAttributes.forEach((attr) => {
87
+ const value = super.getAttribute(attr);
88
+ if (value !== null) {
89
+ this.setAttribute(attr, value);
90
+ }
91
+ });
92
+ }
93
+ getAttribute(qualifiedName) {
94
+ switch (qualifiedName) {
95
+ case "id":
96
+ return this.id || null;
97
+ case "title":
98
+ return this.title || null;
99
+ case "aria-label":
100
+ return this.ariaLabel;
101
+ case "aria-labelledby":
102
+ return this.ariaLabelledBy;
103
+ case "aria-describedby":
104
+ return this.ariaDescribedBy;
105
+ default:
106
+ return super.getAttribute(qualifiedName);
107
+ }
108
+ }
109
+ hasAttribute(qualifiedName) {
110
+ switch (qualifiedName) {
111
+ case "id":
112
+ return this.id !== "";
113
+ case "title":
114
+ return this.title !== "";
115
+ case "aria-label":
116
+ return this.ariaLabel !== null;
117
+ case "aria-labelledby":
118
+ return this.ariaLabelledBy !== null;
119
+ case "aria-describedby":
120
+ return this.ariaDescribedBy !== null;
121
+ default:
122
+ return super.hasAttribute(qualifiedName);
123
+ }
124
+ }
125
+ setAttribute(qualifiedName, value) {
126
+ switch (qualifiedName) {
127
+ case "id":
128
+ this.id = value;
129
+ break;
130
+ case "title":
131
+ this.title = value;
132
+ break;
133
+ case "aria-label":
134
+ this.ariaLabel = value;
135
+ break;
136
+ case "aria-labelledby":
137
+ this.ariaLabelledBy = value;
138
+ break;
139
+ case "aria-describedby":
140
+ this.ariaDescribedBy = value;
141
+ break;
142
+ default:
143
+ super.setAttribute(qualifiedName, value);
144
+ }
145
+ }
146
+ removeAttribute(qualifiedName) {
147
+ switch (qualifiedName) {
148
+ case "id":
149
+ this.id = "";
150
+ break;
151
+ case "title":
152
+ this.title = "";
153
+ break;
154
+ case "aria-label":
155
+ this.ariaLabel = null;
156
+ break;
157
+ case "aria-labelledby":
158
+ this.ariaLabelledBy = null;
159
+ break;
160
+ case "aria-describedby":
161
+ this.ariaDescribedBy = null;
162
+ break;
163
+ default:
164
+ super.removeAttribute(qualifiedName);
165
+ }
166
+ }
167
+ _removeHostAttribute(name) {
168
+ const host = this;
169
+ if (HTMLElement.prototype.hasAttribute.call(host, name)) {
170
+ HTMLElement.prototype.removeAttribute.call(host, name);
171
+ }
172
+ }
173
+ get forwardedAriaLabel() {
174
+ const value = this.ariaLabel?.trim();
175
+ return value ? value : void 0;
176
+ }
177
+ get forwardedAriaLabelledBy() {
178
+ const value = this.ariaLabelledBy?.trim();
179
+ return value ? value : void 0;
180
+ }
181
+ get forwardedAriaDescribedBy() {
182
+ const value = this.ariaDescribedBy?.trim();
183
+ return value ? value : void 0;
184
+ }
185
+ };
186
+ SpectreBaseElement.properties = {};
187
+
188
+ // src/utils/dom.ts
189
+ function hasMeaningfulContent(nodes) {
190
+ return nodes.some((node) => {
191
+ if (node.nodeType === Node.ELEMENT_NODE) {
192
+ return true;
193
+ }
194
+ if (node.nodeType === Node.TEXT_NODE) {
195
+ return (node.textContent?.trim().length ?? 0) > 0;
196
+ }
197
+ return false;
198
+ });
199
+ }
200
+
201
+ // src/utils/projectable.ts
202
+ var SpectreProjectableElement = class extends SpectreBaseElement {
203
+ constructor() {
204
+ super(...arguments);
205
+ this.projectedContent = [];
206
+ }
207
+ get hasProjectedContent() {
208
+ return hasMeaningfulContent(this.projectedContent);
209
+ }
210
+ connectedCallback() {
211
+ super.connectedCallback();
212
+ this.syncProjectedContent();
213
+ this.startContentObserver();
214
+ }
215
+ disconnectedCallback() {
216
+ this.stopContentObserver();
217
+ super.disconnectedCallback();
218
+ }
219
+ update(changedProperties) {
220
+ this.stopContentObserver();
221
+ super.update(changedProperties);
222
+ this.startContentObserver();
223
+ }
224
+ syncProjectedContent() {
225
+ const nextProjectedContent = [];
226
+ const sourceNodes = [
227
+ ...this.childNodes,
228
+ ...this.getContentContainer()?.childNodes ?? []
229
+ ];
230
+ sourceNodes.forEach((node) => {
231
+ if (!this.isInternalNode(node) && !nextProjectedContent.includes(node)) {
232
+ nextProjectedContent.push(node);
233
+ }
234
+ });
235
+ const hasChanged = nextProjectedContent.length !== this.projectedContent.length || nextProjectedContent.some((node, index) => node !== this.projectedContent[index]);
236
+ if (hasChanged) {
237
+ this.projectedContent = nextProjectedContent;
238
+ }
239
+ return hasChanged;
240
+ }
241
+ startContentObserver() {
242
+ if (this.contentObserver) {
243
+ return;
244
+ }
245
+ this.contentObserver = new MutationObserver((mutations) => {
246
+ const isInternalMovement = mutations.every(
247
+ (mutation) => [...mutation.removedNodes].every(
248
+ (node) => this.isInternalNode(node) || this.contains(node)
249
+ ) && [...mutation.addedNodes].every((node) => this.isInternalNode(node))
250
+ );
251
+ if (isInternalMovement) {
252
+ return;
253
+ }
254
+ if (this.syncProjectedContent()) {
255
+ this.requestUpdate();
256
+ }
257
+ });
258
+ this.contentObserver.observe(this, { childList: true });
259
+ }
260
+ stopContentObserver() {
261
+ this.contentObserver?.disconnect();
262
+ this.contentObserver = void 0;
263
+ }
264
+ };
6
265
  var spectreButtonVariants = [
7
266
  "primary",
8
267
  "secondary",
@@ -23,23 +282,9 @@ function isButtonSize(value) {
23
282
  function isButtonType(value) {
24
283
  return spectreButtonTypes.includes(value);
25
284
  }
26
- function hasMeaningfulContent(nodes) {
27
- return nodes.some((node) => {
28
- if (node.nodeType === Node.ELEMENT_NODE) {
29
- return true;
30
- }
31
- if (node.nodeType === Node.TEXT_NODE) {
32
- return (node.textContent?.trim().length ?? 0) > 0;
33
- }
34
- return false;
35
- });
36
- }
37
- var SpectreButtonElement = class extends LitElement {
285
+ var SpectreButtonElement = class extends SpectreProjectableElement {
38
286
  constructor() {
39
287
  super(...arguments);
40
- this.ariaLabel = null;
41
- this.ariaLabelledBy = null;
42
- this.ariaDescribedBy = null;
43
288
  this.autofocus = false;
44
289
  this.disabled = false;
45
290
  this.fullWidth = false;
@@ -47,68 +292,19 @@ var SpectreButtonElement = class extends LitElement {
47
292
  this.loadingLabel = "Loading";
48
293
  this.pill = false;
49
294
  this.size = "md";
50
- this.title = "";
51
295
  this.type = "button";
52
296
  this.variant = "primary";
53
- // Native slot projection is a Shadow DOM feature, so in light DOM we keep
54
- // host-provided content reactive by tracking and reusing the host nodes.
55
- this.projectedContent = [];
297
+ this.value = "";
56
298
  }
57
- get id() {
58
- return this._id ?? "";
59
- }
60
- set id(value) {
61
- if ((this._id ?? "") === value) {
62
- return;
63
- }
64
- this._id = value;
65
- const host = this;
66
- if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
67
- HTMLElement.prototype.removeAttribute.call(host, "id");
68
- }
69
- this.requestUpdate();
70
- }
71
- createRenderRoot() {
72
- return this;
73
- }
74
- connectedCallback() {
75
- super.connectedCallback();
76
- const hostId = super.getAttribute("id");
77
- if (hostId !== null) {
78
- this.id = hostId;
79
- }
80
- this.syncProjectedContent();
81
- this.startContentObserver();
82
- }
83
- getAttribute(qualifiedName) {
84
- if (qualifiedName === "id") {
85
- return this.id || null;
86
- }
87
- return super.getAttribute(qualifiedName);
88
- }
89
- hasAttribute(qualifiedName) {
90
- if (qualifiedName === "id") {
91
- return this.id !== "";
92
- }
93
- return super.hasAttribute(qualifiedName);
94
- }
95
- setAttribute(qualifiedName, value) {
96
- if (qualifiedName === "id") {
97
- this.id = value;
98
- return;
99
- }
100
- super.setAttribute(qualifiedName, value);
299
+ getContentContainer() {
300
+ return this.querySelector("[data-sp-button-native]");
101
301
  }
102
- removeAttribute(qualifiedName) {
103
- if (qualifiedName === "id") {
104
- this.id = "";
105
- return;
302
+ isInternalNode(node) {
303
+ if (node.nodeType !== Node.ELEMENT_NODE) {
304
+ return false;
106
305
  }
107
- super.removeAttribute(qualifiedName);
108
- }
109
- disconnectedCallback() {
110
- this.stopContentObserver();
111
- super.disconnectedCallback();
306
+ const el = node;
307
+ return el.hasAttribute("data-sp-button-native") || el.hasAttribute("data-sp-button-loading-label") || el.hasAttribute("data-sp-button-label-fallback");
112
308
  }
113
309
  willUpdate(changedProperties) {
114
310
  if (changedProperties.has("variant") && !isButtonVariant(this.variant)) {
@@ -125,11 +321,9 @@ var SpectreButtonElement = class extends LitElement {
125
321
  this.loadingLabel = "Loading";
126
322
  }
127
323
  }
128
- }
129
- update(changedProperties) {
130
- this.stopContentObserver();
131
- super.update(changedProperties);
132
- this.startContentObserver();
324
+ if (changedProperties.has("value") && this.value == null) {
325
+ this.value = "";
326
+ }
133
327
  }
134
328
  get buttonClasses() {
135
329
  return getButtonClasses({
@@ -144,118 +338,50 @@ var SpectreButtonElement = class extends LitElement {
144
338
  get isDisabled() {
145
339
  return this.disabled || this.loading;
146
340
  }
147
- get hasProjectedContent() {
148
- return hasMeaningfulContent(this.projectedContent);
149
- }
150
341
  get visibleLabelFallback() {
151
342
  const trimmedLabel = this.label?.trim();
152
343
  return trimmedLabel ? trimmedLabel : void 0;
153
344
  }
154
- get forwardedAriaLabel() {
155
- const ariaLabel = this.ariaLabel?.trim();
156
- return ariaLabel ? ariaLabel : void 0;
157
- }
158
- get forwardedAriaLabelledBy() {
159
- const ariaLabelledBy = this.ariaLabelledBy?.trim();
160
- return ariaLabelledBy ? ariaLabelledBy : void 0;
161
- }
162
- get forwardedAriaDescribedBy() {
163
- const ariaDescribedBy = this.ariaDescribedBy?.trim();
164
- return ariaDescribedBy ? ariaDescribedBy : void 0;
165
- }
166
- startContentObserver() {
167
- if (this.contentObserver) {
168
- return;
169
- }
170
- this.contentObserver = new MutationObserver((mutations) => {
171
- const isInternalMovement = mutations.every((mutation) => {
172
- return Array.from(mutation.removedNodes).every(
173
- (node) => this.isInternalButtonNode(node) || this.contains(node)
174
- ) && Array.from(mutation.addedNodes).every((node) => this.isInternalButtonNode(node));
175
- });
176
- if (isInternalMovement) {
177
- return;
178
- }
179
- if (this.syncProjectedContent()) {
180
- this.requestUpdate();
181
- }
182
- });
183
- this.contentObserver.observe(this, {
184
- childList: true
185
- });
186
- }
187
- stopContentObserver() {
188
- this.contentObserver?.disconnect();
189
- this.contentObserver = void 0;
190
- }
191
- syncProjectedContent() {
192
- const nextProjectedContent = [];
193
- Array.from(this.childNodes).forEach((node) => {
194
- if (this.isInternalButtonNode(node)) {
195
- this.projectedContent.forEach((pNode) => {
196
- if (pNode.parentNode !== this && this.contains(pNode)) {
197
- nextProjectedContent.push(pNode);
198
- }
199
- });
200
- } else {
201
- nextProjectedContent.push(node);
202
- }
203
- });
204
- const hasChanged = nextProjectedContent.length !== this.projectedContent.length || nextProjectedContent.some((node, index) => node !== this.projectedContent[index]);
205
- if (hasChanged) {
206
- this.projectedContent = nextProjectedContent;
207
- }
208
- return hasChanged;
209
- }
210
- isInternalButtonNode(node) {
211
- return node.nodeType === Node.ELEMENT_NODE && node.hasAttribute("data-sp-button-native");
212
- }
213
- get nativeButton() {
214
- return this.querySelector("[data-sp-button-native]");
215
- }
216
345
  focus(options) {
217
- this.nativeButton?.focus(options);
346
+ this.getContentContainer()?.focus(options);
218
347
  }
219
348
  blur() {
220
- this.nativeButton?.blur();
349
+ this.getContentContainer()?.blur();
221
350
  }
222
351
  renderButtonContent() {
223
352
  if (this.loading) {
224
- return this.loadingLabel;
353
+ return html`<span data-sp-button-loading-label>${this.loadingLabel}</span>`;
225
354
  }
226
355
  if (this.hasProjectedContent) {
227
356
  return this.projectedContent;
228
357
  }
229
- return this.visibleLabelFallback ?? "";
358
+ return this.visibleLabelFallback ? html`<span data-sp-button-label-fallback>${this.visibleLabelFallback}</span>` : nothing;
230
359
  }
231
360
  render() {
232
- return html`
233
- <button
234
- aria-busy=${this.loading ? "true" : "false"}
235
- aria-describedby=${ifDefined(this.forwardedAriaDescribedBy)}
236
- aria-label=${ifDefined(this.forwardedAriaLabel)}
237
- aria-labelledby=${ifDefined(this.forwardedAriaLabelledBy)}
238
- ?autofocus=${this.autofocus}
239
- class=${this.buttonClasses}
240
- data-sp-button-native
241
- ?disabled=${this.isDisabled}
242
- id=${ifDefined(this.id || void 0)}
243
- name=${ifDefined(this.name)}
244
- title=${ifDefined(this.title || void 0)}
245
- type=${this.type}
246
- value=${ifDefined(this.value)}
247
- >
248
- ${this.renderButtonContent() || nothing}
249
- </button>
250
- `;
361
+ return html`<button
362
+ aria-busy="${this.loading ? "true" : "false"}"
363
+ aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
364
+ aria-label="${ifDefined(this.forwardedAriaLabel)}"
365
+ aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
366
+ ?autofocus="${this.autofocus}"
367
+ class="${this.buttonClasses}"
368
+ data-sp-button-native
369
+ ?disabled="${this.isDisabled}"
370
+ form="${ifDefined(this.form || void 0)}"
371
+ id="${ifDefined(this.id || void 0)}"
372
+ name="${ifDefined(this.name || void 0)}"
373
+ title="${ifDefined(this.title || void 0)}"
374
+ type="${this.type}"
375
+ value="${ifDefined(this.value || void 0)}"
376
+ >
377
+ ${this.renderButtonContent()}
378
+ </button>`;
251
379
  }
252
380
  };
253
381
  SpectreButtonElement.properties = {
254
- ariaLabel: { attribute: "aria-label", type: String },
255
- ariaLabelledBy: { attribute: "aria-labelledby", type: String },
256
- ariaDescribedBy: { attribute: "aria-describedby", type: String },
257
382
  autofocus: { type: Boolean, reflect: true },
258
383
  disabled: { type: Boolean, reflect: true },
384
+ form: { type: String },
259
385
  fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
260
386
  label: { type: String, reflect: true },
261
387
  loading: { type: Boolean, reflect: true },
@@ -263,10 +389,9 @@ SpectreButtonElement.properties = {
263
389
  name: { type: String, reflect: true },
264
390
  pill: { type: Boolean, reflect: true },
265
391
  size: { type: String, reflect: true },
266
- title: { type: String, reflect: true },
267
392
  type: { type: String, reflect: true },
268
393
  variant: { type: String, reflect: true },
269
- value: { type: String, reflect: true }
394
+ value: { type: String }
270
395
  };
271
396
  function defineSpectreButton(tagName = "sp-button") {
272
397
  const existingElement = customElements.get(tagName);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/button/sp-button.ts"],"names":[],"mappings":";;;;;AASO,IAAM,qBAAA,GAAwB;AAAA,EACnC,SAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF;AAEO,IAAM,kBAAA,GAAqB,CAAC,IAAA,EAAM,IAAA,EAAM,IAAI;AAC5C,IAAM,kBAAA,GAAqB,CAAC,QAAA,EAAU,QAAA,EAAU,OAAO;AAsB9D,SAAS,gBAAgB,KAAA,EAAuC;AAC9D,EAAA,OAAQ,qBAAA,CAA4C,SAAS,KAAK,CAAA;AACpE;AAEA,SAAS,aAAa,KAAA,EAAoC;AACxD,EAAA,OAAQ,kBAAA,CAAyC,SAAS,KAAK,CAAA;AACjE;AAEA,SAAS,aAAa,KAAA,EAA2C;AAC/D,EAAA,OAAQ,kBAAA,CAAyC,SAAS,KAAK,CAAA;AACjE;AAEA,SAAS,qBAAqB,KAAA,EAAiC;AAC7D,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,CAAC,IAAA,KAAS;AAC1B,IAAA,IAAI,IAAA,CAAK,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,SAAS,IAAA,EAAK;AAAA,EACnE,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACrC,OAAA,EAAS,EAAE,IAAA,EAAM,OAAA,EAAS,SAAS,IAAA,EAAK;AAAA,EACxC,cAAc,EAAE,SAAA,EAAW,iBAAiB,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACxE,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,IAAA,EAAM,EAAE,IAAA,EAAM,OAAA,EAAS,SAAS,IAAA,EAAK;AAAA,EACrC,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACrC,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,OAAA,EAAS,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACvC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA;AAClC,CAAA;AAwRK,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":"button.js","sourcesContent":["import { LitElement, html, nothing, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport {\n getButtonClasses,\n type ButtonSize,\n type ButtonVariant,\n} from '@phcdevworks/spectre-ui';\n\nexport const spectreButtonVariants = [\n 'primary',\n 'secondary',\n 'ghost',\n 'danger',\n 'success',\n 'cta',\n 'accent',\n] as const;\n\nexport const spectreButtonSizes = ['sm', 'md', 'lg'] as const;\nexport const spectreButtonTypes = ['button', 'submit', 'reset'] as const;\n\nexport type SpectreButtonVariant = (typeof spectreButtonVariants)[number];\nexport type SpectreButtonSize = (typeof spectreButtonSizes)[number];\nexport type SpectreButtonType = (typeof spectreButtonTypes)[number];\n\nexport interface SpectreButtonProps {\n autofocus?: boolean;\n disabled?: boolean;\n fullWidth?: boolean;\n label?: string;\n loading?: boolean;\n loadingLabel?: string;\n name?: string;\n pill?: boolean;\n size?: SpectreButtonSize;\n title?: string;\n type?: SpectreButtonType;\n variant?: SpectreButtonVariant;\n value?: string;\n}\n\nfunction isButtonVariant(value: string): value is ButtonVariant {\n return (spectreButtonVariants as readonly string[]).includes(value);\n}\n\nfunction isButtonSize(value: string): value is ButtonSize {\n return (spectreButtonSizes as readonly string[]).includes(value);\n}\n\nfunction isButtonType(value: string): value is SpectreButtonType {\n return (spectreButtonTypes as readonly string[]).includes(value);\n}\n\nfunction 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\nexport class SpectreButtonElement extends LitElement implements SpectreButtonProps {\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 label: { type: String, reflect: true },\n loading: { type: Boolean, reflect: true },\n loadingLabel: { attribute: 'loading-label', type: String, reflect: true },\n name: { type: String, reflect: true },\n pill: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n title: { type: String, reflect: true },\n type: { type: String, reflect: true },\n variant: { type: String, reflect: true },\n value: { type: String, reflect: true },\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 label?: string;\n loading = false;\n loadingLabel = 'Loading';\n name?: string;\n pill = false;\n size: SpectreButtonSize = 'md';\n override title = '';\n type: SpectreButtonType = 'button';\n variant: SpectreButtonVariant = 'primary';\n value?: string;\n private _id?: string;\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 // Native slot projection is a Shadow DOM feature, so in light DOM we keep\n // host-provided content reactive by tracking and reusing the host nodes.\n private projectedContent: Node[] = [];\n private contentObserver?: MutationObserver | undefined;\n\n createRenderRoot(): this {\n // Spectre components intentionally render in light DOM so the global\n // `@phcdevworks/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.syncProjectedContent();\n this.startContentObserver();\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 override disconnectedCallback(): void {\n this.stopContentObserver();\n super.disconnectedCallback();\n }\n\n protected override willUpdate(changedProperties: Map<PropertyKey, unknown>): void {\n if (changedProperties.has('variant') && !isButtonVariant(this.variant)) {\n this.variant = 'primary';\n }\n\n if (changedProperties.has('size') && !isButtonSize(this.size)) {\n this.size = 'md';\n }\n\n if (changedProperties.has('type') && !isButtonType(this.type)) {\n this.type = 'button';\n }\n\n if (changedProperties.has('loadingLabel')) {\n if (this.loadingLabel == null || this.loadingLabel.trim() === '') {\n this.loadingLabel = 'Loading';\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 private get buttonClasses(): string {\n return getButtonClasses({\n disabled: this.isDisabled,\n fullWidth: this.fullWidth,\n loading: this.loading,\n pill: this.pill,\n size: this.size,\n variant: this.variant,\n });\n }\n\n private get isDisabled(): boolean {\n return this.disabled || this.loading;\n }\n\n private get hasProjectedContent(): boolean {\n return hasMeaningfulContent(this.projectedContent);\n }\n\n private get visibleLabelFallback(): string | undefined {\n const trimmedLabel = this.label?.trim();\n return trimmedLabel ? trimmedLabel : undefined;\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.isInternalButtonNode(node) || this.contains(node),\n ) &&\n Array.from(mutation.addedNodes).every((node) => this.isInternalButtonNode(node))\n );\n });\n\n if (isInternalMovement) {\n return;\n }\n\n if (this.syncProjectedContent()) {\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 syncProjectedContent(): boolean {\n const nextProjectedContent: Node[] = [];\n\n Array.from(this.childNodes).forEach((node) => {\n if (this.isInternalButtonNode(node)) {\n this.projectedContent.forEach((pNode) => {\n if (pNode.parentNode !== this && this.contains(pNode)) {\n nextProjectedContent.push(pNode);\n }\n });\n } else {\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 isInternalButtonNode(node: Node): boolean {\n return (\n node.nodeType === Node.ELEMENT_NODE && (node as Element).hasAttribute('data-sp-button-native')\n );\n }\n\n private get nativeButton(): HTMLButtonElement | null {\n return this.querySelector('[data-sp-button-native]');\n }\n\n override focus(options?: FocusOptions): void {\n this.nativeButton?.focus(options);\n }\n\n override blur(): void {\n this.nativeButton?.blur();\n }\n\n private renderButtonContent(): TemplateResult | Node[] | string {\n if (this.loading) {\n return this.loadingLabel;\n }\n\n if (this.hasProjectedContent) {\n return this.projectedContent;\n }\n\n return this.visibleLabelFallback ?? '';\n }\n\n override render() {\n return html`\n <button\n aria-busy=${this.loading ? 'true' : 'false'}\n aria-describedby=${ifDefined(this.forwardedAriaDescribedBy)}\n aria-label=${ifDefined(this.forwardedAriaLabel)}\n aria-labelledby=${ifDefined(this.forwardedAriaLabelledBy)}\n ?autofocus=${this.autofocus}\n class=${this.buttonClasses}\n data-sp-button-native\n ?disabled=${this.isDisabled}\n id=${ifDefined(this.id || undefined)}\n name=${ifDefined(this.name)}\n title=${ifDefined(this.title || undefined)}\n type=${this.type}\n value=${ifDefined(this.value)}\n >\n ${this.renderButtonContent() || nothing}\n </button>\n `;\n }\n}\n\nexport function defineSpectreButton(tagName = 'sp-button'): typeof SpectreButtonElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreButtonElement;\n }\n\n customElements.define(tagName, SpectreButtonElement);\n return SpectreButtonElement;\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/base.ts","../src/utils/dom.ts","../src/utils/projectable.ts","../src/components/button/sp-button.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,iBAAiB,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IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,OAAA,EAAS,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACvC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA;AACjB,CAAA;AAyHK,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":"button.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 { html, nothing, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { SpectreProjectableElement } from '../../utils/projectable';\n\nimport {\n getButtonClasses,\n type ButtonSize,\n type ButtonVariant,\n} from '@phcdevworks/spectre-ui';\n\nexport const spectreButtonVariants = [\n 'primary',\n 'secondary',\n 'ghost',\n 'danger',\n 'success',\n 'cta',\n 'accent',\n] as const;\n\nexport const spectreButtonSizes = ['sm', 'md', 'lg'] as const;\nexport const spectreButtonTypes = ['button', 'submit', 'reset'] as const;\n\nexport type SpectreButtonVariant = (typeof spectreButtonVariants)[number];\nexport type SpectreButtonSize = (typeof spectreButtonSizes)[number];\nexport type SpectreButtonType = (typeof spectreButtonTypes)[number];\n\nexport interface SpectreButtonProps {\n ariaLabel: string | null;\n ariaLabelledBy: string | null;\n ariaDescribedBy: string | null;\n autofocus?: boolean | undefined;\n disabled?: boolean | undefined;\n form?: string | undefined;\n fullWidth?: boolean | undefined;\n label?: string | undefined;\n loading?: boolean | undefined;\n loadingLabel?: string | undefined;\n name?: string | undefined;\n pill?: boolean | undefined;\n size?: SpectreButtonSize | undefined;\n title?: string | undefined;\n type?: SpectreButtonType | undefined;\n variant?: SpectreButtonVariant | undefined;\n value?: string | undefined;\n}\n\nfunction isButtonVariant(value: string): value is ButtonVariant {\n return (spectreButtonVariants as readonly string[]).includes(value);\n}\n\nfunction isButtonSize(value: string): value is ButtonSize {\n return (spectreButtonSizes as readonly string[]).includes(value);\n}\n\nfunction isButtonType(value: string): value is SpectreButtonType {\n return (spectreButtonTypes as readonly string[]).includes(value);\n}\n\nexport class SpectreButtonElement extends SpectreProjectableElement implements SpectreButtonProps {\n static properties = {\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 label: { type: String, reflect: true },\n loading: { type: Boolean, reflect: true },\n loadingLabel: { attribute: 'loading-label', type: String, reflect: true },\n name: { type: String, reflect: true },\n pill: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n type: { type: String, reflect: true },\n variant: { type: String, reflect: true },\n value: { type: String },\n };\n\n autofocus = false;\n disabled = false;\n form: string | undefined;\n fullWidth = false;\n label: string | undefined;\n loading = false;\n loadingLabel = 'Loading';\n name: string | undefined;\n pill = false;\n size: SpectreButtonSize = 'md';\n type: SpectreButtonType = 'button';\n variant: SpectreButtonVariant = 'primary';\n value = '';\n\n protected override getContentContainer(): Element | null {\n return this.querySelector('[data-sp-button-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 (\n el.hasAttribute('data-sp-button-native') ||\n el.hasAttribute('data-sp-button-loading-label') ||\n el.hasAttribute('data-sp-button-label-fallback')\n );\n }\n\n protected override willUpdate(changedProperties: Map<PropertyKey, unknown>): void {\n if (changedProperties.has('variant') && !isButtonVariant(this.variant)) {\n this.variant = 'primary';\n }\n\n if (changedProperties.has('size') && !isButtonSize(this.size)) {\n this.size = 'md';\n }\n\n if (changedProperties.has('type') && !isButtonType(this.type)) {\n this.type = 'button';\n }\n\n if (changedProperties.has('loadingLabel')) {\n if (this.loadingLabel == null || this.loadingLabel.trim() === '') {\n this.loadingLabel = 'Loading';\n }\n }\n\n if (changedProperties.has('value') && this.value == null) {\n this.value = '';\n }\n }\n\n private get buttonClasses(): string {\n return getButtonClasses({\n disabled: this.isDisabled,\n fullWidth: this.fullWidth,\n loading: this.loading,\n pill: this.pill,\n size: this.size,\n variant: this.variant,\n });\n }\n\n private get isDisabled(): boolean {\n return this.disabled || this.loading;\n }\n\n private get visibleLabelFallback(): string | undefined {\n const trimmedLabel = this.label?.trim();\n return trimmedLabel ? trimmedLabel : undefined;\n }\n\n override focus(options?: FocusOptions): void {\n (this.getContentContainer() as HTMLButtonElement | null)?.focus(options);\n }\n\n override blur(): void {\n (this.getContentContainer() as HTMLButtonElement | null)?.blur();\n }\n\n private renderButtonContent(): TemplateResult | Node[] | typeof nothing {\n if (this.loading) {\n return html`<span data-sp-button-loading-label>${this.loadingLabel}</span>`;\n }\n\n if (this.hasProjectedContent) {\n return this.projectedContent as Node[];\n }\n\n return this.visibleLabelFallback\n ? html`<span data-sp-button-label-fallback>${this.visibleLabelFallback}</span>`\n : nothing;\n }\n\n override render() {\n return html`<button\n aria-busy=\"${this.loading ? 'true' : 'false'}\"\n aria-describedby=\"${ifDefined(this.forwardedAriaDescribedBy)}\"\n aria-label=\"${ifDefined(this.forwardedAriaLabel)}\"\n aria-labelledby=\"${ifDefined(this.forwardedAriaLabelledBy)}\"\n ?autofocus=\"${this.autofocus}\"\n class=\"${this.buttonClasses}\"\n data-sp-button-native\n ?disabled=\"${this.isDisabled}\"\n form=\"${ifDefined(this.form || undefined)}\"\n id=\"${ifDefined(this.id || undefined)}\"\n name=\"${ifDefined(this.name || undefined)}\"\n title=\"${ifDefined(this.title || undefined)}\"\n type=\"${this.type}\"\n value=\"${ifDefined(this.value || undefined)}\"\n >\n ${this.renderButtonContent()}\n </button>`;\n }\n}\n\nexport function defineSpectreButton(tagName = 'sp-button'): typeof SpectreButtonElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreButtonElement;\n }\n\n customElements.define(tagName, SpectreButtonElement);\n return SpectreButtonElement;\n}\n"]}