@scouterna/ui-webc 1.0.0 → 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/loader.cjs.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/collection/collection-manifest.json +3 -1
- 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.js +1 -1
- 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/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.js +1 -1
- 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 +317 -1
- package/dist/esm/loader.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +22 -0
- package/dist/types/components/switch/switch.d.ts +25 -0
- package/dist/types/components.d.ts +134 -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-fb926c68.entry.js → p-7245a55a.entry.js} +2 -2
- package/dist/ui-webc/scout-checkbox.entry.esm.js.map +1 -0
- package/dist/ui-webc/scout-switch.entry.esm.js.map +1 -0
- package/dist/ui-webc/ui-webc.esm.js +1 -1
- package/package.json +2 -1
- /package/dist/ui-webc/{p-fb926c68.entry.js.map → p-7245a55a.entry.js.map} +0 -0
|
@@ -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"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface ScoutCheckbox extends Components.ScoutCheckbox, HTMLElement {}
|
|
4
|
+
export const ScoutCheckbox: {
|
|
5
|
+
prototype: ScoutCheckbox;
|
|
6
|
+
new (): ScoutCheckbox;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h } from './p-MfRr-Vl1.js';
|
|
2
|
+
|
|
3
|
+
const checkSvg = 'data:image/svg+xml;base64,PHN2ZwogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB3aWR0aD0iMjQiCiAgaGVpZ2h0PSIyNCIKICB2aWV3Qm94PSIwIDAgMjQgMjQiCiAgZmlsbD0ibm9uZSIKICBzdHJva2U9ImN1cnJlbnRDb2xvciIKICBzdHJva2Utd2lkdGg9IjIiCiAgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgY2xhc3M9Imljb24gaWNvbi10YWJsZXIgaWNvbnMtdGFibGVyLW91dGxpbmUgaWNvbi10YWJsZXItY2hlY2siCj4KICA8cGF0aCBzdHJva2U9Im5vbmUiIGQ9Ik0wIDBoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz4KICA8cGF0aCBkPSJNNSAxMmw1IDVsMTAgLTEwIiAvPgo8L3N2Zz4=';
|
|
4
|
+
|
|
5
|
+
const checkboxCss = ".checkbox.sc-scout-checkbox{width:var(--spacing-6);height:var(--spacing-6);-moz-appearance:none;appearance:none;-webkit-appearance:none;display:flex;align-content:center;justify-content:center;border-radius:3px;background-color:var(--color-text-brand-inverse);border:2px solid var(--color-gray-300);position:relative}.checkbox.sc-scout-checkbox:hover{border:2px solid var(--color-gray-400);box-shadow:inset 0px 0px 5px 5px var(--color-background-brand-subtle-hovered);cursor:pointer}.checkbox.sc-scout-checkbox:active{background-color:var(--color-background-brand-subtle-pressed)}.checkbox.sc-scout-checkbox:checked:hover{background-color:var(--color-background-brand-hovered);border:2px solid var(--color-background-brand-hovered);box-shadow:none}.checkbox.sc-scout-checkbox:checked{background-color:var(--color-background-brand-base);border-color:var(--color-background-brand-base)}.checkbox.sc-scout-checkbox::after{content:\"\";position:absolute;width:var(--spacing-10);height:var(--spacing-10);top:50%;left:50%;transform:translate(-50%, -50%)}.checkbox.sc-scout-checkbox:checked::before{content:\"\";background-color:var(--color-text-brand-inverse);width:var(--spacing-6);height:var(--spacing-6);position:absolute;top:50%;left:50%;right:0;bottom:0;transform:translate(-50%, -50%);-webkit-mask-image:var(--icon-checkbox);mask-image:var(--icon-checkbox);-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}.checkbox.sc-scout-checkbox:disabled{pointer-events:none;background-color:var(--color-gray-100);border-color:var(--color-gray-100)}label.sc-scout-checkbox{display:flex;flex-direction:row-reverse;align-items:center;font:var(--type-label-base);color:var(--color-text-base)}.inlineDivider.sc-scout-checkbox{width:var(--spacing-2)}";
|
|
6
|
+
|
|
7
|
+
const ScoutCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class ScoutCheckbox extends H {
|
|
8
|
+
constructor(registerHost) {
|
|
9
|
+
super();
|
|
10
|
+
if (registerHost !== false) {
|
|
11
|
+
this.__registerHost();
|
|
12
|
+
}
|
|
13
|
+
this.scoutCheckboxChecked = createEvent(this, "scoutCheckboxChecked");
|
|
14
|
+
this._fieldId = createEvent(this, "_fieldId");
|
|
15
|
+
}
|
|
16
|
+
checked = false;
|
|
17
|
+
disabled = false;
|
|
18
|
+
/**
|
|
19
|
+
* Use this prop if you need to connect your checkbox with another element describing its use, other than the property label.
|
|
20
|
+
*/
|
|
21
|
+
ariaLabelledby;
|
|
22
|
+
label;
|
|
23
|
+
ariaId;
|
|
24
|
+
scoutCheckboxChecked;
|
|
25
|
+
/**
|
|
26
|
+
* Internal event used for form field association.
|
|
27
|
+
*/
|
|
28
|
+
_fieldId;
|
|
29
|
+
componentWillLoad() {
|
|
30
|
+
this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;
|
|
31
|
+
this._fieldId.emit(this.ariaId);
|
|
32
|
+
}
|
|
33
|
+
onClick(event) {
|
|
34
|
+
const checkbox = event.target;
|
|
35
|
+
console.log("checkbox", checkbox.checked);
|
|
36
|
+
this.scoutCheckboxChecked.emit({
|
|
37
|
+
checked: checkbox.checked,
|
|
38
|
+
element: checkbox,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/*
|
|
42
|
+
todo:
|
|
43
|
+
- Wrap checkbox with label if used.
|
|
44
|
+
- make sure it works with field nicely with label.
|
|
45
|
+
*/
|
|
46
|
+
render() {
|
|
47
|
+
const Tag = this.label && this.label.length ? "label" : "div";
|
|
48
|
+
return (h(Tag, { key: '2d97627d29b09521936eeef81419673d70fc75f1' }, this.label, h("span", { key: 'f62b4e360f03b4b6fb6e8fee326756552a5a631d', class: "inlineDivider" }), h("input", { key: '7ca6b74e12c369fc937d1b8c85e70c52fd9aa25c', class: "checkbox", onChange: (event) => this.onClick(event), style: { "--icon-checkbox": `url(${checkSvg})` }, type: "checkbox", id: this.ariaId, "aria-labelledby": this.ariaLabelledby, "aria-disabled": this.disabled, disabled: this.disabled, checked: this.checked })));
|
|
49
|
+
}
|
|
50
|
+
static get style() { return checkboxCss; }
|
|
51
|
+
}, [258, "scout-checkbox", {
|
|
52
|
+
"checked": [4],
|
|
53
|
+
"disabled": [4],
|
|
54
|
+
"ariaLabelledby": [1, "aria-labelledby"],
|
|
55
|
+
"label": [1],
|
|
56
|
+
"ariaId": [32]
|
|
57
|
+
}]);
|
|
58
|
+
function defineCustomElement$1() {
|
|
59
|
+
if (typeof customElements === "undefined") {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const components = ["scout-checkbox"];
|
|
63
|
+
components.forEach(tagName => { switch (tagName) {
|
|
64
|
+
case "scout-checkbox":
|
|
65
|
+
if (!customElements.get(tagName)) {
|
|
66
|
+
customElements.define(tagName, ScoutCheckbox$1);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
} });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const ScoutCheckbox = ScoutCheckbox$1;
|
|
73
|
+
const defineCustomElement = defineCustomElement$1;
|
|
74
|
+
|
|
75
|
+
export { ScoutCheckbox, defineCustomElement };
|
|
76
|
+
//# sourceMappingURL=scout-checkbox.js.map
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=scout-checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"scout-checkbox.js","mappings":";;AAAA,MAAM,QAAQ,GAAG,4fAA4f;;ACA7gB,MAAM,WAAW,GAAG,0sDAA0sD;;MCejtDA,eAAa,iBAAAC,kBAAA,CAAA,MAAA,aAAA,SAAAC,CAAA,CAAA;;;;;;;;;IAChB,OAAO,GAAY,KAAK;IAExB,QAAQ,GAAY,KAAK;AAEjC;;AAEG;AACK,IAAA,cAAc;AAEd,IAAA,KAAK;AAEJ,IAAA,MAAM;AAEN,IAAA,oBAAoB;AAI7B;;AAEG;AACM,IAAA,QAAQ;IAEjB,iBAAiB,GAAA;QACf,IAAI,CAAC,MAAM,GAAG,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAE;QAC9D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;;AAGjC,IAAA,OAAO,CAAC,KAAY,EAAA;AAClB,QAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,MAA0B;QACjD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC;AAEzC,QAAA,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;YAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO;AACzB,YAAA,OAAO,EAAE,QAAQ;AAClB,SAAA,CAAC;;AAEJ;;;;AAIE;IAEF,MAAM,GAAA;AACJ,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,KAAK;QAC7D,QACE,EAAC,GAAG,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,EACD,IAAI,CAAC,KAAK,EACX,CAAM,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,eAAe,EAAQ,CAAA,EACnC,CAAA,CAAA,OAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EACE,KAAK,EAAC,UAAU,EAChB,QAAQ,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EACxC,KAAK,EAAE,EAAE,iBAAiB,EAAE,CAAA,IAAA,EAAOC,QAAS,CAAA,CAAA,CAAG,EAAE,EACjD,IAAI,EAAC,UAAU,EACf,EAAE,EAAE,IAAI,CAAC,MAAM,EAAA,iBAAA,EACE,IAAI,CAAC,cAAc,EAAA,eAAA,EACrB,IAAI,CAAC,QAAQ,EAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAA,CACrB,CACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["ScoutCheckbox","__stencil_proxyCustomElement","HTMLElement","checkIcon"],"sources":["../../node_modules/.pnpm/@tabler+icons@3.35.0/node_modules/@tabler/icons/icons/outline/check.svg","src/components/checkbox/checkbox.css?tag=scout-checkbox&encapsulation=scoped","src/components/checkbox/checkbox.tsx"],"sourcesContent":["<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-check\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M5 12l5 5l10 -10\" />\n</svg>",".checkbox {\n width: var(--spacing-6);\n height: var(--spacing-6);\n appearance: none;\n -webkit-appearance: none;\n display: flex;\n align-content: center;\n justify-content: center;\n border-radius: 3px;\n background-color: var(--color-text-brand-inverse);\n border: 2px solid var(--color-gray-300);\n position: relative;\n}\n\n.checkbox:hover {\n border: 2px solid var(--color-gray-400);\n box-shadow: inset 0px 0px 5px 5px var(--color-background-brand-subtle-hovered);\n cursor: pointer;\n}\n\n.checkbox:active {\n background-color: var(--color-background-brand-subtle-pressed);\n}\n\n.checkbox:checked:hover {\n background-color: var(--color-background-brand-hovered);\n border: 2px solid var(--color-background-brand-hovered);\n box-shadow: none;\n}\n\n.checkbox:checked {\n background-color: var(--color-background-brand-base);\n border-color: var(--color-background-brand-base);\n}\n\n.checkbox::after {\n content: \"\";\n position: absolute;\n width: var(--spacing-10);\n height: var(--spacing-10);\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n\n.checkbox:checked::before {\n content: \"\";\n background-color: var(--color-text-brand-inverse);\n width: var(--spacing-6);\n height: var(--spacing-6);\n position: absolute;\n /* Needed because of the border */\n top: 50%;\n left: 50%;\n right: 0;\n bottom: 0;\n transform: translate(-50%, -50%);\n mask-image: var(--icon-checkbox);\n mask-repeat: no-repeat;\n}\n\n.checkbox:disabled {\n pointer-events: none;\n background-color: var(--color-gray-100);\n border-color: var(--color-gray-100);\n}\n\nlabel {\n display: flex;\n flex-direction: row-reverse;\n align-items: center;\n font: var(--type-label-base);\n color: var(--color-text-base);\n}\n\n.inlineDivider {\n width: var(--spacing-2);\n}\n","import {\n Component,\n Event,\n type EventEmitter,\n h,\n Prop,\n State,\n} from \"@stencil/core\";\nimport checkIcon from \"@tabler/icons/outline/check.svg\";\n\n@Component({\n tag: \"scout-checkbox\",\n styleUrl: \"checkbox.css\",\n scoped: true,\n})\nexport class ScoutCheckbox {\n @Prop() checked: boolean = false;\n\n @Prop() disabled: boolean = false;\n\n /**\n * Use this prop if you need to connect your checkbox 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() scoutCheckboxChecked: EventEmitter<{\n checked: 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 checkbox = event.target as HTMLInputElement;\n console.log(\"checkbox\", checkbox.checked);\n\n this.scoutCheckboxChecked.emit({\n checked: checkbox.checked,\n element: checkbox,\n });\n }\n /*\n todo:\n - Wrap checkbox with label if used.\n - make sure it works with field nicely with label.\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=\"checkbox\"\n onChange={(event) => this.onClick(event)}\n style={{ \"--icon-checkbox\": `url(${checkIcon})` }}\n type=\"checkbox\"\n id={this.ariaId}\n aria-labelledby={this.ariaLabelledby}\n aria-disabled={this.disabled}\n disabled={this.disabled}\n checked={this.checked}\n />\n </Tag>\n );\n }\n}\n"],"version":3}
|
|
@@ -39,7 +39,7 @@ const ScoutField$1 = /*@__PURE__*/ proxyCustomElement(class ScoutField extends H
|
|
|
39
39
|
this.errorHidden = false;
|
|
40
40
|
}
|
|
41
41
|
render() {
|
|
42
|
-
return (h("div", { key: '
|
|
42
|
+
return (h("div", { key: '0ba5919cf10618bf4617e1ced85485a6d136f668', class: "field" }, h("label", { key: '55cac1b4eb9c0d58ea1e4045b9c85c30a384d99b', htmlFor: this.inputId, class: "label" }, this.label), h("slot", { key: 'b5931e88ad82e693ff1dc24acd99db393f048fab' }), h("p", { key: '6354b6187ba63158bdd5c784787f1612eb641db4', class: "error-text", "aria-live": "polite" }, !this.errorHidden && this.errorText), this.helpText && h("p", { key: 'ba9e47977b682fbe28afd61c6a00832506860e56', class: "help-text" }, this.helpText)));
|
|
43
43
|
}
|
|
44
44
|
static get style() { return fieldCss; }
|
|
45
45
|
}, [262, "scout-field", {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface ScoutSwitch extends Components.ScoutSwitch, HTMLElement {}
|
|
4
|
+
export const ScoutSwitch: {
|
|
5
|
+
prototype: ScoutSwitch;
|
|
6
|
+
new (): ScoutSwitch;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h } from './p-MfRr-Vl1.js';
|
|
2
|
+
|
|
3
|
+
const switchCss = ".switch{width:var(--spacing-12);height:var(--spacing-6);-moz-appearance:none;appearance:none;-webkit-appearance:none;border-radius:var(--spacing-8);background-color:var(--color-text-brand-inverse);border:1px solid var(--color-gray-300);position:relative;display:flex;align-content:center;justify-content:center;transition-property:border-color;transition-duration:0.3s;transition-timing-function:ease-in-out;cursor:pointer;--switch-ball-size:calc((var(--spacing-6) - var(--spacing-1) / 2) + 1px)}.switch:hover{transition-property:none;border-color:var(--color-gray-400);background-color:var(--color-background-brand-subtle-hovered)}.switch:active{background-color:var(--color-background-brand-subtle-pressed)}.switch:checked{border-color:var(--color-background-brand-base)}.switch:hover::before{background-color:var(--color-gray-400)}.switch::before{content:\"\";background-color:var(--color-gray-300);width:var(--switch-ball-size);height:var(--switch-ball-size);border-radius:50%;position:absolute;left:-1px;right:0;transition-duration:0.3s;transition-property:left, right}.switch:checked::before{content:\"\";background-color:var(--color-background-brand-base);left:calc(100% - (var(--spacing-6) - var(--spacing-1) / 2) + 1px);left:calc(100% - calc(var(--spacing-6) - var(--spacing-1) / 2) + 1px)}.switch:disabled{pointer-events:none;background-color:var(--color-gray-100);border-color:var(--color-gray-100)}.switch:disabled::before{background-color:var(--color-gray-300)}label{display:flex;flex-direction:row-reverse;align-items:center;font:var(--type-label-base);color:var(--color-text-base)}.inlineDivider{width:var(--spacing-2)}";
|
|
4
|
+
|
|
5
|
+
const ScoutSwitch$1 = /*@__PURE__*/ proxyCustomElement(class ScoutSwitch extends H {
|
|
6
|
+
constructor(registerHost) {
|
|
7
|
+
super();
|
|
8
|
+
if (registerHost !== false) {
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
}
|
|
11
|
+
this.__attachShadow();
|
|
12
|
+
this.scoutSwitchToggled = createEvent(this, "scoutSwitchToggled");
|
|
13
|
+
this._fieldId = createEvent(this, "_fieldId");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Indicates whether the switch is toggled on or off.
|
|
17
|
+
*/
|
|
18
|
+
toggled = false;
|
|
19
|
+
disabled = false;
|
|
20
|
+
/**
|
|
21
|
+
* Use this prop if you need to connect your switch with another element describing its use, other than the property label.
|
|
22
|
+
*/
|
|
23
|
+
ariaLabelledby;
|
|
24
|
+
label;
|
|
25
|
+
ariaId;
|
|
26
|
+
scoutSwitchToggled;
|
|
27
|
+
/**
|
|
28
|
+
* Internal event used for form field association.
|
|
29
|
+
*/
|
|
30
|
+
_fieldId;
|
|
31
|
+
componentWillLoad() {
|
|
32
|
+
this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;
|
|
33
|
+
this._fieldId.emit(this.ariaId);
|
|
34
|
+
}
|
|
35
|
+
onClick(event) {
|
|
36
|
+
const switchElement = event.target;
|
|
37
|
+
this.scoutSwitchToggled.emit({
|
|
38
|
+
toggled: switchElement.checked,
|
|
39
|
+
element: switchElement,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
const Tag = this.label && this.label.length ? "label" : "div";
|
|
44
|
+
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 })));
|
|
45
|
+
}
|
|
46
|
+
static get delegatesFocus() { return true; }
|
|
47
|
+
static get style() { return switchCss; }
|
|
48
|
+
}, [273, "scout-switch", {
|
|
49
|
+
"toggled": [4],
|
|
50
|
+
"disabled": [4],
|
|
51
|
+
"ariaLabelledby": [1, "aria-labelledby"],
|
|
52
|
+
"label": [1],
|
|
53
|
+
"ariaId": [32]
|
|
54
|
+
}]);
|
|
55
|
+
function defineCustomElement$1() {
|
|
56
|
+
if (typeof customElements === "undefined") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const components = ["scout-switch"];
|
|
60
|
+
components.forEach(tagName => { switch (tagName) {
|
|
61
|
+
case "scout-switch":
|
|
62
|
+
if (!customElements.get(tagName)) {
|
|
63
|
+
customElements.define(tagName, ScoutSwitch$1);
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
} });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const ScoutSwitch = ScoutSwitch$1;
|
|
70
|
+
const defineCustomElement = defineCustomElement$1;
|
|
71
|
+
|
|
72
|
+
export { ScoutSwitch, defineCustomElement };
|
|
73
|
+
//# sourceMappingURL=scout-switch.js.map
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=scout-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"scout-switch.js","mappings":";;AAAA,MAAM,SAAS,GAAG,omDAAomD;;MCgBzmDA,aAAW,iBAAAC,kBAAA,CAAA,MAAA,WAAA,SAAAC,CAAA,CAAA;;;;;;;;;;AACtB;;AAEG;IACK,OAAO,GAAY,KAAK;IAExB,QAAQ,GAAY,KAAK;AAEjC;;AAEG;AACK,IAAA,cAAc;AAEd,IAAA,KAAK;AAEJ,IAAA,MAAM;AAEN,IAAA,kBAAkB;AAI3B;;AAEG;AACM,IAAA,QAAQ;IAEjB,iBAAiB,GAAA;QACf,IAAI,CAAC,MAAM,GAAG,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAE;QAC9D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;;AAGjC,IAAA,OAAO,CAAC,KAAY,EAAA;AAClB,QAAA,MAAM,aAAa,GAAG,KAAK,CAAC,MAA0B;AAEtD,QAAA,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,aAAa,CAAC,OAAO;AAC9B,YAAA,OAAO,EAAE,aAAa;AACvB,SAAA,CAAC;;IAGJ,MAAM,GAAA;AACJ,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,KAAK;QAC7D,QACE,EAAC,GAAG,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,EACD,IAAI,CAAC,KAAK,EACX,CAAM,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,eAAe,EAAQ,CAAA,EACnC,CACE,CAAA,OAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,QAAQ,EACd,QAAQ,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EACxC,IAAI,EAAC,UAAU,EACf,EAAE,EAAE,IAAI,CAAC,MAAM,EAAA,iBAAA,EACE,IAAI,CAAC,cAAc,mBACrB,IAAI,CAAC,QAAQ,EAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAA,CACrB,CACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["ScoutSwitch","__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/switch/switch.css?tag=scout-switch&encapsulation=shadow","src/components/switch/switch.tsx"],"sourcesContent":[".switch {\n width: var(--spacing-12);\n height: var(--spacing-6);\n appearance: none;\n -webkit-appearance: none;\n border-radius: var(--spacing-8);\n background-color: var(--color-text-brand-inverse);\n border: 1px solid var(--color-gray-300);\n position: relative;\n display: flex;\n align-content: center;\n justify-content: center;\n transition-property: border-color;\n transition-duration: 0.3s;\n transition-timing-function: ease-in-out;\n cursor: pointer;\n --switch-ball-size: calc((var(--spacing-6) - var(--spacing-1) / 2) + 1px);\n}\n\n.switch:hover {\n transition-property: none;\n border-color: var(--color-gray-400);\n background-color: var(--color-background-brand-subtle-hovered);\n}\n\n.switch:active {\n background-color: var(--color-background-brand-subtle-pressed);\n}\n\n.switch:checked {\n border-color: var(--color-background-brand-base);\n}\n\n.switch:hover::before {\n background-color: var(--color-gray-400);\n}\n\n.switch::before {\n content: \"\";\n background-color: var(--color-gray-300);\n width: var(--switch-ball-size);\n height: var(--switch-ball-size);\n border-radius: 50%;\n position: absolute;\n left: -1px;\n right: 0;\n transition-duration: 0.3s;\n transition-property: left, right;\n}\n.switch:checked::before {\n content: \"\";\n background-color: var(--color-background-brand-base);\n left: calc(100% - calc(var(--spacing-6) - var(--spacing-1) / 2) + 1px);\n}\n\n.switch:disabled {\n pointer-events: none;\n background-color: var(--color-gray-100);\n border-color: var(--color-gray-100);\n}\n\n.switch:disabled::before {\n background-color: var(--color-gray-300);\n}\n\nlabel {\n display: flex;\n flex-direction: row-reverse;\n align-items: center;\n font: var(--type-label-base);\n color: var(--color-text-base);\n}\n\n.inlineDivider {\n width: var(--spacing-2);\n}\n","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"],"version":3}
|