@phcdevworks/spectre-components 0.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -40
- package/dist/base-2rD8EmdC.d.cts +32 -0
- package/dist/base-2rD8EmdC.d.ts +32 -0
- package/dist/button.cjs +295 -170
- package/dist/button.cjs.map +1 -1
- package/dist/button.d.cts +30 -61
- package/dist/button.d.ts +30 -61
- package/dist/button.js +296 -171
- package/dist/button.js.map +1 -1
- package/dist/checkbox.cjs +286 -71
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.d.cts +38 -43
- package/dist/checkbox.d.ts +38 -43
- package/dist/checkbox.js +287 -72
- package/dist/checkbox.js.map +1 -1
- package/dist/fieldset.cjs +233 -88
- package/dist/fieldset.cjs.map +1 -1
- package/dist/fieldset.d.cts +23 -40
- package/dist/fieldset.d.ts +23 -40
- package/dist/fieldset.js +233 -88
- package/dist/fieldset.js.map +1 -1
- package/dist/form-iI7vV-3W.d.cts +6 -0
- package/dist/form-iI7vV-3W.d.ts +6 -0
- package/dist/index.cjs +564 -1029
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +566 -1030
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +232 -119
- package/dist/input.cjs.map +1 -1
- package/dist/input.d.cts +52 -68
- package/dist/input.d.ts +52 -68
- package/dist/input.js +232 -119
- package/dist/input.js.map +1 -1
- package/dist/label.cjs +232 -73
- package/dist/label.cjs.map +1 -1
- package/dist/label.d.cts +13 -22
- package/dist/label.d.ts +13 -22
- package/dist/label.js +232 -73
- package/dist/label.js.map +1 -1
- package/dist/projectable-BzDQ4xp_.d.cts +17 -0
- package/dist/projectable-s3SgvjGX.d.ts +17 -0
- package/dist/radio.cjs +286 -71
- package/dist/radio.cjs.map +1 -1
- package/dist/radio.d.cts +38 -43
- package/dist/radio.d.ts +38 -43
- package/dist/radio.js +287 -72
- package/dist/radio.js.map +1 -1
- package/dist/select.cjs +292 -163
- package/dist/select.cjs.map +1 -1
- package/dist/select.d.cts +35 -58
- package/dist/select.d.ts +35 -58
- package/dist/select.js +293 -163
- package/dist/select.js.map +1 -1
- package/dist/textarea.cjs +191 -290
- package/dist/textarea.cjs.map +1 -1
- package/dist/textarea.d.cts +41 -58
- package/dist/textarea.d.ts +41 -58
- package/dist/textarea.js +191 -290
- package/dist/textarea.js.map +1 -1
- package/package.json +13 -12
package/dist/textarea.cjs
CHANGED
|
@@ -6,227 +6,201 @@ var ifDefined_js = require('lit/directives/if-defined.js');
|
|
|
6
6
|
var spectreUi = require('@phcdevworks/spectre-ui');
|
|
7
7
|
|
|
8
8
|
// src/components/textarea/sp-textarea.ts
|
|
9
|
-
var
|
|
10
|
-
"text",
|
|
11
|
-
"email",
|
|
12
|
-
"password",
|
|
13
|
-
"search",
|
|
14
|
-
"tel",
|
|
15
|
-
"url",
|
|
16
|
-
"number",
|
|
17
|
-
"date",
|
|
18
|
-
"datetime-local",
|
|
19
|
-
"month",
|
|
20
|
-
"time",
|
|
21
|
-
"week"
|
|
22
|
-
];
|
|
23
|
-
var spectreInputSizes = ["sm", "md", "lg"];
|
|
24
|
-
function isInputType(value) {
|
|
25
|
-
return spectreInputTypes.includes(value);
|
|
26
|
-
}
|
|
27
|
-
function isInputSize(value) {
|
|
28
|
-
return spectreInputSizes.includes(value);
|
|
29
|
-
}
|
|
30
|
-
var SpectreInputElement = class extends lit.LitElement {
|
|
9
|
+
var SpectreBaseElement = class extends lit.LitElement {
|
|
31
10
|
constructor() {
|
|
32
11
|
super(...arguments);
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
12
|
+
this._ariaLabel = null;
|
|
13
|
+
this._ariaLabelledBy = null;
|
|
14
|
+
this._ariaDescribedBy = null;
|
|
15
|
+
this._title = "";
|
|
16
|
+
this._id = "";
|
|
17
|
+
}
|
|
18
|
+
get ariaLabel() {
|
|
19
|
+
return this._ariaLabel;
|
|
20
|
+
}
|
|
21
|
+
set ariaLabel(value) {
|
|
22
|
+
if (this._ariaLabel === value) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this._ariaLabel = value;
|
|
26
|
+
this._removeHostAttribute("aria-label");
|
|
27
|
+
this.requestUpdate();
|
|
28
|
+
}
|
|
29
|
+
get ariaLabelledBy() {
|
|
30
|
+
return this._ariaLabelledBy;
|
|
31
|
+
}
|
|
32
|
+
set ariaLabelledBy(value) {
|
|
33
|
+
if (this._ariaLabelledBy === value) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this._ariaLabelledBy = value;
|
|
37
|
+
this._removeHostAttribute("aria-labelledby");
|
|
38
|
+
this.requestUpdate();
|
|
39
|
+
}
|
|
40
|
+
get ariaDescribedBy() {
|
|
41
|
+
return this._ariaDescribedBy;
|
|
42
|
+
}
|
|
43
|
+
set ariaDescribedBy(value) {
|
|
44
|
+
if (this._ariaDescribedBy === value) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this._ariaDescribedBy = value;
|
|
48
|
+
this._removeHostAttribute("aria-describedby");
|
|
49
|
+
this.requestUpdate();
|
|
50
|
+
}
|
|
51
|
+
get title() {
|
|
52
|
+
return this._title;
|
|
53
|
+
}
|
|
54
|
+
set title(value) {
|
|
55
|
+
const normalizedValue = value ?? "";
|
|
56
|
+
if (this._title === normalizedValue) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._title = normalizedValue;
|
|
60
|
+
this._removeHostAttribute("title");
|
|
61
|
+
this.requestUpdate();
|
|
49
62
|
}
|
|
50
63
|
get id() {
|
|
51
|
-
return this._id
|
|
64
|
+
return this._id;
|
|
52
65
|
}
|
|
53
66
|
set id(value) {
|
|
54
|
-
|
|
67
|
+
const normalizedValue = value ?? "";
|
|
68
|
+
if (this._id === normalizedValue) {
|
|
55
69
|
return;
|
|
56
70
|
}
|
|
57
|
-
this._id =
|
|
58
|
-
|
|
59
|
-
if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
|
|
60
|
-
HTMLElement.prototype.removeAttribute.call(host, "id");
|
|
61
|
-
}
|
|
71
|
+
this._id = normalizedValue;
|
|
72
|
+
this._removeHostAttribute("id");
|
|
62
73
|
this.requestUpdate();
|
|
63
74
|
}
|
|
75
|
+
// Spectre components intentionally render in light DOM so the global
|
|
76
|
+
// `@phcdevworks/spectre-ui` styling contract can apply directly.
|
|
64
77
|
createRenderRoot() {
|
|
65
78
|
return this;
|
|
66
79
|
}
|
|
67
80
|
connectedCallback() {
|
|
68
81
|
super.connectedCallback();
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
const proxiedAttributes = [
|
|
83
|
+
"id",
|
|
84
|
+
"title",
|
|
85
|
+
"aria-label",
|
|
86
|
+
"aria-labelledby",
|
|
87
|
+
"aria-describedby"
|
|
88
|
+
];
|
|
89
|
+
proxiedAttributes.forEach((attr) => {
|
|
90
|
+
const value = super.getAttribute(attr);
|
|
91
|
+
if (value !== null) {
|
|
92
|
+
this.setAttribute(attr, value);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
73
95
|
}
|
|
74
96
|
getAttribute(qualifiedName) {
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
switch (qualifiedName) {
|
|
98
|
+
case "id":
|
|
99
|
+
return this.id || null;
|
|
100
|
+
case "title":
|
|
101
|
+
return this.title || null;
|
|
102
|
+
case "aria-label":
|
|
103
|
+
return this.ariaLabel;
|
|
104
|
+
case "aria-labelledby":
|
|
105
|
+
return this.ariaLabelledBy;
|
|
106
|
+
case "aria-describedby":
|
|
107
|
+
return this.ariaDescribedBy;
|
|
108
|
+
default:
|
|
109
|
+
return super.getAttribute(qualifiedName);
|
|
77
110
|
}
|
|
78
|
-
return super.getAttribute(qualifiedName);
|
|
79
111
|
}
|
|
80
112
|
hasAttribute(qualifiedName) {
|
|
81
|
-
|
|
82
|
-
|
|
113
|
+
switch (qualifiedName) {
|
|
114
|
+
case "id":
|
|
115
|
+
return this.id !== "";
|
|
116
|
+
case "title":
|
|
117
|
+
return this.title !== "";
|
|
118
|
+
case "aria-label":
|
|
119
|
+
return this.ariaLabel !== null;
|
|
120
|
+
case "aria-labelledby":
|
|
121
|
+
return this.ariaLabelledBy !== null;
|
|
122
|
+
case "aria-describedby":
|
|
123
|
+
return this.ariaDescribedBy !== null;
|
|
124
|
+
default:
|
|
125
|
+
return super.hasAttribute(qualifiedName);
|
|
83
126
|
}
|
|
84
|
-
return super.hasAttribute(qualifiedName);
|
|
85
127
|
}
|
|
86
128
|
setAttribute(qualifiedName, value) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
129
|
+
switch (qualifiedName) {
|
|
130
|
+
case "id":
|
|
131
|
+
this.id = value;
|
|
132
|
+
break;
|
|
133
|
+
case "title":
|
|
134
|
+
this.title = value;
|
|
135
|
+
break;
|
|
136
|
+
case "aria-label":
|
|
137
|
+
this.ariaLabel = value;
|
|
138
|
+
break;
|
|
139
|
+
case "aria-labelledby":
|
|
140
|
+
this.ariaLabelledBy = value;
|
|
141
|
+
break;
|
|
142
|
+
case "aria-describedby":
|
|
143
|
+
this.ariaDescribedBy = value;
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
super.setAttribute(qualifiedName, value);
|
|
90
147
|
}
|
|
91
|
-
super.setAttribute(qualifiedName, value);
|
|
92
148
|
}
|
|
93
149
|
removeAttribute(qualifiedName) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
150
|
+
switch (qualifiedName) {
|
|
151
|
+
case "id":
|
|
152
|
+
this.id = "";
|
|
153
|
+
break;
|
|
154
|
+
case "title":
|
|
155
|
+
this.title = "";
|
|
156
|
+
break;
|
|
157
|
+
case "aria-label":
|
|
158
|
+
this.ariaLabel = null;
|
|
159
|
+
break;
|
|
160
|
+
case "aria-labelledby":
|
|
161
|
+
this.ariaLabelledBy = null;
|
|
162
|
+
break;
|
|
163
|
+
case "aria-describedby":
|
|
164
|
+
this.ariaDescribedBy = null;
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
super.removeAttribute(qualifiedName);
|
|
97
168
|
}
|
|
98
|
-
super.removeAttribute(qualifiedName);
|
|
99
169
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (changedProperties.has("type") && !isInputType(this.type)) {
|
|
105
|
-
this.type = "text";
|
|
106
|
-
}
|
|
107
|
-
if (changedProperties.has("value") && this.value == null) {
|
|
108
|
-
this.value = "";
|
|
109
|
-
}
|
|
110
|
-
if (changedProperties.has("maxlength")) {
|
|
111
|
-
if (this.maxlength == null || !Number.isInteger(this.maxlength) || this.maxlength < 0) {
|
|
112
|
-
this.maxlength = void 0;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (changedProperties.has("minlength")) {
|
|
116
|
-
if (this.minlength == null || !Number.isInteger(this.minlength) || this.minlength < 0) {
|
|
117
|
-
this.minlength = void 0;
|
|
118
|
-
}
|
|
170
|
+
_removeHostAttribute(name) {
|
|
171
|
+
const host = this;
|
|
172
|
+
if (HTMLElement.prototype.hasAttribute.call(host, name)) {
|
|
173
|
+
HTMLElement.prototype.removeAttribute.call(host, name);
|
|
119
174
|
}
|
|
120
175
|
}
|
|
121
|
-
get inputClasses() {
|
|
122
|
-
return spectreUi.getInputClasses({
|
|
123
|
-
fullWidth: this.fullWidth,
|
|
124
|
-
pill: this.pill,
|
|
125
|
-
size: this.size,
|
|
126
|
-
state: this.isDisabled ? this.disabled ? "disabled" : "loading" : this.invalid ? "error" : this.success ? "success" : "default"
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
get isDisabled() {
|
|
130
|
-
return this.disabled || this.loading;
|
|
131
|
-
}
|
|
132
|
-
get nativeInput() {
|
|
133
|
-
return this.querySelector("[data-sp-input-native]");
|
|
134
|
-
}
|
|
135
176
|
get forwardedAriaLabel() {
|
|
136
|
-
const
|
|
137
|
-
return
|
|
177
|
+
const value = this.ariaLabel?.trim();
|
|
178
|
+
return value ? value : void 0;
|
|
138
179
|
}
|
|
139
180
|
get forwardedAriaLabelledBy() {
|
|
140
|
-
const
|
|
141
|
-
return
|
|
181
|
+
const value = this.ariaLabelledBy?.trim();
|
|
182
|
+
return value ? value : void 0;
|
|
142
183
|
}
|
|
143
184
|
get forwardedAriaDescribedBy() {
|
|
144
|
-
const
|
|
145
|
-
return
|
|
185
|
+
const value = this.ariaDescribedBy?.trim();
|
|
186
|
+
return value ? value : void 0;
|
|
146
187
|
}
|
|
147
|
-
handleInput(event) {
|
|
148
|
-
const input = event.currentTarget;
|
|
149
|
-
this.value = input.value;
|
|
150
|
-
}
|
|
151
|
-
handleChange(event) {
|
|
152
|
-
const input = event.currentTarget;
|
|
153
|
-
this.value = input.value;
|
|
154
|
-
}
|
|
155
|
-
focus(options) {
|
|
156
|
-
this.nativeInput?.focus(options);
|
|
157
|
-
}
|
|
158
|
-
blur() {
|
|
159
|
-
this.nativeInput?.blur();
|
|
160
|
-
}
|
|
161
|
-
render() {
|
|
162
|
-
return lit.html`
|
|
163
|
-
<input
|
|
164
|
-
aria-busy=${this.loading ? "true" : "false"}
|
|
165
|
-
aria-describedby=${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}
|
|
166
|
-
aria-invalid=${ifDefined_js.ifDefined(this.invalid ? "true" : void 0)}
|
|
167
|
-
aria-label=${ifDefined_js.ifDefined(this.forwardedAriaLabel)}
|
|
168
|
-
aria-labelledby=${ifDefined_js.ifDefined(this.forwardedAriaLabelledBy)}
|
|
169
|
-
autocomplete=${ifDefined_js.ifDefined(this.autocomplete)}
|
|
170
|
-
?autofocus=${this.autofocus}
|
|
171
|
-
class=${this.inputClasses}
|
|
172
|
-
data-sp-input-native
|
|
173
|
-
?disabled=${this.isDisabled}
|
|
174
|
-
?readonly=${this.readonly}
|
|
175
|
-
?required=${this.required}
|
|
176
|
-
id=${ifDefined_js.ifDefined(this.id || void 0)}
|
|
177
|
-
inputmode=${ifDefined_js.ifDefined(this.inputmode)}
|
|
178
|
-
max=${ifDefined_js.ifDefined(this.max)}
|
|
179
|
-
maxlength=${ifDefined_js.ifDefined(this.maxlength)}
|
|
180
|
-
min=${ifDefined_js.ifDefined(this.min)}
|
|
181
|
-
minlength=${ifDefined_js.ifDefined(this.minlength)}
|
|
182
|
-
name=${ifDefined_js.ifDefined(this.name)}
|
|
183
|
-
placeholder=${ifDefined_js.ifDefined(this.placeholder)}
|
|
184
|
-
step=${ifDefined_js.ifDefined(this.step)}
|
|
185
|
-
title=${ifDefined_js.ifDefined(this.title || void 0)}
|
|
186
|
-
type=${this.type}
|
|
187
|
-
.value=${live_js.live(this.value)}
|
|
188
|
-
@change=${this.handleChange}
|
|
189
|
-
@input=${this.handleInput}
|
|
190
|
-
/>
|
|
191
|
-
`;
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
SpectreInputElement.properties = {
|
|
195
|
-
ariaLabel: { attribute: "aria-label", type: String },
|
|
196
|
-
ariaLabelledBy: { attribute: "aria-labelledby", type: String },
|
|
197
|
-
ariaDescribedBy: { attribute: "aria-describedby", type: String },
|
|
198
|
-
autocomplete: { type: String },
|
|
199
|
-
autofocus: { type: Boolean, reflect: true },
|
|
200
|
-
disabled: { type: Boolean, reflect: true },
|
|
201
|
-
fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
|
|
202
|
-
inputmode: { type: String },
|
|
203
|
-
invalid: { type: Boolean, reflect: true },
|
|
204
|
-
loading: { type: Boolean, reflect: true },
|
|
205
|
-
max: { type: String },
|
|
206
|
-
maxlength: { type: Number },
|
|
207
|
-
min: { type: String },
|
|
208
|
-
minlength: { type: Number },
|
|
209
|
-
name: { type: String },
|
|
210
|
-
pill: { type: Boolean, reflect: true },
|
|
211
|
-
placeholder: { type: String },
|
|
212
|
-
readonly: { type: Boolean, reflect: true },
|
|
213
|
-
required: { type: Boolean, reflect: true },
|
|
214
|
-
size: { type: String, reflect: true },
|
|
215
|
-
step: { type: String },
|
|
216
|
-
success: { type: Boolean, reflect: true },
|
|
217
|
-
title: { type: String, reflect: true },
|
|
218
|
-
type: { type: String, reflect: true },
|
|
219
|
-
value: { type: String }
|
|
220
188
|
};
|
|
221
|
-
|
|
222
|
-
|
|
189
|
+
SpectreBaseElement.properties = {};
|
|
190
|
+
var spectreInputSizes = ["sm", "md", "lg"];
|
|
191
|
+
function isInputSize(value) {
|
|
192
|
+
return spectreInputSizes.includes(value);
|
|
193
|
+
}
|
|
194
|
+
function normalizeInt(value, fallback, min = 0) {
|
|
195
|
+
if (value == null || typeof value !== "number" || !Number.isInteger(value) || value < min) {
|
|
196
|
+
return fallback;
|
|
197
|
+
}
|
|
198
|
+
return value;
|
|
199
|
+
}
|
|
223
200
|
var DEFAULT_ROWS = 2;
|
|
224
|
-
var SpectreTextareaElement = class extends
|
|
201
|
+
var SpectreTextareaElement = class extends SpectreBaseElement {
|
|
225
202
|
constructor() {
|
|
226
203
|
super(...arguments);
|
|
227
|
-
this.ariaLabel = null;
|
|
228
|
-
this.ariaLabelledBy = null;
|
|
229
|
-
this.ariaDescribedBy = null;
|
|
230
204
|
this.autofocus = false;
|
|
231
205
|
this.disabled = false;
|
|
232
206
|
this.fullWidth = false;
|
|
@@ -238,80 +212,23 @@ var SpectreTextareaElement = class extends lit.LitElement {
|
|
|
238
212
|
this.rows = DEFAULT_ROWS;
|
|
239
213
|
this.size = "md";
|
|
240
214
|
this.success = false;
|
|
241
|
-
this.title = "";
|
|
242
215
|
this.value = "";
|
|
243
216
|
}
|
|
244
|
-
get id() {
|
|
245
|
-
return this._id ?? "";
|
|
246
|
-
}
|
|
247
|
-
set id(value) {
|
|
248
|
-
if ((this._id ?? "") === value) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
this._id = value;
|
|
252
|
-
const host = this;
|
|
253
|
-
if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
|
|
254
|
-
HTMLElement.prototype.removeAttribute.call(host, "id");
|
|
255
|
-
}
|
|
256
|
-
this.requestUpdate();
|
|
257
|
-
}
|
|
258
|
-
createRenderRoot() {
|
|
259
|
-
return this;
|
|
260
|
-
}
|
|
261
|
-
connectedCallback() {
|
|
262
|
-
super.connectedCallback();
|
|
263
|
-
const hostId = super.getAttribute("id");
|
|
264
|
-
if (hostId !== null) {
|
|
265
|
-
this.id = hostId;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
getAttribute(qualifiedName) {
|
|
269
|
-
if (qualifiedName === "id") {
|
|
270
|
-
return this.id || null;
|
|
271
|
-
}
|
|
272
|
-
return super.getAttribute(qualifiedName);
|
|
273
|
-
}
|
|
274
|
-
hasAttribute(qualifiedName) {
|
|
275
|
-
if (qualifiedName === "id") {
|
|
276
|
-
return this.id !== "";
|
|
277
|
-
}
|
|
278
|
-
return super.hasAttribute(qualifiedName);
|
|
279
|
-
}
|
|
280
|
-
setAttribute(qualifiedName, value) {
|
|
281
|
-
if (qualifiedName === "id") {
|
|
282
|
-
this.id = value;
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
super.setAttribute(qualifiedName, value);
|
|
286
|
-
}
|
|
287
|
-
removeAttribute(qualifiedName) {
|
|
288
|
-
if (qualifiedName === "id") {
|
|
289
|
-
this.id = "";
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
super.removeAttribute(qualifiedName);
|
|
293
|
-
}
|
|
294
217
|
willUpdate(changedProperties) {
|
|
295
218
|
if (changedProperties.has("size") && !isInputSize(this.size)) {
|
|
296
219
|
this.size = "md";
|
|
297
220
|
}
|
|
298
221
|
if (changedProperties.has("rows")) {
|
|
299
|
-
|
|
300
|
-
this.rows = DEFAULT_ROWS;
|
|
301
|
-
}
|
|
222
|
+
this.rows = normalizeInt(this.rows, DEFAULT_ROWS, 1);
|
|
302
223
|
}
|
|
303
224
|
if (changedProperties.has("value") && this.value == null) {
|
|
304
225
|
this.value = "";
|
|
305
226
|
}
|
|
306
227
|
if (changedProperties.has("maxlength")) {
|
|
307
|
-
|
|
308
|
-
this.maxlength = void 0;
|
|
309
|
-
}
|
|
228
|
+
this.maxlength = normalizeInt(this.maxlength, void 0);
|
|
310
229
|
}
|
|
311
230
|
if (changedProperties.has("minlength")) {
|
|
312
|
-
|
|
313
|
-
this.minlength = void 0;
|
|
314
|
-
}
|
|
231
|
+
this.minlength = normalizeInt(this.minlength, void 0);
|
|
315
232
|
}
|
|
316
233
|
}
|
|
317
234
|
get textareaClasses() {
|
|
@@ -328,18 +245,6 @@ var SpectreTextareaElement = class extends lit.LitElement {
|
|
|
328
245
|
get nativeTextarea() {
|
|
329
246
|
return this.querySelector("[data-sp-textarea-native]");
|
|
330
247
|
}
|
|
331
|
-
get forwardedAriaLabel() {
|
|
332
|
-
const ariaLabel = this.ariaLabel?.trim();
|
|
333
|
-
return ariaLabel ? ariaLabel : void 0;
|
|
334
|
-
}
|
|
335
|
-
get forwardedAriaLabelledBy() {
|
|
336
|
-
const ariaLabelledBy = this.ariaLabelledBy?.trim();
|
|
337
|
-
return ariaLabelledBy ? ariaLabelledBy : void 0;
|
|
338
|
-
}
|
|
339
|
-
get forwardedAriaDescribedBy() {
|
|
340
|
-
const ariaDescribedBy = this.ariaDescribedBy?.trim();
|
|
341
|
-
return ariaDescribedBy ? ariaDescribedBy : void 0;
|
|
342
|
-
}
|
|
343
248
|
handleInput(event) {
|
|
344
249
|
const textarea = event.currentTarget;
|
|
345
250
|
this.value = textarea.value;
|
|
@@ -355,57 +260,53 @@ var SpectreTextareaElement = class extends lit.LitElement {
|
|
|
355
260
|
this.nativeTextarea?.blur();
|
|
356
261
|
}
|
|
357
262
|
render() {
|
|
358
|
-
return lit.html
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
`;
|
|
263
|
+
return lit.html`<textarea
|
|
264
|
+
aria-busy="${this.loading ? "true" : "false"}"
|
|
265
|
+
aria-describedby="${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}"
|
|
266
|
+
aria-invalid="${ifDefined_js.ifDefined(this.invalid ? "true" : void 0)}"
|
|
267
|
+
aria-label="${ifDefined_js.ifDefined(this.forwardedAriaLabel)}"
|
|
268
|
+
aria-labelledby="${ifDefined_js.ifDefined(this.forwardedAriaLabelledBy)}"
|
|
269
|
+
autocomplete="${ifDefined_js.ifDefined(this.autocomplete || void 0)}"
|
|
270
|
+
?autofocus="${this.autofocus}"
|
|
271
|
+
class="${this.textareaClasses}"
|
|
272
|
+
data-sp-textarea-native
|
|
273
|
+
?disabled="${this.isDisabled}"
|
|
274
|
+
form="${ifDefined_js.ifDefined(this.form || void 0)}"
|
|
275
|
+
inputmode="${ifDefined_js.ifDefined(this.inputmode || void 0)}"
|
|
276
|
+
?readonly="${this.readonly}"
|
|
277
|
+
?required="${this.required}"
|
|
278
|
+
id="${ifDefined_js.ifDefined(this.id || void 0)}"
|
|
279
|
+
maxlength="${ifDefined_js.ifDefined(this.maxlength)}"
|
|
280
|
+
minlength="${ifDefined_js.ifDefined(this.minlength)}"
|
|
281
|
+
name="${ifDefined_js.ifDefined(this.name || void 0)}"
|
|
282
|
+
placeholder="${ifDefined_js.ifDefined(this.placeholder || void 0)}"
|
|
283
|
+
rows="${this.rows}"
|
|
284
|
+
title="${ifDefined_js.ifDefined(this.title || void 0)}"
|
|
285
|
+
.value="${live_js.live(this.value)}"
|
|
286
|
+
@change="${this.handleChange}"
|
|
287
|
+
@input="${this.handleInput}"
|
|
288
|
+
></textarea>`;
|
|
385
289
|
}
|
|
386
290
|
};
|
|
387
291
|
SpectreTextareaElement.properties = {
|
|
388
|
-
|
|
389
|
-
ariaLabelledBy: { attribute: "aria-labelledby", type: String },
|
|
390
|
-
ariaDescribedBy: { attribute: "aria-describedby", type: String },
|
|
391
|
-
autocomplete: { type: String },
|
|
292
|
+
autocomplete: { type: String, reflect: true },
|
|
392
293
|
autofocus: { type: Boolean, reflect: true },
|
|
393
294
|
disabled: { type: Boolean, reflect: true },
|
|
295
|
+
form: { type: String },
|
|
394
296
|
fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
|
|
395
|
-
inputmode: { type: String },
|
|
297
|
+
inputmode: { type: String, reflect: true },
|
|
396
298
|
invalid: { type: Boolean, reflect: true },
|
|
397
299
|
loading: { type: Boolean, reflect: true },
|
|
398
|
-
maxlength: { type: Number },
|
|
399
|
-
minlength: { type: Number },
|
|
400
|
-
name: { type: String },
|
|
300
|
+
maxlength: { type: Number, reflect: true },
|
|
301
|
+
minlength: { type: Number, reflect: true },
|
|
302
|
+
name: { type: String, reflect: true },
|
|
401
303
|
pill: { type: Boolean, reflect: true },
|
|
402
|
-
placeholder: { type: String },
|
|
304
|
+
placeholder: { type: String, reflect: true },
|
|
403
305
|
readonly: { type: Boolean, reflect: true },
|
|
404
306
|
required: { type: Boolean, reflect: true },
|
|
405
307
|
rows: { type: Number },
|
|
406
308
|
size: { type: String, reflect: true },
|
|
407
309
|
success: { type: Boolean, reflect: true },
|
|
408
|
-
title: { type: String, reflect: true },
|
|
409
310
|
value: { type: String }
|
|
410
311
|
};
|
|
411
312
|
function defineSpectreTextarea(tagName = "sp-textarea") {
|