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