@spectrum-web-components/shared 0.14.4 → 0.14.5
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 +52 -6
- package/src/first-focusable-in.dev.js +6 -0
- package/src/first-focusable-in.dev.js.map +7 -0
- package/src/first-focusable-in.js +3 -14
- package/src/first-focusable-in.js.map +7 -1
- package/src/focus-visible.dev.js +68 -0
- package/src/focus-visible.dev.js.map +7 -0
- package/src/focus-visible.js +59 -105
- package/src/focus-visible.js.map +7 -1
- package/src/focusable.dev.js +190 -0
- package/src/focusable.dev.js.map +7 -0
- package/src/focusable.js +185 -244
- package/src/focusable.js.map +7 -1
- package/src/get-active-element.dev.js +4 -0
- package/src/get-active-element.dev.js.map +7 -0
- package/src/get-active-element.js +2 -14
- package/src/get-active-element.js.map +7 -1
- package/src/get-deep-element-from-point.dev.js +12 -0
- package/src/get-deep-element-from-point.dev.js.map +7 -0
- package/src/get-deep-element-from-point.js +9 -20
- package/src/get-deep-element-from-point.js.map +7 -1
- package/src/index.dev.js +10 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +10 -21
- package/src/index.js.map +7 -1
- package/src/like-anchor.dev.js +58 -0
- package/src/like-anchor.dev.js.map +7 -0
- package/src/like-anchor.js +45 -40
- package/src/like-anchor.js.map +7 -1
- package/src/observe-slot-presence.dev.js +52 -0
- package/src/observe-slot-presence.dev.js.map +7 -0
- package/src/observe-slot-presence.js +47 -55
- package/src/observe-slot-presence.js.map +7 -1
- package/src/observe-slot-text.dev.js +79 -0
- package/src/observe-slot-text.dev.js.map +7 -0
- package/src/observe-slot-text.js +73 -64
- package/src/observe-slot-text.js.map +7 -1
- package/src/platform.dev.js +31 -0
- package/src/platform.dev.js.map +7 -0
- package/src/platform.js +11 -32
- package/src/platform.js.map +7 -1
- package/src/reparent-children.dev.js +50 -0
- package/src/reparent-children.dev.js.map +7 -0
- package/src/reparent-children.js +44 -52
- package/src/reparent-children.js.map +7 -1
- package/test/focusable.test.js +19 -31
- package/test/focusable.test.js.map +7 -1
- package/test/observe-slot-presence.test.js +17 -27
- package/test/observe-slot-presence.test.js.map +7 -1
- package/test/observe-slot-text.test.js +17 -28
- package/test/observe-slot-text.test.js.map +7 -1
- package/test/reparent-children.test.js +151 -162
- package/test/reparent-children.test.js.map +7 -1
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
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
1
|
export const getDeepElementFromPoint = (x, y) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
target = innerTarget;
|
|
2
|
+
let target = document.elementFromPoint(x, y);
|
|
3
|
+
while (target == null ? void 0 : target.shadowRoot) {
|
|
4
|
+
const innerTarget = target.shadowRoot.elementFromPoint(x, y);
|
|
5
|
+
if (!innerTarget || innerTarget === target) {
|
|
6
|
+
break;
|
|
20
7
|
}
|
|
21
|
-
|
|
8
|
+
target = innerTarget;
|
|
9
|
+
}
|
|
10
|
+
return target;
|
|
22
11
|
};
|
|
23
|
-
//# sourceMappingURL=get-deep-element-from-point.js.map
|
|
12
|
+
//# sourceMappingURL=get-deep-element-from-point.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["get-deep-element-from-point.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 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\nexport const getDeepElementFromPoint = (\n x: number,\n y: number\n): Element | null => {\n let target = document.elementFromPoint(x, y);\n while (target?.shadowRoot) {\n const innerTarget = (\n target.shadowRoot as unknown as {\n elementFromPoint: (x: number, y: number) => Element | null;\n }\n ).elementFromPoint(x, y);\n if (!innerTarget || innerTarget === target) {\n break;\n }\n target = innerTarget;\n }\n return target;\n};\n"],
|
|
5
|
+
"mappings": "AAYO,aAAM,0BAA0B,CACnC,GACA,MACiB;AACjB,MAAI,SAAS,SAAS,iBAAiB,GAAG,CAAC;AAC3C,SAAO,iCAAQ,YAAY;AACvB,UAAM,cACF,OAAO,WAGT,iBAAiB,GAAG,CAAC;AACvB,QAAI,CAAC,eAAe,gBAAgB,QAAQ;AACxC;AAAA,IACJ;AACA,aAAS;AAAA,EACb;AACA,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.dev.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./first-focusable-in.dev.js";
|
|
2
|
+
export * from "./focus-visible.dev.js";
|
|
3
|
+
export * from "./focusable.dev.js";
|
|
4
|
+
export * from "./get-active-element.dev.js";
|
|
5
|
+
export * from "./like-anchor.dev.js";
|
|
6
|
+
export * from "./observe-slot-presence.dev.js";
|
|
7
|
+
export * from "./observe-slot-text.dev.js";
|
|
8
|
+
export * from "./platform.dev.js";
|
|
9
|
+
export * from "./reparent-children.dev.js";
|
|
10
|
+
//# sourceMappingURL=index.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.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\nexport * from './first-focusable-in.dev.js'\nexport * from './focus-visible.dev.js'\nexport * from './focusable.dev.js'\nexport * from './get-active-element.dev.js'\nexport * from './like-anchor.dev.js'\nexport * from './observe-slot-presence.dev.js'\nexport * from './observe-slot-text.dev.js'\nexport * from './platform.dev.js'\nexport * from './reparent-children.dev.js'\n"],
|
|
5
|
+
"mappings": "AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
export * from './first-focusable-in.js';
|
|
13
|
-
export * from './focus-visible.js';
|
|
14
|
-
export * from './focusable.js';
|
|
15
|
-
export * from './get-active-element.js';
|
|
16
|
-
export * from './like-anchor.js';
|
|
17
|
-
export * from './observe-slot-presence.js';
|
|
18
|
-
export * from './observe-slot-text.js';
|
|
19
|
-
export * from './platform.js';
|
|
20
|
-
export * from './reparent-children.js';
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./first-focusable-in.js";
|
|
2
|
+
export * from "./focus-visible.js";
|
|
3
|
+
export * from "./focusable.js";
|
|
4
|
+
export * from "./get-active-element.js";
|
|
5
|
+
export * from "./like-anchor.js";
|
|
6
|
+
export * from "./observe-slot-presence.js";
|
|
7
|
+
export * from "./observe-slot-text.js";
|
|
8
|
+
export * from "./platform.js";
|
|
9
|
+
export * from "./reparent-children.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.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\nexport * from './first-focusable-in.js';\nexport * from './focus-visible.js';\nexport * from './focusable.js';\nexport * from './get-active-element.js';\nexport * from './like-anchor.js';\nexport * from './observe-slot-presence.js';\nexport * from './observe-slot-text.js';\nexport * from './platform.js';\nexport * from './reparent-children.js';\n"],
|
|
5
|
+
"mappings": "AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
} from "@spectrum-web-components/base";
|
|
15
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
16
|
+
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
17
|
+
export function LikeAnchor(constructor) {
|
|
18
|
+
class LikeAnchorElement extends constructor {
|
|
19
|
+
renderAnchor({
|
|
20
|
+
id,
|
|
21
|
+
className,
|
|
22
|
+
ariaHidden,
|
|
23
|
+
labelledby,
|
|
24
|
+
tabindex,
|
|
25
|
+
anchorContent = html`<slot></slot>`
|
|
26
|
+
}) {
|
|
27
|
+
return html`<a
|
|
28
|
+
id=${id}
|
|
29
|
+
class=${ifDefined(className)}
|
|
30
|
+
href=${ifDefined(this.href)}
|
|
31
|
+
download=${ifDefined(this.download)}
|
|
32
|
+
target=${ifDefined(this.target)}
|
|
33
|
+
aria-label=${ifDefined(this.label)}
|
|
34
|
+
aria-labelledby=${ifDefined(labelledby)}
|
|
35
|
+
aria-hidden=${ifDefined(ariaHidden ? "true" : void 0)}
|
|
36
|
+
tabindex=${ifDefined(tabindex)}
|
|
37
|
+
rel=${ifDefined(this.rel)}
|
|
38
|
+
>${anchorContent}</a>`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
__decorateClass([
|
|
42
|
+
property({ reflect: true })
|
|
43
|
+
], LikeAnchorElement.prototype, "download", 2);
|
|
44
|
+
__decorateClass([
|
|
45
|
+
property()
|
|
46
|
+
], LikeAnchorElement.prototype, "label", 2);
|
|
47
|
+
__decorateClass([
|
|
48
|
+
property({ reflect: true })
|
|
49
|
+
], LikeAnchorElement.prototype, "href", 2);
|
|
50
|
+
__decorateClass([
|
|
51
|
+
property({ reflect: true })
|
|
52
|
+
], LikeAnchorElement.prototype, "target", 2);
|
|
53
|
+
__decorateClass([
|
|
54
|
+
property({ reflect: true })
|
|
55
|
+
], LikeAnchorElement.prototype, "rel", 2);
|
|
56
|
+
return LikeAnchorElement;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=like-anchor.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["like-anchor.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 {\n html,\n ReactiveElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\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\ntype RenderAnchorOptions = {\n id: string;\n className?: string;\n ariaHidden?: boolean;\n anchorContent?: TemplateResult | TemplateResult[];\n labelledby?: string;\n tabindex?: -1 | 0;\n};\n\nexport interface LikeAnchorInterface {\n download?: string;\n label?: string;\n href?: string;\n rel?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n renderAnchor(options: RenderAnchorOptions): TemplateResult;\n}\n\nexport function LikeAnchor<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<LikeAnchorInterface> {\n class LikeAnchorElement extends constructor {\n @property({ reflect: true })\n public download?: string;\n\n @property()\n public label?: string;\n\n @property({ reflect: true })\n public href?: string;\n\n @property({ reflect: true })\n public target?: '_blank' | '_parent' | '_self' | '_top';\n\n @property({ reflect: true })\n public rel?: string;\n\n public renderAnchor({\n id,\n className,\n ariaHidden,\n labelledby,\n tabindex,\n // prettier-ignore\n anchorContent = html`<slot></slot>`,\n }: RenderAnchorOptions): TemplateResult {\n // prettier-ignore\n return html\n `<a\n id=${id}\n class=${ifDefined(className)}\n href=${ifDefined(this.href)}\n download=${ifDefined(this.download)}\n target=${ifDefined(this.target)}\n aria-label=${ifDefined(this.label)}\n aria-labelledby=${ifDefined(labelledby)}\n aria-hidden=${ifDefined(ariaHidden ? 'true' : undefined)}\n tabindex=${ifDefined(tabindex)}\n rel=${ifDefined(this.rel)}\n >${anchorContent}</a>`;\n }\n }\n return LikeAnchorElement;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAWA;AAAA;AAAA;AAKA;AACA;AA0BO,2BACH,aACoC;AACpC,QAAM,0BAA0B,YAAY;AAAA,IAgBjC,aAAa;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA,gBAAgB;AAAA,OACoB;AAEpC,aAAO;AAAA,yBAEM;AAAA,4BACG,UAAU,SAAS;AAAA,2BACpB,UAAU,KAAK,IAAI;AAAA,+BACf,UAAU,KAAK,QAAQ;AAAA,6BACzB,UAAU,KAAK,MAAM;AAAA,iCACjB,UAAU,KAAK,KAAK;AAAA,sCACf,UAAU,UAAU;AAAA,kCACxB,UAAU,aAAa,SAAS,MAAS;AAAA,+BAC5C,UAAU,QAAQ;AAAA,0BACvB,UAAU,KAAK,GAAG;AAAA,mBACzB;AAAA,IACX;AAAA,EACJ;AAtCW;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AAFX,kBAEW;AAGA;AAAA,IADP,AAAC,SAAS;AAAA,KACH,AALX,kBAKW;AAGA;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AARX,kBAQW;AAGA;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AAXX,kBAWW;AAGA;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AAdX,kBAcW;AA2BX,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/like-anchor.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
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
|
+
} from "@spectrum-web-components/base";
|
|
15
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
16
|
+
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
16
17
|
export function LikeAnchor(constructor) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
class LikeAnchorElement extends constructor {
|
|
19
|
+
renderAnchor({
|
|
20
|
+
id,
|
|
21
|
+
className,
|
|
22
|
+
ariaHidden,
|
|
23
|
+
labelledby,
|
|
24
|
+
tabindex,
|
|
25
|
+
anchorContent = html`<slot></slot>`
|
|
26
|
+
}) {
|
|
27
|
+
return html`<a
|
|
23
28
|
id=${id}
|
|
24
29
|
class=${ifDefined(className)}
|
|
25
30
|
href=${ifDefined(this.href)}
|
|
@@ -27,27 +32,27 @@ export function LikeAnchor(constructor) {
|
|
|
27
32
|
target=${ifDefined(this.target)}
|
|
28
33
|
aria-label=${ifDefined(this.label)}
|
|
29
34
|
aria-labelledby=${ifDefined(labelledby)}
|
|
30
|
-
aria-hidden=${ifDefined(ariaHidden ?
|
|
35
|
+
aria-hidden=${ifDefined(ariaHidden ? "true" : void 0)}
|
|
31
36
|
tabindex=${ifDefined(tabindex)}
|
|
32
37
|
rel=${ifDefined(this.rel)}
|
|
33
38
|
>${anchorContent}</a>`;
|
|
34
|
-
}
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
}
|
|
41
|
+
__decorateClass([
|
|
42
|
+
property({ reflect: true })
|
|
43
|
+
], LikeAnchorElement.prototype, "download", 2);
|
|
44
|
+
__decorateClass([
|
|
45
|
+
property()
|
|
46
|
+
], LikeAnchorElement.prototype, "label", 2);
|
|
47
|
+
__decorateClass([
|
|
48
|
+
property({ reflect: true })
|
|
49
|
+
], LikeAnchorElement.prototype, "href", 2);
|
|
50
|
+
__decorateClass([
|
|
51
|
+
property({ reflect: true })
|
|
52
|
+
], LikeAnchorElement.prototype, "target", 2);
|
|
53
|
+
__decorateClass([
|
|
54
|
+
property({ reflect: true })
|
|
55
|
+
], LikeAnchorElement.prototype, "rel", 2);
|
|
56
|
+
return LikeAnchorElement;
|
|
52
57
|
}
|
|
53
|
-
//# sourceMappingURL=like-anchor.js.map
|
|
58
|
+
//# sourceMappingURL=like-anchor.js.map
|
package/src/like-anchor.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["like-anchor.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 {\n html,\n ReactiveElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\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\ntype RenderAnchorOptions = {\n id: string;\n className?: string;\n ariaHidden?: boolean;\n anchorContent?: TemplateResult | TemplateResult[];\n labelledby?: string;\n tabindex?: -1 | 0;\n};\n\nexport interface LikeAnchorInterface {\n download?: string;\n label?: string;\n href?: string;\n rel?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n renderAnchor(options: RenderAnchorOptions): TemplateResult;\n}\n\nexport function LikeAnchor<T extends Constructor<ReactiveElement>>(\n constructor: T\n): T & Constructor<LikeAnchorInterface> {\n class LikeAnchorElement extends constructor {\n @property({ reflect: true })\n public download?: string;\n\n @property()\n public label?: string;\n\n @property({ reflect: true })\n public href?: string;\n\n @property({ reflect: true })\n public target?: '_blank' | '_parent' | '_self' | '_top';\n\n @property({ reflect: true })\n public rel?: string;\n\n public renderAnchor({\n id,\n className,\n ariaHidden,\n labelledby,\n tabindex,\n // prettier-ignore\n anchorContent = html`<slot></slot>`,\n }: RenderAnchorOptions): TemplateResult {\n // prettier-ignore\n return html\n `<a\n id=${id}\n class=${ifDefined(className)}\n href=${ifDefined(this.href)}\n download=${ifDefined(this.download)}\n target=${ifDefined(this.target)}\n aria-label=${ifDefined(this.label)}\n aria-labelledby=${ifDefined(labelledby)}\n aria-hidden=${ifDefined(ariaHidden ? 'true' : undefined)}\n tabindex=${ifDefined(tabindex)}\n rel=${ifDefined(this.rel)}\n >${anchorContent}</a>`;\n }\n }\n return LikeAnchorElement;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAWA;AAAA;AAAA;AAKA;AACA;AA0BO,2BACH,aACoC;AACpC,QAAM,0BAA0B,YAAY;AAAA,IAgBjC,aAAa;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA,gBAAgB;AAAA,OACoB;AAEpC,aAAO;AAAA,yBAEM;AAAA,4BACG,UAAU,SAAS;AAAA,2BACpB,UAAU,KAAK,IAAI;AAAA,+BACf,UAAU,KAAK,QAAQ;AAAA,6BACzB,UAAU,KAAK,MAAM;AAAA,iCACjB,UAAU,KAAK,KAAK;AAAA,sCACf,UAAU,UAAU;AAAA,kCACxB,UAAU,aAAa,SAAS,MAAS;AAAA,+BAC5C,UAAU,QAAQ;AAAA,0BACvB,UAAU,KAAK,GAAG;AAAA,mBACzB;AAAA,IACX;AAAA,EACJ;AAtCW;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AAFX,kBAEW;AAGA;AAAA,IADP,AAAC,SAAS;AAAA,KACH,AALX,kBAKW;AAGA;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AARX,kBAQW;AAGA;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AAXX,kBAWW;AAGA;AAAA,IADP,AAAC,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,KACpB,AAdX,kBAcW;AA2BX,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MutationController } from "@lit-labs/observers/mutation_controller.js";
|
|
2
|
+
const slotContentIsPresent = Symbol("slotContentIsPresent");
|
|
3
|
+
export function ObserveSlotPresence(constructor, lightDomSelector) {
|
|
4
|
+
var _a;
|
|
5
|
+
const lightDomSelectors = Array.isArray(lightDomSelector) ? lightDomSelector : [lightDomSelector];
|
|
6
|
+
class SlotPresenceObservingElement extends constructor {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(args);
|
|
9
|
+
this[_a] = /* @__PURE__ */ new Map();
|
|
10
|
+
this.managePresenceObservedSlot = () => {
|
|
11
|
+
let changes = false;
|
|
12
|
+
lightDomSelectors.forEach((selector) => {
|
|
13
|
+
const nextValue = !!this.querySelector(selector);
|
|
14
|
+
const previousValue = this[slotContentIsPresent].get(selector) || false;
|
|
15
|
+
changes = changes || previousValue !== nextValue;
|
|
16
|
+
this[slotContentIsPresent].set(selector, !!this.querySelector(selector));
|
|
17
|
+
});
|
|
18
|
+
if (changes) {
|
|
19
|
+
this.updateComplete.then(() => {
|
|
20
|
+
this.requestUpdate();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
new MutationController(this, {
|
|
25
|
+
config: {
|
|
26
|
+
childList: true,
|
|
27
|
+
subtree: true
|
|
28
|
+
},
|
|
29
|
+
callback: () => {
|
|
30
|
+
this.managePresenceObservedSlot();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
this.managePresenceObservedSlot();
|
|
34
|
+
}
|
|
35
|
+
get slotContentIsPresent() {
|
|
36
|
+
if (lightDomSelectors.length === 1) {
|
|
37
|
+
return this[slotContentIsPresent].get(lightDomSelectors[0]) || false;
|
|
38
|
+
} else {
|
|
39
|
+
throw new Error("Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
getSlotContentPresence(selector) {
|
|
43
|
+
if (this[slotContentIsPresent].has(selector)) {
|
|
44
|
+
return this[slotContentIsPresent].get(selector) || false;
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`The provided selector \`${selector}\` is not being observed.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
_a = slotContentIsPresent;
|
|
50
|
+
return SlotPresenceObservingElement;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=observe-slot-presence.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["observe-slot-presence.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\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 { ReactiveElement } from '@spectrum-web-components/base';\nimport { MutationController } from '@lit-labs/observers/mutation_controller.js';\n\nconst slotContentIsPresent = Symbol('slotContentIsPresent');\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\nexport interface SlotPresenceObservingInterface {\n slotContentIsPresent: boolean;\n getSlotContentPresence(selector: string): boolean;\n managePresenceObservedSlot(): void;\n}\n\nexport function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(\n constructor: T,\n lightDomSelector: string | string[]\n): T & Constructor<SlotPresenceObservingInterface> {\n const lightDomSelectors = Array.isArray(lightDomSelector)\n ? lightDomSelector\n : [lightDomSelector];\n class SlotPresenceObservingElement\n extends constructor\n implements SlotPresenceObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.managePresenceObservedSlot();\n },\n });\n\n this.managePresenceObservedSlot();\n }\n\n /**\n * @private\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return (\n this[slotContentIsPresent].get(lightDomSelectors[0]) ||\n false\n );\n } else {\n throw new Error(\n 'Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.'\n );\n }\n }\n private [slotContentIsPresent]: Map<string, boolean> = new Map();\n\n public getSlotContentPresence(selector: string): boolean {\n if (this[slotContentIsPresent].has(selector)) {\n return this[slotContentIsPresent].get(selector) || false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(selector);\n const previousValue =\n this[slotContentIsPresent].get(selector) || false;\n changes = changes || previousValue !== nextValue;\n this[slotContentIsPresent].set(\n selector,\n !!this.querySelector(selector)\n );\n });\n if (changes) {\n this.updateComplete.then(() => {\n this.requestUpdate();\n });\n }\n };\n }\n return SlotPresenceObservingElement;\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,MAAM,uBAAuB,OAAO,sBAAsB;AAcnD,oCACH,aACA,kBAC+C;AA9BnD;AA+BI,QAAM,oBAAoB,MAAM,QAAQ,gBAAgB,IAClD,mBACA,CAAC,gBAAgB;AACvB,QAAM,qCACM,YAEZ;AAAA,IAEI,eAAe,MAAa;AACxB,YAAM,IAAI;AA8BL,iBAA8C,oBAAI,IAAI;AAWxD,wCAA6B,MAAY;AAC5C,YAAI,UAAU;AACd,0BAAkB,QAAQ,CAAC,aAAa;AACpC,gBAAM,YAAY,CAAC,CAAC,KAAK,cAAc,QAAQ;AAC/C,gBAAM,gBACF,KAAK,sBAAsB,IAAI,QAAQ,KAAK;AAChD,oBAAU,WAAW,kBAAkB;AACvC,eAAK,sBAAsB,IACvB,UACA,CAAC,CAAC,KAAK,cAAc,QAAQ,CACjC;AAAA,QACJ,CAAC;AACD,YAAI,SAAS;AACT,eAAK,eAAe,KAAK,MAAM;AAC3B,iBAAK,cAAc;AAAA,UACvB,CAAC;AAAA,QACL;AAAA,MACJ;AAxDI,UAAI,mBAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,WAAW;AAAA,UACX,SAAS;AAAA,QACb;AAAA,QACA,UAAU,MAAM;AACZ,eAAK,2BAA2B;AAAA,QACpC;AAAA,MACJ,CAAC;AAED,WAAK,2BAA2B;AAAA,IACpC;AAAA,QAKW,uBAAgC;AACvC,UAAI,kBAAkB,WAAW,GAAG;AAChC,eACI,KAAK,sBAAsB,IAAI,kBAAkB,EAAE,KACnD;AAAA,MAER,OAAO;AACH,cAAM,IAAI,MACN,8GACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IAGO,uBAAuB,UAA2B;AACrD,UAAI,KAAK,sBAAsB,IAAI,QAAQ,GAAG;AAC1C,eAAO,KAAK,sBAAsB,IAAI,QAAQ,KAAK;AAAA,MACvD;AACA,YAAM,IAAI,MACN,2BAA2B,mCAC/B;AAAA,IACJ;AAAA,EAoBJ;AAnGJ,EAsEiB;AA8Bb,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,60 +1,52 @@
|
|
|
1
|
-
import { MutationController } from
|
|
2
|
-
const slotContentIsPresent = Symbol(
|
|
1
|
+
import { MutationController } from "@lit-labs/observers/mutation_controller.js";
|
|
2
|
+
const slotContentIsPresent = Symbol("slotContentIsPresent");
|
|
3
3
|
export function ObserveSlotPresence(constructor, lightDomSelector) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.updateComplete.then(() => {
|
|
23
|
-
this.requestUpdate();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
new MutationController(this, {
|
|
28
|
-
config: {
|
|
29
|
-
childList: true,
|
|
30
|
-
subtree: true,
|
|
31
|
-
},
|
|
32
|
-
callback: () => {
|
|
33
|
-
this.managePresenceObservedSlot();
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
this.managePresenceObservedSlot();
|
|
4
|
+
var _a;
|
|
5
|
+
const lightDomSelectors = Array.isArray(lightDomSelector) ? lightDomSelector : [lightDomSelector];
|
|
6
|
+
class SlotPresenceObservingElement extends constructor {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(args);
|
|
9
|
+
this[_a] = /* @__PURE__ */ new Map();
|
|
10
|
+
this.managePresenceObservedSlot = () => {
|
|
11
|
+
let changes = false;
|
|
12
|
+
lightDomSelectors.forEach((selector) => {
|
|
13
|
+
const nextValue = !!this.querySelector(selector);
|
|
14
|
+
const previousValue = this[slotContentIsPresent].get(selector) || false;
|
|
15
|
+
changes = changes || previousValue !== nextValue;
|
|
16
|
+
this[slotContentIsPresent].set(selector, !!this.querySelector(selector));
|
|
17
|
+
});
|
|
18
|
+
if (changes) {
|
|
19
|
+
this.updateComplete.then(() => {
|
|
20
|
+
this.requestUpdate();
|
|
21
|
+
});
|
|
37
22
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
else {
|
|
47
|
-
throw new Error('Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
getSlotContentPresence(selector) {
|
|
51
|
-
if (this[slotContentIsPresent].has(selector)) {
|
|
52
|
-
return this[slotContentIsPresent].get(selector) || false;
|
|
53
|
-
}
|
|
54
|
-
throw new Error(`The provided selector \`${selector}\` is not being observed.`);
|
|
23
|
+
};
|
|
24
|
+
new MutationController(this, {
|
|
25
|
+
config: {
|
|
26
|
+
childList: true,
|
|
27
|
+
subtree: true
|
|
28
|
+
},
|
|
29
|
+
callback: () => {
|
|
30
|
+
this.managePresenceObservedSlot();
|
|
55
31
|
}
|
|
32
|
+
});
|
|
33
|
+
this.managePresenceObservedSlot();
|
|
34
|
+
}
|
|
35
|
+
get slotContentIsPresent() {
|
|
36
|
+
if (lightDomSelectors.length === 1) {
|
|
37
|
+
return this[slotContentIsPresent].get(lightDomSelectors[0]) || false;
|
|
38
|
+
} else {
|
|
39
|
+
throw new Error("Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
getSlotContentPresence(selector) {
|
|
43
|
+
if (this[slotContentIsPresent].has(selector)) {
|
|
44
|
+
return this[slotContentIsPresent].get(selector) || false;
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`The provided selector \`${selector}\` is not being observed.`);
|
|
56
47
|
}
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
}
|
|
49
|
+
_a = slotContentIsPresent;
|
|
50
|
+
return SlotPresenceObservingElement;
|
|
59
51
|
}
|
|
60
|
-
//# sourceMappingURL=observe-slot-presence.js.map
|
|
52
|
+
//# sourceMappingURL=observe-slot-presence.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["observe-slot-presence.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\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 { ReactiveElement } from '@spectrum-web-components/base';\nimport { MutationController } from '@lit-labs/observers/mutation_controller.js';\n\nconst slotContentIsPresent = Symbol('slotContentIsPresent');\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\nexport interface SlotPresenceObservingInterface {\n slotContentIsPresent: boolean;\n getSlotContentPresence(selector: string): boolean;\n managePresenceObservedSlot(): void;\n}\n\nexport function ObserveSlotPresence<T extends Constructor<ReactiveElement>>(\n constructor: T,\n lightDomSelector: string | string[]\n): T & Constructor<SlotPresenceObservingInterface> {\n const lightDomSelectors = Array.isArray(lightDomSelector)\n ? lightDomSelector\n : [lightDomSelector];\n class SlotPresenceObservingElement\n extends constructor\n implements SlotPresenceObservingInterface\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(args);\n\n new MutationController(this, {\n config: {\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.managePresenceObservedSlot();\n },\n });\n\n this.managePresenceObservedSlot();\n }\n\n /**\n * @private\n */\n public get slotContentIsPresent(): boolean {\n if (lightDomSelectors.length === 1) {\n return (\n this[slotContentIsPresent].get(lightDomSelectors[0]) ||\n false\n );\n } else {\n throw new Error(\n 'Multiple selectors provided to `ObserveSlotPresence` use `getSlotContentPresence(selector: string)` instead.'\n );\n }\n }\n private [slotContentIsPresent]: Map<string, boolean> = new Map();\n\n public getSlotContentPresence(selector: string): boolean {\n if (this[slotContentIsPresent].has(selector)) {\n return this[slotContentIsPresent].get(selector) || false;\n }\n throw new Error(\n `The provided selector \\`${selector}\\` is not being observed.`\n );\n }\n\n public managePresenceObservedSlot = (): void => {\n let changes = false;\n lightDomSelectors.forEach((selector) => {\n const nextValue = !!this.querySelector(selector);\n const previousValue =\n this[slotContentIsPresent].get(selector) || false;\n changes = changes || previousValue !== nextValue;\n this[slotContentIsPresent].set(\n selector,\n !!this.querySelector(selector)\n );\n });\n if (changes) {\n this.updateComplete.then(() => {\n this.requestUpdate();\n });\n }\n };\n }\n return SlotPresenceObservingElement;\n}\n"],
|
|
5
|
+
"mappings": "AAWA;AAEA,MAAM,uBAAuB,OAAO,sBAAsB;AAcnD,oCACH,aACA,kBAC+C;AA9BnD;AA+BI,QAAM,oBAAoB,MAAM,QAAQ,gBAAgB,IAClD,mBACA,CAAC,gBAAgB;AACvB,QAAM,qCACM,YAEZ;AAAA,IAEI,eAAe,MAAa;AACxB,YAAM,IAAI;AA8BL,iBAA8C,oBAAI,IAAI;AAWxD,wCAA6B,MAAY;AAC5C,YAAI,UAAU;AACd,0BAAkB,QAAQ,CAAC,aAAa;AACpC,gBAAM,YAAY,CAAC,CAAC,KAAK,cAAc,QAAQ;AAC/C,gBAAM,gBACF,KAAK,sBAAsB,IAAI,QAAQ,KAAK;AAChD,oBAAU,WAAW,kBAAkB;AACvC,eAAK,sBAAsB,IACvB,UACA,CAAC,CAAC,KAAK,cAAc,QAAQ,CACjC;AAAA,QACJ,CAAC;AACD,YAAI,SAAS;AACT,eAAK,eAAe,KAAK,MAAM;AAC3B,iBAAK,cAAc;AAAA,UACvB,CAAC;AAAA,QACL;AAAA,MACJ;AAxDI,UAAI,mBAAmB,MAAM;AAAA,QACzB,QAAQ;AAAA,UACJ,WAAW;AAAA,UACX,SAAS;AAAA,QACb;AAAA,QACA,UAAU,MAAM;AACZ,eAAK,2BAA2B;AAAA,QACpC;AAAA,MACJ,CAAC;AAED,WAAK,2BAA2B;AAAA,IACpC;AAAA,QAKW,uBAAgC;AACvC,UAAI,kBAAkB,WAAW,GAAG;AAChC,eACI,KAAK,sBAAsB,IAAI,kBAAkB,EAAE,KACnD;AAAA,MAER,OAAO;AACH,cAAM,IAAI,MACN,8GACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IAGO,uBAAuB,UAA2B;AACrD,UAAI,KAAK,sBAAsB,IAAI,QAAQ,GAAG;AAC1C,eAAO,KAAK,sBAAsB,IAAI,QAAQ,KAAK;AAAA,MACvD;AACA,YAAM,IAAI,MACN,2BAA2B,mCAC/B;AAAA,IACJ;AAAA,EAoBJ;AAnGJ,EAsEiB;AA8Bb,SAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
property,
|
|
14
|
+
queryAssignedNodes
|
|
15
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
|
16
|
+
import { MutationController } from "@lit-labs/observers/mutation_controller.js";
|
|
17
|
+
const assignedNodesList = Symbol("assignedNodes");
|
|
18
|
+
export function ObserveSlotText(constructor, slotName) {
|
|
19
|
+
var _a;
|
|
20
|
+
class SlotTextObservingElement extends constructor {
|
|
21
|
+
constructor(...args) {
|
|
22
|
+
super(args);
|
|
23
|
+
this.slotHasContent = false;
|
|
24
|
+
new MutationController(this, {
|
|
25
|
+
config: {
|
|
26
|
+
characterData: true,
|
|
27
|
+
subtree: true
|
|
28
|
+
},
|
|
29
|
+
callback: (mutationsList) => {
|
|
30
|
+
for (const mutation of mutationsList) {
|
|
31
|
+
if (mutation.type === "characterData") {
|
|
32
|
+
this.manageTextObservedSlot();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
manageTextObservedSlot() {
|
|
40
|
+
if (!this[assignedNodesList])
|
|
41
|
+
return;
|
|
42
|
+
const assignedNodes = [...this[assignedNodesList]].filter((node) => {
|
|
43
|
+
if (node.tagName) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return node.textContent ? node.textContent.trim() : false;
|
|
47
|
+
});
|
|
48
|
+
this.slotHasContent = assignedNodes.length > 0;
|
|
49
|
+
}
|
|
50
|
+
update(changedProperties) {
|
|
51
|
+
if (!this.hasUpdated) {
|
|
52
|
+
const { childNodes } = this;
|
|
53
|
+
const textNodes = [...childNodes].filter((node) => {
|
|
54
|
+
if (node.tagName) {
|
|
55
|
+
return slotName ? node.getAttribute("slot") === slotName : !node.hasAttribute("slot");
|
|
56
|
+
}
|
|
57
|
+
return node.textContent ? node.textContent.trim() : false;
|
|
58
|
+
});
|
|
59
|
+
this.slotHasContent = textNodes.length > 0;
|
|
60
|
+
}
|
|
61
|
+
super.update(changedProperties);
|
|
62
|
+
}
|
|
63
|
+
firstUpdated(changedProperties) {
|
|
64
|
+
super.firstUpdated(changedProperties);
|
|
65
|
+
this.updateComplete.then(() => {
|
|
66
|
+
this.manageTextObservedSlot();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
_a = assignedNodesList;
|
|
71
|
+
__decorateClass([
|
|
72
|
+
property({ type: Boolean, attribute: false })
|
|
73
|
+
], SlotTextObservingElement.prototype, "slotHasContent", 2);
|
|
74
|
+
__decorateClass([
|
|
75
|
+
queryAssignedNodes(slotName, true)
|
|
76
|
+
], SlotTextObservingElement.prototype, _a, 2);
|
|
77
|
+
return SlotTextObservingElement;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=observe-slot-text.dev.js.map
|