@scouterna/ui-webc 0.2.10 → 2.0.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/dist/cjs/{index-M8pbc2b8.js → index-D42maJcS.js} +455 -9
- package/dist/cjs/index-D42maJcS.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/scout-bottom-bar-item.cjs.entry.js +3 -2
- package/dist/cjs/scout-bottom-bar-item.entry.cjs.js.map +1 -1
- package/dist/cjs/scout-bottom-bar.cjs.entry.js +3 -2
- package/dist/cjs/scout-bottom-bar.entry.cjs.js.map +1 -1
- package/dist/cjs/scout-button.cjs.entry.js +3 -2
- package/dist/cjs/scout-button.entry.cjs.js.map +1 -1
- package/dist/cjs/scout-card.cjs.entry.js +19 -0
- package/dist/cjs/scout-card.entry.cjs.js.map +1 -0
- package/dist/cjs/scout-checkbox.cjs.entry.js +53 -0
- package/dist/cjs/scout-checkbox.entry.cjs.js.map +1 -0
- package/dist/cjs/scout-field.cjs.entry.js +47 -0
- package/dist/cjs/scout-field.entry.cjs.js.map +1 -0
- package/dist/cjs/scout-input.cjs.entry.js +72 -0
- package/dist/cjs/scout-input.entry.cjs.js.map +1 -0
- package/dist/cjs/scout-switch.cjs.entry.js +49 -0
- package/dist/cjs/scout-switch.entry.cjs.js.map +1 -0
- package/dist/cjs/ui-webc.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +6 -1
- package/dist/collection/components/bottom-bar/bottom-bar.js +2 -1
- package/dist/collection/components/bottom-bar/bottom-bar.js.map +1 -1
- package/dist/collection/components/bottom-bar-item/bottom-bar-item.js +2 -1
- package/dist/collection/components/bottom-bar-item/bottom-bar-item.js.map +1 -1
- package/dist/collection/components/button/button.js +2 -1
- package/dist/collection/components/button/button.js.map +1 -1
- package/dist/collection/components/card/card.css +8 -0
- package/dist/collection/components/card/card.js +23 -0
- package/dist/collection/components/card/card.js.map +1 -0
- package/dist/collection/components/checkbox/checkbox.css +81 -0
- package/dist/collection/components/checkbox/checkbox.js +176 -0
- package/dist/collection/components/checkbox/checkbox.js.map +1 -0
- package/dist/collection/components/field/field.css +26 -0
- package/dist/collection/components/field/field.js +119 -0
- package/dist/collection/components/field/field.js.map +1 -0
- package/dist/collection/components/input/input.css +15 -0
- package/dist/collection/components/input/input.js +259 -0
- package/dist/collection/components/input/input.js.map +1 -0
- package/dist/collection/components/switch/switch.css +79 -0
- package/dist/collection/components/switch/switch.js +173 -0
- package/dist/collection/components/switch/switch.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/{p-CMd0pUms.js → p-MfRr-Vl1.js} +448 -10
- package/dist/components/p-MfRr-Vl1.js.map +1 -0
- package/dist/components/scout-bottom-bar-item.js +4 -3
- package/dist/components/scout-bottom-bar-item.js.map +1 -1
- package/dist/components/scout-bottom-bar.js +4 -3
- package/dist/components/scout-bottom-bar.js.map +1 -1
- package/dist/components/scout-button.js +4 -3
- package/dist/components/scout-button.js.map +1 -1
- package/dist/components/scout-card.d.ts +11 -0
- package/dist/components/scout-card.js +39 -0
- package/dist/components/scout-card.js.map +1 -0
- package/dist/components/scout-checkbox.d.ts +11 -0
- package/dist/components/scout-checkbox.js +78 -0
- package/dist/components/scout-checkbox.js.map +1 -0
- package/dist/components/scout-field.d.ts +11 -0
- package/dist/components/scout-field.js +72 -0
- package/dist/components/scout-field.js.map +1 -0
- package/dist/components/scout-input.d.ts +11 -0
- package/dist/components/scout-input.js +99 -0
- package/dist/components/scout-input.js.map +1 -0
- package/dist/components/scout-switch.d.ts +11 -0
- package/dist/components/scout-switch.js +75 -0
- package/dist/components/scout-switch.js.map +1 -0
- package/dist/custom-elements.json +732 -14
- package/dist/esm/{index-BKWL7m90.js → index-DByXnE9g.js} +455 -10
- package/dist/esm/index-DByXnE9g.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/scout-bottom-bar-item.entry.js +3 -2
- package/dist/esm/scout-bottom-bar-item.entry.js.map +1 -1
- package/dist/esm/scout-bottom-bar.entry.js +3 -2
- package/dist/esm/scout-bottom-bar.entry.js.map +1 -1
- package/dist/esm/scout-button.entry.js +3 -2
- package/dist/esm/scout-button.entry.js.map +1 -1
- package/dist/esm/scout-card.entry.js +17 -0
- package/dist/esm/scout-card.entry.js.map +1 -0
- package/dist/esm/scout-checkbox.entry.js +51 -0
- package/dist/esm/scout-checkbox.entry.js.map +1 -0
- package/dist/esm/scout-field.entry.js +45 -0
- package/dist/esm/scout-field.entry.js.map +1 -0
- package/dist/esm/scout-input.entry.js +70 -0
- package/dist/esm/scout-input.entry.js.map +1 -0
- package/dist/esm/scout-switch.entry.js +47 -0
- package/dist/esm/scout-switch.entry.js.map +1 -0
- package/dist/esm/ui-webc.js +3 -3
- package/dist/types/components/card/card.d.ts +6 -0
- package/dist/types/components/checkbox/checkbox.d.ts +22 -0
- package/dist/types/components/field/field.d.ts +23 -0
- package/dist/types/components/input/input.d.ts +47 -0
- package/dist/types/components/switch/switch.d.ts +25 -0
- package/dist/types/components.d.ts +286 -0
- package/dist/ui-webc/p-24632b65.entry.js +2 -0
- package/dist/ui-webc/p-24632b65.entry.js.map +1 -0
- package/dist/ui-webc/p-2b434594.entry.js +2 -0
- package/dist/ui-webc/p-2b434594.entry.js.map +1 -0
- package/dist/ui-webc/p-383736c1.entry.js +2 -0
- package/dist/ui-webc/p-383736c1.entry.js.map +1 -0
- package/dist/ui-webc/p-7245a55a.entry.js +2 -0
- package/dist/ui-webc/p-7245a55a.entry.js.map +1 -0
- package/dist/ui-webc/{p-5a234307.entry.js → p-99329c64.entry.js} +2 -2
- package/dist/ui-webc/p-99329c64.entry.js.map +1 -0
- package/dist/ui-webc/p-9b7c270d.entry.js +2 -0
- package/dist/ui-webc/p-9b7c270d.entry.js.map +1 -0
- package/dist/ui-webc/p-DByXnE9g.js +3 -0
- package/dist/ui-webc/p-DByXnE9g.js.map +1 -0
- package/dist/ui-webc/p-c0c3a4af.entry.js +2 -0
- package/dist/ui-webc/p-c0c3a4af.entry.js.map +1 -0
- package/dist/ui-webc/p-e7602729.entry.js +2 -0
- package/dist/ui-webc/p-e7602729.entry.js.map +1 -0
- package/dist/ui-webc/scout-bottom-bar-item.entry.esm.js.map +1 -1
- package/dist/ui-webc/scout-bottom-bar.entry.esm.js.map +1 -1
- package/dist/ui-webc/scout-button.entry.esm.js.map +1 -1
- package/dist/ui-webc/scout-card.entry.esm.js.map +1 -0
- package/dist/ui-webc/scout-checkbox.entry.esm.js.map +1 -0
- package/dist/ui-webc/scout-field.entry.esm.js.map +1 -0
- package/dist/ui-webc/scout-input.entry.esm.js.map +1 -0
- package/dist/ui-webc/scout-switch.entry.esm.js.map +1 -0
- package/dist/ui-webc/ui-webc.css +13 -1
- package/dist/ui-webc/ui-webc.esm.js +1 -1
- package/package.json +3 -5
- package/dist/cjs/index-M8pbc2b8.js.map +0 -1
- package/dist/components/p-CMd0pUms.js.map +0 -1
- package/dist/esm/index-BKWL7m90.js.map +0 -1
- package/dist/ui-webc/p-2b13b5cd.entry.js +0 -2
- package/dist/ui-webc/p-2b13b5cd.entry.js.map +0 -1
- package/dist/ui-webc/p-5a234307.entry.js.map +0 -1
- package/dist/ui-webc/p-BKWL7m90.js +0 -3
- package/dist/ui-webc/p-BKWL7m90.js.map +0 -1
- package/dist/ui-webc/p-d1aadf34.entry.js +0 -2
- package/dist/ui-webc/p-d1aadf34.entry.js.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { h, } from "@stencil/core";
|
|
2
|
+
export class ScoutInput {
|
|
3
|
+
/**
|
|
4
|
+
* Type of input element. If you need a number input, read the accessibility
|
|
5
|
+
* section of this MDN article first:
|
|
6
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number#accessibility
|
|
7
|
+
*/
|
|
8
|
+
type = "text";
|
|
9
|
+
/**
|
|
10
|
+
* Input mode hints for devices with dynamic keyboards.
|
|
11
|
+
*/
|
|
12
|
+
inputmode;
|
|
13
|
+
/**
|
|
14
|
+
* Regex pattern for input validation.
|
|
15
|
+
*/
|
|
16
|
+
pattern;
|
|
17
|
+
/**
|
|
18
|
+
* Value of the input element, in case you want to control it yourself.
|
|
19
|
+
*/
|
|
20
|
+
value = "";
|
|
21
|
+
/**
|
|
22
|
+
* Whether the input is disabled. Disabled inputs are not editable, excluded
|
|
23
|
+
* from tab order and are not validated.
|
|
24
|
+
*/
|
|
25
|
+
disabled = false;
|
|
26
|
+
/**
|
|
27
|
+
* Custom validation function run on top of the implicit validation performed
|
|
28
|
+
* by the browser. Return a string with the validation message to mark the
|
|
29
|
+
* input as invalid, or null to mark it as valid.
|
|
30
|
+
*/
|
|
31
|
+
validate;
|
|
32
|
+
scoutInputChange;
|
|
33
|
+
scoutBlur;
|
|
34
|
+
/**
|
|
35
|
+
* Internal event used for form field association.
|
|
36
|
+
*/
|
|
37
|
+
_fieldId;
|
|
38
|
+
ariaId;
|
|
39
|
+
componentWillLoad() {
|
|
40
|
+
this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;
|
|
41
|
+
this._fieldId.emit(this.ariaId);
|
|
42
|
+
}
|
|
43
|
+
onInput(event) {
|
|
44
|
+
const input = event.target;
|
|
45
|
+
if (this.validate) {
|
|
46
|
+
const validationMessage = this.validate(input.value);
|
|
47
|
+
input.setCustomValidity(validationMessage ?? "");
|
|
48
|
+
}
|
|
49
|
+
this.scoutInputChange.emit({
|
|
50
|
+
value: input.value,
|
|
51
|
+
element: input,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
return (h("input", { key: '7bc05d32826cd3173b6a6e4620acfb501fae4edc', id: this.ariaId, type: this.type, inputMode: this.inputmode, pattern: this.pattern, class: "input", value: this.value, disabled: this.disabled, onInput: (e) => this.onInput(e), onBlur: () => this.scoutBlur.emit() }));
|
|
56
|
+
}
|
|
57
|
+
static get is() { return "scout-input"; }
|
|
58
|
+
static get encapsulation() { return "scoped"; }
|
|
59
|
+
static get originalStyleUrls() {
|
|
60
|
+
return {
|
|
61
|
+
"$": ["input.css"]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static get styleUrls() {
|
|
65
|
+
return {
|
|
66
|
+
"$": ["input.css"]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static get properties() {
|
|
70
|
+
return {
|
|
71
|
+
"type": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"mutable": false,
|
|
74
|
+
"complexType": {
|
|
75
|
+
"original": "InputType",
|
|
76
|
+
"resolved": "\"email\" | \"number\" | \"password\" | \"tel\" | \"text\" | \"url\" | string & {}",
|
|
77
|
+
"references": {
|
|
78
|
+
"InputType": {
|
|
79
|
+
"location": "local",
|
|
80
|
+
"path": "/home/runner/work/j26-web-components/j26-web-components/packages/ui-webc/src/components/input/input.tsx",
|
|
81
|
+
"id": "src/components/input/input.tsx::InputType"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"required": false,
|
|
86
|
+
"optional": false,
|
|
87
|
+
"docs": {
|
|
88
|
+
"tags": [],
|
|
89
|
+
"text": "Type of input element. If you need a number input, read the accessibility\nsection of this MDN article first:\nhttps://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number#accessibility"
|
|
90
|
+
},
|
|
91
|
+
"getter": false,
|
|
92
|
+
"setter": false,
|
|
93
|
+
"reflect": false,
|
|
94
|
+
"attribute": "type",
|
|
95
|
+
"defaultValue": "\"text\""
|
|
96
|
+
},
|
|
97
|
+
"inputmode": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"mutable": false,
|
|
100
|
+
"complexType": {
|
|
101
|
+
"original": "InputMode",
|
|
102
|
+
"resolved": "\"decimal\" | \"email\" | \"none\" | \"numeric\" | \"search\" | \"tel\" | \"text\" | \"url\" | string & {}",
|
|
103
|
+
"references": {
|
|
104
|
+
"InputMode": {
|
|
105
|
+
"location": "local",
|
|
106
|
+
"path": "/home/runner/work/j26-web-components/j26-web-components/packages/ui-webc/src/components/input/input.tsx",
|
|
107
|
+
"id": "src/components/input/input.tsx::InputMode"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"required": false,
|
|
112
|
+
"optional": true,
|
|
113
|
+
"docs": {
|
|
114
|
+
"tags": [],
|
|
115
|
+
"text": "Input mode hints for devices with dynamic keyboards."
|
|
116
|
+
},
|
|
117
|
+
"getter": false,
|
|
118
|
+
"setter": false,
|
|
119
|
+
"reflect": false,
|
|
120
|
+
"attribute": "inputmode"
|
|
121
|
+
},
|
|
122
|
+
"pattern": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"mutable": false,
|
|
125
|
+
"complexType": {
|
|
126
|
+
"original": "string",
|
|
127
|
+
"resolved": "string",
|
|
128
|
+
"references": {}
|
|
129
|
+
},
|
|
130
|
+
"required": false,
|
|
131
|
+
"optional": true,
|
|
132
|
+
"docs": {
|
|
133
|
+
"tags": [],
|
|
134
|
+
"text": "Regex pattern for input validation."
|
|
135
|
+
},
|
|
136
|
+
"getter": false,
|
|
137
|
+
"setter": false,
|
|
138
|
+
"reflect": false,
|
|
139
|
+
"attribute": "pattern"
|
|
140
|
+
},
|
|
141
|
+
"value": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"mutable": false,
|
|
144
|
+
"complexType": {
|
|
145
|
+
"original": "string",
|
|
146
|
+
"resolved": "string",
|
|
147
|
+
"references": {}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": false,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [],
|
|
153
|
+
"text": "Value of the input element, in case you want to control it yourself."
|
|
154
|
+
},
|
|
155
|
+
"getter": false,
|
|
156
|
+
"setter": false,
|
|
157
|
+
"reflect": false,
|
|
158
|
+
"attribute": "value",
|
|
159
|
+
"defaultValue": "\"\""
|
|
160
|
+
},
|
|
161
|
+
"disabled": {
|
|
162
|
+
"type": "boolean",
|
|
163
|
+
"mutable": false,
|
|
164
|
+
"complexType": {
|
|
165
|
+
"original": "boolean",
|
|
166
|
+
"resolved": "boolean",
|
|
167
|
+
"references": {}
|
|
168
|
+
},
|
|
169
|
+
"required": false,
|
|
170
|
+
"optional": false,
|
|
171
|
+
"docs": {
|
|
172
|
+
"tags": [],
|
|
173
|
+
"text": "Whether the input is disabled. Disabled inputs are not editable, excluded\nfrom tab order and are not validated."
|
|
174
|
+
},
|
|
175
|
+
"getter": false,
|
|
176
|
+
"setter": false,
|
|
177
|
+
"reflect": false,
|
|
178
|
+
"attribute": "disabled",
|
|
179
|
+
"defaultValue": "false"
|
|
180
|
+
},
|
|
181
|
+
"validate": {
|
|
182
|
+
"type": "unknown",
|
|
183
|
+
"mutable": false,
|
|
184
|
+
"complexType": {
|
|
185
|
+
"original": "(value: string) => string | null",
|
|
186
|
+
"resolved": "(value: string) => string",
|
|
187
|
+
"references": {}
|
|
188
|
+
},
|
|
189
|
+
"required": false,
|
|
190
|
+
"optional": true,
|
|
191
|
+
"docs": {
|
|
192
|
+
"tags": [],
|
|
193
|
+
"text": "Custom validation function run on top of the implicit validation performed\nby the browser. Return a string with the validation message to mark the\ninput as invalid, or null to mark it as valid."
|
|
194
|
+
},
|
|
195
|
+
"getter": false,
|
|
196
|
+
"setter": false
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
static get states() {
|
|
201
|
+
return {
|
|
202
|
+
"ariaId": {}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
static get events() {
|
|
206
|
+
return [{
|
|
207
|
+
"method": "scoutInputChange",
|
|
208
|
+
"name": "scoutInputChange",
|
|
209
|
+
"bubbles": true,
|
|
210
|
+
"cancelable": true,
|
|
211
|
+
"composed": true,
|
|
212
|
+
"docs": {
|
|
213
|
+
"tags": [],
|
|
214
|
+
"text": ""
|
|
215
|
+
},
|
|
216
|
+
"complexType": {
|
|
217
|
+
"original": "{\n value: string;\n element: HTMLInputElement;\n }",
|
|
218
|
+
"resolved": "{ value: string; element: HTMLInputElement; }",
|
|
219
|
+
"references": {
|
|
220
|
+
"HTMLInputElement": {
|
|
221
|
+
"location": "global",
|
|
222
|
+
"id": "global::HTMLInputElement"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
"method": "scoutBlur",
|
|
228
|
+
"name": "scoutBlur",
|
|
229
|
+
"bubbles": true,
|
|
230
|
+
"cancelable": true,
|
|
231
|
+
"composed": true,
|
|
232
|
+
"docs": {
|
|
233
|
+
"tags": [],
|
|
234
|
+
"text": ""
|
|
235
|
+
},
|
|
236
|
+
"complexType": {
|
|
237
|
+
"original": "void",
|
|
238
|
+
"resolved": "void",
|
|
239
|
+
"references": {}
|
|
240
|
+
}
|
|
241
|
+
}, {
|
|
242
|
+
"method": "_fieldId",
|
|
243
|
+
"name": "_fieldId",
|
|
244
|
+
"bubbles": true,
|
|
245
|
+
"cancelable": true,
|
|
246
|
+
"composed": true,
|
|
247
|
+
"docs": {
|
|
248
|
+
"tags": [],
|
|
249
|
+
"text": "Internal event used for form field association."
|
|
250
|
+
},
|
|
251
|
+
"complexType": {
|
|
252
|
+
"original": "string",
|
|
253
|
+
"resolved": "string",
|
|
254
|
+
"references": {}
|
|
255
|
+
}
|
|
256
|
+
}];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,KAAK,GACN,MAAM,eAAe,CAAC;AA6BvB,MAAM,OAAO,UAAU;IACrB;;;;OAIG;IACK,IAAI,GAAc,MAAM,CAAC;IAEjC;;OAEG;IACK,SAAS,CAAa;IAE9B;;OAEG;IACK,OAAO,CAAU;IAEzB;;OAEG;IACK,KAAK,GAAW,EAAE,CAAC;IAE3B;;;OAGG;IACK,QAAQ,GAAY,KAAK,CAAC;IAElC;;;;OAIG;IACK,QAAQ,CAAoC;IAE3C,gBAAgB,CAGtB;IACM,SAAS,CAAqB;IAEvC;;OAEG;IACM,QAAQ,CAAuB;IAE/B,MAAM,CAAS;IAExB,iBAAiB;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC/D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,KAAiB;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;QAE/C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrD,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;YACzB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;IACL,CAAC;IAED,MAAM;QACJ,OAAO,CACL,8DACE,EAAE,EAAE,IAAI,CAAC,MAAM,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,KAAK,EAAC,OAAO,EACb,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GACnC,CACH,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n type ComponentInterface,\n Event,\n type EventEmitter,\n h,\n Prop,\n State,\n} from \"@stencil/core\";\n\nexport type InputType =\n | \"text\"\n | \"password\"\n | \"email\"\n | \"number\"\n | \"tel\"\n | \"url\"\n // Hack to suggest above value but still allow any other string value\n | (string & {});\n\nexport type InputMode =\n | \"none\"\n | \"text\"\n | \"decimal\"\n | \"numeric\"\n | \"tel\"\n | \"search\"\n | \"email\"\n | \"url\"\n // Hack to suggest above value but still allow any other string value\n | (string & {});\n\n@Component({\n tag: \"scout-input\",\n styleUrl: \"input.css\",\n scoped: true,\n})\nexport class ScoutInput implements ComponentInterface {\n /**\n * Type of input element. If you need a number input, read the accessibility\n * section of this MDN article first:\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number#accessibility\n */\n @Prop() type: InputType = \"text\";\n\n /**\n * Input mode hints for devices with dynamic keyboards.\n */\n @Prop() inputmode?: InputMode;\n\n /**\n * Regex pattern for input validation.\n */\n @Prop() pattern?: string;\n\n /**\n * Value of the input element, in case you want to control it yourself.\n */\n @Prop() value: string = \"\";\n\n /**\n * Whether the input is disabled. Disabled inputs are not editable, excluded\n * from tab order and are not validated.\n */\n @Prop() disabled: boolean = false;\n\n /**\n * Custom validation function run on top of the implicit validation performed\n * by the browser. Return a string with the validation message to mark the\n * input as invalid, or null to mark it as valid.\n */\n @Prop() validate?: (value: string) => string | null;\n\n @Event() scoutInputChange: EventEmitter<{\n value: string;\n element: HTMLInputElement;\n }>;\n @Event() scoutBlur: EventEmitter<void>;\n\n /**\n * Internal event used for form field association.\n */\n @Event() _fieldId: EventEmitter<string>;\n\n @State() ariaId: string;\n\n componentWillLoad(): Promise<void> | void {\n this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;\n this._fieldId.emit(this.ariaId);\n }\n\n onInput(event: InputEvent) {\n const input = event.target as HTMLInputElement;\n\n if (this.validate) {\n const validationMessage = this.validate(input.value);\n input.setCustomValidity(validationMessage ?? \"\");\n }\n\n this.scoutInputChange.emit({\n value: input.value,\n element: input,\n });\n }\n\n render() {\n return (\n <input\n id={this.ariaId}\n type={this.type}\n inputMode={this.inputmode}\n pattern={this.pattern}\n class=\"input\"\n value={this.value}\n disabled={this.disabled}\n onInput={(e) => this.onInput(e)}\n onBlur={() => this.scoutBlur.emit()}\n />\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
.switch {
|
|
2
|
+
width: var(--spacing-12);
|
|
3
|
+
height: var(--spacing-6);
|
|
4
|
+
-moz-appearance: none;
|
|
5
|
+
appearance: none;
|
|
6
|
+
-webkit-appearance: none;
|
|
7
|
+
border-radius: var(--spacing-8);
|
|
8
|
+
background-color: var(--color-text-brand-inverse);
|
|
9
|
+
border: 1px solid var(--color-gray-300);
|
|
10
|
+
position: relative;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-content: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
transition-property: border-color;
|
|
15
|
+
transition-duration: 0.3s;
|
|
16
|
+
transition-timing-function: ease-in-out;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
--switch-ball-size: calc((var(--spacing-6) - var(--spacing-1) / 2) + 1px);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.switch:hover {
|
|
22
|
+
transition-property: none;
|
|
23
|
+
border-color: var(--color-gray-400);
|
|
24
|
+
background-color: var(--color-background-brand-subtle-hovered);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.switch:active {
|
|
28
|
+
background-color: var(--color-background-brand-subtle-pressed);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.switch:checked {
|
|
32
|
+
border-color: var(--color-background-brand-base);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.switch:hover::before {
|
|
36
|
+
background-color: var(--color-gray-400);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.switch::before {
|
|
40
|
+
content: "";
|
|
41
|
+
background-color: var(--color-gray-300);
|
|
42
|
+
width: var(--switch-ball-size);
|
|
43
|
+
height: var(--switch-ball-size);
|
|
44
|
+
border-radius: 50%;
|
|
45
|
+
position: absolute;
|
|
46
|
+
left: -1px;
|
|
47
|
+
right: 0;
|
|
48
|
+
transition-duration: 0.3s;
|
|
49
|
+
transition-property: left, right;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.switch:checked::before {
|
|
53
|
+
content: "";
|
|
54
|
+
background-color: var(--color-background-brand-base);
|
|
55
|
+
left: calc(100% - (var(--spacing-6) - var(--spacing-1) / 2) + 1px);
|
|
56
|
+
left: calc(100% - calc(var(--spacing-6) - var(--spacing-1) / 2) + 1px);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.switch:disabled {
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
background-color: var(--color-gray-100);
|
|
62
|
+
border-color: var(--color-gray-100);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.switch:disabled::before {
|
|
66
|
+
background-color: var(--color-gray-300);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
label {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: row-reverse;
|
|
72
|
+
align-items: center;
|
|
73
|
+
font: var(--type-label-base);
|
|
74
|
+
color: var(--color-text-base);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.inlineDivider {
|
|
78
|
+
width: var(--spacing-2);
|
|
79
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { h, } from "@stencil/core";
|
|
2
|
+
export class ScoutSwitch {
|
|
3
|
+
/**
|
|
4
|
+
* Indicates whether the switch is toggled on or off.
|
|
5
|
+
*/
|
|
6
|
+
toggled = false;
|
|
7
|
+
disabled = false;
|
|
8
|
+
/**
|
|
9
|
+
* Use this prop if you need to connect your switch with another element describing its use, other than the property label.
|
|
10
|
+
*/
|
|
11
|
+
ariaLabelledby;
|
|
12
|
+
label;
|
|
13
|
+
ariaId;
|
|
14
|
+
scoutSwitchToggled;
|
|
15
|
+
/**
|
|
16
|
+
* Internal event used for form field association.
|
|
17
|
+
*/
|
|
18
|
+
_fieldId;
|
|
19
|
+
componentWillLoad() {
|
|
20
|
+
this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;
|
|
21
|
+
this._fieldId.emit(this.ariaId);
|
|
22
|
+
}
|
|
23
|
+
onClick(event) {
|
|
24
|
+
const switchElement = event.target;
|
|
25
|
+
this.scoutSwitchToggled.emit({
|
|
26
|
+
toggled: switchElement.checked,
|
|
27
|
+
element: switchElement,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
const Tag = this.label && this.label.length ? "label" : "div";
|
|
32
|
+
return (h(Tag, { key: '06f33e80dedee05abc34f15fbd8453f3df50d760' }, this.label, h("span", { key: '3061c223b64f313d4ebcd4b068ca84d83c5bb9c2', class: "inlineDivider" }), h("input", { key: '66a3a848ce3aa484af9bb13eda6cc30e46e74c1d', class: "switch", onChange: (event) => this.onClick(event), type: "checkbox", id: this.ariaId, "aria-labelledby": this.ariaLabelledby, "aria-disabled": this.disabled, disabled: this.disabled, checked: this.toggled })));
|
|
33
|
+
}
|
|
34
|
+
static get is() { return "scout-switch"; }
|
|
35
|
+
static get encapsulation() { return "shadow"; }
|
|
36
|
+
static get delegatesFocus() { return true; }
|
|
37
|
+
static get originalStyleUrls() {
|
|
38
|
+
return {
|
|
39
|
+
"$": ["switch.css"]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
static get styleUrls() {
|
|
43
|
+
return {
|
|
44
|
+
"$": ["switch.css"]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
static get properties() {
|
|
48
|
+
return {
|
|
49
|
+
"toggled": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"mutable": false,
|
|
52
|
+
"complexType": {
|
|
53
|
+
"original": "boolean",
|
|
54
|
+
"resolved": "boolean",
|
|
55
|
+
"references": {}
|
|
56
|
+
},
|
|
57
|
+
"required": false,
|
|
58
|
+
"optional": false,
|
|
59
|
+
"docs": {
|
|
60
|
+
"tags": [],
|
|
61
|
+
"text": "Indicates whether the switch is toggled on or off."
|
|
62
|
+
},
|
|
63
|
+
"getter": false,
|
|
64
|
+
"setter": false,
|
|
65
|
+
"reflect": false,
|
|
66
|
+
"attribute": "toggled",
|
|
67
|
+
"defaultValue": "false"
|
|
68
|
+
},
|
|
69
|
+
"disabled": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"mutable": false,
|
|
72
|
+
"complexType": {
|
|
73
|
+
"original": "boolean",
|
|
74
|
+
"resolved": "boolean",
|
|
75
|
+
"references": {}
|
|
76
|
+
},
|
|
77
|
+
"required": false,
|
|
78
|
+
"optional": false,
|
|
79
|
+
"docs": {
|
|
80
|
+
"tags": [],
|
|
81
|
+
"text": ""
|
|
82
|
+
},
|
|
83
|
+
"getter": false,
|
|
84
|
+
"setter": false,
|
|
85
|
+
"reflect": false,
|
|
86
|
+
"attribute": "disabled",
|
|
87
|
+
"defaultValue": "false"
|
|
88
|
+
},
|
|
89
|
+
"ariaLabelledby": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"mutable": false,
|
|
92
|
+
"complexType": {
|
|
93
|
+
"original": "string",
|
|
94
|
+
"resolved": "string",
|
|
95
|
+
"references": {}
|
|
96
|
+
},
|
|
97
|
+
"required": false,
|
|
98
|
+
"optional": false,
|
|
99
|
+
"docs": {
|
|
100
|
+
"tags": [],
|
|
101
|
+
"text": "Use this prop if you need to connect your switch with another element describing its use, other than the property label."
|
|
102
|
+
},
|
|
103
|
+
"getter": false,
|
|
104
|
+
"setter": false,
|
|
105
|
+
"reflect": false,
|
|
106
|
+
"attribute": "aria-labelledby"
|
|
107
|
+
},
|
|
108
|
+
"label": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"mutable": false,
|
|
111
|
+
"complexType": {
|
|
112
|
+
"original": "string",
|
|
113
|
+
"resolved": "string",
|
|
114
|
+
"references": {}
|
|
115
|
+
},
|
|
116
|
+
"required": false,
|
|
117
|
+
"optional": false,
|
|
118
|
+
"docs": {
|
|
119
|
+
"tags": [],
|
|
120
|
+
"text": ""
|
|
121
|
+
},
|
|
122
|
+
"getter": false,
|
|
123
|
+
"setter": false,
|
|
124
|
+
"reflect": false,
|
|
125
|
+
"attribute": "label"
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
static get states() {
|
|
130
|
+
return {
|
|
131
|
+
"ariaId": {}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
static get events() {
|
|
135
|
+
return [{
|
|
136
|
+
"method": "scoutSwitchToggled",
|
|
137
|
+
"name": "scoutSwitchToggled",
|
|
138
|
+
"bubbles": true,
|
|
139
|
+
"cancelable": true,
|
|
140
|
+
"composed": true,
|
|
141
|
+
"docs": {
|
|
142
|
+
"tags": [],
|
|
143
|
+
"text": ""
|
|
144
|
+
},
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "{\n toggled: boolean;\n element: HTMLInputElement;\n }",
|
|
147
|
+
"resolved": "{ toggled: boolean; element: HTMLInputElement; }",
|
|
148
|
+
"references": {
|
|
149
|
+
"HTMLInputElement": {
|
|
150
|
+
"location": "global",
|
|
151
|
+
"id": "global::HTMLInputElement"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
"method": "_fieldId",
|
|
157
|
+
"name": "_fieldId",
|
|
158
|
+
"bubbles": true,
|
|
159
|
+
"cancelable": true,
|
|
160
|
+
"composed": true,
|
|
161
|
+
"docs": {
|
|
162
|
+
"tags": [],
|
|
163
|
+
"text": "Internal event used for form field association."
|
|
164
|
+
},
|
|
165
|
+
"complexType": {
|
|
166
|
+
"original": "string",
|
|
167
|
+
"resolved": "string",
|
|
168
|
+
"references": {}
|
|
169
|
+
}
|
|
170
|
+
}];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/components/switch/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,KAAK,GACN,MAAM,eAAe,CAAC;AASvB,MAAM,OAAO,WAAW;IACtB;;OAEG;IACK,OAAO,GAAY,KAAK,CAAC;IAEzB,QAAQ,GAAY,KAAK,CAAC;IAElC;;OAEG;IACK,cAAc,CAAS;IAEvB,KAAK,CAAS;IAEb,MAAM,CAAS;IAEf,kBAAkB,CAGxB;IACH;;OAEG;IACM,QAAQ,CAAuB;IAExC,iBAAiB;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC/D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,KAAY;QAClB,MAAM,aAAa,GAAG,KAAK,CAAC,MAA0B,CAAC;QAEvD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,OAAO,EAAE,aAAa;SACvB,CAAC,CAAC;IACL,CAAC;IAED,MAAM;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAC9D,OAAO,CACL,EAAC,GAAG;YACD,IAAI,CAAC,KAAK;YACX,6DAAM,KAAK,EAAC,eAAe,GAAQ;YACnC,8DACE,KAAK,EAAC,QAAQ,EACd,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EACxC,IAAI,EAAC,UAAU,EACf,EAAE,EAAE,IAAI,CAAC,MAAM,qBACE,IAAI,CAAC,cAAc,mBACrB,IAAI,CAAC,QAAQ,EAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,IAAI,CAAC,OAAO,GACrB,CACE,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Event,\n type EventEmitter,\n h,\n Prop,\n State,\n} from \"@stencil/core\";\n\n@Component({\n tag: \"scout-switch\",\n styleUrl: \"switch.css\",\n shadow: {\n delegatesFocus: true,\n },\n})\nexport class ScoutSwitch {\n /**\n * Indicates whether the switch is toggled on or off.\n */\n @Prop() toggled: boolean = false;\n\n @Prop() disabled: boolean = false;\n\n /**\n * Use this prop if you need to connect your switch with another element describing its use, other than the property label.\n */\n @Prop() ariaLabelledby: string;\n\n @Prop() label: string;\n\n @State() ariaId: string;\n\n @Event() scoutSwitchToggled: EventEmitter<{\n toggled: boolean;\n element: HTMLInputElement;\n }>;\n /**\n * Internal event used for form field association.\n */\n @Event() _fieldId: EventEmitter<string>;\n\n componentWillLoad(): Promise<void> | void {\n this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;\n this._fieldId.emit(this.ariaId);\n }\n\n onClick(event: Event) {\n const switchElement = event.target as HTMLInputElement;\n\n this.scoutSwitchToggled.emit({\n toggled: switchElement.checked,\n element: switchElement,\n });\n }\n\n render() {\n const Tag = this.label && this.label.length ? \"label\" : \"div\";\n return (\n <Tag>\n {this.label}\n <span class=\"inlineDivider\"></span>\n <input\n class=\"switch\"\n onChange={(event) => this.onClick(event)}\n type=\"checkbox\"\n id={this.ariaId}\n aria-labelledby={this.ariaLabelledby}\n aria-disabled={this.disabled}\n disabled={this.disabled}\n checked={this.toggled}\n />\n </Tag>\n );\n }\n}\n"]}
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as getAssetPath, r as render, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-
|
|
1
|
+
export { g as getAssetPath, r as render, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-MfRr-Vl1.js';
|
|
2
2
|
|
|
3
3
|
function format(first, middle, last) {
|
|
4
4
|
return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
|