@spectrum-web-components/radio 0.9.13 → 0.9.15-devmode.7
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/package.json +33 -14
- package/sp-radio-group.dev.js +3 -0
- package/sp-radio-group.dev.js.map +7 -0
- package/sp-radio-group.js +3 -14
- package/sp-radio-group.js.map +7 -1
- package/sp-radio.dev.js +3 -0
- package/sp-radio.dev.js.map +7 -0
- package/sp-radio.js +3 -14
- package/sp-radio.js.map +7 -1
- package/src/Radio.dev.js +125 -0
- package/src/Radio.dev.js.map +7 -0
- package/src/Radio.js +112 -134
- package/src/Radio.js.map +7 -1
- package/src/RadioGroup.dev.js +112 -0
- package/src/RadioGroup.dev.js.map +7 -0
- package/src/RadioGroup.js +102 -119
- package/src/RadioGroup.js.map +7 -1
- package/src/index.dev.js +3 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +3 -14
- package/src/index.js.map +7 -1
- package/src/radio.css.dev.js +118 -0
- package/src/radio.css.dev.js.map +7 -0
- package/src/radio.css.js +3 -14
- package/src/radio.css.js.map +7 -1
- package/src/spectrum-radio.css.dev.js +116 -0
- package/src/spectrum-radio.css.dev.js.map +7 -0
- package/src/spectrum-radio.css.js +3 -14
- package/src/spectrum-radio.css.js.map +7 -1
- package/stories/radio.stories.js +81 -93
- package/stories/radio.stories.js.map +7 -1
- package/test/benchmark/test-basic.js +6 -17
- package/test/benchmark/test-basic.js.map +7 -1
- package/test/radio-group.test.js +303 -308
- package/test/radio-group.test.js.map +7 -1
- package/test/radio.test-vrt.js +4 -15
- package/test/radio.test-vrt.js.map +7 -1
- package/test/radio.test.js +126 -130
- package/test/radio.test.js.map +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/radio",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.15-devmode.7+8303f3a2a",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,13 +20,32 @@
|
|
|
20
20
|
"module": "./src/index.js",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
23
|
+
".": {
|
|
24
|
+
"development": "./src/index.dev.js",
|
|
25
|
+
"default": "./src/index.js"
|
|
26
|
+
},
|
|
25
27
|
"./package.json": "./package.json",
|
|
26
|
-
"./
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
"./src/Radio.js": {
|
|
29
|
+
"development": "./src/Radio.dev.js",
|
|
30
|
+
"default": "./src/Radio.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/RadioGroup.js": {
|
|
33
|
+
"development": "./src/RadioGroup.dev.js",
|
|
34
|
+
"default": "./src/RadioGroup.js"
|
|
35
|
+
},
|
|
36
|
+
"./src/index.js": {
|
|
37
|
+
"development": "./src/index.dev.js",
|
|
38
|
+
"default": "./src/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./src/radio.css.js": "./src/radio.css.js",
|
|
41
|
+
"./sp-radio.js": {
|
|
42
|
+
"development": "./sp-radio.dev.js",
|
|
43
|
+
"default": "./sp-radio.js"
|
|
44
|
+
},
|
|
45
|
+
"./sp-radio-group.js": {
|
|
46
|
+
"development": "./sp-radio-group.dev.js",
|
|
47
|
+
"default": "./sp-radio-group.js"
|
|
48
|
+
}
|
|
30
49
|
},
|
|
31
50
|
"scripts": {
|
|
32
51
|
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
|
@@ -46,20 +65,20 @@
|
|
|
46
65
|
"lit-html"
|
|
47
66
|
],
|
|
48
67
|
"dependencies": {
|
|
49
|
-
"@spectrum-web-components/base": "^0.5.
|
|
50
|
-
"@spectrum-web-components/field-group": "^0.5.
|
|
51
|
-
"@spectrum-web-components/help-text": "^0.1.
|
|
52
|
-
"@spectrum-web-components/reactive-controllers": "^0.2.
|
|
53
|
-
"@spectrum-web-components/shared": "^0.14.
|
|
68
|
+
"@spectrum-web-components/base": "^0.5.9-devmode.31+8303f3a2a",
|
|
69
|
+
"@spectrum-web-components/field-group": "^0.5.12-devmode.7+8303f3a2a",
|
|
70
|
+
"@spectrum-web-components/help-text": "^0.1.11-devmode.7+8303f3a2a",
|
|
71
|
+
"@spectrum-web-components/reactive-controllers": "^0.2.5-devmode.86+8303f3a2a",
|
|
72
|
+
"@spectrum-web-components/shared": "^0.14.5-devmode.7+8303f3a2a",
|
|
54
73
|
"tslib": "^2.0.0"
|
|
55
74
|
},
|
|
56
75
|
"devDependencies": {
|
|
57
|
-
"@spectrum-css/radio": "^3.0.
|
|
76
|
+
"@spectrum-css/radio": "^3.0.24"
|
|
58
77
|
},
|
|
59
78
|
"types": "./src/index.d.ts",
|
|
60
79
|
"customElements": "custom-elements.json",
|
|
61
80
|
"sideEffects": [
|
|
62
81
|
"./sp-*.js"
|
|
63
82
|
],
|
|
64
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "8303f3a2a90b0aedc15158797662ccfa8f4a2031"
|
|
65
84
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-radio-group.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { RadioGroup } from './src/RadioGroup.dev.js'\n\ncustomElements.define('sp-radio-group', RadioGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-radio-group': RadioGroup;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,kBAAkB,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-radio-group.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { RadioGroup } from './src/RadioGroup.js';
|
|
13
|
-
customElements.define('sp-radio-group', RadioGroup);
|
|
14
|
-
//# sourceMappingURL=sp-radio-group.js.map
|
|
1
|
+
import { RadioGroup } from "./src/RadioGroup.js";
|
|
2
|
+
customElements.define("sp-radio-group", RadioGroup);
|
|
3
|
+
//# sourceMappingURL=sp-radio-group.js.map
|
package/sp-radio-group.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-radio-group.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { RadioGroup } from './src/RadioGroup.js';\n\ncustomElements.define('sp-radio-group', RadioGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-radio-group': RadioGroup;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,kBAAkB,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-radio.dev.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-radio.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { Radio } from './src/Radio.dev.js'\n\ncustomElements.define('sp-radio', Radio);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-radio': Radio;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,YAAY,KAAK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-radio.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { Radio } from './src/Radio.js';
|
|
13
|
-
customElements.define('sp-radio', Radio);
|
|
14
|
-
//# sourceMappingURL=sp-radio.js.map
|
|
1
|
+
import { Radio } from "./src/Radio.js";
|
|
2
|
+
customElements.define("sp-radio", Radio);
|
|
3
|
+
//# sourceMappingURL=sp-radio.js.map
|
package/sp-radio.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-radio.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { Radio } from './src/Radio.js';\n\ncustomElements.define('sp-radio', Radio);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-radio': Radio;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,eAAe,OAAO,YAAY,KAAK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/Radio.dev.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html,
|
|
14
|
+
SpectrumElement
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
+
import { FocusVisiblePolyfillMixin } from "@spectrum-web-components/shared/src/focus-visible.js";
|
|
18
|
+
import radioStyles from "./radio.css.js";
|
|
19
|
+
export class Radio extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.autofocus = false;
|
|
23
|
+
this.value = "";
|
|
24
|
+
this.checked = false;
|
|
25
|
+
this.disabled = false;
|
|
26
|
+
this.emphasized = false;
|
|
27
|
+
this.invalid = false;
|
|
28
|
+
this.readonly = false;
|
|
29
|
+
}
|
|
30
|
+
static get styles() {
|
|
31
|
+
return [radioStyles];
|
|
32
|
+
}
|
|
33
|
+
click() {
|
|
34
|
+
if (this.disabled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.activate();
|
|
38
|
+
}
|
|
39
|
+
manageAutoFocus() {
|
|
40
|
+
if (this.autofocus) {
|
|
41
|
+
this.dispatchEvent(new KeyboardEvent("keydown", {
|
|
42
|
+
code: "Tab"
|
|
43
|
+
}));
|
|
44
|
+
this.focus();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
activate() {
|
|
48
|
+
if (this.checked) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.checked = true;
|
|
52
|
+
this.dispatchEvent(new Event("change", {
|
|
53
|
+
bubbles: true,
|
|
54
|
+
composed: true
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
handleKeyup(event) {
|
|
58
|
+
if (event.code === "Space") {
|
|
59
|
+
this.activate();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
return html`
|
|
64
|
+
<div id="input"></div>
|
|
65
|
+
<span id="button"></span>
|
|
66
|
+
<span id="label" role="presentation"><slot></slot></span>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
firstUpdated(changes) {
|
|
70
|
+
super.firstUpdated(changes);
|
|
71
|
+
this.setAttribute("role", "radio");
|
|
72
|
+
if (!this.hasAttribute("tabindex")) {
|
|
73
|
+
this.tabIndex = 0;
|
|
74
|
+
}
|
|
75
|
+
this.manageAutoFocus();
|
|
76
|
+
this.addEventListener("click", this.activate);
|
|
77
|
+
this.addEventListener("keyup", this.handleKeyup);
|
|
78
|
+
}
|
|
79
|
+
updated(changes) {
|
|
80
|
+
super.updated(changes);
|
|
81
|
+
if (changes.has("invalid")) {
|
|
82
|
+
if (this.invalid) {
|
|
83
|
+
this.setAttribute("aria-invalid", "true");
|
|
84
|
+
} else {
|
|
85
|
+
this.removeAttribute("aria-invalid");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (changes.has("checked")) {
|
|
89
|
+
if (this.checked) {
|
|
90
|
+
this.setAttribute("aria-checked", "true");
|
|
91
|
+
} else {
|
|
92
|
+
this.setAttribute("aria-checked", "false");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (changes.has("disabled")) {
|
|
96
|
+
if (this.disabled) {
|
|
97
|
+
this.setAttribute("aria-disabled", "true");
|
|
98
|
+
} else {
|
|
99
|
+
this.removeAttribute("aria-disabeld");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
__decorateClass([
|
|
105
|
+
property({ type: Boolean })
|
|
106
|
+
], Radio.prototype, "autofocus", 2);
|
|
107
|
+
__decorateClass([
|
|
108
|
+
property({ type: String, reflect: true })
|
|
109
|
+
], Radio.prototype, "value", 2);
|
|
110
|
+
__decorateClass([
|
|
111
|
+
property({ type: Boolean, reflect: true })
|
|
112
|
+
], Radio.prototype, "checked", 2);
|
|
113
|
+
__decorateClass([
|
|
114
|
+
property({ type: Boolean, reflect: true })
|
|
115
|
+
], Radio.prototype, "disabled", 2);
|
|
116
|
+
__decorateClass([
|
|
117
|
+
property({ type: Boolean, reflect: true })
|
|
118
|
+
], Radio.prototype, "emphasized", 2);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
property({ type: Boolean, reflect: true })
|
|
121
|
+
], Radio.prototype, "invalid", 2);
|
|
122
|
+
__decorateClass([
|
|
123
|
+
property({ type: Boolean, reflect: true })
|
|
124
|
+
], Radio.prototype, "readonly", 2);
|
|
125
|
+
//# sourceMappingURL=Radio.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Radio.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.js';\n\nimport radioStyles from './radio.css.js';\n\n/**\n * @element sp-radio\n *\n * @slot - text label of the Radio button\n * @attr label-below - Moves the label below the radio button\n * @attr invalid - Uses the invalid style\n * @attr disabled - Uses the disabled style\n * @attr checked - Represents when the input is checked\n * @attr value - Identifies this radio button within its radio group\n *\n * @fires change - When the input is interacted with and its state is changed\n */\nexport class Radio extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static override get styles(): CSSResultArray {\n return [radioStyles];\n }\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n @property({ type: String, reflect: true })\n public value = '';\n\n @property({ type: Boolean, reflect: true })\n public checked = false;\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property({ type: Boolean, reflect: true })\n public invalid = false;\n\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n this.activate();\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focus();\n }\n }\n\n protected activate(): void {\n if (this.checked) {\n return;\n }\n this.checked = true;\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n if (event.code === 'Space') {\n this.activate();\n }\n }\n\n protected override render(): TemplateResult {\n return html`\n <div id=\"input\"></div>\n <span id=\"button\"></span>\n <span id=\"label\" role=\"presentation\"><slot></slot></span>\n `;\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('role', 'radio');\n if (!this.hasAttribute('tabindex')) {\n this.tabIndex = 0;\n }\n this.manageAutoFocus();\n this.addEventListener('click', this.activate);\n this.addEventListener('keyup', this.handleKeyup);\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('invalid')) {\n if (this.invalid) {\n this.setAttribute('aria-invalid', 'true');\n } else {\n this.removeAttribute('aria-invalid');\n }\n }\n if (changes.has('checked')) {\n if (this.checked) {\n this.setAttribute('aria-checked', 'true');\n } else {\n this.setAttribute('aria-checked', 'false');\n }\n }\n if (changes.has('disabled')) {\n if (this.disabled) {\n this.setAttribute('aria-disabled', 'true');\n } else {\n this.removeAttribute('aria-disabeld');\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA;AAAA;AAAA;AAOA;AACA;AAEA;AAcO,aAAM,cAAc,0BAA0B,eAAe,EAAE;AAAA,EAA/D;AAAA;AAUa,qBAAY;AAGrB,iB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
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* @slot - text label of the Radio button
|
|
21
|
-
* @attr label-below - Moves the label below the radio button
|
|
22
|
-
* @attr invalid - Uses the invalid style
|
|
23
|
-
* @attr disabled - Uses the disabled style
|
|
24
|
-
* @attr checked - Represents when the input is checked
|
|
25
|
-
* @attr value - Identifies this radio button within its radio group
|
|
26
|
-
*
|
|
27
|
-
* @fires change - When the input is interacted with and its state is changed
|
|
28
|
-
*/
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html,
|
|
14
|
+
SpectrumElement
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
+
import { FocusVisiblePolyfillMixin } from "@spectrum-web-components/shared/src/focus-visible.js";
|
|
18
|
+
import radioStyles from "./radio.css.js";
|
|
29
19
|
export class Radio extends FocusVisiblePolyfillMixin(SpectrumElement) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.autofocus = false;
|
|
23
|
+
this.value = "";
|
|
24
|
+
this.checked = false;
|
|
25
|
+
this.disabled = false;
|
|
26
|
+
this.emphasized = false;
|
|
27
|
+
this.invalid = false;
|
|
28
|
+
this.readonly = false;
|
|
29
|
+
}
|
|
30
|
+
static get styles() {
|
|
31
|
+
return [radioStyles];
|
|
32
|
+
}
|
|
33
|
+
click() {
|
|
34
|
+
if (this.disabled) {
|
|
35
|
+
return;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
this.activate();
|
|
38
|
+
}
|
|
39
|
+
manageAutoFocus() {
|
|
40
|
+
if (this.autofocus) {
|
|
41
|
+
this.dispatchEvent(new KeyboardEvent("keydown", {
|
|
42
|
+
code: "Tab"
|
|
43
|
+
}));
|
|
44
|
+
this.focus();
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.activate();
|
|
46
|
+
}
|
|
47
|
+
activate() {
|
|
48
|
+
if (this.checked) {
|
|
49
|
+
return;
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}));
|
|
63
|
-
this.focus();
|
|
64
|
-
}
|
|
51
|
+
this.checked = true;
|
|
52
|
+
this.dispatchEvent(new Event("change", {
|
|
53
|
+
bubbles: true,
|
|
54
|
+
composed: true
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
handleKeyup(event) {
|
|
58
|
+
if (event.code === "Space") {
|
|
59
|
+
this.activate();
|
|
65
60
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
this.checked = true;
|
|
71
|
-
this.dispatchEvent(new Event('change', {
|
|
72
|
-
bubbles: true,
|
|
73
|
-
composed: true,
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
handleKeyup(event) {
|
|
77
|
-
if (event.code === 'Space') {
|
|
78
|
-
this.activate();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
render() {
|
|
82
|
-
return html `
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
return html`
|
|
83
64
|
<div id="input"></div>
|
|
84
65
|
<span id="button"></span>
|
|
85
66
|
<span id="label" role="presentation"><slot></slot></span>
|
|
86
67
|
`;
|
|
68
|
+
}
|
|
69
|
+
firstUpdated(changes) {
|
|
70
|
+
super.firstUpdated(changes);
|
|
71
|
+
this.setAttribute("role", "radio");
|
|
72
|
+
if (!this.hasAttribute("tabindex")) {
|
|
73
|
+
this.tabIndex = 0;
|
|
74
|
+
}
|
|
75
|
+
this.manageAutoFocus();
|
|
76
|
+
this.addEventListener("click", this.activate);
|
|
77
|
+
this.addEventListener("keyup", this.handleKeyup);
|
|
78
|
+
}
|
|
79
|
+
updated(changes) {
|
|
80
|
+
super.updated(changes);
|
|
81
|
+
if (changes.has("invalid")) {
|
|
82
|
+
if (this.invalid) {
|
|
83
|
+
this.setAttribute("aria-invalid", "true");
|
|
84
|
+
} else {
|
|
85
|
+
this.removeAttribute("aria-invalid");
|
|
86
|
+
}
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.setAttribute(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.manageAutoFocus();
|
|
95
|
-
this.addEventListener('click', this.activate);
|
|
96
|
-
this.addEventListener('keyup', this.handleKeyup);
|
|
88
|
+
if (changes.has("checked")) {
|
|
89
|
+
if (this.checked) {
|
|
90
|
+
this.setAttribute("aria-checked", "true");
|
|
91
|
+
} else {
|
|
92
|
+
this.setAttribute("aria-checked", "false");
|
|
93
|
+
}
|
|
97
94
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
else {
|
|
105
|
-
this.removeAttribute('aria-invalid');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (changes.has('checked')) {
|
|
109
|
-
if (this.checked) {
|
|
110
|
-
this.setAttribute('aria-checked', 'true');
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.setAttribute('aria-checked', 'false');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (changes.has('disabled')) {
|
|
117
|
-
if (this.disabled) {
|
|
118
|
-
this.setAttribute('aria-disabled', 'true');
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
this.removeAttribute('aria-disabeld');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
95
|
+
if (changes.has("disabled")) {
|
|
96
|
+
if (this.disabled) {
|
|
97
|
+
this.setAttribute("aria-disabled", "true");
|
|
98
|
+
} else {
|
|
99
|
+
this.removeAttribute("aria-disabeld");
|
|
100
|
+
}
|
|
124
101
|
}
|
|
102
|
+
}
|
|
125
103
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
], Radio.prototype, "autofocus",
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
], Radio.prototype, "value",
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
], Radio.prototype, "checked",
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
], Radio.prototype, "disabled",
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
], Radio.prototype, "emphasized",
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
], Radio.prototype, "invalid",
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
], Radio.prototype, "readonly",
|
|
147
|
-
//# sourceMappingURL=Radio.js.map
|
|
104
|
+
__decorateClass([
|
|
105
|
+
property({ type: Boolean })
|
|
106
|
+
], Radio.prototype, "autofocus", 2);
|
|
107
|
+
__decorateClass([
|
|
108
|
+
property({ type: String, reflect: true })
|
|
109
|
+
], Radio.prototype, "value", 2);
|
|
110
|
+
__decorateClass([
|
|
111
|
+
property({ type: Boolean, reflect: true })
|
|
112
|
+
], Radio.prototype, "checked", 2);
|
|
113
|
+
__decorateClass([
|
|
114
|
+
property({ type: Boolean, reflect: true })
|
|
115
|
+
], Radio.prototype, "disabled", 2);
|
|
116
|
+
__decorateClass([
|
|
117
|
+
property({ type: Boolean, reflect: true })
|
|
118
|
+
], Radio.prototype, "emphasized", 2);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
property({ type: Boolean, reflect: true })
|
|
121
|
+
], Radio.prototype, "invalid", 2);
|
|
122
|
+
__decorateClass([
|
|
123
|
+
property({ type: Boolean, reflect: true })
|
|
124
|
+
], Radio.prototype, "readonly", 2);
|
|
125
|
+
//# sourceMappingURL=Radio.js.map
|
package/src/Radio.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Radio.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.js';\n\nimport radioStyles from './radio.css.js';\n\n/**\n * @element sp-radio\n *\n * @slot - text label of the Radio button\n * @attr label-below - Moves the label below the radio button\n * @attr invalid - Uses the invalid style\n * @attr disabled - Uses the disabled style\n * @attr checked - Represents when the input is checked\n * @attr value - Identifies this radio button within its radio group\n *\n * @fires change - When the input is interacted with and its state is changed\n */\nexport class Radio extends FocusVisiblePolyfillMixin(SpectrumElement) {\n public static override get styles(): CSSResultArray {\n return [radioStyles];\n }\n\n /**\n * When this control is rendered, focus it automatically\n * @private\n */\n @property({ type: Boolean })\n public override autofocus = false;\n\n @property({ type: String, reflect: true })\n public value = '';\n\n @property({ type: Boolean, reflect: true })\n public checked = false;\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property({ type: Boolean, reflect: true })\n public invalid = false;\n\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n public override click(): void {\n if (this.disabled) {\n return;\n }\n this.activate();\n }\n\n protected manageAutoFocus(): void {\n if (this.autofocus) {\n /**\n * Trick :focus-visible polyfill into thinking keyboard based focus\n *\n * @private\n **/\n this.dispatchEvent(\n new KeyboardEvent('keydown', {\n code: 'Tab',\n })\n );\n this.focus();\n }\n }\n\n protected activate(): void {\n if (this.checked) {\n return;\n }\n this.checked = true;\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n if (event.code === 'Space') {\n this.activate();\n }\n }\n\n protected override render(): TemplateResult {\n return html`\n <div id=\"input\"></div>\n <span id=\"button\"></span>\n <span id=\"label\" role=\"presentation\"><slot></slot></span>\n `;\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('role', 'radio');\n if (!this.hasAttribute('tabindex')) {\n this.tabIndex = 0;\n }\n this.manageAutoFocus();\n this.addEventListener('click', this.activate);\n this.addEventListener('keyup', this.handleKeyup);\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n if (changes.has('invalid')) {\n if (this.invalid) {\n this.setAttribute('aria-invalid', 'true');\n } else {\n this.removeAttribute('aria-invalid');\n }\n }\n if (changes.has('checked')) {\n if (this.checked) {\n this.setAttribute('aria-checked', 'true');\n } else {\n this.setAttribute('aria-checked', 'false');\n }\n }\n if (changes.has('disabled')) {\n if (this.disabled) {\n this.setAttribute('aria-disabled', 'true');\n } else {\n this.removeAttribute('aria-dis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