@spectrum-web-components/action-button 0.9.0 → 0.9.1-devmode.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/package.json +23 -10
- package/sp-action-button.dev.js +3 -0
- package/sp-action-button.dev.js.map +7 -0
- package/sp-action-button.js +3 -14
- package/sp-action-button.js.map +7 -1
- package/src/ActionButton.dev.js +172 -0
- package/src/ActionButton.dev.js.map +7 -0
- package/src/ActionButton.js +152 -182
- package/src/ActionButton.js.map +7 -1
- package/src/action-button.css.dev.js +426 -0
- package/src/action-button.css.dev.js.map +7 -0
- package/src/action-button.css.js +3 -14
- package/src/action-button.css.js.map +7 -1
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -13
- package/src/index.js.map +7 -1
- package/src/spectrum-action-button.css.dev.js +394 -0
- package/src/spectrum-action-button.css.dev.js.map +7 -0
- package/src/spectrum-action-button.css.js +3 -14
- package/src/spectrum-action-button.css.js.map +7 -1
- package/stories/action-button-black-quiet.stories.js +19 -19
- package/stories/action-button-black-quiet.stories.js.map +7 -1
- package/stories/action-button-black.stories.js +15 -15
- package/stories/action-button-black.stories.js.map +7 -1
- package/stories/action-button-emphasized-quiet.stories.js +16 -16
- package/stories/action-button-emphasized-quiet.stories.js.map +7 -1
- package/stories/action-button-emphasized.stories.js +12 -12
- package/stories/action-button-emphasized.stories.js.map +7 -1
- package/stories/action-button-quiet.stories.js +12 -12
- package/stories/action-button-quiet.stories.js.map +7 -1
- package/stories/action-button-standard.stories.js +8 -8
- package/stories/action-button-standard.stories.js.map +7 -1
- package/stories/action-button-white-quiet.stories.js +19 -19
- package/stories/action-button-white-quiet.stories.js.map +7 -1
- package/stories/action-button-white.stories.js +15 -15
- package/stories/action-button-white.stories.js.map +7 -1
- package/stories/action-button.stories.js +19 -31
- package/stories/action-button.stories.js.map +7 -1
- package/stories/index.js +50 -39
- package/stories/index.js.map +7 -1
- package/test/action-button-black-quiet.test-vrt.js +4 -15
- package/test/action-button-black-quiet.test-vrt.js.map +7 -1
- package/test/action-button-black.test-vrt.js +4 -15
- package/test/action-button-black.test-vrt.js.map +7 -1
- package/test/action-button-emphasized-quiet.test-vrt.js +4 -15
- package/test/action-button-emphasized-quiet.test-vrt.js.map +7 -1
- package/test/action-button-emphasized.test-vrt.js +4 -15
- package/test/action-button-emphasized.test-vrt.js.map +7 -1
- package/test/action-button-quiet.test-vrt.js +4 -15
- package/test/action-button-quiet.test-vrt.js.map +7 -1
- package/test/action-button-standard.test-vrt.js +4 -15
- package/test/action-button-standard.test-vrt.js.map +7 -1
- package/test/action-button-white-quiet.test-vrt.js +4 -15
- package/test/action-button-white-quiet.test-vrt.js.map +7 -1
- package/test/action-button-white.test-vrt.js +4 -15
- package/test/action-button-white.test-vrt.js.map +7 -1
- package/test/action-button.test-vrt.js +4 -15
- package/test/action-button.test-vrt.js.map +7 -1
- package/test/action-button.test.js +105 -110
- package/test/action-button.test.js.map +7 -1
- package/test/benchmark/basic-test.js +5 -16
- package/test/benchmark/basic-test.js.map +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/action-button",
|
|
3
|
-
"version": "0.9.0",
|
|
3
|
+
"version": "0.9.1-devmode.0+07474d44f",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,11 +20,24 @@
|
|
|
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
|
+
"./src/ActionButton.js": {
|
|
29
|
+
"development": "./src/ActionButton.dev.js",
|
|
30
|
+
"default": "./src/ActionButton.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/action-button.css.js": "./src/action-button.css.js",
|
|
33
|
+
"./src/index.js": {
|
|
34
|
+
"development": "./src/index.dev.js",
|
|
35
|
+
"default": "./src/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./sp-action-button.js": {
|
|
38
|
+
"development": "./sp-action-button.dev.js",
|
|
39
|
+
"default": "./sp-action-button.js"
|
|
40
|
+
}
|
|
28
41
|
},
|
|
29
42
|
"scripts": {
|
|
30
43
|
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
|
@@ -44,10 +57,10 @@
|
|
|
44
57
|
"lit-html"
|
|
45
58
|
],
|
|
46
59
|
"dependencies": {
|
|
47
|
-
"@spectrum-web-components/base": "^0.5.
|
|
48
|
-
"@spectrum-web-components/button": "^0.18.0",
|
|
49
|
-
"@spectrum-web-components/icon": "^0.11.
|
|
50
|
-
"@spectrum-web-components/icons-ui": "^0.8.
|
|
60
|
+
"@spectrum-web-components/base": "^0.5.9-devmode.24+07474d44f",
|
|
61
|
+
"@spectrum-web-components/button": "^0.18.1-devmode.0+07474d44f",
|
|
62
|
+
"@spectrum-web-components/icon": "^0.11.12-devmode.0+07474d44f",
|
|
63
|
+
"@spectrum-web-components/icons-ui": "^0.8.12-devmode.0+07474d44f",
|
|
51
64
|
"tslib": "^2.0.0"
|
|
52
65
|
},
|
|
53
66
|
"devDependencies": {
|
|
@@ -58,5 +71,5 @@
|
|
|
58
71
|
"sideEffects": [
|
|
59
72
|
"./sp-*.js"
|
|
60
73
|
],
|
|
61
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "07474d44f6cee1db241b9ccf3dc812514ffbe7fa"
|
|
62
75
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-action-button.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 { ActionButton } from './src/ActionButton.dev.js'\n\ncustomElements.define('sp-action-button', ActionButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-action-button': ActionButton;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAYA;AAEA,eAAe,OAAO,oBAAoB,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-action-button.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 { ActionButton } from './src/ActionButton.js';
|
|
13
|
-
customElements.define('sp-action-button', ActionButton);
|
|
14
|
-
//# sourceMappingURL=sp-action-button.js.map
|
|
1
|
+
import { ActionButton } from "./src/ActionButton.js";
|
|
2
|
+
customElements.define("sp-action-button", ActionButton);
|
|
3
|
+
//# sourceMappingURL=sp-action-button.js.map
|
package/sp-action-button.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-action-button.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 { ActionButton } from './src/ActionButton.js';\n\ncustomElements.define('sp-action-button', ActionButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-action-button': ActionButton;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAYA;AAEA,eAAe,OAAO,oBAAoB,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
SizedMixin
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
+
import { ButtonBase } from "@spectrum-web-components/button";
|
|
18
|
+
import buttonStyles from "./action-button.css.js";
|
|
19
|
+
import cornerTriangleStyles from "@spectrum-web-components/icon/src/spectrum-icon-corner-triangle.css.js";
|
|
20
|
+
import "@spectrum-web-components/icons-ui/icons/sp-icon-corner-triangle300.js";
|
|
21
|
+
const holdAffordanceClass = {
|
|
22
|
+
s: "spectrum-UIIcon-CornerTriangle75",
|
|
23
|
+
m: "spectrum-UIIcon-CornerTriangle100",
|
|
24
|
+
l: "spectrum-UIIcon-CornerTriangle200",
|
|
25
|
+
xl: "spectrum-UIIcon-CornerTriangle300"
|
|
26
|
+
};
|
|
27
|
+
const LONGPRESS_DURATION = 300;
|
|
28
|
+
let LONGPRESS_TIMEOUT;
|
|
29
|
+
export class ActionButton extends SizedMixin(ButtonBase) {
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.emphasized = false;
|
|
33
|
+
this.holdAffordance = false;
|
|
34
|
+
this.quiet = false;
|
|
35
|
+
this.role = "button";
|
|
36
|
+
this.selected = false;
|
|
37
|
+
this.toggles = false;
|
|
38
|
+
this._value = "";
|
|
39
|
+
this.onClick = () => {
|
|
40
|
+
if (!this.toggles) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.selected = !this.selected;
|
|
44
|
+
const applyDefault = this.dispatchEvent(new Event("change", {
|
|
45
|
+
cancelable: true
|
|
46
|
+
}));
|
|
47
|
+
if (!applyDefault) {
|
|
48
|
+
this.selected = !this.selected;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
this.addEventListener("click", this.onClick);
|
|
52
|
+
this.addEventListener("pointerdown", this.onPointerdown);
|
|
53
|
+
}
|
|
54
|
+
static get styles() {
|
|
55
|
+
return [buttonStyles, cornerTriangleStyles];
|
|
56
|
+
}
|
|
57
|
+
get value() {
|
|
58
|
+
return this._value || this.itemText;
|
|
59
|
+
}
|
|
60
|
+
set value(value) {
|
|
61
|
+
if (value === this._value) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._value = value || "";
|
|
65
|
+
if (this._value) {
|
|
66
|
+
this.setAttribute("value", this._value);
|
|
67
|
+
} else {
|
|
68
|
+
this.removeAttribute("value");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
get itemText() {
|
|
72
|
+
return (this.textContent || "").trim();
|
|
73
|
+
}
|
|
74
|
+
onPointerdown() {
|
|
75
|
+
this.addEventListener("pointerup", this.onPointerup);
|
|
76
|
+
this.addEventListener("pointercancel", this.onPointerup);
|
|
77
|
+
LONGPRESS_TIMEOUT = setTimeout(() => {
|
|
78
|
+
this.dispatchEvent(new CustomEvent("longpress", {
|
|
79
|
+
bubbles: true,
|
|
80
|
+
composed: true,
|
|
81
|
+
detail: {
|
|
82
|
+
source: "pointer"
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
}, LONGPRESS_DURATION);
|
|
86
|
+
}
|
|
87
|
+
onPointerup() {
|
|
88
|
+
clearTimeout(LONGPRESS_TIMEOUT);
|
|
89
|
+
this.removeEventListener("pointerup", this.onPointerup);
|
|
90
|
+
this.removeEventListener("pointercancel", this.onPointerup);
|
|
91
|
+
}
|
|
92
|
+
handleKeydown(event) {
|
|
93
|
+
if (!this.holdAffordance) {
|
|
94
|
+
return super.handleKeydown(event);
|
|
95
|
+
}
|
|
96
|
+
const { code, altKey } = event;
|
|
97
|
+
if (code === "Space" || altKey && code === "ArrowDown") {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
if (code === "ArrowDown") {
|
|
100
|
+
event.stopPropagation();
|
|
101
|
+
event.stopImmediatePropagation();
|
|
102
|
+
}
|
|
103
|
+
this.addEventListener("keyup", this.handleKeyup);
|
|
104
|
+
this.active = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
handleKeyup(event) {
|
|
108
|
+
if (!this.holdAffordance) {
|
|
109
|
+
return super.handleKeyup(event);
|
|
110
|
+
}
|
|
111
|
+
const { code, altKey } = event;
|
|
112
|
+
if (code === "Space" || altKey && code === "ArrowDown") {
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
this.dispatchEvent(new CustomEvent("longpress", {
|
|
115
|
+
bubbles: true,
|
|
116
|
+
composed: true,
|
|
117
|
+
detail: {
|
|
118
|
+
source: "keyboard"
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
this.active = false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
get buttonContent() {
|
|
125
|
+
const buttonContent = super.buttonContent;
|
|
126
|
+
if (this.holdAffordance) {
|
|
127
|
+
buttonContent.unshift(html`
|
|
128
|
+
<sp-icon-corner-triangle300
|
|
129
|
+
class="hold-affordance ${holdAffordanceClass[this.size]}"
|
|
130
|
+
></sp-icon-corner-triangle300>
|
|
131
|
+
`);
|
|
132
|
+
}
|
|
133
|
+
return buttonContent;
|
|
134
|
+
}
|
|
135
|
+
updated(changes) {
|
|
136
|
+
super.updated(changes);
|
|
137
|
+
const isButton = this.role === "button";
|
|
138
|
+
const canBePressed = isButton && (this.selected || this.toggles);
|
|
139
|
+
if (changes.has("selected") || changes.has("role")) {
|
|
140
|
+
if (canBePressed) {
|
|
141
|
+
this.setAttribute("aria-pressed", this.selected ? "true" : "false");
|
|
142
|
+
} else {
|
|
143
|
+
this.removeAttribute("aria-pressed");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
__decorateClass([
|
|
149
|
+
property({ type: Boolean, reflect: true })
|
|
150
|
+
], ActionButton.prototype, "emphasized", 2);
|
|
151
|
+
__decorateClass([
|
|
152
|
+
property({ type: Boolean, reflect: true, attribute: "hold-affordance" })
|
|
153
|
+
], ActionButton.prototype, "holdAffordance", 2);
|
|
154
|
+
__decorateClass([
|
|
155
|
+
property({ type: Boolean, reflect: true })
|
|
156
|
+
], ActionButton.prototype, "quiet", 2);
|
|
157
|
+
__decorateClass([
|
|
158
|
+
property({ reflect: true })
|
|
159
|
+
], ActionButton.prototype, "role", 2);
|
|
160
|
+
__decorateClass([
|
|
161
|
+
property({ type: Boolean, reflect: true })
|
|
162
|
+
], ActionButton.prototype, "selected", 2);
|
|
163
|
+
__decorateClass([
|
|
164
|
+
property({ type: Boolean, reflect: true })
|
|
165
|
+
], ActionButton.prototype, "toggles", 2);
|
|
166
|
+
__decorateClass([
|
|
167
|
+
property({ reflect: true })
|
|
168
|
+
], ActionButton.prototype, "variant", 2);
|
|
169
|
+
__decorateClass([
|
|
170
|
+
property({ type: String })
|
|
171
|
+
], ActionButton.prototype, "value", 1);
|
|
172
|
+
//# sourceMappingURL=ActionButton.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["ActionButton.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 DefaultElementSize,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { ButtonBase } from '@spectrum-web-components/button';\nimport buttonStyles from './action-button.css.js';\nimport cornerTriangleStyles from '@spectrum-web-components/icon/src/spectrum-icon-corner-triangle.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-corner-triangle300.js';\n\nconst holdAffordanceClass = {\n s: 'spectrum-UIIcon-CornerTriangle75',\n m: 'spectrum-UIIcon-CornerTriangle100',\n l: 'spectrum-UIIcon-CornerTriangle200',\n xl: 'spectrum-UIIcon-CornerTriangle300',\n};\n\nconst LONGPRESS_DURATION = 300;\nlet LONGPRESS_TIMEOUT: ReturnType<typeof setTimeout>;\n\nexport type LongpressEvent = {\n source: 'pointer' | 'keyboard';\n};\n\n/**\n * @element sp-action-button\n *\n * @slot - text label of the Action Button\n * @slot icon - The icon to use for Action Button\n * @fires change - Announces a change in the `selected` property of an action button\n * @fires longpress - Synthesizes a \"longpress\" interaction that signifies a\n * `pointerdown` event that is >=300ms or a keyboard event wher code is `Space` or code is `ArrowDown`\n * while `altKey===true`.\n */\nexport class ActionButton extends SizedMixin(ButtonBase) {\n public static override get styles(): CSSResultArray {\n return [buttonStyles, cornerTriangleStyles];\n }\n\n @property({ type: Boolean, reflect: true })\n public emphasized = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'hold-affordance' })\n public holdAffordance = false;\n\n @property({ type: Boolean, reflect: true })\n public quiet = false;\n\n @property({ reflect: true })\n public role = 'button';\n\n /**\n * Whether an Action Button with `role='button'`\n * should also be `aria-pressed='true'`\n */\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n /**\n * Whether to automatically manage the `selected`\n * attribute on interaction and whether `aria-pressed=\"false\"`\n * should be used when `selected === false`\n */\n @property({ type: Boolean, reflect: true })\n public toggles = false;\n\n @property({ reflect: true })\n public variant?: 'white' | 'black';\n\n @property({ type: String })\n public get value(): string {\n return this._value || this.itemText;\n }\n public set value(value: string) {\n if (value === this._value) {\n return;\n }\n this._value = value || '';\n if (this._value) {\n this.setAttribute('value', this._value);\n } else {\n this.removeAttribute('value');\n }\n }\n private _value = '';\n\n /**\n * @private\n */\n public get itemText(): string {\n return (this.textContent || /* c8 ignore next */ '').trim();\n }\n\n constructor() {\n super();\n this.addEventListener('click', this.onClick);\n this.addEventListener('pointerdown', this.onPointerdown);\n }\n\n private onClick = (): void => {\n if (!this.toggles) {\n return;\n }\n this.selected = !this.selected;\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.selected = !this.selected;\n }\n };\n\n private onPointerdown(): void {\n this.addEventListener('pointerup', this.onPointerup);\n this.addEventListener('pointercancel', this.onPointerup);\n LONGPRESS_TIMEOUT = setTimeout(() => {\n this.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'pointer',\n },\n })\n );\n }, LONGPRESS_DURATION);\n }\n\n private onPointerup(): void {\n clearTimeout(LONGPRESS_TIMEOUT);\n this.removeEventListener('pointerup', this.onPointerup);\n this.removeEventListener('pointercancel', this.onPointerup);\n }\n\n /**\n * @private\n */\n protected override handleKeydown(event: KeyboardEvent): void {\n if (!this.holdAffordance) {\n return super.handleKeydown(event);\n }\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n event.preventDefault();\n if (code === 'ArrowDown') {\n event.stopPropagation();\n event.stopImmediatePropagation();\n }\n this.addEventListener('keyup', this.handleKeyup);\n this.active = true;\n }\n }\n\n protected override handleKeyup(event: KeyboardEvent): void {\n if (!this.holdAffordance) {\n return super.handleKeyup(event);\n }\n const { code, altKey } = event;\n if (code === 'Space' || (altKey && code === 'ArrowDown')) {\n event.stopPropagation();\n this.dispatchEvent(\n new CustomEvent<LongpressEvent>('longpress', {\n bubbles: true,\n composed: true,\n detail: {\n source: 'keyboard',\n },\n })\n );\n this.active = false;\n }\n }\n\n protected override get buttonContent(): TemplateResult[] {\n const buttonContent = super.buttonContent;\n if (this.holdAffordance) {\n buttonContent.unshift(html`\n <sp-icon-corner-triangle300\n class=\"hold-affordance ${holdAffordanceClass[\n this.size as DefaultElementSize\n ]}\"\n ></sp-icon-corner-triangle300>\n `);\n }\n return buttonContent;\n }\n\n protected override updated(changes: PropertyValues): void {\n super.updated(changes);\n const isButton = this.role === 'button';\n const canBePressed = isButton && (this.selected || this.toggles);\n if (changes.has('selected') || changes.has('role')) {\n // When role !== 'button' then the Action Button is within\n // an Action Group that manages selects which means the\n // Action Button is a \"checkbox\" or \"radio\" and cannot\n // accept the `aria-pressed` attribute.\n if (canBePressed) {\n this.setAttribute(\n 'aria-pressed',\n this.selected ? 'true' : 'false'\n );\n } else {\n // When !this.toggles the lack of \"aria-pressed\" is inconsequential.\n this.removeAttribute('aria-pressed');\n }\n }\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n longpress: CustomEvent<LongpressEvent>;\n }\n}\n"],
|
|
5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