@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.
- package/README.md +113 -40
- package/dist/{base-DQtCQ-dP.d.cts → base-2rD8EmdC.d.cts} +15 -5
- package/dist/{base-DQtCQ-dP.d.ts → base-2rD8EmdC.d.ts} +15 -5
- package/dist/button.cjs +158 -58
- package/dist/button.cjs.map +1 -1
- package/dist/button.d.cts +22 -28
- package/dist/button.d.ts +22 -28
- package/dist/button.js +158 -58
- package/dist/button.js.map +1 -1
- package/dist/checkbox.cjs +164 -64
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.d.cts +18 -23
- package/dist/checkbox.d.ts +18 -23
- package/dist/checkbox.js +164 -64
- package/dist/checkbox.js.map +1 -1
- package/dist/fieldset.cjs +154 -55
- package/dist/fieldset.cjs.map +1 -1
- package/dist/fieldset.d.cts +13 -18
- package/dist/fieldset.d.ts +13 -18
- package/dist/fieldset.js +154 -55
- package/dist/fieldset.js.map +1 -1
- package/dist/index.cjs +324 -261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +324 -261
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +174 -72
- package/dist/input.cjs.map +1 -1
- package/dist/input.d.cts +33 -38
- package/dist/input.d.ts +33 -38
- package/dist/input.js +174 -72
- package/dist/input.js.map +1 -1
- package/dist/label.cjs +152 -56
- package/dist/label.cjs.map +1 -1
- package/dist/label.d.cts +8 -13
- package/dist/label.d.ts +8 -13
- package/dist/label.js +152 -56
- package/dist/label.js.map +1 -1
- package/dist/{projectable-DcnBRiko.d.cts → projectable-BzDQ4xp_.d.cts} +1 -1
- package/dist/{projectable-SzbPvXfM.d.ts → projectable-s3SgvjGX.d.ts} +1 -1
- package/dist/radio.cjs +164 -64
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.d.cts +18 -23
- package/dist/radio.d.ts +18 -23
- package/dist/radio.js +164 -64
- package/dist/radio.js.map +1 -1
- package/dist/select.cjs +161 -61
- package/dist/select.cjs.map +1 -1
- package/dist/select.d.cts +22 -27
- package/dist/select.d.ts +22 -27
- package/dist/select.js +161 -61
- package/dist/select.js.map +1 -1
- package/dist/textarea.cjs +172 -72
- package/dist/textarea.cjs.map +1 -1
- package/dist/textarea.d.cts +27 -32
- package/dist/textarea.d.ts +27 -32
- package/dist/textarea.js +172 -72
- package/dist/textarea.js.map +1 -1
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -7,22 +7,67 @@ import { live } from 'lit/directives/live.js';
|
|
|
7
7
|
var SpectreBaseElement = class extends LitElement {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
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();
|
|
13
60
|
}
|
|
14
61
|
get id() {
|
|
15
|
-
return this._id
|
|
62
|
+
return this._id;
|
|
16
63
|
}
|
|
17
64
|
set id(value) {
|
|
18
|
-
|
|
65
|
+
const normalizedValue = value ?? "";
|
|
66
|
+
if (this._id === normalizedValue) {
|
|
19
67
|
return;
|
|
20
68
|
}
|
|
21
|
-
this._id =
|
|
22
|
-
|
|
23
|
-
if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
|
|
24
|
-
HTMLElement.prototype.removeAttribute.call(host, "id");
|
|
25
|
-
}
|
|
69
|
+
this._id = normalizedValue;
|
|
70
|
+
this._removeHostAttribute("id");
|
|
26
71
|
this.requestUpdate();
|
|
27
72
|
}
|
|
28
73
|
// Spectre components intentionally render in light DOM so the global
|
|
@@ -32,36 +77,99 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
32
77
|
}
|
|
33
78
|
connectedCallback() {
|
|
34
79
|
super.connectedCallback();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
});
|
|
39
93
|
}
|
|
40
94
|
getAttribute(qualifiedName) {
|
|
41
|
-
|
|
42
|
-
|
|
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);
|
|
43
108
|
}
|
|
44
|
-
return super.getAttribute(qualifiedName);
|
|
45
109
|
}
|
|
46
110
|
hasAttribute(qualifiedName) {
|
|
47
|
-
|
|
48
|
-
|
|
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);
|
|
49
124
|
}
|
|
50
|
-
return super.hasAttribute(qualifiedName);
|
|
51
125
|
}
|
|
52
126
|
setAttribute(qualifiedName, value) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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);
|
|
56
145
|
}
|
|
57
|
-
super.setAttribute(qualifiedName, value);
|
|
58
146
|
}
|
|
59
147
|
removeAttribute(qualifiedName) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
_removeHostAttribute(name) {
|
|
169
|
+
const host = this;
|
|
170
|
+
if (HTMLElement.prototype.hasAttribute.call(host, name)) {
|
|
171
|
+
HTMLElement.prototype.removeAttribute.call(host, name);
|
|
63
172
|
}
|
|
64
|
-
super.removeAttribute(qualifiedName);
|
|
65
173
|
}
|
|
66
174
|
get forwardedAriaLabel() {
|
|
67
175
|
const value = this.ariaLabel?.trim();
|
|
@@ -76,11 +184,7 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
76
184
|
return value ? value : void 0;
|
|
77
185
|
}
|
|
78
186
|
};
|
|
79
|
-
SpectreBaseElement.properties = {
|
|
80
|
-
ariaLabel: { attribute: "aria-label", type: String },
|
|
81
|
-
ariaLabelledBy: { attribute: "aria-labelledby", type: String },
|
|
82
|
-
ariaDescribedBy: { attribute: "aria-describedby", type: String }
|
|
83
|
-
};
|
|
187
|
+
SpectreBaseElement.properties = {};
|
|
84
188
|
|
|
85
189
|
// src/utils/dom.ts
|
|
86
190
|
function hasMeaningfulContent(nodes) {
|
|
@@ -141,9 +245,9 @@ var SpectreProjectableElement = class extends SpectreBaseElement {
|
|
|
141
245
|
}
|
|
142
246
|
this.contentObserver = new MutationObserver((mutations) => {
|
|
143
247
|
const isInternalMovement = mutations.every(
|
|
144
|
-
(mutation) =>
|
|
248
|
+
(mutation) => [...mutation.removedNodes].every(
|
|
145
249
|
(node) => this.isInternalNode(node) || this.contains(node)
|
|
146
|
-
) &&
|
|
250
|
+
) && [...mutation.addedNodes].every((node) => this.isInternalNode(node))
|
|
147
251
|
);
|
|
148
252
|
if (isInternalMovement) {
|
|
149
253
|
return;
|
|
@@ -189,7 +293,6 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
189
293
|
this.loadingLabel = "Loading";
|
|
190
294
|
this.pill = false;
|
|
191
295
|
this.size = "md";
|
|
192
|
-
this.title = "";
|
|
193
296
|
this.type = "button";
|
|
194
297
|
this.variant = "primary";
|
|
195
298
|
this.value = "";
|
|
@@ -256,26 +359,24 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
256
359
|
return this.visibleLabelFallback ? html`<span data-sp-button-label-fallback>${this.visibleLabelFallback}</span>` : nothing;
|
|
257
360
|
}
|
|
258
361
|
render() {
|
|
259
|
-
return html
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
</button>
|
|
278
|
-
`;
|
|
362
|
+
return html`<button
|
|
363
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
364
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
365
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
366
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
367
|
+
?autofocus="${this.autofocus}"
|
|
368
|
+
class="${this.buttonClasses}"
|
|
369
|
+
data-sp-button-native
|
|
370
|
+
?disabled="${this.isDisabled}"
|
|
371
|
+
form="${ifDefined(this.form || void 0)}"
|
|
372
|
+
id="${ifDefined(this.id || void 0)}"
|
|
373
|
+
name="${ifDefined(this.name || void 0)}"
|
|
374
|
+
title="${ifDefined(this.title || void 0)}"
|
|
375
|
+
type="${this.type}"
|
|
376
|
+
value="${ifDefined(this.value || void 0)}"
|
|
377
|
+
>
|
|
378
|
+
${this.renderButtonContent()}
|
|
379
|
+
</button>`;
|
|
279
380
|
}
|
|
280
381
|
};
|
|
281
382
|
SpectreButtonElement.properties = {
|
|
@@ -289,10 +390,9 @@ SpectreButtonElement.properties = {
|
|
|
289
390
|
name: { type: String, reflect: true },
|
|
290
391
|
pill: { type: Boolean, reflect: true },
|
|
291
392
|
size: { type: String, reflect: true },
|
|
292
|
-
title: { type: String, reflect: true },
|
|
293
393
|
type: { type: String, reflect: true },
|
|
294
394
|
variant: { type: String, reflect: true },
|
|
295
|
-
value: { type: String
|
|
395
|
+
value: { type: String }
|
|
296
396
|
};
|
|
297
397
|
function defineSpectreButton(tagName = "sp-button") {
|
|
298
398
|
const existingElement = customElements.get(tagName);
|
|
@@ -323,6 +423,12 @@ var spectreInputTypes = [
|
|
|
323
423
|
function isInputType(value) {
|
|
324
424
|
return spectreInputTypes.includes(value);
|
|
325
425
|
}
|
|
426
|
+
function normalizeInt(value, fallback, min = 0) {
|
|
427
|
+
if (value == null || typeof value !== "number" || !Number.isInteger(value) || value < min) {
|
|
428
|
+
return fallback;
|
|
429
|
+
}
|
|
430
|
+
return value;
|
|
431
|
+
}
|
|
326
432
|
var SpectreInputElement = class extends SpectreBaseElement {
|
|
327
433
|
constructor() {
|
|
328
434
|
super(...arguments);
|
|
@@ -336,7 +442,6 @@ var SpectreInputElement = class extends SpectreBaseElement {
|
|
|
336
442
|
this.required = false;
|
|
337
443
|
this.size = "md";
|
|
338
444
|
this.success = false;
|
|
339
|
-
this.title = "";
|
|
340
445
|
this.type = "text";
|
|
341
446
|
this.value = "";
|
|
342
447
|
}
|
|
@@ -351,14 +456,10 @@ var SpectreInputElement = class extends SpectreBaseElement {
|
|
|
351
456
|
this.value = "";
|
|
352
457
|
}
|
|
353
458
|
if (changedProperties.has("maxlength")) {
|
|
354
|
-
|
|
355
|
-
this.maxlength = void 0;
|
|
356
|
-
}
|
|
459
|
+
this.maxlength = normalizeInt(this.maxlength, void 0);
|
|
357
460
|
}
|
|
358
461
|
if (changedProperties.has("minlength")) {
|
|
359
|
-
|
|
360
|
-
this.minlength = void 0;
|
|
361
|
-
}
|
|
462
|
+
this.minlength = normalizeInt(this.minlength, void 0);
|
|
362
463
|
}
|
|
363
464
|
}
|
|
364
465
|
get inputClasses() {
|
|
@@ -390,37 +491,35 @@ var SpectreInputElement = class extends SpectreBaseElement {
|
|
|
390
491
|
this.nativeInput?.blur();
|
|
391
492
|
}
|
|
392
493
|
render() {
|
|
393
|
-
return html
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
/>
|
|
423
|
-
`;
|
|
494
|
+
return html`<input
|
|
495
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
496
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
497
|
+
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
498
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
499
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
500
|
+
autocomplete="${ifDefined(this.autocomplete || void 0)}"
|
|
501
|
+
?autofocus="${this.autofocus}"
|
|
502
|
+
class="${this.inputClasses}"
|
|
503
|
+
data-sp-input-native
|
|
504
|
+
?disabled="${this.isDisabled}"
|
|
505
|
+
form="${ifDefined(this.form || void 0)}"
|
|
506
|
+
?readonly="${this.readonly}"
|
|
507
|
+
?required="${this.required}"
|
|
508
|
+
id="${ifDefined(this.id || void 0)}"
|
|
509
|
+
inputmode="${ifDefined(this.inputmode || void 0)}"
|
|
510
|
+
max="${ifDefined(this.max || void 0)}"
|
|
511
|
+
maxlength="${ifDefined(this.maxlength)}"
|
|
512
|
+
min="${ifDefined(this.min || void 0)}"
|
|
513
|
+
minlength="${ifDefined(this.minlength)}"
|
|
514
|
+
name="${ifDefined(this.name || void 0)}"
|
|
515
|
+
placeholder="${ifDefined(this.placeholder || void 0)}"
|
|
516
|
+
step="${ifDefined(this.step || void 0)}"
|
|
517
|
+
title="${ifDefined(this.title || void 0)}"
|
|
518
|
+
type="${this.type}"
|
|
519
|
+
.value="${live(this.value)}"
|
|
520
|
+
@change="${this.handleChange}"
|
|
521
|
+
@input="${this.handleInput}"
|
|
522
|
+
/>`;
|
|
424
523
|
}
|
|
425
524
|
};
|
|
426
525
|
SpectreInputElement.properties = {
|
|
@@ -444,7 +543,6 @@ SpectreInputElement.properties = {
|
|
|
444
543
|
size: { type: String, reflect: true },
|
|
445
544
|
step: { type: String, reflect: true },
|
|
446
545
|
success: { type: Boolean, reflect: true },
|
|
447
|
-
title: { type: String, reflect: true },
|
|
448
546
|
type: { type: String, reflect: true },
|
|
449
547
|
value: { type: String }
|
|
450
548
|
};
|
|
@@ -471,7 +569,6 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
471
569
|
this.rows = DEFAULT_ROWS;
|
|
472
570
|
this.size = "md";
|
|
473
571
|
this.success = false;
|
|
474
|
-
this.title = "";
|
|
475
572
|
this.value = "";
|
|
476
573
|
}
|
|
477
574
|
willUpdate(changedProperties) {
|
|
@@ -479,22 +576,16 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
479
576
|
this.size = "md";
|
|
480
577
|
}
|
|
481
578
|
if (changedProperties.has("rows")) {
|
|
482
|
-
|
|
483
|
-
this.rows = DEFAULT_ROWS;
|
|
484
|
-
}
|
|
579
|
+
this.rows = normalizeInt(this.rows, DEFAULT_ROWS, 1);
|
|
485
580
|
}
|
|
486
581
|
if (changedProperties.has("value") && this.value == null) {
|
|
487
582
|
this.value = "";
|
|
488
583
|
}
|
|
489
584
|
if (changedProperties.has("maxlength")) {
|
|
490
|
-
|
|
491
|
-
this.maxlength = void 0;
|
|
492
|
-
}
|
|
585
|
+
this.maxlength = normalizeInt(this.maxlength, void 0);
|
|
493
586
|
}
|
|
494
587
|
if (changedProperties.has("minlength")) {
|
|
495
|
-
|
|
496
|
-
this.minlength = void 0;
|
|
497
|
-
}
|
|
588
|
+
this.minlength = normalizeInt(this.minlength, void 0);
|
|
498
589
|
}
|
|
499
590
|
}
|
|
500
591
|
get textareaClasses() {
|
|
@@ -526,34 +617,32 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
526
617
|
this.nativeTextarea?.blur();
|
|
527
618
|
}
|
|
528
619
|
render() {
|
|
529
|
-
return html
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
></textarea>
|
|
556
|
-
`;
|
|
620
|
+
return html`<textarea
|
|
621
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
622
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
623
|
+
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
624
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
625
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
626
|
+
autocomplete="${ifDefined(this.autocomplete || void 0)}"
|
|
627
|
+
?autofocus="${this.autofocus}"
|
|
628
|
+
class="${this.textareaClasses}"
|
|
629
|
+
data-sp-textarea-native
|
|
630
|
+
?disabled="${this.isDisabled}"
|
|
631
|
+
form="${ifDefined(this.form || void 0)}"
|
|
632
|
+
inputmode="${ifDefined(this.inputmode || void 0)}"
|
|
633
|
+
?readonly="${this.readonly}"
|
|
634
|
+
?required="${this.required}"
|
|
635
|
+
id="${ifDefined(this.id || void 0)}"
|
|
636
|
+
maxlength="${ifDefined(this.maxlength)}"
|
|
637
|
+
minlength="${ifDefined(this.minlength)}"
|
|
638
|
+
name="${ifDefined(this.name || void 0)}"
|
|
639
|
+
placeholder="${ifDefined(this.placeholder || void 0)}"
|
|
640
|
+
rows="${this.rows}"
|
|
641
|
+
title="${ifDefined(this.title || void 0)}"
|
|
642
|
+
.value="${live(this.value)}"
|
|
643
|
+
@change="${this.handleChange}"
|
|
644
|
+
@input="${this.handleInput}"
|
|
645
|
+
></textarea>`;
|
|
557
646
|
}
|
|
558
647
|
};
|
|
559
648
|
SpectreTextareaElement.properties = {
|
|
@@ -575,7 +664,6 @@ SpectreTextareaElement.properties = {
|
|
|
575
664
|
rows: { type: Number },
|
|
576
665
|
size: { type: String, reflect: true },
|
|
577
666
|
success: { type: Boolean, reflect: true },
|
|
578
|
-
title: { type: String, reflect: true },
|
|
579
667
|
value: { type: String }
|
|
580
668
|
};
|
|
581
669
|
function defineSpectreTextarea(tagName = "sp-textarea") {
|
|
@@ -598,7 +686,6 @@ var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
|
598
686
|
this.required = false;
|
|
599
687
|
this.size = "md";
|
|
600
688
|
this.success = false;
|
|
601
|
-
this.title = "";
|
|
602
689
|
this.value = "";
|
|
603
690
|
}
|
|
604
691
|
getContentContainer() {
|
|
@@ -665,30 +752,28 @@ var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
|
665
752
|
this.getContentContainer()?.blur();
|
|
666
753
|
}
|
|
667
754
|
render() {
|
|
668
|
-
return html
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
</select>
|
|
691
|
-
`;
|
|
755
|
+
return html`<select
|
|
756
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
757
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
758
|
+
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
759
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
760
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
761
|
+
autocomplete="${ifDefined(this.autocomplete || void 0)}"
|
|
762
|
+
?autofocus="${this.autofocus}"
|
|
763
|
+
class="${this.selectClasses}"
|
|
764
|
+
data-sp-select-native
|
|
765
|
+
?disabled="${this.isDisabled}"
|
|
766
|
+
form="${ifDefined(this.form || void 0)}"
|
|
767
|
+
id="${ifDefined(this.id || void 0)}"
|
|
768
|
+
name="${ifDefined(this.name || void 0)}"
|
|
769
|
+
?required="${this.required}"
|
|
770
|
+
title="${ifDefined(this.title || void 0)}"
|
|
771
|
+
.value="${live(this.value)}"
|
|
772
|
+
@change="${this.handleChange}"
|
|
773
|
+
@input="${this.handleInput}"
|
|
774
|
+
>
|
|
775
|
+
${this.hasProjectedContent ? this.projectedContent : nothing}
|
|
776
|
+
</select>`;
|
|
692
777
|
}
|
|
693
778
|
};
|
|
694
779
|
SpectreSelectElement.properties = {
|
|
@@ -704,7 +789,6 @@ SpectreSelectElement.properties = {
|
|
|
704
789
|
required: { type: Boolean, reflect: true },
|
|
705
790
|
size: { type: String, reflect: true },
|
|
706
791
|
success: { type: Boolean, reflect: true },
|
|
707
|
-
title: { type: String, reflect: true },
|
|
708
792
|
value: { type: String }
|
|
709
793
|
};
|
|
710
794
|
function defineSpectreSelect(tagName = "sp-select") {
|
|
@@ -725,7 +809,6 @@ var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
|
725
809
|
this.loading = false;
|
|
726
810
|
this.required = false;
|
|
727
811
|
this.success = false;
|
|
728
|
-
this.title = "";
|
|
729
812
|
this.value = "on";
|
|
730
813
|
}
|
|
731
814
|
getContentContainer() {
|
|
@@ -768,33 +851,31 @@ var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
|
768
851
|
this.nativeInput?.blur();
|
|
769
852
|
}
|
|
770
853
|
render() {
|
|
771
|
-
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span class=
|
|
772
|
-
return html
|
|
773
|
-
<
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
</label>
|
|
797
|
-
`;
|
|
854
|
+
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span class="sp-label" data-sp-checkbox-label-fallback>${this.visibleLabelFallback}</span>` : nothing;
|
|
855
|
+
return html`<label data-sp-checkbox-label>
|
|
856
|
+
<input
|
|
857
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
858
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
859
|
+
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
860
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
861
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
862
|
+
?autofocus="${this.autofocus}"
|
|
863
|
+
data-sp-checkbox-native
|
|
864
|
+
.checked="${live(this.checked)}"
|
|
865
|
+
?disabled="${this.isDisabled}"
|
|
866
|
+
form="${ifDefined(this.form || void 0)}"
|
|
867
|
+
id="${ifDefined(this.id || void 0)}"
|
|
868
|
+
name="${ifDefined(this.name || void 0)}"
|
|
869
|
+
?required="${this.required}"
|
|
870
|
+
title="${ifDefined(this.title || void 0)}"
|
|
871
|
+
type="checkbox"
|
|
872
|
+
value="${ifDefined(this.value)}"
|
|
873
|
+
@change="${this.handleChange}"
|
|
874
|
+
@input="${this.handleInput}"
|
|
875
|
+
/>
|
|
876
|
+
<span class="sp-checkbox-indicator" data-sp-checkbox-indicator></span>
|
|
877
|
+
${labelContent}
|
|
878
|
+
</label>`;
|
|
798
879
|
}
|
|
799
880
|
};
|
|
800
881
|
SpectreCheckboxElement.properties = {
|
|
@@ -808,7 +889,6 @@ SpectreCheckboxElement.properties = {
|
|
|
808
889
|
name: { type: String, reflect: true },
|
|
809
890
|
required: { type: Boolean, reflect: true },
|
|
810
891
|
success: { type: Boolean, reflect: true },
|
|
811
|
-
title: { type: String, reflect: true },
|
|
812
892
|
value: { type: String }
|
|
813
893
|
};
|
|
814
894
|
function defineSpectreCheckbox(tagName = "sp-checkbox") {
|
|
@@ -829,7 +909,6 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
829
909
|
this.loading = false;
|
|
830
910
|
this.required = false;
|
|
831
911
|
this.success = false;
|
|
832
|
-
this.title = "";
|
|
833
912
|
this.value = "on";
|
|
834
913
|
}
|
|
835
914
|
getContentContainer() {
|
|
@@ -872,33 +951,31 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
872
951
|
this.nativeInput?.blur();
|
|
873
952
|
}
|
|
874
953
|
render() {
|
|
875
|
-
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span class=
|
|
876
|
-
return html
|
|
877
|
-
<
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
</label>
|
|
901
|
-
`;
|
|
954
|
+
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span class="sp-label" data-sp-radio-label-fallback>${this.visibleLabelFallback}</span>` : nothing;
|
|
955
|
+
return html`<label data-sp-radio-label>
|
|
956
|
+
<input
|
|
957
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
958
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
959
|
+
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
960
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
961
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
962
|
+
?autofocus="${this.autofocus}"
|
|
963
|
+
data-sp-radio-native
|
|
964
|
+
.checked="${live(this.checked)}"
|
|
965
|
+
?disabled="${this.isDisabled}"
|
|
966
|
+
form="${ifDefined(this.form || void 0)}"
|
|
967
|
+
id="${ifDefined(this.id || void 0)}"
|
|
968
|
+
name="${ifDefined(this.name || void 0)}"
|
|
969
|
+
?required="${this.required}"
|
|
970
|
+
title="${ifDefined(this.title || void 0)}"
|
|
971
|
+
type="radio"
|
|
972
|
+
value="${ifDefined(this.value)}"
|
|
973
|
+
@change="${this.handleChange}"
|
|
974
|
+
@input="${this.handleInput}"
|
|
975
|
+
/>
|
|
976
|
+
<span class="sp-radio-indicator" data-sp-radio-indicator></span>
|
|
977
|
+
${labelContent}
|
|
978
|
+
</label>`;
|
|
902
979
|
}
|
|
903
980
|
};
|
|
904
981
|
SpectreRadioElement.properties = {
|
|
@@ -912,7 +989,6 @@ SpectreRadioElement.properties = {
|
|
|
912
989
|
name: { type: String, reflect: true },
|
|
913
990
|
required: { type: Boolean, reflect: true },
|
|
914
991
|
success: { type: Boolean, reflect: true },
|
|
915
|
-
title: { type: String, reflect: true },
|
|
916
992
|
value: { type: String }
|
|
917
993
|
};
|
|
918
994
|
function defineSpectreRadio(tagName = "sp-radio") {
|
|
@@ -924,10 +1000,6 @@ function defineSpectreRadio(tagName = "sp-radio") {
|
|
|
924
1000
|
return SpectreRadioElement;
|
|
925
1001
|
}
|
|
926
1002
|
var SpectreLabelElement = class extends SpectreProjectableElement {
|
|
927
|
-
constructor() {
|
|
928
|
-
super(...arguments);
|
|
929
|
-
this.title = "";
|
|
930
|
-
}
|
|
931
1003
|
getContentContainer() {
|
|
932
1004
|
return this.querySelector("[data-sp-label-native]");
|
|
933
1005
|
}
|
|
@@ -945,26 +1017,22 @@ var SpectreLabelElement = class extends SpectreProjectableElement {
|
|
|
945
1017
|
this.getContentContainer()?.blur();
|
|
946
1018
|
}
|
|
947
1019
|
render() {
|
|
948
|
-
return html
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
${this.hasProjectedContent ? this.projectedContent : nothing}
|
|
961
|
-
</label>
|
|
962
|
-
`;
|
|
1020
|
+
return html`<label
|
|
1021
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
1022
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
1023
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
1024
|
+
class="sp-label"
|
|
1025
|
+
data-sp-label-native
|
|
1026
|
+
for="${ifDefined(this.htmlFor || void 0)}"
|
|
1027
|
+
id="${ifDefined(this.id || void 0)}"
|
|
1028
|
+
title="${ifDefined(this.title || void 0)}"
|
|
1029
|
+
>
|
|
1030
|
+
${this.hasProjectedContent ? this.projectedContent : nothing}
|
|
1031
|
+
</label>`;
|
|
963
1032
|
}
|
|
964
1033
|
};
|
|
965
1034
|
SpectreLabelElement.properties = {
|
|
966
|
-
htmlFor: { attribute: "for", type: String, reflect: true }
|
|
967
|
-
title: { type: String, reflect: true }
|
|
1035
|
+
htmlFor: { attribute: "for", type: String, reflect: true }
|
|
968
1036
|
};
|
|
969
1037
|
function defineSpectreLabel(tagName = "sp-label") {
|
|
970
1038
|
const existingElement = customElements.get(tagName);
|
|
@@ -978,8 +1046,6 @@ var SpectreFieldsetElement = class extends SpectreProjectableElement {
|
|
|
978
1046
|
constructor() {
|
|
979
1047
|
super(...arguments);
|
|
980
1048
|
this.disabled = false;
|
|
981
|
-
this.legend = "";
|
|
982
|
-
this.title = "";
|
|
983
1049
|
}
|
|
984
1050
|
getContentContainer() {
|
|
985
1051
|
return this.querySelector("[data-sp-fieldset-native]");
|
|
@@ -998,30 +1064,27 @@ var SpectreFieldsetElement = class extends SpectreProjectableElement {
|
|
|
998
1064
|
this.getContentContainer()?.blur();
|
|
999
1065
|
}
|
|
1000
1066
|
render() {
|
|
1001
|
-
return html
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
</fieldset>
|
|
1016
|
-
`;
|
|
1067
|
+
return html`<fieldset
|
|
1068
|
+
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
1069
|
+
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
1070
|
+
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
1071
|
+
data-sp-fieldset-native
|
|
1072
|
+
?disabled="${this.disabled}"
|
|
1073
|
+
form="${ifDefined(this.form || void 0)}"
|
|
1074
|
+
id="${ifDefined(this.id || void 0)}"
|
|
1075
|
+
name="${ifDefined(this.name || void 0)}"
|
|
1076
|
+
title="${ifDefined(this.title || void 0)}"
|
|
1077
|
+
>
|
|
1078
|
+
${this.legend ? html`<legend class="sp-label" data-sp-fieldset-legend>${this.legend}</legend>` : nothing}
|
|
1079
|
+
${this.hasProjectedContent ? this.projectedContent : nothing}
|
|
1080
|
+
</fieldset>`;
|
|
1017
1081
|
}
|
|
1018
1082
|
};
|
|
1019
1083
|
SpectreFieldsetElement.properties = {
|
|
1020
1084
|
disabled: { type: Boolean, reflect: true },
|
|
1021
1085
|
form: { type: String },
|
|
1022
1086
|
legend: { type: String, reflect: true },
|
|
1023
|
-
name: { type: String, reflect: true }
|
|
1024
|
-
title: { type: String, reflect: true }
|
|
1087
|
+
name: { type: String, reflect: true }
|
|
1025
1088
|
};
|
|
1026
1089
|
function defineSpectreFieldset(tagName = "sp-fieldset") {
|
|
1027
1090
|
const existingElement = customElements.get(tagName);
|