@phcdevworks/spectre-components 1.1.0 → 1.3.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 +559 -153
- package/dist/{base-2rD8EmdC.d.cts → base-BRQ7QAAr.d.cts} +9 -0
- package/dist/{base-2rD8EmdC.d.ts → base-BRQ7QAAr.d.ts} +9 -0
- package/dist/button.cjs +146 -35
- package/dist/button.cjs.map +1 -1
- package/dist/button.d.cts +34 -29
- package/dist/button.d.ts +34 -29
- package/dist/button.js +146 -35
- package/dist/button.js.map +1 -1
- package/dist/checkbox.cjs +113 -6
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.d.cts +21 -19
- package/dist/checkbox.d.ts +21 -19
- package/dist/checkbox.js +113 -6
- package/dist/checkbox.js.map +1 -1
- package/dist/fieldset.cjs +126 -5
- package/dist/fieldset.cjs.map +1 -1
- package/dist/fieldset.d.cts +36 -7
- package/dist/fieldset.d.ts +36 -7
- package/dist/fieldset.js +126 -5
- package/dist/fieldset.js.map +1 -1
- package/dist/form-yR_u97J-.d.cts +10 -0
- package/dist/form-yR_u97J-.d.ts +10 -0
- package/dist/index.cjs +530 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +530 -96
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +138 -7
- package/dist/input.cjs.map +1 -1
- package/dist/input.d.cts +49 -23
- package/dist/input.d.ts +49 -23
- package/dist/input.js +138 -7
- package/dist/input.js.map +1 -1
- package/dist/label.cjs +98 -3
- package/dist/label.cjs.map +1 -1
- package/dist/label.d.cts +19 -6
- package/dist/label.d.ts +19 -6
- package/dist/label.js +98 -3
- package/dist/label.js.map +1 -1
- package/dist/{projectable-BzDQ4xp_.d.cts → projectable-Bx-IVk0w.d.cts} +1 -1
- package/dist/{projectable-s3SgvjGX.d.ts → projectable-D6IDeKfr.d.ts} +1 -1
- package/dist/radio.cjs +133 -6
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.d.cts +23 -19
- package/dist/radio.d.ts +23 -19
- package/dist/radio.js +133 -6
- package/dist/radio.js.map +1 -1
- package/dist/select.cjs +120 -8
- package/dist/select.cjs.map +1 -1
- package/dist/select.d.cts +24 -22
- package/dist/select.d.ts +24 -22
- package/dist/select.js +120 -8
- package/dist/select.js.map +1 -1
- package/dist/textarea.cjs +134 -7
- package/dist/textarea.cjs.map +1 -1
- package/dist/textarea.d.cts +37 -22
- package/dist/textarea.d.ts +37 -22
- package/dist/textarea.js +134 -7
- package/dist/textarea.js.map +1 -1
- package/package.json +24 -12
- package/dist/form-iI7vV-3W.d.cts +0 -6
- package/dist/form-iI7vV-3W.d.ts +0 -6
package/dist/index.js
CHANGED
|
@@ -1,15 +1,61 @@
|
|
|
1
|
+
import { getButtonClasses, getInputLabelClasses, getInputClasses } from '@phcdevworks/spectre-ui';
|
|
1
2
|
import { LitElement, html, nothing } from 'lit';
|
|
2
3
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
-
import { getButtonClasses, getInputClasses } from '@phcdevworks/spectre-ui';
|
|
4
4
|
import { live } from 'lit/directives/live.js';
|
|
5
5
|
|
|
6
|
-
// src/
|
|
6
|
+
// src/utils/form.ts
|
|
7
|
+
var spectreInputSizes = ["sm", "md", "lg"];
|
|
8
|
+
function isInputSize(value) {
|
|
9
|
+
return spectreInputSizes.includes(value);
|
|
10
|
+
}
|
|
11
|
+
var spectreButtonVariants = [
|
|
12
|
+
"primary",
|
|
13
|
+
"secondary",
|
|
14
|
+
"ghost",
|
|
15
|
+
"danger",
|
|
16
|
+
"success",
|
|
17
|
+
"cta",
|
|
18
|
+
"accent"
|
|
19
|
+
];
|
|
20
|
+
function isButtonVariant(value) {
|
|
21
|
+
return spectreButtonVariants.includes(value);
|
|
22
|
+
}
|
|
23
|
+
var spectreButtonTypes = ["button", "submit", "reset"];
|
|
24
|
+
function isButtonType(value) {
|
|
25
|
+
return spectreButtonTypes.includes(value);
|
|
26
|
+
}
|
|
27
|
+
var spectreInputTypes = [
|
|
28
|
+
"text",
|
|
29
|
+
"email",
|
|
30
|
+
"password",
|
|
31
|
+
"search",
|
|
32
|
+
"tel",
|
|
33
|
+
"url",
|
|
34
|
+
"number",
|
|
35
|
+
"date",
|
|
36
|
+
"datetime-local",
|
|
37
|
+
"month",
|
|
38
|
+
"time",
|
|
39
|
+
"week"
|
|
40
|
+
];
|
|
41
|
+
function isInputType(value) {
|
|
42
|
+
return spectreInputTypes.includes(value);
|
|
43
|
+
}
|
|
44
|
+
function normalizeInt(value, fallback, min = 0) {
|
|
45
|
+
if (value == null || typeof value !== "number" || !Number.isInteger(value) || value < min) {
|
|
46
|
+
return fallback;
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
7
50
|
var SpectreBaseElement = class extends LitElement {
|
|
8
51
|
constructor() {
|
|
9
52
|
super(...arguments);
|
|
10
53
|
this._ariaLabel = null;
|
|
11
54
|
this._ariaLabelledBy = null;
|
|
12
55
|
this._ariaDescribedBy = null;
|
|
56
|
+
this._autocapitalize = "";
|
|
57
|
+
this._autofocus = false;
|
|
58
|
+
this._spellcheck = null;
|
|
13
59
|
this._title = "";
|
|
14
60
|
this._id = "";
|
|
15
61
|
}
|
|
@@ -46,6 +92,29 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
46
92
|
this._removeHostAttribute("aria-describedby");
|
|
47
93
|
this.requestUpdate();
|
|
48
94
|
}
|
|
95
|
+
get autocapitalize() {
|
|
96
|
+
return this._autocapitalize;
|
|
97
|
+
}
|
|
98
|
+
set autocapitalize(value) {
|
|
99
|
+
const normalizedValue = value ?? "";
|
|
100
|
+
if (this._autocapitalize === normalizedValue) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this._autocapitalize = normalizedValue;
|
|
104
|
+
this._removeHostAttribute("autocapitalize");
|
|
105
|
+
this.requestUpdate();
|
|
106
|
+
}
|
|
107
|
+
get spellcheck() {
|
|
108
|
+
return this._spellcheck ?? super.spellcheck;
|
|
109
|
+
}
|
|
110
|
+
set spellcheck(value) {
|
|
111
|
+
if (this._spellcheck === value) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this._spellcheck = value ?? null;
|
|
115
|
+
this._removeHostAttribute("spellcheck");
|
|
116
|
+
this.requestUpdate();
|
|
117
|
+
}
|
|
49
118
|
get title() {
|
|
50
119
|
return this._title;
|
|
51
120
|
}
|
|
@@ -70,6 +139,18 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
70
139
|
this._removeHostAttribute("id");
|
|
71
140
|
this.requestUpdate();
|
|
72
141
|
}
|
|
142
|
+
get autofocus() {
|
|
143
|
+
return this._autofocus;
|
|
144
|
+
}
|
|
145
|
+
set autofocus(value) {
|
|
146
|
+
const normalizedValue = !!value;
|
|
147
|
+
if (this._autofocus === normalizedValue) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this._autofocus = normalizedValue;
|
|
151
|
+
this._removeHostAttribute("autofocus");
|
|
152
|
+
this.requestUpdate();
|
|
153
|
+
}
|
|
73
154
|
// Spectre components intentionally render in light DOM so the global
|
|
74
155
|
// `@phcdevworks/spectre-ui` styling contract can apply directly.
|
|
75
156
|
createRenderRoot() {
|
|
@@ -80,6 +161,9 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
80
161
|
const proxiedAttributes = [
|
|
81
162
|
"id",
|
|
82
163
|
"title",
|
|
164
|
+
"autocapitalize",
|
|
165
|
+
"autofocus",
|
|
166
|
+
"spellcheck",
|
|
83
167
|
"aria-label",
|
|
84
168
|
"aria-labelledby",
|
|
85
169
|
"aria-describedby"
|
|
@@ -97,6 +181,12 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
97
181
|
return this.id || null;
|
|
98
182
|
case "title":
|
|
99
183
|
return this.title || null;
|
|
184
|
+
case "autocapitalize":
|
|
185
|
+
return this.autocapitalize || null;
|
|
186
|
+
case "autofocus":
|
|
187
|
+
return this.autofocus ? "" : null;
|
|
188
|
+
case "spellcheck":
|
|
189
|
+
return this._spellcheck !== null ? String(this._spellcheck) : null;
|
|
100
190
|
case "aria-label":
|
|
101
191
|
return this.ariaLabel;
|
|
102
192
|
case "aria-labelledby":
|
|
@@ -113,6 +203,12 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
113
203
|
return this.id !== "";
|
|
114
204
|
case "title":
|
|
115
205
|
return this.title !== "";
|
|
206
|
+
case "autocapitalize":
|
|
207
|
+
return this.autocapitalize !== "";
|
|
208
|
+
case "autofocus":
|
|
209
|
+
return this.autofocus;
|
|
210
|
+
case "spellcheck":
|
|
211
|
+
return this._spellcheck !== null;
|
|
116
212
|
case "aria-label":
|
|
117
213
|
return this.ariaLabel !== null;
|
|
118
214
|
case "aria-labelledby":
|
|
@@ -131,6 +227,15 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
131
227
|
case "title":
|
|
132
228
|
this.title = value;
|
|
133
229
|
break;
|
|
230
|
+
case "autocapitalize":
|
|
231
|
+
this.autocapitalize = value;
|
|
232
|
+
break;
|
|
233
|
+
case "autofocus":
|
|
234
|
+
this.autofocus = true;
|
|
235
|
+
break;
|
|
236
|
+
case "spellcheck":
|
|
237
|
+
this.spellcheck = value !== "false";
|
|
238
|
+
break;
|
|
134
239
|
case "aria-label":
|
|
135
240
|
this.ariaLabel = value;
|
|
136
241
|
break;
|
|
@@ -152,6 +257,15 @@ var SpectreBaseElement = class extends LitElement {
|
|
|
152
257
|
case "title":
|
|
153
258
|
this.title = "";
|
|
154
259
|
break;
|
|
260
|
+
case "autocapitalize":
|
|
261
|
+
this.autocapitalize = "";
|
|
262
|
+
break;
|
|
263
|
+
case "autofocus":
|
|
264
|
+
this.autofocus = false;
|
|
265
|
+
break;
|
|
266
|
+
case "spellcheck":
|
|
267
|
+
this.spellcheck = null;
|
|
268
|
+
break;
|
|
155
269
|
case "aria-label":
|
|
156
270
|
this.ariaLabel = null;
|
|
157
271
|
break;
|
|
@@ -263,32 +377,12 @@ var SpectreProjectableElement = class extends SpectreBaseElement {
|
|
|
263
377
|
this.contentObserver = void 0;
|
|
264
378
|
}
|
|
265
379
|
};
|
|
266
|
-
var spectreButtonVariants = [
|
|
267
|
-
"primary",
|
|
268
|
-
"secondary",
|
|
269
|
-
"ghost",
|
|
270
|
-
"danger",
|
|
271
|
-
"success",
|
|
272
|
-
"cta",
|
|
273
|
-
"accent"
|
|
274
|
-
];
|
|
275
|
-
var spectreButtonSizes = ["sm", "md", "lg"];
|
|
276
|
-
var spectreButtonTypes = ["button", "submit", "reset"];
|
|
277
|
-
function isButtonVariant(value) {
|
|
278
|
-
return spectreButtonVariants.includes(value);
|
|
279
|
-
}
|
|
280
|
-
function isButtonSize(value) {
|
|
281
|
-
return spectreButtonSizes.includes(value);
|
|
282
|
-
}
|
|
283
|
-
function isButtonType(value) {
|
|
284
|
-
return spectreButtonTypes.includes(value);
|
|
285
|
-
}
|
|
286
380
|
var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
287
381
|
constructor() {
|
|
288
382
|
super(...arguments);
|
|
289
|
-
this.autofocus = false;
|
|
290
383
|
this.disabled = false;
|
|
291
384
|
this.fullWidth = false;
|
|
385
|
+
this.iconOnly = false;
|
|
292
386
|
this.loading = false;
|
|
293
387
|
this.loadingLabel = "Loading";
|
|
294
388
|
this.pill = false;
|
|
@@ -297,6 +391,24 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
297
391
|
this.variant = "primary";
|
|
298
392
|
this.value = "";
|
|
299
393
|
}
|
|
394
|
+
get id() {
|
|
395
|
+
return super.id;
|
|
396
|
+
}
|
|
397
|
+
set id(value) {
|
|
398
|
+
super.id = value;
|
|
399
|
+
}
|
|
400
|
+
get title() {
|
|
401
|
+
return super.title;
|
|
402
|
+
}
|
|
403
|
+
set title(value) {
|
|
404
|
+
super.title = value;
|
|
405
|
+
}
|
|
406
|
+
get autofocus() {
|
|
407
|
+
return super.autofocus;
|
|
408
|
+
}
|
|
409
|
+
set autofocus(value) {
|
|
410
|
+
super.autofocus = value;
|
|
411
|
+
}
|
|
300
412
|
getContentContainer() {
|
|
301
413
|
return this.querySelector("[data-sp-button-native]");
|
|
302
414
|
}
|
|
@@ -308,13 +420,28 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
308
420
|
return el.hasAttribute("data-sp-button-native") || el.hasAttribute("data-sp-button-loading-label") || el.hasAttribute("data-sp-button-label-fallback");
|
|
309
421
|
}
|
|
310
422
|
willUpdate(changedProperties) {
|
|
311
|
-
if (changedProperties.has("
|
|
423
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
424
|
+
this.disabled = false;
|
|
425
|
+
}
|
|
426
|
+
if (changedProperties.has("fullWidth") && this.fullWidth == null) {
|
|
427
|
+
this.fullWidth = false;
|
|
428
|
+
}
|
|
429
|
+
if (changedProperties.has("iconOnly") && this.iconOnly == null) {
|
|
430
|
+
this.iconOnly = false;
|
|
431
|
+
}
|
|
432
|
+
if (changedProperties.has("loading") && this.loading == null) {
|
|
433
|
+
this.loading = false;
|
|
434
|
+
}
|
|
435
|
+
if (changedProperties.has("pill") && this.pill == null) {
|
|
436
|
+
this.pill = false;
|
|
437
|
+
}
|
|
438
|
+
if (changedProperties.has("variant") && (this.variant == null || !isButtonVariant(this.variant))) {
|
|
312
439
|
this.variant = "primary";
|
|
313
440
|
}
|
|
314
|
-
if (changedProperties.has("size") && !
|
|
441
|
+
if (changedProperties.has("size") && (this.size == null || !isInputSize(this.size))) {
|
|
315
442
|
this.size = "md";
|
|
316
443
|
}
|
|
317
|
-
if (changedProperties.has("type") && !isButtonType(this.type)) {
|
|
444
|
+
if (changedProperties.has("type") && (this.type == null || !isButtonType(this.type))) {
|
|
318
445
|
this.type = "button";
|
|
319
446
|
}
|
|
320
447
|
if (changedProperties.has("loadingLabel")) {
|
|
@@ -329,15 +456,16 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
329
456
|
get buttonClasses() {
|
|
330
457
|
return getButtonClasses({
|
|
331
458
|
disabled: this.isDisabled,
|
|
332
|
-
fullWidth: this.fullWidth,
|
|
333
|
-
|
|
334
|
-
|
|
459
|
+
fullWidth: this.fullWidth ?? false,
|
|
460
|
+
iconOnly: this.iconOnly ?? false,
|
|
461
|
+
loading: this.loading ?? false,
|
|
462
|
+
pill: this.pill ?? false,
|
|
335
463
|
size: this.size,
|
|
336
464
|
variant: this.variant
|
|
337
465
|
});
|
|
338
466
|
}
|
|
339
467
|
get isDisabled() {
|
|
340
|
-
return this.disabled || this.loading;
|
|
468
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
341
469
|
}
|
|
342
470
|
get visibleLabelFallback() {
|
|
343
471
|
const trimmedLabel = this.label?.trim();
|
|
@@ -351,12 +479,18 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
351
479
|
}
|
|
352
480
|
renderButtonContent() {
|
|
353
481
|
if (this.loading) {
|
|
354
|
-
return html`<span
|
|
482
|
+
return html`<span
|
|
483
|
+
class="${getInputLabelClasses({ disabled: this.isDisabled })}"
|
|
484
|
+
data-sp-button-loading-label
|
|
485
|
+
>${this.loadingLabel}</span>`;
|
|
355
486
|
}
|
|
356
487
|
if (this.hasProjectedContent) {
|
|
357
488
|
return this.projectedContent;
|
|
358
489
|
}
|
|
359
|
-
return this.visibleLabelFallback ? html`<span
|
|
490
|
+
return this.visibleLabelFallback ? html`<span
|
|
491
|
+
class="${getInputLabelClasses({ disabled: this.isDisabled })}"
|
|
492
|
+
data-sp-button-label-fallback
|
|
493
|
+
>${this.visibleLabelFallback}</span>` : nothing;
|
|
360
494
|
}
|
|
361
495
|
render() {
|
|
362
496
|
return html`<button
|
|
@@ -373,17 +507,17 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
373
507
|
name="${ifDefined(this.name || void 0)}"
|
|
374
508
|
title="${ifDefined(this.title || void 0)}"
|
|
375
509
|
type="${this.type}"
|
|
376
|
-
value="${ifDefined(this.value
|
|
510
|
+
value="${ifDefined(this.value)}"
|
|
377
511
|
>
|
|
378
512
|
${this.renderButtonContent()}
|
|
379
513
|
</button>`;
|
|
380
514
|
}
|
|
381
515
|
};
|
|
382
516
|
SpectreButtonElement.properties = {
|
|
383
|
-
autofocus: { type: Boolean, reflect: true },
|
|
384
517
|
disabled: { type: Boolean, reflect: true },
|
|
385
518
|
form: { type: String },
|
|
386
519
|
fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
|
|
520
|
+
iconOnly: { attribute: "icon-only", type: Boolean, reflect: true },
|
|
387
521
|
label: { type: String, reflect: true },
|
|
388
522
|
loading: { type: Boolean, reflect: true },
|
|
389
523
|
loadingLabel: { attribute: "loading-label", type: String, reflect: true },
|
|
@@ -402,37 +536,9 @@ function defineSpectreButton(tagName = "sp-button") {
|
|
|
402
536
|
customElements.define(tagName, SpectreButtonElement);
|
|
403
537
|
return SpectreButtonElement;
|
|
404
538
|
}
|
|
405
|
-
var spectreInputSizes = ["sm", "md", "lg"];
|
|
406
|
-
function isInputSize(value) {
|
|
407
|
-
return spectreInputSizes.includes(value);
|
|
408
|
-
}
|
|
409
|
-
var spectreInputTypes = [
|
|
410
|
-
"text",
|
|
411
|
-
"email",
|
|
412
|
-
"password",
|
|
413
|
-
"search",
|
|
414
|
-
"tel",
|
|
415
|
-
"url",
|
|
416
|
-
"number",
|
|
417
|
-
"date",
|
|
418
|
-
"datetime-local",
|
|
419
|
-
"month",
|
|
420
|
-
"time",
|
|
421
|
-
"week"
|
|
422
|
-
];
|
|
423
|
-
function isInputType(value) {
|
|
424
|
-
return spectreInputTypes.includes(value);
|
|
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
|
-
}
|
|
432
539
|
var SpectreInputElement = class extends SpectreBaseElement {
|
|
433
540
|
constructor() {
|
|
434
541
|
super(...arguments);
|
|
435
|
-
this.autofocus = false;
|
|
436
542
|
this.disabled = false;
|
|
437
543
|
this.fullWidth = false;
|
|
438
544
|
this.invalid = false;
|
|
@@ -445,11 +551,65 @@ var SpectreInputElement = class extends SpectreBaseElement {
|
|
|
445
551
|
this.type = "text";
|
|
446
552
|
this.value = "";
|
|
447
553
|
}
|
|
554
|
+
get autocapitalize() {
|
|
555
|
+
return super.autocapitalize;
|
|
556
|
+
}
|
|
557
|
+
set autocapitalize(value) {
|
|
558
|
+
super.autocapitalize = value;
|
|
559
|
+
}
|
|
560
|
+
get autofocus() {
|
|
561
|
+
return super.autofocus;
|
|
562
|
+
}
|
|
563
|
+
set autofocus(value) {
|
|
564
|
+
super.autofocus = value;
|
|
565
|
+
}
|
|
566
|
+
get id() {
|
|
567
|
+
return super.id;
|
|
568
|
+
}
|
|
569
|
+
set id(value) {
|
|
570
|
+
super.id = value;
|
|
571
|
+
}
|
|
572
|
+
get spellcheck() {
|
|
573
|
+
return super.spellcheck;
|
|
574
|
+
}
|
|
575
|
+
set spellcheck(value) {
|
|
576
|
+
super.spellcheck = value;
|
|
577
|
+
}
|
|
578
|
+
get title() {
|
|
579
|
+
return super.title;
|
|
580
|
+
}
|
|
581
|
+
set title(value) {
|
|
582
|
+
super.title = value;
|
|
583
|
+
}
|
|
448
584
|
willUpdate(changedProperties) {
|
|
449
|
-
if (changedProperties.has("
|
|
585
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
586
|
+
this.disabled = false;
|
|
587
|
+
}
|
|
588
|
+
if (changedProperties.has("fullWidth") && this.fullWidth == null) {
|
|
589
|
+
this.fullWidth = false;
|
|
590
|
+
}
|
|
591
|
+
if (changedProperties.has("invalid") && this.invalid == null) {
|
|
592
|
+
this.invalid = false;
|
|
593
|
+
}
|
|
594
|
+
if (changedProperties.has("loading") && this.loading == null) {
|
|
595
|
+
this.loading = false;
|
|
596
|
+
}
|
|
597
|
+
if (changedProperties.has("pill") && this.pill == null) {
|
|
598
|
+
this.pill = false;
|
|
599
|
+
}
|
|
600
|
+
if (changedProperties.has("readonly") && this.readonly == null) {
|
|
601
|
+
this.readonly = false;
|
|
602
|
+
}
|
|
603
|
+
if (changedProperties.has("required") && this.required == null) {
|
|
604
|
+
this.required = false;
|
|
605
|
+
}
|
|
606
|
+
if (changedProperties.has("success") && this.success == null) {
|
|
607
|
+
this.success = false;
|
|
608
|
+
}
|
|
609
|
+
if (changedProperties.has("size") && (this.size == null || !isInputSize(this.size))) {
|
|
450
610
|
this.size = "md";
|
|
451
611
|
}
|
|
452
|
-
if (changedProperties.has("type") && !isInputType(this.type)) {
|
|
612
|
+
if (changedProperties.has("type") && (this.type == null || !isInputType(this.type))) {
|
|
453
613
|
this.type = "text";
|
|
454
614
|
}
|
|
455
615
|
if (changedProperties.has("value") && this.value == null) {
|
|
@@ -464,14 +624,14 @@ var SpectreInputElement = class extends SpectreBaseElement {
|
|
|
464
624
|
}
|
|
465
625
|
get inputClasses() {
|
|
466
626
|
return getInputClasses({
|
|
467
|
-
fullWidth: this.fullWidth,
|
|
468
|
-
pill: this.pill,
|
|
627
|
+
fullWidth: this.fullWidth ?? false,
|
|
628
|
+
pill: this.pill ?? false,
|
|
469
629
|
size: this.size,
|
|
470
630
|
state: this.isDisabled ? this.disabled ? "disabled" : "loading" : this.invalid ? "error" : this.success ? "success" : "default"
|
|
471
631
|
});
|
|
472
632
|
}
|
|
473
633
|
get isDisabled() {
|
|
474
|
-
return this.disabled || this.loading;
|
|
634
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
475
635
|
}
|
|
476
636
|
get nativeInput() {
|
|
477
637
|
return this.querySelector("[data-sp-input-native]");
|
|
@@ -497,22 +657,27 @@ var SpectreInputElement = class extends SpectreBaseElement {
|
|
|
497
657
|
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
498
658
|
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
499
659
|
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
660
|
+
autocapitalize="${ifDefined(this.autocapitalize || void 0)}"
|
|
500
661
|
autocomplete="${ifDefined(this.autocomplete || void 0)}"
|
|
501
662
|
?autofocus="${this.autofocus}"
|
|
502
663
|
class="${this.inputClasses}"
|
|
503
664
|
data-sp-input-native
|
|
504
665
|
?disabled="${this.isDisabled}"
|
|
666
|
+
enterkeyhint="${ifDefined(this.enterkeyhint || void 0)}"
|
|
505
667
|
form="${ifDefined(this.form || void 0)}"
|
|
506
668
|
?readonly="${this.readonly}"
|
|
507
669
|
?required="${this.required}"
|
|
508
670
|
id="${ifDefined(this.id || void 0)}"
|
|
509
671
|
inputmode="${ifDefined(this.inputmode || void 0)}"
|
|
672
|
+
list="${ifDefined(this.list || void 0)}"
|
|
510
673
|
max="${ifDefined(this.max || void 0)}"
|
|
511
674
|
maxlength="${ifDefined(this.maxlength)}"
|
|
512
675
|
min="${ifDefined(this.min || void 0)}"
|
|
513
676
|
minlength="${ifDefined(this.minlength)}"
|
|
514
677
|
name="${ifDefined(this.name || void 0)}"
|
|
678
|
+
pattern="${ifDefined(this.pattern || void 0)}"
|
|
515
679
|
placeholder="${ifDefined(this.placeholder || void 0)}"
|
|
680
|
+
spellcheck="${ifDefined(this.getAttribute("spellcheck") ?? void 0)}"
|
|
516
681
|
step="${ifDefined(this.step || void 0)}"
|
|
517
682
|
title="${ifDefined(this.title || void 0)}"
|
|
518
683
|
type="${this.type}"
|
|
@@ -524,18 +689,20 @@ var SpectreInputElement = class extends SpectreBaseElement {
|
|
|
524
689
|
};
|
|
525
690
|
SpectreInputElement.properties = {
|
|
526
691
|
autocomplete: { type: String, reflect: true },
|
|
527
|
-
autofocus: { type: Boolean, reflect: true },
|
|
528
692
|
disabled: { type: Boolean, reflect: true },
|
|
693
|
+
enterkeyhint: { type: String, reflect: true },
|
|
529
694
|
form: { type: String },
|
|
530
695
|
fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
|
|
531
696
|
inputmode: { type: String, reflect: true },
|
|
532
697
|
invalid: { type: Boolean, reflect: true },
|
|
698
|
+
list: { type: String, reflect: true },
|
|
533
699
|
loading: { type: Boolean, reflect: true },
|
|
534
700
|
max: { type: String, reflect: true },
|
|
535
701
|
maxlength: { type: Number, reflect: true },
|
|
536
702
|
min: { type: String, reflect: true },
|
|
537
703
|
minlength: { type: Number, reflect: true },
|
|
538
704
|
name: { type: String, reflect: true },
|
|
705
|
+
pattern: { type: String, reflect: true },
|
|
539
706
|
pill: { type: Boolean, reflect: true },
|
|
540
707
|
placeholder: { type: String, reflect: true },
|
|
541
708
|
readonly: { type: Boolean, reflect: true },
|
|
@@ -558,7 +725,6 @@ var DEFAULT_ROWS = 2;
|
|
|
558
725
|
var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
559
726
|
constructor() {
|
|
560
727
|
super(...arguments);
|
|
561
|
-
this.autofocus = false;
|
|
562
728
|
this.disabled = false;
|
|
563
729
|
this.fullWidth = false;
|
|
564
730
|
this.invalid = false;
|
|
@@ -571,8 +737,62 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
571
737
|
this.success = false;
|
|
572
738
|
this.value = "";
|
|
573
739
|
}
|
|
740
|
+
get autocapitalize() {
|
|
741
|
+
return super.autocapitalize;
|
|
742
|
+
}
|
|
743
|
+
set autocapitalize(value) {
|
|
744
|
+
super.autocapitalize = value;
|
|
745
|
+
}
|
|
746
|
+
get autofocus() {
|
|
747
|
+
return super.autofocus;
|
|
748
|
+
}
|
|
749
|
+
set autofocus(value) {
|
|
750
|
+
super.autofocus = value;
|
|
751
|
+
}
|
|
752
|
+
get id() {
|
|
753
|
+
return super.id;
|
|
754
|
+
}
|
|
755
|
+
set id(value) {
|
|
756
|
+
super.id = value;
|
|
757
|
+
}
|
|
758
|
+
get spellcheck() {
|
|
759
|
+
return super.spellcheck;
|
|
760
|
+
}
|
|
761
|
+
set spellcheck(value) {
|
|
762
|
+
super.spellcheck = value;
|
|
763
|
+
}
|
|
764
|
+
get title() {
|
|
765
|
+
return super.title;
|
|
766
|
+
}
|
|
767
|
+
set title(value) {
|
|
768
|
+
super.title = value;
|
|
769
|
+
}
|
|
574
770
|
willUpdate(changedProperties) {
|
|
575
|
-
if (changedProperties.has("
|
|
771
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
772
|
+
this.disabled = false;
|
|
773
|
+
}
|
|
774
|
+
if (changedProperties.has("fullWidth") && this.fullWidth == null) {
|
|
775
|
+
this.fullWidth = false;
|
|
776
|
+
}
|
|
777
|
+
if (changedProperties.has("invalid") && this.invalid == null) {
|
|
778
|
+
this.invalid = false;
|
|
779
|
+
}
|
|
780
|
+
if (changedProperties.has("loading") && this.loading == null) {
|
|
781
|
+
this.loading = false;
|
|
782
|
+
}
|
|
783
|
+
if (changedProperties.has("pill") && this.pill == null) {
|
|
784
|
+
this.pill = false;
|
|
785
|
+
}
|
|
786
|
+
if (changedProperties.has("readonly") && this.readonly == null) {
|
|
787
|
+
this.readonly = false;
|
|
788
|
+
}
|
|
789
|
+
if (changedProperties.has("required") && this.required == null) {
|
|
790
|
+
this.required = false;
|
|
791
|
+
}
|
|
792
|
+
if (changedProperties.has("success") && this.success == null) {
|
|
793
|
+
this.success = false;
|
|
794
|
+
}
|
|
795
|
+
if (changedProperties.has("size") && (this.size == null || !isInputSize(this.size))) {
|
|
576
796
|
this.size = "md";
|
|
577
797
|
}
|
|
578
798
|
if (changedProperties.has("rows")) {
|
|
@@ -590,14 +810,14 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
590
810
|
}
|
|
591
811
|
get textareaClasses() {
|
|
592
812
|
return getInputClasses({
|
|
593
|
-
fullWidth: this.fullWidth,
|
|
594
|
-
pill: this.pill,
|
|
813
|
+
fullWidth: this.fullWidth ?? false,
|
|
814
|
+
pill: this.pill ?? false,
|
|
595
815
|
size: this.size,
|
|
596
816
|
state: this.isDisabled ? this.disabled ? "disabled" : "loading" : this.invalid ? "error" : this.success ? "success" : "default"
|
|
597
817
|
});
|
|
598
818
|
}
|
|
599
819
|
get isDisabled() {
|
|
600
|
-
return this.disabled || this.loading;
|
|
820
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
601
821
|
}
|
|
602
822
|
get nativeTextarea() {
|
|
603
823
|
return this.querySelector("[data-sp-textarea-native]");
|
|
@@ -623,11 +843,13 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
623
843
|
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
624
844
|
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
625
845
|
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
846
|
+
autocapitalize="${ifDefined(this.autocapitalize || void 0)}"
|
|
626
847
|
autocomplete="${ifDefined(this.autocomplete || void 0)}"
|
|
627
848
|
?autofocus="${this.autofocus}"
|
|
628
849
|
class="${this.textareaClasses}"
|
|
629
850
|
data-sp-textarea-native
|
|
630
851
|
?disabled="${this.isDisabled}"
|
|
852
|
+
enterkeyhint="${ifDefined(this.enterkeyhint || void 0)}"
|
|
631
853
|
form="${ifDefined(this.form || void 0)}"
|
|
632
854
|
inputmode="${ifDefined(this.inputmode || void 0)}"
|
|
633
855
|
?readonly="${this.readonly}"
|
|
@@ -638,6 +860,7 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
638
860
|
name="${ifDefined(this.name || void 0)}"
|
|
639
861
|
placeholder="${ifDefined(this.placeholder || void 0)}"
|
|
640
862
|
rows="${this.rows}"
|
|
863
|
+
spellcheck="${ifDefined(this.getAttribute("spellcheck") ?? void 0)}"
|
|
641
864
|
title="${ifDefined(this.title || void 0)}"
|
|
642
865
|
.value="${live(this.value)}"
|
|
643
866
|
@change="${this.handleChange}"
|
|
@@ -647,8 +870,8 @@ var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
|
647
870
|
};
|
|
648
871
|
SpectreTextareaElement.properties = {
|
|
649
872
|
autocomplete: { type: String, reflect: true },
|
|
650
|
-
autofocus: { type: Boolean, reflect: true },
|
|
651
873
|
disabled: { type: Boolean, reflect: true },
|
|
874
|
+
enterkeyhint: { type: String, reflect: true },
|
|
652
875
|
form: { type: String },
|
|
653
876
|
fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
|
|
654
877
|
inputmode: { type: String, reflect: true },
|
|
@@ -661,7 +884,7 @@ SpectreTextareaElement.properties = {
|
|
|
661
884
|
placeholder: { type: String, reflect: true },
|
|
662
885
|
readonly: { type: Boolean, reflect: true },
|
|
663
886
|
required: { type: Boolean, reflect: true },
|
|
664
|
-
rows: { type: Number },
|
|
887
|
+
rows: { type: Number, reflect: true },
|
|
665
888
|
size: { type: String, reflect: true },
|
|
666
889
|
success: { type: Boolean, reflect: true },
|
|
667
890
|
value: { type: String }
|
|
@@ -677,7 +900,6 @@ function defineSpectreTextarea(tagName = "sp-textarea") {
|
|
|
677
900
|
var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
678
901
|
constructor() {
|
|
679
902
|
super(...arguments);
|
|
680
|
-
this.autofocus = false;
|
|
681
903
|
this.disabled = false;
|
|
682
904
|
this.fullWidth = false;
|
|
683
905
|
this.invalid = false;
|
|
@@ -688,6 +910,24 @@ var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
|
688
910
|
this.success = false;
|
|
689
911
|
this.value = "";
|
|
690
912
|
}
|
|
913
|
+
get id() {
|
|
914
|
+
return super.id;
|
|
915
|
+
}
|
|
916
|
+
set id(value) {
|
|
917
|
+
super.id = value;
|
|
918
|
+
}
|
|
919
|
+
get title() {
|
|
920
|
+
return super.title;
|
|
921
|
+
}
|
|
922
|
+
set title(value) {
|
|
923
|
+
super.title = value;
|
|
924
|
+
}
|
|
925
|
+
get autofocus() {
|
|
926
|
+
return super.autofocus;
|
|
927
|
+
}
|
|
928
|
+
set autofocus(value) {
|
|
929
|
+
super.autofocus = value;
|
|
930
|
+
}
|
|
691
931
|
getContentContainer() {
|
|
692
932
|
return this.querySelector("[data-sp-select-native]");
|
|
693
933
|
}
|
|
@@ -699,7 +939,28 @@ var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
|
699
939
|
return el.hasAttribute("data-sp-select-native");
|
|
700
940
|
}
|
|
701
941
|
willUpdate(changedProperties) {
|
|
702
|
-
if (changedProperties.has("
|
|
942
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
943
|
+
this.disabled = false;
|
|
944
|
+
}
|
|
945
|
+
if (changedProperties.has("fullWidth") && this.fullWidth == null) {
|
|
946
|
+
this.fullWidth = false;
|
|
947
|
+
}
|
|
948
|
+
if (changedProperties.has("invalid") && this.invalid == null) {
|
|
949
|
+
this.invalid = false;
|
|
950
|
+
}
|
|
951
|
+
if (changedProperties.has("loading") && this.loading == null) {
|
|
952
|
+
this.loading = false;
|
|
953
|
+
}
|
|
954
|
+
if (changedProperties.has("pill") && this.pill == null) {
|
|
955
|
+
this.pill = false;
|
|
956
|
+
}
|
|
957
|
+
if (changedProperties.has("required") && this.required == null) {
|
|
958
|
+
this.required = false;
|
|
959
|
+
}
|
|
960
|
+
if (changedProperties.has("success") && this.success == null) {
|
|
961
|
+
this.success = false;
|
|
962
|
+
}
|
|
963
|
+
if (changedProperties.has("size") && (this.size == null || !isInputSize(this.size))) {
|
|
703
964
|
this.size = "md";
|
|
704
965
|
}
|
|
705
966
|
if (changedProperties.has("value") && this.value == null) {
|
|
@@ -712,8 +973,12 @@ var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
|
712
973
|
if (!nativeSelect) {
|
|
713
974
|
return;
|
|
714
975
|
}
|
|
715
|
-
|
|
716
|
-
|
|
976
|
+
const valueChanged = changedProperties.has("value");
|
|
977
|
+
const oldValue = changedProperties.get("value");
|
|
978
|
+
if (valueChanged && this.value !== void 0 && (this.value !== "" || oldValue !== void 0 || this.hasAttribute("value"))) {
|
|
979
|
+
if (nativeSelect.value !== this.value) {
|
|
980
|
+
nativeSelect.value = this.value;
|
|
981
|
+
}
|
|
717
982
|
}
|
|
718
983
|
if (this.value === "" && !this.hasAttribute("value")) {
|
|
719
984
|
const nativeValue = nativeSelect.value ?? "";
|
|
@@ -728,14 +993,14 @@ var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
|
728
993
|
}
|
|
729
994
|
get selectClasses() {
|
|
730
995
|
return getInputClasses({
|
|
731
|
-
fullWidth: this.fullWidth,
|
|
732
|
-
pill: this.pill,
|
|
996
|
+
fullWidth: this.fullWidth ?? false,
|
|
997
|
+
pill: this.pill ?? false,
|
|
733
998
|
size: this.size,
|
|
734
999
|
state: this.isDisabled ? this.disabled ? "disabled" : "loading" : this.invalid ? "error" : this.success ? "success" : "default"
|
|
735
1000
|
});
|
|
736
1001
|
}
|
|
737
1002
|
get isDisabled() {
|
|
738
|
-
return this.disabled || this.loading;
|
|
1003
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
739
1004
|
}
|
|
740
1005
|
handleInput(event) {
|
|
741
1006
|
const select = event.currentTarget;
|
|
@@ -778,7 +1043,6 @@ var SpectreSelectElement = class extends SpectreProjectableElement {
|
|
|
778
1043
|
};
|
|
779
1044
|
SpectreSelectElement.properties = {
|
|
780
1045
|
autocomplete: { type: String, reflect: true },
|
|
781
|
-
autofocus: { type: Boolean, reflect: true },
|
|
782
1046
|
disabled: { type: Boolean, reflect: true },
|
|
783
1047
|
form: { type: String },
|
|
784
1048
|
fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
|
|
@@ -802,7 +1066,6 @@ function defineSpectreSelect(tagName = "sp-select") {
|
|
|
802
1066
|
var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
803
1067
|
constructor() {
|
|
804
1068
|
super(...arguments);
|
|
805
|
-
this.autofocus = false;
|
|
806
1069
|
this.checked = false;
|
|
807
1070
|
this.disabled = false;
|
|
808
1071
|
this.invalid = false;
|
|
@@ -811,6 +1074,24 @@ var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
|
811
1074
|
this.success = false;
|
|
812
1075
|
this.value = "on";
|
|
813
1076
|
}
|
|
1077
|
+
get id() {
|
|
1078
|
+
return super.id;
|
|
1079
|
+
}
|
|
1080
|
+
set id(value) {
|
|
1081
|
+
super.id = value;
|
|
1082
|
+
}
|
|
1083
|
+
get title() {
|
|
1084
|
+
return super.title;
|
|
1085
|
+
}
|
|
1086
|
+
set title(value) {
|
|
1087
|
+
super.title = value;
|
|
1088
|
+
}
|
|
1089
|
+
get autofocus() {
|
|
1090
|
+
return super.autofocus;
|
|
1091
|
+
}
|
|
1092
|
+
set autofocus(value) {
|
|
1093
|
+
super.autofocus = value;
|
|
1094
|
+
}
|
|
814
1095
|
getContentContainer() {
|
|
815
1096
|
return this.querySelector("[data-sp-checkbox-label]");
|
|
816
1097
|
}
|
|
@@ -822,6 +1103,24 @@ var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
|
822
1103
|
return el.hasAttribute("data-sp-checkbox-label") || el.hasAttribute("data-sp-checkbox-native") || el.hasAttribute("data-sp-checkbox-label-fallback") || el.hasAttribute("data-sp-checkbox-indicator");
|
|
823
1104
|
}
|
|
824
1105
|
willUpdate(changedProperties) {
|
|
1106
|
+
if (changedProperties.has("checked") && this.checked == null) {
|
|
1107
|
+
this.checked = false;
|
|
1108
|
+
}
|
|
1109
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
1110
|
+
this.disabled = false;
|
|
1111
|
+
}
|
|
1112
|
+
if (changedProperties.has("invalid") && this.invalid == null) {
|
|
1113
|
+
this.invalid = false;
|
|
1114
|
+
}
|
|
1115
|
+
if (changedProperties.has("loading") && this.loading == null) {
|
|
1116
|
+
this.loading = false;
|
|
1117
|
+
}
|
|
1118
|
+
if (changedProperties.has("required") && this.required == null) {
|
|
1119
|
+
this.required = false;
|
|
1120
|
+
}
|
|
1121
|
+
if (changedProperties.has("success") && this.success == null) {
|
|
1122
|
+
this.success = false;
|
|
1123
|
+
}
|
|
825
1124
|
if (changedProperties.has("value") && this.value == null) {
|
|
826
1125
|
this.value = "on";
|
|
827
1126
|
}
|
|
@@ -830,7 +1129,7 @@ var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
|
830
1129
|
return this.querySelector("[data-sp-checkbox-native]");
|
|
831
1130
|
}
|
|
832
1131
|
get isDisabled() {
|
|
833
|
-
return this.disabled || this.loading;
|
|
1132
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
834
1133
|
}
|
|
835
1134
|
get visibleLabelFallback() {
|
|
836
1135
|
const trimmedLabel = this.label?.trim();
|
|
@@ -851,7 +1150,10 @@ var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
|
851
1150
|
this.nativeInput?.blur();
|
|
852
1151
|
}
|
|
853
1152
|
render() {
|
|
854
|
-
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span
|
|
1153
|
+
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span
|
|
1154
|
+
class="${getInputLabelClasses({ disabled: this.isDisabled })}"
|
|
1155
|
+
data-sp-checkbox-label-fallback
|
|
1156
|
+
>${this.visibleLabelFallback}</span>` : nothing;
|
|
855
1157
|
return html`<label data-sp-checkbox-label>
|
|
856
1158
|
<input
|
|
857
1159
|
aria-busy="${this.loading ? "true" : "false"}"
|
|
@@ -879,7 +1181,6 @@ var SpectreCheckboxElement = class extends SpectreProjectableElement {
|
|
|
879
1181
|
}
|
|
880
1182
|
};
|
|
881
1183
|
SpectreCheckboxElement.properties = {
|
|
882
|
-
autofocus: { type: Boolean, reflect: true },
|
|
883
1184
|
checked: { type: Boolean, reflect: true },
|
|
884
1185
|
disabled: { type: Boolean, reflect: true },
|
|
885
1186
|
form: { type: String },
|
|
@@ -902,7 +1203,6 @@ function defineSpectreCheckbox(tagName = "sp-checkbox") {
|
|
|
902
1203
|
var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
903
1204
|
constructor() {
|
|
904
1205
|
super(...arguments);
|
|
905
|
-
this.autofocus = false;
|
|
906
1206
|
this.checked = false;
|
|
907
1207
|
this.disabled = false;
|
|
908
1208
|
this.invalid = false;
|
|
@@ -911,6 +1211,24 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
911
1211
|
this.success = false;
|
|
912
1212
|
this.value = "on";
|
|
913
1213
|
}
|
|
1214
|
+
get id() {
|
|
1215
|
+
return super.id;
|
|
1216
|
+
}
|
|
1217
|
+
set id(value) {
|
|
1218
|
+
super.id = value;
|
|
1219
|
+
}
|
|
1220
|
+
get title() {
|
|
1221
|
+
return super.title;
|
|
1222
|
+
}
|
|
1223
|
+
set title(value) {
|
|
1224
|
+
super.title = value;
|
|
1225
|
+
}
|
|
1226
|
+
get autofocus() {
|
|
1227
|
+
return super.autofocus;
|
|
1228
|
+
}
|
|
1229
|
+
set autofocus(value) {
|
|
1230
|
+
super.autofocus = value;
|
|
1231
|
+
}
|
|
914
1232
|
getContentContainer() {
|
|
915
1233
|
return this.querySelector("[data-sp-radio-label]");
|
|
916
1234
|
}
|
|
@@ -922,6 +1240,24 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
922
1240
|
return el.hasAttribute("data-sp-radio-label") || el.hasAttribute("data-sp-radio-native") || el.hasAttribute("data-sp-radio-label-fallback") || el.hasAttribute("data-sp-radio-indicator");
|
|
923
1241
|
}
|
|
924
1242
|
willUpdate(changedProperties) {
|
|
1243
|
+
if (changedProperties.has("checked") && this.checked == null) {
|
|
1244
|
+
this.checked = false;
|
|
1245
|
+
}
|
|
1246
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
1247
|
+
this.disabled = false;
|
|
1248
|
+
}
|
|
1249
|
+
if (changedProperties.has("invalid") && this.invalid == null) {
|
|
1250
|
+
this.invalid = false;
|
|
1251
|
+
}
|
|
1252
|
+
if (changedProperties.has("loading") && this.loading == null) {
|
|
1253
|
+
this.loading = false;
|
|
1254
|
+
}
|
|
1255
|
+
if (changedProperties.has("required") && this.required == null) {
|
|
1256
|
+
this.required = false;
|
|
1257
|
+
}
|
|
1258
|
+
if (changedProperties.has("success") && this.success == null) {
|
|
1259
|
+
this.success = false;
|
|
1260
|
+
}
|
|
925
1261
|
if (changedProperties.has("value") && this.value == null) {
|
|
926
1262
|
this.value = "on";
|
|
927
1263
|
}
|
|
@@ -930,7 +1266,7 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
930
1266
|
return this.querySelector("[data-sp-radio-native]");
|
|
931
1267
|
}
|
|
932
1268
|
get isDisabled() {
|
|
933
|
-
return this.disabled || this.loading;
|
|
1269
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
934
1270
|
}
|
|
935
1271
|
get visibleLabelFallback() {
|
|
936
1272
|
const trimmedLabel = this.label?.trim();
|
|
@@ -944,6 +1280,26 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
944
1280
|
const input = event.currentTarget;
|
|
945
1281
|
this.checked = input.checked;
|
|
946
1282
|
}
|
|
1283
|
+
updated(changedProperties) {
|
|
1284
|
+
super.updated(changedProperties);
|
|
1285
|
+
if ((changedProperties.has("checked") || changedProperties.has("name")) && this.checked && this.name) {
|
|
1286
|
+
this.syncGroup();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
syncGroup() {
|
|
1290
|
+
if (!this.name || !this.checked) {
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
const root = this.getRootNode();
|
|
1294
|
+
const radios = root.querySelectorAll(
|
|
1295
|
+
"sp-radio"
|
|
1296
|
+
);
|
|
1297
|
+
radios.forEach((radio) => {
|
|
1298
|
+
if (radio !== this && radio.name === this.name && radio.checked) {
|
|
1299
|
+
radio.checked = false;
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
947
1303
|
focus(options) {
|
|
948
1304
|
this.nativeInput?.focus(options);
|
|
949
1305
|
}
|
|
@@ -951,7 +1307,10 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
951
1307
|
this.nativeInput?.blur();
|
|
952
1308
|
}
|
|
953
1309
|
render() {
|
|
954
|
-
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span
|
|
1310
|
+
const labelContent = this.hasProjectedContent ? this.projectedContent : this.visibleLabelFallback ? html`<span
|
|
1311
|
+
class="${getInputLabelClasses({ disabled: this.isDisabled })}"
|
|
1312
|
+
data-sp-radio-label-fallback
|
|
1313
|
+
>${this.visibleLabelFallback}</span>` : nothing;
|
|
955
1314
|
return html`<label data-sp-radio-label>
|
|
956
1315
|
<input
|
|
957
1316
|
aria-busy="${this.loading ? "true" : "false"}"
|
|
@@ -979,7 +1338,6 @@ var SpectreRadioElement = class extends SpectreProjectableElement {
|
|
|
979
1338
|
}
|
|
980
1339
|
};
|
|
981
1340
|
SpectreRadioElement.properties = {
|
|
982
|
-
autofocus: { type: Boolean, reflect: true },
|
|
983
1341
|
checked: { type: Boolean, reflect: true },
|
|
984
1342
|
disabled: { type: Boolean, reflect: true },
|
|
985
1343
|
form: { type: String },
|
|
@@ -1000,6 +1358,30 @@ function defineSpectreRadio(tagName = "sp-radio") {
|
|
|
1000
1358
|
return SpectreRadioElement;
|
|
1001
1359
|
}
|
|
1002
1360
|
var SpectreLabelElement = class extends SpectreProjectableElement {
|
|
1361
|
+
constructor() {
|
|
1362
|
+
super(...arguments);
|
|
1363
|
+
this.disabled = false;
|
|
1364
|
+
}
|
|
1365
|
+
willUpdate(changedProperties) {
|
|
1366
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
1367
|
+
this.disabled = false;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
get isDisabled() {
|
|
1371
|
+
return this.disabled ?? false;
|
|
1372
|
+
}
|
|
1373
|
+
get id() {
|
|
1374
|
+
return super.id;
|
|
1375
|
+
}
|
|
1376
|
+
set id(value) {
|
|
1377
|
+
super.id = value;
|
|
1378
|
+
}
|
|
1379
|
+
get title() {
|
|
1380
|
+
return super.title;
|
|
1381
|
+
}
|
|
1382
|
+
set title(value) {
|
|
1383
|
+
super.title = value;
|
|
1384
|
+
}
|
|
1003
1385
|
getContentContainer() {
|
|
1004
1386
|
return this.querySelector("[data-sp-label-native]");
|
|
1005
1387
|
}
|
|
@@ -1021,7 +1403,7 @@ var SpectreLabelElement = class extends SpectreProjectableElement {
|
|
|
1021
1403
|
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
1022
1404
|
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
1023
1405
|
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
1024
|
-
class="
|
|
1406
|
+
class="${getInputLabelClasses({ disabled: this.isDisabled })}"
|
|
1025
1407
|
data-sp-label-native
|
|
1026
1408
|
for="${ifDefined(this.htmlFor || void 0)}"
|
|
1027
1409
|
id="${ifDefined(this.id || void 0)}"
|
|
@@ -1032,6 +1414,7 @@ var SpectreLabelElement = class extends SpectreProjectableElement {
|
|
|
1032
1414
|
}
|
|
1033
1415
|
};
|
|
1034
1416
|
SpectreLabelElement.properties = {
|
|
1417
|
+
disabled: { type: Boolean, reflect: true },
|
|
1035
1418
|
htmlFor: { attribute: "for", type: String, reflect: true }
|
|
1036
1419
|
};
|
|
1037
1420
|
function defineSpectreLabel(tagName = "sp-label") {
|
|
@@ -1046,6 +1429,34 @@ var SpectreFieldsetElement = class extends SpectreProjectableElement {
|
|
|
1046
1429
|
constructor() {
|
|
1047
1430
|
super(...arguments);
|
|
1048
1431
|
this.disabled = false;
|
|
1432
|
+
this.invalid = false;
|
|
1433
|
+
this.loading = false;
|
|
1434
|
+
this.success = false;
|
|
1435
|
+
}
|
|
1436
|
+
get id() {
|
|
1437
|
+
return super.id;
|
|
1438
|
+
}
|
|
1439
|
+
set id(value) {
|
|
1440
|
+
super.id = value;
|
|
1441
|
+
}
|
|
1442
|
+
get title() {
|
|
1443
|
+
return super.title;
|
|
1444
|
+
}
|
|
1445
|
+
set title(value) {
|
|
1446
|
+
super.title = value;
|
|
1447
|
+
}
|
|
1448
|
+
get autofocus() {
|
|
1449
|
+
return super.autofocus;
|
|
1450
|
+
}
|
|
1451
|
+
set autofocus(value) {
|
|
1452
|
+
super.autofocus = value;
|
|
1453
|
+
}
|
|
1454
|
+
get visibleLegend() {
|
|
1455
|
+
const trimmedLegend = this.legend?.trim();
|
|
1456
|
+
return trimmedLegend ? trimmedLegend : void 0;
|
|
1457
|
+
}
|
|
1458
|
+
get isDisabled() {
|
|
1459
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
1049
1460
|
}
|
|
1050
1461
|
getContentContainer() {
|
|
1051
1462
|
return this.querySelector("[data-sp-fieldset-native]");
|
|
@@ -1057,6 +1468,20 @@ var SpectreFieldsetElement = class extends SpectreProjectableElement {
|
|
|
1057
1468
|
const el = node;
|
|
1058
1469
|
return el.hasAttribute("data-sp-fieldset-native") || el.hasAttribute("data-sp-fieldset-legend");
|
|
1059
1470
|
}
|
|
1471
|
+
willUpdate(changedProperties) {
|
|
1472
|
+
if (changedProperties.has("disabled") && this.disabled == null) {
|
|
1473
|
+
this.disabled = false;
|
|
1474
|
+
}
|
|
1475
|
+
if (changedProperties.has("invalid") && this.invalid == null) {
|
|
1476
|
+
this.invalid = false;
|
|
1477
|
+
}
|
|
1478
|
+
if (changedProperties.has("loading") && this.loading == null) {
|
|
1479
|
+
this.loading = false;
|
|
1480
|
+
}
|
|
1481
|
+
if (changedProperties.has("success") && this.success == null) {
|
|
1482
|
+
this.success = false;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1060
1485
|
focus(options) {
|
|
1061
1486
|
this.getContentContainer()?.focus(options);
|
|
1062
1487
|
}
|
|
@@ -1065,17 +1490,23 @@ var SpectreFieldsetElement = class extends SpectreProjectableElement {
|
|
|
1065
1490
|
}
|
|
1066
1491
|
render() {
|
|
1067
1492
|
return html`<fieldset
|
|
1493
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
1068
1494
|
aria-describedby="${ifDefined(this.forwardedAriaDescribedBy)}"
|
|
1495
|
+
aria-invalid="${ifDefined(this.invalid ? "true" : void 0)}"
|
|
1069
1496
|
aria-label="${ifDefined(this.forwardedAriaLabel)}"
|
|
1070
1497
|
aria-labelledby="${ifDefined(this.forwardedAriaLabelledBy)}"
|
|
1498
|
+
?autofocus="${this.autofocus}"
|
|
1071
1499
|
data-sp-fieldset-native
|
|
1072
|
-
?disabled="${this.
|
|
1500
|
+
?disabled="${this.isDisabled}"
|
|
1073
1501
|
form="${ifDefined(this.form || void 0)}"
|
|
1074
1502
|
id="${ifDefined(this.id || void 0)}"
|
|
1075
1503
|
name="${ifDefined(this.name || void 0)}"
|
|
1076
1504
|
title="${ifDefined(this.title || void 0)}"
|
|
1077
1505
|
>
|
|
1078
|
-
${this.
|
|
1506
|
+
${this.visibleLegend ? html`<legend
|
|
1507
|
+
class="${getInputLabelClasses({ disabled: this.isDisabled })}"
|
|
1508
|
+
data-sp-fieldset-legend
|
|
1509
|
+
>${this.visibleLegend}</legend>` : nothing}
|
|
1079
1510
|
${this.hasProjectedContent ? this.projectedContent : nothing}
|
|
1080
1511
|
</fieldset>`;
|
|
1081
1512
|
}
|
|
@@ -1083,8 +1514,11 @@ var SpectreFieldsetElement = class extends SpectreProjectableElement {
|
|
|
1083
1514
|
SpectreFieldsetElement.properties = {
|
|
1084
1515
|
disabled: { type: Boolean, reflect: true },
|
|
1085
1516
|
form: { type: String },
|
|
1517
|
+
invalid: { type: Boolean, reflect: true },
|
|
1086
1518
|
legend: { type: String, reflect: true },
|
|
1087
|
-
|
|
1519
|
+
loading: { type: Boolean, reflect: true },
|
|
1520
|
+
name: { type: String, reflect: true },
|
|
1521
|
+
success: { type: Boolean, reflect: true }
|
|
1088
1522
|
};
|
|
1089
1523
|
function defineSpectreFieldset(tagName = "sp-fieldset") {
|
|
1090
1524
|
const existingElement = customElements.get(tagName);
|
|
@@ -1107,6 +1541,6 @@ function defineSpectreComponents() {
|
|
|
1107
1541
|
defineSpectreFieldset();
|
|
1108
1542
|
}
|
|
1109
1543
|
|
|
1110
|
-
export { SpectreButtonElement, SpectreCheckboxElement, SpectreFieldsetElement, SpectreInputElement, SpectreLabelElement, SpectreRadioElement, SpectreSelectElement, SpectreTextareaElement, defineSpectreButton, defineSpectreCheckbox, defineSpectreComponents, defineSpectreFieldset, defineSpectreInput, defineSpectreLabel, defineSpectreRadio, defineSpectreSelect, defineSpectreTextarea, spectreButtonSizes, spectreButtonTypes, spectreButtonVariants, spectreInputSizes, spectreInputTypes };
|
|
1544
|
+
export { SpectreButtonElement, SpectreCheckboxElement, SpectreFieldsetElement, SpectreInputElement, SpectreLabelElement, SpectreRadioElement, SpectreSelectElement, SpectreTextareaElement, defineSpectreButton, defineSpectreCheckbox, defineSpectreComponents, defineSpectreFieldset, defineSpectreInput, defineSpectreLabel, defineSpectreRadio, defineSpectreSelect, defineSpectreTextarea, spectreInputSizes as spectreButtonSizes, spectreButtonTypes, spectreButtonVariants, spectreInputSizes, spectreInputTypes };
|
|
1111
1545
|
//# sourceMappingURL=index.js.map
|
|
1112
1546
|
//# sourceMappingURL=index.js.map
|