@devschile/chucao 1.2.0 → 1.4.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 +1 -0
- package/dist/chucao/chucao.css +2 -2
- package/dist/chucao/chucao.esm.js +1 -1
- package/dist/chucao/index.esm.js +1 -1
- package/dist/chucao/index.esm.js.map +1 -1
- package/dist/chucao/p-1f47dd08.entry.js +2 -0
- package/dist/chucao/p-1f47dd08.entry.js.map +1 -0
- package/dist/chucao/p-438e1401.entry.js +2 -0
- package/dist/chucao/p-438e1401.entry.js.map +1 -0
- package/dist/chucao/p-7413b8c3.entry.js +2 -0
- package/dist/chucao/p-7413b8c3.entry.js.map +1 -0
- package/dist/chucao/p-90db80a2.entry.js +2 -0
- package/dist/chucao/p-90db80a2.entry.js.map +1 -0
- package/dist/chucao/p-Bk9pvIKL.js +3 -0
- package/dist/chucao/p-Bk9pvIKL.js.map +1 -0
- package/dist/chucao/p-faa21ce0.entry.js +2 -0
- package/dist/chucao/p-faa21ce0.entry.js.map +1 -0
- package/dist/cjs/ch-badge_5.cjs.entry.js +57 -9
- package/dist/cjs/ch-badge_5.cjs.entry.js.map +1 -1
- package/dist/cjs/ch-checkbox.cjs.entry.js +80 -0
- package/dist/cjs/ch-checkbox.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-radio.cjs.entry.js +83 -0
- package/dist/cjs/ch-radio.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-switch.cjs.entry.js +80 -0
- package/dist/cjs/ch-switch.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-textarea.cjs.entry.js +94 -0
- package/dist/cjs/ch-textarea.cjs.entry.js.map +1 -0
- package/dist/cjs/chucao.cjs.js +2 -2
- package/dist/cjs/{index-Tiana_FZ.js → index-DX3RZKi8.js} +6 -3
- package/dist/cjs/index-DX3RZKi8.js.map +1 -0
- package/dist/cjs/index.cjs.js +148 -7
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +5 -1
- package/dist/collection/components/ch-badge/ch-badge.css +5 -5
- package/dist/collection/components/ch-button/ch-button.css +19 -19
- package/dist/collection/components/ch-card/ch-card.css +10 -10
- package/dist/collection/components/ch-card/ch-card.js +1 -1
- package/dist/collection/components/ch-checkbox/ch-checkbox.css +79 -0
- package/dist/collection/components/ch-checkbox/ch-checkbox.js +276 -0
- package/dist/collection/components/ch-checkbox/ch-checkbox.js.map +1 -0
- package/dist/collection/components/ch-input/ch-input.css +30 -10
- package/dist/collection/components/ch-input/ch-input.js +83 -1
- package/dist/collection/components/ch-input/ch-input.js.map +1 -1
- package/dist/collection/components/ch-radio/ch-radio.css +89 -0
- package/dist/collection/components/ch-radio/ch-radio.js +282 -0
- package/dist/collection/components/ch-radio/ch-radio.js.map +1 -0
- package/dist/collection/components/ch-select/ch-select.css +30 -10
- package/dist/collection/components/ch-select/ch-select.js +83 -1
- package/dist/collection/components/ch-select/ch-select.js.map +1 -1
- package/dist/collection/components/ch-switch/ch-switch.css +92 -0
- package/dist/collection/components/ch-switch/ch-switch.js +276 -0
- package/dist/collection/components/ch-switch/ch-switch.js.map +1 -0
- package/dist/collection/components/ch-textarea/ch-textarea.css +66 -0
- package/dist/collection/components/ch-textarea/ch-textarea.js +323 -0
- package/dist/collection/components/ch-textarea/ch-textarea.js.map +1 -0
- package/dist/collection/tokens/tokens.js +108 -6
- package/dist/collection/tokens/tokens.js.map +1 -1
- package/dist/collection/tokens/types.js.map +1 -1
- package/dist/components/ch-badge.js +1 -1
- package/dist/components/ch-badge.js.map +1 -1
- package/dist/components/ch-button.js +1 -1
- package/dist/components/ch-button.js.map +1 -1
- package/dist/components/ch-card.js +1 -1
- package/dist/components/ch-card.js.map +1 -1
- package/dist/components/ch-checkbox.d.ts +11 -0
- package/dist/components/ch-checkbox.js +2 -0
- package/dist/components/ch-checkbox.js.map +1 -0
- package/dist/components/ch-input.js +1 -1
- package/dist/components/ch-input.js.map +1 -1
- package/dist/components/ch-radio.d.ts +11 -0
- package/dist/components/ch-radio.js +2 -0
- package/dist/components/ch-radio.js.map +1 -0
- package/dist/components/ch-select.js +1 -1
- package/dist/components/ch-select.js.map +1 -1
- package/dist/components/ch-switch.d.ts +11 -0
- package/dist/components/ch-switch.js +2 -0
- package/dist/components/ch-switch.js.map +1 -0
- package/dist/components/ch-textarea.d.ts +11 -0
- package/dist/components/ch-textarea.js +2 -0
- package/dist/components/ch-textarea.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-CcEsJ4Ml.js +2 -0
- package/dist/components/p-CcEsJ4Ml.js.map +1 -0
- package/dist/esm/ch-badge_5.entry.js +57 -9
- package/dist/esm/ch-badge_5.entry.js.map +1 -1
- package/dist/esm/ch-checkbox.entry.js +78 -0
- package/dist/esm/ch-checkbox.entry.js.map +1 -0
- package/dist/esm/ch-radio.entry.js +81 -0
- package/dist/esm/ch-radio.entry.js.map +1 -0
- package/dist/esm/ch-switch.entry.js +78 -0
- package/dist/esm/ch-switch.entry.js.map +1 -0
- package/dist/esm/ch-textarea.entry.js +92 -0
- package/dist/esm/ch-textarea.entry.js.map +1 -0
- package/dist/esm/chucao.js +3 -3
- package/dist/esm/{index-CuWheDah.js → index-Bk9pvIKL.js} +6 -3
- package/dist/esm/index-Bk9pvIKL.js.map +1 -0
- package/dist/esm/index.js +109 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/ch-checkbox/ch-checkbox.d.ts +51 -0
- package/dist/types/components/ch-input/ch-input.d.ts +16 -0
- package/dist/types/components/ch-radio/ch-radio.d.ts +58 -0
- package/dist/types/components/ch-select/ch-select.d.ts +16 -0
- package/dist/types/components/ch-switch/ch-switch.d.ts +51 -0
- package/dist/types/components/ch-textarea/ch-textarea.d.ts +60 -0
- package/dist/types/components.d.ts +571 -0
- package/dist/types/tokens/tokens.d.ts +104 -2
- package/dist/types/tokens/types.d.ts +13 -4
- package/dist-react/components.d.ts +22 -1
- package/dist-react/components.js +39 -0
- package/dist-react/components.ts +55 -1
- package/dist-vue/index.d.ts +4 -0
- package/dist-vue/index.js +69 -0
- package/dist-vue/index.ts +77 -0
- package/package.json +2 -1
- package/dist/chucao/p-035c479d.entry.js +0 -2
- package/dist/chucao/p-035c479d.entry.js.map +0 -1
- package/dist/chucao/p-CuWheDah.js +0 -3
- package/dist/chucao/p-CuWheDah.js.map +0 -1
- package/dist/cjs/index-Tiana_FZ.js.map +0 -1
- package/dist/components/p-DXg-7eP0.js +0 -2
- package/dist/components/p-DXg-7eP0.js.map +0 -1
- package/dist/esm/index-CuWheDah.js.map +0 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
let switchIds = 0;
|
|
3
|
+
export class ChSwitch {
|
|
4
|
+
switchId = `ch-switch-${++switchIds}`;
|
|
5
|
+
hintId = `${this.switchId}-hint`;
|
|
6
|
+
errorId = `${this.switchId}-error`;
|
|
7
|
+
/**
|
|
8
|
+
* Visible label rendered next to the switch, associated with it via
|
|
9
|
+
* `for`/`id`, so assistive technology announces the switch's purpose.
|
|
10
|
+
*/
|
|
11
|
+
label;
|
|
12
|
+
/**
|
|
13
|
+
* The name of the switch, submitted with form data.
|
|
14
|
+
*/
|
|
15
|
+
name;
|
|
16
|
+
/**
|
|
17
|
+
* The value of the switch, submitted with form data.
|
|
18
|
+
*/
|
|
19
|
+
value = 'on';
|
|
20
|
+
/**
|
|
21
|
+
* Whether the switch is on.
|
|
22
|
+
*/
|
|
23
|
+
checked = false;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the switch is disabled.
|
|
26
|
+
*/
|
|
27
|
+
disabled = false;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the switch is required.
|
|
30
|
+
*/
|
|
31
|
+
required = false;
|
|
32
|
+
/**
|
|
33
|
+
* Helper text rendered below the switch, associated via `aria-describedby`.
|
|
34
|
+
* Replaced by `errorMessage` when the switch is invalid.
|
|
35
|
+
*/
|
|
36
|
+
hint;
|
|
37
|
+
/**
|
|
38
|
+
* Error message rendered below the switch when it is invalid.
|
|
39
|
+
*/
|
|
40
|
+
errorMessage;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the switch is in an invalid state; toggles `aria-invalid` and error styling.
|
|
43
|
+
*/
|
|
44
|
+
invalid = false;
|
|
45
|
+
/**
|
|
46
|
+
* Emitted when the switch is toggled, with the new on/off state.
|
|
47
|
+
*/
|
|
48
|
+
chChange;
|
|
49
|
+
handleChange = (ev) => {
|
|
50
|
+
this.checked = ev.target.checked;
|
|
51
|
+
this.chChange.emit(this.checked);
|
|
52
|
+
};
|
|
53
|
+
get describedBy() {
|
|
54
|
+
if (this.invalid && this.errorMessage) {
|
|
55
|
+
return this.errorId;
|
|
56
|
+
}
|
|
57
|
+
if (this.hint) {
|
|
58
|
+
return this.hintId;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
return (h(Host, { key: '445ccc591418d52d9259ecd652187c3d47427283' }, h("label", { key: '8ac36ff0f80a6d230ebdbf471df94672adb700de', class: { 'control': true, 'control--disabled': this.disabled }, htmlFor: this.switchId }, h("input", { key: '9c371eb76d14b7a8be24ab316cdc19323c154009', id: this.switchId, class: { 'input': true, 'input--invalid': this.invalid }, type: "checkbox", role: "switch", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled, required: this.required, "aria-checked": this.checked ? 'true' : 'false', "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), h("span", { key: '87285bc1c74eb6f75feea539670be85222e00c8a', class: "track" }), h("span", { key: 'ce6fbd422d94e6be191e387c4205f22a4cd77f1e', class: "thumb" }), this.label && h("span", { key: '8531db41660ca9001830e44ddccfbfc2c5c81ce6', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '3910211978477bc27114206833a5e80670f45eb2', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '910f553da102d03c530e12fd637ffe5339d48936', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
64
|
+
}
|
|
65
|
+
static get is() { return "ch-switch"; }
|
|
66
|
+
static get encapsulation() { return "shadow"; }
|
|
67
|
+
static get originalStyleUrls() {
|
|
68
|
+
return {
|
|
69
|
+
"$": ["ch-switch.css"]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
static get styleUrls() {
|
|
73
|
+
return {
|
|
74
|
+
"$": ["ch-switch.css"]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static get properties() {
|
|
78
|
+
return {
|
|
79
|
+
"label": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"mutable": false,
|
|
82
|
+
"complexType": {
|
|
83
|
+
"original": "string",
|
|
84
|
+
"resolved": "string",
|
|
85
|
+
"references": {}
|
|
86
|
+
},
|
|
87
|
+
"required": false,
|
|
88
|
+
"optional": true,
|
|
89
|
+
"docs": {
|
|
90
|
+
"tags": [],
|
|
91
|
+
"text": "Visible label rendered next to the switch, associated with it via\n`for`/`id`, so assistive technology announces the switch's purpose."
|
|
92
|
+
},
|
|
93
|
+
"getter": false,
|
|
94
|
+
"setter": false,
|
|
95
|
+
"reflect": false,
|
|
96
|
+
"attribute": "label"
|
|
97
|
+
},
|
|
98
|
+
"name": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"mutable": false,
|
|
101
|
+
"complexType": {
|
|
102
|
+
"original": "string",
|
|
103
|
+
"resolved": "string",
|
|
104
|
+
"references": {}
|
|
105
|
+
},
|
|
106
|
+
"required": false,
|
|
107
|
+
"optional": true,
|
|
108
|
+
"docs": {
|
|
109
|
+
"tags": [],
|
|
110
|
+
"text": "The name of the switch, submitted with form data."
|
|
111
|
+
},
|
|
112
|
+
"getter": false,
|
|
113
|
+
"setter": false,
|
|
114
|
+
"reflect": false,
|
|
115
|
+
"attribute": "name"
|
|
116
|
+
},
|
|
117
|
+
"value": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"mutable": false,
|
|
120
|
+
"complexType": {
|
|
121
|
+
"original": "string",
|
|
122
|
+
"resolved": "string",
|
|
123
|
+
"references": {}
|
|
124
|
+
},
|
|
125
|
+
"required": false,
|
|
126
|
+
"optional": false,
|
|
127
|
+
"docs": {
|
|
128
|
+
"tags": [],
|
|
129
|
+
"text": "The value of the switch, submitted with form data."
|
|
130
|
+
},
|
|
131
|
+
"getter": false,
|
|
132
|
+
"setter": false,
|
|
133
|
+
"reflect": false,
|
|
134
|
+
"attribute": "value",
|
|
135
|
+
"defaultValue": "'on'"
|
|
136
|
+
},
|
|
137
|
+
"checked": {
|
|
138
|
+
"type": "boolean",
|
|
139
|
+
"mutable": true,
|
|
140
|
+
"complexType": {
|
|
141
|
+
"original": "boolean",
|
|
142
|
+
"resolved": "boolean",
|
|
143
|
+
"references": {}
|
|
144
|
+
},
|
|
145
|
+
"required": false,
|
|
146
|
+
"optional": false,
|
|
147
|
+
"docs": {
|
|
148
|
+
"tags": [],
|
|
149
|
+
"text": "Whether the switch is on."
|
|
150
|
+
},
|
|
151
|
+
"getter": false,
|
|
152
|
+
"setter": false,
|
|
153
|
+
"reflect": false,
|
|
154
|
+
"attribute": "checked",
|
|
155
|
+
"defaultValue": "false"
|
|
156
|
+
},
|
|
157
|
+
"disabled": {
|
|
158
|
+
"type": "boolean",
|
|
159
|
+
"mutable": false,
|
|
160
|
+
"complexType": {
|
|
161
|
+
"original": "boolean",
|
|
162
|
+
"resolved": "boolean",
|
|
163
|
+
"references": {}
|
|
164
|
+
},
|
|
165
|
+
"required": false,
|
|
166
|
+
"optional": false,
|
|
167
|
+
"docs": {
|
|
168
|
+
"tags": [],
|
|
169
|
+
"text": "Whether the switch is disabled."
|
|
170
|
+
},
|
|
171
|
+
"getter": false,
|
|
172
|
+
"setter": false,
|
|
173
|
+
"reflect": false,
|
|
174
|
+
"attribute": "disabled",
|
|
175
|
+
"defaultValue": "false"
|
|
176
|
+
},
|
|
177
|
+
"required": {
|
|
178
|
+
"type": "boolean",
|
|
179
|
+
"mutable": false,
|
|
180
|
+
"complexType": {
|
|
181
|
+
"original": "boolean",
|
|
182
|
+
"resolved": "boolean",
|
|
183
|
+
"references": {}
|
|
184
|
+
},
|
|
185
|
+
"required": false,
|
|
186
|
+
"optional": false,
|
|
187
|
+
"docs": {
|
|
188
|
+
"tags": [],
|
|
189
|
+
"text": "Whether the switch is required."
|
|
190
|
+
},
|
|
191
|
+
"getter": false,
|
|
192
|
+
"setter": false,
|
|
193
|
+
"reflect": false,
|
|
194
|
+
"attribute": "required",
|
|
195
|
+
"defaultValue": "false"
|
|
196
|
+
},
|
|
197
|
+
"hint": {
|
|
198
|
+
"type": "string",
|
|
199
|
+
"mutable": false,
|
|
200
|
+
"complexType": {
|
|
201
|
+
"original": "string",
|
|
202
|
+
"resolved": "string",
|
|
203
|
+
"references": {}
|
|
204
|
+
},
|
|
205
|
+
"required": false,
|
|
206
|
+
"optional": true,
|
|
207
|
+
"docs": {
|
|
208
|
+
"tags": [],
|
|
209
|
+
"text": "Helper text rendered below the switch, associated via `aria-describedby`.\nReplaced by `errorMessage` when the switch is invalid."
|
|
210
|
+
},
|
|
211
|
+
"getter": false,
|
|
212
|
+
"setter": false,
|
|
213
|
+
"reflect": false,
|
|
214
|
+
"attribute": "hint"
|
|
215
|
+
},
|
|
216
|
+
"errorMessage": {
|
|
217
|
+
"type": "string",
|
|
218
|
+
"mutable": false,
|
|
219
|
+
"complexType": {
|
|
220
|
+
"original": "string",
|
|
221
|
+
"resolved": "string",
|
|
222
|
+
"references": {}
|
|
223
|
+
},
|
|
224
|
+
"required": false,
|
|
225
|
+
"optional": true,
|
|
226
|
+
"docs": {
|
|
227
|
+
"tags": [],
|
|
228
|
+
"text": "Error message rendered below the switch when it is invalid."
|
|
229
|
+
},
|
|
230
|
+
"getter": false,
|
|
231
|
+
"setter": false,
|
|
232
|
+
"reflect": false,
|
|
233
|
+
"attribute": "error-message"
|
|
234
|
+
},
|
|
235
|
+
"invalid": {
|
|
236
|
+
"type": "boolean",
|
|
237
|
+
"mutable": false,
|
|
238
|
+
"complexType": {
|
|
239
|
+
"original": "boolean",
|
|
240
|
+
"resolved": "boolean",
|
|
241
|
+
"references": {}
|
|
242
|
+
},
|
|
243
|
+
"required": false,
|
|
244
|
+
"optional": false,
|
|
245
|
+
"docs": {
|
|
246
|
+
"tags": [],
|
|
247
|
+
"text": "Whether the switch is in an invalid state; toggles `aria-invalid` and error styling."
|
|
248
|
+
},
|
|
249
|
+
"getter": false,
|
|
250
|
+
"setter": false,
|
|
251
|
+
"reflect": false,
|
|
252
|
+
"attribute": "invalid",
|
|
253
|
+
"defaultValue": "false"
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
static get events() {
|
|
258
|
+
return [{
|
|
259
|
+
"method": "chChange",
|
|
260
|
+
"name": "chChange",
|
|
261
|
+
"bubbles": true,
|
|
262
|
+
"cancelable": true,
|
|
263
|
+
"composed": true,
|
|
264
|
+
"docs": {
|
|
265
|
+
"tags": [],
|
|
266
|
+
"text": "Emitted when the switch is toggled, with the new on/off state."
|
|
267
|
+
},
|
|
268
|
+
"complexType": {
|
|
269
|
+
"original": "boolean",
|
|
270
|
+
"resolved": "boolean",
|
|
271
|
+
"references": {}
|
|
272
|
+
}
|
|
273
|
+
}];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=ch-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ch-switch.js","sourceRoot":"","sources":["../../../../src/components/ch-switch/ch-switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAqB,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAEnF,IAAI,SAAS,GAAG,CAAC,CAAC;AAOlB,MAAM,OAAO,QAAQ;IACF,QAAQ,GAAG,aAAa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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, type EventEmitter, Host, Prop, h } from '@stencil/core';\n\nlet switchIds = 0;\n\n@Component({\n tag: 'ch-switch',\n styleUrl: 'ch-switch.css',\n shadow: true,\n})\nexport class ChSwitch {\n private readonly switchId = `ch-switch-${++switchIds}`;\n private readonly hintId = `${this.switchId}-hint`;\n private readonly errorId = `${this.switchId}-error`;\n\n /**\n * Visible label rendered next to the switch, associated with it via\n * `for`/`id`, so assistive technology announces the switch's purpose.\n */\n @Prop() label?: string;\n\n /**\n * The name of the switch, submitted with form data.\n */\n @Prop() name?: string;\n\n /**\n * The value of the switch, submitted with form data.\n */\n @Prop() value = 'on';\n\n /**\n * Whether the switch is on.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * Whether the switch is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Whether the switch is required.\n */\n @Prop() required = false;\n\n /**\n * Helper text rendered below the switch, associated via `aria-describedby`.\n * Replaced by `errorMessage` when the switch is invalid.\n */\n @Prop() hint?: string;\n\n /**\n * Error message rendered below the switch when it is invalid.\n */\n @Prop() errorMessage?: string;\n\n /**\n * Whether the switch is in an invalid state; toggles `aria-invalid` and error styling.\n */\n @Prop() invalid = false;\n\n /**\n * Emitted when the switch is toggled, with the new on/off state.\n */\n @Event() chChange: EventEmitter<boolean>;\n\n private handleChange = (ev: Event) => {\n this.checked = (ev.target as HTMLInputElement).checked;\n this.chChange.emit(this.checked);\n };\n\n private get describedBy(): string | undefined {\n if (this.invalid && this.errorMessage) {\n return this.errorId;\n }\n if (this.hint) {\n return this.hintId;\n }\n return undefined;\n }\n\n render() {\n return (\n <Host>\n <label class={{ 'control': true, 'control--disabled': this.disabled }} htmlFor={this.switchId}>\n <input\n id={this.switchId}\n class={{ 'input': true, 'input--invalid': this.invalid }}\n type=\"checkbox\"\n role=\"switch\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled}\n required={this.required}\n aria-checked={this.checked ? 'true' : 'false'}\n aria-invalid={this.invalid ? 'true' : undefined}\n aria-describedby={this.describedBy}\n onChange={this.handleChange}\n />\n <span class=\"track\"></span>\n <span class=\"thumb\"></span>\n {this.label && <span class=\"label-text\">{this.label}</span>}\n </label>\n {this.hint && !(this.invalid && this.errorMessage) && (\n <p class=\"hint\" id={this.hintId}>\n {this.hint}\n </p>\n )}\n {this.invalid && this.errorMessage && (\n <p class=\"error\" id={this.errorId} role=\"alert\">\n {this.errorMessage}\n </p>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.label {
|
|
7
|
+
display: block;
|
|
8
|
+
margin-bottom: var(--spacing-sm);
|
|
9
|
+
font-size: var(--typography-size-sm);
|
|
10
|
+
font-weight: var(--typography-weight-semibold);
|
|
11
|
+
color: var(--text);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.textarea {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
width: 100%;
|
|
17
|
+
min-height: var(--spacing-6xl);
|
|
18
|
+
padding: var(--spacing-xl) var(--spacing-3xl);
|
|
19
|
+
border-radius: var(--radius);
|
|
20
|
+
border: var(--border-width) solid var(--border);
|
|
21
|
+
background: var(--surface);
|
|
22
|
+
color: var(--text);
|
|
23
|
+
backdrop-filter: blur(var(--effect-blur));
|
|
24
|
+
font-family: inherit;
|
|
25
|
+
font-size: inherit;
|
|
26
|
+
line-height: var(--spacing-5xl);
|
|
27
|
+
resize: vertical;
|
|
28
|
+
transition:
|
|
29
|
+
border-color var(--duration-normal) var(--easing-default),
|
|
30
|
+
box-shadow var(--duration-normal) var(--easing-default);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.textarea::placeholder {
|
|
34
|
+
color: var(--text-muted);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.textarea:focus {
|
|
38
|
+
border-color: var(--accent);
|
|
39
|
+
box-shadow: var(--shadow-focus-ring);
|
|
40
|
+
outline: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.textarea--invalid {
|
|
44
|
+
border-color: var(--color-status-warning);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.textarea--invalid:focus {
|
|
48
|
+
border-color: var(--color-status-warning);
|
|
49
|
+
box-shadow: 0 0 0 3px var(--color-status-warning-background);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.textarea:disabled {
|
|
53
|
+
opacity: var(--opacity-disabled);
|
|
54
|
+
cursor: not-allowed;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.hint,
|
|
58
|
+
.error {
|
|
59
|
+
margin: var(--spacing-sm) 0 0;
|
|
60
|
+
font-size: var(--typography-size-sm);
|
|
61
|
+
color: var(--text-muted);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.error {
|
|
65
|
+
color: var(--color-status-warning);
|
|
66
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
let textareaIds = 0;
|
|
3
|
+
const DEFAULT_ROWS = 4;
|
|
4
|
+
export class ChTextarea {
|
|
5
|
+
textareaId = `ch-textarea-${++textareaIds}`;
|
|
6
|
+
hintId = `${this.textareaId}-hint`;
|
|
7
|
+
errorId = `${this.textareaId}-error`;
|
|
8
|
+
/**
|
|
9
|
+
* Visible label rendered above the textarea and associated with it via
|
|
10
|
+
* `for`/`id`, so assistive technology announces the textarea's purpose.
|
|
11
|
+
*/
|
|
12
|
+
label;
|
|
13
|
+
/**
|
|
14
|
+
* The value of the textarea.
|
|
15
|
+
*/
|
|
16
|
+
value = '';
|
|
17
|
+
/**
|
|
18
|
+
* Placeholder text shown when the textarea is empty.
|
|
19
|
+
*/
|
|
20
|
+
placeholder;
|
|
21
|
+
/**
|
|
22
|
+
* The number of visible rows of the textarea.
|
|
23
|
+
*/
|
|
24
|
+
rows = DEFAULT_ROWS;
|
|
25
|
+
/**
|
|
26
|
+
* The name of the textarea, submitted with form data.
|
|
27
|
+
*/
|
|
28
|
+
name;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the textarea is disabled.
|
|
31
|
+
*/
|
|
32
|
+
disabled = false;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the textarea is required.
|
|
35
|
+
*/
|
|
36
|
+
required = false;
|
|
37
|
+
/**
|
|
38
|
+
* Helper text rendered below the textarea, associated via `aria-describedby`.
|
|
39
|
+
* Replaced by `errorMessage` when the textarea is invalid.
|
|
40
|
+
*/
|
|
41
|
+
hint;
|
|
42
|
+
/**
|
|
43
|
+
* Error message rendered below the textarea when it is invalid.
|
|
44
|
+
*/
|
|
45
|
+
errorMessage;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the textarea is in an invalid state; toggles `aria-invalid` and error styling.
|
|
48
|
+
*/
|
|
49
|
+
invalid = false;
|
|
50
|
+
/**
|
|
51
|
+
* Emitted on every keystroke, with the current textarea value.
|
|
52
|
+
*/
|
|
53
|
+
chInput;
|
|
54
|
+
/**
|
|
55
|
+
* Emitted when the textarea value is committed (on native `change`).
|
|
56
|
+
*/
|
|
57
|
+
chChange;
|
|
58
|
+
handleInput = (ev) => {
|
|
59
|
+
this.value = ev.target.value;
|
|
60
|
+
this.chInput.emit(this.value);
|
|
61
|
+
};
|
|
62
|
+
handleChange = (ev) => {
|
|
63
|
+
this.value = ev.target.value;
|
|
64
|
+
this.chChange.emit(this.value);
|
|
65
|
+
};
|
|
66
|
+
get describedBy() {
|
|
67
|
+
if (this.invalid && this.errorMessage) {
|
|
68
|
+
return this.errorId;
|
|
69
|
+
}
|
|
70
|
+
if (this.hint) {
|
|
71
|
+
return this.hintId;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
render() {
|
|
76
|
+
return (h(Host, { key: '7ff32c75e6d9730f2c9fef5f0651545c37d7a267' }, this.label && (h("label", { key: '4d3dea600362e805ff34932b4512d0672a44545a', class: "label", htmlFor: this.textareaId }, this.label)), h("textarea", { key: 'ca13e92970a1f0b42a65b592296c0b1851cb9793', id: this.label ? this.textareaId : undefined, class: { 'textarea': true, 'textarea--invalid': this.invalid }, rows: this.rows, name: this.name, placeholder: this.placeholder, disabled: this.disabled, required: this.required, value: this.value, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onInput: this.handleInput, onChange: this.handleChange }), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '2188b00c3dd708d4c822d47b9ac7628b500a7ee3', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: 'af38339ae5d34a670313ed89425d531f71d63b82', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
77
|
+
}
|
|
78
|
+
static get is() { return "ch-textarea"; }
|
|
79
|
+
static get encapsulation() { return "shadow"; }
|
|
80
|
+
static get originalStyleUrls() {
|
|
81
|
+
return {
|
|
82
|
+
"$": ["ch-textarea.css"]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
static get styleUrls() {
|
|
86
|
+
return {
|
|
87
|
+
"$": ["ch-textarea.css"]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
static get properties() {
|
|
91
|
+
return {
|
|
92
|
+
"label": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"mutable": false,
|
|
95
|
+
"complexType": {
|
|
96
|
+
"original": "string",
|
|
97
|
+
"resolved": "string",
|
|
98
|
+
"references": {}
|
|
99
|
+
},
|
|
100
|
+
"required": false,
|
|
101
|
+
"optional": true,
|
|
102
|
+
"docs": {
|
|
103
|
+
"tags": [],
|
|
104
|
+
"text": "Visible label rendered above the textarea and associated with it via\n`for`/`id`, so assistive technology announces the textarea's purpose."
|
|
105
|
+
},
|
|
106
|
+
"getter": false,
|
|
107
|
+
"setter": false,
|
|
108
|
+
"reflect": false,
|
|
109
|
+
"attribute": "label"
|
|
110
|
+
},
|
|
111
|
+
"value": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"mutable": true,
|
|
114
|
+
"complexType": {
|
|
115
|
+
"original": "string",
|
|
116
|
+
"resolved": "string",
|
|
117
|
+
"references": {}
|
|
118
|
+
},
|
|
119
|
+
"required": false,
|
|
120
|
+
"optional": false,
|
|
121
|
+
"docs": {
|
|
122
|
+
"tags": [],
|
|
123
|
+
"text": "The value of the textarea."
|
|
124
|
+
},
|
|
125
|
+
"getter": false,
|
|
126
|
+
"setter": false,
|
|
127
|
+
"reflect": false,
|
|
128
|
+
"attribute": "value",
|
|
129
|
+
"defaultValue": "''"
|
|
130
|
+
},
|
|
131
|
+
"placeholder": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"mutable": false,
|
|
134
|
+
"complexType": {
|
|
135
|
+
"original": "string",
|
|
136
|
+
"resolved": "string",
|
|
137
|
+
"references": {}
|
|
138
|
+
},
|
|
139
|
+
"required": false,
|
|
140
|
+
"optional": true,
|
|
141
|
+
"docs": {
|
|
142
|
+
"tags": [],
|
|
143
|
+
"text": "Placeholder text shown when the textarea is empty."
|
|
144
|
+
},
|
|
145
|
+
"getter": false,
|
|
146
|
+
"setter": false,
|
|
147
|
+
"reflect": false,
|
|
148
|
+
"attribute": "placeholder"
|
|
149
|
+
},
|
|
150
|
+
"rows": {
|
|
151
|
+
"type": "number",
|
|
152
|
+
"mutable": false,
|
|
153
|
+
"complexType": {
|
|
154
|
+
"original": "number",
|
|
155
|
+
"resolved": "number",
|
|
156
|
+
"references": {}
|
|
157
|
+
},
|
|
158
|
+
"required": false,
|
|
159
|
+
"optional": false,
|
|
160
|
+
"docs": {
|
|
161
|
+
"tags": [],
|
|
162
|
+
"text": "The number of visible rows of the textarea."
|
|
163
|
+
},
|
|
164
|
+
"getter": false,
|
|
165
|
+
"setter": false,
|
|
166
|
+
"reflect": false,
|
|
167
|
+
"attribute": "rows",
|
|
168
|
+
"defaultValue": "4"
|
|
169
|
+
},
|
|
170
|
+
"name": {
|
|
171
|
+
"type": "string",
|
|
172
|
+
"mutable": false,
|
|
173
|
+
"complexType": {
|
|
174
|
+
"original": "string",
|
|
175
|
+
"resolved": "string",
|
|
176
|
+
"references": {}
|
|
177
|
+
},
|
|
178
|
+
"required": false,
|
|
179
|
+
"optional": true,
|
|
180
|
+
"docs": {
|
|
181
|
+
"tags": [],
|
|
182
|
+
"text": "The name of the textarea, submitted with form data."
|
|
183
|
+
},
|
|
184
|
+
"getter": false,
|
|
185
|
+
"setter": false,
|
|
186
|
+
"reflect": false,
|
|
187
|
+
"attribute": "name"
|
|
188
|
+
},
|
|
189
|
+
"disabled": {
|
|
190
|
+
"type": "boolean",
|
|
191
|
+
"mutable": false,
|
|
192
|
+
"complexType": {
|
|
193
|
+
"original": "boolean",
|
|
194
|
+
"resolved": "boolean",
|
|
195
|
+
"references": {}
|
|
196
|
+
},
|
|
197
|
+
"required": false,
|
|
198
|
+
"optional": false,
|
|
199
|
+
"docs": {
|
|
200
|
+
"tags": [],
|
|
201
|
+
"text": "Whether the textarea is disabled."
|
|
202
|
+
},
|
|
203
|
+
"getter": false,
|
|
204
|
+
"setter": false,
|
|
205
|
+
"reflect": false,
|
|
206
|
+
"attribute": "disabled",
|
|
207
|
+
"defaultValue": "false"
|
|
208
|
+
},
|
|
209
|
+
"required": {
|
|
210
|
+
"type": "boolean",
|
|
211
|
+
"mutable": false,
|
|
212
|
+
"complexType": {
|
|
213
|
+
"original": "boolean",
|
|
214
|
+
"resolved": "boolean",
|
|
215
|
+
"references": {}
|
|
216
|
+
},
|
|
217
|
+
"required": false,
|
|
218
|
+
"optional": false,
|
|
219
|
+
"docs": {
|
|
220
|
+
"tags": [],
|
|
221
|
+
"text": "Whether the textarea is required."
|
|
222
|
+
},
|
|
223
|
+
"getter": false,
|
|
224
|
+
"setter": false,
|
|
225
|
+
"reflect": false,
|
|
226
|
+
"attribute": "required",
|
|
227
|
+
"defaultValue": "false"
|
|
228
|
+
},
|
|
229
|
+
"hint": {
|
|
230
|
+
"type": "string",
|
|
231
|
+
"mutable": false,
|
|
232
|
+
"complexType": {
|
|
233
|
+
"original": "string",
|
|
234
|
+
"resolved": "string",
|
|
235
|
+
"references": {}
|
|
236
|
+
},
|
|
237
|
+
"required": false,
|
|
238
|
+
"optional": true,
|
|
239
|
+
"docs": {
|
|
240
|
+
"tags": [],
|
|
241
|
+
"text": "Helper text rendered below the textarea, associated via `aria-describedby`.\nReplaced by `errorMessage` when the textarea is invalid."
|
|
242
|
+
},
|
|
243
|
+
"getter": false,
|
|
244
|
+
"setter": false,
|
|
245
|
+
"reflect": false,
|
|
246
|
+
"attribute": "hint"
|
|
247
|
+
},
|
|
248
|
+
"errorMessage": {
|
|
249
|
+
"type": "string",
|
|
250
|
+
"mutable": false,
|
|
251
|
+
"complexType": {
|
|
252
|
+
"original": "string",
|
|
253
|
+
"resolved": "string",
|
|
254
|
+
"references": {}
|
|
255
|
+
},
|
|
256
|
+
"required": false,
|
|
257
|
+
"optional": true,
|
|
258
|
+
"docs": {
|
|
259
|
+
"tags": [],
|
|
260
|
+
"text": "Error message rendered below the textarea when it is invalid."
|
|
261
|
+
},
|
|
262
|
+
"getter": false,
|
|
263
|
+
"setter": false,
|
|
264
|
+
"reflect": false,
|
|
265
|
+
"attribute": "error-message"
|
|
266
|
+
},
|
|
267
|
+
"invalid": {
|
|
268
|
+
"type": "boolean",
|
|
269
|
+
"mutable": false,
|
|
270
|
+
"complexType": {
|
|
271
|
+
"original": "boolean",
|
|
272
|
+
"resolved": "boolean",
|
|
273
|
+
"references": {}
|
|
274
|
+
},
|
|
275
|
+
"required": false,
|
|
276
|
+
"optional": false,
|
|
277
|
+
"docs": {
|
|
278
|
+
"tags": [],
|
|
279
|
+
"text": "Whether the textarea is in an invalid state; toggles `aria-invalid` and error styling."
|
|
280
|
+
},
|
|
281
|
+
"getter": false,
|
|
282
|
+
"setter": false,
|
|
283
|
+
"reflect": false,
|
|
284
|
+
"attribute": "invalid",
|
|
285
|
+
"defaultValue": "false"
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
static get events() {
|
|
290
|
+
return [{
|
|
291
|
+
"method": "chInput",
|
|
292
|
+
"name": "chInput",
|
|
293
|
+
"bubbles": true,
|
|
294
|
+
"cancelable": true,
|
|
295
|
+
"composed": true,
|
|
296
|
+
"docs": {
|
|
297
|
+
"tags": [],
|
|
298
|
+
"text": "Emitted on every keystroke, with the current textarea value."
|
|
299
|
+
},
|
|
300
|
+
"complexType": {
|
|
301
|
+
"original": "string",
|
|
302
|
+
"resolved": "string",
|
|
303
|
+
"references": {}
|
|
304
|
+
}
|
|
305
|
+
}, {
|
|
306
|
+
"method": "chChange",
|
|
307
|
+
"name": "chChange",
|
|
308
|
+
"bubbles": true,
|
|
309
|
+
"cancelable": true,
|
|
310
|
+
"composed": true,
|
|
311
|
+
"docs": {
|
|
312
|
+
"tags": [],
|
|
313
|
+
"text": "Emitted when the textarea value is committed (on native `change`)."
|
|
314
|
+
},
|
|
315
|
+
"complexType": {
|
|
316
|
+
"original": "string",
|
|
317
|
+
"resolved": "string",
|
|
318
|
+
"references": {}
|
|
319
|
+
}
|
|
320
|
+
}];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=ch-textarea.js.map
|