@spectrum-web-components/shared 0.0.0-20241209155954
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/README.md +132 -0
- package/package.json +112 -0
- package/src/first-focusable-in.d.ts +3 -0
- package/src/first-focusable-in.dev.js +15 -0
- package/src/first-focusable-in.dev.js.map +7 -0
- package/src/first-focusable-in.js +2 -0
- package/src/first-focusable-in.js.map +7 -0
- package/src/focus-visible.d.ts +29 -0
- package/src/focus-visible.dev.js +77 -0
- package/src/focus-visible.dev.js.map +7 -0
- package/src/focus-visible.js +2 -0
- package/src/focus-visible.js.map +7 -0
- package/src/focusable-selectors.d.ts +2 -0
- package/src/focusable-selectors.dev.js +15 -0
- package/src/focusable-selectors.dev.js.map +7 -0
- package/src/focusable-selectors.js +2 -0
- package/src/focusable-selectors.js.map +7 -0
- package/src/focusable.d.ts +56 -0
- package/src/focusable.dev.js +245 -0
- package/src/focusable.dev.js.map +7 -0
- package/src/focusable.js +2 -0
- package/src/focusable.js.map +7 -0
- package/src/get-active-element.d.ts +1 -0
- package/src/get-active-element.dev.js +5 -0
- package/src/get-active-element.dev.js.map +7 -0
- package/src/get-active-element.js +2 -0
- package/src/get-active-element.js.map +7 -0
- package/src/get-deep-element-from-point.d.ts +1 -0
- package/src/get-deep-element-from-point.dev.js +13 -0
- package/src/get-deep-element-from-point.dev.js.map +7 -0
- package/src/get-deep-element-from-point.js +2 -0
- package/src/get-deep-element-from-point.js.map +7 -0
- package/src/get-label-from-slot.d.ts +1 -0
- package/src/get-label-from-slot.dev.js +17 -0
- package/src/get-label-from-slot.dev.js.map +7 -0
- package/src/get-label-from-slot.js +2 -0
- package/src/get-label-from-slot.js.map +7 -0
- package/src/index.d.ts +12 -0
- package/src/index.dev.js +14 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -0
- package/src/index.js.map +7 -0
- package/src/like-anchor.d.ts +23 -0
- package/src/like-anchor.dev.js +63 -0
- package/src/like-anchor.dev.js.map +7 -0
- package/src/like-anchor.js +14 -0
- package/src/like-anchor.js.map +7 -0
- package/src/observe-slot-presence.d.ts +12 -0
- package/src/observe-slot-presence.dev.js +63 -0
- package/src/observe-slot-presence.dev.js.map +7 -0
- package/src/observe-slot-presence.js +2 -0
- package/src/observe-slot-presence.js.map +7 -0
- package/src/observe-slot-text.d.ts +11 -0
- package/src/observe-slot-text.dev.js +95 -0
- package/src/observe-slot-text.dev.js.map +7 -0
- package/src/observe-slot-text.js +2 -0
- package/src/observe-slot-text.js.map +7 -0
- package/src/platform.d.ts +10 -0
- package/src/platform.dev.js +39 -0
- package/src/platform.dev.js.map +7 -0
- package/src/platform.js +2 -0
- package/src/platform.js.map +7 -0
- package/src/random-id.d.ts +1 -0
- package/src/random-id.dev.js +8 -0
- package/src/random-id.dev.js.map +7 -0
- package/src/random-id.js +2 -0
- package/src/random-id.js.map +7 -0
- package/src/reparent-children.d.ts +4 -0
- package/src/reparent-children.dev.js +57 -0
- package/src/reparent-children.dev.js.map +7 -0
- package/src/reparent-children.js +2 -0
- package/src/reparent-children.js.map +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
Shared mixins, tools, etc. that support developing Spectrum Web Components.
|
|
4
|
+
|
|
5
|
+
### Usage
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@spectrum-web-components/shared)
|
|
8
|
+
[](https://bundlephobia.com/result?p=@spectrum-web-components/shared)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @spectrum-web-components/shared
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Individual base classes and mixins can be imported as follows:
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
import {
|
|
18
|
+
Focusable,
|
|
19
|
+
FocusVisiblePolyfillMixin,
|
|
20
|
+
getActiveElement,
|
|
21
|
+
LikeAnchor,
|
|
22
|
+
ObserveSlotText,
|
|
23
|
+
} from '@spectrum-web-components/shared';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### getDeepElementFromPoint
|
|
27
|
+
|
|
28
|
+
The `getDeepElementFromPoint` method allows you to obtain the deepest possible element at a given coordinates on the current page. The method will step into any available `shadowRoot`s until it reaches the first element with no `shadowRoot` or no children available at the given coordinates.
|
|
29
|
+
|
|
30
|
+
### Focusable
|
|
31
|
+
|
|
32
|
+
The `Focusable` subclass of `LitElement` adds some helpers method and lifecycle coverage in order to support passing focus to a container element inside of a custom element. The Focusable base class handles tabindex setting into shadowed elements automatically and is based heavily on the [aybolit delegate-focus-mixin](https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js).
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { Focusable } from '@spectrum-web-components/shared';
|
|
36
|
+
import { html } from 'lit-element';
|
|
37
|
+
|
|
38
|
+
class FocusableButton extends Focusable {
|
|
39
|
+
public static override get styles(): CSSResultArray {
|
|
40
|
+
return [...super.styles];
|
|
41
|
+
}
|
|
42
|
+
public get focusElement(): HTMLElement {
|
|
43
|
+
return this.shadowRoot.querySelector('#button') as HTMLElement;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected override render(): TemplateResult {
|
|
47
|
+
return html`
|
|
48
|
+
<button
|
|
49
|
+
id="button"
|
|
50
|
+
>
|
|
51
|
+
Focus for this button is being managed by the focusable base class.
|
|
52
|
+
</button>
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### FocusVisiblePolyfillMixin
|
|
59
|
+
|
|
60
|
+
Use this mixin if you would like to leverage `:focus-visible` based selectors in your CSS. [Learn more about the polyfill that powers this.](https://www.npmjs.com/package/focus-visible)
|
|
61
|
+
|
|
62
|
+
### getActiveElement
|
|
63
|
+
|
|
64
|
+
Use this helper to find an `activeElement` in your component. [Learn more about tracking active elements over shadow DOM boundaries.](https://dev.to/open-wc/mind-the-document-activeelement-2o9a)
|
|
65
|
+
|
|
66
|
+
### LikeAnchor
|
|
67
|
+
|
|
68
|
+
Mix `download`, `label`, `href`, and `target` properties into your element to allow it to act more like an `HTMLAnchorElement`.
|
|
69
|
+
|
|
70
|
+
### ObserveSlotPresence
|
|
71
|
+
|
|
72
|
+
When working with styles that are driven by the conditional presence of `<slot>`s in a component's shadow DOM, you will need to track whether light DOM that is meant for that slot exists. Use the `ObserveSlotPresence` mixin to target specific light DOM to observe the presence of and trigger `this.requestUpdate()` calls when content fulfilling that selector comes in and out of availability.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import { ObserveSlotPresence } from '@spectrum-web-components/shared';
|
|
76
|
+
import { LitElement, html } from 'lit-element';
|
|
77
|
+
class ObserveSlotPresenceElement extends ObserveSlotPresence(LitElement, '[slot="conditional-slot"]') {
|
|
78
|
+
// translate the mixin properties into locally understandable language
|
|
79
|
+
protected get hasConditionalSlotContent() {
|
|
80
|
+
return this.slotContentIsPresent;
|
|
81
|
+
}
|
|
82
|
+
protected override render(): TemplateResult {
|
|
83
|
+
return html`
|
|
84
|
+
<button
|
|
85
|
+
id="button"
|
|
86
|
+
>
|
|
87
|
+
${this.hasConditionalSlotContent
|
|
88
|
+
? html`
|
|
89
|
+
<slot
|
|
90
|
+
name="conditional-slot"
|
|
91
|
+
></slot>
|
|
92
|
+
`
|
|
93
|
+
: html``
|
|
94
|
+
}
|
|
95
|
+
</button>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
protected updated(): void {
|
|
99
|
+
console.log(this.slotContentIsPresent); // => true when <observing-slot-presence-element><div slot="conditional-slot"></div></observing-slot-presence-element>
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
customElements.define('observing-slot-presence-element', ObserveSlotPresenceElement);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### ObserveSlotText
|
|
106
|
+
|
|
107
|
+
When working with `<slot>`s and their `slotchange` event, you will have the opportunity to capture when the nodes and/or elements in your element are added or removed. However, if the `textContent` of a text node changes, you will not receive the `slotchange` event because the slot hasn't actually received new nodes and/or elements in the exchange. When working with a lit-html binding `<your-element>${text}</your-element>` that means you will not receive a `slotchange` event when the value of `text` goes from `text = ''` to `text = 'something'` or the other way. In these cases the `ObserveSlotText` can be leverages to apply a mutation observe onto your element that tracks `characterData` mutations so that you can resspond as desired.
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
import { ObserveSlotText } from '@spectrum-web-components/shared';
|
|
111
|
+
import { LitElement, html } from 'lit-element';
|
|
112
|
+
|
|
113
|
+
class ObserveSlotTextElement extends ObserveSlotText(LitElement, '#observing-slot') {
|
|
114
|
+
protected override render(): TemplateResult {
|
|
115
|
+
return html`
|
|
116
|
+
<button
|
|
117
|
+
id="button"
|
|
118
|
+
>
|
|
119
|
+
<slot
|
|
120
|
+
id="observing-slot"
|
|
121
|
+
@slotchange=${this.manageObservedSlot}
|
|
122
|
+
></slot>
|
|
123
|
+
</button>
|
|
124
|
+
`;
|
|
125
|
+
}
|
|
126
|
+
protected updated(): void {
|
|
127
|
+
console.log(this.slotHasContent); // => true when <observing-slot-text-element>Text</observing-slot-text-element>
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
customElements.define('observing-slot-text-element', ObserveSlotTextElement);
|
|
132
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spectrum-web-components/shared",
|
|
3
|
+
"version": "0.0.0-20241209155954",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/adobe/spectrum-web-components.git",
|
|
12
|
+
"directory": "tools/shared"
|
|
13
|
+
},
|
|
14
|
+
"author": "",
|
|
15
|
+
"homepage": "https://opensource.adobe.com/spectrum-web-components/tools/shared",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/adobe/spectrum-web-components/issues"
|
|
18
|
+
},
|
|
19
|
+
"main": "./src/index.js",
|
|
20
|
+
"module": "./src/index.js",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"development": "./src/index.dev.js",
|
|
25
|
+
"default": "./src/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json",
|
|
28
|
+
"./src/first-focusable-in.js": {
|
|
29
|
+
"development": "./src/first-focusable-in.dev.js",
|
|
30
|
+
"default": "./src/first-focusable-in.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/focus-visible.js": {
|
|
33
|
+
"development": "./src/focus-visible.dev.js",
|
|
34
|
+
"default": "./src/focus-visible.js"
|
|
35
|
+
},
|
|
36
|
+
"./src/focusable-selectors.js": {
|
|
37
|
+
"development": "./src/focusable-selectors.dev.js",
|
|
38
|
+
"default": "./src/focusable-selectors.js"
|
|
39
|
+
},
|
|
40
|
+
"./src/focusable.js": {
|
|
41
|
+
"development": "./src/focusable.dev.js",
|
|
42
|
+
"default": "./src/focusable.js"
|
|
43
|
+
},
|
|
44
|
+
"./src/get-active-element.js": {
|
|
45
|
+
"development": "./src/get-active-element.dev.js",
|
|
46
|
+
"default": "./src/get-active-element.js"
|
|
47
|
+
},
|
|
48
|
+
"./src/get-deep-element-from-point.js": {
|
|
49
|
+
"development": "./src/get-deep-element-from-point.dev.js",
|
|
50
|
+
"default": "./src/get-deep-element-from-point.js"
|
|
51
|
+
},
|
|
52
|
+
"./src/get-label-from-slot.js": {
|
|
53
|
+
"development": "./src/get-label-from-slot.dev.js",
|
|
54
|
+
"default": "./src/get-label-from-slot.js"
|
|
55
|
+
},
|
|
56
|
+
"./src/index.js": {
|
|
57
|
+
"development": "./src/index.dev.js",
|
|
58
|
+
"default": "./src/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./src/like-anchor.js": {
|
|
61
|
+
"development": "./src/like-anchor.dev.js",
|
|
62
|
+
"default": "./src/like-anchor.js"
|
|
63
|
+
},
|
|
64
|
+
"./src/observe-slot-presence.js": {
|
|
65
|
+
"development": "./src/observe-slot-presence.dev.js",
|
|
66
|
+
"default": "./src/observe-slot-presence.js"
|
|
67
|
+
},
|
|
68
|
+
"./src/observe-slot-text.js": {
|
|
69
|
+
"development": "./src/observe-slot-text.dev.js",
|
|
70
|
+
"default": "./src/observe-slot-text.js"
|
|
71
|
+
},
|
|
72
|
+
"./src/platform.js": {
|
|
73
|
+
"development": "./src/platform.dev.js",
|
|
74
|
+
"default": "./src/platform.js"
|
|
75
|
+
},
|
|
76
|
+
"./src/random-id.js": {
|
|
77
|
+
"development": "./src/random-id.dev.js",
|
|
78
|
+
"default": "./src/random-id.js"
|
|
79
|
+
},
|
|
80
|
+
"./src/reparent-children.js": {
|
|
81
|
+
"development": "./src/reparent-children.dev.js",
|
|
82
|
+
"default": "./src/reparent-children.js"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
|
87
|
+
},
|
|
88
|
+
"files": [
|
|
89
|
+
"**/*.d.ts",
|
|
90
|
+
"**/*.js",
|
|
91
|
+
"**/*.js.map",
|
|
92
|
+
"custom-elements.json",
|
|
93
|
+
"!stories/",
|
|
94
|
+
"!test/"
|
|
95
|
+
],
|
|
96
|
+
"keywords": [
|
|
97
|
+
"spectrum css",
|
|
98
|
+
"web components",
|
|
99
|
+
"lit-element",
|
|
100
|
+
"lit-html"
|
|
101
|
+
],
|
|
102
|
+
"dependencies": {
|
|
103
|
+
"@lit-labs/observers": "^2.0.2",
|
|
104
|
+
"@spectrum-web-components/base": "0.0.0-20241209155954",
|
|
105
|
+
"focus-visible": "^5.1.0"
|
|
106
|
+
},
|
|
107
|
+
"types": "./src/index.d.ts",
|
|
108
|
+
"customElements": "custom-elements.json",
|
|
109
|
+
"sideEffects": [
|
|
110
|
+
"./**/*.dev.js"
|
|
111
|
+
]
|
|
112
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { userFocusableSelector } from "./focusable-selectors.dev.js";
|
|
3
|
+
export const firstFocusableIn = (root) => {
|
|
4
|
+
const firstFocusable = root.querySelector(
|
|
5
|
+
userFocusableSelector
|
|
6
|
+
);
|
|
7
|
+
return firstFocusable;
|
|
8
|
+
};
|
|
9
|
+
export const firstFocusableSlottedIn = (root) => {
|
|
10
|
+
const firstFocusable = root.assignedElements().find(
|
|
11
|
+
(element) => element.matches(userFocusableSelector)
|
|
12
|
+
);
|
|
13
|
+
return firstFocusable;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=first-focusable-in.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["first-focusable-in.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 type { SpectrumElement } from '@spectrum-web-components/base';\nimport { userFocusableSelector } from './focusable-selectors.dev.js'\n\nexport const firstFocusableIn = (\n root: HTMLElement | ShadowRoot\n): SpectrumElement | null => {\n const firstFocusable = root.querySelector(\n userFocusableSelector\n ) as SpectrumElement;\n return firstFocusable;\n};\n\nexport const firstFocusableSlottedIn = (\n root: HTMLSlotElement\n): SpectrumElement | null => {\n const firstFocusable = root\n .assignedElements()\n .find((element) =>\n element.matches(userFocusableSelector)\n ) as SpectrumElement;\n return firstFocusable;\n};\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,6BAA6B;AAE/B,aAAM,mBAAmB,CAC5B,SACyB;AACzB,QAAM,iBAAiB,KAAK;AAAA,IACxB;AAAA,EACJ;AACA,SAAO;AACX;AAEO,aAAM,0BAA0B,CACnC,SACyB;AACzB,QAAM,iBAAiB,KAClB,iBAAiB,EACjB;AAAA,IAAK,CAAC,YACH,QAAQ,QAAQ,qBAAqB;AAAA,EACzC;AACJ,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["first-focusable-in.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 type { SpectrumElement } from '@spectrum-web-components/base';\nimport { userFocusableSelector } from './focusable-selectors.js';\n\nexport const firstFocusableIn = (\n root: HTMLElement | ShadowRoot\n): SpectrumElement | null => {\n const firstFocusable = root.querySelector(\n userFocusableSelector\n ) as SpectrumElement;\n return firstFocusable;\n};\n\nexport const firstFocusableSlottedIn = (\n root: HTMLSlotElement\n): SpectrumElement | null => {\n const firstFocusable = root\n .assignedElements()\n .find((element) =>\n element.matches(userFocusableSelector)\n ) as SpectrumElement;\n return firstFocusable;\n};\n"],
|
|
5
|
+
"mappings": "aAaA,OAAS,yBAAAA,MAA6B,2BAE/B,aAAM,iBACTC,GAEuBA,EAAK,cACxBD,CACJ,EAIS,wBACTC,GAEuBA,EAClB,iBAAiB,EACjB,KAAMC,GACHA,EAAQ,QAAQF,CAAqB,CACzC",
|
|
6
|
+
"names": ["userFocusableSelector", "root", "element"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
type Constructor<T = Record<string, unknown>> = {
|
|
7
|
+
new (...args: any[]): T;
|
|
8
|
+
prototype: T;
|
|
9
|
+
};
|
|
10
|
+
interface OptionalLifecycleCallbacks {
|
|
11
|
+
connectedCallback?(): void;
|
|
12
|
+
disconnectedCallback?(): void;
|
|
13
|
+
manageAutoFocus?(): void;
|
|
14
|
+
}
|
|
15
|
+
type MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;
|
|
16
|
+
/**
|
|
17
|
+
* This mixin function is designed to be applied to a class that inherits
|
|
18
|
+
* from HTMLElement. It makes it easy for a custom element to coordinate with
|
|
19
|
+
* the :focus-visible polyfill.
|
|
20
|
+
*
|
|
21
|
+
* NOTE(cdata): The code here was adapted from an example proposed with the
|
|
22
|
+
* introduction of ShadowDOM support in the :focus-visible polyfill.
|
|
23
|
+
*
|
|
24
|
+
* @see https://github.com/WICG/focus-visible/pull/196
|
|
25
|
+
* @param {Function} SuperClass The base class implementation to decorate with
|
|
26
|
+
* implementation that coordinates with the :focus-visible polyfill
|
|
27
|
+
*/
|
|
28
|
+
export declare const FocusVisiblePolyfillMixin: <T extends Constructor<MixableBaseClass>>(SuperClass: T) => T;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
let hasFocusVisible = true;
|
|
3
|
+
try {
|
|
4
|
+
document.body.querySelector(":focus-visible");
|
|
5
|
+
} catch (error) {
|
|
6
|
+
hasFocusVisible = false;
|
|
7
|
+
import("focus-visible");
|
|
8
|
+
}
|
|
9
|
+
export const FocusVisiblePolyfillMixin = (SuperClass) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const coordinateWithPolyfill = (instance) => {
|
|
12
|
+
if (instance.shadowRoot == null || instance.hasAttribute("data-js-focus-visible")) {
|
|
13
|
+
return () => {
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (self.applyFocusVisiblePolyfill) {
|
|
17
|
+
self.applyFocusVisiblePolyfill(instance.shadowRoot);
|
|
18
|
+
if (instance.manageAutoFocus) {
|
|
19
|
+
instance.manageAutoFocus();
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
const coordinationHandler = () => {
|
|
23
|
+
if (self.applyFocusVisiblePolyfill && instance.shadowRoot) {
|
|
24
|
+
self.applyFocusVisiblePolyfill(instance.shadowRoot);
|
|
25
|
+
}
|
|
26
|
+
if (instance.manageAutoFocus) {
|
|
27
|
+
instance.manageAutoFocus();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
self.addEventListener(
|
|
31
|
+
"focus-visible-polyfill-ready",
|
|
32
|
+
coordinationHandler,
|
|
33
|
+
{ once: true }
|
|
34
|
+
);
|
|
35
|
+
return () => {
|
|
36
|
+
self.removeEventListener(
|
|
37
|
+
"focus-visible-polyfill-ready",
|
|
38
|
+
coordinationHandler
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return () => {
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const $endPolyfillCoordination = Symbol("endPolyfillCoordination");
|
|
46
|
+
class FocusVisibleCoordinator extends (_b = SuperClass, _a = $endPolyfillCoordination, _b) {
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments);
|
|
49
|
+
this[_a] = null;
|
|
50
|
+
}
|
|
51
|
+
// Attempt to coordinate with the polyfill when connected to the
|
|
52
|
+
// document:
|
|
53
|
+
connectedCallback() {
|
|
54
|
+
super.connectedCallback && super.connectedCallback();
|
|
55
|
+
if (!hasFocusVisible) {
|
|
56
|
+
requestAnimationFrame(() => {
|
|
57
|
+
if (this[$endPolyfillCoordination] == null) {
|
|
58
|
+
this[$endPolyfillCoordination] = coordinateWithPolyfill(this);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
disconnectedCallback() {
|
|
64
|
+
super.disconnectedCallback && super.disconnectedCallback();
|
|
65
|
+
if (!hasFocusVisible) {
|
|
66
|
+
requestAnimationFrame(() => {
|
|
67
|
+
if (this[$endPolyfillCoordination] != null) {
|
|
68
|
+
this[$endPolyfillCoordination]();
|
|
69
|
+
this[$endPolyfillCoordination] = null;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return FocusVisibleCoordinator;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=focus-visible.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["focus-visible.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\ndeclare global {\n interface Window {\n applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;\n }\n}\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\ninterface OptionalLifecycleCallbacks {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n manageAutoFocus?(): void;\n}\n\ntype MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;\n\ntype EndPolyfillCoordinationCallback = () => void;\n\nlet hasFocusVisible = true;\n\ntry {\n document.body.querySelector(':focus-visible');\n} catch (error) {\n hasFocusVisible = false;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n import('focus-visible');\n}\n\n/**\n * This mixin function is designed to be applied to a class that inherits\n * from HTMLElement. It makes it easy for a custom element to coordinate with\n * the :focus-visible polyfill.\n *\n * NOTE(cdata): The code here was adapted from an example proposed with the\n * introduction of ShadowDOM support in the :focus-visible polyfill.\n *\n * @see https://github.com/WICG/focus-visible/pull/196\n * @param {Function} SuperClass The base class implementation to decorate with\n * implementation that coordinates with the :focus-visible polyfill\n */\nexport const FocusVisiblePolyfillMixin = <\n T extends Constructor<MixableBaseClass>\n>(\n SuperClass: T\n): T => {\n const coordinateWithPolyfill = (\n instance: MixableBaseClass\n ): EndPolyfillCoordinationCallback => {\n // If there is no shadow root, there is no need to coordinate with\n // the polyfill. If we already coordinated with the polyfill, we can\n // skip subsequent invokcations:\n if (\n instance.shadowRoot == null ||\n instance.hasAttribute('data-js-focus-visible')\n ) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n // The polyfill might already be loaded. If so, we can apply it to\n // the shadow root immediately:\n if (self.applyFocusVisiblePolyfill) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n } else {\n const coordinationHandler = (): void => {\n if (self.applyFocusVisiblePolyfill && instance.shadowRoot) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n }\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n };\n // Otherwise, wait for the polyfill to be loaded lazily. It might\n // never be loaded, but if it is then we can apply it to the\n // shadow root at the appropriate time by waiting for the ready\n // event:\n self.addEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler,\n { once: true }\n );\n\n return () => {\n self.removeEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler\n );\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n };\n\n const $endPolyfillCoordination = Symbol('endPolyfillCoordination');\n\n // IE11 doesn't natively support custom elements or JavaScript class\n // syntax The mixin implementation assumes that the user will take the\n // appropriate steps to support both:\n class FocusVisibleCoordinator extends SuperClass {\n private [$endPolyfillCoordination]: EndPolyfillCoordinationCallback | null =\n null;\n\n // Attempt to coordinate with the polyfill when connected to the\n // document:\n override connectedCallback(): void {\n super.connectedCallback && super.connectedCallback();\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] == null) {\n this[$endPolyfillCoordination] =\n coordinateWithPolyfill(this);\n }\n });\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback && super.disconnectedCallback();\n // It's important to remove the polyfill event listener when we\n // disconnect, otherwise we will leak the whole element via window:\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] != null) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this[$endPolyfillCoordination]!();\n this[$endPolyfillCoordination] = null;\n }\n });\n }\n }\n }\n\n return FocusVisibleCoordinator;\n};\n"],
|
|
5
|
+
"mappings": ";AAkCA,IAAI,kBAAkB;AAEtB,IAAI;AACA,WAAS,KAAK,cAAc,gBAAgB;AAChD,SAAS,OAAO;AACZ,oBAAkB;AAGlB,SAAO,eAAe;AAC1B;AAcO,aAAM,4BAA4B,CAGrC,eACI;AA7DR;AA8DI,QAAM,yBAAyB,CAC3B,aACkC;AAIlC,QACI,SAAS,cAAc,QACvB,SAAS,aAAa,uBAAuB,GAC/C;AAEE,aAAO,MAAM;AAAA,MAAC;AAAA,IAClB;AAIA,QAAI,KAAK,2BAA2B;AAChC,WAAK,0BAA0B,SAAS,UAAU;AAElD,UAAI,SAAS,iBAAiB;AAC1B,iBAAS,gBAAgB;AAAA,MAC7B;AAAA,IACJ,OAAO;AACH,YAAM,sBAAsB,MAAY;AACpC,YAAI,KAAK,6BAA6B,SAAS,YAAY;AACvD,eAAK,0BAA0B,SAAS,UAAU;AAAA,QACtD;AAEA,YAAI,SAAS,iBAAiB;AAC1B,mBAAS,gBAAgB;AAAA,QAC7B;AAAA,MACJ;AAKA,WAAK;AAAA,QACD;AAAA,QACA;AAAA,QACA,EAAE,MAAM,KAAK;AAAA,MACjB;AAEA,aAAO,MAAM;AACT,aAAK;AAAA,UACD;AAAA,UACA;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAGA,WAAO,MAAM;AAAA,IAAC;AAAA,EAClB;AAEA,QAAM,2BAA2B,OAAO,yBAAyB;AAAA,EAKjE,MAAM,iCAAgC,iBACzB,+BADyB,IAAW;AAAA,IAAjD;AAAA;AACI,WAAS,MACL;AAAA;AAAA;AAAA;AAAA,IAIK,oBAA0B;AAC/B,YAAM,qBAAqB,MAAM,kBAAkB;AACnD,UAAI,CAAC,iBAAiB;AAClB,8BAAsB,MAAM;AACxB,cAAI,KAAK,wBAAwB,KAAK,MAAM;AACxC,iBAAK,wBAAwB,IACzB,uBAAuB,IAAI;AAAA,UACnC;AAAA,QACJ,CAAC;AAAA,MACL;AAAA,IACJ;AAAA,IAES,uBAA6B;AAClC,YAAM,wBAAwB,MAAM,qBAAqB;AAGzD,UAAI,CAAC,iBAAiB;AAClB,8BAAsB,MAAM;AACxB,cAAI,KAAK,wBAAwB,KAAK,MAAM;AAExC,iBAAK,wBAAwB,EAAG;AAChC,iBAAK,wBAAwB,IAAI;AAAA,UACrC;AAAA,QACJ,CAAC;AAAA,MACL;AAAA,IACJ;AAAA,EACJ;AAEA,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";let i=!0;try{document.body.querySelector(":focus-visible")}catch(a){i=!1,import("focus-visible")}export const FocusVisiblePolyfillMixin=a=>{var s,t;const n=l=>{if(l.shadowRoot==null||l.hasAttribute("data-js-focus-visible"))return()=>{};if(self.applyFocusVisiblePolyfill)self.applyFocusVisiblePolyfill(l.shadowRoot),l.manageAutoFocus&&l.manageAutoFocus();else{const e=()=>{self.applyFocusVisiblePolyfill&&l.shadowRoot&&self.applyFocusVisiblePolyfill(l.shadowRoot),l.manageAutoFocus&&l.manageAutoFocus()};return self.addEventListener("focus-visible-polyfill-ready",e,{once:!0}),()=>{self.removeEventListener("focus-visible-polyfill-ready",e)}}return()=>{}},o=Symbol("endPolyfillCoordination");class c extends(t=a,s=o,t){constructor(){super(...arguments);this[s]=null}connectedCallback(){super.connectedCallback&&super.connectedCallback(),i||requestAnimationFrame(()=>{this[o]==null&&(this[o]=n(this))})}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),i||requestAnimationFrame(()=>{this[o]!=null&&(this[o](),this[o]=null)})}}return c};
|
|
2
|
+
//# sourceMappingURL=focus-visible.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["focus-visible.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\ndeclare global {\n interface Window {\n applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;\n }\n}\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\ninterface OptionalLifecycleCallbacks {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n manageAutoFocus?(): void;\n}\n\ntype MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;\n\ntype EndPolyfillCoordinationCallback = () => void;\n\nlet hasFocusVisible = true;\n\ntry {\n document.body.querySelector(':focus-visible');\n} catch (error) {\n hasFocusVisible = false;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n import('focus-visible');\n}\n\n/**\n * This mixin function is designed to be applied to a class that inherits\n * from HTMLElement. It makes it easy for a custom element to coordinate with\n * the :focus-visible polyfill.\n *\n * NOTE(cdata): The code here was adapted from an example proposed with the\n * introduction of ShadowDOM support in the :focus-visible polyfill.\n *\n * @see https://github.com/WICG/focus-visible/pull/196\n * @param {Function} SuperClass The base class implementation to decorate with\n * implementation that coordinates with the :focus-visible polyfill\n */\nexport const FocusVisiblePolyfillMixin = <\n T extends Constructor<MixableBaseClass>\n>(\n SuperClass: T\n): T => {\n const coordinateWithPolyfill = (\n instance: MixableBaseClass\n ): EndPolyfillCoordinationCallback => {\n // If there is no shadow root, there is no need to coordinate with\n // the polyfill. If we already coordinated with the polyfill, we can\n // skip subsequent invokcations:\n if (\n instance.shadowRoot == null ||\n instance.hasAttribute('data-js-focus-visible')\n ) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n // The polyfill might already be loaded. If so, we can apply it to\n // the shadow root immediately:\n if (self.applyFocusVisiblePolyfill) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n } else {\n const coordinationHandler = (): void => {\n if (self.applyFocusVisiblePolyfill && instance.shadowRoot) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n }\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n };\n // Otherwise, wait for the polyfill to be loaded lazily. It might\n // never be loaded, but if it is then we can apply it to the\n // shadow root at the appropriate time by waiting for the ready\n // event:\n self.addEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler,\n { once: true }\n );\n\n return () => {\n self.removeEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler\n );\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n };\n\n const $endPolyfillCoordination = Symbol('endPolyfillCoordination');\n\n // IE11 doesn't natively support custom elements or JavaScript class\n // syntax The mixin implementation assumes that the user will take the\n // appropriate steps to support both:\n class FocusVisibleCoordinator extends SuperClass {\n private [$endPolyfillCoordination]: EndPolyfillCoordinationCallback | null =\n null;\n\n // Attempt to coordinate with the polyfill when connected to the\n // document:\n override connectedCallback(): void {\n super.connectedCallback && super.connectedCallback();\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] == null) {\n this[$endPolyfillCoordination] =\n coordinateWithPolyfill(this);\n }\n });\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback && super.disconnectedCallback();\n // It's important to remove the polyfill event listener when we\n // disconnect, otherwise we will leak the whole element via window:\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] != null) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this[$endPolyfillCoordination]!();\n this[$endPolyfillCoordination] = null;\n }\n });\n }\n }\n }\n\n return FocusVisibleCoordinator;\n};\n"],
|
|
5
|
+
"mappings": "aAkCA,IAAIA,EAAkB,GAEtB,GAAI,CACA,SAAS,KAAK,cAAc,gBAAgB,CAChD,OAASC,EAAO,CACZD,EAAkB,GAGlB,OAAO,eAAe,CAC1B,CAcO,aAAM,0BAGTE,GACI,CA7DR,IAAAC,EAAAC,EA8DI,MAAMC,EACFC,GACkC,CAIlC,GACIA,EAAS,YAAc,MACvBA,EAAS,aAAa,uBAAuB,EAG7C,MAAO,IAAM,CAAC,EAKlB,GAAI,KAAK,0BACL,KAAK,0BAA0BA,EAAS,UAAU,EAE9CA,EAAS,iBACTA,EAAS,gBAAgB,MAE1B,CACH,MAAMC,EAAsB,IAAY,CAChC,KAAK,2BAA6BD,EAAS,YAC3C,KAAK,0BAA0BA,EAAS,UAAU,EAGlDA,EAAS,iBACTA,EAAS,gBAAgB,CAEjC,EAKA,YAAK,iBACD,+BACAC,EACA,CAAE,KAAM,EAAK,CACjB,EAEO,IAAM,CACT,KAAK,oBACD,+BACAA,CACJ,CACJ,CACJ,CAGA,MAAO,IAAM,CAAC,CAClB,EAEMC,EAA2B,OAAO,yBAAyB,EAKjE,MAAMC,UAAgCL,EAAAF,EACzBC,EAAAK,EADyBJ,EAAW,CAAjD,kCACI,KAASD,GACL,KAIK,mBAA0B,CAC/B,MAAM,mBAAqB,MAAM,kBAAkB,EAC9CH,GACD,sBAAsB,IAAM,CACpB,KAAKQ,CAAwB,GAAK,OAClC,KAAKA,CAAwB,EACzBH,EAAuB,IAAI,EAEvC,CAAC,CAET,CAES,sBAA6B,CAClC,MAAM,sBAAwB,MAAM,qBAAqB,EAGpDL,GACD,sBAAsB,IAAM,CACpB,KAAKQ,CAAwB,GAAK,OAElC,KAAKA,CAAwB,EAAG,EAChC,KAAKA,CAAwB,EAAI,KAEzC,CAAC,CAET,CACJ,CAEA,OAAOC,CACX",
|
|
6
|
+
"names": ["hasFocusVisible", "error", "SuperClass", "_a", "_b", "coordinateWithPolyfill", "instance", "coordinationHandler", "$endPolyfillCoordination", "FocusVisibleCoordinator"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const focusables = [
|
|
3
|
+
"button",
|
|
4
|
+
"[focusable]",
|
|
5
|
+
"[href]",
|
|
6
|
+
"input",
|
|
7
|
+
"label",
|
|
8
|
+
"select",
|
|
9
|
+
"textarea",
|
|
10
|
+
"[tabindex]"
|
|
11
|
+
];
|
|
12
|
+
const userFocuable = ':not([tabindex="-1"])';
|
|
13
|
+
export const userFocusableSelector = focusables.join(`${userFocuable}, `) + userFocuable;
|
|
14
|
+
export const focusableSelector = focusables.join(", ");
|
|
15
|
+
//# sourceMappingURL=focusable-selectors.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["focusable-selectors.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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\nconst focusables = [\n 'button',\n '[focusable]',\n '[href]',\n 'input',\n 'label',\n 'select',\n 'textarea',\n '[tabindex]',\n];\n\nconst userFocuable = ':not([tabindex=\"-1\"])';\n\nexport const userFocusableSelector =\n focusables.join(`${userFocuable}, `) + userFocuable;\n\nexport const focusableSelector = focusables.join(', ');\n"],
|
|
5
|
+
"mappings": ";AAYA,MAAM,aAAa;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAEA,MAAM,eAAe;AAEd,aAAM,wBACT,WAAW,KAAK,GAAG,YAAY,IAAI,IAAI;AAEpC,aAAM,oBAAoB,WAAW,KAAK,IAAI;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["focusable-selectors.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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\nconst focusables = [\n 'button',\n '[focusable]',\n '[href]',\n 'input',\n 'label',\n 'select',\n 'textarea',\n '[tabindex]',\n];\n\nconst userFocuable = ':not([tabindex=\"-1\"])';\n\nexport const userFocusableSelector =\n focusables.join(`${userFocuable}, `) + userFocuable;\n\nexport const focusableSelector = focusables.join(', ');\n"],
|
|
5
|
+
"mappings": "aAYA,MAAMA,EAAa,CACf,SACA,cACA,SACA,QACA,QACA,SACA,WACA,YACJ,EAEMC,EAAe,wBAEd,aAAM,sBACTD,EAAW,KAAK,GAAGC,CAAY,IAAI,EAAIA,EAE9B,kBAAoBD,EAAW,KAAK,IAAI",
|
|
6
|
+
"names": ["focusables", "userFocuable"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PropertyValues, SpectrumElement } from '@spectrum-web-components/base';
|
|
2
|
+
type DisableableElement = HTMLElement & {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const Focusable_base: typeof SpectrumElement;
|
|
6
|
+
/**
|
|
7
|
+
* Focusable base class handles tabindex setting into shadowed elements automatically.
|
|
8
|
+
*
|
|
9
|
+
* This implementation is based heavily on the aybolit delegate-focus-mixin at
|
|
10
|
+
* https://github.com/web-padawan/aybolit/blob/master/packages/core/src/mixins/delegate-focus-mixin.js
|
|
11
|
+
*/
|
|
12
|
+
export declare class Focusable extends Focusable_base {
|
|
13
|
+
/**
|
|
14
|
+
* Disable this control. It will not receive focus or events
|
|
15
|
+
*/
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* When this control is rendered, focus it automatically
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
autofocus: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The tab index to apply to this control. See general documentation about
|
|
24
|
+
* the tabindex HTML property
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
get tabIndex(): number;
|
|
29
|
+
set tabIndex(tabIndex: number);
|
|
30
|
+
private _tabIndex;
|
|
31
|
+
private onPointerdownManagementOfTabIndex;
|
|
32
|
+
private manageFocusElementTabindex;
|
|
33
|
+
private manipulatingTabindex;
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
get focusElement(): DisableableElement;
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
* @returns {boolean} whether the component should manage its focusElement tab-index or not
|
|
41
|
+
* Needed for action-menu to be supported in action-group in an accessible way
|
|
42
|
+
*/
|
|
43
|
+
get selfManageFocusElement(): boolean;
|
|
44
|
+
focus(options?: FocusOptions): void;
|
|
45
|
+
blur(): void;
|
|
46
|
+
click(): void;
|
|
47
|
+
protected manageAutoFocus(): void;
|
|
48
|
+
protected firstUpdated(changes: PropertyValues): void;
|
|
49
|
+
protected update(changedProperties: PropertyValues): void;
|
|
50
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
51
|
+
private handleDisabledChanged;
|
|
52
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
53
|
+
private autofocusReady;
|
|
54
|
+
connectedCallback(): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|