@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
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -5,7 +5,7 @@ var index = require('./index-D42maJcS.js');
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await index.globalScripts();
|
|
8
|
-
return index.bootstrapLazy([["scout-bottom-bar.cjs",[[273,"scout-bottom-bar"]]],["scout-bottom-bar-item.cjs",[[273,"scout-bottom-bar-item",{"type":[1],"href":[1],"icon":[1],"label":[1],"active":[4]}]]],["scout-button.cjs",[[273,"scout-button",{"type":[1],"variant":[1],"icon":[1]}]]],["scout-card.cjs",[[273,"scout-card"]]],["scout-field.cjs",[[262,"scout-field",{"label":[1],"helpText":[1,"help-text"],"inputId":[32],"errorText":[32],"errorHidden":[32]},[[0,"_fieldId","catchFieldId"],[0,"scoutInputChange","handleInputChange"],[0,"scoutBlur","handleValidationBlur"]]]]],["scout-input.cjs",[[258,"scout-input",{"type":[1],"inputmode":[1],"pattern":[1],"value":[1],"disabled":[4],"validate":[16],"ariaId":[32]}]]]], options);
|
|
8
|
+
return index.bootstrapLazy([["scout-bottom-bar.cjs",[[273,"scout-bottom-bar"]]],["scout-bottom-bar-item.cjs",[[273,"scout-bottom-bar-item",{"type":[1],"href":[1],"icon":[1],"label":[1],"active":[4]}]]],["scout-button.cjs",[[273,"scout-button",{"type":[1],"variant":[1],"icon":[1]}]]],["scout-card.cjs",[[273,"scout-card"]]],["scout-checkbox.cjs",[[258,"scout-checkbox",{"checked":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"ariaId":[32]}]]],["scout-field.cjs",[[262,"scout-field",{"label":[1],"helpText":[1,"help-text"],"inputId":[32],"errorText":[32],"errorHidden":[32]},[[0,"_fieldId","catchFieldId"],[0,"scoutInputChange","handleInputChange"],[0,"scoutBlur","handleValidationBlur"]]]]],["scout-input.cjs",[[258,"scout-input",{"type":[1],"inputmode":[1],"pattern":[1],"value":[1],"disabled":[4],"validate":[16],"ariaId":[32]}]]],["scout-switch.cjs",[[273,"scout-switch",{"toggled":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"ariaId":[32]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-D42maJcS.js');
|
|
4
|
+
|
|
5
|
+
const checkSvg = 'data:image/svg+xml;base64,PHN2ZwogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB3aWR0aD0iMjQiCiAgaGVpZ2h0PSIyNCIKICB2aWV3Qm94PSIwIDAgMjQgMjQiCiAgZmlsbD0ibm9uZSIKICBzdHJva2U9ImN1cnJlbnRDb2xvciIKICBzdHJva2Utd2lkdGg9IjIiCiAgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgY2xhc3M9Imljb24gaWNvbi10YWJsZXIgaWNvbnMtdGFibGVyLW91dGxpbmUgaWNvbi10YWJsZXItY2hlY2siCj4KICA8cGF0aCBzdHJva2U9Im5vbmUiIGQ9Ik0wIDBoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz4KICA8cGF0aCBkPSJNNSAxMmw1IDVsMTAgLTEwIiAvPgo8L3N2Zz4=';
|
|
6
|
+
|
|
7
|
+
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)}";
|
|
8
|
+
|
|
9
|
+
const ScoutCheckbox = class {
|
|
10
|
+
constructor(hostRef) {
|
|
11
|
+
index.registerInstance(this, hostRef);
|
|
12
|
+
this.scoutCheckboxChecked = index.createEvent(this, "scoutCheckboxChecked");
|
|
13
|
+
this._fieldId = index.createEvent(this, "_fieldId");
|
|
14
|
+
}
|
|
15
|
+
checked = false;
|
|
16
|
+
disabled = false;
|
|
17
|
+
/**
|
|
18
|
+
* Use this prop if you need to connect your checkbox with another element describing its use, other than the property label.
|
|
19
|
+
*/
|
|
20
|
+
ariaLabelledby;
|
|
21
|
+
label;
|
|
22
|
+
ariaId;
|
|
23
|
+
scoutCheckboxChecked;
|
|
24
|
+
/**
|
|
25
|
+
* Internal event used for form field association.
|
|
26
|
+
*/
|
|
27
|
+
_fieldId;
|
|
28
|
+
componentWillLoad() {
|
|
29
|
+
this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;
|
|
30
|
+
this._fieldId.emit(this.ariaId);
|
|
31
|
+
}
|
|
32
|
+
onClick(event) {
|
|
33
|
+
const checkbox = event.target;
|
|
34
|
+
console.log("checkbox", checkbox.checked);
|
|
35
|
+
this.scoutCheckboxChecked.emit({
|
|
36
|
+
checked: checkbox.checked,
|
|
37
|
+
element: checkbox,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/*
|
|
41
|
+
todo:
|
|
42
|
+
- Wrap checkbox with label if used.
|
|
43
|
+
- make sure it works with field nicely with label.
|
|
44
|
+
*/
|
|
45
|
+
render() {
|
|
46
|
+
const Tag = this.label && this.label.length ? "label" : "div";
|
|
47
|
+
return (index.h(Tag, { key: '2d97627d29b09521936eeef81419673d70fc75f1' }, this.label, index.h("span", { key: 'f62b4e360f03b4b6fb6e8fee326756552a5a631d', class: "inlineDivider" }), index.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 })));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
ScoutCheckbox.style = checkboxCss;
|
|
51
|
+
|
|
52
|
+
exports.scout_checkbox = ScoutCheckbox;
|
|
53
|
+
//# sourceMappingURL=scout-checkbox.entry.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scout-checkbox.entry.cjs.js","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"],"names":["h","checkIcon"],"mappings":";;;;AAAA,MAAM,QAAQ,GAAG,4fAA4f;;ACA7gB,MAAM,WAAW,GAAG,0sDAA0sD;;MCejtD,aAAa,GAAA,MAAA;;;;;;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,QACEA,QAAC,GAAG,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,EACD,IAAI,CAAC,KAAK,EACXA,OAAM,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,eAAe,EAAQ,CAAA,EACnCA,OAAA,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;;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -38,7 +38,7 @@ const ScoutField = class {
|
|
|
38
38
|
this.errorHidden = false;
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
return (index.h("div", { key: '
|
|
41
|
+
return (index.h("div", { key: '0ba5919cf10618bf4617e1ced85485a6d136f668', class: "field" }, index.h("label", { key: '55cac1b4eb9c0d58ea1e4045b9c85c30a384d99b', htmlFor: this.inputId, class: "label" }, this.label), index.h("slot", { key: 'b5931e88ad82e693ff1dc24acd99db393f048fab' }), index.h("p", { key: '6354b6187ba63158bdd5c784787f1612eb641db4', class: "error-text", "aria-live": "polite" }, !this.errorHidden && this.errorText), this.helpText && index.h("p", { key: 'ba9e47977b682fbe28afd61c6a00832506860e56', class: "help-text" }, this.helpText)));
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
ScoutField.style = fieldCss;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-D42maJcS.js');
|
|
4
|
+
|
|
5
|
+
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)}";
|
|
6
|
+
|
|
7
|
+
const ScoutSwitch = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
index.registerInstance(this, hostRef);
|
|
10
|
+
this.scoutSwitchToggled = index.createEvent(this, "scoutSwitchToggled");
|
|
11
|
+
this._fieldId = index.createEvent(this, "_fieldId");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Indicates whether the switch is toggled on or off.
|
|
15
|
+
*/
|
|
16
|
+
toggled = false;
|
|
17
|
+
disabled = false;
|
|
18
|
+
/**
|
|
19
|
+
* Use this prop if you need to connect your switch with another element describing its use, other than the property label.
|
|
20
|
+
*/
|
|
21
|
+
ariaLabelledby;
|
|
22
|
+
label;
|
|
23
|
+
ariaId;
|
|
24
|
+
scoutSwitchToggled;
|
|
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 switchElement = event.target;
|
|
35
|
+
this.scoutSwitchToggled.emit({
|
|
36
|
+
toggled: switchElement.checked,
|
|
37
|
+
element: switchElement,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
const Tag = this.label && this.label.length ? "label" : "div";
|
|
42
|
+
return (index.h(Tag, { key: '06f33e80dedee05abc34f15fbd8453f3df50d760' }, this.label, index.h("span", { key: '3061c223b64f313d4ebcd4b068ca84d83c5bb9c2', class: "inlineDivider" }), index.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 })));
|
|
43
|
+
}
|
|
44
|
+
static get delegatesFocus() { return true; }
|
|
45
|
+
};
|
|
46
|
+
ScoutSwitch.style = switchCss;
|
|
47
|
+
|
|
48
|
+
exports.scout_switch = ScoutSwitch;
|
|
49
|
+
//# sourceMappingURL=scout-switch.entry.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scout-switch.entry.cjs.js","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"],"names":["h"],"mappings":";;;;AAAA,MAAM,SAAS,GAAG,omDAAomD;;MCgBzmD,WAAW,GAAA,MAAA;;;;;;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,QACEA,QAAC,GAAG,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,EACD,IAAI,CAAC,KAAK,EACXA,OAAM,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,eAAe,EAAQ,CAAA,EACnCA,OACE,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;;;;;;;;"}
|
package/dist/cjs/ui-webc.cjs.js
CHANGED
|
@@ -18,7 +18,7 @@ var patchBrowser = () => {
|
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(async (options) => {
|
|
20
20
|
await index.globalScripts();
|
|
21
|
-
return index.bootstrapLazy([["scout-bottom-bar.cjs",[[273,"scout-bottom-bar"]]],["scout-bottom-bar-item.cjs",[[273,"scout-bottom-bar-item",{"type":[1],"href":[1],"icon":[1],"label":[1],"active":[4]}]]],["scout-button.cjs",[[273,"scout-button",{"type":[1],"variant":[1],"icon":[1]}]]],["scout-card.cjs",[[273,"scout-card"]]],["scout-field.cjs",[[262,"scout-field",{"label":[1],"helpText":[1,"help-text"],"inputId":[32],"errorText":[32],"errorHidden":[32]},[[0,"_fieldId","catchFieldId"],[0,"scoutInputChange","handleInputChange"],[0,"scoutBlur","handleValidationBlur"]]]]],["scout-input.cjs",[[258,"scout-input",{"type":[1],"inputmode":[1],"pattern":[1],"value":[1],"disabled":[4],"validate":[16],"ariaId":[32]}]]]], options);
|
|
21
|
+
return index.bootstrapLazy([["scout-bottom-bar.cjs",[[273,"scout-bottom-bar"]]],["scout-bottom-bar-item.cjs",[[273,"scout-bottom-bar-item",{"type":[1],"href":[1],"icon":[1],"label":[1],"active":[4]}]]],["scout-button.cjs",[[273,"scout-button",{"type":[1],"variant":[1],"icon":[1]}]]],["scout-card.cjs",[[273,"scout-card"]]],["scout-checkbox.cjs",[[258,"scout-checkbox",{"checked":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"ariaId":[32]}]]],["scout-field.cjs",[[262,"scout-field",{"label":[1],"helpText":[1,"help-text"],"inputId":[32],"errorText":[32],"errorHidden":[32]},[[0,"_fieldId","catchFieldId"],[0,"scoutInputChange","handleInputChange"],[0,"scoutBlur","handleValidationBlur"]]]]],["scout-input.cjs",[[258,"scout-input",{"type":[1],"inputmode":[1],"pattern":[1],"value":[1],"disabled":[4],"validate":[16],"ariaId":[32]}]]],["scout-switch.cjs",[[273,"scout-switch",{"toggled":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"ariaId":[32]}]]]], options);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
exports.setNonce = index.setNonce;
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
"components/input/input.js",
|
|
6
6
|
"components/bottom-bar/bottom-bar.js",
|
|
7
7
|
"components/card/card.js",
|
|
8
|
-
"components/
|
|
8
|
+
"components/checkbox/checkbox.js",
|
|
9
|
+
"components/field/field.js",
|
|
10
|
+
"components/switch/switch.js"
|
|
9
11
|
],
|
|
10
12
|
"compiler": {
|
|
11
13
|
"name": "@stencil/core",
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.checkbox {
|
|
2
|
+
width: var(--spacing-6);
|
|
3
|
+
height: var(--spacing-6);
|
|
4
|
+
-moz-appearance: none;
|
|
5
|
+
appearance: none;
|
|
6
|
+
-webkit-appearance: none;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-content: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
border-radius: 3px;
|
|
11
|
+
background-color: var(--color-text-brand-inverse);
|
|
12
|
+
border: 2px solid var(--color-gray-300);
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.checkbox:hover {
|
|
17
|
+
border: 2px solid var(--color-gray-400);
|
|
18
|
+
box-shadow: inset 0px 0px 5px 5px var(--color-background-brand-subtle-hovered);
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.checkbox:active {
|
|
23
|
+
background-color: var(--color-background-brand-subtle-pressed);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.checkbox:checked:hover {
|
|
27
|
+
background-color: var(--color-background-brand-hovered);
|
|
28
|
+
border: 2px solid var(--color-background-brand-hovered);
|
|
29
|
+
box-shadow: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.checkbox:checked {
|
|
33
|
+
background-color: var(--color-background-brand-base);
|
|
34
|
+
border-color: var(--color-background-brand-base);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.checkbox::after {
|
|
38
|
+
content: "";
|
|
39
|
+
position: absolute;
|
|
40
|
+
width: var(--spacing-10);
|
|
41
|
+
height: var(--spacing-10);
|
|
42
|
+
top: 50%;
|
|
43
|
+
left: 50%;
|
|
44
|
+
transform: translate(-50%, -50%);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.checkbox:checked::before {
|
|
48
|
+
content: "";
|
|
49
|
+
background-color: var(--color-text-brand-inverse);
|
|
50
|
+
width: var(--spacing-6);
|
|
51
|
+
height: var(--spacing-6);
|
|
52
|
+
position: absolute;
|
|
53
|
+
/* Needed because of the border */
|
|
54
|
+
top: 50%;
|
|
55
|
+
left: 50%;
|
|
56
|
+
right: 0;
|
|
57
|
+
bottom: 0;
|
|
58
|
+
transform: translate(-50%, -50%);
|
|
59
|
+
-webkit-mask-image: var(--icon-checkbox);
|
|
60
|
+
mask-image: var(--icon-checkbox);
|
|
61
|
+
-webkit-mask-repeat: no-repeat;
|
|
62
|
+
mask-repeat: no-repeat;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.checkbox:disabled {
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
background-color: var(--color-gray-100);
|
|
68
|
+
border-color: var(--color-gray-100);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
label {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: row-reverse;
|
|
74
|
+
align-items: center;
|
|
75
|
+
font: var(--type-label-base);
|
|
76
|
+
color: var(--color-text-base);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.inlineDivider {
|
|
80
|
+
width: var(--spacing-2);
|
|
81
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { h, } from "@stencil/core";
|
|
2
|
+
import checkIcon from "@tabler/icons/outline/check.svg";
|
|
3
|
+
export class ScoutCheckbox {
|
|
4
|
+
checked = false;
|
|
5
|
+
disabled = false;
|
|
6
|
+
/**
|
|
7
|
+
* Use this prop if you need to connect your checkbox with another element describing its use, other than the property label.
|
|
8
|
+
*/
|
|
9
|
+
ariaLabelledby;
|
|
10
|
+
label;
|
|
11
|
+
ariaId;
|
|
12
|
+
scoutCheckboxChecked;
|
|
13
|
+
/**
|
|
14
|
+
* Internal event used for form field association.
|
|
15
|
+
*/
|
|
16
|
+
_fieldId;
|
|
17
|
+
componentWillLoad() {
|
|
18
|
+
this.ariaId = `_${Math.random().toString(36).substring(2, 9)}`;
|
|
19
|
+
this._fieldId.emit(this.ariaId);
|
|
20
|
+
}
|
|
21
|
+
onClick(event) {
|
|
22
|
+
const checkbox = event.target;
|
|
23
|
+
console.log("checkbox", checkbox.checked);
|
|
24
|
+
this.scoutCheckboxChecked.emit({
|
|
25
|
+
checked: checkbox.checked,
|
|
26
|
+
element: checkbox,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/*
|
|
30
|
+
todo:
|
|
31
|
+
- Wrap checkbox with label if used.
|
|
32
|
+
- make sure it works with field nicely with label.
|
|
33
|
+
*/
|
|
34
|
+
render() {
|
|
35
|
+
const Tag = this.label && this.label.length ? "label" : "div";
|
|
36
|
+
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(${checkIcon})` }, type: "checkbox", id: this.ariaId, "aria-labelledby": this.ariaLabelledby, "aria-disabled": this.disabled, disabled: this.disabled, checked: this.checked })));
|
|
37
|
+
}
|
|
38
|
+
static get is() { return "scout-checkbox"; }
|
|
39
|
+
static get encapsulation() { return "scoped"; }
|
|
40
|
+
static get originalStyleUrls() {
|
|
41
|
+
return {
|
|
42
|
+
"$": ["checkbox.css"]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
static get styleUrls() {
|
|
46
|
+
return {
|
|
47
|
+
"$": ["checkbox.css"]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
static get properties() {
|
|
51
|
+
return {
|
|
52
|
+
"checked": {
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"mutable": false,
|
|
55
|
+
"complexType": {
|
|
56
|
+
"original": "boolean",
|
|
57
|
+
"resolved": "boolean",
|
|
58
|
+
"references": {}
|
|
59
|
+
},
|
|
60
|
+
"required": false,
|
|
61
|
+
"optional": false,
|
|
62
|
+
"docs": {
|
|
63
|
+
"tags": [],
|
|
64
|
+
"text": ""
|
|
65
|
+
},
|
|
66
|
+
"getter": false,
|
|
67
|
+
"setter": false,
|
|
68
|
+
"reflect": false,
|
|
69
|
+
"attribute": "checked",
|
|
70
|
+
"defaultValue": "false"
|
|
71
|
+
},
|
|
72
|
+
"disabled": {
|
|
73
|
+
"type": "boolean",
|
|
74
|
+
"mutable": false,
|
|
75
|
+
"complexType": {
|
|
76
|
+
"original": "boolean",
|
|
77
|
+
"resolved": "boolean",
|
|
78
|
+
"references": {}
|
|
79
|
+
},
|
|
80
|
+
"required": false,
|
|
81
|
+
"optional": false,
|
|
82
|
+
"docs": {
|
|
83
|
+
"tags": [],
|
|
84
|
+
"text": ""
|
|
85
|
+
},
|
|
86
|
+
"getter": false,
|
|
87
|
+
"setter": false,
|
|
88
|
+
"reflect": false,
|
|
89
|
+
"attribute": "disabled",
|
|
90
|
+
"defaultValue": "false"
|
|
91
|
+
},
|
|
92
|
+
"ariaLabelledby": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"mutable": false,
|
|
95
|
+
"complexType": {
|
|
96
|
+
"original": "string",
|
|
97
|
+
"resolved": "string",
|
|
98
|
+
"references": {}
|
|
99
|
+
},
|
|
100
|
+
"required": false,
|
|
101
|
+
"optional": false,
|
|
102
|
+
"docs": {
|
|
103
|
+
"tags": [],
|
|
104
|
+
"text": "Use this prop if you need to connect your checkbox with another element describing its use, other than the property label."
|
|
105
|
+
},
|
|
106
|
+
"getter": false,
|
|
107
|
+
"setter": false,
|
|
108
|
+
"reflect": false,
|
|
109
|
+
"attribute": "aria-labelledby"
|
|
110
|
+
},
|
|
111
|
+
"label": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"mutable": false,
|
|
114
|
+
"complexType": {
|
|
115
|
+
"original": "string",
|
|
116
|
+
"resolved": "string",
|
|
117
|
+
"references": {}
|
|
118
|
+
},
|
|
119
|
+
"required": false,
|
|
120
|
+
"optional": false,
|
|
121
|
+
"docs": {
|
|
122
|
+
"tags": [],
|
|
123
|
+
"text": ""
|
|
124
|
+
},
|
|
125
|
+
"getter": false,
|
|
126
|
+
"setter": false,
|
|
127
|
+
"reflect": false,
|
|
128
|
+
"attribute": "label"
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
static get states() {
|
|
133
|
+
return {
|
|
134
|
+
"ariaId": {}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
static get events() {
|
|
138
|
+
return [{
|
|
139
|
+
"method": "scoutCheckboxChecked",
|
|
140
|
+
"name": "scoutCheckboxChecked",
|
|
141
|
+
"bubbles": true,
|
|
142
|
+
"cancelable": true,
|
|
143
|
+
"composed": true,
|
|
144
|
+
"docs": {
|
|
145
|
+
"tags": [],
|
|
146
|
+
"text": ""
|
|
147
|
+
},
|
|
148
|
+
"complexType": {
|
|
149
|
+
"original": "{\n checked: boolean;\n element: HTMLInputElement;\n }",
|
|
150
|
+
"resolved": "{ checked: boolean; element: HTMLInputElement; }",
|
|
151
|
+
"references": {
|
|
152
|
+
"HTMLInputElement": {
|
|
153
|
+
"location": "global",
|
|
154
|
+
"id": "global::HTMLInputElement"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
"method": "_fieldId",
|
|
160
|
+
"name": "_fieldId",
|
|
161
|
+
"bubbles": true,
|
|
162
|
+
"cancelable": true,
|
|
163
|
+
"composed": true,
|
|
164
|
+
"docs": {
|
|
165
|
+
"tags": [],
|
|
166
|
+
"text": "Internal event used for form field association."
|
|
167
|
+
},
|
|
168
|
+
"complexType": {
|
|
169
|
+
"original": "string",
|
|
170
|
+
"resolved": "string",
|
|
171
|
+
"references": {}
|
|
172
|
+
}
|
|
173
|
+
}];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../../src/components/checkbox/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EAEL,CAAC,EACD,IAAI,EACJ,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,SAAS,MAAM,iCAAiC,CAAC;AAOxD,MAAM,OAAO,aAAa;IAChB,OAAO,GAAY,KAAK,CAAC;IAEzB,QAAQ,GAAY,KAAK,CAAC;IAElC;;OAEG;IACK,cAAc,CAAS;IAEvB,KAAK,CAAS;IAEb,MAAM,CAAS;IAEf,oBAAoB,CAG1B;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,QAAQ,GAAG,KAAK,CAAC,MAA0B,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE1C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;YAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,OAAO,EAAE,QAAQ;SAClB,CAAC,CAAC;IACL,CAAC;IACD;;;;MAIE;IAEF,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,UAAU,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EACxC,KAAK,EAAE,EAAE,iBAAiB,EAAE,OAAO,SAAS,GAAG,EAAE,EACjD,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\";\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"]}
|
|
@@ -30,7 +30,7 @@ export class ScoutField {
|
|
|
30
30
|
this.errorHidden = false;
|
|
31
31
|
}
|
|
32
32
|
render() {
|
|
33
|
-
return (h("div", { key: '
|
|
33
|
+
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)));
|
|
34
34
|
}
|
|
35
35
|
static get is() { return "scout-field"; }
|
|
36
36
|
static get encapsulation() { return "scoped"; }
|
|
@@ -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
|
+
}
|