@phcdevworks/spectre-components 1.0.0 → 1.2.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 +586 -107
- package/dist/base-B_9DJkh2.d.cts +38 -0
- package/dist/base-B_9DJkh2.d.ts +38 -0
- package/dist/button.cjs +252 -90
- package/dist/button.cjs.map +1 -1
- package/dist/button.d.cts +39 -37
- package/dist/button.d.ts +39 -37
- package/dist/button.js +252 -90
- package/dist/button.js.map +1 -1
- package/dist/checkbox.cjs +228 -67
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.d.cts +21 -21
- package/dist/checkbox.d.ts +21 -21
- package/dist/checkbox.js +228 -67
- package/dist/checkbox.js.map +1 -1
- package/dist/fieldset.cjs +245 -56
- package/dist/fieldset.cjs.map +1 -1
- package/dist/fieldset.d.cts +35 -14
- package/dist/fieldset.d.ts +35 -14
- package/dist/fieldset.js +245 -56
- package/dist/fieldset.js.map +1 -1
- package/dist/form-9cZG1E9P.d.cts +10 -0
- package/dist/form-9cZG1E9P.d.ts +10 -0
- package/dist/index.cjs +647 -328
- 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 +647 -328
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +262 -77
- package/dist/input.cjs.map +1 -1
- package/dist/input.d.cts +72 -40
- package/dist/input.d.ts +72 -40
- package/dist/input.js +262 -77
- package/dist/input.js.map +1 -1
- package/dist/label.cjs +217 -55
- package/dist/label.cjs.map +1 -1
- package/dist/label.d.cts +17 -10
- package/dist/label.d.ts +17 -10
- package/dist/label.js +217 -55
- package/dist/label.js.map +1 -1
- package/dist/{projectable-DcnBRiko.d.cts → projectable-CIfxi7dv.d.cts} +1 -1
- package/dist/{projectable-SzbPvXfM.d.ts → projectable-Ksv9eoIr.d.ts} +1 -1
- package/dist/radio.cjs +248 -67
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.d.cts +23 -21
- package/dist/radio.d.ts +23 -21
- package/dist/radio.js +248 -67
- package/dist/radio.js.map +1 -1
- package/dist/select.cjs +230 -67
- package/dist/select.cjs.map +1 -1
- package/dist/select.d.cts +27 -27
- package/dist/select.d.ts +27 -27
- package/dist/select.js +230 -67
- package/dist/select.js.map +1 -1
- package/dist/textarea.cjs +256 -77
- package/dist/textarea.cjs.map +1 -1
- package/dist/textarea.d.cts +53 -32
- package/dist/textarea.d.ts +53 -32
- package/dist/textarea.js +256 -77
- package/dist/textarea.js.map +1 -1
- package/package.json +22 -12
- package/dist/base-DQtCQ-dP.d.cts +0 -22
- package/dist/base-DQtCQ-dP.d.ts +0 -22
- package/dist/form-iI7vV-3W.d.cts +0 -6
- package/dist/form-iI7vV-3W.d.ts +0 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, PropertyDeclarations } from 'lit';
|
|
2
|
+
|
|
3
|
+
declare class SpectreBaseElement extends LitElement {
|
|
4
|
+
static properties: PropertyDeclarations;
|
|
5
|
+
private _ariaLabel;
|
|
6
|
+
private _ariaLabelledBy;
|
|
7
|
+
private _ariaDescribedBy;
|
|
8
|
+
private _autocapitalize;
|
|
9
|
+
private _spellcheck;
|
|
10
|
+
private _title;
|
|
11
|
+
private _id;
|
|
12
|
+
get ariaLabel(): string | null;
|
|
13
|
+
set ariaLabel(value: string | null);
|
|
14
|
+
get ariaLabelledBy(): string | null;
|
|
15
|
+
set ariaLabelledBy(value: string | null);
|
|
16
|
+
get ariaDescribedBy(): string | null;
|
|
17
|
+
set ariaDescribedBy(value: string | null);
|
|
18
|
+
get autocapitalize(): string;
|
|
19
|
+
set autocapitalize(value: string | undefined | null);
|
|
20
|
+
get spellcheck(): boolean;
|
|
21
|
+
set spellcheck(value: boolean | undefined | null);
|
|
22
|
+
get title(): string;
|
|
23
|
+
set title(value: string | undefined | null);
|
|
24
|
+
get id(): string;
|
|
25
|
+
set id(value: string | undefined | null);
|
|
26
|
+
createRenderRoot(): this;
|
|
27
|
+
connectedCallback(): void;
|
|
28
|
+
getAttribute(qualifiedName: string): string | null;
|
|
29
|
+
hasAttribute(qualifiedName: string): boolean;
|
|
30
|
+
setAttribute(qualifiedName: string, value: string): void;
|
|
31
|
+
removeAttribute(qualifiedName: string): void;
|
|
32
|
+
private _removeHostAttribute;
|
|
33
|
+
protected get forwardedAriaLabel(): string | undefined;
|
|
34
|
+
protected get forwardedAriaLabelledBy(): string | undefined;
|
|
35
|
+
protected get forwardedAriaDescribedBy(): string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { SpectreBaseElement as S };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, PropertyDeclarations } from 'lit';
|
|
2
|
+
|
|
3
|
+
declare class SpectreBaseElement extends LitElement {
|
|
4
|
+
static properties: PropertyDeclarations;
|
|
5
|
+
private _ariaLabel;
|
|
6
|
+
private _ariaLabelledBy;
|
|
7
|
+
private _ariaDescribedBy;
|
|
8
|
+
private _autocapitalize;
|
|
9
|
+
private _spellcheck;
|
|
10
|
+
private _title;
|
|
11
|
+
private _id;
|
|
12
|
+
get ariaLabel(): string | null;
|
|
13
|
+
set ariaLabel(value: string | null);
|
|
14
|
+
get ariaLabelledBy(): string | null;
|
|
15
|
+
set ariaLabelledBy(value: string | null);
|
|
16
|
+
get ariaDescribedBy(): string | null;
|
|
17
|
+
set ariaDescribedBy(value: string | null);
|
|
18
|
+
get autocapitalize(): string;
|
|
19
|
+
set autocapitalize(value: string | undefined | null);
|
|
20
|
+
get spellcheck(): boolean;
|
|
21
|
+
set spellcheck(value: boolean | undefined | null);
|
|
22
|
+
get title(): string;
|
|
23
|
+
set title(value: string | undefined | null);
|
|
24
|
+
get id(): string;
|
|
25
|
+
set id(value: string | undefined | null);
|
|
26
|
+
createRenderRoot(): this;
|
|
27
|
+
connectedCallback(): void;
|
|
28
|
+
getAttribute(qualifiedName: string): string | null;
|
|
29
|
+
hasAttribute(qualifiedName: string): boolean;
|
|
30
|
+
setAttribute(qualifiedName: string, value: string): void;
|
|
31
|
+
removeAttribute(qualifiedName: string): void;
|
|
32
|
+
private _removeHostAttribute;
|
|
33
|
+
protected get forwardedAriaLabel(): string | undefined;
|
|
34
|
+
protected get forwardedAriaLabelledBy(): string | undefined;
|
|
35
|
+
protected get forwardedAriaDescribedBy(): string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { SpectreBaseElement as S };
|
package/dist/button.cjs
CHANGED
|
@@ -1,29 +1,119 @@
|
|
|
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
|
|
|
7
|
-
// src/
|
|
7
|
+
// src/utils/form.ts
|
|
8
|
+
var spectreInputSizes = ["sm", "md", "lg"];
|
|
9
|
+
function isInputSize(value) {
|
|
10
|
+
return spectreInputSizes.includes(value);
|
|
11
|
+
}
|
|
12
|
+
var spectreButtonVariants = [
|
|
13
|
+
"primary",
|
|
14
|
+
"secondary",
|
|
15
|
+
"ghost",
|
|
16
|
+
"danger",
|
|
17
|
+
"success",
|
|
18
|
+
"cta",
|
|
19
|
+
"accent"
|
|
20
|
+
];
|
|
21
|
+
function isButtonVariant(value) {
|
|
22
|
+
return spectreButtonVariants.includes(value);
|
|
23
|
+
}
|
|
24
|
+
var spectreButtonTypes = ["button", "submit", "reset"];
|
|
25
|
+
function isButtonType(value) {
|
|
26
|
+
return spectreButtonTypes.includes(value);
|
|
27
|
+
}
|
|
8
28
|
var SpectreBaseElement = class extends lit.LitElement {
|
|
9
29
|
constructor() {
|
|
10
30
|
super(...arguments);
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
31
|
+
this._ariaLabel = null;
|
|
32
|
+
this._ariaLabelledBy = null;
|
|
33
|
+
this._ariaDescribedBy = null;
|
|
34
|
+
this._autocapitalize = "";
|
|
35
|
+
this._spellcheck = null;
|
|
36
|
+
this._title = "";
|
|
37
|
+
this._id = "";
|
|
38
|
+
}
|
|
39
|
+
get ariaLabel() {
|
|
40
|
+
return this._ariaLabel;
|
|
41
|
+
}
|
|
42
|
+
set ariaLabel(value) {
|
|
43
|
+
if (this._ariaLabel === value) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this._ariaLabel = value;
|
|
47
|
+
this._removeHostAttribute("aria-label");
|
|
48
|
+
this.requestUpdate();
|
|
49
|
+
}
|
|
50
|
+
get ariaLabelledBy() {
|
|
51
|
+
return this._ariaLabelledBy;
|
|
52
|
+
}
|
|
53
|
+
set ariaLabelledBy(value) {
|
|
54
|
+
if (this._ariaLabelledBy === value) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this._ariaLabelledBy = value;
|
|
58
|
+
this._removeHostAttribute("aria-labelledby");
|
|
59
|
+
this.requestUpdate();
|
|
60
|
+
}
|
|
61
|
+
get ariaDescribedBy() {
|
|
62
|
+
return this._ariaDescribedBy;
|
|
63
|
+
}
|
|
64
|
+
set ariaDescribedBy(value) {
|
|
65
|
+
if (this._ariaDescribedBy === value) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this._ariaDescribedBy = value;
|
|
69
|
+
this._removeHostAttribute("aria-describedby");
|
|
70
|
+
this.requestUpdate();
|
|
71
|
+
}
|
|
72
|
+
get autocapitalize() {
|
|
73
|
+
return this._autocapitalize;
|
|
74
|
+
}
|
|
75
|
+
set autocapitalize(value) {
|
|
76
|
+
const normalizedValue = value ?? "";
|
|
77
|
+
if (this._autocapitalize === normalizedValue) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this._autocapitalize = normalizedValue;
|
|
81
|
+
this._removeHostAttribute("autocapitalize");
|
|
82
|
+
this.requestUpdate();
|
|
83
|
+
}
|
|
84
|
+
get spellcheck() {
|
|
85
|
+
return this._spellcheck ?? super.spellcheck;
|
|
86
|
+
}
|
|
87
|
+
set spellcheck(value) {
|
|
88
|
+
if (this._spellcheck === value) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this._spellcheck = value ?? null;
|
|
92
|
+
this._removeHostAttribute("spellcheck");
|
|
93
|
+
this.requestUpdate();
|
|
94
|
+
}
|
|
95
|
+
get title() {
|
|
96
|
+
return this._title;
|
|
97
|
+
}
|
|
98
|
+
set title(value) {
|
|
99
|
+
const normalizedValue = value ?? "";
|
|
100
|
+
if (this._title === normalizedValue) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this._title = normalizedValue;
|
|
104
|
+
this._removeHostAttribute("title");
|
|
105
|
+
this.requestUpdate();
|
|
14
106
|
}
|
|
15
107
|
get id() {
|
|
16
|
-
return this._id
|
|
108
|
+
return this._id;
|
|
17
109
|
}
|
|
18
110
|
set id(value) {
|
|
19
|
-
|
|
111
|
+
const normalizedValue = value ?? "";
|
|
112
|
+
if (this._id === normalizedValue) {
|
|
20
113
|
return;
|
|
21
114
|
}
|
|
22
|
-
this._id =
|
|
23
|
-
|
|
24
|
-
if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
|
|
25
|
-
HTMLElement.prototype.removeAttribute.call(host, "id");
|
|
26
|
-
}
|
|
115
|
+
this._id = normalizedValue;
|
|
116
|
+
this._removeHostAttribute("id");
|
|
27
117
|
this.requestUpdate();
|
|
28
118
|
}
|
|
29
119
|
// Spectre components intentionally render in light DOM so the global
|
|
@@ -33,36 +123,121 @@ var SpectreBaseElement = class extends lit.LitElement {
|
|
|
33
123
|
}
|
|
34
124
|
connectedCallback() {
|
|
35
125
|
super.connectedCallback();
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
126
|
+
const proxiedAttributes = [
|
|
127
|
+
"id",
|
|
128
|
+
"title",
|
|
129
|
+
"autocapitalize",
|
|
130
|
+
"spellcheck",
|
|
131
|
+
"aria-label",
|
|
132
|
+
"aria-labelledby",
|
|
133
|
+
"aria-describedby"
|
|
134
|
+
];
|
|
135
|
+
proxiedAttributes.forEach((attr) => {
|
|
136
|
+
const value = super.getAttribute(attr);
|
|
137
|
+
if (value !== null) {
|
|
138
|
+
this.setAttribute(attr, value);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
40
141
|
}
|
|
41
142
|
getAttribute(qualifiedName) {
|
|
42
|
-
|
|
43
|
-
|
|
143
|
+
switch (qualifiedName) {
|
|
144
|
+
case "id":
|
|
145
|
+
return this.id || null;
|
|
146
|
+
case "title":
|
|
147
|
+
return this.title || null;
|
|
148
|
+
case "autocapitalize":
|
|
149
|
+
return this.autocapitalize || null;
|
|
150
|
+
case "spellcheck":
|
|
151
|
+
return this._spellcheck !== null ? String(this._spellcheck) : null;
|
|
152
|
+
case "aria-label":
|
|
153
|
+
return this.ariaLabel;
|
|
154
|
+
case "aria-labelledby":
|
|
155
|
+
return this.ariaLabelledBy;
|
|
156
|
+
case "aria-describedby":
|
|
157
|
+
return this.ariaDescribedBy;
|
|
158
|
+
default:
|
|
159
|
+
return super.getAttribute(qualifiedName);
|
|
44
160
|
}
|
|
45
|
-
return super.getAttribute(qualifiedName);
|
|
46
161
|
}
|
|
47
162
|
hasAttribute(qualifiedName) {
|
|
48
|
-
|
|
49
|
-
|
|
163
|
+
switch (qualifiedName) {
|
|
164
|
+
case "id":
|
|
165
|
+
return this.id !== "";
|
|
166
|
+
case "title":
|
|
167
|
+
return this.title !== "";
|
|
168
|
+
case "autocapitalize":
|
|
169
|
+
return this.autocapitalize !== "";
|
|
170
|
+
case "spellcheck":
|
|
171
|
+
return this._spellcheck !== null;
|
|
172
|
+
case "aria-label":
|
|
173
|
+
return this.ariaLabel !== null;
|
|
174
|
+
case "aria-labelledby":
|
|
175
|
+
return this.ariaLabelledBy !== null;
|
|
176
|
+
case "aria-describedby":
|
|
177
|
+
return this.ariaDescribedBy !== null;
|
|
178
|
+
default:
|
|
179
|
+
return super.hasAttribute(qualifiedName);
|
|
50
180
|
}
|
|
51
|
-
return super.hasAttribute(qualifiedName);
|
|
52
181
|
}
|
|
53
182
|
setAttribute(qualifiedName, value) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
183
|
+
switch (qualifiedName) {
|
|
184
|
+
case "id":
|
|
185
|
+
this.id = value;
|
|
186
|
+
break;
|
|
187
|
+
case "title":
|
|
188
|
+
this.title = value;
|
|
189
|
+
break;
|
|
190
|
+
case "autocapitalize":
|
|
191
|
+
this.autocapitalize = value;
|
|
192
|
+
break;
|
|
193
|
+
case "spellcheck":
|
|
194
|
+
this.spellcheck = value !== "false";
|
|
195
|
+
break;
|
|
196
|
+
case "aria-label":
|
|
197
|
+
this.ariaLabel = value;
|
|
198
|
+
break;
|
|
199
|
+
case "aria-labelledby":
|
|
200
|
+
this.ariaLabelledBy = value;
|
|
201
|
+
break;
|
|
202
|
+
case "aria-describedby":
|
|
203
|
+
this.ariaDescribedBy = value;
|
|
204
|
+
break;
|
|
205
|
+
default:
|
|
206
|
+
super.setAttribute(qualifiedName, value);
|
|
57
207
|
}
|
|
58
|
-
super.setAttribute(qualifiedName, value);
|
|
59
208
|
}
|
|
60
209
|
removeAttribute(qualifiedName) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
210
|
+
switch (qualifiedName) {
|
|
211
|
+
case "id":
|
|
212
|
+
this.id = "";
|
|
213
|
+
break;
|
|
214
|
+
case "title":
|
|
215
|
+
this.title = "";
|
|
216
|
+
break;
|
|
217
|
+
case "autocapitalize":
|
|
218
|
+
this.autocapitalize = "";
|
|
219
|
+
break;
|
|
220
|
+
case "spellcheck":
|
|
221
|
+
this.spellcheck = null;
|
|
222
|
+
break;
|
|
223
|
+
case "aria-label":
|
|
224
|
+
this.ariaLabel = null;
|
|
225
|
+
break;
|
|
226
|
+
case "aria-labelledby":
|
|
227
|
+
this.ariaLabelledBy = null;
|
|
228
|
+
break;
|
|
229
|
+
case "aria-describedby":
|
|
230
|
+
this.ariaDescribedBy = null;
|
|
231
|
+
break;
|
|
232
|
+
default:
|
|
233
|
+
super.removeAttribute(qualifiedName);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
_removeHostAttribute(name) {
|
|
237
|
+
const host = this;
|
|
238
|
+
if (HTMLElement.prototype.hasAttribute.call(host, name)) {
|
|
239
|
+
HTMLElement.prototype.removeAttribute.call(host, name);
|
|
64
240
|
}
|
|
65
|
-
super.removeAttribute(qualifiedName);
|
|
66
241
|
}
|
|
67
242
|
get forwardedAriaLabel() {
|
|
68
243
|
const value = this.ariaLabel?.trim();
|
|
@@ -77,11 +252,7 @@ var SpectreBaseElement = class extends lit.LitElement {
|
|
|
77
252
|
return value ? value : void 0;
|
|
78
253
|
}
|
|
79
254
|
};
|
|
80
|
-
SpectreBaseElement.properties = {
|
|
81
|
-
ariaLabel: { attribute: "aria-label", type: String },
|
|
82
|
-
ariaLabelledBy: { attribute: "aria-labelledby", type: String },
|
|
83
|
-
ariaDescribedBy: { attribute: "aria-describedby", type: String }
|
|
84
|
-
};
|
|
255
|
+
SpectreBaseElement.properties = {};
|
|
85
256
|
|
|
86
257
|
// src/utils/dom.ts
|
|
87
258
|
function hasMeaningfulContent(nodes) {
|
|
@@ -142,9 +313,9 @@ var SpectreProjectableElement = class extends SpectreBaseElement {
|
|
|
142
313
|
}
|
|
143
314
|
this.contentObserver = new MutationObserver((mutations) => {
|
|
144
315
|
const isInternalMovement = mutations.every(
|
|
145
|
-
(mutation) =>
|
|
316
|
+
(mutation) => [...mutation.removedNodes].every(
|
|
146
317
|
(node) => this.isInternalNode(node) || this.contains(node)
|
|
147
|
-
) &&
|
|
318
|
+
) && [...mutation.addedNodes].every((node) => this.isInternalNode(node))
|
|
148
319
|
);
|
|
149
320
|
if (isInternalMovement) {
|
|
150
321
|
return;
|
|
@@ -160,41 +331,33 @@ var SpectreProjectableElement = class extends SpectreBaseElement {
|
|
|
160
331
|
this.contentObserver = void 0;
|
|
161
332
|
}
|
|
162
333
|
};
|
|
163
|
-
var spectreButtonVariants = [
|
|
164
|
-
"primary",
|
|
165
|
-
"secondary",
|
|
166
|
-
"ghost",
|
|
167
|
-
"danger",
|
|
168
|
-
"success",
|
|
169
|
-
"cta",
|
|
170
|
-
"accent"
|
|
171
|
-
];
|
|
172
|
-
var spectreButtonSizes = ["sm", "md", "lg"];
|
|
173
|
-
var spectreButtonTypes = ["button", "submit", "reset"];
|
|
174
|
-
function isButtonVariant(value) {
|
|
175
|
-
return spectreButtonVariants.includes(value);
|
|
176
|
-
}
|
|
177
|
-
function isButtonSize(value) {
|
|
178
|
-
return spectreButtonSizes.includes(value);
|
|
179
|
-
}
|
|
180
|
-
function isButtonType(value) {
|
|
181
|
-
return spectreButtonTypes.includes(value);
|
|
182
|
-
}
|
|
183
334
|
var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
184
335
|
constructor() {
|
|
185
336
|
super(...arguments);
|
|
186
337
|
this.autofocus = false;
|
|
187
338
|
this.disabled = false;
|
|
188
339
|
this.fullWidth = false;
|
|
340
|
+
this.iconOnly = false;
|
|
189
341
|
this.loading = false;
|
|
190
342
|
this.loadingLabel = "Loading";
|
|
191
343
|
this.pill = false;
|
|
192
344
|
this.size = "md";
|
|
193
|
-
this.title = "";
|
|
194
345
|
this.type = "button";
|
|
195
346
|
this.variant = "primary";
|
|
196
347
|
this.value = "";
|
|
197
348
|
}
|
|
349
|
+
get id() {
|
|
350
|
+
return super.id;
|
|
351
|
+
}
|
|
352
|
+
set id(value) {
|
|
353
|
+
super.id = value;
|
|
354
|
+
}
|
|
355
|
+
get title() {
|
|
356
|
+
return super.title;
|
|
357
|
+
}
|
|
358
|
+
set title(value) {
|
|
359
|
+
super.title = value;
|
|
360
|
+
}
|
|
198
361
|
getContentContainer() {
|
|
199
362
|
return this.querySelector("[data-sp-button-native]");
|
|
200
363
|
}
|
|
@@ -206,13 +369,13 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
206
369
|
return el.hasAttribute("data-sp-button-native") || el.hasAttribute("data-sp-button-loading-label") || el.hasAttribute("data-sp-button-label-fallback");
|
|
207
370
|
}
|
|
208
371
|
willUpdate(changedProperties) {
|
|
209
|
-
if (changedProperties.has("variant") && !isButtonVariant(this.variant)) {
|
|
372
|
+
if (changedProperties.has("variant") && (this.variant == null || !isButtonVariant(this.variant))) {
|
|
210
373
|
this.variant = "primary";
|
|
211
374
|
}
|
|
212
|
-
if (changedProperties.has("size") && !
|
|
375
|
+
if (changedProperties.has("size") && (this.size == null || !isInputSize(this.size))) {
|
|
213
376
|
this.size = "md";
|
|
214
377
|
}
|
|
215
|
-
if (changedProperties.has("type") && !isButtonType(this.type)) {
|
|
378
|
+
if (changedProperties.has("type") && (this.type == null || !isButtonType(this.type))) {
|
|
216
379
|
this.type = "button";
|
|
217
380
|
}
|
|
218
381
|
if (changedProperties.has("loadingLabel")) {
|
|
@@ -227,15 +390,16 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
227
390
|
get buttonClasses() {
|
|
228
391
|
return spectreUi.getButtonClasses({
|
|
229
392
|
disabled: this.isDisabled,
|
|
230
|
-
fullWidth: this.fullWidth,
|
|
231
|
-
|
|
232
|
-
|
|
393
|
+
fullWidth: this.fullWidth ?? false,
|
|
394
|
+
iconOnly: this.iconOnly ?? false,
|
|
395
|
+
loading: this.loading ?? false,
|
|
396
|
+
pill: this.pill ?? false,
|
|
233
397
|
size: this.size,
|
|
234
398
|
variant: this.variant
|
|
235
399
|
});
|
|
236
400
|
}
|
|
237
401
|
get isDisabled() {
|
|
238
|
-
return this.disabled || this.loading;
|
|
402
|
+
return (this.disabled ?? false) || (this.loading ?? false);
|
|
239
403
|
}
|
|
240
404
|
get visibleLabelFallback() {
|
|
241
405
|
const trimmedLabel = this.label?.trim();
|
|
@@ -249,34 +413,32 @@ var SpectreButtonElement = class extends SpectreProjectableElement {
|
|
|
249
413
|
}
|
|
250
414
|
renderButtonContent() {
|
|
251
415
|
if (this.loading) {
|
|
252
|
-
return lit.html`<span data-sp-button-loading-label>${this.loadingLabel}</span>`;
|
|
416
|
+
return lit.html`<span class="sp-label" data-sp-button-loading-label>${this.loadingLabel}</span>`;
|
|
253
417
|
}
|
|
254
418
|
if (this.hasProjectedContent) {
|
|
255
419
|
return this.projectedContent;
|
|
256
420
|
}
|
|
257
|
-
return this.visibleLabelFallback ? lit.html`<span data-sp-button-label-fallback>${this.visibleLabelFallback}</span>` : lit.nothing;
|
|
421
|
+
return this.visibleLabelFallback ? lit.html`<span class="sp-label" data-sp-button-label-fallback>${this.visibleLabelFallback}</span>` : lit.nothing;
|
|
258
422
|
}
|
|
259
423
|
render() {
|
|
260
|
-
return lit.html
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
</button>
|
|
279
|
-
`;
|
|
424
|
+
return lit.html`<button
|
|
425
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
426
|
+
aria-describedby="${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}"
|
|
427
|
+
aria-label="${ifDefined_js.ifDefined(this.forwardedAriaLabel)}"
|
|
428
|
+
aria-labelledby="${ifDefined_js.ifDefined(this.forwardedAriaLabelledBy)}"
|
|
429
|
+
?autofocus="${this.autofocus}"
|
|
430
|
+
class="${this.buttonClasses}"
|
|
431
|
+
data-sp-button-native
|
|
432
|
+
?disabled="${this.isDisabled}"
|
|
433
|
+
form="${ifDefined_js.ifDefined(this.form || void 0)}"
|
|
434
|
+
id="${ifDefined_js.ifDefined(this.id || void 0)}"
|
|
435
|
+
name="${ifDefined_js.ifDefined(this.name || void 0)}"
|
|
436
|
+
title="${ifDefined_js.ifDefined(this.title || void 0)}"
|
|
437
|
+
type="${this.type}"
|
|
438
|
+
value="${ifDefined_js.ifDefined(this.value)}"
|
|
439
|
+
>
|
|
440
|
+
${this.renderButtonContent()}
|
|
441
|
+
</button>`;
|
|
280
442
|
}
|
|
281
443
|
};
|
|
282
444
|
SpectreButtonElement.properties = {
|
|
@@ -284,16 +446,16 @@ SpectreButtonElement.properties = {
|
|
|
284
446
|
disabled: { type: Boolean, reflect: true },
|
|
285
447
|
form: { type: String },
|
|
286
448
|
fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
|
|
449
|
+
iconOnly: { attribute: "icon-only", type: Boolean, reflect: true },
|
|
287
450
|
label: { type: String, reflect: true },
|
|
288
451
|
loading: { type: Boolean, reflect: true },
|
|
289
452
|
loadingLabel: { attribute: "loading-label", type: String, reflect: true },
|
|
290
453
|
name: { type: String, reflect: true },
|
|
291
454
|
pill: { type: Boolean, reflect: true },
|
|
292
455
|
size: { type: String, reflect: true },
|
|
293
|
-
title: { type: String, reflect: true },
|
|
294
456
|
type: { type: String, reflect: true },
|
|
295
457
|
variant: { type: String, reflect: true },
|
|
296
|
-
value: { type: String
|
|
458
|
+
value: { type: String }
|
|
297
459
|
};
|
|
298
460
|
function defineSpectreButton(tagName = "sp-button") {
|
|
299
461
|
const existingElement = customElements.get(tagName);
|
|
@@ -306,7 +468,7 @@ function defineSpectreButton(tagName = "sp-button") {
|
|
|
306
468
|
|
|
307
469
|
exports.SpectreButtonElement = SpectreButtonElement;
|
|
308
470
|
exports.defineSpectreButton = defineSpectreButton;
|
|
309
|
-
exports.spectreButtonSizes =
|
|
471
|
+
exports.spectreButtonSizes = spectreInputSizes;
|
|
310
472
|
exports.spectreButtonTypes = spectreButtonTypes;
|
|
311
473
|
exports.spectreButtonVariants = spectreButtonVariants;
|
|
312
474
|
//# sourceMappingURL=button.cjs.map
|