@phcdevworks/spectre-components 1.0.0 → 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 (60) hide show
  1. package/README.md +113 -40
  2. package/dist/{base-DQtCQ-dP.d.cts → base-2rD8EmdC.d.cts} +15 -5
  3. package/dist/{base-DQtCQ-dP.d.ts → base-2rD8EmdC.d.ts} +15 -5
  4. package/dist/button.cjs +158 -58
  5. package/dist/button.cjs.map +1 -1
  6. package/dist/button.d.cts +22 -28
  7. package/dist/button.d.ts +22 -28
  8. package/dist/button.js +158 -58
  9. package/dist/button.js.map +1 -1
  10. package/dist/checkbox.cjs +164 -64
  11. package/dist/checkbox.cjs.map +1 -1
  12. package/dist/checkbox.d.cts +18 -23
  13. package/dist/checkbox.d.ts +18 -23
  14. package/dist/checkbox.js +164 -64
  15. package/dist/checkbox.js.map +1 -1
  16. package/dist/fieldset.cjs +154 -55
  17. package/dist/fieldset.cjs.map +1 -1
  18. package/dist/fieldset.d.cts +13 -18
  19. package/dist/fieldset.d.ts +13 -18
  20. package/dist/fieldset.js +154 -55
  21. package/dist/fieldset.js.map +1 -1
  22. package/dist/index.cjs +324 -261
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +324 -261
  27. package/dist/index.js.map +1 -1
  28. package/dist/input.cjs +174 -72
  29. package/dist/input.cjs.map +1 -1
  30. package/dist/input.d.cts +33 -38
  31. package/dist/input.d.ts +33 -38
  32. package/dist/input.js +174 -72
  33. package/dist/input.js.map +1 -1
  34. package/dist/label.cjs +152 -56
  35. package/dist/label.cjs.map +1 -1
  36. package/dist/label.d.cts +8 -13
  37. package/dist/label.d.ts +8 -13
  38. package/dist/label.js +152 -56
  39. package/dist/label.js.map +1 -1
  40. package/dist/{projectable-DcnBRiko.d.cts → projectable-BzDQ4xp_.d.cts} +1 -1
  41. package/dist/{projectable-SzbPvXfM.d.ts → projectable-s3SgvjGX.d.ts} +1 -1
  42. package/dist/radio.cjs +164 -64
  43. package/dist/radio.cjs.map +1 -1
  44. package/dist/radio.d.cts +18 -23
  45. package/dist/radio.d.ts +18 -23
  46. package/dist/radio.js +164 -64
  47. package/dist/radio.js.map +1 -1
  48. package/dist/select.cjs +161 -61
  49. package/dist/select.cjs.map +1 -1
  50. package/dist/select.d.cts +22 -27
  51. package/dist/select.d.ts +22 -27
  52. package/dist/select.js +161 -61
  53. package/dist/select.js.map +1 -1
  54. package/dist/textarea.cjs +172 -72
  55. package/dist/textarea.cjs.map +1 -1
  56. package/dist/textarea.d.cts +27 -32
  57. package/dist/textarea.d.ts +27 -32
  58. package/dist/textarea.js +172 -72
  59. package/dist/textarea.js.map +1 -1
  60. package/package.json +9 -8
package/dist/label.js CHANGED
@@ -5,22 +5,67 @@ import { ifDefined } from 'lit/directives/if-defined.js';
5
5
  var SpectreBaseElement = class extends LitElement {
6
6
  constructor() {
7
7
  super(...arguments);
8
- this.ariaLabel = null;
9
- this.ariaLabelledBy = null;
10
- this.ariaDescribedBy = null;
8
+ this._ariaLabel = null;
9
+ this._ariaLabelledBy = null;
10
+ this._ariaDescribedBy = null;
11
+ this._title = "";
12
+ this._id = "";
13
+ }
14
+ get ariaLabel() {
15
+ return this._ariaLabel;
16
+ }
17
+ set ariaLabel(value) {
18
+ if (this._ariaLabel === value) {
19
+ return;
20
+ }
21
+ this._ariaLabel = value;
22
+ this._removeHostAttribute("aria-label");
23
+ this.requestUpdate();
24
+ }
25
+ get ariaLabelledBy() {
26
+ return this._ariaLabelledBy;
27
+ }
28
+ set ariaLabelledBy(value) {
29
+ if (this._ariaLabelledBy === value) {
30
+ return;
31
+ }
32
+ this._ariaLabelledBy = value;
33
+ this._removeHostAttribute("aria-labelledby");
34
+ this.requestUpdate();
35
+ }
36
+ get ariaDescribedBy() {
37
+ return this._ariaDescribedBy;
38
+ }
39
+ set ariaDescribedBy(value) {
40
+ if (this._ariaDescribedBy === value) {
41
+ return;
42
+ }
43
+ this._ariaDescribedBy = value;
44
+ this._removeHostAttribute("aria-describedby");
45
+ this.requestUpdate();
46
+ }
47
+ get title() {
48
+ return this._title;
49
+ }
50
+ set title(value) {
51
+ const normalizedValue = value ?? "";
52
+ if (this._title === normalizedValue) {
53
+ return;
54
+ }
55
+ this._title = normalizedValue;
56
+ this._removeHostAttribute("title");
57
+ this.requestUpdate();
11
58
  }
12
59
  get id() {
13
- return this._id ?? "";
60
+ return this._id;
14
61
  }
15
62
  set id(value) {
16
- if ((this._id ?? "") === value) {
63
+ const normalizedValue = value ?? "";
64
+ if (this._id === normalizedValue) {
17
65
  return;
18
66
  }
19
- this._id = value;
20
- const host = this;
21
- if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
22
- HTMLElement.prototype.removeAttribute.call(host, "id");
23
- }
67
+ this._id = normalizedValue;
68
+ this._removeHostAttribute("id");
24
69
  this.requestUpdate();
25
70
  }
26
71
  // Spectre components intentionally render in light DOM so the global
@@ -30,36 +75,99 @@ var SpectreBaseElement = class extends LitElement {
30
75
  }
31
76
  connectedCallback() {
32
77
  super.connectedCallback();
33
- const hostId = super.getAttribute("id");
34
- if (hostId !== null) {
35
- this.id = hostId;
36
- }
78
+ const proxiedAttributes = [
79
+ "id",
80
+ "title",
81
+ "aria-label",
82
+ "aria-labelledby",
83
+ "aria-describedby"
84
+ ];
85
+ proxiedAttributes.forEach((attr) => {
86
+ const value = super.getAttribute(attr);
87
+ if (value !== null) {
88
+ this.setAttribute(attr, value);
89
+ }
90
+ });
37
91
  }
38
92
  getAttribute(qualifiedName) {
39
- if (qualifiedName === "id") {
40
- return this.id || null;
93
+ switch (qualifiedName) {
94
+ case "id":
95
+ return this.id || null;
96
+ case "title":
97
+ return this.title || null;
98
+ case "aria-label":
99
+ return this.ariaLabel;
100
+ case "aria-labelledby":
101
+ return this.ariaLabelledBy;
102
+ case "aria-describedby":
103
+ return this.ariaDescribedBy;
104
+ default:
105
+ return super.getAttribute(qualifiedName);
41
106
  }
42
- return super.getAttribute(qualifiedName);
43
107
  }
44
108
  hasAttribute(qualifiedName) {
45
- if (qualifiedName === "id") {
46
- return this.id !== "";
109
+ switch (qualifiedName) {
110
+ case "id":
111
+ return this.id !== "";
112
+ case "title":
113
+ return this.title !== "";
114
+ case "aria-label":
115
+ return this.ariaLabel !== null;
116
+ case "aria-labelledby":
117
+ return this.ariaLabelledBy !== null;
118
+ case "aria-describedby":
119
+ return this.ariaDescribedBy !== null;
120
+ default:
121
+ return super.hasAttribute(qualifiedName);
47
122
  }
48
- return super.hasAttribute(qualifiedName);
49
123
  }
50
124
  setAttribute(qualifiedName, value) {
51
- if (qualifiedName === "id") {
52
- this.id = value;
53
- return;
125
+ switch (qualifiedName) {
126
+ case "id":
127
+ this.id = value;
128
+ break;
129
+ case "title":
130
+ this.title = value;
131
+ break;
132
+ case "aria-label":
133
+ this.ariaLabel = value;
134
+ break;
135
+ case "aria-labelledby":
136
+ this.ariaLabelledBy = value;
137
+ break;
138
+ case "aria-describedby":
139
+ this.ariaDescribedBy = value;
140
+ break;
141
+ default:
142
+ super.setAttribute(qualifiedName, value);
54
143
  }
55
- super.setAttribute(qualifiedName, value);
56
144
  }
57
145
  removeAttribute(qualifiedName) {
58
- if (qualifiedName === "id") {
59
- this.id = "";
60
- return;
146
+ switch (qualifiedName) {
147
+ case "id":
148
+ this.id = "";
149
+ break;
150
+ case "title":
151
+ this.title = "";
152
+ break;
153
+ case "aria-label":
154
+ this.ariaLabel = null;
155
+ break;
156
+ case "aria-labelledby":
157
+ this.ariaLabelledBy = null;
158
+ break;
159
+ case "aria-describedby":
160
+ this.ariaDescribedBy = null;
161
+ break;
162
+ default:
163
+ super.removeAttribute(qualifiedName);
164
+ }
165
+ }
166
+ _removeHostAttribute(name) {
167
+ const host = this;
168
+ if (HTMLElement.prototype.hasAttribute.call(host, name)) {
169
+ HTMLElement.prototype.removeAttribute.call(host, name);
61
170
  }
62
- super.removeAttribute(qualifiedName);
63
171
  }
64
172
  get forwardedAriaLabel() {
65
173
  const value = this.ariaLabel?.trim();
@@ -74,11 +182,7 @@ var SpectreBaseElement = class extends LitElement {
74
182
  return value ? value : void 0;
75
183
  }
76
184
  };
77
- SpectreBaseElement.properties = {
78
- ariaLabel: { attribute: "aria-label", type: String },
79
- ariaLabelledBy: { attribute: "aria-labelledby", type: String },
80
- ariaDescribedBy: { attribute: "aria-describedby", type: String }
81
- };
185
+ SpectreBaseElement.properties = {};
82
186
 
83
187
  // src/utils/dom.ts
84
188
  function hasMeaningfulContent(nodes) {
@@ -139,9 +243,9 @@ var SpectreProjectableElement = class extends SpectreBaseElement {
139
243
  }
140
244
  this.contentObserver = new MutationObserver((mutations) => {
141
245
  const isInternalMovement = mutations.every(
142
- (mutation) => Array.from(mutation.removedNodes).every(
246
+ (mutation) => [...mutation.removedNodes].every(
143
247
  (node) => this.isInternalNode(node) || this.contains(node)
144
- ) && Array.from(mutation.addedNodes).every((node) => this.isInternalNode(node))
248
+ ) && [...mutation.addedNodes].every((node) => this.isInternalNode(node))
145
249
  );
146
250
  if (isInternalMovement) {
147
251
  return;
@@ -160,10 +264,6 @@ var SpectreProjectableElement = class extends SpectreBaseElement {
160
264
 
161
265
  // src/components/label/sp-label.ts
162
266
  var SpectreLabelElement = class extends SpectreProjectableElement {
163
- constructor() {
164
- super(...arguments);
165
- this.title = "";
166
- }
167
267
  getContentContainer() {
168
268
  return this.querySelector("[data-sp-label-native]");
169
269
  }
@@ -181,26 +281,22 @@ var SpectreLabelElement = class extends SpectreProjectableElement {
181
281
  this.getContentContainer()?.blur();
182
282
  }
183
283
  render() {
184
- return html`
185
- <label
186
- aria-describedby=${ifDefined(this.forwardedAriaDescribedBy)}
187
- aria-label=${ifDefined(this.forwardedAriaLabel)}
188
- aria-labelledby=${ifDefined(this.forwardedAriaLabelledBy)}
189
- class='sp-label'
190
- data-sp-label-native
191
- for=${ifDefined(this.htmlFor)}
192
- id=${ifDefined(this.id || void 0)}
193
- tabindex='-1'
194
- title=${ifDefined(this.title || void 0)}
195
- >
196
- ${this.hasProjectedContent ? this.projectedContent : nothing}
197
- </label>
198
- `;
284
+ return html`<label
285
+ aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
286
+ aria-label="${ifDefined(this.forwardedAriaLabel)}"
287
+ aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
288
+ class="sp-label"
289
+ data-sp-label-native
290
+ for="${ifDefined(this.htmlFor || void 0)}"
291
+ id="${ifDefined(this.id || void 0)}"
292
+ title="${ifDefined(this.title || void 0)}"
293
+ >
294
+ ${this.hasProjectedContent ? this.projectedContent : nothing}
295
+ </label>`;
199
296
  }
200
297
  };
201
298
  SpectreLabelElement.properties = {
202
- htmlFor: { attribute: "for", type: String, reflect: true },
203
- title: { type: String, reflect: true }
299
+ htmlFor: { attribute: "for", type: String, reflect: true }
204
300
  };
205
301
  function defineSpectreLabel(tagName = "sp-label") {
206
302
  const existingElement = customElements.get(tagName);
package/dist/label.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/base.ts","../src/utils/dom.ts","../src/utils/projectable.ts","../src/components/label/sp-label.ts"],"names":[],"mappings":";;;;AAEO,IAAM,kBAAA,GAAN,cAAiC,UAAA,CAAW;AAAA,EAA5C,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAOL,IAAA,IAAA,CAAA,SAAA,GAA2B,IAAA;AAC3B,IAAA,IAAA,CAAA,cAAA,GAAgC,IAAA;AAChC,IAAA,IAAA,CAAA,eAAA,GAAiC,IAAA;AAAA,EAAA;AAAA,EAIjC,IAAa,EAAA,GAAa;AACxB,IAAA,OAAO,KAAK,GAAA,IAAO,EAAA;AAAA,EACrB;AAAA,EAEA,IAAa,GAAG,KAAA,EAAe;AAC7B,IAAA,IAAA,CAAK,IAAA,CAAK,GAAA,IAAO,EAAA,MAAQ,KAAA,EAAO;AAC9B,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,GAAA,GAA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AA;AAAA,IAAA,CAAA;AAAA,EAGlE;AACF;AA/Ca,mBAAA,CACJ,UAAA,GAAa;AAAA,EAClB,SAAS,EAAE,SAAA,EAAW,OAAO,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACzD,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA;AAClC,CAAA;AA6CK,SAAS,kBAAA,CAAmB,UAAU,UAAA,EAAwC;AACnF,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,mBAAmB,CAAA;AAClD,EAAA,OAAO,mBAAA;AACT","file":"label.js","sourcesContent":["import { LitElement, type PropertyDeclarations } from 'lit';\n\nexport class SpectreBaseElement extends LitElement {\n static properties: PropertyDeclarations = {\n ariaLabel: { attribute: 'aria-label', type: String },\n ariaLabelledBy: { attribute: 'aria-labelledby', type: String },\n ariaDescribedBy: { attribute: 'aria-describedby', type: String },\n };\n\n ariaLabel: string | null = null;\n ariaLabelledBy: string | null = null;\n ariaDescribedBy: string | null = null;\n\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 // 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 hostId = super.getAttribute('id');\n if (hostId !== null) {\n this.id = hostId;\n }\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 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 Array.from(mutation.removedNodes).every(\n (node) => this.isInternalNode(node) || this.contains(node),\n ) &&\n Array.from(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 } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { SpectreProjectableElement } from '../../utils/projectable';\n\nexport interface SpectreLabelProps {\n ariaLabel?: string | null;\n ariaLabelledBy?: string | null;\n ariaDescribedBy?: string | null;\n htmlFor?: string;\n title?: string;\n}\n\nexport class SpectreLabelElement extends SpectreProjectableElement implements SpectreLabelProps {\n static properties = {\n htmlFor: { attribute: 'for', type: String, reflect: true },\n title: { type: String, reflect: true },\n };\n\n htmlFor?: string;\n override title = '';\n\n protected override getContentContainer(): Element | null {\n return this.querySelector('[data-sp-label-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-label-native');\n }\n\n override focus(options?: FocusOptions): void {\n (this.getContentContainer() as HTMLLabelElement | null)?.focus(options);\n }\n\n override blur(): void {\n (this.getContentContainer() as HTMLLabelElement | null)?.blur();\n }\n\n override render() {\n return html`\n <label\n aria-describedby=${ifDefined(this.forwardedAriaDescribedBy)}\n aria-label=${ifDefined(this.forwardedAriaLabel)}\n aria-labelledby=${ifDefined(this.forwardedAriaLabelledBy)}\n class='sp-label'\n data-sp-label-native\n for=${ifDefined(this.htmlFor)}\n id=${ifDefined(this.id || undefined)}\n tabindex='-1'\n title=${ifDefined(this.title || undefined)}\n >\n ${this.hasProjectedContent ? this.projectedContent : nothing}\n </label>\n `;\n }\n}\n\nexport function defineSpectreLabel(tagName = 'sp-label'): typeof SpectreLabelElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreLabelElement;\n }\n\n customElements.define(tagName, SpectreLabelElement);\n return SpectreLabelElement;\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/base.ts","../src/utils/dom.ts","../src/utils/projectable.ts","../src/components/label/sp-label.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,CA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AAAA;AAAA,MAAA,EAEzC,IAAA,CAAK,mBAAA,GAAsB,IAAA,CAAK,gBAAA,GAAmB,OAAO;AAAA,YAAA,CAAA;AAAA,EAEhE;AACF;AA1Ca,mBAAA,CACJ,UAAA,GAAa;AAAA,EAClB,SAAS,EAAE,SAAA,EAAW,OAAO,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA;AACtD,CAAA;AAyCK,SAAS,kBAAA,CAAmB,UAAU,UAAA,EAAwC;AACnF,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,mBAAmB,CAAA;AAClD,EAAA,OAAO,mBAAA;AACT","file":"label.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 } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { SpectreProjectableElement } from '../../utils/projectable';\n\nexport interface SpectreLabelProps {\n ariaLabel: string | null;\n ariaLabelledBy: string | null;\n ariaDescribedBy: string | null;\n htmlFor?: string | undefined;\n title?: string | undefined;\n}\n\nexport class SpectreLabelElement extends SpectreProjectableElement implements SpectreLabelProps {\n static properties = {\n htmlFor: { attribute: 'for', type: String, reflect: true },\n };\n\n htmlFor: string | undefined;\n\n protected override getContentContainer(): Element | null {\n return this.querySelector('[data-sp-label-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-label-native');\n }\n\n override focus(options?: FocusOptions): void {\n (this.getContentContainer() as HTMLLabelElement | null)?.focus(options);\n }\n\n override blur(): void {\n (this.getContentContainer() as HTMLLabelElement | null)?.blur();\n }\n\n override render() {\n return html`<label\n aria-describedby=\"${ifDefined(this.forwardedAriaDescribedBy)}\"\n aria-label=\"${ifDefined(this.forwardedAriaLabel)}\"\n aria-labelledby=\"${ifDefined(this.forwardedAriaLabelledBy)}\"\n class=\"sp-label\"\n data-sp-label-native\n for=\"${ifDefined(this.htmlFor || undefined)}\"\n id=\"${ifDefined(this.id || undefined)}\"\n title=\"${ifDefined(this.title || undefined)}\"\n >\n ${this.hasProjectedContent ? this.projectedContent : nothing}\n </label>`;\n }\n}\n\nexport function defineSpectreLabel(tagName = 'sp-label'): typeof SpectreLabelElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreLabelElement;\n }\n\n customElements.define(tagName, SpectreLabelElement);\n return SpectreLabelElement;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { S as SpectreBaseElement } from './base-DQtCQ-dP.cjs';
1
+ import { S as SpectreBaseElement } from './base-2rD8EmdC.cjs';
2
2
 
3
3
  declare abstract class SpectreProjectableElement extends SpectreBaseElement {
4
4
  protected projectedContent: Node[];
@@ -1,4 +1,4 @@
1
- import { S as SpectreBaseElement } from './base-DQtCQ-dP.js';
1
+ import { S as SpectreBaseElement } from './base-2rD8EmdC.js';
2
2
 
3
3
  declare abstract class SpectreProjectableElement extends SpectreBaseElement {
4
4
  protected projectedContent: Node[];
package/dist/radio.cjs CHANGED
@@ -8,22 +8,67 @@ var ifDefined_js = require('lit/directives/if-defined.js');
8
8
  var SpectreBaseElement = class extends lit.LitElement {
9
9
  constructor() {
10
10
  super(...arguments);
11
- this.ariaLabel = null;
12
- this.ariaLabelledBy = null;
13
- this.ariaDescribedBy = null;
11
+ this._ariaLabel = null;
12
+ this._ariaLabelledBy = null;
13
+ this._ariaDescribedBy = null;
14
+ this._title = "";
15
+ this._id = "";
16
+ }
17
+ get ariaLabel() {
18
+ return this._ariaLabel;
19
+ }
20
+ set ariaLabel(value) {
21
+ if (this._ariaLabel === value) {
22
+ return;
23
+ }
24
+ this._ariaLabel = value;
25
+ this._removeHostAttribute("aria-label");
26
+ this.requestUpdate();
27
+ }
28
+ get ariaLabelledBy() {
29
+ return this._ariaLabelledBy;
30
+ }
31
+ set ariaLabelledBy(value) {
32
+ if (this._ariaLabelledBy === value) {
33
+ return;
34
+ }
35
+ this._ariaLabelledBy = value;
36
+ this._removeHostAttribute("aria-labelledby");
37
+ this.requestUpdate();
38
+ }
39
+ get ariaDescribedBy() {
40
+ return this._ariaDescribedBy;
41
+ }
42
+ set ariaDescribedBy(value) {
43
+ if (this._ariaDescribedBy === value) {
44
+ return;
45
+ }
46
+ this._ariaDescribedBy = value;
47
+ this._removeHostAttribute("aria-describedby");
48
+ this.requestUpdate();
49
+ }
50
+ get title() {
51
+ return this._title;
52
+ }
53
+ set title(value) {
54
+ const normalizedValue = value ?? "";
55
+ if (this._title === normalizedValue) {
56
+ return;
57
+ }
58
+ this._title = normalizedValue;
59
+ this._removeHostAttribute("title");
60
+ this.requestUpdate();
14
61
  }
15
62
  get id() {
16
- return this._id ?? "";
63
+ return this._id;
17
64
  }
18
65
  set id(value) {
19
- if ((this._id ?? "") === value) {
66
+ const normalizedValue = value ?? "";
67
+ if (this._id === normalizedValue) {
20
68
  return;
21
69
  }
22
- this._id = value;
23
- const host = this;
24
- if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
25
- HTMLElement.prototype.removeAttribute.call(host, "id");
26
- }
70
+ this._id = normalizedValue;
71
+ this._removeHostAttribute("id");
27
72
  this.requestUpdate();
28
73
  }
29
74
  // Spectre components intentionally render in light DOM so the global
@@ -33,36 +78,99 @@ var SpectreBaseElement = class extends lit.LitElement {
33
78
  }
34
79
  connectedCallback() {
35
80
  super.connectedCallback();
36
- const hostId = super.getAttribute("id");
37
- if (hostId !== null) {
38
- this.id = hostId;
39
- }
81
+ const proxiedAttributes = [
82
+ "id",
83
+ "title",
84
+ "aria-label",
85
+ "aria-labelledby",
86
+ "aria-describedby"
87
+ ];
88
+ proxiedAttributes.forEach((attr) => {
89
+ const value = super.getAttribute(attr);
90
+ if (value !== null) {
91
+ this.setAttribute(attr, value);
92
+ }
93
+ });
40
94
  }
41
95
  getAttribute(qualifiedName) {
42
- if (qualifiedName === "id") {
43
- return this.id || null;
96
+ switch (qualifiedName) {
97
+ case "id":
98
+ return this.id || null;
99
+ case "title":
100
+ return this.title || null;
101
+ case "aria-label":
102
+ return this.ariaLabel;
103
+ case "aria-labelledby":
104
+ return this.ariaLabelledBy;
105
+ case "aria-describedby":
106
+ return this.ariaDescribedBy;
107
+ default:
108
+ return super.getAttribute(qualifiedName);
44
109
  }
45
- return super.getAttribute(qualifiedName);
46
110
  }
47
111
  hasAttribute(qualifiedName) {
48
- if (qualifiedName === "id") {
49
- return this.id !== "";
112
+ switch (qualifiedName) {
113
+ case "id":
114
+ return this.id !== "";
115
+ case "title":
116
+ return this.title !== "";
117
+ case "aria-label":
118
+ return this.ariaLabel !== null;
119
+ case "aria-labelledby":
120
+ return this.ariaLabelledBy !== null;
121
+ case "aria-describedby":
122
+ return this.ariaDescribedBy !== null;
123
+ default:
124
+ return super.hasAttribute(qualifiedName);
50
125
  }
51
- return super.hasAttribute(qualifiedName);
52
126
  }
53
127
  setAttribute(qualifiedName, value) {
54
- if (qualifiedName === "id") {
55
- this.id = value;
56
- return;
128
+ switch (qualifiedName) {
129
+ case "id":
130
+ this.id = value;
131
+ break;
132
+ case "title":
133
+ this.title = value;
134
+ break;
135
+ case "aria-label":
136
+ this.ariaLabel = value;
137
+ break;
138
+ case "aria-labelledby":
139
+ this.ariaLabelledBy = value;
140
+ break;
141
+ case "aria-describedby":
142
+ this.ariaDescribedBy = value;
143
+ break;
144
+ default:
145
+ super.setAttribute(qualifiedName, value);
57
146
  }
58
- super.setAttribute(qualifiedName, value);
59
147
  }
60
148
  removeAttribute(qualifiedName) {
61
- if (qualifiedName === "id") {
62
- this.id = "";
63
- return;
149
+ switch (qualifiedName) {
150
+ case "id":
151
+ this.id = "";
152
+ break;
153
+ case "title":
154
+ this.title = "";
155
+ break;
156
+ case "aria-label":
157
+ this.ariaLabel = null;
158
+ break;
159
+ case "aria-labelledby":
160
+ this.ariaLabelledBy = null;
161
+ break;
162
+ case "aria-describedby":
163
+ this.ariaDescribedBy = null;
164
+ break;
165
+ default:
166
+ super.removeAttribute(qualifiedName);
167
+ }
168
+ }
169
+ _removeHostAttribute(name) {
170
+ const host = this;
171
+ if (HTMLElement.prototype.hasAttribute.call(host, name)) {
172
+ HTMLElement.prototype.removeAttribute.call(host, name);
64
173
  }
65
- super.removeAttribute(qualifiedName);
66
174
  }
67
175
  get forwardedAriaLabel() {
68
176
  const value = this.ariaLabel?.trim();
@@ -77,11 +185,7 @@ var SpectreBaseElement = class extends lit.LitElement {
77
185
  return value ? value : void 0;
78
186
  }
79
187
  };
80
- SpectreBaseElement.properties = {
81
- ariaLabel: { attribute: "aria-label", type: String },
82
- ariaLabelledBy: { attribute: "aria-labelledby", type: String },
83
- ariaDescribedBy: { attribute: "aria-describedby", type: String }
84
- };
188
+ SpectreBaseElement.properties = {};
85
189
 
86
190
  // src/utils/dom.ts
87
191
  function hasMeaningfulContent(nodes) {
@@ -142,9 +246,9 @@ var SpectreProjectableElement = class extends SpectreBaseElement {
142
246
  }
143
247
  this.contentObserver = new MutationObserver((mutations) => {
144
248
  const isInternalMovement = mutations.every(
145
- (mutation) => Array.from(mutation.removedNodes).every(
249
+ (mutation) => [...mutation.removedNodes].every(
146
250
  (node) => this.isInternalNode(node) || this.contains(node)
147
- ) && Array.from(mutation.addedNodes).every((node) => this.isInternalNode(node))
251
+ ) && [...mutation.addedNodes].every((node) => this.isInternalNode(node))
148
252
  );
149
253
  if (isInternalMovement) {
150
254
  return;
@@ -172,7 +276,6 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
172
276
  this.loading = false;
173
277
  this.required = false;
174
278
  this.success = false;
175
- this.title = "";
176
279
  this.value = "on";
177
280
  }
178
281
  getContentContainer() {
@@ -215,33 +318,31 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
215
318
  this.nativeInput?.blur();
216
319
  }
217
320
  render() {
218
- const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? lit.html`<span class='sp-label' data-sp-radio-label-fallback>${this.visibleLabelFallback}</span>` : lit.nothing;
219
- return lit.html`
220
- <label data-sp-radio-label>
221
- <input
222
- aria-busy=${this.loading ? "true" : "false"}
223
- aria-describedby=${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}
224
- aria-invalid=${ifDefined_js.ifDefined(this.invalid ? "true" : void 0)}
225
- aria-label=${ifDefined_js.ifDefined(this.forwardedAriaLabel)}
226
- aria-labelledby=${ifDefined_js.ifDefined(this.forwardedAriaLabelledBy)}
227
- ?autofocus=${this.autofocus}
228
- data-sp-radio-native
229
- .checked=${live_js.live(this.checked)}
230
- ?disabled=${this.isDisabled}
231
- form=${ifDefined_js.ifDefined(this.form)}
232
- id=${ifDefined_js.ifDefined(this.id || void 0)}
233
- name=${ifDefined_js.ifDefined(this.name)}
234
- ?required=${this.required}
235
- title=${ifDefined_js.ifDefined(this.title || void 0)}
236
- type='radio'
237
- value=${ifDefined_js.ifDefined(this.value || void 0)}
238
- @change=${this.handleChange}
239
- @input=${this.handleInput}
240
- />
241
- <span class="sp-radio-indicator" data-sp-radio-indicator></span>
242
- ${labelContent}
243
- </label>
244
- `;
321
+ const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? lit.html`<span class="sp-label" data-sp-radio-label-fallback>${this.visibleLabelFallback}</span>` : lit.nothing;
322
+ return lit.html`<label data-sp-radio-label>
323
+ <input
324
+ aria-busy="${this.loading ? "true" : "false"}"
325
+ aria-describedby="${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}"
326
+ aria-invalid="${ifDefined_js.ifDefined(this.invalid ? "true" : void 0)}"
327
+ aria-label="${ifDefined_js.ifDefined(this.forwardedAriaLabel)}"
328
+ aria-labelledby="${ifDefined_js.ifDefined(this.forwardedAriaLabelledBy)}"
329
+ ?autofocus="${this.autofocus}"
330
+ data-sp-radio-native
331
+ .checked="${live_js.live(this.checked)}"
332
+ ?disabled="${this.isDisabled}"
333
+ form="${ifDefined_js.ifDefined(this.form || void 0)}"
334
+ id="${ifDefined_js.ifDefined(this.id || void 0)}"
335
+ name="${ifDefined_js.ifDefined(this.name || void 0)}"
336
+ ?required="${this.required}"
337
+ title="${ifDefined_js.ifDefined(this.title || void 0)}"
338
+ type="radio"
339
+ value="${ifDefined_js.ifDefined(this.value)}"
340
+ @change="${this.handleChange}"
341
+ @input="${this.handleInput}"
342
+ />
343
+ <span class="sp-radio-indicator" data-sp-radio-indicator></span>
344
+ ${labelContent}
345
+ </label>`;
245
346
  }
246
347
  };
247
348
  SpectreRadioElement.properties = {
@@ -255,7 +356,6 @@ SpectreRadioElement.properties = {
255
356
  name: { type: String, reflect: true },
256
357
  required: { type: Boolean, reflect: true },
257
358
  success: { type: Boolean, reflect: true },
258
- title: { type: String, reflect: true },
259
359
  value: { type: String }
260
360
  };
261
361
  function defineSpectreRadio(tagName = "sp-radio") {